• Subscribe to this RSS feed
  • Receive updates as soon as they are posted.
  • Subscribe to this RSS feed
  • Receive updates as soon as they are posted.

Have you ever tried to put headers in MediaWiki and tried to edit them from page view? You might have been forwarded to template edit section instead of section edit. If you want to go to section edit section rather than template edit section then this small hack is for you.

here are the steps you have to perform:

1. open includes/Parser.php file from MediaWiki installed directory.

2. find the following line inside the formatHadings function.

# give headline the correct <h#> tag
if( $showEditLink && ( !$istemplate || $templatetitle !== “” ) ) {
if( $istemplate )
$editlink = $sk->editSectionLinkForOther($templatetitle, $templatesection);
else
$editlink = $sk->editSectionLink($this->mTitle, $sectionCount+1, $headline_hint);
} else {
$editlink = ”;
}
$head[$headlineCount] = $sk->makeHeadline( $level, $matches['attrib'][$headlineCount], $anchor, $headline, $editlink );

$headlineCount++;
if( !$istemplate )
$sectionCount++;

and replace with

if( $showEditLink && ( !$istemplate || $templatetitle !== “” ) ) {
$editlink = $sk->editSectionLink($this->mTitle, $sectionCount+1, $headline_hint);
} else {
$editlink = ”;
}
$head[$headlineCount] = $sk->makeHeadline( $level, $matches['attrib'][$headlineCount], $anchor, $headline, $editlink );

$headlineCount++;
$sectionCount++;

3. now save the file and test the feature.

you are all done to use this hack…

Note: The content is written for the “MediaWiki Administrators’ tutorial guide” book readers. So you will find some reference of the book here. Ignore those references if you do not have the book. You can download the PDF at the bottom of the article.

Sometime it might require for you to setup multiple MediaWiki site on the same server using the same source code. The reason behind using the same code base for multiple wiki is easy to maintain the changes. It is always easier to maintain a single thing rather than instances of the same thing. In order to accomplish this task you have to follow few simple methods.

1. Use same database server and same database with different tables or

2. Use same database server but different database or

3. Use different database server.

Before narrating the steps for achieving your target to setup multiple wiki using same source code, you have to know what will be the required things to consider before installing multiple wiki in a single server. First of all you need to separate the database configuration and other configuration (the configuration variables in LocalSettings.php file) into different files or separate them to work properly. The next important thing is to separate upload directory so that multiple wiki do not conflict in common files. Most of the time multiple wiki are required for multilingual purpose and in multilingual site same content is shown but in different language. There is a fair possibility that two wiki can have same image file name in use. In such case one will replace another. In order to avoid such unwanted circumstances, it is always better to separate the image folder for each wiki installation. The last thing to consider is the extensions that you are using for the existing wiki. You can make a common extension file and place all the extension to that file so that all the wiki instances share the common extensions. Now let me show you the ways you can make it work:

Let’s make it work:

In chapter two of the book you have learned how to install MediaWiki at your server. You also learned the fact that you have to move the LocalSettings.php file in the root folder for the installation to work. Now here are steps to apply.

1. Rename your existing LocalSettings.php file to Wiki_one_settings.php or anything you want to.

2. Now open a browser window and type your URL location for the wiki. If your URL is http://www.mywiki.com then try to browse the http://www.mywiki.com/config/ .

3. You will be taken to the installation page same as described in chapter 2. You have to follow the same steps until the database configuration section. As you know you can choose the same database but different prefix for new installation or you can choose a new database name for the new installation or even choose a new server located in some other place for the new installation. Here is the place you have to enter the database information.

4. If you want to use the same database but different tables then we gave to add database table prefix in the colored region of the image. You can add any prefix for the new tables. If you wan to add new database then add database name in the database name field.

5. After putting all required information, click the install button to install new instance of MediaWiki. A new instance of the MediaWiki database has been added to the database server according to your chosen method and a new LocalSettings.php file is also created in the Config folder. Like you did in chapter two, you have to place this file in the root folder. But you have to play another little trick here. Since it is used for second wiki, we have to rename the file as Wiki_two_settings.php (or any name that you want to) and then you can place it in the root folder.

6. Now you have two settings file Wiki_one_settings.php and Wiki_two_settings.php but no LocalSettings.php file. So you have to create a file named LocalSettings.php. You can have two scenarios over here:

a. First of all you can have wikis are in different directories or sub domains linked to the same directory on our server

b. We have different domains that link to one directory on your server

For the first scenario we have to write the following code and save it as LocalSettings.php.

<?php
 
$callingURL = strtolower($_SERVER['REQUEST_URI']); //the requesting url
        
if ( strpos( $callingURL, 'wikione') ) {
        require_once('Wiki_one_settings.php');    
}
else if ( strpos( $callingURL, 'wikitwo') ) {
        require_once('Wiki_two_settings.php' );    
}
 
