r109524 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109523‎ | r109524 | r109525 >
Date:11:22, 19 January 2012
Author:siebrand
Status:ok
Tags:backcompat, languagegetmagic 
Comment:
Remove use of deprecated LanguageGetMagic hook.
Remove unused global.
Remove some superfluous comments.
Add i18n for missing special page alias.
Remove calls to pre-1.15 compat wfLoadExtensionMessages().
Add a FIXME for hard coded UI text.
Modified paths:
  • /trunk/extensions/QPoll/ctrl/poll/qp_abstractpoll.php (modified) (history)
  • /trunk/extensions/QPoll/i18n/QPoll.i18n.magic.php (added) (history)
  • /trunk/extensions/QPoll/i18n/qp.alias.php (modified) (history)
  • /trunk/extensions/QPoll/includes/qp_functionshook.php (modified) (history)
  • /trunk/extensions/QPoll/qp_user.php (modified) (history)
  • /trunk/extensions/QPoll/specials/qp_results.php (modified) (history)
  • /trunk/extensions/QPoll/specials/qp_special.php (modified) (history)
  • /trunk/extensions/QPoll/specials/qp_webinstall.php (modified) (history)

Diff [purge]

Index: trunk/extensions/QPoll/i18n/QPoll.i18n.magic.php
@@ -0,0 +1,10 @@
 2+<?php
 3+/**
 4+ * Internationalization file for magic words.
 5+ */
 6+
 7+$magicWords = array();
 8+
 9+$magicWords['en'] = array(
 10+ 'qpuserchoice' => array( 0, 'qpuserchoice' ),
 11+);
Property changes on: trunk/extensions/QPoll/i18n/QPoll.i18n.magic.php
___________________________________________________________________
Added: svn:eol-style
112 + native
Added: svn:keywords
213 + Id
Index: trunk/extensions/QPoll/i18n/qp.alias.php
@@ -11,6 +11,8 @@
1212 /** English (English) */
1313 $specialPageAliases['en'] = array(
1414 'PollResults' => array( 'PollResults' ),
 15+ 'QPollWebInstall' => array( 'QPollWebInstall' ),
 16+
1517 );
1618
1719 /** Arabic (العربية) */
Index: trunk/extensions/QPoll/specials/qp_special.php
@@ -33,10 +33,6 @@
3434 * @author QuestPC <questpc@rambler.ru>
3535 */
3636
37 -if ( !defined( 'MEDIAWIKI' ) ) {
38 - die( "This file is part of the QPoll extension. It is not a valid entry point.\n" );
39 -}
40 -
4137 /**
4238 * A special page with handy built-in Linker
4339 */
@@ -93,7 +89,6 @@
9490 * thus, it is much safer to implement a larger subset of pager itself
9591 */
9692 abstract class qp_QueryPage extends qp_SpecialPage {
97 -
9893 var $listoutput = false;
9994
10095 public function __construct() {
Index: trunk/extensions/QPoll/specials/qp_results.php
@@ -33,19 +33,9 @@
3434 * @author QuestPC <questpc@rambler.ru>
3535 */
3636
37 -if ( !defined( 'MEDIAWIKI' ) ) {
38 - die( "This file is part of the QPoll extension. It is not a valid entry point.\n" );
39 -}
40 -
4137 class PollResults extends qp_SpecialPage {
42 -
4338 public function __construct() {
4439 parent::__construct( 'PollResults', 'read' );
45 - # for MW 1.15 (still being used by many customers)
46 - # please do not remove until 2012
47 - if ( qp_Setup::mediaWikiVersionCompare( '1.16' ) ) {
48 - wfLoadExtensionMessages( 'QPoll' );
49 - }
5040 }
5141
5242 static $accessPermissions = array( 'read', 'pollresults' );
Index: trunk/extensions/QPoll/specials/qp_webinstall.php
@@ -1,15 +1,10 @@
22 <?php
33
4 -if ( !defined( 'MEDIAWIKI' ) ) {
5 - die( "This file is part of the QPoll extension. It is not a valid entry point.\n" );
6 -}
7 -
84 /**
95 * Installs/updates DB schema for the people who do not have shell access
106 * (not being able to run maintenance scripts)
117 */
128 class qp_WebInstall extends qp_SpecialPage {
13 -
149 private $allowed_groups = array( 'sysop', 'bureaucrat' );
1510
1611 public function __construct() {
@@ -30,11 +25,11 @@
3126
3227 # only sysops and bureaucrats can update the DB
3328 if ( !$this->userCanExecute( $wgUser ) ) {
 29+ // @todo FIXME: i18n missing.
3430 $wgOut->addHTML( 'You have to be a member of the following group(s) to perform web install:' . implode( ', ', $this->allowed_groups ) );
3531 return;
3632 }
3733 # display update result
3834 $wgOut->addHTML( qp_SchemaUpdater::checkAndUpdate() );
3935 }
40 -
41 -} /* end of qp_WebInstall class */
 36+}
Index: trunk/extensions/QPoll/ctrl/poll/qp_abstractpoll.php
@@ -102,10 +102,8 @@
103103 * @public
104104 */
105105 function __construct( array $argv, qp_AbstractPollView $view ) {
106 - global $wgLanguageCode;
107106 $this->mResponse = qp_Setup::$request->response();
108107 # Determine which messages will be used, according to the language.
109 - qp_Setup::onLoadAllMessages();
110108 $view->setController( $this );
111109 # *** get visual style poll attributes ***
112110 $perRow = intval( array_key_exists( 'perrow', $argv ) ? $argv['perrow'] : 1 );
@@ -289,5 +287,4 @@
290288 }
291289 return $showResults;
292290 }
293 -
294 -} /* end of qp_AbstractPoll class */
 291+}
