Index: trunk/extensions/MultiBoilerplate/MultiBoilerplate.i18n.php |
— | — | @@ -17,6 +17,15 @@ |
18 | 18 | 'multiboilerplate-label' => '', |
19 | 19 | 'multiboilerplate-legend' => 'Select boilerplate', |
20 | 20 | 'multiboilerplate-submit' => 'Load', |
| 21 | + 'boilerplates' => 'Custom preload on creation', |
| 22 | + 'boilerplates-name' => 'Boilerplates', |
| 23 | + 'multiboilerplate-special-title' => 'Custom templates preloader', |
| 24 | + 'multiboilerplate-special-pagetext' => 'Those templates can be preloaded on page creation. (<span class=plainlinks>[{{fullurl:This page does not exist|action=edit}} demo]</span>)', |
| 25 | + 'multiboilerplate-special-define-on-localsettings' => 'Boilerplates are defined on LocalSettings.php in array <code>$wgMultiBoilerplateOptions</code>. Set <code>$wgMultiBoilerplateOptions = false;</code> to use [[MediaWiki:Multiboilerplate]] instead.', |
| 26 | + 'multiboilerplate-special-define-on-interface' => 'Boilerplates are defined on interface page: [[MediaWiki:Multiboilerplate]].', |
| 27 | + 'multiboilerplate-label' => '', |
| 28 | + 'multiboilerplate-legend' => 'Select boilerplate', |
| 29 | + 'multiboilerplate-submit' => 'Load', |
21 | 30 | ); |
22 | 31 | |
23 | 32 | /** Message documentation (Message documentation) |
— | — | @@ -30,6 +39,7 @@ |
31 | 40 | 'multiboilerplate-submit' => 'The text displayed on the button that loads the boilerplate into the edit box. |
32 | 41 | |
33 | 42 | {{Identical|Load}}', |
| 43 | + 'boilerplates' => 'The description on Special:SpecialPages', |
34 | 44 | ); |
35 | 45 | |
36 | 46 | /** Afrikaans (Afrikaans) |
Index: trunk/extensions/MultiBoilerplate/MultiBoilerplate.php |
— | — | @@ -11,8 +11,9 @@ |
12 | 12 | * |
13 | 13 | * @link http://www.mediawiki.org/wiki/Extension:MultiBoilerplate |
14 | 14 | * |
15 | | - * @author MinuteElectron <minuteelectron@googlemail.com> |
16 | | - * @copyright Copyright © 2007-2008 MinuteElectron. |
| 15 | + * @author Robert Leverington <robert@rhl.me.uk> |
| 16 | + * @copyright Copyright © 2007 - 2009 Robert Leverington. |
| 17 | + * @copyright Copyright © 2009 Al Maghi. |
17 | 18 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
18 | 19 | */ |
19 | 20 | |
— | — | @@ -25,16 +26,21 @@ |
26 | 27 | 'name' => 'MultiBoilerplate', |
27 | 28 | 'description' => 'Allows a boilerplate to be selected from a drop down box located above the edit form when editing pages.', |
28 | 29 | 'descriptionmsg' => 'multiboilerplate-desc', |
29 | | - 'author' => 'MinuteElectron', |
| 30 | + 'author' => array( 'Robert Leverington', 'Al Maghi' ), |
30 | 31 | 'url' => 'http://www.mediawiki.org/wiki/Extension:MultiBoilerplate', |
31 | | - 'version' => '1.7', |
| 32 | + 'version' => '1.8.0', |
32 | 33 | ); |
33 | 34 | |
34 | 35 | // Hook into EditPage::showEditForm:initial to modify the edit page header. |
35 | 36 | $wgHooks[ 'EditPage::showEditForm:initial' ][] = 'efMultiBoilerplate'; |
36 | 37 | |
37 | 38 | // Set extension messages file. |
38 | | -$wgExtensionMessagesFiles[ 'MultiBoilerplate' ] = dirname( __FILE__ ) . '/MultiBoilerplate.i18n.php'; |
| 39 | +$dir = dirname( __FILE__ ) . '/'; |
| 40 | +$wgExtensionMessagesFiles[ 'MultiBoilerplate' ] = $dir . 'MultiBoilerplate.i18n.php'; |
| 41 | +$wgExtensionMessagesFiles[ 'MultiBoilerplate' ] = $dir . 'MultiBoilerplate.i18n.php'; |
| 42 | +$wgAutoloadClasses['SpecialBoilerplates'] = $dir . 'SpecialBoilerplates_body.php'; |
| 43 | +$wgSpecialPages['Boilerplates'] = 'SpecialBoilerplates'; |
| 44 | +$wgSpecialPageGroups['Boilerplates'] = 'wiki'; //section of [[Special:SpecialPages]] |
39 | 45 | |
40 | 46 | // Default configuration variables. |
41 | 47 | /* Array of boilerplate names to boilerplate pages to load, for example: |
— | — | @@ -46,7 +52,20 @@ |
47 | 53 | $wgMultiBoilerplateOptions = array(); |
48 | 54 | /* Whether or not to show the form when editing pre-existing pages. */ |
49 | 55 | $wgMultiBoilerplateOverwrite = false; |
| 56 | +/* Whether or not to display a special page listing boilerplates. |
| 57 | + * If set to true then the special page exists. */ |
| 58 | +$wgMultiBoilerplateDiplaySpecialPage = false; |
| 59 | + |
| 60 | +$wgHooks['SpecialPage_initList'][]='efBoilerplateDisplaySpecialPage'; |
| 61 | +function efBoilerplateDisplaySpecialPage( &$aSpecialPages ) { |
| 62 | + global $wgMultiBoilerplateDiplaySpecialPage; |
| 63 | + if ( !$wgMultiBoilerplateDiplaySpecialPage ) { |
| 64 | + unset( $aSpecialPages['Boilerplates'] ); |
| 65 | + } |
| 66 | + return true; |
| 67 | +} |
50 | 68 | |
| 69 | + |
51 | 70 | /** |
52 | 71 | * Generate the form to be displayed at the top of the edit page and insert it. |
53 | 72 | * @param $form EditPage object. |
Index: trunk/extensions/MultiBoilerplate/SpecialBoilerplates_body.php |
— | — | @@ -0,0 +1,47 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Special:boilerplates, provides a list of MediaWiki:Multiboilerplate or $wgMultiBoilerplateOptions. |
| 5 | + * This add-on use three new messages. |
| 6 | + * For more info see http://mediawiki.org/wiki/Extension:Multiboilerplate |
| 7 | + * |
| 8 | + * @subpackage Extensions |
| 9 | + * @author Al Maghi |
| 10 | + */ |
| 11 | + |
| 12 | +class SpecialBoilerplates extends IncludableSpecialPage { |
| 13 | + |
| 14 | + function __construct() { |
| 15 | + parent::SpecialPage( 'Boilerplates' ); |
| 16 | + $this->mIncludable = true; |
| 17 | + } |
| 18 | + |
| 19 | + function execute( $par ) { |
| 20 | + global $wgOut, $wgMultiBoilerplateOptions; |
| 21 | + if ( !isset($wgMultiBoilerplateOptions)) return true; // No options found in either configuration file, abort. |
| 22 | + wfLoadExtensionMessages( 'MultiBoilerplate' ); |
| 23 | + if( !$this->mIncluding ) { |
| 24 | + $this->setHeaders(); |
| 25 | + $wgOut->setPagetitle( wfMsg( "multiboilerplate-special-title" ) ); |
| 26 | + $wgOut->addWikiMsg( "multiboilerplate-special-pagetext" ); |
| 27 | + $wgOut->wrapWikiMsg( "==$1==\n", "boilerplates-name" ); |
| 28 | + } |
| 29 | + if( is_array( $wgMultiBoilerplateOptions ) ) { |
| 30 | + if( !$this->mIncluding ) $wgOut->addWikiMsg( "multiboilerplate-special-define-on-localsettings" ); |
| 31 | + foreach( $wgMultiBoilerplateOptions as $name => $template ) { |
| 32 | + $wgOut->addWikiText( "* [[$template]]\n" ); |
| 33 | + } |
| 34 | + } else { |
| 35 | + if( !$this->mIncluding ) $wgOut->addWikiMsg( "multiboilerplate-special-define-on-interface" ) ; |
| 36 | + $things = explode( "\n", str_replace( "\r", "\n", str_replace( "\r\n", "\n", wfMsg( 'multiboilerplate' ) ) ) ); // Ensure line-endings are \n |
| 37 | + foreach( $things as $row ) { |
| 38 | + if ( substr( ltrim( $row ), 0, 1 ) === '*' ) { |
| 39 | + $row = ltrim( $row, '* ' ); // Remove the asterix (and a space if found) from the start of the line. |
| 40 | + $row = explode( '|', $row ); |
| 41 | + if( !isset( $row[ 1 ] ) ) return true; // Invalid syntax, abort. |
| 42 | + $wgOut->addWikiText( "* [[$row[1]|$row[0]]]\n" ); |
| 43 | + } |
| 44 | + } |
| 45 | + } |
| 46 | + } |
| 47 | +} |
| 48 | + |