r35996 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r35995‎ | r35996 | r35997 >
Date:14:43, 7 June 2008
Author:ashley
Status:old
Tags:
Comment:
CreateBox:
*Avoid unstubbing $wgParser too early on modern (1.12+) MW versions, as per r35980
*Bump version number from 1.5 to 1.6
*Use 'create' message as the button text rather than 'createarticle' as the latter is provided by Inputbox extension and not everyone has Inputbox installed
*Add messages into their separate file & add Finnish i18n
Modified paths:
  • /trunk/extensions/CreateBox/CreateBox.i18n.php (added) (history)
  • /trunk/extensions/CreateBox/CreateBox.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CreateBox/CreateBox.i18n.php
@@ -0,0 +1,35 @@
 2+<?php
 3+/**
 4+ * Internationalisation file for the CreateBox extension.
 5+ *
 6+ * @ingroup Extensions
 7+ * @author Ross McClure
 8+ */
 9+
 10+$messages = array();
 11+
 12+/** English
 13+ * @author Ross McClure
 14+ */
 15+$messages['en'] = array(
 16+ 'create' => 'Create',
 17+ 'createbox-exists' => "Sorry, \"'''{{FULLPAGENAME}}'''\" already " .
 18+ "exists.\n\nYou cannot create this page, but you can " .
 19+ "[{{fullurl:{{FULLPAGENAME}}|action=edit}} edit it], " .
 20+ "[{{fullurl:{{FULLPAGENAME}}}} read it], or choose to " .
 21+ "create a different page using the box below.\n\n" .
 22+ "<createbox>break=no</createbox>",
 23+);
 24+
 25+/** Finnish (Suomi)
 26+ * @author Jack Phoenix
 27+ */
 28+$messages['fi'] = array (
 29+ 'create' => 'Luo',
 30+ 'createbox-exists' => "Pahoittelut, \"'''{{FULLPAGENAME}}'''\" on jo " .
 31+ "olemassa.\n\nEt voi luoda tätä sivua, mutta voit " .
 32+ "[{{fullurl:{{FULLPAGENAME}}|action=edit}} muokata sitä], " .
 33+ "[{{fullurl:{{FULLPAGENAME}}}} lukea sitä], tai luoda " .
 34+ "erilaisen sivun allaolevaa laatikkoa käyttäen.\n\n" .
 35+ "<createbox>break=no</createbox>",
 36+);
\ No newline at end of file
Property changes on: trunk/extensions/CreateBox/CreateBox.i18n.php
___________________________________________________________________
Name: svn:eol-style
137 + native
Index: trunk/extensions/CreateBox/CreateBox.php
@@ -1,7 +1,7 @@
22 <?php
33 /*
44
5 - CreateBox v1.5 -- Specialized Inputbox for page creation
 5+ CreateBox v1.6 -- Specialized Inputbox for page creation
66
77 Author: Ross McClure
88 http://www.mediawiki.org/wiki/User:Algorithm
@@ -24,37 +24,36 @@
2525 http://www.gnu.org/copyleft/gpl.html
2626
2727 To install, add following to LocalSettings.php
28 - include("extensions/create.php");
29 -
 28+ require_once("extensions/create.php");
3029 */
3130
32 -$wgExtensionFunctions[] = "wfCreateBox";
 31+//Avoid unstubbing $wgParser too early on modern (1.12+) MW versions, as per r35980
 32+if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
 33+ $wgHooks['ParserFirstCallInit'][] = 'wfCreateBox';
 34+} else {
 35+ $wgExtensionFunctions[] = 'wfCreateBox';
 36+}
 37+
3338 $wgHooks['UnknownAction'][] = 'actionCreate';
3439 $wgExtensionCredits['parserhook'][] = array(
3540 'name' => 'CreateBox',
3641 'url' => 'http://www.mediawiki.org/wiki/Extension:CreateBox',
3742 'description' => 'Specialized Inputbox for page creation',
3843 'author' => 'Ross McClure',
39 - 'version' => '1.5'
 44+ 'version' => '1.6'
4045 );
4146
 47+$dir = dirname(__FILE__) . '/';
 48+$wgExtensionMessagesFiles['CreateBox'] = $dir . 'CreateBox.i18n.php';
 49+
4250 function wfCreateBox() {
43 - global $wgParser, $wgMessageCache;
44 -
45 - $wgMessageCache->addMessages( array(
46 - 'create' => "Create",
47 - 'create_exists' => "Sorry, \"'''{{FULLPAGENAME}}'''\" already " .
48 - "exists.\n\nYou cannot create this page, but you can " .
49 - "[{{fullurl:{{FULLPAGENAME}}|action=edit}} edit it], " .
50 - "[{{fullurl:{{FULLPAGENAME}}}} read it], or choose to " .
51 - "create a different page using the box below.\n\n" .
52 - "<createbox>break=no</createbox>"
53 - ));
54 -
55 - $wgParser->setHook( "createbox", "acMakeBox" );
 51+ global $wgParser;
 52+ $wgParser->setHook( 'createbox', 'acMakeBox' );
 53+ return true;
5654 }
5755
5856 function actionCreate($action, $article) {
 57+ wfLoadExtensionMessages('CreateBox');
5958 if($action != 'create') return true;
6059
6160 global $wgRequest;
@@ -77,7 +76,7 @@
7877 $text = $article->getTitle()->getPrefixedText();
7978 $wgOut->setPageTitle($text);
8079 $wgOut->setHTMLTitle(wfMsg('pagetitle', $text.' - '.wfMsg('create')));
81 - $wgOut->addWikiText(wfMsg('create_exists'));
 80+ $wgOut->addWikiText(wfMsg('createbox-exists'));
8281 }
8382 return false;
8483 }
@@ -91,6 +90,7 @@
9291 }
9392
9493 function acMakeBox($input, $argv, &$parser) {
 94+ wfLoadExtensionMessages('CreateBox');
9595 global $wgRequest, $wgScript;
9696 if($wgRequest->getVal('action')=='create') {
9797 $prefix = $wgRequest->getVal('prefix');
@@ -106,10 +106,10 @@
107107 $text = acGetOption($input,'default');
108108 }
109109 $submit = htmlspecialchars($wgScript);
110 - $width = acGetOption($input,'width',0);
111 - $align = acGetOption($input,'align','center');
112 - $br = ((acGetOption($input,'break','no')=='no') ? '' : '<br />');
113 - $label = acGetOption($input,'buttonlabel',wfMsgHtml("createarticle"));
 110+ $width = acGetOption($input, 'width', 0);
 111+ $align = acGetOption($input, 'align', 'center');
 112+ $br = ((acGetOption($input, 'break', 'no')=='no') ? '' : '<br />');
 113+ $label = acGetOption($input, 'buttonlabel', wfMsgHtml('create'));
114114 $output=<<<ENDFORM
115115 <div class="createbox" align="{$align}">
116116 <form name="createbox" action="{$submit}" method="get" class="createboxForm">

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r35980Update a bunch of extensions to avoid unstubbing $wgParser early for setHook(...brion20:38, 6 June 2008

Status & tagging log