Extension:PHPBB ShowForum
|
PHPBB_ShowForum Release status: experimental |
|||
|---|---|---|---|
| Implementation | Tag | ||
| Description | Show your PHPbb post inside Mediawiki's Pages | ||
| Author(s) | Marcolino (Marcolino7Talk) | ||
| Last version | 0.2 | ||
| License | No license specified | ||
| Download | Extension:PHPBB_ShowForum#Code Thos Version is Tested on PHPbb 2.x 0.1 - Basic support to PHPbb 2.x, 0.2 Disabled Cache and Icon Path |
||
| Example | see Gestione Acquario's Wiki | ||
|
|||
|
Check usage (experimental) |
|||
Contents |
[edit] What can this extension do?
This extension can show PHPbb's List of Topic with Username and Datetime.
[edit] Usage
<phpbb_forum>a|b|c</phpbb_forum>
- a = Forum ID
- b = Number of post to show
- c = Backgound Color ie: FEFAF3
You can also view multiple forum. This make possible with parameter a. In example to show forum 1, 4 and 5 the tag is:
<phpbb_forum>'1','4','5'|5|FEFAF3</phpbb_forum>
In this case a = '1','4','5'
[edit] Download instructions
Please cut and paste the code found below and place it in $IP/extensions/PHPBB_ShowForum/PHPBB_ShowForum.php. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.
[edit] Installation
To install this extension, add the following to LocalSettings.php:
require_once("$IP/extensions/ExtensionName/ExtensionName.php");
[edit] Configuration parameters
Inside PHPBB_ShowForum.php you have to change this parameter in according with your forum configuration:
$phpbbDBSERVER= MySQL Host $phpbbDBUSER= MySQL User $phpbbDBUSERPW= MySQL Password $phpbbDBNAME= MySQL Database Name $phpbbDBPrefix="phpbb_" PHPbb's Table prefix (Usually no changes needed) $phpbb_home = "http://www.yoursite.com/forum/" Full Address of your forum $phpbb_icon_path = "templates/subSilver/images/folder.gif" path of the icon
[edit] Code
<?php /* * Installation: * require_once("extensions/PHPBB_ShowForum/PHPBB_ShowForum.php"); in LocalSettings.php * update $phpbbDBSERVER, $phpbbDBUSER, $phpbbDBUSERPW, $phpbbDBNAME, $phpbb_home, $phpbb_icon_path * Usage: * <phpbb_forum>forumID|Number of post|Background Color</phpbb_forum> * * @version 0.2 marcolino7 * * 0.2 - Added Path for the Icon * Disabled Caching * 0.1 - Initial Release * * http://www.mediawiki.org/wiki/Extension:PHPBB_ShowForum */ if( !defined( 'MEDIAWIKI' ) ) { echo( "This is an extension to the MediaWiki package and cannot be run standalone.\n" ); die( -1 ); } // Extension credits that will show up on Special:Version $wgExtensionCredits['parserhook']['PHPBB_ShowForum'] = array( 'name' => 'PHPBB Show Forum', 'version' => '0.2', 'author' => 'marcolino7, [http://www.mediawiki.org/wiki/User:Marcolino7]', 'description' => 'Link to Show PHPBB Forum in MediaWiki', 'url' => '' ); $wgExtensionFunctions[] = "wfPHPBBExtension"; function wfPHPBBExtension() { global $wgParser; $wgParser->setHook( "phpbb_forum", "showForum" ); } function showForum( $input, $argv, &$parser) { $phpbbDBSERVER="Database Address"; $phpbbDBUSER="Username"; $phpbbDBUSERPW="Password"; $phpbbDBNAME="Database Name"; $phpbbDBPrefix="phpbb_"; $phpbb_home = "http://www.yoursite.org/forum/"; $phpbb_icon_path = "templates/subSilver/images/folder.gif"; # -------------------------------------------- //Disabling Cache $parser->disableCache(); //Split input in 2 Parameters list($forumID, $postLimit,$bgColor) = split('[|.-]', $input); $link = mysql_connect($phpbbDBSERVER,$phpbbDBUSER ,$phpbbDBUSERPW); if ( !$link ) { return "<hr><b>Error while connecting to host \"$phpbbDBSERVER\" !</b><hr>"; } $db_selected = mysql_select_db($phpbbDBNAME, $link); if (!$db_selected) {return "<hr><b>Error while selecting database \"$phpbbDBNAME\" !</b><hr>"; } $sql = "SELECT t.topic_title, p.topic_id, t.topic_last_post_id, p.post_time, f.forum_name, f.forum_id, u.username, u.user_id, p.post_username, u2.username as user2, u2.user_id as id2 FROM ". $phpbbDBPrefix ."topics AS t, ". $phpbbDBPrefix ."forums AS f, ". $phpbbDBPrefix ."posts AS p, ". $phpbbDBPrefix . "users AS u, ". $phpbbDBPrefix . "users AS u2 WHERE f.forum_id = t.forum_id AND t.topic_poster = u.user_id AND p.post_id = t.topic_last_post_id AND p.poster_id = u2.user_id AND t.topic_moved_id = 0 AND f.forum_id in ( $forumID ) ORDER BY t.topic_last_post_id DESC LIMIT 0, $postLimit"; $qryres = mysql_query($sql); if (!$qryres) { return "<hr><b>Error while MySQL Query :". mysql_error() ;} $out = "<table width=\"80%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\">"; $row_count = 0; //Cycle inside recordset and populate page while ($row = mysql_fetch_row($qryres)) { $out = $out . " <tr style=\"background-color: #$bgColor\"> <td width=\"2%\" valign=\"top\"><img src=\"".$phpbb_home.$phpbb_icon_path."\" width=\"19\" height=\"18\" ></td> <td width=\"80%\"><strong> <a href=\"".$phpbb_home."viewtopic.php?t=".$row[1]."#".$row[2]."\" class=\"external text\" >".$row[0]."</a> </strong> <div style=\"font-size: x-small; font-family: \"Courier New\", Courier, monospace;\">from <a href=\"profile.php?mode=viewprofile&u=".$row[7]."\">".$row[6]."</a> on ".date("D, d M Y H:i",$row[3])."</div> </td> </tr>"; } //End While $out = $out . "</table>"; mysql_free_result($qryres); return $out; } ?>