?>

For the second scenario we have to write the following code and save it as LocalSettings.php

<?php
$callingURL = strtolower($_SERVER['SERVER_NAME']);
 
$pos = strpos( $callingURL, ‘firstwiki’); //e.g. www.firstwiki.com
  
if ( $pos === false ) {
        require_once('Wiki_two_settings.php');    
}
else
{
        require_once('Wiki_one_settings.php');
}
?>

Now you run the wiki and see the different wiki using the same source code. If your site address is www.mywiki.com then browse www.mywiki.com/wikione/ and also www.mywiki.com/wikitwo/ . You will find the difference by yourself.

Note: To link the sub domains to the server, you might need to edit the configuration file of the server or change the DNS configuration of the site.

 

Setting Different Image directory:

If you want to set different upload directory for each wiki installation, you can do that too. Just define the upload directory on each of the LocalSettings.php file for each wiki. First you have to make sure that the file upload option is enabled. Then add the following line at the end of the LocalSettings.php file.

For example for the first wiki you have to write the following line

$wgUploadDirectory = “{$IP}/images”;

And for the second wiki you can use different directory

$wgUploadDirectory = “{$IP}second_/images”;

Now save the file and access the pages. We are all done with setting different image directory for each wiki.

Sharing common resources:

Sometime it might be required for you to share files and extensions for your wiki installation. For creating a shared directory we have to write the following lines from DefaultSettings.php to LocalSettings.php file for each LocalSettings.php file.

$wgUseSharedUploads = true;

$wgSharedUploadPath = ‘http://yourwikiname/images’;

$wgSharedUploadDirectory = ‘/(LOCALPATH)/Folder Name/images/’;

$wgHashedSharedUploadDirectory = true;

In order to share common extensions first you need to copy all the extensions inclusion to a common file. You can name the file anything you want to. Now include the common extension file in every LocalSettings.php file you have created. So if you need to add/remove any extension you just have to edit the common extension file not every settings file.

This way you can integrate multiple wiki using the same code base. You can play around with the LocalSettings.php file as you can put some kind of switching command instead of creating separate setting files. The way is shown and you can apply your knowledge for something better.

Note: if you are looking for more references then you can look at the following sites. They are very well explained.

http://www.steverumberg.com/wiki/index.php/WikiHelp

http://www.mediawiki.org/wiki/Manual:Wiki_family

[Download PDF]

I got my Book on hand!!!!!!!

April 25 , 2007 In: Me, MediaWiki, PHP, Packt Publishing

After waiting for a month, finally i got the printed copy of my book on my hand. It’s a feeling that i can’t express in few words. Though i was baffled by the wrong address posting of the book byPackt, but finally it arrived to the right place.

The book just look awesome to me. I wish the people also find it useful and interesting.
I am now anxiously waiting for few reviews from the readers to know the actual reaction from my audience.

Code Igniter: Installation and First Run

March 23 , 2007 In: Code Igniter

Code Igniter is an PHP Application Development Framework - a toolkit for PHP developers. The main goal of Code Igniter is to enable developers to develop projects much faster than they could have done ( if they have started from scratch) by providing a rich set of libraries for commonly needed tasks, as well as a simple interface and logical structure to access these libraries.

You can download Code Igniter from http://www.codeigniter.com/

How to Install:

1. Download the zip file from the above URL.

2. unzip the files and put them to your webserver where you want to. lets assume that you put it at codeigniter folder of your web server.

3. Open the application/config/config.php file with a text editor and set your base URL. lets asumme that your base URL is set like this:

$config['base_url'] = “http://localhost/codeigniter/”;

4. if you intend to use a database, open the application/config/database.php file with a text editor and set your database settings. Set the following variables according to your setup.

$db['default']['hostname'] = “localhost”;
$db['default']['username'] = “admin”;
$db['default']['password'] = “*****”;
$db['default']['database'] = “projectone”;
$db['default']['dbdriver'] = “mysql”;
$db['default']['dbprefix'] = “”;
$db['default']['active_r'] = TRUE;
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = “”;

5. now you are ready to run our installed piece of software. in order to run Code Igniter you have to visit the following URL in you web server.

http://localhost/codeigniter/index.php/

if your setup is correct then you will see a welcome page with heading

“Welcome to Code Igniter!”

Now you are ready to work with Code Igniter.

Note: if you try to access the Code Igniter installation like the following then you will definitely get an error message.

http://localhost/codeigniter/

http://localhost/codeigniter/index.php

