Index: trunk/extensions/Wikidata/WiktionaryZ/WiktionaryZ.php |
— | — | @@ -1,5 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | |
| 4 | +require_once('wikidata.php'); |
4 | 5 | require_once('Expression.php'); |
5 | 6 | require_once('forms.php'); |
6 | 7 | require_once('table.php'); |
— | — | @@ -34,7 +35,6 @@ |
35 | 36 | $synonymAndTranslationTables = $this->getSynonymAndTranslationTables($definedMeaningIds, $expressionId); |
36 | 37 | $definedMeaningTexts = $this->getDefinedMeaningTexts($definedMeaningIds); |
37 | 38 | $alternativeMeaningTexts = $this->getAlternativeMeaningTexts($definedMeaningIds); |
38 | | - $definedMeaningRelations = $this->getDefinedMeaningRelations($definedMeaningIds); |
39 | 39 | |
40 | 40 | $wgOut->addHTML($skin->editSectionLink($wgTitle, $expressionId)); |
41 | 41 | $wgOut->addHTML("<h2><i>Spelling</i>: $row->spelling - <i>Language:</i> ".$wgLanguageNames[$row->language_id]. "</h2>"); |
— | — | @@ -57,45 +57,11 @@ |
58 | 58 | } |
59 | 59 | |
60 | 60 | $wgOut->addHTML('<div class="wiki-data-blocks">'); |
61 | | - $wgOut->addHTML('<div class="wiki-data-block">'); |
62 | | - $wgOut->addHTML('<h4>Translations and synonyms</h4>'); |
63 | | - $wgOut->addHTML(getTableAsHTML($synonymAndTranslationTables[$definedMeaningId])); |
64 | | - $wgOut->addHTML('</div>'); |
65 | | - |
66 | | - $wgOut->addHTML('<div class="wiki-data-block">'); |
67 | | - $wgOut->addHTML('<h4>Relations</h4>'); |
68 | | - $relations = $definedMeaningRelations[$definedMeaningId]; |
69 | | - foreach($relations as $type => $rellist) { |
70 | | - $wgOut->addHTML("<p>$typenames[$type]:</p>"); |
71 | | - $wgOut->addHTML("<ul>"); |
72 | | - foreach($rellist as $rel) { |
73 | | - $rs_res=$dbr->query("SELECT expression_id from uw_defined_meaning where defined_meaning_id=".$rel." LIMIT 1"); |
74 | | - $rs_row=$dbr->fetchObject($rs_res); |
75 | | - if($rs_row->expression_id) { |
76 | | - $li_res=$dbr->query("SELECT spelling from uw_expression_ns where expression_id=".$rs_row->expression_id); |
77 | | - $li_row=$dbr->fetchObject($li_res); |
78 | | - $wgOut->addHTML("<li>". $skin->makeLink("WiktionaryZ:".$li_row->spelling, $li_row->spelling) ."</li>"); |
79 | | - } |
80 | | - } |
81 | | - $wgOut->addHTML("</ul>"); |
82 | | - } |
83 | | - $wgOut->addHTML('</div>'); |
| 61 | + addWikiDataBlock("Translations and synonyms", getTableAsHTML($synonymAndTranslationTables[$definedMeaningId])); |
| 62 | + addWikiDataBlock("Relations", getTableAsHTML($this->getDefinedMeaningRelationsTable($definedMeaningId))); |
| 63 | + addWikiDataBlock("Attributes", getTableAsHTML($this->getDefinedMeaningAttributesTable($definedMeaningId))); |
84 | 64 | |
85 | | - $wgOut->addHTML('<div class="wiki-data-block">'); |
86 | | - $wgOut->addHTML('<h4>Attributes</h4>'); |
87 | | - $attributes = $attributesPerDefinedMeaning[$definedMeaningId]; |
88 | | - |
89 | | - if (count($attributes) > 0) { |
90 | | - $wgOut->addHTML('<ul>'); |
91 | | - foreach($attributes as $attribute) { |
92 | | - $attributeName = $attnames[$attribute]; |
93 | | - $wgOut->addHTML("<li>". $skin->makeLink("WiktionaryZ:".$attributeName, $attributeName) ."</li>"); |
94 | | - } |
95 | | - $wgOut->addHTML('</ul>'); |
96 | | - } |
97 | | - |
98 | 65 | $wgOut->addHTML('</div>'); |
99 | | - $wgOut->addHTML('</div>'); |
100 | 66 | $wgOut->addHTML('<div class="clear-float"/>'); |
101 | 67 | $wgOut->addHTML('</li>'); |
102 | 68 | } |
— | — | @@ -119,15 +85,15 @@ |
120 | 86 | } |
121 | 87 | |
122 | 88 | function getRelationTypeSuggest($definedMeaningId) { |
123 | | - return getSuggest("new-relation-type-$definedMeaningId", |
124 | | - "relation-type", |
125 | | - "member_mid", "spelling"); |
| 89 | + return getSuggest("new-relation-type-$definedMeaningId", "relation-type"); |
126 | 90 | } |
127 | 91 | |
| 92 | + function getAttributeSuggest($definedMeaningId) { |
| 93 | + return getSuggest("new-attribute-$definedMeaningId", "attribute"); |
| 94 | + } |
| 95 | + |
128 | 96 | function getDefinedMeaningSuggest($definedMeaningId) { |
129 | | - return getSuggest("new-relation-other-meaning-$definedMeaningId", |
130 | | - "defined-meaning", |
131 | | - "member_mid", "spelling"); |
| 97 | + return getSuggest("new-relation-other-meaning-$definedMeaningId", "defined-meaning"); |
132 | 98 | } |
133 | 99 | |
134 | 100 | function getRelationTypes() { |
— | — | @@ -206,9 +172,12 @@ |
207 | 173 | $this->setText($textId, $definition); |
208 | 174 | } |
209 | 175 | |
210 | | - $this->addTranslatedDefinitionFromRequest($definedMeaningId, $definedMeaningTextId, getRevisionForExpressionId($expressionId), array_keys($translatedContents)); |
| 176 | + if (count($translatedContents)) |
| 177 | + $this->addTranslatedDefinitionFromRequest($definedMeaningId, $definedMeaningTextId, getRevisionForExpressionId($expressionId), array_keys($translatedContents)); |
| 178 | + |
211 | 179 | $this->addSynonymsOrTranslationsFromRequest($definedMeaningId); |
212 | 180 | $this->addRelationFromRequest($definedMeaningId); |
| 181 | + $this->addAttributeFromRequest($definedMeaningId); |
213 | 182 | } |
214 | 183 | |
215 | 184 | function edit() { |
— | — | @@ -302,20 +271,18 @@ |
303 | 272 | getTextArea("definition-$textId", $this->getText($textId))); |
304 | 273 | } |
305 | 274 | |
306 | | - $wgOut->addHTML('<div><i>Translate into</i>: '. |
307 | | - $this->getLanguageSelect("translated-definition-language-$definedMeaningId", array_keys($translatedContents)).'</div>'. |
308 | | - getTextArea("translated-definition-$definedMeaningId")); |
| 275 | + if (count($translatedContents) > 0) { |
| 276 | + $wgOut->addHTML('<div><i>Translate into</i>: '. |
| 277 | + $this->getLanguageSelect("translated-definition-language-$definedMeaningId", array_keys($translatedContents)).'</div>'. |
| 278 | + getTextArea("translated-definition-$definedMeaningId")); |
| 279 | + } |
309 | 280 | |
310 | 281 | $wgOut->addHTML('<div class="wiki-data-blocks">'); |
311 | | - $wgOut->addHTML('<div class="wiki-data-block">'); |
312 | | - $wgOut->addHTML('<h4>Translations and synonyms</h4>'); |
313 | | - $wgOut->addHTML(getTableAsEditHTML($synonymAndTranslationTable, "add-translation-synonym-$definedMeaningId", $this->getAddTranslationsAndSynonymsRowFields($definedMeaningId), true)); |
| 282 | + addWikiDataBlock("Translations and synonyms", getTableAsEditHTML($synonymAndTranslationTable, "add-translation-synonym-$definedMeaningId", $this->getAddTranslationsAndSynonymsRowFields($definedMeaningId), true)); |
| 283 | + addWikiDataBlock("Relations", getTableAsEditHTML($this->getDefinedMeaningRelationsTable($definedMeaningId), "", array($this->getRelationTypeSuggest($definedMeaningId), $this->getDefinedMeaningSuggest($definedMeaningId)), false)); |
| 284 | + addWikiDataBlock("Attributes", getTableAsEditHTML($this->getDefinedMeaningAttributesTable($definedMeaningId), "", array($this->getAttributeSuggest($definedMeaningId)), false)); |
314 | 285 | $wgOut->addHTML('</div>'); |
315 | | - |
316 | | - $wgOut->addHTML('<div class="wiki-data-block">'); |
317 | | - $wgOut->addHTML($this->getAddRelationsFormFields($definedMeaningId)); |
318 | | - $wgOut->addHTML('</div>'); |
319 | | - $wgOut->addHTML('</div>'); |
| 286 | + |
320 | 287 | $wgOut->addHTML('<div class="clear-float"/>'); |
321 | 288 | } |
322 | 289 | |
— | — | @@ -425,6 +392,33 @@ |
426 | 393 | return $result; |
427 | 394 | } |
428 | 395 | |
| 396 | + function getDefinedMeaningRelationsTable($definedMeaningId) { |
| 397 | + $attributes = array(new Attribute("Relation type", "defined-meaning"), new Attribute("Other defined meaning", "defined-meaning")); |
| 398 | + $table = new ArrayTable($attributes); |
| 399 | + |
| 400 | + $dbr =& wfGetDB(DB_SLAVE); |
| 401 | + $queryResult = $dbr->query("SELECT relationtype_mid, meaning2_mid from uw_meaning_relations where meaning1_mid=$definedMeaningId and relationtype_mid!=0 and is_latest_set=1 ORDER BY relationtype_mid"); |
| 402 | + |
| 403 | + while($definedMeaningRelation = $dbr->fetchObject($queryResult)) |
| 404 | + $table->addRow(array($this->getExpressionForMeaningId($definedMeaningRelation->relationtype_mid, 85), |
| 405 | + $this->getExpressionForMeaningId($definedMeaningRelation->meaning2_mid, 85))); |
| 406 | + |
| 407 | + return $table; |
| 408 | + } |
| 409 | + |
| 410 | + function getDefinedMeaningAttributesTable($definedMeaningId) { |
| 411 | + $attributes = array(new Attribute("Attribute", "defined-meaning")); |
| 412 | + $table = new ArrayTable($attributes); |
| 413 | + |
| 414 | + $dbr =& wfGetDB(DB_SLAVE); |
| 415 | + $queryResult = $dbr->query("SELECT relationtype_mid, meaning2_mid from uw_meaning_relations where meaning1_mid=$definedMeaningId and relationtype_mid=0 and is_latest_set=1"); |
| 416 | + |
| 417 | + while($attribute = $dbr->fetchObject($queryResult)) |
| 418 | + $table->addRow(array($this->getExpressionForMeaningId($attribute->meaning2_mid, 85))); |
| 419 | + |
| 420 | + return $table; |
| 421 | + } |
| 422 | + |
429 | 423 | function getDefinedMeaningRelations($definedMeaningIds) { |
430 | 424 | $dbr =& wfGetDB(DB_SLAVE); |
431 | 425 | $definedMeaningRelations = array(); |
— | — | @@ -475,14 +469,6 @@ |
476 | 470 | return array($this->getLanguageSelect("language-$definedMeaningId"), getTextBox("spelling-$definedMeaningId"), getCheckBox("endemic-meaning-$definedMeaningId", true)); |
477 | 471 | } |
478 | 472 | |
479 | | - function getAddRelationsFormFields($definedMeaningId) { |
480 | | - return '<h4>Add relation</h4> |
481 | | - <table class="wiki-data-table"> |
482 | | - <tr><th>Relation type</th><th>Other defined meaning</th></tr> |
483 | | - <tr><td>' . $this->getRelationTypeSuggest($definedMeaningId) . '</td><td>' . $this->getDefinedMeaningSuggest($definedMeaningId) . '</td></tr> |
484 | | - </table>'; |
485 | | - } |
486 | | - |
487 | 473 | function getTranslationIdsForDefinedMeaning($definedMeaningId) { |
488 | 474 | $dbr =& wfGetDB(DB_SLAVE); |
489 | 475 | $queryResult = $dbr->query("SELECT * from text where old_id=$textId"); |
— | — | @@ -622,11 +608,26 @@ |
623 | 609 | } |
624 | 610 | |
625 | 611 | function getExpressionForMeaningId($mid, $langcode) { |
| 612 | +// $dbr =& wfGetDB(DB_SLAVE); |
| 613 | +// $sql="SELECT spelling from uw_syntrans,uw_expression_ns where defined_meaning_id=".$mid." and uw_expression_ns.expression_id=uw_syntrans.expression_id and uw_expression_ns.language_id=".$langcode." limit 1"; |
| 614 | +// $sp_res=$dbr->query($sql); |
| 615 | +// $sp_row=$dbr->fetchObject($sp_res); |
| 616 | +// return $sp_row->spelling; |
| 617 | + $expressions = $this->getExpressionsForDefinedMeaningIds(array($mid)); |
| 618 | + return $expressions[$mid]; |
| 619 | + } |
| 620 | + |
| 621 | + # Fixme, the following function only returns English expressions |
| 622 | + # Should be expressions in the language of preference, with an appropriate fallback scheme |
| 623 | + function getExpressionsForDefinedMeaningIds($definedMeaningIds) { |
626 | 624 | $dbr =& wfGetDB(DB_SLAVE); |
627 | | - $sql="SELECT spelling from uw_syntrans,uw_expression_ns where defined_meaning_id=".$mid." and uw_expression_ns.expression_id=uw_syntrans.expression_id and uw_expression_ns.language_id=".$langcode." limit 1"; |
628 | | - $sp_res=$dbr->query($sql); |
629 | | - $sp_row=$dbr->fetchObject($sp_res); |
630 | | - return $sp_row->spelling; |
| 625 | + $queryResult = $dbr->query("SELECT defined_meaning_id, spelling from uw_syntrans, uw_expression_ns where defined_meaning_id in (". implode(",", $definedMeaningIds) . ") and uw_expression_ns.expression_id=uw_syntrans.expression_id and uw_expression_ns.language_id=85"); |
| 626 | + $expressions = array(); |
| 627 | + |
| 628 | + while ($expression = $dbr->fetchObject($queryResult)) |
| 629 | + $expressions[$expression->defined_meaning_id] = $expression->spelling; |
| 630 | + |
| 631 | + return $expressions; |
631 | 632 | } |
632 | 633 | |
633 | 634 | function addRelationFromRequest($definedMeaningId) { |
— | — | @@ -640,6 +641,16 @@ |
641 | 642 | $this->addRelation($definedMeaningId, $relationTypeId, $otherDefinedMeaningId); |
642 | 643 | } |
643 | 644 | |
| 645 | + function addAttributeFromRequest($definedMeaningId) { |
| 646 | + global |
| 647 | + $wgRequest; |
| 648 | + |
| 649 | + $attributeId = $wgRequest->getInt("new-attribute-$definedMeaningId"); |
| 650 | + |
| 651 | + if ($attributeId != 0) |
| 652 | + $this->addRelation($definedMeaningId, 0, $attributeId); |
| 653 | + } |
| 654 | + |
644 | 655 | function getSetIdForDefinedMeaningRelations($definedMeaningId) { |
645 | 656 | $dbr =& wfGetDB(DB_SLAVE); |
646 | 657 | $sql = "SELECT set_id from uw_meaning_relations where meaning1_mid=$definedMeaningId and is_latest_set=1 limit 1"; |
Index: trunk/extensions/Wikidata/WiktionaryZ/tmp/tables.css |
— | — | @@ -4,53 +4,42 @@ |
5 | 5 | skins/common/common.css |
6 | 6 | */ |
7 | 7 | |
8 | | -/* Wikidata blocks */
|
9 | | -
|
10 | | -.clear-float {
|
11 | | - clear: both;
|
12 | | -}
|
13 | | -
|
14 | | -.wiki-data-blocks .wiki-data-block {
|
15 | | - display: inline;
|
16 | | - float: left;
|
17 | | - margin: 4px;
|
18 | | -}
|
19 | | -
|
20 | | -/* Wikidata tables */
|
21 | | -
|
22 | | -.wiki-data-table td, .wiki-data-table th {
|
23 | | - padding-top: 0px;
|
24 | | - padding-bottom: 0px;
|
25 | | - padding-left: 2px;
|
26 | | - padding-right: 2px;
|
27 | | - margin: 0px;
|
28 | | - border: none;
|
29 | | -}
|
30 | | -
|
31 | | -.wiki-data-table th {
|
32 | | - background-color: #EEEEEE;
|
33 | | -}
|
34 | | -
|
35 | | -.wiki-data-table td.column-odd {
|
36 | | - background-color: #F6F6F6;
|
37 | | -}
|
38 | | -
|
39 | | -.boolean {
|
40 | | - text-align: center;
|
41 | | -}
|
42 | | -
|
43 | | -.text {
|
44 | | - text-align: left;
|
45 | | -}
|
46 | | -
|
47 | | -.spelling {
|
48 | | - text-align: left;
|
49 | | -}
|
50 | | -
|
51 | | -.language {
|
52 | | - text-align: left;
|
53 | | -}
|
54 | | -
|
55 | | -td.language {
|
56 | | - font-style: italic;
|
| 8 | +/* Wikidata blocks */ |
| 9 | + |
| 10 | +.clear-float { |
| 11 | + clear: both; |
| 12 | +} |
| 13 | + |
| 14 | +.wiki-data-blocks .wiki-data-block { |
| 15 | + display: inline; |
| 16 | + float: left; |
| 17 | + margin: 4px; |
| 18 | +} |
| 19 | + |
| 20 | +/* Wikidata tables */ |
| 21 | + |
| 22 | +.wiki-data-table td, .wiki-data-table th { |
| 23 | + padding-top: 0px; |
| 24 | + padding-bottom: 0px; |
| 25 | + padding-left: 2px; |
| 26 | + padding-right: 2px; |
| 27 | + margin: 0px; |
| 28 | + border: none; |
| 29 | +} |
| 30 | + |
| 31 | +.wiki-data-table th { |
| 32 | + background-color: #EEEEEE; |
| 33 | + text-align: left; |
| 34 | +} |
| 35 | + |
| 36 | +.wiki-data-table td.column-odd { |
| 37 | + background-color: #F6F6F6; |
| 38 | +} |
| 39 | + |
| 40 | +.boolean { |
| 41 | + text-align: center; |
| 42 | +} |
| 43 | + |
| 44 | +td.language { |
| 45 | + font-style: italic; |
57 | 46 | } |
\ No newline at end of file |
Index: trunk/extensions/Wikidata/WiktionaryZ/tmp/suggest.css |
— | — | @@ -6,37 +6,38 @@ |
7 | 7 | |
8 | 8 | /* Suggestion control */ |
9 | 9 | |
10 | | -.wiki-data-table td .suggest-link {
|
11 | | - display: block;
|
12 | | -}
|
13 | | -
|
14 | | -.suggest-link {
|
15 | | - border-width: 1px;
|
16 | | - border-style: solid;
|
17 | | - border-color: #7F9DB9;
|
18 | | - padding-left: 4px;
|
19 | | - padding-right: 4px;
|
20 | | - padding-top: 1px;
|
21 | | - padding-bottom: 0px;
|
22 | | -}
|
23 | | -
|
24 | | -.suggest-link, .suggest-link:hover, .suggest-link:active, .suggest-link:visited {
|
25 | | - color: #000000;
|
26 | | - text-decoration: none;
|
27 | | - white-space: nowrap;
|
28 | | -}
|
29 | | -
|
| 10 | +.wiki-data-table td .suggest-link { |
| 11 | + display: block; |
| 12 | + background-color: #FFFFFF; |
| 13 | +} |
| 14 | + |
| 15 | +.suggest-link { |
| 16 | + border-width: 1px; |
| 17 | + border-style: solid; |
| 18 | + border-color: #7F9DB9; |
| 19 | + padding-left: 4px; |
| 20 | + padding-right: 4px; |
| 21 | + padding-top: px; |
| 22 | + padding-bottom: 1px; |
| 23 | +} |
| 24 | + |
| 25 | +.suggest-link,.suggest-link:hover,.suggest-link:active,.suggest-link:visited { |
| 26 | + color: #000000; |
| 27 | + text-decoration: none; |
| 28 | + white-space: nowrap; |
| 29 | +} |
| 30 | + |
30 | 31 | .suggestion-row { |
31 | 32 | padding: 0px; |
32 | 33 | margin: 0px; |
33 | 34 | } |
34 | 35 | |
35 | | -.suggestion-row.active { |
| 36 | +.suggestion-row .active { |
36 | 37 | background-color: #DDDDDD; |
37 | 38 | cursor: pointer; |
38 | 39 | } |
39 | 40 | |
40 | | -.suggestion-row.inactive { |
| 41 | +.suggestion-row .inactive { |
41 | 42 | background-color: #FFFFFF; |
42 | 43 | } |
43 | 44 | |
Index: trunk/extensions/Wikidata/WiktionaryZ/wikidata.php |
— | — | @@ -0,0 +1,11 @@ |
| 2 | +<?php |
| 3 | + function addWikiDataBlock($title, $content) { |
| 4 | + global |
| 5 | + $wgOut; |
| 6 | + |
| 7 | + $wgOut->addHTML('<div class="wiki-data-block"> |
| 8 | + <h4>'. $title . '</h4>'. |
| 9 | + $content . |
| 10 | + '</div>'); |
| 11 | + } |
| 12 | +?> |
Index: trunk/extensions/Wikidata/WiktionaryZ/Suggest.php |
— | — | @@ -22,17 +22,20 @@ |
23 | 23 | $searchCondition = ""; |
24 | 24 | |
25 | 25 | if ($query == 'relation-type') |
26 | | - $sql = "select member_mid as row_id, expression1.spelling as relation, expression2.spelling as collection " . |
27 | | - "from uw_collection_contents, uw_collection_ns, uw_syntrans syntrans1, uw_expression_ns expression1, uw_syntrans syntrans2, uw_expression_ns expression2 " . |
28 | | - "where uw_collection_contents.collection_id=uw_collection_ns.collection_id and uw_collection_ns.collection_type='RELT' " . |
29 | | - |
30 | | - "and syntrans1.defined_meaning_id=uw_collection_contents.member_mid " . |
31 | | - "and expression1.expression_id=syntrans1.expression_id and expression1.language_id=85 " . |
32 | | - |
33 | | - "and syntrans2.defined_meaning_id=uw_collection_ns.collection_mid " . |
34 | | - "and expression2.expression_id=syntrans2.expression_id and expression2.language_id=85 " . |
35 | | - |
36 | | - "and uw_collection_contents.is_latest_set=1 "; |
| 26 | +// $sql = "select member_mid as row_id, expression1.spelling as relation, expression2.spelling as collection " . |
| 27 | +// "from uw_collection_contents, uw_collection_ns, uw_syntrans syntrans1, uw_expression_ns expression1, uw_syntrans syntrans2, uw_expression_ns expression2 " . |
| 28 | +// "where uw_collection_contents.collection_id=uw_collection_ns.collection_id and uw_collection_ns.collection_type='RELT' " . |
| 29 | +// |
| 30 | +// "and syntrans1.defined_meaning_id=uw_collection_contents.member_mid " . |
| 31 | +// "and expression1.expression_id=syntrans1.expression_id and expression1.language_id=85 " . |
| 32 | +// |
| 33 | +// "and syntrans2.defined_meaning_id=uw_collection_ns.collection_mid " . |
| 34 | +// "and expression2.expression_id=syntrans2.expression_id and expression2.language_id=85 " . |
| 35 | +// |
| 36 | +// "and uw_collection_contents.is_latest_set=1 "; |
| 37 | + $sql = getSQLForCollectionOfType('RELT'); |
| 38 | + else if ($query == 'attribute') |
| 39 | + $sql = getSQLForCollectionOfType('ATTR'); |
37 | 40 | else if ($query == 'defined-meaning') |
38 | 41 | $sql = "select syntrans1.defined_meaning_id as row_id, expression1.spelling as relation ". |
39 | 42 | "from uw_expression_ns expression1, uw_syntrans syntrans1 ". |
— | — | @@ -49,4 +52,18 @@ |
50 | 53 | echo('<tr id="'. $row['row_id'] .'" class="suggestion-row inactive" onclick="suggestRowClicked(this)" onmouseover="mouseOverRow(this)" onmouseout="mouseOutRow(this)"><td>' . $row['relation'] . '</td><td>'. $row['collection'] .'</td></tr>'); |
51 | 54 | |
52 | 55 | echo('</table>'); |
| 56 | + |
| 57 | + function getSQLForCollectionOfType($collectionType) { |
| 58 | + return "select member_mid as row_id, expression1.spelling as relation, expression2.spelling as collection " . |
| 59 | + "from uw_collection_contents, uw_collection_ns, uw_syntrans syntrans1, uw_expression_ns expression1, uw_syntrans syntrans2, uw_expression_ns expression2 " . |
| 60 | + "where uw_collection_contents.collection_id=uw_collection_ns.collection_id and uw_collection_ns.collection_type='$collectionType' " . |
| 61 | + |
| 62 | + "and syntrans1.defined_meaning_id=uw_collection_contents.member_mid " . |
| 63 | + "and expression1.expression_id=syntrans1.expression_id and expression1.language_id=85 " . |
| 64 | + |
| 65 | + "and syntrans2.defined_meaning_id=uw_collection_ns.collection_mid " . |
| 66 | + "and expression2.expression_id=syntrans2.expression_id and expression2.language_id=85 " . |
| 67 | + |
| 68 | + "and uw_collection_contents.is_latest_set=1 "; |
| 69 | + } |
53 | 70 | ?> |
Index: trunk/extensions/Wikidata/WiktionaryZ/type.php |
— | — | @@ -34,6 +34,7 @@ |
35 | 35 | switch($type) { |
36 | 36 | case "boolean": return booleanAsHTML($value); |
37 | 37 | case "spelling": return spellingAsLink($value); |
| 38 | + case "defined-meaning": return spellingAsLink($value); |
38 | 39 | case "language": return languageIdAsText($value); |
39 | 40 | default: return $value; |
40 | 41 | } |
Index: trunk/extensions/Wikidata/WiktionaryZ/forms.php |
— | — | @@ -1,35 +1,28 @@ |
2 | 2 | <?php |
3 | | -/* |
4 | | - * Created on May 5, 2006 |
5 | | - * |
6 | | - * To change the template for this generated file go to |
7 | | - * Window - Preferences - PHPeclipse - PHP - Code Templates |
8 | | - */ |
| 3 | +function getTextBox($name, $maximumLength = 255, $value = "") { |
| 4 | + return '<input type="text" name="'. $name .'" value="'. $value .'" maxlength="'. $maximumLength .'"/>'; |
| 5 | +} |
9 | 6 | |
10 | | - function getTextBox($name, $maximumLength = 255, $value = "") { |
11 | | - return '<input type="text" name="'. $name .'" value="'. $value .'" maxlength="'. $maximumLength .'"/>'; |
12 | | - } |
| 7 | +function getTextArea($name, $text = "", $rows = 5, $columns = 80) { |
| 8 | + return '<textarea name="'.$name. '" rows="'. $rows . '" cols="'. $columns . '">' . htmlspecialchars($text) . '</textarea>'; |
| 9 | +} |
13 | 10 | |
14 | | - function getTextArea($name, $text = "", $rows = 5, $columns = 80) { |
15 | | - return '<textarea name="'.$name. '" rows="'. $rows . '" cols="'. $columns . '">' . htmlspecialchars($text) . '</textarea>'; |
16 | | - } |
| 11 | +function getCheckBox($name, $isChecked) { |
| 12 | + if ($isChecked) |
| 13 | + $checked = ' checked="checked"'; |
| 14 | + else |
| 15 | + $checked = ''; |
17 | 16 | |
18 | | - function getCheckBox($name, $isChecked) { |
19 | | - if ($isChecked) |
20 | | - $checked = ' checked="checked"'; |
21 | | - else |
22 | | - $checked = ''; |
23 | | - |
24 | | - return '<input type="checkbox" name="'. $name .'"'. $checked . '/>'; |
25 | | - } |
| 17 | + return '<input type="checkbox" name="'. $name .'"'. $checked . '/>'; |
| 18 | +} |
26 | 19 | |
27 | | - # $options is an array of [value => text] pairs |
28 | | - function getSelect($name, $options, $selectedValue="") { |
29 | | - $result = '<select name="'. $name . '">'; |
| 20 | +# $options is an array of [value => text] pairs |
| 21 | +function getSelect($name, $options, $selectedValue="") { |
| 22 | + $result = '<select name="'. $name . '">'; |
30 | 23 | |
31 | | - asort($options); |
32 | | - |
33 | | - foreach($options as $value => $text) { |
| 24 | + asort($options); |
| 25 | + |
| 26 | + foreach($options as $value => $text) { |
34 | 27 | if ($value == $selectedValue) |
35 | 28 | $selected = ' selected="selected"'; |
36 | 29 | else |
— | — | @@ -37,11 +30,11 @@ |
38 | 31 | |
39 | 32 | $result .= '<option value="'. $value .'"'. $selected .'>'. htmlspecialchars($text) . '</option>'; |
40 | 33 | } |
41 | | - |
| 34 | + |
42 | 35 | return $result . '</select>'; |
43 | 36 | } |
44 | 37 | |
45 | | -function getSuggest($name, $query, $idField, $labelField) { |
| 38 | +function getSuggest($name, $query) { |
46 | 39 | global |
47 | 40 | $dbr; |
48 | 41 | |
Index: trunk/extensions/Wikidata/WiktionaryZ/table.php |
— | — | @@ -106,19 +106,8 @@ |
107 | 107 | |
108 | 108 | $result .= '</tr>'; |
109 | 109 | |
110 | | - for($i = 0; $i < $tableModel->getRowCount(); $i++) { |
111 | | -// $result .= '<tr>'; |
112 | | -// $j = 0; |
113 | | -// |
114 | | -// foreach($tableModel->getRow($i) as $cell) { |
115 | | -// $type = $attributes[$j]->type; |
116 | | -// $result .= '<td class="'. $type .' column-'. parityClass($j) . '">'. convertToHTML($cell, $type) . '</td>'; |
117 | | -// $j++; |
118 | | -// } |
119 | | -// |
120 | | -// $result .= '</tr>'; |
| 110 | + for($i = 0; $i < $tableModel->getRowCount(); $i++) |
121 | 111 | $result .= '<tr>' . getTableCellsAsHTML($attributes, convertValuesToHTML($attributes, $tableModel->getRow($i))) .'</tr>'; |
122 | | - } |
123 | 112 | |
124 | 113 | $result .= '</table>'; |
125 | 114 | |