Difference between revisions of "Extension:FileHistoryClear.php"
(Same job as imagehistory clear but for files) |
m |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<?php | <?php | ||
/** | /** | ||
− | * FileHistoryClear extension - An extension to strip | + | * FileHistoryClear extension - An extension to strip links from file page views. Made with [http://www.organicdesign.co.nz/Template:Extension Template:Extension]. |
*{{php}}{{Category:Extensions|FileHistoryClear}}{{Category:Jack}} | *{{php}}{{Category:Extensions|FileHistoryClear}}{{Category:Jack}} | ||
* See http://www.mediawiki.org/wiki/Extension:FileHistoryClear for installation and usage details | * See http://www.mediawiki.org/wiki/Extension:FileHistoryClear for installation and usage details | ||
Line 20: | Line 20: | ||
'name' => 'FileHistoryClear', | 'name' => 'FileHistoryClear', | ||
'author' => '[http://www.organicdesign.co.nz/wiki/User:Jack User:Jack]', | 'author' => '[http://www.organicdesign.co.nz/wiki/User:Jack User:Jack]', | ||
− | 'description' => 'An extension to strip | + | 'description' => 'An extension to strip links from file page views. Made with [http://www.organicdesign.co.nz/Template:Extension Template:Extension].', |
− | 'url' => 'http://www.organicdesign.co.nz/Extension:FileHistoryClear', | + | 'url' => 'http://www.organicdesign.co.nz/Extension:FileHistoryClear.php', |
'version' => FILEHISTORYCLEAR_VERSION | 'version' => FILEHISTORYCLEAR_VERSION | ||
); | ); | ||
/** | /** | ||
− | * Function called from the hook BeforePageDisplay, with a regular expression to replace | + | * Function called from the hook BeforePageDisplay, with a regular expression to replace links. |
*/ | */ | ||
function efFileHistoryClear (&$out) { | function efFileHistoryClear (&$out) { | ||
$out->mBodytext = preg_replace ('%(<div class="fullImageLink" id="file">)(.*)(<img.+?/>)(</a.+?)(</div>)%s','<div class="fullImageLink" id="file">\3</div>',$out->mBodytext); | $out->mBodytext = preg_replace ('%(<div class="fullImageLink" id="file">)(.*)(<img.+?/>)(</a.+?)(</div>)%s','<div class="fullImageLink" id="file">\3</div>',$out->mBodytext); | ||
− | |||
return true; | return true; | ||
} | } | ||
/** | /** | ||
− | * Setup function specifies a condition for the page being an file page | + | * Setup function specifies a condition for the page being an file page. |
*/ | */ | ||
Latest revision as of 11:13, 16 July 2009
<?php /**
* FileHistoryClear extension - An extension to strip links from file page views. Made with Template:Extension. *Template:Php
* 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 links from file page views. Made with Template:Extension.', 'url' => 'http://www.organicdesign.co.nz/Extension:FileHistoryClear.php', 'version' => FILEHISTORYCLEAR_VERSION );
/**
* Function called from the hook BeforePageDisplay, with a regular expression to replace links. */
function efFileHistoryClear (&$out) {
$out->mBodytext = preg_replace ('%(
)%s','
',$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'; }