r97890 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97889‎ | r97890 | r97891 >
Date:06:48, 23 September 2011
Author:siebrand
Status:ok (Comments)
Tags:
Comment:
stylize.php, update whitespace, remove superfluous comment lines
update indentation and sprinkle some braces.
Modified paths:
  • /trunk/extensions/Gadgets/ApiQueryGadgetCategories.php (modified) (history)
  • /trunk/extensions/Gadgets/ApiQueryGadgets.php (modified) (history)
  • /trunk/extensions/Gadgets/Gadgets.i18n.php (modified) (history)
  • /trunk/extensions/Gadgets/Gadgets.php (modified) (history)
  • /trunk/extensions/Gadgets/Gadgets_body.php (modified) (history)
  • /trunk/extensions/Gadgets/Gadgets_tests.php (modified) (history)
  • /trunk/extensions/Gadgets/README (modified) (history)
  • /trunk/extensions/Gadgets/SpecialGadgets.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Gadgets/Gadgets_body.php
@@ -2,7 +2,6 @@
33 /**
44 * Gadgets extension - lets users select custom javascript gadgets
55 *
6 - *
76 * For more info see http://mediawiki.org/wiki/Extension:Gadgets
87 *
98 * @file
@@ -13,7 +12,6 @@
1413 */
1514
1615 class GadgetHooks {
17 -
1816 /**
1917 * ArticleSaveComplete hook handler.
2018 *
@@ -22,9 +20,9 @@
2321 * @param $text String: New page text
2422 */
2523 public static function articleSaveComplete( $article, $user, $text ) {
26 - //update cache if MediaWiki:Gadgets-definition was edited
 24+ // update cache if MediaWiki:Gadgets-definition was edited
2725 $title = $article->mTitle;
28 - if( $title->getNamespace() == NS_MEDIAWIKI && $title->getText() == 'Gadgets-definition' ) {
 26+ if ( $title->getNamespace() == NS_MEDIAWIKI && $title->getText() == 'Gadgets-definition' ) {
2927 Gadget::loadStructuredList( $text );
3028 }
3129 return true;
@@ -36,15 +34,16 @@
3735 */
3836 public static function userGetDefaultOptions( &$defaultOptions ) {
3937 $gadgets = Gadget::loadStructuredList();
40 - if (!$gadgets) return true;
 38+ if ( !$gadgets ) return true;
4139
42 - foreach( $gadgets as $section => $thisSection ) {
43 - foreach( $thisSection as $gadgetId => $gadget ) {
 40+ foreach ( $gadgets as $section => $thisSection ) {
 41+ foreach ( $thisSection as $gadgetId => $gadget ) {
4442 if ( $gadget->isOnByDefault() ) {
4543 $defaultOptions['gadget-' . $gadgetId] = 1;
4644 }
4745 }
4846 }
 47+
4948 return true;
5049 }
5150
@@ -55,13 +54,17 @@
5655 */
5756 public static function getPreferences( $user, &$preferences ) {
5857 $gadgets = Gadget::loadStructuredList();
59 - if (!$gadgets) return true;
6058
 59+ if ( !$gadgets ) {
 60+ return true;
 61+ }
 62+
6163 $options = array();
6264 $default = array();
63 - foreach( $gadgets as $section => $thisSection ) {
 65+ foreach ( $gadgets as $section => $thisSection ) {
6466 $available = array();
65 - foreach( $thisSection as $gadget ) {
 67+
 68+ foreach ( $thisSection as $gadget ) {
6669 if ( $gadget->isAllowed( $user ) ) {
6770 $gname = $gadget->getName();
6871 $available[$gadget->getDescription()] = $gname;
@@ -70,8 +73,10 @@
7174 }
7275 }
7376 }
 77+
7478 if ( $section !== '' ) {
7579 $section = wfMsgExt( "gadget-section-$section", 'parseinline' );
 80+
7681 if ( count ( $available ) ) {
7782 $options[$section] = $available;
7883 }
@@ -111,9 +116,11 @@
112117 */
113118 public static function registerModules( &$resourceLoader ) {
114119 $gadgets = Gadget::loadList();
 120+
115121 if ( !$gadgets ) {
116122 return true;
117123 }
 124+
118125 foreach ( $gadgets as $g ) {
119126 $module = $g->getModule();
120127 if ( $module ) {
@@ -121,6 +128,7 @@
122129 }
123130 }
124131 return true;
 132+
125133 }
126134
127135 /**
@@ -147,6 +155,7 @@
148156 if ( $gadget->hasModule() ) {
149157 $out->addModules( $gadget->getModuleName() );
150158 }
 159+
151160 foreach ( $gadget->getLegacyScripts() as $page ) {
152161 $lb->add( NS_MEDIAWIKI, $page );
153162 $pages[] = $page;
@@ -157,8 +166,12 @@
158167 $lb->execute( __METHOD__ );
159168
160169 $done = array();
 170+
161171 foreach ( $pages as $page ) {
162 - if ( isset( $done[$page] ) ) continue;
 172+ if ( isset( $done[$page] ) ) {
 173+ continue;
 174+ }
 175+
163176 $done[$page] = true;
164177 self::applyScript( $page, $out );
165178 }
@@ -180,12 +193,14 @@
181194 # ResourceLoader handle this in OutputPage::getModules()
182195 # TODO: make this extension load everything via RL, then we don't need to worry
183196 # about any of this.
184 - if( $out->getAllowedModules( ResourceLoaderModule::TYPE_SCRIPTS ) < ResourceLoaderModule::ORIGIN_USER_SITEWIDE ){
 197+ if ( $out->getAllowedModules( ResourceLoaderModule::TYPE_SCRIPTS ) < ResourceLoaderModule::ORIGIN_USER_SITEWIDE ) {
185198 return;
186199 }
187200
188201 $t = Title::makeTitleSafe( NS_MEDIAWIKI, $page );
189 - if ( !$t ) return;
 202+ if ( !$t ) {
 203+ return;
 204+ }
190205
191206 $u = $t->getLocalURL( 'action=raw&ctype=' . $wgJsMimeType );
192207 $out->addScriptFile( $u, $t->getLatestRevID() );
@@ -197,6 +212,7 @@
198213 */
199214 public static function unitTestsList( $files ) {
200215 $files[] = dirname( __FILE__ ) . '/Gadgets_tests.php';
 216+
201217 return true;
202218 }
203219 }
@@ -211,10 +227,10 @@
212228 const GADGET_CLASS_VERSION = 5;
213229
214230 private $version = self::GADGET_CLASS_VERSION,
215 - $scripts = array(),
216 - $styles = array(),
 231+ $scripts = array(),
 232+ $styles = array(),
217233 $dependencies = array(),
218 - $name,
 234+ $name,
219235 $definition,
220236 $resourceLoaded = false,
221237 $requiredRights = array(),
@@ -231,13 +247,14 @@
232248 if ( !preg_match( '/^\*+ *([a-zA-Z](?:[-_:.\w\d ]*[a-zA-Z0-9])?)(\s*\[.*?\])?\s*((\|[^|]*)+)\s*$/', $definition, $m ) ) {
233249 return false;
234250 }
235 - //NOTE: the gadget name is used as part of the name of a form field,
 251+ // NOTE: the gadget name is used as part of the name of a form field,
236252 // and must follow the rules defined in http://www.w3.org/TR/html4/types.html#type-cdata
237253 // Also, title-normalization applies.
238254 $gadget = new Gadget();
239 - $gadget->name = trim( str_replace(' ', '_', $m[1] ) );
 255+ $gadget->name = trim( str_replace( ' ', '_', $m[1] ) );
240256 $gadget->definition = $definition;
241257 $options = trim( $m[2], ' []' );
 258+
242259 foreach ( preg_split( '/\s*\|\s*/', $options, -1, PREG_SPLIT_NO_EMPTY ) as $option ) {
243260 $arr = preg_split( '/\s*=\s*/', $option, 2 );
244261 $option = $arr[0];
@@ -247,6 +264,7 @@
248265 } else {
249266 $params = array();
250267 }
 268+
251269 switch ( $option ) {
252270 case 'ResourceLoader':
253271 $gadget->resourceLoaded = true;
@@ -262,14 +280,17 @@
263281 break;
264282 }
265283 }
 284+
266285 foreach ( preg_split( '/\s*\|\s*/', $m[3], -1, PREG_SPLIT_NO_EMPTY ) as $page ) {
267286 $page = "Gadget-$page";
 287+
268288 if ( preg_match( '/\.js/', $page ) ) {
269289 $gadget->scripts[] = $page;
270290 } elseif ( preg_match( '/\.css/', $page ) ) {
271291 $gadget->styles[] = $page;
272292 }
273293 }
 294+
274295 return $gadget;
275296 }
276297
@@ -394,17 +415,21 @@
395416 */
396417 public function getModule() {
397418 $pages = array();
398 - foreach( $this->styles as $style ) {
 419+
 420+ foreach ( $this->styles as $style ) {
399421 $pages['MediaWiki:' . $style] = array( 'type' => 'style' );
400422 }
 423+
401424 if ( $this->supportsResourceLoader() ) {
402425 foreach ( $this->scripts as $script ) {
403426 $pages['MediaWiki:' . $script] = array( 'type' => 'script' );
404427 }
405428 }
 429+
406430 if ( !count( $pages ) ) {
407431 return null;
408432 }
 433+
409434 return new GadgetResourceLoaderModule( $pages, $this->dependencies );
410435 }
411436
@@ -442,10 +467,13 @@
443468 public static function loadList() {
444469 static $gadgets = null;
445470
446 - if ( $gadgets !== null ) return $gadgets;
 471+ if ( $gadgets !== null ) {
 472+ return $gadgets;
 473+ }
447474
448475 wfProfileIn( __METHOD__ );
449476 $struct = self::loadStructuredList();
 477+
450478 if ( !$struct ) {
451479 $gadgets = $struct;
452480 wfProfileOut( __METHOD__ );
@@ -478,6 +506,7 @@
479507 }
480508 }
481509 }
 510+
482511 return true; // empty array
483512 }
484513
@@ -493,13 +522,15 @@
494523 global $wgMemc;
495524
496525 static $gadgets = null;
497 - if ( $gadgets !== null && $forceNewText === null ) return $gadgets;
 526+ if ( $gadgets !== null && $forceNewText === null ) {
 527+ return $gadgets;
 528+ }
498529
499530 wfProfileIn( __METHOD__ );
500531 $key = wfMemcKey( 'gadgets-definition', self::GADGET_CLASS_VERSION );
501532
502533 if ( $forceNewText === null ) {
503 - //cached?
 534+ // cached?
504535 $gadgets = $wgMemc->get( $key );
505536 if ( self::isValidList( $gadgets ) ) {
506537 wfProfileOut( __METHOD__ );
@@ -537,10 +568,10 @@
538569 }
539570 }
540571
541 - //cache for a while. gets purged automatically when MediaWiki:Gadgets-definition is edited
542 - $wgMemc->set( $key, $gadgets, 60*60*24 );
 572+ // cache for a while. gets purged automatically when MediaWiki:Gadgets-definition is edited
 573+ $wgMemc->set( $key, $gadgets, 60 * 60 * 24 );
543574 $source = $forceNewText !== null ? 'input text' : 'MediaWiki:Gadgets-definition';
544 - wfDebug( __METHOD__ . ": $source parsed, cache entry $key updated\n");
 575+ wfDebug( __METHOD__ . ": $source parsed, cache entry $key updated\n" );
545576 wfProfileOut( __METHOD__ );
546577
547578 return $gadgets;
Index: trunk/extensions/Gadgets/Gadgets.i18n.php
@@ -15,10 +15,10 @@
1616 * @author Daniel Kinzler, brightbyte.de
1717 */
1818 $messages['en'] = array(
19 - #for Special:Version
 19+ # for Special:Version
2020 'gadgets-desc' => 'Lets users select custom [[Special:Gadgets|CSS and JavaScript gadgets]] in their [[Special:Preferences|preferences]]',
2121
22 - #for Special:Preferences
 22+ # for Special:Preferences
2323 'prefs-gadgets' => 'Gadgets',
2424 'gadgets-prefstext' => 'Below is a list of special gadgets you can enable for your account.
2525 These gadgets are mostly based on JavaScript, so JavaScript has to be enabled in your browser for them to work.
@@ -27,7 +27,7 @@
2828 Also note that these special gadgets are not part of the MediaWiki software, and are usually developed and maintained by users on your local wiki.
2929 Local administrators can edit the [[MediaWiki:Gadgets-definition|definitions]] and [[Special:Gadgets|descriptions]] of available gadgets.',
3030
31 - #for Special:Gadgets
 31+ # for Special:Gadgets
3232 'gadgets' => 'Gadgets',
3333 'gadgets-title' => 'Gadgets',
3434 'gadgets-pagetext' => "Below is a list of special gadgets users can enable on their [[Special:Preferences|preferences page]], as defined by the [[MediaWiki:Gadgets-definition|definitions]].
@@ -128,7 +128,7 @@
129129 'gadgets-prefstext' => "Contino ye una lista de trastes especials que puede fer servir en a suya cuenta.
130130 Como quasi totz istos trastes son feitos en JavaScript, caldrá que tienga activato JavaScript en o suyo navegador ta que vaigan bien. Pare cuenta que istos trastes no tendrán garra efeuto en ista pachina de preferencias.
131131
132 -Pare cuenta tamién que istos trastes especials no fan parte d'o software MediaWiki, y que gosan estar desenvolicatos y mantenitos por usuarios d'a suya wiki local.
 132+Pare cuenta tamién que istos trastes especials no fan parte d'o software MediaWiki, y que gosan estar desenvolicatos y mantenitos por usuarios d'a suya wiki local.
133133 Os almenistradors locals pueden editar os trastes disponibles en as pachinas de [[MediaWiki:Gadgets-definition|definicions]] y de [[Special:Gadgets|descripcions]].",
134134 'gadgets' => 'Trastes',
135135 'gadgets-title' => 'Trastes',
@@ -689,14 +689,14 @@
690690 'gadgets-desc' => 'Permesas al uzantoj elekti proprajn [[Special:Gadgets|CSS kaj JavaScript aldonaĵojn]] en ties [[Special:Preferences|preferoj]].',
691691 'prefs-gadgets' => 'Aldonaĵoj',
692692 'gadgets-prefstext' => 'Jen listo de specialaj aldonaĵoj kiujn vi povas aktivigi por via uzulkonto.
693 -Plej multaj el ili baziĝas sur Ĵavaskriptoj, sekve Ĵavaskripto nepre estu aktivigita por ke ili funkciu.
694 -Notu ke tiuj aldonaĵoj ne efikos sur viaj preferoj.
 693+Plej multaj el ili baziĝas sur Ĵavaskriptoj, sekve Ĵavaskripto nepre estu aktivigita por ke ili funkciu.
 694+Notu ke tiuj aldonaĵoj ne efikos sur viaj preferoj.
695695
696696 Notu ankaŭ ke ili ne estas parto de la programaro MediaWiki, kaj estas kutime evoluigitaj kaj prizorgataj de uzuloj sur via loka vikio.
697697 Lokaj administrantoj povas redakti liston de haveblaj aldonaĵoj per [[MediaWiki:Gadgets-definition|difinoj]] kaj [[Special:Gadgets|priskriboj]].',
698698 'gadgets' => 'Aldonaĵoj',
699699 'gadgets-title' => 'Aldonaĵoj',
700 - 'gadgets-pagetext' => 'Jen listo da specialaj aldonaĵoj kiujn uzuloj povas aktivigi en [[Special:Preferences|siaj preferoj]], kiel difinite en [[MediaWiki:Gadgets-definition|difinoj]].
 700+ 'gadgets-pagetext' => 'Jen listo da specialaj aldonaĵoj kiujn uzuloj povas aktivigi en [[Special:Preferences|siaj preferoj]], kiel difinite en [[MediaWiki:Gadgets-definition|difinoj]].
701701 Ĉi tiu superrigardo provizas facilan aliron al la sistemaj mesaĝoj kiuj difinas la priskribon kaj la kodon de ĉiuj aldonaĵoj.',
702702 'gadgets-uses' => 'uzas',
703703 'gadgets-required-rights' => 'Bezonas la {{PLURAL:$2|$1 rajton|jenajn rajtojn: $1}}.',
@@ -1088,8 +1088,8 @@
10891089 'gadgets-export' => 'Izvezi',
10901090 'gadgets-export-title' => "Izvoz JS skripti (''gadgets'')",
10911091 'gadgets-not-found' => "''Gadget'' \"\$1\" nije pronađen.",
1092 - 'gadgets-export-text' => 'Za izvoz $1 JavaScript pomoćne skripte (\'\'gadgeta\'\'), kliknite na "{{int:gadgets-export-download}}" gumb, snimiti preuzetu datoteku,
1093 -zatim idete na Special:Import na odredišnoj wiki i postavite skriptu tamo. Zatim dodajte sljedeće na "MediaWiki:Gadgets-definition stranici:
 1092+ 'gadgets-export-text' => 'Za izvoz $1 JavaScript pomoćne skripte (\'\'gadgeta\'\'), kliknite na "{{int:gadgets-export-download}}" gumb, snimiti preuzetu datoteku,
 1093+zatim idete na Special:Import na odredišnoj wiki i postavite skriptu tamo. Zatim dodajte sljedeće na "MediaWiki:Gadgets-definition stranici:
10941094 <pre>$2</pre>
10951095 Morate imati odgovarajuća prava na odredišnoj wiki (uključujući i pravo na uređivanje sistemskih poruka) i uvoz iz snimljenih datoteka mora biti omogućen.',
10961096 'gadgets-export-download' => 'Preuzmi',
@@ -1302,7 +1302,7 @@
13031303 $messages['jv'] = array(
13041304 'gadgets-desc' => 'Marengaké para panganggo milih [[Special:Gadgets|gadget CSS lan JavaScript]] ngliwati [[Special:Preferences|préferènsi]] dhéwé-dhéwé.',
13051305 'prefs-gadgets' => 'Gadget',
1306 - 'gadgets-prefstext' => 'Ing ngisor iki daftar gadget astaméwa sing bisa panjenangan aktifaké kanggo rékening panjenengan. Gadget-gadget iki sabagéyan gedhé adhedhasar JavaScript dadi panjenengan kudu ngaktifaké JavaScript ing panjlajah wèb panjenengan supaya bisa nglakokaké.
 1306+ 'gadgets-prefstext' => 'Ing ngisor iki daftar gadget astaméwa sing bisa panjenangan aktifaké kanggo rékening panjenengan. Gadget-gadget iki sabagéyan gedhé adhedhasar JavaScript dadi panjenengan kudu ngaktifaké JavaScript ing panjlajah wèb panjenengan supaya bisa nglakokaké.
13071307 Mangga diwigatèkaké yèn gadget-gadget iki ora ndarbèni pangaruh marang kaca préferènsi iki.
13081308
13091309 Uga mangga diwigatèkaké yèn gadget astaméwa iki dudu bagéyan saka piranti empuk MediaWiki lan biasané dikembangaké lan diopèni déning panganggo-panganggo ing wiki lokal panjenengan. Pangurus lokal bisa nyunting gadget sing kasedyakaké nganggo [[MediaWiki:Gadgets-definition|dhéfinisi]] lan [[Special:Gadgets|uraian]].',
@@ -1490,7 +1490,7 @@
14911491 D'Gadgete baséiere meeschtens op engem JavaScript, dofir muss JavaScript an Ärem Browser aktivéiert sinn, fir datt se fonctionéieren.
14921492 D'Gadgete fonctionéieren awer net op dëser Säit mat de perséinlechen Astellungen.
14931493
1494 -Ausserdeem sollt Dir wëssen, datt dës Gadgete generell net Deel vu MediaWiki sinn, a meeschtens vu Benotzer vu lokale Wikien entwéckelt an ënnerhale ginn.
 1494+Ausserdeem sollt Dir wëssen, datt dës Gadgete generell net Deel vu MediaWiki sinn, a meeschtens vu Benotzer vu lokale Wikien entwéckelt an ënnerhale ginn.
14951495 Lokal Wiki-Administrateure kënnen d'Lëscht von den disponibele Gadgeten op de Säiten [[MediaWiki:Gadgets-definition|Definitioune vun Gadgeten]] a [[Special:Gadgets|Beschreiwunge vu Gadgeten]] änneren.",
14961496 'gadgets' => 'Gadgeten',
14971497 'gadgets-title' => 'Gadgeten',
@@ -1519,7 +1519,7 @@
15201520 De oetbreijinge zeen veurnamelik gebaseerd op JavaScript, dus JavaScript mót veur diene browser ingesjakeld zeen óm die te laote wirke.
15211521 De oetbreijinge höbbe geine invlood op dees pazjena mit veurkäöre.
15221522
1523 -Dees sjpeciaal oetbreijinge zeen ouch gein óngerdeil van de MediaWiki-software en die mótte meistal óntwikkeld en óngerhauwe waere door gebroekers van diene wiki.
 1523+Dees sjpeciaal oetbreijinge zeen ouch gein óngerdeil van de MediaWiki-software en die mótte meistal óntwikkeld en óngerhauwe waere door gebroekers van diene wiki.
15241524 Lokaal beheerders kónne de besjikbaar oetbreijinge aangaeve in [[MediaWiki:Gadgets-definition]] en [[Special:Gadgets]].',
15251525 'gadgets' => 'Oetbreijinger',
15261526 'gadgets-title' => 'Oetbreijinger',
@@ -1740,7 +1740,7 @@
17411741 'prefs-gadgets' => 'उपकरणहरु',
17421742 'gadgets-prefstext' => 'विशेष उपकरणहरुको सूची तल दिइएकोछ तपाईंले आफ्नो खातामा सक्रिय पार्न सक्नुहुन्छ।
17431743 प्राय सबै उपकरणहरु जाभास्क्रीप्टमा आधारित छन्, यस कारण ब्राउजरमा काम गराउनको लागि जाभास्क्रीप्टलाई सक्रिय गर्नु पर्छ।
1744 -याद राख्नुहोस् ती उपकरणहरुले अभिरुचि पृष्ठमा असर गर्दैनन्।
 1744+याद राख्नुहोस् ती उपकरणहरुले अभिरुचि पृष्ठमा असर गर्दैनन्।
17451745 यो पनि याद राखुहोस् यी विशेष उपकरणहरु मीडिया विकि सफ्टवेयरभित्र पर्दैनन् र प्राय स्थानीय विकि प्रयोगकर्ताहरुले विकास यसको विकास र सञ्चालन गर्दछन्। स्थानीय प्रबन्धकहरुले उपलब्ध उपकरणहरुका [[MediaWiki:Gadgets-definition|परिभाषाहरु]] र [[Special:Gadgets|विवरणहरु]] सम्पादन गर्दछन्।',
17461746 'gadgets' => 'उपकरणहरु',
17471747 'gadgets-title' => 'उपकरणहरु',
@@ -1952,15 +1952,15 @@
19531953 $messages['pms'] = array(
19541954 'gadgets-desc' => "A lassa che j'utent a selession-o [[Special:Gadgets|CSS e gadget JavaScript]] ant ij [[Special:Preferences|sò gust]]",
19551955 'prefs-gadgets' => 'Component',
1956 - 'gadgets-prefstext' => "Ambelessì sota a-i é na lista ëd component ch'a peul vischesse ant sò cont personal.
1957 -Sti component-sì a son dzortut basà ansima a JavaScript, donca a venta anans tut che JavaScript a sia avisch ant sò navigator, s'a veul che ij component a travajo.
 1956+ 'gadgets-prefstext' => "Ambelessì sota a-i é na lista ëd component ch'a peul vischesse ant sò cont personal.
 1957+Sti component-sì a son dzortut basà ansima a JavaScript, donca a venta anans tut che JavaScript a sia avisch ant sò navigator, s'a veul che ij component a travajo.
19581958 Ch'a ten-a present che sti component a l'han gnun efet ansima a la pàgina dij \"sò gust\".
19591959
1960 -Ch'a nòta ëdcò che a son nen part dël programa MediaWiki e che për sòlit a resto dësvlupà e mantnù da dj'utent dla wiki andova chiel/chila as treuva adess.
 1960+Ch'a nòta ëdcò che a son nen part dël programa MediaWiki e che për sòlit a resto dësvlupà e mantnù da dj'utent dla wiki andova chiel/chila as treuva adess.
19611961 J'aministrator locaj a peulo regolé ij component disponibij ën dovrand le pàgine [[MediaWiki:Gadgets-definition|definission dij component]] e [[Special:Gadgets|component]].",
19621962 'gadgets' => 'Component',
19631963 'gadgets-title' => 'Component',
1964 - 'gadgets-pagetext' => "Ambelessì sota a-i é na lista ëd component spessiaj che j'utent a peulo butesse avisch ant ij [[Special:Preferences|sò gust]], conforma a la [[MediaWiki:Gadgets-definition|definission dij component]].
 1964+ 'gadgets-pagetext' => "Ambelessì sota a-i é na lista ëd component spessiaj che j'utent a peulo butesse avisch ant ij [[Special:Preferences|sò gust]], conforma a la [[MediaWiki:Gadgets-definition|definission dij component]].
19651965 Sta lista complessiva a smon na stra còmoda për rivé a le pàgine ëd messagi ëd sistema ch'a definisso descrission e còdes ëd vira component.",
19661966 'gadgets-uses' => 'a dòvra',
19671967 'gadgets-required-rights' => 'A ciama {{PLURAL:$2|ël drit $1|ij drit sì-dapress: $1}}.',
@@ -2142,8 +2142,8 @@
21432143 'gadgets-export' => 'Экспортировать',
21442144 'gadgets-export-title' => 'Экспорт гаджета',
21452145 'gadgets-not-found' => 'Гаджет «$1» не найден.',
2146 - 'gadgets-export-text' => 'Для экспорта гаджета $1, нажмите кнопку «{{int:gadgets-export-download}}», сохраните загруженный файл,
2147 -перейдите на страницу Special:Import целевой вики и загрузите файл. Затем добавьте следующие строки на страницу MediaWiki:Gadgets-definition:
 2146+ 'gadgets-export-text' => 'Для экспорта гаджета $1, нажмите кнопку «{{int:gadgets-export-download}}», сохраните загруженный файл,
 2147+перейдите на страницу Special:Import целевой вики и загрузите файл. Затем добавьте следующие строки на страницу MediaWiki:Gadgets-definition:
21482148 <pre>$2</pre>
21492149 Вы должны иметь соответствующие разрешения в целевой вики (в том числе право на редактирование системных сообщений), также на сервере должна быть включена настройка импорта из файлов.',
21502150 'gadgets-export-download' => 'Загрузить',
@@ -2198,8 +2198,8 @@
21992199 'gadgets-export' => 'Экспортаа',
22002200 'gadgets-export-title' => 'Ҕааддьыты таһаарыы (экспорт)',
22012201 'gadgets-not-found' => '"$1" ҕааддьыт көстүбэтэ.',
2202 - 'gadgets-export-text' => '$1 ҕааддьыты таһаарарга (экспорт), «{{int:gadgets-export-download}}» тимэҕи баттаа, хачайдаммыт билэни бигэргэт,
2203 -онтон угуохтаах биикиҥ Special:Import сирэйигэр киирэн уган кэбис. Ол кэннэ MediaWiki:Gadgets-definition сирэйгэ бу устуруокалары эп:
 2202+ 'gadgets-export-text' => '$1 ҕааддьыты таһаарарга (экспорт), «{{int:gadgets-export-download}}» тимэҕи баттаа, хачайдаммыт билэни бигэргэт,
 2203+онтон угуохтаах биикиҥ Special:Import сирэйигэр киирэн уган кэбис. Ол кэннэ MediaWiki:Gadgets-definition сирэйгэ бу устуруокалары эп:
22042204 <pre>$2</pre>
22052205 Угуохтаах биикигэр аналлаах көҥүллээх буолуохтааххын (ол иһигэр тиһилик биллэриилэрин эрэдээксийэлиир кыах), эбиитин сиэрбэргэ билэни киллэрии көҥүллэммит буолуохтаах.',
22062206 'gadgets-export-download' => 'Хачайдааһын',
@@ -2263,8 +2263,8 @@
22642264 'gadgets-export' => 'Exportovať',
22652265 'gadgets-export-title' => 'Export nástroja',
22662266 'gadgets-not-found' => 'Nástroj „$1” nebol nájdený.',
2267 - 'gadgets-export-text' => 'Ak chcete exportovať nástroj $1, kliknite na tlačidlo „{{int:gadgets-export-download}}“, uložte stiahnutý súbor,
2268 - choďte na stránku Special:Import na cieľovej wiki a nahrajte ho. Potom pridajte nasledujúce na stránku MediaWiki:Gadgets-definition:
 2267+ 'gadgets-export-text' => 'Ak chcete exportovať nástroj $1, kliknite na tlačidlo „{{int:gadgets-export-download}}“, uložte stiahnutý súbor,
 2268+ choďte na stránku Special:Import na cieľovej wiki a nahrajte ho. Potom pridajte nasledujúce na stránku MediaWiki:Gadgets-definition:
22692269 <pre>$2</pre>
22702270 Musíte mať príslušné oprávnenia na cieľovej wiki (vrátane práva na úpravu systémových správ) a import z nahraného súboru musí byť povolený.',
22712271 'gadgets-export-download' => 'Stiahnuť',
@@ -2278,8 +2278,8 @@
22792279 'gadgets-desc' => 'Omogoča uporabnikom, da vključijo [[Special:Gadgets|vtičnike CSS in JavaScript]] v [[Special:Preferences|nastavitvah]]',
22802280 'prefs-gadgets' => 'Vtičniki',
22812281 'gadgets-prefstext' => 'Prikazan je seznam posebnih vtičnikov, ki si jih lahko omogočite za vaš račun.
2282 -Večinoma temeljijo na JavaScript, zato mora biti za njihovo delovanje omogočen v vašem brskalniku.
2283 -Ti vtičniki nimajo nobenega vpliva na to nastavitveno stran.
 2282+Večinoma temeljijo na JavaScript, zato mora biti za njihovo delovanje omogočen v vašem brskalniku.
 2283+Ti vtičniki nimajo nobenega vpliva na to nastavitveno stran.
22842284
22852285 Prav tako pomnite, da ti vtičniki niso del programja MediaWiki, in jih običajno razvijajo ter vzdržujejo uporabniki na vašem lokalnem wikiju.
22862286 Administratorji lahko uredite seznam vtičnikov z uporabo [[Special:Gadgets|posebne strani]] in [[MediaWiki:Gadgets-definition|opisov]].',
@@ -2550,8 +2550,8 @@
25512551 'gadgets-export' => 'Iluwas',
25522552 'gadgets-export-title' => 'Pagluluwas ng gadyet',
25532553 'gadgets-not-found' => 'Hindi natagpuan ang gadyet na "$1".',
2554 - 'gadgets-export-text' => 'Upang iluwas ang gadyet na $1, pindutin ang pindutang "{{int:gadgets-export-download}}", sagipin ang talaksang ikinargang paibaba,
2555 -pumunta sa Special:Import na nasa kapupuntahang wiki at ikarga itong paitaas. Pagkaraan ay idagdag ang sumusunod sa pahina ng MediaWiki:Gadgets-definition:
 2554+ 'gadgets-export-text' => 'Upang iluwas ang gadyet na $1, pindutin ang pindutang "{{int:gadgets-export-download}}", sagipin ang talaksang ikinargang paibaba,
 2555+pumunta sa Special:Import na nasa kapupuntahang wiki at ikarga itong paitaas. Pagkaraan ay idagdag ang sumusunod sa pahina ng MediaWiki:Gadgets-definition:
25562556 <pre>$2</pre>
25572557 Dapat kang mayroong nararapat na mga pahintulot sa kapupuntahang wiki (kasama ang karapatang mamatnugot ng mga mensahe ng sistema) at dapat na gumagana ang mga inangkat mula sa mga talaksang ikinargang paitaas',
25582558 'gadgets-export-download' => 'Ikargang pababa',
Index: trunk/extensions/Gadgets/ApiQueryGadgets.php
@@ -59,6 +59,7 @@
6060 if ( $this->categories && !isset( $this->categories[$category] ) ) {
6161 continue;
6262 }
 63+
6364 foreach ( $list as $g ) {
6465 if ( $this->isNeeded( $g ) ) {
6566 $result[] = $g;
@@ -80,15 +81,19 @@
8182 if ( isset( $this->props['id'] ) ) {
8283 $row['id'] = $g->getName();
8384 }
 85+
8486 if ( isset( $this->props['metadata'] ) ) {
8587 $row['metadata'] = $this->fakeMetadata( $g );
8688 $this->setIndexedTagNameForMetadata( $row['metadata'] );
8789 }
 90+
8891 if ( isset( $this->props['desc'] ) ) {
8992 $row['desc'] = $g->getDescription();
9093 }
 94+
9195 $data[] = $row;
9296 }
 97+
9398 $result->setIndexedTagName( $data, 'gadget' );
9499 $result->addValue( 'query', $this->getModuleName(), $data );
95100 }
@@ -212,5 +217,4 @@
213218 public function getVersion() {
214219 return __CLASS__ . ': $Id$';
215220 }
216 -
217221 }
Index: trunk/extensions/Gadgets/Gadgets.php
@@ -2,7 +2,6 @@
33 /**
44 * Gadgets extension - lets users select custom javascript gadgets
55 *
6 - *
76 * For more info see http://mediawiki.org/wiki/Extension:Gadgets
87 *
98 * @file
@@ -12,7 +11,7 @@
1312 * @license GNU General Public Licence 2.0 or later
1413 */
1514
16 -if( !defined( 'MEDIAWIKI' ) ) {
 15+if ( !defined( 'MEDIAWIKI' ) ) {
1716 echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" );
1817 die( 1 );
1918 }
@@ -36,7 +35,7 @@
3736 $wgHooks['ResourceLoaderRegisterModules'][] = 'GadgetHooks::registerModules';
3837 $wgHooks['UnitTestsList'][] = 'GadgetHooks::unitTestsList';
3938
40 -$dir = dirname(__FILE__) . '/';
 39+$dir = dirname( __FILE__ ) . '/';
4140 $wgExtensionMessagesFiles['Gadgets'] = $dir . 'Gadgets.i18n.php';
4241 $wgExtensionAliasesFiles['Gadgets'] = $dir . 'Gadgets.alias.php';
4342
Index: trunk/extensions/Gadgets/SpecialGadgets.php
@@ -9,14 +9,6 @@
1010 * @license GNU General Public License 2.0 or later
1111 */
1212
13 -if( !defined( 'MEDIAWIKI' ) ) {
14 - echo( "not a valid entry point.\n" );
15 - die( 1 );
16 -}
17 -
18 -/**
19 - *
20 - */
2113 class SpecialGadgets extends SpecialPage {
2214
2315 /**
@@ -32,13 +24,14 @@
3325 */
3426 function execute( $par ) {
3527 $parts = explode( '/', $par );
 28+
3629 if ( count( $parts ) == 2 && $parts[0] == 'export' ) {
3730 $this->showExportForm( $parts[1] );
3831 } else {
3932 $this->showMainForm();
4033 }
4134 }
42 -
 35+
4336 /**
4437 * Displays form showing the list of installed gadgets
4538 */
@@ -63,43 +56,50 @@
6457
6558 $msgOpt = array( 'parseinline', 'parsemag' );
6659 $editInterfaceAllowed = $wgUser->isAllowed( 'editinterface' );
67 -
 60+
6861 foreach ( $gadgets as $section => $entries ) {
6962 if ( $section !== false && $section !== '' ) {
7063 $t = Title::makeTitleSafe( NS_MEDIAWIKI, "Gadget-section-$section$lang" );
7164 if ( $editInterfaceAllowed ) {
7265 $lnkTarget = $t
73 - ? $skin->link( $t, wfMsgHTML( 'edit' ), array(), array( 'action' => 'edit' ) )
 66+ ? $skin->link( $t, wfMsgHTML( 'edit' ), array(), array( 'action' => 'edit' ) )
7467 : htmlspecialchars( $section );
7568 $lnk = "&#160; &#160; [$lnkTarget]";
7669 } else {
7770 $lnk = '';
7871 }
 72+
7973 $ttext = wfMsgExt( "gadget-section-$section", $msgOpt );
8074
81 - if( $listOpen ) {
 75+ if ( $listOpen ) {
8276 $wgOut->addHTML( Xml::closeElement( 'ul' ) . "\n" );
8377 $listOpen = false;
8478 }
 79+
8580 $wgOut->addHTML( Html::rawElement( 'h2', array(), $ttext . $lnk ) . "\n" );
8681 }
8782
8883 foreach ( $entries as $gadget ) {
8984 $t = Title::makeTitleSafe( NS_MEDIAWIKI, "Gadget-{$gadget->getName()}$lang" );
90 - if ( !$t ) continue;
9185
 86+ if ( !$t ) {
 87+ continue;
 88+ }
 89+
9290 $links = array();
9391 if ( $editInterfaceAllowed ) {
9492 $links[] = $skin->link( $t, wfMsgHTML( 'edit' ), array(), array( 'action' => 'edit' ) );
9593 }
 94+
9695 $links[] = $skin->link( $this->getTitle( "export/{$gadget->getName()}" ), wfMsgHtml( 'gadgets-export' ) );
97 -
 96+
9897 $ttext = wfMsgExt( "gadget-{$gadget->getName()}", $msgOpt );
9998
100 - if( !$listOpen ) {
 99+ if ( !$listOpen ) {
101100 $listOpen = true;
102101 $wgOut->addHTML( Xml::openElement( 'ul' ) );
103102 }
 103+
104104 $lnk = '&#160;&#160;' . wfMsg( 'parentheses', $wgLang->pipeList( $links ) );
105105 $wgOut->addHTML( Xml::openElement( 'li' ) .
106106 $ttext . $lnk . "<br />" .
@@ -109,26 +109,31 @@
110110 $lnk = array();
111111 foreach ( $gadget->getScriptsAndStyles() as $codePage ) {
112112 $t = Title::makeTitleSafe( NS_MEDIAWIKI, $codePage );
113 - if ( !$t ) continue;
114113
 114+ if ( !$t ) {
 115+ continue;
 116+ }
 117+
115118 $lnk[] = $skin->link( $t, htmlspecialchars( $t->getText() ) );
116119 }
117120 $wgOut->addHTML( $wgLang->commaList( $lnk ) );
118121 $rights = $gadget->getRequiredRights();
 122+
119123 if ( count( $rights ) ) {
120 - $wgOut->addHTML( '<br />' .
 124+ $wgOut->addHTML( '<br />' .
121125 wfMessage( 'gadgets-required-rights', $wgLang->commaList( $rights ), count( $rights ) )->parse()
122126 );
123127 }
 128+
124129 if ( $gadget->isOnByDefault() ) {
125130 $wgOut->addHTML( '<br />' . wfMessage( 'gadgets-default' )->parse() );
126131 }
127 -
 132+
128133 $wgOut->addHTML( Xml::closeElement( 'li' ) . "\n" );
129134 }
130135 }
131136
132 - if( $listOpen ) {
 137+ if ( $listOpen ) {
133138 $wgOut->addHTML( Xml::closeElement( 'ul' ) . "\n" );
134139 }
135140 }
@@ -145,7 +150,7 @@
146151 $wgOut->showErrorPage( 'error', 'gadgets-not-found', array( $gadget ) );
147152 return;
148153 }
149 -
 154+
150155 $g = $gadgets[$gadget];
151156 $this->setHeaders();
152157 $wgOut->setPagetitle( wfMsg( "gadgets-export-title" ) );
Index: trunk/extensions/Gadgets/Gadgets_tests.php
@@ -1,14 +1,14 @@
22 <?php
3 -
43 /**
54 * @group Gadgets
65 */
7 -class GadgetsTest extends PHPUnit_Framework_TestCase {
86
 7+class GadgetsTest extends PHPUnit_Framework_TestCase {
98 private function create( $line ) {
109 $g = Gadget::newFromDefinition( $line );
1110 // assertInstanceOf() is available since PHPUnit 3.5
1211 $this->assertEquals( 'Gadget', get_class( $g ) );
 12+
1313 return $g;
1414 }
1515
@@ -34,7 +34,7 @@
3535 $g = $this->create( '*foo [ResourceLoader]|foo.js|foo.css' );
3636 $this->assertEquals( 'foo', $g->getName() );
3737 $this->assertTrue( $g->supportsResourceLoader() );
38 - $this->assertEquals(0, count( $g->getLegacyScripts() ) );
 38+ $this->assertEquals( 0, count( $g->getLegacyScripts() ) );
3939 }
4040
4141 function testDependencies() {
@@ -45,12 +45,11 @@
4646 }
4747
4848 function testPreferences() {
49 - global $wgUser;
 49+ global $wgUser, $wgOut, $wgTitle;
5050
5151 // This test makes call to the parser which requires valids Outputpage
5252 // and Title objects. Set them up there, they will be released at the
5353 // end of the test.
54 - global $wgOut, $wgTitle;
5554 $old_wgOut = $wgOut;
5655 $old_wgTitle = $wgTitle;
5756 $wgTitle = Title::newFromText( 'Parser test for Gadgets extension' );
Index: trunk/extensions/Gadgets/ApiQueryGadgetCategories.php
@@ -50,14 +50,17 @@
5151 if ( isset( $this->props['name'] ) ) {
5252 $row['name'] = $category;
5353 }
 54+
5455 if ( $category !== "" ) {
5556 if ( isset( $this->props['title'] ) ) {
5657 $row['desc'] = wfMessage( "gadget-section-$category" )->parse();
5758 }
5859 }
 60+
5961 if ( isset( $this->props['members'] ) ) {
6062 $row['members'] = count( $list );
6163 }
 64+
6265 $data[] = $row;
6366 }
6467 }
@@ -102,6 +105,7 @@
103106 public function getExamples() {
104107 $params = $this->getAllowedParams();
105108 $allProps = implode( '|', $params['prop'][ApiBase::PARAM_TYPE] );
 109+
106110 return array(
107111 'Get a list of existing gadget categories:',
108112 ' api.php?action=query&list=gadgetcategories',
@@ -113,5 +117,4 @@
114118 public function getVersion() {
115119 return __CLASS__ . ': $Id$';
116120 }
117 -
118121 }
Index: trunk/extensions/Gadgets/README
@@ -32,7 +32,7 @@
3333
3434 == Caveats ==
3535
36 -* Gadgets do not apply to Special:Preferences, Special:UserLogin and
 36+* Gadgets do not apply to Special:Preferences, Special:UserLogin and
3737 Special:ResetPass so users can always disable any broken gadgets they
3838 may have enabled, and malicious gadgets will be unable to steal passwords.
3939 * Uses BeforePageDisplay hook, thus only works with MonoBook based skins;

Comments

#Comment by Aaron Schulz (talk | contribs)   06:59, 23 September 2011

One nice thing I noticed with entry-point guards is that they prevent fatals about some parent class (e.g. Child extends Parent) not existing when somebody tries to access the php file. Probably not worth the clutter of having them though.

Status & tagging log