Extension:My blog/SpecialPagesAllBlogs.php

From MediaWiki.org

Jump to: navigation, search

The script is part of the My blog extension, go to My blog for full details on how to install this extension.

<?php
$wgExtensionFunctions[] = "loadSpecialListAllBlogs";
require_once("includes/SpecialPage.php");
 
class SpecialListAllBlogs extends SpecialPage {
 
        function SpecialListAllBlogs() {
                SpecialPage::SpecialPage('ListAllBlogs', '', false);
                $this->includable(true);
        }
 
        function execute( $parent = null ) {
                global $wgRequest, $wgOut, $wgUser;
                $wgOut->setArticleRelated( false );
                $fname = 'listallblogs';
 
 
                // Handle Errors
                $target = $this->including() ? $wgRequest->getVal( 'title' ) :
                                (isset( $parent ) ? $parent : $wgRequest->getVal( 'target' ));
 
                if (is_null($target)) {
 
 
                        return;
                }
 
                $target = Title::newFromURL( $target );
                $skin = $wgUser->getSkin();
#                if (!$this->including()) {
                        // Start Page
 
                 $wgOut->setPagetitle("Most Recent Blogs" );
                 $wgOut->addWikiText("__NOTOC__");
 
 
#                        $wgOut->addHTML('< ' . $skin->makeKnownLinkObj($target, '', '' ) . "<br />\n");
#                }
 
                // Do query
                list($limit, $offset) = $wgRequest->getLimitOffset();
                $dbr =& wfGetDB( DB_READ );
                $limit = 10;
                $offset = 0;
 
                $result = $dbr->select( 'page' ,
                                array( 'page_namespace', 'page_title', 'page_touched' ),
                                array(  'page_namespace' => '2',
                                        "page_title LIKE '%BlogEntry%'"),
                                        $fname,
                                        array( 'ORDER BY'=>'page_touched DESC',  'LIMIT' => "$offset,$limit" ) );
 
                // Output results
                if ( 0 == $dbr->numRows( $result ) ) {
                  $d = date( 'Y F d H:i:s T' );
                  $wgOut->addWikiText("Currently No Blog Entries.");
                  return;
                }
 
 
                $rows = array();
 
                $d = date( 'Y F d H:i:s T' );
 
                while ($row = $dbr->fetchObject($result)) {
                    $wgOut->addHTML('<table width=100% border=1 cellpadding=5 cellspacing=0 ><tr><td>');
                    $link = Title::makeTitle( $row->page_namespace, $row->page_title);
 
                    list($user1,$date1) = explode("/BlogEntry:_",$row->page_title,2);
                    $date1 = preg_replace('/_/', ' ', $date1);
                    $wgOut->addHTML("<table width=100%><tr><td align=left><font size=4><a href=\"/wiki/index.php/User:". $row->page_title ."\">$date1</a></font><br>Posted By: <a href=\"/wiki/index.php/User:$user1\">$user1</a></td><td valign=top align=right><a href=\"/wiki/index.php/User_talk:". $row->page_title ."\">Discussion</a><br><a href=\"/wiki/index.php/Special:ListSubPages/User:$user1\">$user1's Blog</a><td></tr></table>");
 
                    $tempvalue = "{{:User:" . $row->page_title . "}}";
                    $wgOut->addWikiText($tempvalue);
                    $wgOut->addHTML("<table width=100%><tr><td align=right>Blog Entry: ".$skin->makeKnownLinkObj($link)."</td></tr></table>");
 
                    $wgOut->addHTML('</td></tr></table><p>');
                }
 
                $dbr->freeResult($result);
                $wgOut->addHTML($prevnext);
        }
}
 
 
function loadSpecialListAllBlogs()
{
        SpecialPage::addPage(new SpecialListAllBlogs);
}
 
?>

By Smcnaught - I am also available on irc.chekmate.org #MediaWiki

Personal tools