Extension:FileHistoryClear.php

From Organic Design wiki
Revision as of 10:12, 16 July 2009 by Jack (talk | contribs) (Same job as imagehistory clear but for files)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

<?php /**

* FileHistoryClear extension - An extension to strip TOC, history and links information from file page views. Made with Template:Extension.
*Template:Php
Info.svg These are the MediaWiki extensions we're using and/or developing. Please refer to the information on the mediawiki.org wiki for installation and usage details. Extensions here which have no corresponding mediawiki article are either not ready for use or have been superseded. You can also browse our extension code in our local Subversion repository or our GitHub mirror.
* See http://www.mediawiki.org/wiki/Extension:FileHistoryClear for installation and usage details
*
* @package MediaWiki
* @subpackage Extensions
* @author User:Jack
* @copyright © 2009 User:Jack
* @licence GNU General Public Licence 2.0 or later
*/

if (!defined('MEDIAWIKI')) die('Not an entry point.');

define('FILEHISTORYCLEAR_VERSION', '1.0.0, 2009-07-16');

$wgExtensionFunctions[] = 'efSetupFileHistoryClear';

$wgExtensionCredits['parserhook'][] = array( 'name' => 'FileHistoryClear', 'author' => 'User:Jack', 'description' => 'An extension to strip TOC, history and links information from image page views by anonymous users. Made with Template:Extension.', 'url' => 'http://www.organicdesign.co.nz/Extension:FileHistoryClear', 'version' => FILEHISTORYCLEAR_VERSION );

/**

* Function called from the hook BeforePageDisplay, with a regular expression to replace TOC, history and image information.
*/

function efFileHistoryClear (&$out) {

$out->mBodytext = preg_replace ('%(

)%s','

',$out->mBodytext);

//$out->mBodytext = preg_replace ('%(fullImageLink)%s','foo',$out->mBodytext); return true; }

/**

* Setup function specifies a condition for the page being an file page
*/

function efSetupFileHistoryClear() { global $wgHooks,$wgUser,$wgRequest; $title = Title::newFromText($wgRequest->getText('title')); if (is_object($title) && $title->getNamespace()==NS_FILE) $wgHooks['BeforePageDisplay'][] = 'efFileHistoryClear'; }