Index: trunk/extensions/Wikidata/patches/OmegaWiki.diff |
— | — | @@ -52,11 +52,11 @@ |
53 | 53 | |
54 | 54 | wfProfileIn( __METHOD__ ); |
55 | 55 | |
56 | | -+ global $wgWikiDataHandlerClasses, $wgWikiDataHandlerPath; |
| 56 | ++ global $wdHandlerClasses, $wdHandlerPath; |
57 | 57 | + $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'; |
61 | 61 | + if( file_exists( $handlerFile ) ) { |
62 | 62 | + require_once $handlerFile; |
63 | 63 | + $handlerInstance = new $handlerClass(); |
— | — | @@ -112,11 +112,11 @@ |
113 | 113 | return; |
114 | 114 | } else { |
115 | 115 | + |
116 | | -+ global $wgWikiDataHandlerClasses, $wgWikiDataHandlerPath; |
| 116 | ++ global $wdHandlerClasses, $wdHandlerPath; |
117 | 117 | + $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'; |
121 | 121 | + if( file_exists( $handlerFile ) ) { |
122 | 122 | + require_once $handlerFile; |
123 | 123 | + $handlerInstance = new $handlerClass(); |
— | — | @@ -141,9 +141,9 @@ |
142 | 142 | */ |
143 | 143 | public static function isMovable( $index ) { |
144 | 144 | - global $wgAllowImageMoving; |
145 | | -+ global $wgAllowImageMoving, $wgWikiDataHandlerClasses; |
| 145 | ++ global $wgAllowImageMoving, $wdHandlerClasses; |
146 | 146 | + # 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; |
148 | 148 | return !( $index < NS_MAIN || ($index == NS_FILE && !$wgAllowImageMoving) || $index == NS_CATEGORY ); |
149 | 149 | } |
150 | 150 | |
— | — | @@ -189,11 +189,11 @@ |
190 | 190 | |
191 | 191 | wfProfileIn( __METHOD__ ); |
192 | 192 | |
193 | | -+ global $wgWikiDataHandlerClasses, $wgWikiDataHandlerPath; |
| 193 | ++ global $wdHandlerClasses, $wdHandlerPath; |
194 | 194 | + $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'; |
198 | 198 | + if( file_exists( $handlerFile ) ) { |
199 | 199 | + require_once $handlerFile; |
200 | 200 | + $handlerInstance = new $handlerClass(); |
Index: trunk/extensions/Wikidata/App.php |
— | — | @@ -84,9 +84,6 @@ |
85 | 85 | |
86 | 86 | $wgGotoSourceTemplates = array(5 => $swissProtGotoSourceTemplate); |
87 | 87 | |
88 | | -$dir = dirname( __FILE__ ) . '/'; |
89 | | -$wgExtensionMessagesFiles['Wikidata'] = $dir . 'SpecialLanguages.i18n.php'; |
90 | | - |
91 | 88 | require_once("{$IP}/extensions/Wikidata/AddPrefs.php"); |
92 | 89 | require_once("{$IP}/extensions/Wikidata/SpecialLanguages.php"); |
93 | 90 | require_once("{$IP}/extensions/Wikidata/OmegaWiki/SpecialSuggest.php"); |
— | — | @@ -122,10 +119,8 @@ |
123 | 120 | } |
124 | 121 | |
125 | 122 | 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 ); |
130 | 125 | |
131 | 126 | } |
132 | 127 | |
— | — | @@ -156,11 +151,11 @@ |
157 | 152 | * @param $tabs as passed by MW |
158 | 153 | */ |
159 | 154 | function modifyTabs($skin, $content_actions) { |
160 | | - global $wgUser, $wgTitle, $wdTesting, $wgCommunity_dc, $wdShowEditCopy; |
| 155 | + global $wgUser, $wgTitle, $wdTesting, $wgCommunity_dc, $wdShowEditCopy, $wdHandlerClasses; |
161 | 156 | $dc=wdGetDataSetContext(); |
162 | | - $ns=Namespace::get($wgTitle->getNamespace()); |
| 157 | + $ns=$wgTitle->getNamespace(); |
163 | 158 | $editChanged = false; |
164 | | - if($ns->getHandlerClass()=='DefinedMeaning') { |
| 159 | + if(array_key_exists( $ns, $wdHandlerClasses ) && $wdHandlerClasses[ $ns ] == 'DefinedMeaning' ) { |
165 | 160 | |
166 | 161 | # Hackishly determine which DMID we're on by looking at the page title component |
167 | 162 | $tt=$wgTitle->getText(); |
— | — | @@ -199,9 +194,13 @@ |
200 | 195 | |
201 | 196 | function initializeWikidata() { |
202 | 197 | 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 | + } |
203 | 204 | |
204 | | - wfLoadExensionMessages( 'Wikidata' ); |
205 | | - |
206 | 205 | $dbr =& wfGetDB(DB_MASTER); |
207 | 206 | $dbr->query("SET NAMES utf8"); |
208 | 207 | |
— | — | @@ -217,7 +216,12 @@ |
218 | 217 | 'size' => 10, |
219 | 218 | 'options' => $datasetarray |
220 | 219 | ); |
221 | | - |
| 220 | + |
| 221 | + global |
| 222 | + $messageCacheOK; |
| 223 | + |
| 224 | + $messageCacheOK = true; |
| 225 | + |
222 | 226 | global |
223 | 227 | $wgRecordSetLanguage; |
224 | 228 | |
— | — | @@ -232,3 +236,4 @@ |
233 | 237 | |
234 | 238 | return true; |
235 | 239 | } |
| 240 | + |