r53536 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53535‎ | r53536 | r53537 >
Date:09:28, 20 July 2009
Author:minuteelectron
Status:deferred
Tags:
Comment:
* Migration away from namspace manager code in OmegaWiki (forgot to commit this earlier).
* Use improved variable name for handler classes.
Modified paths:
  • /trunk/extensions/Wikidata/App.php (modified) (history)
  • /trunk/extensions/Wikidata/patches/OmegaWiki.diff (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/patches/OmegaWiki.diff
@@ -52,11 +52,11 @@
5353
5454 wfProfileIn( __METHOD__ );
5555
56 -+ global $wgWikiDataHandlerClasses, $wgWikiDataHandlerPath;
 56++ global $wdHandlerClasses, $wdHandlerPath;
5757 + $ns = $this->mTitle->getNamespace();
58 -+ if( array_key_exists( $ns, $wgWikiDataHandlerClasses ) ) {
59 -+ $handlerClass = $wgWikiDataHandlerClasses[ $ns ];
60 -+ $handlerFile = $wgWikiDataHandlerPath . $handlerClass . '.php';
 58++ if( array_key_exists( $ns, $wdHandlerClasses ) ) {
 59++ $handlerClass = $wdHandlerClasses[ $ns ];
 60++ $handlerFile = $wdHandlerPath . $handlerClass . '.php';
6161 + if( file_exists( $handlerFile ) ) {
6262 + require_once $handlerFile;
6363 + $handlerInstance = new $handlerClass();
@@ -112,11 +112,11 @@
113113 return;
114114 } else {
115115 +
116 -+ global $wgWikiDataHandlerClasses, $wgWikiDataHandlerPath;
 116++ global $wdHandlerClasses, $wdHandlerPath;
117117 + $namespaceId = $this->mTitle->getNamespace();
118 -+ if( array_key_exists( $namespaceId, $wgWikiDataHandlerClasses ) ) {
119 -+ $handlerClass = $wgWikiDataHandlerClasses[ $namespaceId ];
120 -+ $handlerFile = $wgWikiDataHandlerPath . $handlerClass . '.php';
 118++ if( array_key_exists( $namespaceId, $wdHandlerClasses ) ) {
 119++ $handlerClass = $wdHandlerClasses[ $namespaceId ];
 120++ $handlerFile = $wdHandlerPath . $handlerClass . '.php';
121121 + if( file_exists( $handlerFile ) ) {
122122 + require_once $handlerFile;
123123 + $handlerInstance = new $handlerClass();
@@ -141,9 +141,9 @@
142142 */
143143 public static function isMovable( $index ) {
144144 - global $wgAllowImageMoving;
145 -+ global $wgAllowImageMoving, $wgWikiDataHandlerClasses;
 145++ global $wgAllowImageMoving, $wdHandlerClasses;
146146 + # FIXME: This means that namespaces with custom handlers are assumed to never be movable.
147 -+ if( array_key_exists( $index, $wgWikiDataHandlerClasses ) ) return false;
 147++ if( array_key_exists( $index, $wdHandlerClasses ) ) return false;
148148 return !( $index < NS_MAIN || ($index == NS_FILE && !$wgAllowImageMoving) || $index == NS_CATEGORY );
149149 }
150150
@@ -189,11 +189,11 @@
190190
191191 wfProfileIn( __METHOD__ );
192192
193 -+ global $wgWikiDataHandlerClasses, $wgWikiDataHandlerPath;
 193++ global $wdHandlerClasses, $wdHandlerPath;
194194 + $namespaceId = $this->mTitle->getNamespace();
195 -+ if( array_key_exists( $namespaceId, $wgWikiDataHandlerClasses ) ) {
196 -+ $handlerClass = $wgWikiDataHandlerClasses[ $namespaceId ];
197 -+ $handlerFile = $wgWikiDataHandlerPath . $handlerClass . '.php';
 195++ if( array_key_exists( $namespaceId, $wdHandlerClasses ) ) {
 196++ $handlerClass = $wdHandlerClasses[ $namespaceId ];
 197++ $handlerFile = $wdHandlerPath . $handlerClass . '.php';
198198 + if( file_exists( $handlerFile ) ) {
199199 + require_once $handlerFile;
200200 + $handlerInstance = new $handlerClass();
Index: trunk/extensions/Wikidata/App.php
@@ -84,9 +84,6 @@
8585
8686 $wgGotoSourceTemplates = array(5 => $swissProtGotoSourceTemplate);
8787
88 -$dir = dirname( __FILE__ ) . '/';
89 -$wgExtensionMessagesFiles['Wikidata'] = $dir . 'SpecialLanguages.i18n.php';
90 -
9188 require_once("{$IP}/extensions/Wikidata/AddPrefs.php");
9289 require_once("{$IP}/extensions/Wikidata/SpecialLanguages.php");
9390 require_once("{$IP}/extensions/Wikidata/OmegaWiki/SpecialSuggest.php");
@@ -122,10 +119,8 @@
123120 }
124121
125122 function wdIsWikidataNs() {
126 - global $wgTitle;
127 - $ns=Namespace::get($wgTitle->getNamespace());
128 - return
129 - ($ns->getHandlerClass()=='OmegaWiki' || $ns->getHandlerClass()=='DefinedMeaning' || $ns->getHandlerClass()=='ExpressionPage');
 123+ global $wgTitle, $wdHandlerClasses;
 124+ return array_key_exists( $wgTitle->getNamespace(), $wdHandlerClasses );
130125
131126 }
132127
@@ -156,11 +151,11 @@
157152 * @param $tabs as passed by MW
158153 */
159154 function modifyTabs($skin, $content_actions) {
160 - global $wgUser, $wgTitle, $wdTesting, $wgCommunity_dc, $wdShowEditCopy;
 155+ global $wgUser, $wgTitle, $wdTesting, $wgCommunity_dc, $wdShowEditCopy, $wdHandlerClasses;
161156 $dc=wdGetDataSetContext();
162 - $ns=Namespace::get($wgTitle->getNamespace());
 157+ $ns=$wgTitle->getNamespace();
163158 $editChanged = false;
164 - if($ns->getHandlerClass()=='DefinedMeaning') {
 159+ if(array_key_exists( $ns, $wdHandlerClasses ) && $wdHandlerClasses[ $ns ] == 'DefinedMeaning' ) {
165160
166161 # Hackishly determine which DMID we're on by looking at the page title component
167162 $tt=$wgTitle->getText();
@@ -199,9 +194,13 @@
200195
201196 function initializeWikidata() {
202197 global $wgExtensionPreferences, $wdSiteContext, $wgPropertyToColumnFilters;
 198+
 199+ # Add extension messages to the cache (initialize it here because they will be needed below)
 200+ global $wgMessageCache, $wdMessages;
 201+ foreach( $wdMessages as $language => $translations ) {
 202+ $wgMessageCache->addMessages( $translations, $language );
 203+ }
203204
204 - wfLoadExensionMessages( 'Wikidata' );
205 -
206205 $dbr =& wfGetDB(DB_MASTER);
207206 $dbr->query("SET NAMES utf8");
208207
@@ -217,7 +216,12 @@
218217 'size' => 10,
219218 'options' => $datasetarray
220219 );
221 -
 220+
 221+ global
 222+ $messageCacheOK;
 223+
 224+ $messageCacheOK = true;
 225+
222226 global
223227 $wgRecordSetLanguage;
224228
@@ -232,3 +236,4 @@
233237
234238 return true;
235239 }
 240+

Status & tagging log