Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataAPI.php |
— | — | @@ -1181,7 +1181,7 @@ |
1182 | 1182 | } |
1183 | 1183 | |
1184 | 1184 | function &getAssociatedByConcept($dm, $dc) { |
1185 | | - $dbr = & wfGetDB(DB_SLAVE); |
| 1185 | + #$dbr = & wfGetDB(DB_SLAVE); |
1186 | 1186 | $concept_id=getConceptId($dm,$dc); |
1187 | 1187 | wfDebug("concept id:".$concept_id."\n"); |
1188 | 1188 | return readConceptMapping($concept_id); |
— | — | @@ -1193,7 +1193,7 @@ |
1194 | 1194 | $newSets=array(); |
1195 | 1195 | foreach ($map as $map_dc => $map_dm) { |
1196 | 1196 | $dataset=$sets[$map_dc]; |
1197 | | - $dataset->setDefinedMeaningId($map_dm); |
| 1197 | + # $dataset->setDefinedMeaningId($map_dm); |
1198 | 1198 | $newSets[$map_dc]=$dataset; |
1199 | 1199 | } |
1200 | 1200 | return $newSets; |
— | — | @@ -1201,10 +1201,11 @@ |
1202 | 1202 | function &getDefinedMeaningDataAssociatedByConcept($dm, $dc) { |
1203 | 1203 | $meanings=array(); |
1204 | 1204 | $map=getDataSetsAssociatedByConcept($dm, $dc); |
| 1205 | + $dm_map=getAssociatedByConcept($dm, $dc); |
1205 | 1206 | foreach ($map as $map_dc => $map_dataset) { |
1206 | 1207 | $dmData=new DefinedMeaningData(); |
1207 | 1208 | $dmData->setDataset($map_dataset); |
1208 | | - $dmData->setId($map_dataset->getDefinedMeaningId()); |
| 1209 | + $dmData->setId($dm_map[$map_dc]); |
1209 | 1210 | $meanings[$map_dc]=$dmData; |
1210 | 1211 | } |
1211 | 1212 | return $meanings; |
Index: trunk/extensions/Wikidata/OmegaWiki/Wikidata.php |
— | — | @@ -368,7 +368,7 @@ |
369 | 369 | private $dataSetPrefix; |
370 | 370 | private $isValidPrefix=false; |
371 | 371 | private $fallbackName=''; |
372 | | - private $dmId=0; |
| 372 | + private $dmId=0; # the dmId of the dataset name |
373 | 373 | |
374 | 374 | public function getPrefix() { |
375 | 375 | return $this->dataSetPrefix; |
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialConceptMapping.php |
— | — | @@ -45,8 +45,7 @@ |
46 | 46 | $wgOut->setPageTitle("ConceptMapping"); |
47 | 47 | $action=$wgRequest->getText('action'); |
48 | 48 | if(!$action) { |
49 | | - $wgOut->addWikiText("You didn't set an action. Now kicking back and being lazy.<br>"); |
50 | | - $wgOut->addWikiText(help_text); |
| 49 | + $this->ui(); |
51 | 50 | } elseif ($action=="insert"){ |
52 | 51 | $this->insert(); |
53 | 52 | } elseif ($action=="get"){ |
— | — | @@ -63,6 +62,50 @@ |
64 | 63 | } |
65 | 64 | } |
66 | 65 | |
| 66 | + protected function ui() { |
| 67 | + global $wgOut; |
| 68 | + require_once("forms.php"); |
| 69 | + |
| 70 | + $sets=wdGetDataSets(); |
| 71 | + $options = array(); |
| 72 | + $html=""; |
| 73 | + foreach ($sets as $key=>$set) { |
| 74 | + $options[$set->fetchName()]=$this->getDm($set); |
| 75 | + } |
| 76 | + $wgOut->addHTML(getOptionPanel($options)); |
| 77 | + #debug |
| 78 | + global $wgRequest; |
| 79 | + $mappings=array(); |
| 80 | + foreach ($sets as $key=>$set) { |
| 81 | + $rq=$wgRequest->getText("set_".$key); |
| 82 | + $rq=ltrim($rq); |
| 83 | + $wgOut->addHTML("$key: $rq"); |
| 84 | + if ($rq!=null and $rq!="") { |
| 85 | + $mappings[$key]=$rq; |
| 86 | + $wgOut->addHTML(" (will insert)"); |
| 87 | + } else { |
| 88 | + $wgOut->addHTML("(not supplied)"); |
| 89 | + } |
| 90 | + $wgOut->addHTML("<br>\n"); |
| 91 | + } |
| 92 | + if (sizeOf($mappings)>1) { |
| 93 | + createConceptMapping($mappings); |
| 94 | + $wgOut->addHTML("Mapped all fields marked with (will insert)<br>\n"); |
| 95 | + } else { |
| 96 | + $wgOut->addHTML("Need to have at least two defined meanings before I can link them"); |
| 97 | + } |
| 98 | + |
| 99 | + } |
| 100 | + |
| 101 | + protected function getDm($dataset) { |
| 102 | + global $wgRequest; |
| 103 | + $setname="set_".$dataset->getPrefix(); |
| 104 | + $rq=$wgRequest->getText($setname); |
| 105 | + $html=getTextBox($setname, $rq); |
| 106 | + return $html; |
| 107 | + } |
| 108 | + |
| 109 | + |
67 | 110 | protected function help() { |
68 | 111 | global $wgOut; |
69 | 112 | $wgOut->addWikiText("<h2>Help</h2>"); |