Page MenuHomePhabricator

Add-on_patch.patch

Authored By
bzimport
Nov 21 2014, 10:38 PM
Size
7 KB
Referenced Files
None
Subscribers
None

Add-on_patch.patch

Index: MultiBoilerplate.i18n.php
===================================================================
--- MultiBoilerplate.i18n.php (revision 52526)
+++ MultiBoilerplate.i18n.php (working copy)
@@ -12,11 +12,17 @@
* @author MinuteElectron <minuteelectron@googlemail.com>
*/
$messages['en'] = array(
- 'multiboilerplate' => '',
- 'multiboilerplate-desc' => 'Allows a boilerplate to be selected from a drop down box located above the edit form when editing pages',
- 'multiboilerplate-label' => '',
- 'multiboilerplate-legend' => 'Select boilerplate',
- 'multiboilerplate-submit' => 'Load',
+ 'multiboilerplate' => '',
+ 'multiboilerplate-desc' => 'Allows a [[special:boilerplates|boilerplate]] to be selected from a drop down box located above the edit form when editing pages',
+ 'boilerplates' => 'Custom preload on creation',
+ 'boilerplates-name' => 'Boilerplates',
+ 'multiboilerplate-special-title' => 'Custom templates preloader',
+ 'multiboilerplate-special-pagetext' => 'Those templates can be preloaded on page creation. (<span class=plainlinks>[{{fullurl:This page does not exist|action=edit}} demo]</span>)',
+ '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.',
+ 'multiboilerplate-special-define-on-interface' => 'Boilerplates are defined on interface page: [[MediaWiki:Multiboilerplate]].',
+ 'multiboilerplate-label' => '',
+ 'multiboilerplate-legend' => 'Select boilerplate',
+ 'multiboilerplate-submit' => 'Load',
);
/** Message documentation (Message documentation)
@@ -27,9 +33,9 @@
$messages['qqq'] = array(
'multiboilerplate-desc' => 'Description of the MultiBoilerplate extension, shown on [[Special:Version]]. Do not translate or change links.',
'multiboilerplate-legend' => 'Title of the form used for selecting a boilerplate.',
- 'multiboilerplate-submit' => 'The text displayed on the button that loads the boilerplate into the edit box.
-
-{{Identical|Load}}',
+ 'multiboilerplate-submit' => 'The text displayed on the button that loads the boilerplate into the edit box.',
+ 'boilerplates' => 'The description on Special:SpecialPages',
+'{{Identical|Load}}',
);
/** Afrikaans (Afrikaans)
@@ -353,6 +359,13 @@
'multiboilerplate-submit' => 'Carregar',
);
+/** Tarandíne (Tarandíne)
+ * @author Joetaras
+ */
+$messages['roa-tara'] = array(
+ 'multiboilerplate-submit' => 'Careche',
+);
+
/** Russian (Русский)
* @author Александр Сигачёв
*/
Index: MultiBoilerplate.page.php
===================================================================
--- MultiBoilerplate.page.php (revision 0)
+++ MultiBoilerplate.page.php (revision 0)
@@ -0,0 +1,46 @@
+<?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
+ *
+ * @subpackage Extensions
+ * @author Al Maghi
+ */
+
+class SpecialBoilerplates extends IncludableSpecialPage {
+
+ function __construct() {
+ parent::SpecialPage( 'Boilerplates' );
+ $this->mIncludable = true;
+ }
+
+ function execute( $par ) {
+ global $wgOut, $wgMultiBoilerplateOptions;
+ if ( !isset($wgMultiBoilerplateOptions)) return true; // No options found in either configuration file, abort.
+ wfLoadExtensionMessages( 'MultiBoilerplate' );
+ if( !$this->mIncluding ) {
+ $this->setHeaders();
+ $wgOut->setPagetitle( wfMsg( "multiboilerplate-special-title" ) );
+ $wgOut->addWikiMsg( "multiboilerplate-special-pagetext" );
+ $wgOut->wrapWikiMsg( "==$1==\n", "boilerplates-name" );
+ }
+ if( is_array( $wgMultiBoilerplateOptions ) ) {
+ if( !$this->mIncluding ) $wgOut->addWikiMsg( "multiboilerplate-special-define-on-localsettings" );
+ foreach( $wgMultiBoilerplateOptions as $name => $template ) {
+ $wgOut->addWikiText( "* [[$template]]\n" );
+ }
+ } else {
+ if( !$this->mIncluding ) $wgOut->addWikiMsg( "multiboilerplate-special-define-on-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" );
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Index: MultiBoilerplate.php
===================================================================
--- MultiBoilerplate.php (revision 52526)
+++ MultiBoilerplate.php (working copy)
@@ -27,14 +27,18 @@
'descriptionmsg' => 'multiboilerplate-desc',
'author' => 'MinuteElectron',
'url' => 'http://www.mediawiki.org/wiki/Extension:MultiBoilerplate',
- 'version' => '1.7',
+ 'version' => '1.8',
);
// Hook into EditPage::showEditForm:initial to modify the edit page header.
$wgHooks[ 'EditPage::showEditForm:initial' ][] = 'efMultiBoilerplate';
// Set extension messages file.
-$wgExtensionMessagesFiles[ 'MultiBoilerplate' ] = dirname( __FILE__ ) . '/MultiBoilerplate.i18n.php';
+$dir = dirname(__FILE__) . '/';
+$wgExtensionMessagesFiles[ 'MultiBoilerplate' ] = $dir . 'MultiBoilerplate.i18n.php';
+$wgAutoloadClasses['SpecialBoilerplates'] = $dir . 'MultiBoilerplate.page.php';
+$wgSpecialPages['Boilerplates'] = 'SpecialBoilerplates';
+$wgSpecialPageGroups['Boilerplates'] = 'wiki'; //section of [[Special:SpecialPages]]
// Default configuration variables.
/* Array of boilerplate names to boilerplate pages to load, for example:
@@ -46,7 +50,19 @@
$wgMultiBoilerplateOptions = array();
/* Whether or not to show the form when editing pre-existing pages. */
$wgMultiBoilerplateOverwrite = false;
+/* Whether or not to display a special page listing boilerplates.
+ * If set to true then the special page exists. */
+$wgMultiBoilerplateDiplaySpecialPage = true;
+$wgHooks['SpecialPage_initList'][]='efBoilerplateDisplaySpecialPage';
+function efBoilerplateDisplaySpecialPage( &$aSpecialPages ) {
+ global $wgMultiBoilerplateDiplaySpecialPage;
+ if( !$wgMultiBoilerplateDiplaySpecialPage ) {
+ unset( $aSpecialPages['Boilerplates'] );
+ }
+ return true;
+}
+
/**
* Generate the form to be displayed at the top of the edit page and insert it.
* @param $form EditPage object.
@@ -80,12 +96,14 @@
$options = '';
$things = explode( "\n", str_replace( "\r", "\n", str_replace( "\r\n", "\n", $things ) ) ); // Ensure line-endings are \n
foreach( $things as $row ) {
- $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.
- $selected = false;
- if( $wgRequest->getVal( 'boilerplate' ) == $row[ 1 ] ) $selected = true;
- $options .= Xml::option( $row[ 0 ], $row[ 1 ], $selected );
+ 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.
+ $selected = false;
+ if( $wgRequest->getVal( 'boilerplate' ) == $row[ 1 ] ) $selected = true;
+ $options .= Xml::option( $row[ 0 ], $row[ 1 ], $selected );
+ }
}
}

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5277
Default Alt Text
Add-on_patch.patch (7 KB)

Event Timeline