Index: trunk/extensions/QPoll/qp_user.php
@@ -336,8 +336,9 @@
337337 $wgExtensionMessagesFiles['QPoll'] = self::$ExtDir . '/i18n/qp.i18n.php';
338338 # localized namespace names
339339 $wgExtensionMessagesFiles['QPollNamespaces'] = self::$ExtDir . '/i18n/qp.namespaces.php';
340 - # localized special page titles
 340+ # localized special page titles and magic words.
341341 $wgExtensionMessagesFiles['QPollAlias'] = self::$ExtDir . '/i18n/qp.alias.php';
 342+ $wgExtensionMessagesFiles['QPollMagic'] = self::$ExtDir . '/i18n/QPoll.i18n.magic.php';
342343
343344 # extension setup, hooks handling and content transformation
344345 self::autoLoad( array(
@@ -419,15 +420,11 @@
420421 'interpretation/qp_eval.php' => 'qp_Eval'
421422 ) );
422423
423 - # TODO: Use the new technique for i18n of special page aliases
424424 $wgSpecialPages['PollResults'] = 'PollResults';
425425 $wgSpecialPages['QPollWebInstall'] = 'qp_WebInstall';
426 - # TODO: Use the new technique for i18n of magic words
427426 # instantiating fake instance for PHP < 5.2.3, which does not support 'Class::method' type of callbacks
428 - $wgHooks['LanguageGetMagic'][] =
429427 $wgHooks['MediaWikiPerformAction'][] =
430428 $wgHooks['ParserFirstCallInit'][] =
431 - $wgHooks['LoadAllMessages'][] =
432429 $wgHooks['ParserAfterTidy'][] =
433430 $wgHooks['CanonicalNamespaces'][] = new qp_Setup;
434431 $wgHooks['LoadExtensionSchemaUpdates'][] = new qp_SchemaUpdater;
@@ -530,35 +527,6 @@
531528 return $attr_vals;
532529 }
533530
534 - static function onLoadAllMessages() {
535 - if ( !self::$messagesLoaded ) {
536 - self::$messagesLoaded = true;
537 - # for MW 1.15 which is still being used by many customers
538 - # please do not remove until 2012
539 - if ( self::mediaWikiVersionCompare( '1.16' ) ) {
540 - wfLoadExtensionMessages( 'QPoll' );
541 - }
542 - }
543 - return true;
544 - }
545 -
546 - static function ParserFunctionsWords( $lang ) {
547 - $words = array();
548 - $words[ 'en' ] = array( 'qpuserchoice' => array( 0, 'qpuserchoice' ) );
549 - # English is used as a fallback, and the English synonyms are
550 - # used if a translation has not been provided for a given word
551 - return ( $lang == 'en' || !array_key_exists( $lang, $words ) )
552 - ? $words[ 'en' ]
553 - : array_merge( $words[ 'en' ], $words[ $lang ] );
554 - }
555 -
556 - static function onLanguageGetMagic( &$magicWords, $langCode ) {
557 - foreach ( self::ParserFunctionsWords( $langCode ) as $word => $trans ) {
558 - $magicWords[$word] = $trans;
559 - }
560 - return true;
561 - }
562 -
563531 static function clearCache() {
564532 if ( self::$cache_control ) {
565533 global $parserMemc;
Index: trunk/extensions/QPoll/includes/qp_functionshook.php
@@ -33,10 +33,6 @@
3434 * @author QuestPC <questpc@rambler.ru>
3535 */
3636
37 -if ( !defined( 'MEDIAWIKI' ) ) {
38 - die( "This file is part of the QPoll extension. It is not a valid entry point.\n" );
39 -}
40 -
4137 class qp_FunctionsHook {
4238
4339 var $frame;
@@ -51,7 +47,6 @@
5248 var $error_message = 'no_such_poll';
5349
5450 function qpuserchoice( Parser &$parser, PPFrame $frame, array $args ) {
55 - qp_Setup::onLoadAllMessages();
5651 $this->frame = $frame;
5752 $this->args = &$args;
5853 if ( isset( $args[ 0 ] ) ) {
@@ -138,4 +133,4 @@
139134 return $result;
140135 }
141136
142 -} /* end of qp_FunctionsHook class */
 137+}
\ No newline at end of file

Status & tagging log