r73936 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73935‎ | r73936 | r73937 >
Date:07:56, 29 September 2010
Author:nikerabbit
Status:ok
Tags:
Comment:
More cleanup to MessageGroups
Modified paths:
  • /trunk/extensions/Translate/MessageGroups.php (modified) (history)
  • /trunk/extensions/Translate/tag/TranslatablePage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/MessageGroups.php
@@ -900,17 +900,15 @@
901901 $res = $dbr->select( $tables, $vars, $conds, __METHOD__, $options );
902902
903903 foreach ( $res as $r ) {
904 - /// @todo Lazy-construct translatable page message groups.
905 - $title = Title::makeTitle( $r->page_namespace, $r->page_title )->getPrefixedText();
906 - $id = "page|$title";
 904+ $title = Title::makeTitle( $r->page_namespace, $r->page_title );
 905+ $id = TranslatablePage::getMessageGroupIdFromTitle( $title );
907906 $wgTranslateCC[$id] = new WikiPageMessageGroup( $id, $title );
908 - $wgTranslateCC[$id]->setLabel( $title );
 907+ $wgTranslateCC[$id]->setLabel( $title->getPrefixedText() );
909908 }
910909 }
911910
912 - wfRunHooks( 'TranslatePostInitGroups', array( &$wgTranslateCC ) );
913 -
914911 $autoload = array();
 912+ wfRunHooks( 'TranslatePostInitGroups', array( &$wgTranslateCC, &$deps, &$autoload ) );
915913
916914 foreach ( $wgTranslateGroupFiles as $configFile ) {
917915 wfDebug( $configFile . "\n" );
@@ -962,15 +960,11 @@
963961 } else {
964962 return new $creater;
965963 }
966 - } else {
967 - if ( array_key_exists( $id, $wgTranslateCC ) ) {
968 - if ( is_callable( $wgTranslateCC[$id] ) ) {
969 - return call_user_func( $wgTranslateCC[$id], $id );
970 - } else {
971 - return $wgTranslateCC[$id];
972 - }
 964+ } elseif ( isset( $wgTranslateCC[$id] ) ) {
 965+ if ( is_callable( $wgTranslateCC[$id] ) ) {
 966+ return call_user_func( $wgTranslateCC[$id], $id );
973967 } else {
974 - return null;
 968+ return $wgTranslateCC[$id];
975969 }
976970 }
977971 }
Index: trunk/extensions/Translate/tag/TranslatablePage.php
@@ -152,10 +152,19 @@
153153 * @return \string
154154 */
155155 public function getMessageGroupId() {
156 - return 'page|' . $this->getTitle()->getPrefixedText();
 156+ return self::getMessageGroupIdFromTitle( $this->getTitle() );
157157 }
158158
159159 /**
 160+ * Constructs MessageGroup id for any title.
 161+ * @param $title Title
 162+ * @return \string
 163+ */
 164+ public static function getMessageGroupIdFromTitle( Title $title ) {
 165+ return 'page|' . $title->getPrefixedText();
 166+ }
 167+
 168+ /**
160169 * Returns MessageGroup used for translating this page. It may still be empty
161170 * if the page has not been ever marked.
162171 * @return \type{WikiPageMessageGroup}

Status & tagging log