forked from Majr25/ExcludeRandom
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
55 additions
and
0 deletions.
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
$messages = array(); | ||
$messages['en'] = array( | ||
'excluderandom-desc' => 'Allows pages to be excluded from [[mw:Help:Random page|Special:Random]]', | ||
); |
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
/** | ||
* ExcludeRandom - this extension allows pages to be excluded from Special:Random | ||
* | ||
* To activate this extension, add the following into your LocalSettings.php file: | ||
* require_once( '$IP/extensions/ExcludeRandom/ExcludeRandom.php' ); | ||
* | ||
* @ingroup Extensions | ||
* @author Matt Russell | ||
* @version 0.1 | ||
* @link https://www.mediawiki.org/wiki/Extension:ExcludeRandom Documentation | ||
* @license CopyLeft | ||
*/ | ||
|
||
if ( !defined( 'MEDIAWIKI' ) ) { | ||
echo "This is an extension to the MediaWiki package and cannot be run standalone.\n"; | ||
die( -1 ); | ||
} | ||
|
||
$wgExcludeRandomPages = null; | ||
|
||
$wgHooks['SpecialRandomGetRandomTitle'][] = 'wfExcludeRandomInit'; | ||
|
||
/* Define extensions info */ | ||
$wgExtensionCredits['other'][] = array( | ||
'path' => __FILE__, | ||
'name' => 'ExcludeRandom', | ||
'author' =>'[http://matt-russell.com Matt Russell]', | ||
'url' => 'https://www.mediawiki.org/wiki/Extension:ExcludeRandom', | ||
'descriptionmsg' => 'excluderandom-desc', | ||
'version' => 0.1, | ||
); | ||
|
||
/* Define internationalisation file */ | ||
$dir = dirname( __FILE__ ) . '/'; | ||
$wgExtensionMessagesFiles['ExcludeRandom'] = $dir . 'ExcludeRandom.i18n.php'; | ||
|
||
function wfExcludeRandomInit( &$rand, &$isRedir, &$namespaces, &$extra, &$title ) { | ||
GLOBAL $wgExcludeRandomPages, $dbr; | ||
if ( !$wgExcludeRandomPages ) { | ||
return true; | ||
} | ||
|
||
foreach ( $wgExcludeRandomPages AS $cond ) { | ||
$escape = str_replace( array( ' ', '\\', '%', '_', '*', '\'' ), array( '_', '\\\\', '\%', '\_', '%', '\\\'' ), $cond ); | ||
$extra[] = "`page_title` NOT LIKE '$escape'"; | ||
} | ||
|
||
return true; | ||
} |