r54083 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54082‎ | r54083 | r54084 >
Date:09:55, 31 July 2009
Author:roberthl
Status:deferred
Tags:
Comment:
MultiBoilerplate:
* Integrate patch by Al Maghi, adds a special page listing boilerplates.
Modified paths:
  • /trunk/extensions/MultiBoilerplate/MultiBoilerplate.i18n.php (modified) (history)
  • /trunk/extensions/MultiBoilerplate/MultiBoilerplate.php (modified) (history)
  • /trunk/extensions/MultiBoilerplate/SpecialBoilerplates_body.php (added) (history)

Diff [purge]

Index: trunk/extensions/MultiBoilerplate/MultiBoilerplate.i18n.php
@@ -17,6 +17,15 @@
1818 'multiboilerplate-label' => '',
1919 'multiboilerplate-legend' => 'Select boilerplate',
2020 '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>&#36;wgMultiBoilerplateOptions</code>. Set <code>&#36;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',
2130 );
2231
2332 /** Message documentation (Message documentation)
@@ -30,6 +39,7 @@
3140 'multiboilerplate-submit' => 'The text displayed on the button that loads the boilerplate into the edit box.
3241
3342 {{Identical|Load}}',
 43+ 'boilerplates' => 'The description on Special:SpecialPages',
3444 );
3545
3646 /** Afrikaans (Afrikaans)
Index: trunk/extensions/MultiBoilerplate/MultiBoilerplate.php
@@ -11,8 +11,9 @@
1212 *
1313 * @link http://www.mediawiki.org/wiki/Extension:MultiBoilerplate
1414 *
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.
1718 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
1819 */
1920
@@ -25,16 +26,21 @@
2627 'name' => 'MultiBoilerplate',
2728 'description' => 'Allows a boilerplate to be selected from a drop down box located above the edit form when editing pages.',
2829 'descriptionmsg' => 'multiboilerplate-desc',
29 - 'author' => 'MinuteElectron',
 30+ 'author' => array( 'Robert Leverington', 'Al Maghi' ),
3031 'url' => 'http://www.mediawiki.org/wiki/Extension:MultiBoilerplate',
31 - 'version' => '1.7',
 32+ 'version' => '1.8.0',
3233 );
3334
3435 // Hook into EditPage::showEditForm:initial to modify the edit page header.
3536 $wgHooks[ 'EditPage::showEditForm:initial' ][] = 'efMultiBoilerplate';
3637
3738 // 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]]
3945
4046 // Default configuration variables.
4147 /* Array of boilerplate names to boilerplate pages to load, for example:
@@ -46,7 +52,20 @@
4753 $wgMultiBoilerplateOptions = array();
4854 /* Whether or not to show the form when editing pre-existing pages. */
4955 $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+}
5068
 69+
5170 /**
5271 * Generate the form to be displayed at the top of the edit page and insert it.
5372 * @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+

Status & tagging log