Extension:TotalRevisions

From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
OOjs UI icon alert-warning.svg
TotalRevisions
Release status: unstable
Implementation Variable
Description Variable to get the total number of revisions for the current page.
Author(s) Robert Leverington (RobertLtalk)
MediaWiki 1.11.x
License No license specified
Download Source code
Change log
Hooks used
LanguageGetMagic
ParserGetVariableValueSwitch
MagicWordwgVariableIDs
Translate the TotalRevisions extension if it is available at translatewiki.net
Check usage and version matrix.

The TotalRevisions extension adds a variable that returns the total number of revisions for the current page.

This extension is known to cause incompatibilities with other extensions and is no longer being developed. You are advised not to use this extension.

Installation[edit]

  1. Place the source code into $IP/extensions/TotalRevisions/TotalRevisions.php.
  2. Add require_once $IP . '/extensions/TotalRevisions/TotalRevisions.php'; to LocalSettings.php.

Usage[edit]

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

Source code[edit]

TotalRevisions.php[edit]

<?php

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" => "Robert Leverington",
	"url" => "http://www.mediawiki.org/wiki/Extension:TotalRevisions",
	"version" => "1.1",
);

$wgHooks[ "MagicWordwgVariableIDs" ][] = "wfTotalRevisionsDeclare";
function wfTotalRevisionsDeclare( &$aCustomVariableIds ) {
	$aCustomVariableIds[] = MAG_TOTALREVISIONS;
	return true;
}

Change log[edit]

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