By default Code Igniter follows (Search Engine Friendly (SEF) URL and for this they use segment based URL which will come to next tutorial.

MediaWiki - Nice to have

March 23 , 2007 In: MediaWiki

So far the journey of wiki has been very pleasant to me. I liked the wiki concept and technology it focuses. Mediawiki comes with lots of features and extensions which are really cool. But still i feel that there should be some very good features included in future MediaWiki. Here are my few thoughts:
1. More security options, such as section based protection. currently mediawiki have the option to protect a page not a section. we know in multi user environment many people can contribute their part in a single article. there might be the necessity to protect individual contribution rather than the complete page.

2. The wiki editor can be enhanced little bit to add few more options to make life bit easier. It is not right to expect an end user will know the complete wiki syntax to use it appropriately. May be a WYSIWYG in wiki mode will be good choice.
3. Article save and publish option. currently wiki does not have the ability to save an incomplete article. this option will really help the writers to write articles and publish them once its complete.  It will be also nice to have an auto draft options for articles. so that nothing is lost accidentally.

4. an integrated comments system for the article. it can be kept as an option in the article edit section and will be shown in the view of the article page.

5. last but not least , more of a web 2.0 featured. it will be really cool to load contents dynamically using AJAX and give it a look and feel of a web 2.0 site.

Today my book has been published. It has been a long waiting for me. Finally it’s on the hands of the readers. I can’t wait to receive my copies. Lets hope that it will be well accepted by readers.

here are few pics from David, my development editor at Packt Publishing.

David with the book

David with the book

My Interview has been posted

March 15 , 2007 In: Me, MediaWiki, Packt Publishing

Today my interview has been posted to a blog in Netherlands. Marcel de Ruiter maintains the weblog named Shaping Thoughts. It was very nice to know about him personally and i hope we will share our thougths to shape up something new. Here is the full interview you can read….

http://www.shapingthoughts.com/2007/03/15/interview-with-mizanur-rahman-author-of-mediawiki-administrators-tutorial-guide

QEDwiki

March 2 , 2007 In: New Tech, PHP, Web

Have you ever thought how it will be if our traditional wiki is bundled with cutting edge Web 2.0 features such as Mashups and rich web experience to end user with different web services bundle together in a single place. well if you have not then you have all rights to think about it. Because IBM is preparing to launch its new product named “QEDwiki” and the first impression i got from the youtube session is just awsome. that is what IBM says about QEDWiki

“QEDWiki is a lightweight mash-up maker written in PHP 5 and hosted on a LAMP, WAMP, or MAMP stack. A mash-up assembler will use QEDWiki to create a personalized, ad hoc Web application or mash-up by assembling a collection of widgets on a page, wiring them together to define the behavior of the mash-up application, and then possibly sharing the mash-up with others. Mash-up enablers provide QEDWiki with a collection of widgets that provide application domain- or information-specific functionality. These widgets are represented within QEDWiki as PHP scripts.

When a user renders a page within a QEDWiki workspace, the QEDWiki framework processes the widgets on the server side and then generates a DHTML page that is sent to the browser for client-side processing. The framework includes a rich AJAX-enabled MVC (Model-View-Controller) architecture so that each wiki page is a rich, interactive application for end users.”

here you can find more about QEDwiki.

http://services.alphaworks.ibm.com/qedwiki/

and for the youtube video, click here

MediaWiki Extension - WhosOnline

February 23 , 2007 In: MediaWiki

This extension is the popular “Whos Online extension” of ChekMate Security Group(http://www.chekmate.org/). This extension is modified version in order to make it work with MediaWiki version 1.8.2 and above. In order to work it with previous versions earlier than 1.8.2 , please visit their site to download the code.

URL: http://www.chekmate.org/wiki/index.php/MW:_Whos_Online_Extension

here are the steps that you have to perform to make this extension work.

1. Add one new table in your database, named online. If database uses a prefix, then add the prefix before the table name. Here is the SQL code for creating the table:

CREATE TABLE `online` (

`userid` int(5) NOT NULL default ‘0′,

`username` varchar(255) NOT NULL default ”,

`timestamp` varchar(255) NOT NULL default ”

) TYPE=MyISAM;

2. Download the code below and Save the following in your ./extensions/ directory

<?php
# WhosOnline Mediawiki extension
#
# by Shannon McNaught 22.06.2006
# http://www.chekmate.org/wiki/index.php/Projects

# Installation:
#  * Add new table to your wikidb.
#  * put this file (WhosOnline.php) into the extension directory of your mediawiki installation
#  * add the following to the end of LocalSettings.php: include("extensions/WhosOnline.php");
#
# Example:
#    <whosonline></whosonline>
#

#install extension hook
$wgExtensionFunctions[] = "wfWhosOnlineExtension";

#extension hook callback function
function wfWhosOnlineExtension() {
  global $wgParser;

  #install parser hook for <rss> tags
  $wgParser->setHook( "whosonline", "renderWhosOnline" );
}

#parser hook callback function
function renderWhosOnline( $input, $arge, &$parser ) {
  global $wgUser, $wgDBprefix,$wgVersion,$wgOut;
  global $wgOutputEncoding;

  $dbr =& wfGetDB( DB_SLAVE );

  // ###### INVALIDATE CACHE ######
  global $wgTitle;
  $ts = mktime();
  $now = gmdate("YmdHis", $ts + 120);
  $ns = $wgTitle->getNamespace();
  #$ti = wfStrencode($wgTitle->getDBkey());
  $ti = $wgTitle->getDBkey();
  $version = preg_replace("/^([1-9]).([1-9]).*/", "\1\2", $wgVersion);
  if ($version>14) $sql = "UPDATE $wgDBprefix"."page SET page_touched='$now' WHERE page_namespace=$ns AND page_title='$ti'";
  else             $sql = "UPDATE $wgDBprefix"."cur SET cur_touched='$now' WHERE cur_namespace=$ns AND cur_title='$ti'";
  #wfQuery($sql, DB_WRITE, "");
  $dbr->query( $sql );

  $timeperiod = 3600; # number of seconds

  $DefaultEncoding = "ISO-8859-1";
  $DisableCache = true;
  $ts = mktime();
  $now = gmdate("YmdHis", $ts);
  $old = gmdate("YmdHis", $ts-$timeperiod);
  $userid = $wgUser->getID();
  $username = $wgUser->getName();
  $tblname = $wgDBprefix."online";

  $sql = "DELETE from $tblname WHERE username = '$username' OR timestamp < '$old' ";
  $db =& wfGetDB( DB_WRITE );
  if ( $db !== false ) {
    $ret = $db->query( $sql, '', true );
  }
  else {
    $ret = false;
  }
  if ( false === $ret ) {
    $sql =
      "CREATE TABLE $tblname (
      `userid` int(5) NOT NULL default '0',
      `username` varchar(255) NOT NULL default '',
      `timestamp` varchar(255) NOT NULL default ''
      ) TYPE=MyISAM ";
    #$ret = wfQuery($sql, DB_WRITE, "");
    $ret = $dbr->query( $sql );
  }

  $sql = "INSERT INTO $wgDBprefix"."online (userid,username,timestamp) VALUES ('$userid','$username','$now')";
  $output = $sql;
  #wfQuery($sql, DB_WRITE, "");
  $dbr->query( $sql );
  $sql = "select * from $wgDBprefix"."online where userid = 0";
  $dbr =& wfGetDB( DB_SLAVE );

  $res = $dbr->query ( $sql ) ;
  $guests = $dbr->numRows($res) + 0;
  $sql = "select username from $wgDBprefix"."online where userid != 0";
  $res = $dbr->query ( $sql ) ;
  $registered = $dbr->numRows($res) + 0;
  $Userlist ="";
  while( $row = $dbr->fetchObject( $res ) ){
    $Userlist .= " [[User:".$row->username."|".$row->username."]] ";
  }
  $dbr->freeResult( $res );

  $output = "Guests: $guests Registered: $registered ($Userlist)";

#return $output;
#return $wgOut->parse($output,false);
$localParser = new Parser();
$parserOutput =  $localParser->parse( $output, $parser->mTitle, $parser->mOptions, false );
return $parserOutput->getText();
}

?>

3. Add the following to the end of LocalSettings.php:

require_once("extensions/WhosOnline.php");

4. Add the following code in your wiki page:

<b>Users Online</b>: <whosonline></whosonline>

 

Now save the page and view it in browser. You are done.

My First Book….

February 21 , 2007 In: Me, MediaWiki, Packt Publishing

Today I received the cover page of my first book “MediaWiki Administrators’ Tutorial Guide” from Packt Publishing. I knew it is going to publish at the end of February or early march and was expecting to see the cover of the book beforehand. Adding to my surprise I was invited by Nikhil to discuss the cover page of my book. I am an amateur photographer and I was willing to contribute to the cover image of the book. Akshara (my technical editor) and Nikhil, both remembered the word ‘photographer’ from me and they wanted to have my thoughts on the cover image. I sent them one of my taken pictures and was not sure it will make any impact on the book cover. Next morning I woke up from bed and read the mail from Nikhil that my picture had been chosen for my book. It was really a surprising moment for me as I relish my biggest success as a photographer. I hope others like the picture too as well as the book. Now I am counting the days when I will received the email from Packt with the confirmation that the book has been published.

About Me


I am Mizanur Rahman from Bangladesh. I am a Software Engineer by profession. I love to work on open source projects and specially web based systems. I am a moderator of the PHPExperts, the largest PHP Users group in Bangladesh.

My Books

MediaWiki Administrators’ Tutorial Guide

My Certifications


My Zend Certification


View Mizanur Rahman's profile on LinkedIn

Categories