Extension:TotalRevisions

From MediaWiki.org

Jump to: navigation, search
Manual on MediaWiki Extensions
List of MediaWiki Extensions
TotalRevisions

Release status: beta

Implementation Variable
Description Variable to get the total number of revisions for the current page.
Author(s) MinuteElectron
MediaWiki 1.11
Download #Source Code
#Change Log
Hooks used

LanguageGetMagic
ParserGetVariableValueSwitch
MagicWordwgVariableIDs

The TotalRevisions extension returns the total number of revisions on the current page.

Contents

[edit] Installation

  1. Place the source code into (extensions/TotalRevisions/TotalRevisions.php).
  2. Add require_once( "extensions/TotalRevisions/TotalRevisions.php" ); to LocalSettings.php.
  3. Enjoy!

[edit] Usage

Add {{TOTALREVISIONS}} to a page you want to view the total revisions of.

[edit] Source code

[edit] TotalRevisions.php

<?php
 
# Not a valid entry point, skip unless MEDIAWIKI is defined
if( !defined( "MEDIAWIKI" ) ) {
        die( "Invalid entry point." );
}
 
define( "MAG_TOTALREVISIONS", "totalrevisions");
 
$wgHooks[ "LanguageGetMagic" ][] = "wfTotalRevisionsDefine";
function wfTotalRevisionsDefine( &$aWikiWords, &$langID ) {
        $aWikiWords[ MAG_TOTALREVISIONS ] = array( 0, "TotalRevisions" );
        return true;
}
 
$wgHooks[ "ParserGetVariableValueSwitch" ][] = "wfTotalRevisionsAssign";
function wfTotalRevisionsAssign( &$parser, &$cache, &$magicWordId, &$ret ) {
        if( MAG_TOTALREVISIONS == $magicWordId ) {
                global $wgTitle;
                $dbr =& wfGetDB( DB_SLAVE );
                $ret = $dbr->estimateRowCount( "revision", "*", array( "rev_page" => $wgTitle->getArticleID() ) );;
                return true;  
        } else {
                return false;
        }
}
 
$wgExtensionCredits[ "variable" ][] = array(
        "name" => "TotalRevisions",
        "description" => "Get the total number of revisions of the current page.",
        "author" => "MinuteElectron",
        "url" => "http://www.mediawiki.org/wiki/Extension:TotalRevisions",
        "version" => "1.1",
);
 
$wgHooks[ "MagicWordwgVariableIDs" ][] = "wfTotalRevisionsDeclare";
function wfTotalRevisionsDeclare( &$aCustomVariableIds ) {
        $aCustomVariableIds[] = MAG_TOTALREVISIONS;
        return true;
}

[edit] Change log

Version Release date Comments
1.1 2007-12-17 Original version.

[edit] Known bugs

  1. When used in conjunction with some other magic word extensions neither of the magic words function, but works fine on it's own.

[edit] To do

  • Internationalise the magic word name.
Personal tools