Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataAPI.php |
— | — | @@ -471,6 +471,12 @@ |
472 | 472 | |
473 | 473 | function translatedTextExists($textId, $languageId) { |
474 | 474 | $dc=wdGetDataSetContext(); |
| 475 | + |
| 476 | + if (is_null($textId)) |
| 477 | + throw new Exception("textId is null"); |
| 478 | + if (is_null($languageId)) |
| 479 | + throw new Exception("languageId is null"); |
| 480 | + |
475 | 481 | $dbr = &wfGetDB(DB_SLAVE); |
476 | 482 | $queryResult = $dbr->query( |
477 | 483 | "SELECT translated_content_id" . |
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiRecordSets.php |
— | — | @@ -629,17 +629,18 @@ |
630 | 630 | |
631 | 631 | $o=OmegaWikiAttributes::getInstance(); |
632 | 632 | |
633 | | - if ($viewInformation->filterLanguageId == 0) |
| 633 | + if ($viewInformation->filterLanguageId == 0) { |
634 | 634 | return getTranslatedContentRecordSet($translatedContentId, $viewInformation); |
635 | | - else { |
| 635 | + |
| 636 | + } else { |
636 | 637 | $recordSet = getFilteredTranslatedContentRecordSet($translatedContentId, $viewInformation); |
637 | 638 | |
638 | 639 | if (count($viewInformation->queryTransactionInformation->versioningAttributes()) > 0) |
639 | 640 | return $recordSet; |
640 | 641 | else { |
641 | | - if ($recordSet->getRecordCount() > 0) |
| 642 | + if ($recordSet->getRecordCount() > 0) { |
642 | 643 | return $recordSet->getRecord(0)->text; |
643 | | - else |
| 644 | + } else |
644 | 645 | return ""; |
645 | 646 | } |
646 | 647 | } |
— | — | @@ -651,6 +652,7 @@ |
652 | 653 | global |
653 | 654 | $translatedContentTable; |
654 | 655 | |
| 656 | + |
655 | 657 | $o=OmegaWikiAttributes::getInstance(); |
656 | 658 | |
657 | 659 | $recordSet = queryRecordSet( |
Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php |
— | — | @@ -155,12 +155,10 @@ |
156 | 156 | $record->possiblySynonymous = getPossiblySynonymousRecordSet($id, $view); |
157 | 157 | $filterRelationTypes[] = $view->possiblySynonymousRelationTypeId; |
158 | 158 | } |
159 | | - |
160 | 159 | $record->relations = getDefinedMeaningRelationsRecordSet($id, $filterRelationTypes, $view); |
161 | 160 | $record->reciprocalRelations = getDefinedMeaningReciprocalRelationsRecordSet($id, $view); |
162 | 161 | $record->classMembership = getDefinedMeaningClassMembershipRecordSet($id, $view); |
163 | 162 | $record->collectionMembership= getDefinedMeaningCollectionMembershipRecordSet($id, $view); |
164 | | - |
165 | 163 | $objectAttributesRecord = getObjectAttributesRecord($id, $view); |
166 | 164 | $record->definedMeaningAttributes = $objectAttributesRecord; |
167 | 165 | applyPropertyToColumnFiltersToRecord($record, $objectAttributesRecord, $view); |
— | — | @@ -189,6 +187,7 @@ |
190 | 188 | # more here? |
191 | 189 | $expression->createNewInDatabase(); |
192 | 190 | |
| 191 | + |
193 | 192 | # shouldn't this stuff be protected? |
194 | 193 | $expressionId=$expression->id; |
195 | 194 | $languageId=$expression->languageId; |
— | — | @@ -203,6 +202,7 @@ |
204 | 203 | echo "id: $expressionId lang: $languageId"; |
205 | 204 | $definedMeaningId=createNewDefinedMeaning($expressionId, $languageId, $text); |
206 | 205 | |
| 206 | + |
207 | 207 | getDefinedMeaningEditor($this->viewInformation)->save( |
208 | 208 | $this->getIdStack($definedMeaningId), |
209 | 209 | $this->getRecord() |
— | — | @@ -256,7 +256,10 @@ |
257 | 257 | */ |
258 | 258 | public function getRecord() { |
259 | 259 | if(!$this->recordIsLoaded) { |
| 260 | + |
| 261 | + $this->hackDC($this->dataset); // XXX don't do this at home |
260 | 262 | $this->loadRecord(); |
| 263 | + $this->unhackDC(); // XXX very evil |
261 | 264 | } |
262 | 265 | if(!$this->recordIsLoaded) { |
263 | 266 | return null; |
— | — | @@ -279,7 +282,6 @@ |
280 | 283 | |
281 | 284 | $record=$this->getRecord(); |
282 | 285 | $expression=$record->expression; |
283 | | - echo var_dump($expression); |
284 | 286 | $spelling=$expression->definedMeaningDefiningExpression; |
285 | 287 | $language=$expression->language; |
286 | 288 | return findOrCreateExpression($spelling, $language); |
— | — | @@ -308,6 +310,31 @@ |
309 | 311 | # use proper OO for this. |
310 | 312 | } |
311 | 313 | |
| 314 | + /* XXX |
| 315 | + * 2 very dirty functions, as a placeholder to make things work |
| 316 | + * this very instant. |
| 317 | + * Take the already evil global context, and twist it to our |
| 318 | + * own nefarious ends, then we put it back ASAP and hope nobody |
| 319 | + * notices. |
| 320 | + * Of course, one day they will. |
| 321 | + * Before then, this should be refactored out. |
| 322 | + * Probably by next week friday |
| 323 | + * XXX */ |
| 324 | + protected $_saved_dc=null; |
| 325 | + public function hackDC($to_dataset) { |
| 326 | + global |
| 327 | + $wdCurrentContext; |
| 328 | + |
| 329 | + $this->_saved_dc=$wdCurrentContext; |
| 330 | + $wdCurrentContext=$to_dc; |
| 331 | + } |
| 332 | + |
| 333 | + public function unhackDC() { |
| 334 | + global |
| 335 | + $wdCurrentContext; |
| 336 | + $wdCurrentContext=$this->_saved_dc; |
| 337 | + } |
| 338 | + |
312 | 339 | /** |
313 | 340 | * Return one of the syntrans entries of this defined meaning, |
314 | 341 | * specified by language code. Caches the syntrans records |