-
Notifications
You must be signed in to change notification settings - Fork 0
/
specialboilerplates_body.php
44 lines (41 loc) · 1.65 KB
/
specialboilerplates_body.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/**
* Special:boilerplates, provides a list of MediaWiki:Multiboilerplate or $wgMultiBoilerplateOptions.
* This add-on use three new messages.
* For more info see http://mediawiki.org/wiki/Extension:Multiboilerplate
*
* @file
* @ingroup Extensions
* @author Al Maghi
*/
class SpecialBoilerplates extends IncludableSpecialPage {
function __construct() {
parent::__construct( 'Boilerplates' );
$this->mIncludable = true;
}
function execute( $par ) {
global $wgOut, $wgMultiBoilerplateOptions;
if ( !isset($wgMultiBoilerplateOptions)) return true; // No options found in either configuration file, abort.
if( !$this->mIncluding ) {
$this->setHeaders();
$wgOut->addWikiMsg( "multiboilerplate-special-pagetext" );
}
if( is_array( $wgMultiBoilerplateOptions ) ) {
if( !$this->mIncluding ) $wgOut->addWikiMsg( "multiboilerplate-special-define-in-localsettings" );
foreach( $wgMultiBoilerplateOptions as $name => $template ) {
$wgOut->addWikiText( "* [[$template]]\n" );
}
} else {
if( !$this->mIncluding ) $wgOut->addWikiMsg( "multiboilerplate-special-define-in-interface" ) ;
$things = explode( "\n", str_replace( "\r", "\n", str_replace( "\r\n", "\n", wfMsg( 'multiboilerplate' ) ) ) ); // Ensure line-endings are \n
foreach( $things as $row ) {
if ( substr( ltrim( $row ), 0, 1 ) === '*' ) {
$row = ltrim( $row, '* ' ); // Remove the asterix (and a space if found) from the start of the line.
$row = explode( '|', $row );
if( !isset( $row[ 1 ] ) ) return true; // Invalid syntax, abort.
$wgOut->addWikiText( "* [[$row[1]|$row[0]]]\n" );
}
}
}
}
}