r22542 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22541‎ | r22542 | r22543 >
Date:20:16, 29 May 2007
Author:kim
Status:old
Tags:
Comment:
Added a ui to the default of Special:Conceptmapping
we might want to add safeties to the WikiDataAPI to either disallow or
overwrite conceptmappings that don't yet exist.
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/SpecialConceptMapping.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/WikiDataAPI.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/Wikidata.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataAPI.php
@@ -1181,7 +1181,7 @@
11821182 }
11831183
11841184 function &getAssociatedByConcept($dm, $dc) {
1185 - $dbr = & wfGetDB(DB_SLAVE);
 1185+ #$dbr = & wfGetDB(DB_SLAVE);
11861186 $concept_id=getConceptId($dm,$dc);
11871187 wfDebug("concept id:".$concept_id."\n");
11881188 return readConceptMapping($concept_id);
@@ -1193,7 +1193,7 @@
11941194 $newSets=array();
11951195 foreach ($map as $map_dc => $map_dm) {
11961196 $dataset=$sets[$map_dc];
1197 - $dataset->setDefinedMeaningId($map_dm);
 1197+ # $dataset->setDefinedMeaningId($map_dm);
11981198 $newSets[$map_dc]=$dataset;
11991199 }
12001200 return $newSets;
@@ -1201,10 +1201,11 @@
12021202 function &getDefinedMeaningDataAssociatedByConcept($dm, $dc) {
12031203 $meanings=array();
12041204 $map=getDataSetsAssociatedByConcept($dm, $dc);
 1205+ $dm_map=getAssociatedByConcept($dm, $dc);
12051206 foreach ($map as $map_dc => $map_dataset) {
12061207 $dmData=new DefinedMeaningData();
12071208 $dmData->setDataset($map_dataset);
1208 - $dmData->setId($map_dataset->getDefinedMeaningId());
 1209+ $dmData->setId($dm_map[$map_dc]);
12091210 $meanings[$map_dc]=$dmData;
12101211 }
12111212 return $meanings;
Index: trunk/extensions/Wikidata/OmegaWiki/Wikidata.php
@@ -368,7 +368,7 @@
369369 private $dataSetPrefix;
370370 private $isValidPrefix=false;
371371 private $fallbackName='';
372 - private $dmId=0;
 372+ private $dmId=0; # the dmId of the dataset name
373373
374374 public function getPrefix() {
375375 return $this->dataSetPrefix;
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialConceptMapping.php
@@ -45,8 +45,7 @@
4646 $wgOut->setPageTitle("ConceptMapping");
4747 $action=$wgRequest->getText('action');
4848 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();
5150 } elseif ($action=="insert"){
5251 $this->insert();
5352 } elseif ($action=="get"){
@@ -63,6 +62,50 @@
6463 }
6564 }
6665
 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+
67110 protected function help() {
68111 global $wgOut;
69112 $wgOut->addWikiText("<h2>Help</h2>");