Index: trunk/extensions/Wikidata/OmegaWiki/Wikidata.php |
— | — | @@ -404,7 +404,7 @@ |
405 | 405 | |
406 | 406 | /** |
407 | 407 | * A representation and easy access to all defined-meaning related data in one handy spot |
408 | | - * or would be. Currently only holds data that is eally needed. Please expand and |
| 408 | + * or would be. Currently only holds data that is really needed. Please expand and |
409 | 409 | * use to replace WiKiDataAPI. |
410 | 410 | * Sometimes a getter or setter will query the database and/or attempt to deduce additional |
411 | 411 | * information based on what it already knows, but don't count on that (yet). |
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiRecordSets.php |
— | — | @@ -359,11 +359,12 @@ |
360 | 360 | |
361 | 361 | while($definedMeaning = $dbr->fetchObject($queryResult)) { |
362 | 362 | $definedMeaningId = $definedMeaning->defined_meaning_id; |
| 363 | + $dmModel=new DefinedMeaningModel($definedMeaningId, $filterLanguageId, $possiblySynonymousRelationTypeId, $queryTransactionInformation); |
363 | 364 | $recordSet->addRecord( |
364 | 365 | array( |
365 | 366 | $definedMeaningId, |
366 | 367 | getDefinedMeaningDefinition($definedMeaningId), |
367 | | - getDefinedMeaningRecord($definedMeaningId, $filterLanguageId, $possiblySynonymousRelationTypeId, $queryTransactionInformation) |
| 368 | + $dmModel->getRecord() |
368 | 369 | ) |
369 | 370 | ); |
370 | 371 | } |
— | — | @@ -449,36 +450,7 @@ |
450 | 451 | return 0; |
451 | 452 | } |
452 | 453 | |
453 | | -function getDefinedMeaningRecord($definedMeaningId, $filterLanguageId, $possiblySynonymousRelationTypeId, $queryTransactionInformation) { |
454 | | - global |
455 | | - $definedMeaningAttribute, $definitionAttribute, $classAttributesAttribute, |
456 | | - $alternativeDefinitionsAttribute, $synonymsAndTranslationsAttribute, |
457 | | - $relationsAttribute, $reciprocalRelationsAttribute, |
458 | | - $classMembershipAttribute, $collectionMembershipAttribute, $definedMeaningAttributesAttribute, |
459 | | - $possiblySynonymousAttribute; |
460 | 454 | |
461 | | - $record = new ArrayRecord($definedMeaningAttribute->type->getStructure()); |
462 | | - $record->setAttributeValue($definitionAttribute, getDefinedMeaningDefinitionRecord($definedMeaningId, $filterLanguageId, $queryTransactionInformation)); |
463 | | - $record->setAttributeValue($classAttributesAttribute, getClassAttributesRecordSet($definedMeaningId, $queryTransactionInformation)); |
464 | | - $record->setAttributeValue($alternativeDefinitionsAttribute, getAlternativeDefinitionsRecordSet($definedMeaningId, $filterLanguageId, $queryTransactionInformation)); |
465 | | - $record->setAttributeValue($synonymsAndTranslationsAttribute, getSynonymAndTranslationRecordSet($definedMeaningId, $filterLanguageId, $queryTransactionInformation)); |
466 | | - |
467 | | - $filterRelationTypes = array(); |
468 | | - |
469 | | - if ($possiblySynonymousRelationTypeId != 0) { |
470 | | - $record->setAttributeValue($possiblySynonymousAttribute, getPossiblySynonymousRecordSet($definedMeaningId, $filterLanguageId, $possiblySynonymousRelationTypeId, $queryTransactionInformation)); |
471 | | - $filterRelationTypes[] = $possiblySynonymousRelationTypeId; |
472 | | - } |
473 | | - |
474 | | - $record->setAttributeValue($relationsAttribute, getDefinedMeaningRelationsRecordSet($definedMeaningId, $filterLanguageId, $filterRelationTypes, $queryTransactionInformation)); |
475 | | - $record->setAttributeValue($reciprocalRelationsAttribute, getDefinedMeaningReciprocalRelationsRecordSet($definedMeaningId, $filterLanguageId, $queryTransactionInformation)); |
476 | | - $record->setAttributeValue($classMembershipAttribute, getDefinedMeaningClassMembershipRecordSet($definedMeaningId, $queryTransactionInformation)); |
477 | | - $record->setAttributeValue($collectionMembershipAttribute, getDefinedMeaningCollectionMembershipRecordSet($definedMeaningId, $queryTransactionInformation)); |
478 | | - $record->setAttributeValue($definedMeaningAttributesAttribute, getObjectAttributesRecord($definedMeaningId, $filterLanguageId, $queryTransactionInformation)); |
479 | | - |
480 | | - return $record; |
481 | | -} |
482 | | - |
483 | 455 | function getClassAttributesRecordSet($definedMeaningId, $queryTransactionInformation) { |
484 | 456 | global |
485 | 457 | $classAttributesTable, $classAttributeIdAttribute, $classAttributeLevelAttribute, $classAttributeAttributeAttribute, $classAttributeTypeAttribute, $optionAttributeOptionsAttribute; |
Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php |
— | — | @@ -0,0 +1,49 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +require_once('OmegaWikiRecordSets.php'); |
| 5 | + |
| 6 | +class DefinedMeaningModel { |
| 7 | + |
| 8 | + protected $record=null; |
| 9 | + |
| 10 | + public function __construct($definedMeaningId, $filterLanguageId, $possiblySynonymousRelationTypeId, $queryTransactionInformation) { |
| 11 | + |
| 12 | + global |
| 13 | + $definedMeaningAttribute, $definitionAttribute, $classAttributesAttribute, |
| 14 | + $alternativeDefinitionsAttribute, $synonymsAndTranslationsAttribute, |
| 15 | + $relationsAttribute, $reciprocalRelationsAttribute, |
| 16 | + $classMembershipAttribute, $collectionMembershipAttribute, $definedMeaningAttributesAttribute, |
| 17 | + $possiblySynonymousAttribute; |
| 18 | + |
| 19 | + $record = new ArrayRecord($definedMeaningAttribute->type->getStructure()); |
| 20 | + $record->setAttributeValue($definitionAttribute, getDefinedMeaningDefinitionRecord($definedMeaningId, $filterLanguageId, $queryTransactionInformation)); |
| 21 | + $record->setAttributeValue($classAttributesAttribute, getClassAttributesRecordSet($definedMeaningId, $queryTransactionInformation)); |
| 22 | + $record->setAttributeValue($alternativeDefinitionsAttribute, getAlternativeDefinitionsRecordSet($definedMeaningId, $filterLanguageId, $queryTransactionInformation)); |
| 23 | + $record->setAttributeValue($synonymsAndTranslationsAttribute, getSynonymAndTranslationRecordSet($definedMeaningId, $filterLanguageId, $queryTransactionInformation)); |
| 24 | + |
| 25 | + $filterRelationTypes = array(); |
| 26 | + |
| 27 | + if ($possiblySynonymousRelationTypeId != 0) { |
| 28 | + $record->setAttributeValue($possiblySynonymousAttribute, getPossiblySynonymousRecordSet($definedMeaningId, $filterLanguageId, $possiblySynonymousRelationTypeId, $queryTransactionInformation)); |
| 29 | + $filterRelationTypes[] = $possiblySynonymousRelationTypeId; |
| 30 | + } |
| 31 | + |
| 32 | + $record->setAttributeValue($relationsAttribute, getDefinedMeaningRelationsRecordSet($definedMeaningId, $filterLanguageId, $filterRelationTypes, $queryTransactionInformation)); |
| 33 | + $record->setAttributeValue($reciprocalRelationsAttribute, getDefinedMeaningReciprocalRelationsRecordSet($definedMeaningId, $filterLanguageId, $queryTransactionInformation)); |
| 34 | + $record->setAttributeValue($classMembershipAttribute, getDefinedMeaningClassMembershipRecordSet($definedMeaningId, $queryTransactionInformation)); |
| 35 | + $record->setAttributeValue($collectionMembershipAttribute, getDefinedMeaningCollectionMembershipRecordSet($definedMeaningId, $queryTransactionInformation)); |
| 36 | + $record->setAttributeValue($definedMeaningAttributesAttribute, getObjectAttributesRecord($definedMeaningId, $filterLanguageId, $queryTransactionInformation)); |
| 37 | + $this->record=$record; |
| 38 | + |
| 39 | + } |
| 40 | + |
| 41 | + public function save() { |
| 42 | + |
| 43 | + } |
| 44 | + |
| 45 | + public function getRecord() { |
| 46 | + return $this->record; |
| 47 | + } |
| 48 | + |
| 49 | +} |
| 50 | +?> |
\ No newline at end of file |
Property changes on: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 51 | + native |
Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaning.php |
— | — | @@ -3,6 +3,7 @@ |
4 | 4 | require_once('Wikidata.php'); |
5 | 5 | require_once('OmegaWikiRecordSets.php'); |
6 | 6 | require_once('OmegaWikiEditors.php'); |
| 7 | +require_once('DefinedMeaningModel.php'); |
7 | 8 | |
8 | 9 | class DefinedMeaning extends DefaultWikidataApplication { |
9 | 10 | public function view() { |
— | — | @@ -27,16 +28,18 @@ |
28 | 29 | $definedMeaningId = $this->getDefinedMeaningIdFromTitle($wgTitle->getText()); |
29 | 30 | |
30 | 31 | $wgOut->addHTML($this->getConceptPanel()); |
| 32 | + |
| 33 | + $dmModel=new DefinedMeaningModel( |
| 34 | + $definedMeaningId, |
| 35 | + $this->filterLanguageId, |
| 36 | + $this->possiblySynonymousRelationTypeId, |
| 37 | + $this->viewQueryTransactionInformation); |
| 38 | + |
31 | 39 | $wgOut->addHTML( |
32 | 40 | getDefinedMeaningEditor( |
33 | 41 | $this->filterLanguageId, $this->possiblySynonymousRelationTypeId, false, $this->shouldShowAuthorities)->view( |
34 | 42 | $this->getIdStack($definedMeaningId), |
35 | | - getDefinedMeaningRecord( |
36 | | - $definedMeaningId, |
37 | | - $this->filterLanguageId, |
38 | | - $this->possiblySynonymousRelationTypeId, |
39 | | - $this->viewQueryTransactionInformation |
40 | | - ) |
| 43 | + $dmModel->getRecord() |
41 | 44 | ) |
42 | 45 | ); |
43 | 46 | $this->outputViewFooter(); |
— | — | @@ -51,15 +54,16 @@ |
52 | 55 | $definedMeaningId = $this->getDefinedMeaningIdFromTitle($wgTitle->getText()); |
53 | 56 | |
54 | 57 | $this->outputEditHeader(); |
| 58 | + $dmModel=new DefinedMeaningModel( |
| 59 | + $definedMeaningId, |
| 60 | + $this->filterLanguageId, |
| 61 | + $this->possiblySynonymousRelationTypeId, |
| 62 | + new QueryLatestTransactionInformation() |
| 63 | + ); |
55 | 64 | $wgOut->addHTML( |
56 | 65 | getDefinedMeaningEditor($this->filterLanguageId, $this->possiblySynonymousRelationTypeId, false, false)->edit( |
57 | 66 | $this->getIdStack($definedMeaningId), |
58 | | - getDefinedMeaningRecord( |
59 | | - $definedMeaningId, |
60 | | - $this->filterLanguageId, |
61 | | - $this->possiblySynonymousRelationTypeId, |
62 | | - new QueryLatestTransactionInformation() |
63 | | - ) |
| 67 | + $dmModel->getRecord() |
64 | 68 | ) |
65 | 69 | ); |
66 | 70 | $this->outputEditFooter(); |
— | — | @@ -72,15 +76,16 @@ |
73 | 77 | parent::history(); |
74 | 78 | |
75 | 79 | $definedMeaningId = $this->getDefinedMeaningIdFromTitle($wgTitle->getText()); |
76 | | - $wgOut->addHTML( |
77 | | - getDefinedMeaningEditor($this->filterLanguageId, $this->possiblySynonymousRelationTypeId, $this->showRecordLifeSpan, false)->view( |
78 | | - new IdStack("defined-meaning"), |
79 | | - getDefinedMeaningRecord( |
| 80 | + $dmModel=new DefinedMeaningModel( |
80 | 81 | $definedMeaningId, |
81 | 82 | $this->filterLanguageId, |
82 | 83 | $this->possiblySynonymousRelationTypeId, |
83 | 84 | $this->queryTransactionInformation |
84 | | - ) |
| 85 | + ); |
| 86 | + $wgOut->addHTML( |
| 87 | + getDefinedMeaningEditor($this->filterLanguageId, $this->possiblySynonymousRelationTypeId, $this->showRecordLifeSpan, false)->view( |
| 88 | + new IdStack("defined-meaning"), |
| 89 | + $dmModel->getRecord() |
85 | 90 | ) |
86 | 91 | ); |
87 | 92 | |
— | — | @@ -96,13 +101,13 @@ |
97 | 102 | $wgTitle; |
98 | 103 | |
99 | 104 | $definedMeaningId = $this->getDefinedMeaningIdFromTitle($wgTitle->getText()); |
100 | | - $record=getDefinedMeaningRecord( |
| 105 | + $dmModel=new DefinedMeaningModel( |
101 | 106 | $definedMeaningId, |
102 | 107 | $this->filterLanguageId, |
103 | 108 | $this->possiblySynonymousRelationTypeId, |
104 | 109 | $this->viewQueryTransactionInformation |
105 | 110 | ); |
106 | | - return $record; |
| 111 | + return $dmModel->getRecord(); |
107 | 112 | } |
108 | 113 | |
109 | 114 | protected function save($referenceTransaction) { |
— | — | @@ -111,7 +116,7 @@ |
112 | 117 | |
113 | 118 | parent::save($referenceTransaction); |
114 | 119 | |
115 | | - $definedMeaningId = $this->getDefinedMeaningIdFromTitle($wgTitle->getText()); |
| 120 | +/* $definedMeaningId = $this->getDefinedMeaningIdFromTitle($wgTitle->getText()); |
116 | 121 | getDefinedMeaningEditor($this->filterLanguageId, $this->possiblySynonymousRelationTypeId, false, false)->save( |
117 | 122 | $this->getIdStack($definedMeaningId), |
118 | 123 | getDefinedMeaningRecord( |
— | — | @@ -120,7 +125,22 @@ |
121 | 126 | $this->possiblySynonymousRelationTypeId, |
122 | 127 | $referenceTransaction |
123 | 128 | ) |
| 129 | + );*/ |
| 130 | + |
| 131 | + global |
| 132 | + $wgTitle; |
| 133 | + |
| 134 | + $definedMeaningId = $this->getDefinedMeaningIdFromTitle($wgTitle->getText()); |
| 135 | + |
| 136 | + $dmModel=new DefinedMeaningModel( |
| 137 | + $definedMeaningId, |
| 138 | + $this->filterLanguageId, |
| 139 | + $this->possiblySynonymousRelationTypeId, |
| 140 | + $referenceTransaction |
124 | 141 | ); |
| 142 | + |
| 143 | + echo $dmModel->getRecord(); |
| 144 | + |
125 | 145 | } |
126 | 146 | |
127 | 147 | protected function getIdStack($definedMeaningId) { |