User:EdK/The Pit of Doom and Damnation/P1: wBlog
From Simpedia
wBlog... small, progressively more complicated blog extension for MediaWiki...
It works really well actually, although inclusion (intended purpose...) seems to break normal inclusions on pages.
Note: This source is old. I will update it when the working version of the program is ready for complete release (not just bits of it)
[edit] Source (partial!) of wBlog_body.php
<?php function execute( $par ) { global $wgRequest, $wgOut, $wgUser, $wgTitle; if($par != '') { $useTags = true; } $this->setHeaders(); /////////////////////////// // CODE BLOCK HIDDEN // /////////////////////////// if($useTags) $wTags = wfMsg('wBlog-tagged'); { if ( $wgUser->isAllowed( 'blogger' ) ) $showPostTools = true; $dbw =& wfGetDB( DB_MASTER ); $par = htmlspecialchars($par); if($useTags) { $res = $dbw->query("SELECT * FROM `wBlog` WHERE `blog_tag` = '$par' ORDER BY `blog_id` DESC LIMIT 0,10"); } else { $res = $dbw->query("SELECT * FROM `wBlog` ORDER BY `blog_id` DESC"); } while( $s = $dbw->fetchObject( $res ) ) { $wBlogName = htmlspecialchars( $s->blog_title ); $wAuthorName = htmlspecialchars( $s->blog_author ); $wBlogBody = $s->blog_body; $wBlogTag = $s->blog_tag; /////////////////////////// // CODE BLOCK HIDDEN // /////////////////////////// if(!$useTags || $par == $wBlogTag) { $wgOut->addWikiText("$wBlogName$wTagText - <small>$wPosted $wAuthorName</small><br>$wBlogBody<br>"); $wgOut->addHTML("<hr />"); } } $wgOut->addWikiText('<small>[http://simpedia.co.uk/index.php/Simpedia:WBlog wBlog] by [http://simpedia.co.uk/EdK EdK of Simpedia]</small>'); if($showPostTools) { $wgOut->addHTML("<br /><big>$wPostYours</big><form method=post action=\"$action\"> <table> <tr> <td align='right'>$wTitle </td> <td align='left'><input type='text' size='20' name='btitle' value=\"\" /></td> </tr> <tr> <td align='right'>$wTags </td> <td align='left'><input type='text' size='20' name='btags' value=\"$par\" /></td> </tr> <tr> <td colspan=2><textarea name='body'>$wText</textarea></td> </tr> <tr> <td>$wReloadNote</td> <td align='right'><input type='submit' name='submit' value=\"$wSubmit\" /></td> </tr> </table> <input type='hidden' name='token' value='$wToken' /> </form>"); if ( !$wgRequest->wasPosted() || !$wgUser->matchEditToken( $wgRequest->getVal( 'token' ) ) ) return; /////////////////////////// // CODE BLOCK HIDDEN // /////////////////////////// $dbw->insert('wBlog', array( '`blog_id`'=> $id, '`blog_author`' => $wgUser->getName(), '`blog_body`' => $wgRequest->getText('body'), '`blog_tag`' => $wgRequest->getText('btags'), '`blog_title`' => $wgRequest->getText('btitle') ) ); } return true; } } ?>
