Index: trunk/extensions/Wikidata/OmegaWiki/SpecialSelect.php |
— | — | @@ -29,13 +29,12 @@ |
30 | 30 | } |
31 | 31 | |
32 | 32 | function getSelectOptions() { |
33 | | - global $wgUser; |
34 | | - global $wgOptionAttribute; |
| 33 | + global $wgLang, $wgOptionAttribute; |
35 | 34 | |
36 | 35 | $dc = wdGetDataSetContext(); |
37 | 36 | $optionAttribute = $_GET[$wgOptionAttribute]; |
38 | 37 | $attributeObject = $_GET['attribute-object']; |
39 | | - $lang_code = $wgUser->getOption( 'language' ); |
| 38 | + $lang_code = $wgLang->getCode(); |
40 | 39 | |
41 | 40 | $dbr = wfGetDB( DB_SLAVE ); |
42 | 41 | $sql = 'SELECT language_id' . |
Index: trunk/extensions/Wikidata/OmegaWiki/forms.php |
— | — | @@ -194,10 +194,9 @@ |
195 | 195 | } |
196 | 196 | |
197 | 197 | function getLanguageOptions( $languageIdsToExclude = array() ) { |
198 | | - global |
199 | | - $wgUser; |
| 198 | + global $wgLang ; |
200 | 199 | |
201 | | - $userLanguage = $wgUser->getOption( 'language' ); |
| 200 | + $userLanguage = $wgLang->getCode(); |
202 | 201 | $idNameIndex = getLangNames( $userLanguage ); |
203 | 202 | |
204 | 203 | $result = array(); |
— | — | @@ -210,11 +209,8 @@ |
211 | 210 | } |
212 | 211 | |
213 | 212 | function getLanguageSelect( $name, $languageIdsToExclude = array() ) { |
214 | | - global |
215 | | - $wgUser; |
216 | | - |
217 | | - $userLanguage = $wgUser->getOption( 'language' ); |
218 | | - $userLanguageId = getLanguageIdForCode( $userLanguage ); |
| 213 | + global $wgLang ; |
| 214 | + $userLanguageId = getLanguageIdForCode( $wgLang->getCode() ) ; |
219 | 215 | |
220 | 216 | return getSelect( $name, getLanguageOptions( $languageIdsToExclude ), $userLanguageId ); |
221 | 217 | } |
Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataAPI.php |
— | — | @@ -1084,10 +1084,8 @@ |
1085 | 1085 | * @param $definedMeaningId |
1086 | 1086 | */ |
1087 | 1087 | function getDefinedMeaningDefinition( $definedMeaningId ) { |
1088 | | - global |
1089 | | - $wgUser; |
1090 | | - |
1091 | | - $userLanguageId = getLanguageIdForCode( $wgUser->getOption( 'language' ) ); |
| 1088 | + global $wgLang; |
| 1089 | + $userLanguageId = getLanguageIdForCode( $wgLang->getCode() ) ; |
1092 | 1090 | |
1093 | 1091 | if ( $userLanguageId > 0 ) |
1094 | 1092 | $result = getDefinedMeaningDefinitionForLanguage( $definedMeaningId, $userLanguageId ); |
— | — | @@ -1100,7 +1098,6 @@ |
1101 | 1099 | if ( $result == "" ) |
1102 | 1100 | $result = getDefinedMeaningDefinitionForAnyLanguage( $definedMeaningId ); |
1103 | 1101 | } |
1104 | | - |
1105 | 1102 | return $result; |
1106 | 1103 | } |
1107 | 1104 | |
— | — | @@ -1521,11 +1518,11 @@ |
1522 | 1519 | } |
1523 | 1520 | $dbr = wfGetDB( DB_SLAVE ); |
1524 | 1521 | $queryResult = $dbr->query( "SELECT spelling " . |
1525 | | - " FROM {$dc}_defined_meaning, {$dc}_expression " . |
1526 | | - " WHERE {$dc}_defined_meaning.defined_meaning_id=$definedMeaningId " . |
1527 | | - " AND {$dc}_expression.expression_id={$dc}_defined_meaning.expression_id" . |
1528 | | - " AND " . getLatestTransactionRestriction( "{$dc}_defined_meaning" ) . |
1529 | | - " AND " . getLatestTransactionRestriction( "{$dc}_expression" ) ); |
| 1522 | + " FROM {$dc}_defined_meaning, {$dc}_expression " . |
| 1523 | + " WHERE {$dc}_defined_meaning.defined_meaning_id=$definedMeaningId " . |
| 1524 | + " AND {$dc}_expression.expression_id={$dc}_defined_meaning.expression_id" . |
| 1525 | + " AND " . getLatestTransactionRestriction( "{$dc}_defined_meaning" ) . |
| 1526 | + " AND " . getLatestTransactionRestriction( "{$dc}_expression" ) ); |
1530 | 1527 | $expression = $dbr->fetchObject( $queryResult ); |
1531 | 1528 | if ( $expression ) { |
1532 | 1529 | return $expression->spelling; |
— | — | @@ -1591,17 +1588,17 @@ |
1592 | 1589 | * @param $definedMeaningId |
1593 | 1590 | */ |
1594 | 1591 | function definedMeaningExpression( $definedMeaningId ) { |
1595 | | - global $wgUser; |
| 1592 | + global $wgLang; |
| 1593 | + |
| 1594 | + $userLanguageId = getLanguageIdForCode( $wgLang->getCode() ) ; |
1596 | 1595 | |
1597 | | - $userLanguage = getLanguageIdForCode( $wgUser->getOption( 'language' ) ); |
1598 | | - |
1599 | 1596 | list( $definingExpressionId, $definingExpression, $definingExpressionLanguage ) = definingExpressionRow( $definedMeaningId ); |
1600 | 1597 | |
1601 | | - if ( $definingExpressionLanguage == $userLanguage && expressionIsBoundToDefinedMeaning( $definedMeaningId, $definingExpressionId ) ) |
| 1598 | + if ( $definingExpressionLanguage == $userLanguageId && expressionIsBoundToDefinedMeaning( $definedMeaningId, $definingExpressionId ) ) |
1602 | 1599 | return $definingExpression; |
1603 | 1600 | else { |
1604 | | - if ( $userLanguage > 0 ) |
1605 | | - $result = definedMeaningExpressionForLanguage( $definedMeaningId, $userLanguage ); |
| 1601 | + if ( $userLanguageId > 0 ) |
| 1602 | + $result = definedMeaningExpressionForLanguage( $definedMeaningId, $userLanguageId ); |
1606 | 1603 | else |
1607 | 1604 | $result = ""; |
1608 | 1605 | |
Index: trunk/extensions/Wikidata/OmegaWiki/ExpressionPage.php |
— | — | @@ -1,5 +1,10 @@ |
2 | 2 | <?php |
3 | 3 | |
| 4 | +/** |
| 5 | + * What is this PHP file for? |
| 6 | + * The software seems to work fine even if we delete this file |
| 7 | + */ |
| 8 | + |
4 | 9 | require_once( 'Wikidata.php' ); |
5 | 10 | require_once( 'Transaction.php' ); |
6 | 11 | require_once( 'WikiDataAPI.php' ); |
— | — | @@ -19,8 +24,7 @@ |
20 | 25 | */ |
21 | 26 | class ExpressionPage extends DefaultWikidataApplication { |
22 | 27 | public function view() { |
23 | | - global |
24 | | - $wgOut, $wgTitle; |
| 28 | + global $wgOut, $wgTitle; |
25 | 29 | |
26 | 30 | parent::view(); |
27 | 31 | $expressionAsPageTitle = $wgTitle->getText(); |
— | — | @@ -83,8 +87,7 @@ |
84 | 88 | } |
85 | 89 | |
86 | 90 | public function history() { |
87 | | - global |
88 | | - $wgOut, $wgTitle; |
| 91 | + global $wgOut, $wgTitle; |
89 | 92 | |
90 | 93 | parent::history(); |
91 | 94 | |
— | — | @@ -102,8 +105,7 @@ |
103 | 106 | } |
104 | 107 | |
105 | 108 | protected function save( $referenceQueryTransactionInformation ) { |
106 | | - global |
107 | | - $wgTitle; |
| 109 | + global $wgTitle; |
108 | 110 | |
109 | 111 | parent::save( $referenceQueryTransactionInformation ); |
110 | 112 | |
— | — | @@ -116,8 +118,7 @@ |
117 | 119 | } |
118 | 120 | |
119 | 121 | public function edit() { |
120 | | - global |
121 | | - $wgOut, $wgTitle, $wgUser; |
| 122 | + global $wgOut, $wgTitle, $wgUser; |
122 | 123 | |
123 | 124 | if ( !parent::edit() ) return false; |
124 | 125 | $this->outputEditHeader(); |
— | — | @@ -135,8 +136,7 @@ |
136 | 137 | } |
137 | 138 | |
138 | 139 | public function getTitle() { |
139 | | - global |
140 | | - $wgTitle, $wgUseExpressionPageTitlePrefix; |
| 140 | + global $wgTitle, $wgUseExpressionPageTitlePrefix; |
141 | 141 | |
142 | 142 | if ( $wgUseExpressionPageTitlePrefix ) |
143 | 143 | $title = wfMsg( 'ow_Multiple_meanings', $wgTitle->getText() ); |
Index: trunk/extensions/Wikidata/OmegaWiki/languages.php |
— | — | @@ -5,10 +5,10 @@ |
6 | 6 | * @return array of language names for the user's language preference |
7 | 7 | **/ |
8 | 8 | function getOwLanguageNames( $purge = false ) { |
9 | | - global $wgUser; |
| 9 | + global $wgLang ; |
10 | 10 | static $owLanguageNames = null; |
11 | 11 | if ( is_null( $owLanguageNames ) && !$purge ) { |
12 | | - $owLanguageNames = getLangNames( $wgUser->getOption( 'language' ) ); |
| 12 | + $owLanguageNames = getLangNames( $wgLang->getCode() ); |
13 | 13 | } |
14 | 14 | return $owLanguageNames; |
15 | 15 | |
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialConceptMapping.php |
— | — | @@ -59,8 +59,8 @@ |
60 | 60 | |
61 | 61 | protected function ui() { |
62 | 62 | |
63 | | - global $wgOut, $wgRequest, $wgUser, $wgDefinedMeaning; |
64 | | - $lang = $wgUser->getOption( "language" ); |
| 63 | + global $wgOut, $wgRequest, $wgLang, $wgDefinedMeaning; |
| 64 | + $lang = $wgLang->getCode(); |
65 | 65 | require_once( "forms.php" ); |
66 | 66 | $wgOut->addHTML( wfMsgSc( "conceptmapping_uitext" ) ); |
67 | 67 | $sets = wdGetDataSets(); |
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiRecordSets.php |
— | — | @@ -165,9 +165,9 @@ |
166 | 166 | } |
167 | 167 | |
168 | 168 | function getDefinedMeaningReferenceRecords( array $definedMeaningIds, $usedAs ) { |
169 | | - global |
170 | | - $wgUser; |
171 | | - |
| 169 | + global $wgLang ; |
| 170 | + $userLanguageId = getLanguageIdForCode( $wgLang->getCode() ) ; |
| 171 | + |
172 | 172 | // $startTime = microtime(true); |
173 | 173 | |
174 | 174 | $result = array(); |
— | — | @@ -180,7 +180,7 @@ |
181 | 181 | $userLanguage = $wgRecordSetLanguage; |
182 | 182 | } |
183 | 183 | else { |
184 | | - $userLanguage = getLanguageIdForCode( $wgUser->getOption( 'language' ) ); |
| 184 | + $userLanguage = getLanguageIdForCode( $wgLang->getCode() ); |
185 | 185 | } |
186 | 186 | |
187 | 187 | if ( $userLanguage > 0 ) |
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialSuggest.php |
— | — | @@ -42,7 +42,7 @@ |
43 | 43 | */ |
44 | 44 | function getSuggestions() { |
45 | 45 | $o = OmegaWikiAttributes::getInstance(); |
46 | | - global $wgUser; |
| 46 | + global $wgLang; |
47 | 47 | global |
48 | 48 | $wgDefinedMeaning, |
49 | 49 | $wgDefinedMeaningAttributes, |
— | — | @@ -58,6 +58,7 @@ |
59 | 59 | @$attributesLevel = $_GET['attributesLevel']; |
60 | 60 | @$annotationAttributeId = $_GET['annotationAttributeId']; |
61 | 61 | $syntransId = $_GET["syntransId"]; |
| 62 | + $langCode = $wgLang->getCode(); |
62 | 63 | |
63 | 64 | $sql = ''; |
64 | 65 | |
— | — | @@ -65,14 +66,14 @@ |
66 | 67 | $rowText = 'spelling'; |
67 | 68 | switch ( $query ) { |
68 | 69 | case 'relation-type': |
69 | | - $sqlActual = getSQLForCollectionOfType( 'RELT', $wgUser->getOption( 'language' ) ); |
| 70 | + $sqlActual = getSQLForCollectionOfType( 'RELT', $langCode ); |
70 | 71 | $sqlFallback = getSQLForCollectionOfType( 'RELT', 'en' ); |
71 | 72 | $sql = constructSQLWithFallback( $sqlActual, $sqlFallback, array( "member_mid", "spelling", "collection_mid" ) ); |
72 | 73 | break; |
73 | 74 | case 'class': |
74 | 75 | // constructSQLWithFallback is a bit broken in this case, showing several time the same lines |
75 | 76 | // so : not using it. The English fall back has been included in the SQL query |
76 | | - $sql = getSQLForClasses( $wgUser->getOption( 'language' ) ); |
| 77 | + $sql = getSQLForClasses( $langCode ); |
77 | 78 | break; |
78 | 79 | case "$wgDefinedMeaningAttributes": |
79 | 80 | $sql = getSQLToSelectPossibleAttributes( $definedMeaningId, $attributesLevel, $syntransId, $annotationAttributeId, 'DM' ); |
— | — | @@ -91,7 +92,7 @@ |
92 | 93 | break; |
93 | 94 | case 'language': |
94 | 95 | require_once( 'languages.php' ); |
95 | | - $sql = getSQLForLanguageNames( $wgUser->getOption( 'language' ) ); |
| 96 | + $sql = getSQLForLanguageNames( $langCode ); |
96 | 97 | $rowText = 'language_name'; |
97 | 98 | break; |
98 | 99 | case "$wgDefinedMeaning": |
— | — | @@ -104,10 +105,10 @@ |
105 | 106 | " AND " . getLatestTransactionRestriction( "{$dc}_expression" ); |
106 | 107 | break; |
107 | 108 | case 'class-attributes-level': |
108 | | - $sql = getSQLForLevels( $wgUser->getOption( 'language' ) ); |
| 109 | + $sql = getSQLForLevels( $langCode ); |
109 | 110 | break; |
110 | 111 | case 'collection': |
111 | | - $sqlActual = getSQLForCollection( $wgUser->getOption( 'language' ) ); |
| 112 | + $sqlActual = getSQLForCollection( $langCode ); |
112 | 113 | $sqlFallback = getSQLForCollection( 'en' ); |
113 | 114 | $sql = constructSQLWithFallback( $sqlActual, $sqlFallback, array( "collection_id", "spelling" ) ); |
114 | 115 | break; |
— | — | @@ -256,12 +257,12 @@ |
257 | 258 | |
258 | 259 | function getSQLToSelectPossibleAttributes( $definedMeaningId, $attributesLevel, $syntransId, $annotationAttributeId, $attributesType ) { |
259 | 260 | |
260 | | - global $wgDefaultClassMids, $wgUser; |
| 261 | + global $wgDefaultClassMids, $wgLang; |
261 | 262 | |
262 | 263 | $dc = wdGetDataSetContext(); |
263 | 264 | $dbr = wfGetDB( DB_SLAVE ); |
264 | 265 | |
265 | | - $language = $wgUser->getOption( 'language' ) ; |
| 266 | + $language = $wgLang->getCode() ; |
266 | 267 | $lng = ' ( SELECT language_id FROM language WHERE wikimedia_key = ' . $dbr->addQuotes( $language ) . ' ) '; |
267 | 268 | |
268 | 269 | $classMids = $wgDefaultClassMids ; |
Index: trunk/extensions/Wikidata/OmegaWiki/Wikidata.php |
— | — | @@ -397,9 +397,9 @@ |
398 | 398 | |
399 | 399 | // Fetch! |
400 | 400 | function fetchName() { |
401 | | - global $wgUser, $wdTermDBDataSet; |
| 401 | + global $wgLang, $wdTermDBDataSet; |
402 | 402 | if ( $wdTermDBDataSet ) { |
403 | | - $userLanguage = $wgUser->getOption( 'language' ); |
| 403 | + $userLanguageId = $wgLang->getCode() ; |
404 | 404 | $spelling = getSpellingForLanguage( $this->dmId, $userLanguage, 'en', $wdTermDBDataSet ); |
405 | 405 | if ( $spelling ) return $spelling; |
406 | 406 | } |