Index: trunk/extensions/Wikidata/App.php |
— | — | @@ -46,7 +46,9 @@ |
47 | 47 | |
48 | 48 | function addWikidataHeader() { |
49 | 49 | global $wgOut,$wgScriptPath; |
| 50 | + $dc=wdGetDataSetContext(); |
50 | 51 | $wgOut->addScript("<script type='text/javascript' src='{$wgScriptPath}/extensions/Wikidata/OmegaWiki/suggest.js'></script>"); |
| 52 | + $wgOut->addScript("<script type='text/javascript'>var dataset='$dc';</script>"); |
51 | 53 | $wgOut->addLink(array('rel'=>'stylesheet','type'=>'text/css','media'=>'screen, projection','href'=>"{$wgScriptPath}/extensions/Wikidata/OmegaWiki/suggest.css")); |
52 | 54 | $wgOut->addLink(array('rel'=>'stylesheet','type'=>'text/css','media'=>'screen, projection','href'=>"{$wgScriptPath}/extensions/Wikidata/OmegaWiki/tables.css")); |
53 | 55 | return true; |
— | — | @@ -90,7 +92,7 @@ |
91 | 93 | 'ow_noedit_title' => 'No permission to edit', |
92 | 94 | 'ow_uipref_datasets' => 'Default view', |
93 | 95 | 'ow_uiprefs' => 'Wikidata', |
94 | | - 'ow_none_selected' => '<None selected>', |
| 96 | + 'ow_none_selected' => '<None selected>', |
95 | 97 | 'ow_conceptmapping_help' => "<p>possible actions: <ul> |
96 | 98 | <li>&action=insert&<data_context_prefix>=<defined_id>&... insert a mapping</li> |
97 | 99 | <li>&action=get&concept=<concept_id> read a mapping back</li> |
— | — | @@ -101,12 +103,7 @@ |
102 | 104 | 'ow_conceptmapping_uitext' => " |
103 | 105 | <p>Concept Mapping allows you to identify |
104 | 106 | which defined meaning in one dataset is identical |
105 | | - to defined meanings in other datasets.</p>\n |
106 | | - <p>Please enter or cut and paste the defined |
107 | | - meanings (with id), or simply the defined meaning ids |
108 | | - which are identical.</p>\n |
109 | | - <p> For example, you could paste <code>DefinedMeaning:Boat (7774)</code> |
110 | | - or simply type <code>7774</code>.</p>\n", |
| 107 | + to defined meanings in other datasets.</p>\n", |
111 | 108 | 'ow_conceptmapping_no_action_specified'=>"Apologies, I don't know how to '$1'.", |
112 | 109 | 'ow_dm_OK'=>'OK', |
113 | 110 | 'ow_dm_not_present'=>'not entered', |
— | — | @@ -124,7 +121,7 @@ |
125 | 122 | ); |
126 | 123 | |
127 | 124 | $datasets=wdGetDatasets(); |
128 | | - $datasetarray['']=wfMsg('ow_none_selected'); |
| 125 | + $datasetarray['']=wfMsgHtml('ow_none_selected'); |
129 | 126 | foreach($datasets as $datasetid=>$dataset) { |
130 | 127 | $datasetarray[$datasetid]=$dataset->fetchName(); |
131 | 128 | } |
Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaning.php |
— | — | @@ -165,14 +165,14 @@ |
166 | 166 | protected function getConceptPanel() { |
167 | 167 | global $wgTitle, $wgUser; |
168 | 168 | $active=true; # wrong place, but hey |
169 | | - $dm=$this->getDefinedMeaningId(); |
| 169 | + $dmId=$this->getDefinedMeaningId(); |
170 | 170 | $dc=wdGetDataSetContext(); |
171 | 171 | $ow_conceptpanel=wfMsg("ow_concept_panel"); |
172 | 172 | |
173 | 173 | $html="<div class=\"dataset-panel\">";; |
174 | 174 | $html.="<table border=\"0\"><tr><th class=\"dataset-panel-heading\">$ow_conceptpanel</th></tr>"; |
175 | 175 | $sk=$wgUser->getSkin(); |
176 | | - $meanings=getDefinedMeaningDataAssociatedByConcept($dm, $dc); |
| 176 | + $meanings=getDefinedMeaningDataAssociatedByConcept($dmId, $dc); |
177 | 177 | if($meanings) { |
178 | 178 | foreach ($meanings as $dm) { |
179 | 179 | $dataset=$dm->getDataset(); |
— | — | @@ -190,7 +190,7 @@ |
191 | 191 | } |
192 | 192 | $cmtitle=Title::newFromText("Special:ConceptMapping"); |
193 | 193 | $titleText=$wgTitle->getPrefixedURL(); |
194 | | - $cmlink=$sk->makeLinkObj($cmtitle,"<small>".wfMsg("add_concept_link")."</small>","set_$dc=$titleText&suppressWarnings=true"); |
| 194 | + $cmlink=$sk->makeLinkObj($cmtitle,"<small>".wfMsg("add_concept_link")."</small>","set_$dc=$dmId&suppressWarnings=true"); |
195 | 195 | $html.="<tr><td>$cmlink</td></tr>\n"; |
196 | 196 | $html.="<tr><td>".$this->getCopyPanel()."<td><tr>"; |
197 | 197 | $html.="</table>\n"; |
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialAddCollection.php |
— | — | @@ -5,19 +5,16 @@ |
6 | 6 | |
7 | 7 | $wgAvailableRights[] = 'addcollection'; |
8 | 8 | $wgGroupPermissions['bureaucrat']['addcollection'] = true; |
9 | | - |
10 | 9 | $wgExtensionFunctions[] = 'wfSpecialAddCollection'; |
11 | 10 | |
12 | 11 | function wfSpecialAddCollection() { |
13 | | - global $wgMessageCache; |
14 | | - $wgMessageCache->addMessages(array('addcollection'=>'Wikidata: Add collection'),'en'); |
15 | | - |
16 | 12 | class SpecialAddCollection extends SpecialPage { |
17 | 13 | function SpecialAddCollection() { |
18 | 14 | SpecialPage::SpecialPage('AddCollection'); |
19 | 15 | } |
20 | 16 | |
21 | 17 | function execute($par) { |
| 18 | + |
22 | 19 | global $wgOut, $wgUser, $wgRequest; |
23 | 20 | |
24 | 21 | $wgOut->setPageTitle('Add Collection'); |
Index: trunk/extensions/Wikidata/OmegaWiki/suggest.js |
— | — | @@ -38,12 +38,13 @@ |
39 | 39 | |
40 | 40 | |
41 | 41 | |
42 | | -function updateSuggestions(suggestPrefix) { |
| 42 | +function updateSuggestions(suggestPrefix, dataSetOverride) { |
43 | 43 | var http = getHTTPObject(); |
44 | 44 | var table = document.getElementById(suggestPrefix + "table"); |
45 | 45 | var suggestQuery = document.getElementById(suggestPrefix + "query").value; |
46 | 46 | var suggestOffset = document.getElementById(suggestPrefix + "offset").value; |
47 | | - |
| 47 | + var currentDataSet = dataset; |
| 48 | + |
48 | 49 | suggestText = document.getElementById(suggestPrefix + "text"); |
49 | 50 | suggestText.className = "suggest-loading"; |
50 | 51 | |
— | — | @@ -61,7 +62,8 @@ |
62 | 63 | '/Special:Suggest?search-text=' + encodeURI(suggestText.value) + |
63 | 64 | '&prefix=' + encodeURI(suggestPrefix) + |
64 | 65 | '&query=' + encodeURI(suggestQuery) + |
65 | | - '&offset=' + encodeURI(suggestOffset); |
| 66 | + '&offset=' + encodeURI(suggestOffset) + |
| 67 | + '&dataset='+currentDataSet; |
66 | 68 | |
67 | 69 | if((suggestAttributesLevel != null) && (suggestObjectId != null)) |
68 | 70 | URL = |
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialConceptMapping.php |
— | — | @@ -55,29 +55,40 @@ |
56 | 56 | } |
57 | 57 | |
58 | 58 | protected function ui() { |
59 | | - global $wgOut; |
60 | | - require_once("forms.php"); |
61 | | - |
| 59 | + |
| 60 | + global $wgOut, $wgRequest, $wgUser; |
| 61 | + $lang=$wgUser->getOption("language"); |
| 62 | + require_once("forms.php"); |
62 | 63 | $wgOut->addHTML(wfMsg('ow_conceptmapping_uitext')); |
63 | 64 | $sets=wdGetDataSets(); |
64 | 65 | $options = array(); |
65 | 66 | $html=""; |
66 | | - foreach ($sets as $key=>$set) { |
67 | | - $options[$set->fetchName()]=$this->getDm($set); |
| 67 | + $mappings=array(); |
| 68 | + $rq=array(); |
| 69 | + |
| 70 | + foreach ($sets as $key=>$setObject) { |
| 71 | + $set=$setObject->getPrefix(); |
| 72 | + $rq[$set]=$wgRequest->getText("set_".$set); |
| 73 | + $rq[$set]=trim($rq[$set]); |
| 74 | + $rq[$set]=(int)$rq[$set]; |
| 75 | + if($rq[$set]) { |
| 76 | + $dmModel=new DefinedMeaningModel($rq[$set],null,$setObject); |
| 77 | + $defaultSel=$dmModel->getSyntransByLanguageCode($lang); |
| 78 | + $options[$setObject->fetchName()]=getSuggest("set_$set", 'defined-meaning',array(), $rq[$set], $defaultSel); |
| 79 | + } else { |
| 80 | + $options[$setObject->fetchName()]=getSuggest("set_$set", 'defined-meaning'); |
| 81 | + } |
| 82 | + |
68 | 83 | } |
69 | 84 | $wgOut->addHTML(getOptionPanel($options)); |
70 | | - #debug |
71 | | - global $wgRequest; |
72 | | - $mappings=array(); |
73 | | - foreach ($sets as $key=>$set) { |
74 | | - $rq=$wgRequest->getText("set_".$key); |
75 | | - $noerror=$wgRequest->getText("suppressWarnings"); |
76 | | - $rq=trim($rq); |
77 | | - $dmInfo=DefinedMeaningModel::splitTitleText($rq); |
78 | | - if(!$dmInfo["id"]) { |
| 85 | + $noerror=$wgRequest->getText("suppressWarnings"); |
| 86 | + |
| 87 | + foreach ($sets as $key=>$setObject) { |
| 88 | + $set=$setObject->getPrefix(); |
| 89 | + if(!$rq[$set]) { |
79 | 90 | $wgOut->addHTML(' <span style="color:yellow">['.wfMsg('ow_dm_not_present').']</span>'); |
80 | 91 | } else { |
81 | | - $dmModel=new DefinedMeaningModel($dmInfo["id"],null,$set); |
| 92 | + $dmModel=new DefinedMeaningModel($rq[$set],null,$setObject); |
82 | 93 | $dmModel->checkExistence(); |
83 | 94 | if ($dmModel->exists()) { |
84 | 95 | $id=$dmModel->getId(); |
— | — | @@ -87,7 +98,7 @@ |
88 | 99 | $title=null; |
89 | 100 | } |
90 | 101 | if(!$noerror) { |
91 | | - $wgOut->addHTML("$key: $rq ($title)"); |
| 102 | + $wgOut->addHTML("$key: ".$rq[$set]." ($title)"); |
92 | 103 | } |
93 | 104 | if ($id!=null) { |
94 | 105 | $mappings[$key]=$id; |
Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php |
— | — | @@ -187,7 +187,7 @@ |
188 | 188 | initializeObjectAttributeEditors($this->viewInformation); |
189 | 189 | |
190 | 190 | # Nice try sherlock, but we really need to get our DMID from elsewhere |
191 | | - #$definedMeaningId = $this->getDefinedMeaningID(); |
| 191 | + #$definedMeaningId = $this->getId(); |
192 | 192 | |
193 | 193 | #Need 3 steps: copy defining expression, create new dm, then update |
194 | 194 | |
— | — | @@ -438,26 +438,6 @@ |
439 | 439 | return $this->dataset; |
440 | 440 | } |
441 | 441 | |
442 | | - public function setLanguageId($languageId) { |
443 | | - $this->languageId = $languageId; |
444 | | - } |
445 | | - |
446 | | - public function getLanguageId() { |
447 | | - return $this->languageId; |
448 | | - } |
449 | | - |
450 | | - public function setLanguageCode($languageCode) { |
451 | | - return $this->langaugeCode; |
452 | | - } |
453 | | - |
454 | | - public function getLanguageCode() { |
455 | | - if ($this->languageCode==null) { |
456 | | - global |
457 | | - $wgUser; |
458 | | - $this->languageCode=$wgUser->getOption('language'); |
459 | | - } |
460 | | - return $this->languageCode; |
461 | | - } |
462 | 442 | public function exists() { |
463 | 443 | return $this->exists; |
464 | 444 | } |