Index: trunk/extensions/Wikidata/OmegaWiki/SaveDM.php |
— | — | @@ -14,8 +14,10 @@ |
15 | 15 | require_once("Transaction.php"); |
16 | 16 | |
17 | 17 | /** Just get a defined meaning */ |
18 | | -function getDM($dm_id,$dc="uw") { |
19 | | - $definedMeaningId=663665; # UnitTest |
| 18 | +function getDM($definedMeaningId,$dc="uw") { |
| 19 | + global |
| 20 | + $wdCurrentContext; |
| 21 | + $wdCurrentContext=$dc; |
20 | 22 | $filterLanguageId=0; # ??? What does this do ??? |
21 | 23 | $possiblySynonymousRelationTypeId=0; # ??? What does this do ??? |
22 | 24 | $queryTransactionInformation= new QueryLatestTransactionInformation(); |
— | — | @@ -25,8 +27,12 @@ |
26 | 28 | return $model; |
27 | 29 | } |
28 | 30 | |
29 | | -function saveDM($model) { |
30 | | - $model->saveWithinTransaction(); |
| 31 | +function saveDM($model,$dc="uw") { |
| 32 | + global |
| 33 | + $wdCurrentContext; |
| 34 | + $wdCurrentContext=$dc; |
| 35 | + #echo $model->getRecord(); |
| 36 | + $model->save(); |
31 | 37 | } |
32 | 38 | |
33 | 39 | global |
— | — | @@ -38,11 +44,14 @@ |
39 | 45 | |
40 | 46 | /* insert code here */ |
41 | 47 | |
42 | | -$model=getDM(663655); |
43 | | -$record=$model->getRecord(); |
44 | | -echo $record; |
| 48 | +$model=getDM(663672,"uw"); |
45 | 49 | |
| 50 | +#$record=$model->getRecord(); |
| 51 | +#echo $record; |
46 | 52 | |
| 53 | +SaveDM($model,"tt"); |
| 54 | + |
| 55 | + |
47 | 56 | $endTime = time(); |
48 | 57 | echo("\n\nTime elapsed: " . durationToString($endTime - $beginTime)); |
49 | 58 | |
Index: trunk/extensions/Wikidata/OmegaWiki/Wikidata.php |
— | — | @@ -263,6 +263,11 @@ |
264 | 264 | |
265 | 265 | } |
266 | 266 | |
| 267 | + |
| 268 | +# Global context override. This is an evil hack to allow saving, basically. |
| 269 | +global $wdCurrentContext; |
| 270 | +$wdCurrentContext=null; |
| 271 | + |
267 | 272 | /** |
268 | 273 | * A Wikidata application can manage multiple data sets. |
269 | 274 | * The current "context" is dependent on multiple factors: |
— | — | @@ -275,9 +280,15 @@ |
276 | 281 | * @return prefix (without underscore) |
277 | 282 | **/ |
278 | 283 | function wdGetDataSetContext($dc=null) { |
| 284 | + global $wgRequest, $wdDefaultViewDataSet, $wdGroupDefaultView, $wgUser, |
| 285 | + $wdCurrentContext; |
| 286 | + |
| 287 | + # overrides |
279 | 288 | if (!is_null($dc)) |
280 | 289 | return $dc; |
281 | | - global $wgRequest, $wdDefaultViewDataSet, $wdGroupDefaultView, $wgUser; |
| 290 | + if (!is_null($wdCurrentContext)) |
| 291 | + return $wdCurrentContext; |
| 292 | + |
282 | 293 | $datasets=wdGetDataSets(); |
283 | 294 | $groups=$wgUser->getGroups(); |
284 | 295 | $dbs=wfGetDB(DB_SLAVE); |
Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php |
— | — | @@ -9,6 +9,7 @@ |
10 | 10 | class DefinedMeaningModel { |
11 | 11 | |
12 | 12 | protected $record=null; |
| 13 | + protected $definedMeaningID=null; |
13 | 14 | |
14 | 15 | public function __construct($definedMeaningId, $filterLanguageId, $possiblySynonymousRelationTypeId, $queryTransactionInformation) { |
15 | 16 | |
— | — | @@ -20,6 +21,7 @@ |
21 | 22 | $classMembershipAttribute, $collectionMembershipAttribute, $definedMeaningAttributesAttribute, |
22 | 23 | $possiblySynonymousAttribute; |
23 | 24 | |
| 25 | + $this->setDefinedMeaningID($definedMeaningId); |
24 | 26 | $record = new ArrayRecord($definedMeaningAttribute->type->getAttributes()); |
25 | 27 | $record->setAttributeValue($definitionAttribute, getDefinedMeaningDefinitionRecord($definedMeaningId, $filterLanguageId, $queryTransactionInformation)); |
26 | 28 | $record->setAttributeValue($classAttributesAttribute, getClassAttributesRecordSet($definedMeaningId, $queryTransactionInformation)); |
— | — | @@ -46,12 +48,8 @@ |
47 | 49 | public function save() { |
48 | 50 | initializeOmegaWikiAttributes($this->filterLanguageId != 0, false); |
49 | 51 | initializeObjectAttributeEditors($this->filterLanguageId, false); |
50 | | - global |
51 | | - $wgTitle; |
52 | | - |
53 | | - $definedMeaningId = $this->getDefinedMeaningIdFromTitle($wgTitle->getText()); |
| 52 | + $definedMeaningId = $this->getDefinedMeaningID(); |
54 | 53 | |
55 | | - $definedMeaningId = $this->getDefinedMeaningIdFromTitle($wgTitle->getText()); |
56 | 54 | getDefinedMeaningEditor($this->filterLanguageId, $this->possiblySynonymousRelationTypeId, false, false)->save( |
57 | 55 | $this->getIdStack($definedMeaningId), |
58 | 56 | $this->getRecord() |
— | — | @@ -98,5 +96,13 @@ |
99 | 97 | return $this->record; |
100 | 98 | } |
101 | 99 | |
| 100 | + public function setDefinedMeaningID($definedMeaningID) { |
| 101 | + $this->definedMeaningID=$definedMeaningID; |
| 102 | + } |
| 103 | + |
| 104 | + public function getDefinedMeaningID() { |
| 105 | + return $this->definedMeaningID; |
| 106 | + } |
| 107 | + |
102 | 108 | } |
103 | 109 | |