Index: trunk/extensions/Wikidata/OmegaWiki/SpecialSuggest.php |
— | — | @@ -10,7 +10,7 @@ |
11 | 11 | SpecialPage::SpecialPage( 'Suggest', 'UnlistedSpecialPage' ); |
12 | 12 | |
13 | 13 | } |
14 | | - |
| 14 | + |
15 | 15 | function execute( $par ) { |
16 | 16 | global |
17 | 17 | $wgOut, $IP; |
— | — | @@ -57,6 +57,7 @@ |
58 | 58 | @$offset = $_GET['offset']; |
59 | 59 | @$attributesLevel = $_GET['attributesLevel']; |
60 | 60 | @$annotationAttributeId = $_GET['annotationAttributeId']; |
| 61 | + $syntransId = $_GET["syntransId"]; |
61 | 62 | |
62 | 63 | $sql = ''; |
63 | 64 | |
— | — | @@ -74,19 +75,19 @@ |
75 | 76 | $sql = getSQLForClasses( $wgUser->getOption( 'language' ) ); |
76 | 77 | break; |
77 | 78 | case "$wgDefinedMeaningAttributes": |
78 | | - $sql = getSQLToSelectPossibleAttributes( $definedMeaningId, $attributesLevel, $annotationAttributeId, 'DM' ); |
| 79 | + $sql = getSQLToSelectPossibleAttributes( $definedMeaningId, $attributesLevel, $syntransId, $annotationAttributeId, 'DM' ); |
79 | 80 | break; |
80 | 81 | case 'text-attribute': |
81 | | - $sql = getSQLToSelectPossibleAttributes( $definedMeaningId, $attributesLevel, $annotationAttributeId, 'TEXT' ); |
| 82 | + $sql = getSQLToSelectPossibleAttributes( $definedMeaningId, $attributesLevel, $syntransId, $annotationAttributeId, 'TEXT' ); |
82 | 83 | break; |
83 | 84 | case 'translated-text-attribute': |
84 | | - $sql = getSQLToSelectPossibleAttributes( $definedMeaningId, $attributesLevel, $annotationAttributeId, 'TRNS' ); |
| 85 | + $sql = getSQLToSelectPossibleAttributes( $definedMeaningId, $attributesLevel, $syntransId, $annotationAttributeId, 'TRNS' ); |
85 | 86 | break; |
86 | 87 | case "$wgLinkAttribute": |
87 | | - $sql = getSQLToSelectPossibleAttributes( $definedMeaningId, $attributesLevel, $annotationAttributeId, 'URL' ); |
| 88 | + $sql = getSQLToSelectPossibleAttributes( $definedMeaningId, $attributesLevel, $syntransId, $annotationAttributeId, 'URL' ); |
88 | 89 | break; |
89 | 90 | case "$wgOptionAttribute": |
90 | | - $sql = getSQLToSelectPossibleAttributes( $definedMeaningId, $attributesLevel, $annotationAttributeId, 'OPTN' ); |
| 91 | + $sql = getSQLToSelectPossibleAttributes( $definedMeaningId, $attributesLevel, $syntransId, $annotationAttributeId, 'OPTN' ); |
91 | 92 | break; |
92 | 93 | case 'language': |
93 | 94 | require_once( 'languages.php' ); |
— | — | @@ -121,7 +122,7 @@ |
122 | 123 | " SUBSTRING(timestamp, 9, 2), ':', SUBSTRING(timestamp, 11, 2), ':', SUBSTRING(timestamp, 13, 2))"; |
123 | 124 | break; |
124 | 125 | } |
125 | | - |
| 126 | + |
126 | 127 | if ( $search != '' ) { |
127 | 128 | if ( $query == 'transaction' ) |
128 | 129 | $searchCondition = " AND $rowText LIKE " . $dbr->addQuotes( "%$search%" ); |
— | — | @@ -252,7 +253,7 @@ |
253 | 254 | * @param $language the 2 letter wikimedia code |
254 | 255 | */ |
255 | 256 | |
256 | | -function getSQLToSelectPossibleAttributes( $definedMeaningId, $attributesLevel, $annotationAttributeId, $attributesType ) { |
| 257 | +function getSQLToSelectPossibleAttributes( $definedMeaningId, $attributesLevel, $syntransId, $annotationAttributeId, $attributesType ) { |
257 | 258 | |
258 | 259 | global $wgDefaultClassMids, $wgUser; |
259 | 260 | |
— | — | @@ -262,11 +263,38 @@ |
263 | 264 | $language = $wgUser->getOption( 'language' ) ; |
264 | 265 | $lng = ' ( SELECT language_id FROM language WHERE wikimedia_key = ' . $dbr->addQuotes( $language ) . ' ) '; |
265 | 266 | |
266 | | - if ( count( $wgDefaultClassMids ) > 0 ) |
267 | | - $defaultClassRestriction = " OR {$dc}_class_attributes.class_mid IN (" . join( $wgDefaultClassMids, ", " ) . ")"; |
| 267 | + $classMids = $wgDefaultClassMids ; |
| 268 | + |
| 269 | + if ( $syntransId != 0 ) { |
| 270 | + // find the language of the syntrans and add attributes of that language by adding the language DM to the list of default classes |
| 271 | + // this first query returns the language_id |
| 272 | + $sql = 'SELECT language_id' . |
| 273 | + " FROM {$dc}_syntrans" . |
| 274 | + " JOIN {$dc}_expression ON {$dc}_expression.expression_id = {$dc}_syntrans.expression_id" . |
| 275 | + " WHERE {$dc}_syntrans.syntrans_sid = " . $syntransId . |
| 276 | + ' AND ' . getLatestTransactionRestriction( "{$dc}_syntrans" ) . |
| 277 | + ' AND ' . getLatestTransactionRestriction( "{$dc}_expression" ); |
| 278 | + $lang_res = $dbr->query( $sql ); |
| 279 | + $language_id = $dbr->fetchObject( $lang_res )->language_id; |
| 280 | + |
| 281 | + // this second query finds the DM number for a given language_id |
| 282 | + // 145264 is the collection_id of the "ISO 639-3 codes" collection |
| 283 | + $sql = "SELECT member_mid FROM {$dc}_collection_contents, language" . |
| 284 | + " WHERE language.language_id = $language_id" . |
| 285 | + " AND {$dc}_collection_contents.collection_id = 145264" . |
| 286 | + " AND language.iso639_3 = {$dc}_collection_contents.internal_member_id" . |
| 287 | + ' AND ' . getLatestTransactionRestriction( "{$dc}_collection_contents" ); |
| 288 | + $lang_res = $dbr->query( $sql ); |
| 289 | + $language_dm_id = $dbr->fetchObject( $lang_res )->member_mid; |
| 290 | + |
| 291 | + $classMids = array_merge ( $wgDefaultClassMids , array($language_dm_id) ) ; |
| 292 | + } |
| 293 | + |
| 294 | + if ( count( $classMids ) > 0 ) |
| 295 | + $defaultClassRestriction = " OR {$dc}_class_attributes.class_mid IN (" . join( $classMids, ", " ) . ")"; |
268 | 296 | else |
269 | 297 | $defaultClassRestriction = ""; |
270 | | - |
| 298 | + |
271 | 299 | $filteredAttributesRestriction = getFilteredAttributesRestriction( $annotationAttributeId ); |
272 | 300 | |
273 | 301 | $sql = |
Index: trunk/extensions/Wikidata/OmegaWiki/suggest.js |
— | — | @@ -52,6 +52,7 @@ |
53 | 53 | |
54 | 54 | var suggestAttributesLevel = document.getElementById(suggestPrefix + "parameter-level"); |
55 | 55 | var suggestDefinedMeaningId = document.getElementById(suggestPrefix + "parameter-definedMeaningId"); |
| 56 | + var suggestSyntransId = document.getElementById(suggestPrefix + "parameter-syntransId"); |
56 | 57 | var suggestAnnotationAttributeId = document.getElementById(suggestPrefix + "parameter-annotationAttributeId"); |
57 | 58 | |
58 | 59 | var URL = 'index.php'; |
— | — | @@ -73,6 +74,9 @@ |
74 | 75 | if (suggestDefinedMeaningId != null) |
75 | 76 | URL = URL + '&definedMeaningId=' + encodeURI(suggestDefinedMeaningId.value); |
76 | 77 | |
| 78 | + if (suggestSyntransId != null) |
| 79 | + URL = URL + '&syntransId=' + encodeURI(suggestSyntransId.value); |
| 80 | + |
77 | 81 | if (suggestAnnotationAttributeId != null) |
78 | 82 | URL = URL + '&annotationAttributeId=' + encodeURI(suggestAnnotationAttributeId.value); |
79 | 83 | |
Index: trunk/extensions/Wikidata/OmegaWiki/Editor.php |
— | — | @@ -1303,8 +1303,7 @@ |
1304 | 1304 | } |
1305 | 1305 | |
1306 | 1306 | public function getInputValue( $id ) { |
1307 | | - global |
1308 | | - $wgRequest; |
| 1307 | + global $wgRequest; |
1309 | 1308 | |
1310 | 1309 | return trim( $wgRequest->getText( $id ) ); |
1311 | 1310 | } |
— | — | @@ -1368,12 +1367,16 @@ |
1369 | 1368 | |
1370 | 1369 | public function add( IdStack $idPath ) { |
1371 | 1370 | if ( $this->isAddField ) { |
| 1371 | + $syntransId = $idPath->getKeyStack()->peek( 0 )->syntransId; |
| 1372 | + if ( $syntransId == "" ) $syntransId = 0 ; // in the case of a DM option attribute, there is no syntrans in the PathId |
| 1373 | + |
1372 | 1374 | $parameters = array( |
1373 | 1375 | "level" => $this->attributesLevelName, |
1374 | 1376 | "definedMeaningId" => $idPath->getDefinedMeaningId(), |
| 1377 | + "syntransId" => $syntransId, |
1375 | 1378 | "annotationAttributeId" => $idPath->getAnnotationAttribute()->getId() |
1376 | 1379 | ); |
1377 | | - |
| 1380 | + |
1378 | 1381 | return getSuggest( $this->addId( $idPath->getId() ), $this->suggestType(), $parameters ); |
1379 | 1382 | } |
1380 | 1383 | else |
— | — | @@ -1427,7 +1430,7 @@ |
1428 | 1431 | if ( $this->isAddField ) { |
1429 | 1432 | $syntransId = $idPath->getKeyStack()->peek( 0 )->syntransId; |
1430 | 1433 | if ( ! $syntransId ) $syntransId = 0 ; // in the case of a DM option attribute, there is no syntrans in the PathId |
1431 | | - |
| 1434 | + |
1432 | 1435 | $parameters = array( |
1433 | 1436 | "level" => $this->attributesLevelName, |
1434 | 1437 | "definedMeaningId" => $idPath->getDefinedMeaningId(), |