Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php |
— | — | @@ -195,18 +195,36 @@ |
196 | 196 | # // but where to get useful |
197 | 197 | # // text? |
198 | 198 | |
199 | | - $text=$this->getTitleText(); |
| 199 | + |
| 200 | + $this->hackDC(); // XXX |
| 201 | + $text=$this->getDefiningExpression(); |
| 202 | + $this->unhackDC(); // XXX |
200 | 203 | |
| 204 | + |
201 | 205 | #here we assume the DM is not there yet.. not entirely wise |
202 | 206 | #in the long run. |
203 | 207 | echo "id: $expressionId lang: $languageId"; |
204 | | - $definedMeaningId=createNewDefinedMeaning($expressionId, $languageId, $text); |
| 208 | + $newDefinedMeaningId=createNewDefinedMeaning($expressionId, $languageId, $text); |
205 | 209 | |
206 | 210 | |
207 | 211 | getDefinedMeaningEditor($this->viewInformation)->save( |
208 | | - $this->getIdStack($definedMeaningId), |
| 212 | + $this->getIdStack($newDefinedMeaningId), |
209 | 213 | $this->getRecord() |
210 | 214 | ); |
| 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); |
211 | 229 | } |
212 | 230 | |
213 | 231 | /** |
— | — | @@ -257,9 +275,9 @@ |
258 | 276 | public function getRecord() { |
259 | 277 | if(!$this->recordIsLoaded) { |
260 | 278 | |
261 | | - $this->hackDC($this->dataset); // XXX don't do this at home |
| 279 | + $this->hackDC(); // XXX don't do this at home |
262 | 280 | $this->loadRecord(); |
263 | | - $this->unhackDC(); // XXX very evil |
| 281 | + $this->unhackDC(); // XXX |
264 | 282 | } |
265 | 283 | if(!$this->recordIsLoaded) { |
266 | 284 | return null; |
— | — | @@ -319,20 +337,28 @@ |
320 | 338 | * Of course, one day they will. |
321 | 339 | * Before then, this should be refactored out. |
322 | 340 | * 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. |
323 | 343 | * 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) { |
326 | 347 | global |
327 | 348 | $wdCurrentContext; |
328 | 349 | |
| 350 | + if ($to_dataset==null) |
| 351 | + $to_dataset=$this->dataset; |
| 352 | + |
329 | 353 | $this->_saved_dc=$wdCurrentContext; |
330 | 354 | $wdCurrentContext=$to_dc; |
| 355 | + return $wdCurrentContext; |
331 | 356 | } |
332 | 357 | |
333 | 358 | public function unhackDC() { |
334 | 359 | global |
335 | 360 | $wdCurrentContext; |
336 | 361 | $wdCurrentContext=$this->_saved_dc; |
| 362 | + return $wdCurrentContext; |
337 | 363 | } |
338 | 364 | |
339 | 365 | /** |