-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from paladox/patch-1
Update Purge.php
- Loading branch information
Showing
1 changed file
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,54 @@ | ||
<?php/** * An extension that adds a purge tab on each page * * @author Ævar Arnfjörð Bjarmason <[email protected]> * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later * * This is a fork of the original see https://www.mediawiki.org/wiki/Extension:Purge * Updated by Tom Hutchison to use proper i18n json files * Changed extension hook to SkinTemplateNavigation * Fixed ExtensionCredits to use the preferred descriptionmg * version 1.0.0 */if( !defined( 'MEDIAWIKI' ) ) { echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" ); die( 1 );}$wgExtensionCredits['other'][] = array( 'path' => __FILE__, 'name' => 'Purge', 'author' => 'Tom Hutchison', 'url' => 'https://github.com/Hutchy68/Purge', 'descriptionmsg' => 'descriptionmsg', 'version' => '1.0.0', 'license-name' => "License", // Short name of the license, links LICENSE or COPYING file if existing - string, added in 1.23.0);$wgMessagesDirs['Purge'] = __DIR__ . '/i18n';$wgExtensionMessagesFiles['Purge'] = __DIR__ . '/Purge.i18n.php';$wgHooks['SkinTemplateNavigation'][] = 'PurgeActionExtension::contentHook';class PurgeActionExtension{ public static function contentHook( $skin, array &$content_actions ) { global $wgRequest, $wgUser; // Use getRelevantTitle if present so that this will work on some special pages $title = method_exists( $skin, 'getRelevantTitle' ) ? $skin->getRelevantTitle() : $skin->getTitle(); if ( $title->getNamespace() !== NS_SPECIAL && $wgUser->isAllowed( 'purge' ) ) { $action = $wgRequest->getText( 'action' ); $content_actions['actions']['purge'] = array( 'class' => $action === 'purge' ? 'selected' : false, 'text' => wfMsg( 'purge' ), 'href' => $title->getLocalUrl( 'action=purge' ) ); } return true; } } | ||
<?php | ||
/** | ||
* An extension that adds a purge tab on each page | ||
* | ||
* @author Ævar Arnfjörð Bjarmason <[email protected]> | ||
* @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later | ||
* | ||
* This is a fork of the original see https://www.mediawiki.org/wiki/Extension:Purge | ||
* Updated by Tom Hutchison to use proper i18n json files | ||
* Changed extension hook to SkinTemplateNavigation | ||
* Fixed ExtensionCredits to use the preferred descriptionmg | ||
* version 1.0.0 | ||
*/ | ||
|
||
if( !defined( 'MEDIAWIKI' ) ) { | ||
echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" ); | ||
die( 1 ); | ||
} | ||
|
||
$wgExtensionCredits['other'][] = array( | ||
'path' => __FILE__, | ||
'name' => 'Purge', | ||
'author' => 'Tom Hutchison', | ||
'url' => 'https://github.com/Hutchy68/Purge', | ||
'descriptionmsg' => 'descriptionmsg', | ||
'version' => '1.0.0', | ||
'license-name' => "GPL-2.0+", | ||
); | ||
|
||
$wgMessagesDirs['Purge'] = __DIR__ . '/i18n'; | ||
$wgExtensionMessagesFiles['Purge'] = __DIR__ . '/Purge.i18n.php'; | ||
|
||
$wgHooks['SkinTemplateNavigation'][] = 'PurgeActionExtension::contentHook'; | ||
|
||
class PurgeActionExtension{ | ||
public static function contentHook( $skin, array &$content_actions ) { | ||
global $wgRequest, $wgUser; | ||
// Use getRelevantTitle if present so that this will work on some special pages | ||
$title = method_exists( $skin, 'getRelevantTitle' ) ? | ||
$skin->getRelevantTitle() : $skin->getTitle(); | ||
if ( $title->getNamespace() !== NS_SPECIAL && $wgUser->isAllowed( 'purge' ) ) { | ||
$action = $wgRequest->getText( 'action' ); | ||
|
||
$content_actions['actions']['purge'] = array( | ||
'class' => $action === 'purge' ? 'selected' : false, | ||
'text' => wfMessage( 'purge' )->text(), | ||
'href' => $title->getLocalUrl( 'action=purge' ) | ||
); | ||
} | ||
|
||
return true; | ||
} | ||
} |