r23655 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23654‎ | r23655 | r23656 >
Date:20:44, 2 July 2007
Author:kim
Status:old
Tags:
Comment:
(in progress) saving current progress
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/SaveDM.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/Wikidata.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/SaveDM.php
@@ -14,8 +14,10 @@
1515 require_once("Transaction.php");
1616
1717 /** 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;
2022 $filterLanguageId=0; # ??? What does this do ???
2123 $possiblySynonymousRelationTypeId=0; # ??? What does this do ???
2224 $queryTransactionInformation= new QueryLatestTransactionInformation();
@@ -25,8 +27,12 @@
2628 return $model;
2729 }
2830
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();
3137 }
3238
3339 global
@@ -38,11 +44,14 @@
3945
4046 /* insert code here */
4147
42 -$model=getDM(663655);
43 -$record=$model->getRecord();
44 -echo $record;
 48+$model=getDM(663672,"uw");
4549
 50+#$record=$model->getRecord();
 51+#echo $record;
4652
 53+SaveDM($model,"tt");
 54+
 55+
4756 $endTime = time();
4857 echo("\n\nTime elapsed: " . durationToString($endTime - $beginTime));
4958
Index: trunk/extensions/Wikidata/OmegaWiki/Wikidata.php
@@ -263,6 +263,11 @@
264264
265265 }
266266
 267+
 268+# Global context override. This is an evil hack to allow saving, basically.
 269+global $wdCurrentContext;
 270+$wdCurrentContext=null;
 271+
267272 /**
268273 * A Wikidata application can manage multiple data sets.
269274 * The current "context" is dependent on multiple factors:
@@ -275,9 +280,15 @@
276281 * @return prefix (without underscore)
277282 **/
278283 function wdGetDataSetContext($dc=null) {
 284+ global $wgRequest, $wdDefaultViewDataSet, $wdGroupDefaultView, $wgUser,
 285+ $wdCurrentContext;
 286+
 287+ # overrides
279288 if (!is_null($dc))
280289 return $dc;
281 - global $wgRequest, $wdDefaultViewDataSet, $wdGroupDefaultView, $wgUser;
 290+ if (!is_null($wdCurrentContext))
 291+ return $wdCurrentContext;
 292+
282293 $datasets=wdGetDataSets();
283294 $groups=$wgUser->getGroups();
284295 $dbs=wfGetDB(DB_SLAVE);
Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php
@@ -9,6 +9,7 @@
1010 class DefinedMeaningModel {
1111
1212 protected $record=null;
 13+ protected $definedMeaningID=null;
1314
1415 public function __construct($definedMeaningId, $filterLanguageId, $possiblySynonymousRelationTypeId, $queryTransactionInformation) {
1516
@@ -20,6 +21,7 @@
2122 $classMembershipAttribute, $collectionMembershipAttribute, $definedMeaningAttributesAttribute,
2223 $possiblySynonymousAttribute;
2324
 25+ $this->setDefinedMeaningID($definedMeaningId);
2426 $record = new ArrayRecord($definedMeaningAttribute->type->getAttributes());
2527 $record->setAttributeValue($definitionAttribute, getDefinedMeaningDefinitionRecord($definedMeaningId, $filterLanguageId, $queryTransactionInformation));
2628 $record->setAttributeValue($classAttributesAttribute, getClassAttributesRecordSet($definedMeaningId, $queryTransactionInformation));
@@ -46,12 +48,8 @@
4749 public function save() {
4850 initializeOmegaWikiAttributes($this->filterLanguageId != 0, false);
4951 initializeObjectAttributeEditors($this->filterLanguageId, false);
50 - global
51 - $wgTitle;
52 -
53 - $definedMeaningId = $this->getDefinedMeaningIdFromTitle($wgTitle->getText());
 52+ $definedMeaningId = $this->getDefinedMeaningID();
5453
55 - $definedMeaningId = $this->getDefinedMeaningIdFromTitle($wgTitle->getText());
5654 getDefinedMeaningEditor($this->filterLanguageId, $this->possiblySynonymousRelationTypeId, false, false)->save(
5755 $this->getIdStack($definedMeaningId),
5856 $this->getRecord()
@@ -98,5 +96,13 @@
9997 return $this->record;
10098 }
10199
 100+ public function setDefinedMeaningID($definedMeaningID) {
 101+ $this->definedMeaningID=$definedMeaningID;
 102+ }
 103+
 104+ public function getDefinedMeaningID() {
 105+ return $this->definedMeaningID;
 106+ }
 107+
102108 }
103109

Status & tagging log