Extension talk:HistoryOfPage

Running under mediawiki 1.16 (on Windows Server 2008), the posted code gives an error.

This has been fixed - new code below

I'm not a maintainer, but it was important to me to get this working.

This version changes the basic functionality - no longer returns links to all versions, just the history of the page prior to and including this version. Also strongly formatted the output (HTML4 transitional or previous).

I've not attempted to take over this extension or re-post the code, as the function of the extension has changed in my version. Rather than re-issue a new extension completely, I have posted this as comments for those who want it to work the way that I do.

To get this this working with the PdfBook extension, you need to add the top line to PdfBook as follows: $text   = $wgParser->preprocess($text, $title, $opt); $out    = $wgParser->parse($text, $title, $opt, true, true);

To get PdfBook working with historical revisions of documents takes some effort - head over to the extension talk to see my comments there.

I'll also convert PdfBook to work with WkHtmlToPdf rather than HtmlDoc, as the results from that program are 1) better, 2) working in latest version and 3) maintained by someone who hasn't gone out of business.

<?php /** * HistoryOfPage extension * - An extension that returns the formatted non-minor changes to a page prior to and including this revision * * See http://www.mediawiki.org/wiki/Extension:HistoryOfPage for installation and usage details * See http://www.mediawiki.org/w/index.php?title=Extension_talk:HistoryOfPage for development notes and discussion * * @package MediaWiki * @subpackage Extensions * @author M. Deri Taufan * @copyright © 2011 M. Deri Taufan * @licence GNU General Public Licence 2.0 or later * * Usage: * Minor comments are ignored. * Blank comment strings are replaced with 'No Details' * Section comments are italicised as 'Edited section "XYZ"' * Comments beginning with a version pattern (vX.Y) will be extracted and the revision marked as a major issued version. * * Version history: * 0.1 - Initial Creation * 0.2 - Overhaul *     - This version changes the basic functionality - no longer returns links to all versions, just the history *       of the page prior to and including this version. Also strongly formatted the output (HTML4 transitional or previous). * */

if ( !defined( 'MEDIAWIKI' ) ) { die( 'This file is a MediaWiki extension, it is not a valid entry point' ); }

$wgExtensionCredits['parserhook'][] = array(       'path' => __FILE__,        'name' => "HistoryOfPage",        'description' => "An extension that returns the formatted non-minor changes to a page prior to and including this revision",        'version' => 0.2,        'author' => "M. Deri Taufan, Tony Walker",        'url' => "http://wiki.science.ru.nl/mms", ); $wgHooks['ParserFirstCallInit'][] = 'hpParserFunction_Setup'; $wgHooks['LanguageGetMagic'][] = 'hpParserFunction_Magic';
 * 1) Define a setup function
 * 1) Add a hook to initialise the magic word

function hpParserFunction_Setup ( &$parser ) { $parser->setFunctionHook( 'hop', 'hpParserFunction_Render' ); return true; }

function hpParserFunction_Magic ( &$magicWords, $langCode ) { $magicWords['hop'] = array( 0, 'hop' ); return true; }

function hpParserFunction_Render ( $parser, $param1='' ) { $revPage = ''; $outputLink = ''; $pageTitle = ''; $versParam = intval($param1); $protocol = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http'; $url = $protocol.'://'.$_SERVER['HTTP_HOST']; $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->selectRow(       'revision', // $table        array( 'rev_page','rev_id' ), // $vars (columns of the table)        "rev_id=$versParam", // &conds        __METHOD__, // $fname = 'Database::select',        array( 'ORDER BY' => "rev_id ASC" ) // $options = array    ); $revPage = intval($res->rev_page);

//query the page title based on page_id $res = $dbr->selectRow(       'page',        array( 'page_id','page_title' ),        "page_id=$revPage",        __METHOD__,        array( 'ORDER BY' => "page_id ASC" )    ); $pageTitle = $res->page_title; //query timestamp of a non-minor change, only for changes on or before the version requested. $res = $dbr->select(       'revision',        array( 'rev_timestamp','rev_id','rev_user_text','rev_comment' ),        "rev_page=$revPage AND rev_minor_edit=0 AND rev_id<=$versParam",        __METHOD__,        array( 'ORDER BY' => "rev_id ASC" )    ); $outVers=''; $outStatus=''; $outComment=''; $versions=''; $outputLink=' ';

//return $param1." ".$versParam." ".$outputLink; return $outputLink; } --217.158.90.2 14:18, 31 January 2012 (UTC)