User:Suki

From ChekMate Security Group

I felt it would be a helpfull idea to add my experiences in installing the MW: my blog extension found on this site.

I have to say the code works quite well however the descriptions on the page and in the discussion was a bit difficult to follow.

Here is my step by step notes on how I installed MW: my blog on a MediaWiki version 1.9.3 site.

The core of MW: my blog is made of two extensions. There also has been some changes in MediaWiki since the MW: my blog extension was made. Reading the discussion there are a few things that need to be done to get it working with (at least) version 1.9.3.

Shameless Plug: See Extension:Read Restrict for more contributions I've made.

Contents

Install the core

The two main extensions are SpecialPageSubPages.php and SpecialPagesAllBlogs.php (I don't know why they are called that).

Copy and paste the above code into there respective files and save them to your extensions directory.

Then add the proper includes to your LocalSettings.php file:

require_once ("extensions/SpecialPageSubPages.php");
require_once ("extensions/SpecialPagesAllBlogsphp");

Applying patches

Below is a patch file comprising of the two main bug fixes described in the discussion

Most systems have a patch program (Not including Windows ... of course). Copy and Paste the diff below into a file and run it through patch while in the extensions directory. Gnuwin32 has Patch for Windows.

prompt$ patch -l -p0 < blog_patch.diff

diff

--- SpecialPageSubPages.php~	2007-03-18 00:28:07.000000000 -0400
+++ SpecialPageSubPages.php	2007-03-18 18:15:04.000000000 -0400
@@ -10,7 +10,8 @@
         }
 
         function execute( $parent = null ) {
-                global $wgRequest, $wgOut, $wgUser;
+                global $wgRequest, $wgOut, $wgUser, $wgScript;
+		$wgOut->setArticleRelated( false );
                 $fname = 'listsubpages';
 
 
@@ -47,7 +48,7 @@
                                 array(  'page_namespace' => $target->getNamespace(),
                                         "page_title LIKE " . $dbr->addQuotes($target->getDbKey() . '/%') ),
                                 $fname,
-                                        array( 'ORDER BY'=>'page_touched DESC','LIMIT' => "$offset,$limit" ) );
+                                        array( 'ORDER BY'=>'page_touched DESC', 'LIMIT' => $limit, 'OFFSET' => $offset ) );
 
                 // Output results
                 $wgOut->addWikiText('= ' . $target->getDbKey() . '\'s Blog =');
@@ -81,7 +82,7 @@
 
                     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>");
+                    $wgOut->addHTML("<table width=100%><tr><td align=left><font size=4><a href=\"$wgScript/User:". $row->page_title ."\">$date1</a></font><br>Posted By: <a href=\"$wgScript/User:$user1\">$user1</a></td><td valign=top align=right><a href=\"$wgScript/User_talk:". $row->page_title ."\">Discussion</a><br><a href=\"$wgScript/Special:ListSubPages/User:$user1\">$user1's Blog</a><td></tr></table>");
 
                     $tempvalue = "{{:User:" . $row->page_title . "}}";
                     $wgOut->addWikiText($tempvalue);
--- SpecialPagesAllBlogs.php~	2007-03-18 01:16:45.000000000 -0400
+++ SpecialPagesAllBlogs.php	2007-03-31 03:03:23.000000000 -0400
@@ -10,7 +10,8 @@
         }
 
         function execute( $parent = null ) {
-                global $wgRequest, $wgOut, $wgUser;
+                global $wgRequest, $wgOut, $wgUser, $wgScript;
+		$wgOut->setArticleRelated( false );
                 $fname = 'listallblogs';
 
 
@@ -47,7 +48,7 @@
                                 array(  'page_namespace' => '2',
                                         "page_title LIKE '%BlogEntry%'"),
                                         $fname,
-                                        array( 'ORDER BY'=>'page_touched DESC',  'LIMIT' => "$offset,$limit" ) );
+                                        array( 'ORDER BY'=>'page_touched DESC',  'LIMIT' => $limit, 'OFFSET' => $offset ) );
 
                 // Output results
                 if ( 0 == $dbr->numRows( $result ) ) {
@@ -67,7 +68,7 @@
 
                     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>");
+                    $wgOut->addHTML("<table width=100%><tr><td align=left><font size=4><a href=\"$wgScript/User:". $row->page_title ."\">$date1</a></font><br>Posted By: <a href=\"$wgScript/User:$user1\">$user1</a></td><td valign=top align=right><a href=\"$wgScript/User_talk:". $row->page_title ."\">Discussion</a><br><a href=\"$wgScript/Special:ListSubPages/User:$user1\">$user1's Blog</a><td></tr></table>");
 
                     $tempvalue = "{{:User:" . $row->page_title . "}}";
                     $wgOut->addWikiText($tempvalue);

Adding the link to the user bar

It is suggested in the Talk page that to add a link to the upper right hand toolbar (where my talk and my preferences are) that you edit the template/SkinTemplate.php code and add it. Although this may be the simple solution it is not one that upgrades well. I don't know when MediaWiki added the PersonalUrls hook but it works well in this case and is forward compatible.

All you do is add the extension shown below to your extensions folder and include the following line into your LocalSettings.php file (after the includes you used above).

require_once ("extensions/CustomAddBlogToolbarLink.php");

CustomAddBlogToolbarLink.php

<?php
define ('MYBLOG_LINKTEXT', "my blog");

function wfAddBlogToToolbar( $toolbar, $title )
{
    global $wgUser;
    $name = $wgUser->getName();
    $skin = $wgUser->getSkin();
    $blog_array = array (
	'text' => MYBLOG_LINKTEXT,
	'href' => $skin->makeSpecialUrl ("ListSubPages/User:$name")
    );
    // Force the new link right after the first element.
    // In current releases this *should* be the userpage link.
    array_splice ($toolbar, 1, 0, array('myblog' => $blog_array));
}

$wgHooks['PersonalUrls'][] = 'wfAddBlogToToolbar';
?>

Adding the blog display to the rest of the site

Adding some links to the side bar isn't to difficult. However to include a dynamic list on your Main Page you must install yet another extension.

Sidebar

The extension uses some templates internally so you must define them.

Most Recent Blogs
Special:ListAllBlogs/
** recentblog-url|recentblog

That should add Most Recent Blogs to your side bar.

Main Page

Go and install the Dynamic Article List extension into your extensions directory and include it in your LocalSettings.php file:

require_once ("extensions/DynamicArticleList.php");

Then add the following code to your Main Page:

<DynamicArticleList>
  title=new Blog Entries
  type=blog
  count=10
</DynamicArticleList>