r23781 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23780‎ | r23781 | r23782 >
Date:09:05, 6 July 2007
Author:erik
Status:old
Tags:
Comment:
- make suggest completion work correctly in different datasetse
- make Special:Conceptmapping use suggest completion
- will still need dataset fixes
- remove some obsolete code
Modified paths:
  • /trunk/extensions/Wikidata/App.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/DefinedMeaning.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/SpecialAddCollection.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/SpecialConceptMapping.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/suggest.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/App.php
@@ -46,7 +46,9 @@
4747
4848 function addWikidataHeader() {
4949 global $wgOut,$wgScriptPath;
 50+ $dc=wdGetDataSetContext();
5051 $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>");
5153 $wgOut->addLink(array('rel'=>'stylesheet','type'=>'text/css','media'=>'screen, projection','href'=>"{$wgScriptPath}/extensions/Wikidata/OmegaWiki/suggest.css"));
5254 $wgOut->addLink(array('rel'=>'stylesheet','type'=>'text/css','media'=>'screen, projection','href'=>"{$wgScriptPath}/extensions/Wikidata/OmegaWiki/tables.css"));
5355 return true;
@@ -90,7 +92,7 @@
9193 'ow_noedit_title' => 'No permission to edit',
9294 'ow_uipref_datasets' => 'Default view',
9395 'ow_uiprefs' => 'Wikidata',
94 - 'ow_none_selected' => '&lt;None selected&gt;',
 96+ 'ow_none_selected' => '<None selected>',
9597 'ow_conceptmapping_help' => "<p>possible actions: <ul>
9698 <li>&action=insert&<data_context_prefix>=<defined_id>&... insert a mapping</li>
9799 <li>&action=get&concept=<concept_id> read a mapping back</li>
@@ -101,12 +103,7 @@
102104 'ow_conceptmapping_uitext' => "
103105 <p>Concept Mapping allows you to identify
104106 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",
111108 'ow_conceptmapping_no_action_specified'=>"Apologies, I don't know how to '$1'.",
112109 'ow_dm_OK'=>'OK',
113110 'ow_dm_not_present'=>'not entered',
@@ -124,7 +121,7 @@
125122 );
126123
127124 $datasets=wdGetDatasets();
128 - $datasetarray['']=wfMsg('ow_none_selected');
 125+ $datasetarray['']=wfMsgHtml('ow_none_selected');
129126 foreach($datasets as $datasetid=>$dataset) {
130127 $datasetarray[$datasetid]=$dataset->fetchName();
131128 }
Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaning.php
@@ -165,14 +165,14 @@
166166 protected function getConceptPanel() {
167167 global $wgTitle, $wgUser;
168168 $active=true; # wrong place, but hey
169 - $dm=$this->getDefinedMeaningId();
 169+ $dmId=$this->getDefinedMeaningId();
170170 $dc=wdGetDataSetContext();
171171 $ow_conceptpanel=wfMsg("ow_concept_panel");
172172
173173 $html="<div class=\"dataset-panel\">";;
174174 $html.="<table border=\"0\"><tr><th class=\"dataset-panel-heading\">$ow_conceptpanel</th></tr>";
175175 $sk=$wgUser->getSkin();
176 - $meanings=getDefinedMeaningDataAssociatedByConcept($dm, $dc);
 176+ $meanings=getDefinedMeaningDataAssociatedByConcept($dmId, $dc);
177177 if($meanings) {
178178 foreach ($meanings as $dm) {
179179 $dataset=$dm->getDataset();
@@ -190,7 +190,7 @@
191191 }
192192 $cmtitle=Title::newFromText("Special:ConceptMapping");
193193 $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");
195195 $html.="<tr><td>$cmlink</td></tr>\n";
196196 $html.="<tr><td>".$this->getCopyPanel()."<td><tr>";
197197 $html.="</table>\n";
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialAddCollection.php
@@ -5,19 +5,16 @@
66
77 $wgAvailableRights[] = 'addcollection';
88 $wgGroupPermissions['bureaucrat']['addcollection'] = true;
9 -
109 $wgExtensionFunctions[] = 'wfSpecialAddCollection';
1110
1211 function wfSpecialAddCollection() {
13 - global $wgMessageCache;
14 - $wgMessageCache->addMessages(array('addcollection'=>'Wikidata: Add collection'),'en');
15 -
1612 class SpecialAddCollection extends SpecialPage {
1713 function SpecialAddCollection() {
1814 SpecialPage::SpecialPage('AddCollection');
1915 }
2016
2117 function execute($par) {
 18+
2219 global $wgOut, $wgUser, $wgRequest;
2320
2421 $wgOut->setPageTitle('Add Collection');
Index: trunk/extensions/Wikidata/OmegaWiki/suggest.js
@@ -38,12 +38,13 @@
3939
4040
4141
42 -function updateSuggestions(suggestPrefix) {
 42+function updateSuggestions(suggestPrefix, dataSetOverride) {
4343 var http = getHTTPObject();
4444 var table = document.getElementById(suggestPrefix + "table");
4545 var suggestQuery = document.getElementById(suggestPrefix + "query").value;
4646 var suggestOffset = document.getElementById(suggestPrefix + "offset").value;
47 -
 47+ var currentDataSet = dataset;
 48+
4849 suggestText = document.getElementById(suggestPrefix + "text");
4950 suggestText.className = "suggest-loading";
5051
@@ -61,7 +62,8 @@
6263 '/Special:Suggest?search-text=' + encodeURI(suggestText.value) +
6364 '&prefix=' + encodeURI(suggestPrefix) +
6465 '&query=' + encodeURI(suggestQuery) +
65 - '&offset=' + encodeURI(suggestOffset);
 66+ '&offset=' + encodeURI(suggestOffset) +
 67+ '&dataset='+currentDataSet;
6668
6769 if((suggestAttributesLevel != null) && (suggestObjectId != null))
6870 URL =
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialConceptMapping.php
@@ -55,29 +55,40 @@
5656 }
5757
5858 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");
6263 $wgOut->addHTML(wfMsg('ow_conceptmapping_uitext'));
6364 $sets=wdGetDataSets();
6465 $options = array();
6566 $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+
6883 }
6984 $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]) {
7990 $wgOut->addHTML(' <span style="color:yellow">['.wfMsg('ow_dm_not_present').']</span>');
8091 } else {
81 - $dmModel=new DefinedMeaningModel($dmInfo["id"],null,$set);
 92+ $dmModel=new DefinedMeaningModel($rq[$set],null,$setObject);
8293 $dmModel->checkExistence();
8394 if ($dmModel->exists()) {
8495 $id=$dmModel->getId();
@@ -87,7 +98,7 @@
8899 $title=null;
89100 }
90101 if(!$noerror) {
91 - $wgOut->addHTML("$key: $rq ($title)");
 102+ $wgOut->addHTML("$key: ".$rq[$set]." ($title)");
92103 }
93104 if ($id!=null) {
94105 $mappings[$key]=$id;
Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php
@@ -187,7 +187,7 @@
188188 initializeObjectAttributeEditors($this->viewInformation);
189189
190190 # Nice try sherlock, but we really need to get our DMID from elsewhere
191 - #$definedMeaningId = $this->getDefinedMeaningID();
 191+ #$definedMeaningId = $this->getId();
192192
193193 #Need 3 steps: copy defining expression, create new dm, then update
194194
@@ -438,26 +438,6 @@
439439 return $this->dataset;
440440 }
441441
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 - }
462442 public function exists() {
463443 return $this->exists;
464444 }

Status & tagging log