Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes.php |
— | — | @@ -153,7 +153,7 @@ |
154 | 154 | |
155 | 155 | global |
156 | 156 | $translatedTextAttributeIdAttribute, $translatedTextValueIdAttribute, |
157 | | - $textAttributeObjectAttribute, $translatedTextAttributeAttribute, $translatedTextValueAttribute, $translatedTextAttributeValuesAttribute, |
| 157 | + $translatedTextAttributeObjectAttribute, $translatedTextAttributeAttribute, $translatedTextValueAttribute, $translatedTextAttributeValuesAttribute, |
158 | 158 | $translatedTextAttributeValuesStructure, $wgTranslatedTextAttributeValuesAttributeName, $wgTranslatedTextAttributeAttributeName, $wgTranslatedTextAttributeValueAttributeName; |
159 | 159 | |
160 | 160 | $translatedTextAttributeIdAttribute = new Attribute("translated-text-attribute-id", "Attribute identifier", "object-id"); |
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiRecordSets.php |
— | — | @@ -10,8 +10,7 @@ |
11 | 11 | require_once('DefinedMeaningModel.php'); |
12 | 12 | require_once('ViewInformation.php'); |
13 | 13 | |
14 | | -function getSynonymSQLForLanguage($languageId, &$definedMeaningIds) { |
15 | | - |
| 14 | +function getSynonymSQLForLanguage($languageId, array &$definedMeaningIds) { |
16 | 15 | $dc=wdGetDataSetContext(); |
17 | 16 | |
18 | 17 | return |
— | — | @@ -28,8 +27,7 @@ |
29 | 28 | " GROUP BY {$dc}_defined_meaning.defined_meaning_id"; |
30 | 29 | } |
31 | 30 | |
32 | | -function getSynonymSQLForAnyLanguage(&$definedMeaningIds) { |
33 | | - |
| 31 | +function getSynonymSQLForAnyLanguage(array &$definedMeaningIds) { |
34 | 32 | $dc=wdGetDataSetContext(); |
35 | 33 | |
36 | 34 | return |
— | — | @@ -45,8 +43,7 @@ |
46 | 44 | " GROUP BY {$dc}_defined_meaning.defined_meaning_id"; |
47 | 45 | } |
48 | 46 | |
49 | | -function getDefiningSQLForLanguage($languageId, &$definedMeaningIds) { |
50 | | - |
| 47 | +function getDefiningSQLForLanguage($languageId, array &$definedMeaningIds) { |
51 | 48 | $dc=wdGetDataSetContext(); |
52 | 49 | |
53 | 50 | return |
— | — | @@ -64,8 +61,7 @@ |
65 | 62 | " GROUP BY {$dc}_defined_meaning.defined_meaning_id"; |
66 | 63 | } |
67 | 64 | |
68 | | -function fetchDefinedMeaningReferenceRecords($sql, &$definedMeaningIds, &$definedMeaningReferenceRecords, $usedAs='defined-meaning') { |
69 | | - |
| 65 | +function fetchDefinedMeaningReferenceRecords($sql, array &$definedMeaningIds, array &$definedMeaningReferenceRecords, $usedAs='defined-meaning') { |
70 | 66 | $dc=wdGetDataSetContext(); |
71 | 67 | |
72 | 68 | global |
— | — | @@ -93,7 +89,7 @@ |
94 | 90 | $definedMeaningIds = array_diff($definedMeaningIds, $foundDefinedMeaningIds); |
95 | 91 | } |
96 | 92 | |
97 | | -function fetchDefinedMeaningDefiningExpressions(&$definedMeaningIds, &$definedMeaningReferenceRecords) { |
| 93 | +function fetchDefinedMeaningDefiningExpressions(array &$definedMeaningIds, array &$definedMeaningReferenceRecords) { |
98 | 94 | global |
99 | 95 | $definedMeaningReferenceStructure, $definedMeaningIdAttribute, $definedMeaningLabelAttribute, |
100 | 96 | $definedMeaningDefiningExpressionAttribute; |
— | — | @@ -137,7 +133,7 @@ |
138 | 134 | return $record; |
139 | 135 | } |
140 | 136 | |
141 | | -function getDefinedMeaningReferenceRecords($definedMeaningIds, $usedAs) { |
| 137 | +function getDefinedMeaningReferenceRecords(array $definedMeaningIds, $usedAs) { |
142 | 138 | global |
143 | 139 | $wgUser; |
144 | 140 | |
— | — | @@ -200,8 +196,7 @@ |
201 | 197 | return $result; |
202 | 198 | } |
203 | 199 | |
204 | | -function expandDefinedMeaningReferencesInRecordSet($recordSet, $definedMeaningAttributes) { |
205 | | - |
| 200 | +function expandDefinedMeaningReferencesInRecordSet(RecordSet $recordSet, array $definedMeaningAttributes) { |
206 | 201 | $definedMeaningReferenceRecords=array(); |
207 | 202 | |
208 | 203 | foreach($definedMeaningAttributes as $dmatt) { |
— | — | @@ -220,14 +215,14 @@ |
221 | 216 | } |
222 | 217 | } |
223 | 218 | |
224 | | -function expandTranslatedContentInRecord($record, $idAttribute, $translatedContentAttribute, ViewInformation $viewInformation) { |
| 219 | +function expandTranslatedContentInRecord(Record $record, Attribute $idAttribute, Attribute $translatedContentAttribute, ViewInformation $viewInformation) { |
225 | 220 | $record->setAttributeValue( |
226 | 221 | $translatedContentAttribute, |
227 | 222 | getTranslatedContentValue($record->getAttributeValue($idAttribute), $viewInformation) |
228 | 223 | ); |
229 | 224 | } |
230 | 225 | |
231 | | -function expandTranslatedContentsInRecordSet($recordSet, $idAttribute, $translatedContentAttribute, ViewInformation $viewInformation) { |
| 226 | +function expandTranslatedContentsInRecordSet(RecordSet $recordSet, Attribute $idAttribute, Attribute $translatedContentAttribute, ViewInformation $viewInformation) { |
232 | 227 | for ($i = 0; $i < $recordSet->getRecordCount(); $i++) |
233 | 228 | expandTranslatedContentInRecord($recordSet->getRecord($i), $idAttribute, $translatedContentAttribute, $viewInformation); |
234 | 229 | } |
— | — | @@ -263,7 +258,7 @@ |
264 | 259 | return array(); |
265 | 260 | } |
266 | 261 | |
267 | | -function expandExpressionReferencesInRecordSet($recordSet, $expressionAttributes) { |
| 262 | +function expandExpressionReferencesInRecordSet(RecordSet $recordSet, array $expressionAttributes) { |
268 | 263 | $expressionReferenceRecords = getExpressionReferenceRecords(getUniqueIdsInRecordSet($recordSet, $expressionAttributes)); |
269 | 264 | |
270 | 265 | for ($i = 0; $i < $recordSet->getRecordCount(); $i++) { |
— | — | @@ -277,7 +272,7 @@ |
278 | 273 | } |
279 | 274 | } |
280 | 275 | |
281 | | -function getExpressionSpellings($expressionIds) { |
| 276 | +function getExpressionSpellings(array $expressionIds) { |
282 | 277 | global |
283 | 278 | $expressionAttribute; |
284 | 279 | |
— | — | @@ -303,7 +298,7 @@ |
304 | 299 | return array(); |
305 | 300 | } |
306 | 301 | |
307 | | -function expandExpressionSpellingsInRecordSet($recordSet, $expressionAttributes) { |
| 302 | +function expandExpressionSpellingsInRecordSet(RecordSet $recordSet, array $expressionAttributes) { |
308 | 303 | $expressionSpellings = getExpressionSpellings(getUniqueIdsInRecordSet($recordSet, $expressionAttributes)); |
309 | 304 | |
310 | 305 | for ($i = 0; $i < $recordSet->getRecordCount(); $i++) { |
— | — | @@ -317,8 +312,7 @@ |
318 | 313 | } |
319 | 314 | } |
320 | 315 | |
321 | | -function getTextReferences($textIds) { |
322 | | - |
| 316 | +function getTextReferences(array $textIds) { |
323 | 317 | $dc=wdGetDataSetContext(); |
324 | 318 | if (count($textIds) > 0) { |
325 | 319 | $dbr =& wfGetDB(DB_SLAVE); |
— | — | @@ -339,7 +333,7 @@ |
340 | 334 | return array(); |
341 | 335 | } |
342 | 336 | |
343 | | -function expandTextReferencesInRecordSet($recordSet, $textAttributes) { |
| 337 | +function expandTextReferencesInRecordSet(RecordSet $recordSet, array $textAttributes) { |
344 | 338 | $textReferences = getTextReferences(getUniqueIdsInRecordSet($recordSet, $textAttributes)); |
345 | 339 | |
346 | 340 | for ($i = 0; $i < $recordSet->getRecordCount(); $i++) { |
— | — | @@ -485,7 +479,7 @@ |
486 | 480 | return $recordSet; |
487 | 481 | } |
488 | 482 | |
489 | | -function expandOptionAttributeOptionsInRecordSet($recordSet, $attributeIdAttribute, ViewInformation $viewInformation) { |
| 483 | +function expandOptionAttributeOptionsInRecordSet(RecordSet $recordSet, Attribute $attributeIdAttribute, ViewInformation $viewInformation) { |
490 | 484 | global |
491 | 485 | $definedMeaningIdAttribute, $optionAttributeOptionsAttribute; |
492 | 486 | |
— | — | @@ -663,7 +657,7 @@ |
664 | 658 | return $recordSet; |
665 | 659 | } |
666 | 660 | |
667 | | -function expandObjectAttributesAttribute($recordSet, $objectIdAttribute, ViewInformation $viewInformation) { |
| 661 | +function expandObjectAttributesAttribute(RecordSet $recordSet, Attribute $objectIdAttribute, ViewInformation $viewInformation) { |
668 | 662 | global |
669 | 663 | $objectAttributesAttribute, |
670 | 664 | $textAttributeObjectAttribute, $textAttributeValuesAttribute, |
— | — | @@ -776,7 +770,7 @@ |
777 | 771 | return $record; |
778 | 772 | } |
779 | 773 | |
780 | | -function getDefinedMeaningRelationsRecordSet($definedMeaningId, $filterRelationTypes, ViewInformation $viewInformation) { |
| 774 | +function getDefinedMeaningRelationsRecordSet($definedMeaningId, array $filterRelationTypes, ViewInformation $viewInformation) { |
781 | 775 | global |
782 | 776 | $meaningRelationsTable, $relationIdAttribute, $relationTypeAttribute, |
783 | 777 | $objectAttributesAttribute, $otherDefinedMeaningAttribute, |
— | — | @@ -916,7 +910,7 @@ |
917 | 911 | return $recordSet; |
918 | 912 | } |
919 | 913 | |
920 | | -function getTextAttributesValuesRecordSet($objectIds, ViewInformation $viewInformation) { |
| 914 | +function getTextAttributesValuesRecordSet(array $objectIds, ViewInformation $viewInformation) { |
921 | 915 | global |
922 | 916 | $textAttributeValuesTable, $textAttributeIdAttribute, $textAttributeObjectAttribute, |
923 | 917 | $textAttributeAttribute, $textAttribute, $objectAttributesAttribute, |
— | — | @@ -946,7 +940,7 @@ |
947 | 941 | return $recordSet; |
948 | 942 | } |
949 | 943 | |
950 | | -function getURLAttributeValuesRecordSet($objectIds, ViewInformation $viewInformation) { |
| 944 | +function getURLAttributeValuesRecordSet(array $objectIds, ViewInformation $viewInformation) { |
951 | 945 | global |
952 | 946 | $urlAttributeValuesTable, $urlAttributeIdAttribute, $urlAttributeObjectAttribute, |
953 | 947 | $urlAttributeAttribute, $urlAttribute, $objectAttributesAttribute, |
— | — | @@ -976,7 +970,7 @@ |
977 | 971 | return $recordSet; |
978 | 972 | } |
979 | 973 | |
980 | | -function getTranslatedTextAttributeValuesRecordSet($objectIds, ViewInformation $viewInformation) { |
| 974 | +function getTranslatedTextAttributeValuesRecordSet(array $objectIds, ViewInformation $viewInformation) { |
981 | 975 | global |
982 | 976 | $translatedTextAttributeIdAttribute, $translatedContentAttributeValuesTable, $translatedTextAttributeAttribute, |
983 | 977 | $objectAttributesAttribute, $translatedTextAttributeObjectAttribute, $translatedTextValueAttribute, $translatedTextValueIdAttribute, |
— | — | @@ -1031,7 +1025,7 @@ |
1032 | 1026 | return $recordSet; |
1033 | 1027 | } |
1034 | 1028 | |
1035 | | -function getOptionAttributeValuesRecordSet($objectIds, ViewInformation $viewInformation) { |
| 1029 | +function getOptionAttributeValuesRecordSet(array $objectIds, ViewInformation $viewInformation) { |
1036 | 1030 | global |
1037 | 1031 | $optionAttributeIdAttribute, $optionAttributeObjectAttribute, $optionAttributeOptionIdAttribute, $optionAttributeAttribute,$optionAttributeOptionAttribute, $optionAttributeValuesTable, $objectAttributesAttribute, |
1038 | 1032 | $optionAttributeValuesStructure; |
— | — | @@ -1061,7 +1055,7 @@ |
1062 | 1056 | } |
1063 | 1057 | |
1064 | 1058 | /* XXX: This can probably be combined with other functions. In fact, it probably should be. Do it. */ |
1065 | | -function expandOptionsInRecordSet($recordSet, ViewInformation $viewInformation) { |
| 1059 | +function expandOptionsInRecordSet(RecordSet $recordSet, ViewInformation $viewInformation) { |
1066 | 1060 | global |
1067 | 1061 | $optionAttributeOptionIdAttribute, $optionAttributeIdAttribute, $optionAttributeAttribute, $optionAttributeOptionAttribute, $optionAttributeOptionsTable, $classAttributesTable; |
1068 | 1062 | |
Index: trunk/extensions/Wikidata/OmegaWiki/Transaction.php |
— | — | @@ -4,6 +4,7 @@ |
5 | 5 | require_once('Record.php'); |
6 | 6 | require_once('RecordSet.php'); |
7 | 7 | require_once('Wikidata.php'); |
| 8 | + |
8 | 9 | interface QueryTransactionInformation { |
9 | 10 | public function getRestriction($table); |
10 | 11 | public function getTables(); |
— | — | @@ -14,7 +15,7 @@ |
15 | 16 | public function setVersioningAttributes($record, $row); |
16 | 17 | } |
17 | 18 | |
18 | | -class DefaultQueryTransactionInformation { |
| 19 | +class DefaultQueryTransactionInformation implements QueryTransactionInformation { |
19 | 20 | public function getRestriction($table) { |
20 | 21 | return "1"; |
21 | 22 | } |
Index: trunk/extensions/Wikidata/OmegaWiki/RecordSetQueries.php |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 | return $query; |
34 | 34 | } |
35 | 35 | |
36 | | -function queryRecordSet($recordSetStructureId, $transactionInformation, $keyAttribute, $fieldAttributeMapping, Table $table, $restrictions, $orderBy = array(), $count = -1, $offset = 0) { |
| 36 | +function queryRecordSet($recordSetStructureId, QueryTransactionInformation $transactionInformation, Attribute $keyAttribute, $fieldAttributeMapping, Table $table, $restrictions, $orderBy = array(), $count = -1, $offset = 0) { |
37 | 37 | $dbr =& wfGetDB(DB_SLAVE); |
38 | 38 | |
39 | 39 | $selectFields = array_keys($fieldAttributeMapping); |
Index: trunk/extensions/Wikidata/OmegaWiki/Record.php |
— | — | @@ -5,8 +5,8 @@ |
6 | 6 | |
7 | 7 | interface Record { |
8 | 8 | public function getStructure(); |
9 | | - public function getAttributeValue($attribute); |
10 | | - public function project($structure); |
| 9 | + public function getAttributeValue(Attribute $attribute); |
| 10 | + public function project(Structure $structure); |
11 | 11 | } |
12 | 12 | |
13 | 13 | class ArrayRecord implements Record { |
— | — | @@ -23,18 +23,18 @@ |
24 | 24 | return $this->structure; |
25 | 25 | } |
26 | 26 | |
27 | | - public function getAttributeValue($attribute) { |
| 27 | + public function getAttributeValue(Attribute $attribute) { |
28 | 28 | #FIXME: check if valid |
29 | 29 | return @$this->values[$attribute->id]; |
30 | 30 | } |
31 | 31 | |
32 | 32 | |
33 | | - public function project($structure) { |
| 33 | + public function project(Structure $structure) { |
34 | 34 | $result = project($this, $structure); |
35 | 35 | return $result; |
36 | 36 | } |
37 | 37 | |
38 | | - public function setAttributeValue($attribute, $value) { |
| 38 | + public function setAttributeValue(Attribute $attribute, $value) { |
39 | 39 | #FIXME: check if valid |
40 | 40 | @$this->values[$attribute->id] = $value; |
41 | 41 | } |
— | — | @@ -55,7 +55,7 @@ |
56 | 56 | * @param $record Another record object whose values get written into this one |
57 | 57 | * |
58 | 58 | */ |
59 | | - public function setSubRecord($record) { |
| 59 | + public function setSubRecord(Record $record) { |
60 | 60 | foreach($record->getStructure()->getAttributes() as $attribute) |
61 | 61 | $this->values[$attribute->id] = $record->getAttributeValue($attribute); |
62 | 62 | } |
— | — | @@ -93,7 +93,7 @@ |
94 | 94 | |
95 | 95 | } |
96 | 96 | |
97 | | -function project($record, $structure) { |
| 97 | +function project(Record $record, Structure $structure) { |
98 | 98 | $result = new ArrayRecord($structure); |
99 | 99 | |
100 | 100 | foreach ($structure->getAttributes() as $attribute) { |
— | — | @@ -109,7 +109,7 @@ |
110 | 110 | return $result; |
111 | 111 | } |
112 | 112 | |
113 | | -function equalRecords($structure, $lhs, $rhs) { |
| 113 | +function equalRecords(Structure $structure, Record $lhs, Record $rhs) { |
114 | 114 | $result = true; |
115 | 115 | $attributes = $structure->getAttributes(); |
116 | 116 | $i = 0; |
— | — | @@ -134,7 +134,7 @@ |
135 | 135 | class RecordStack { |
136 | 136 | protected $stack = array(); |
137 | 137 | |
138 | | - public function push($record) { |
| 138 | + public function push(Record $record) { |
139 | 139 | $this->stack[] = $record; |
140 | 140 | } |
141 | 141 | |