Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php |
— | — | @@ -1,7 +1,11 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | require_once('OmegaWikiRecordSets.php'); |
| 5 | +require_once('OmegaWikiAttributes.php'); |
| 6 | +require_once("Transaction.php"); |
| 7 | +require_once("WikiDataAPI.php"); |
5 | 8 | |
| 9 | + |
6 | 10 | class DefinedMeaningModel { |
7 | 11 | |
8 | 12 | protected $record=null; |
— | — | @@ -38,10 +42,58 @@ |
39 | 43 | |
40 | 44 | } |
41 | 45 | |
| 46 | + /*horrible cannibalised hack. Use at own risk*/ |
42 | 47 | public function save() { |
| 48 | + initializeOmegaWikiAttributes($this->filterLanguageId != 0, false); |
| 49 | + initializeObjectAttributeEditors($this->filterLanguageId, false); |
| 50 | + global |
| 51 | + $wgTitle; |
43 | 52 | |
| 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 | + ); |
44 | 60 | } |
45 | 61 | |
| 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 | + |
46 | 98 | public function getRecord() { |
47 | 99 | return $this->record; |
48 | 100 | } |
Index: trunk/extensions/Wikidata/OmegaWiki/Record.php |
— | — | @@ -58,6 +58,18 @@ |
59 | 59 | return $this->getType(); |
60 | 60 | } |
61 | 61 | |
| 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 | + */ |
62 | 74 | public function finish($type) { |
63 | 75 | $type=$this->suggestType($type); |
64 | 76 | |