r25028 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25027‎ | r25028 | r25029 >
Date:02:41, 22 August 2007
Author:kim
Status:old
Tags:
Comment:
Now with auto-conceptmapping when saving (kinda saves me
searching back my dm, each time I edit)

Global dc must die, forsure, but conceptmapping was already
global-dc-agnostic. (pleasant surprise there)
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php
@@ -195,18 +195,36 @@
196196 # // but where to get useful
197197 # // text?
198198
199 - $text=$this->getTitleText();
 199+
 200+ $this->hackDC(); // XXX
 201+ $text=$this->getDefiningExpression();
 202+ $this->unhackDC(); // XXX
200203
 204+
201205 #here we assume the DM is not there yet.. not entirely wise
202206 #in the long run.
203207 echo "id: $expressionId lang: $languageId";
204 - $definedMeaningId=createNewDefinedMeaning($expressionId, $languageId, $text);
 208+ $newDefinedMeaningId=createNewDefinedMeaning($expressionId, $languageId, $text);
205209
206210
207211 getDefinedMeaningEditor($this->viewInformation)->save(
208 - $this->getIdStack($definedMeaningId),
 212+ $this->getIdStack($newDefinedMeaningId),
209213 $this->getRecord()
210214 );
 215+
 216+ /* And do some conceptmapping.
 217+ * Not as painful as you might think:
 218+ * createConceptMapping is already dataset agnostic
 219+ * XXX Still, I'm pulling datasets back out of (un)hackDC...
 220+ */
 221+ $map=array();
 222+ $this->hackDC(); # XXX
 223+ $dataset1=$this->getDataSet();
 224+ $oldId=$this->getId();
 225+ $map["$dataset1"]=$oldId;
 226+ $dataset2=$this->unhackDC(); # XXX
 227+ $map["$dataset2"]=$newDefinedMeaningId;
 228+ createConceptMapping($map);
211229 }
212230
213231 /**
@@ -257,9 +275,9 @@
258276 public function getRecord() {
259277 if(!$this->recordIsLoaded) {
260278
261 - $this->hackDC($this->dataset); // XXX don't do this at home
 279+ $this->hackDC(); // XXX don't do this at home
262280 $this->loadRecord();
263 - $this->unhackDC(); // XXX very evil
 281+ $this->unhackDC(); // XXX
264282 }
265283 if(!$this->recordIsLoaded) {
266284 return null;
@@ -319,20 +337,28 @@
320338 * Of course, one day they will.
321339 * Before then, this should be refactored out.
322340 * Probably by next week friday
 341+ * Note that there is no stack, so you can't nest these!
 342+ * Nor will we implement one, global dc must die.
323343 * XXX */
324 - protected $_saved_dc=null;
325 - public function hackDC($to_dataset) {
 344+ private $_saved_dc=null; # the dirty secret
 345+
 346+ public function hackDC($to_dataset=null) {
326347 global
327348 $wdCurrentContext;
328349
 350+ if ($to_dataset==null)
 351+ $to_dataset=$this->dataset;
 352+
329353 $this->_saved_dc=$wdCurrentContext;
330354 $wdCurrentContext=$to_dc;
 355+ return $wdCurrentContext;
331356 }
332357
333358 public function unhackDC() {
334359 global
335360 $wdCurrentContext;
336361 $wdCurrentContext=$this->_saved_dc;
 362+ return $wdCurrentContext;
337363 }
338364
339365 /**

Status & tagging log