Extension:PhpBB ShowTopic
From MediaWiki.org
|
phpBB_ShowTopic Release status: experimental |
|||
|---|---|---|---|
| Implementation | Tag | ||
| Description | Show phpBB topic inside Mediawiki's Pages | ||
| Author(s) | runey71 (Runey71Talk) | ||
| Last version | 0.1 | ||
| License | No license specified | ||
| Download | Extension:PhpBB_ShowTopic#Code Thos Version is Tested on phpBB 3.x 0.1 - Initial Release |
||
| Example | see Wiki | ||
|
|||
|
Check usage (experimental) |
|||
Contents |
[edit] What can this extension do?
This extension can show a pbpBB topic and a specified number of posts within MediaWiki.
[edit] Usage
<phpbb_topic>forumId|topicId|postLimit|bgColour</phpbb_topic>
- forumId = Unique ID of the forum containing the topic you wish to display
- topicId = Unique ID of the topic you wish to display
- postLimit = Maximum number of posts to display from the selected topic
- bgColour = Background colour ie: FEFAF3
[edit] Download instructions
Please cut and paste the code found below and place it in $IP/extensions/phpBB_ShowTopic/phpBB_ShowTopic.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/phpBB_ShowTopic/phpBB_ShowTopic.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
[edit] Code
<?php /* * Installation: * require_once("extensions/phpBB_ShowTopic/phpBB_ShowTopic.php"); in LocalSettings.php * update $phpbbDBSERVER, $phpbbDBUSER, $phpbbDBUSERPW, $phpbbDBNAME, $phpbbDBPrefix, $phpbb_home * Usage: * <phpbb_topic>forumID|topicID|postLimit|bgColour</phpbb_topic> * * @version 0.1 runey71 * * 0.1 - Initial Release * * http://www.mediawiki.org/wiki/Extension:phpBB_ShowTopic */ 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_ShowTopic'] = array( 'name' => 'phpBB Show Topic', 'version' => '0.1', 'author' => 'runey71, [http://www.mediawiki.org/wiki/User:Runey71]', 'description' => 'Link to Show phpBB Topic in MediaWiki', 'url' => '' ); $wgExtensionFunctions[] = "wfPHPBBExtension"; function wfPHPBBExtension() { global $wgParser; $wgParser->setHook( "phpbb_topic", "showTopic" ); } function showTopic( $input, $argv, &$parser) { $phpbbDBSERVER="Database Address"; $phpbbDBUSER="Username"; $phpbbDBUSERPW="Password"; $phpbbDBNAME="Database Name"; $phpbbDBPrefix="phpbb_"; $phpbb_home = "http://www.example.com/forum/"; # -------------------------------------------- //Disabling Cache $parser->disableCache(); //Split input in 2 Parameters list($forumID, $topicID, $postLimit, $bgColour) = 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 p.forum_id, p.topic_id, p.post_id, p.post_text FROM ". $phpbbDBPrefix ."topics AS t, ". $phpbbDBPrefix ."posts AS p WHERE p.forum_id = $forumID AND p.topic_id = $topicID ORDER BY p.post_id ASC LIMIT 0, $postLimit"; $qryres = mysql_query($sql); if (!$qryres) { return "<hr><b>Error while MySQL Query :". mysql_error() ;} $out = "<table width=\"100%\" 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: #$bgColour\"><td width=\"80%\">".$row[3]."</td></tr>"; } //End While $out = $out . "</table>"; mysql_free_result($qryres); return $out; } ?>
[edit] To Do
- Add BBCode Parser
- Improve layout
- What to do with URLs in topic posts that link back to other topic posts. Leave as is or turn into MediaWiki links?
- Check code and update to suit MediaWiki 1.15 or later (if not already)
