r23622 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23621‎ | r23622 | r23623 >
Date:22:57, 1 July 2007
Author:kim
Status:old
Tags:
Comment:
(TODO)
Partial: Add saves to DefinedMeaningModel.php ... quick and dirty voodoo hack. Still needs debugging.


(+ some function documentation in Record.php)
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/Record.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php
@@ -1,7 +1,11 @@
22 <?php
33
44 require_once('OmegaWikiRecordSets.php');
 5+require_once('OmegaWikiAttributes.php');
 6+require_once("Transaction.php");
 7+require_once("WikiDataAPI.php");
58
 9+
610 class DefinedMeaningModel {
711
812 protected $record=null;
@@ -38,10 +42,58 @@
3943
4044 }
4145
 46+ /*horrible cannibalised hack. Use at own risk*/
4247 public function save() {
 48+ initializeOmegaWikiAttributes($this->filterLanguageId != 0, false);
 49+ initializeObjectAttributeEditors($this->filterLanguageId, false);
 50+ global
 51+ $wgTitle;
4352
 53+ $definedMeaningId = $this->getDefinedMeaningIdFromTitle($wgTitle->getText());
 54+
 55+ $definedMeaningId = $this->getDefinedMeaningIdFromTitle($wgTitle->getText());
 56+ getDefinedMeaningEditor($this->filterLanguageId, $this->possiblySynonymousRelationTypeId, false, false)->save(
 57+ $this->getIdStack($definedMeaningId),
 58+ $this->getRecord()
 59+ );
4460 }
4561
 62+ /*horrible cannibalised hack. Use at own risk*/
 63+ protected function getIdStack($definedMeaningId) {
 64+ global
 65+ $definedMeaningIdAttribute;
 66+
 67+ $definedMeaningIdStructure = new Structure($definedMeaningIdAttribute);
 68+ $definedMeaningIdRecord = new ArrayRecord($definedMeaningIdStructure, $definedMeaningIdStructure);
 69+ $definedMeaningIdRecord->setAttributeValue($definedMeaningIdAttribute, $definedMeaningId);
 70+
 71+ $idStack = new IdStack("defined-meaning");
 72+ $idStack->pushKey($definedMeaningIdRecord);
 73+
 74+ return $idStack;
 75+ }
 76+
 77+ /*horrible cannibalised hack. Use at own risk*/
 78+ public function saveWithinTransaction() {
 79+ global
 80+ $wgTitle, $wgUser, $wgRequest;
 81+
 82+ $summary = $wgRequest->getText('summary');
 83+
 84+ // Insert transaction information into the DB
 85+ startNewTransaction($wgUser->getID(), wfGetIP(), $summary);
 86+
 87+ // Perform regular save
 88+ $this->save(new QueryAtTransactionInformation($wgRequest->getInt('transaction'), false));
 89+
 90+ // Update page caches
 91+ Title::touchArray(array($wgTitle));
 92+
 93+ // Add change to RC log
 94+ $now = wfTimestampNow();
 95+ RecentChange::notifyEdit($now, $wgTitle, false, $wgUser, $summary, 0, $now, false, '', 0, 0, 0);
 96+ }
 97+
4698 public function getRecord() {
4799 return $this->record;
48100 }
Index: trunk/extensions/Wikidata/OmegaWiki/Record.php
@@ -58,6 +58,18 @@
5959 return $this->getType();
6060 }
6161
 62+ /** temporary hack to complete an arrayrecord structure
 63+ * Uses knowlege already present in our Record based structure
 64+ * to explain to records what they are. (ie, finish completes the
 65+ * building of the structure, to leave it in a usable state)
 66+ * @param $type the type that this record should have.
 67+ * (if you have no idea, use some random but readily
 68+ * recognisable string, other records should still get
 69+ * correct types)
 70+ * The brokenness of the system ends here, and only pretty code
 71+ * should run beyond this point. (One day ). Erik Moeller is working
 72+ * on eliminating this function which would be excellent.
 73+ */
6274 public function finish($type) {
6375 $type=$this->suggestType($type);
6476

Status & tagging log