Index: trunk/extensions/Wikidata/POLICY |
— | — | @@ -65,6 +65,10 @@ |
66 | 66 | Other than initial hook functions and command-line scripts, all |
67 | 67 | functions should exist in a class context. |
68 | 68 | |
| 69 | +== Function parameters == |
| 70 | + |
| 71 | +Add type hints and default values where appropriate. |
| 72 | + |
69 | 73 | == Variables == |
70 | 74 | |
71 | 75 | Variable names are generally written in CamelCase (lower case first |
Index: trunk/extensions/Wikidata/OmegaWiki/ViewInformation.php |
— | — | @@ -16,22 +16,20 @@ |
17 | 17 | public $possiblySynonymousRelationTypeId; |
18 | 18 | public $queryTransactionInformation; |
19 | 19 | public $showRecordLifeSpan; |
20 | | - public $showAuthority; |
21 | | - |
| 20 | + |
22 | 21 | public function __construct() { |
23 | 22 | $this->filterLanguageId = 0; |
24 | 23 | $this->possiblySynonymousRelationTypeId = 0; |
25 | 24 | $this->queryTransactionInformation; |
26 | 25 | $this->showRecordLifeSpan = false; |
27 | | - $this->showAuthority = false; |
28 | 26 | } |
29 | 27 | |
30 | 28 | public function hasMetaDataAttributes() { |
31 | | - return $this->showRecordLifeSpan || $this->showAuthority; |
| 29 | + return $this->showRecordLifeSpan; |
32 | 30 | } |
33 | 31 | |
34 | 32 | public function filterOnLanguage() { |
35 | | - return $this->filterOnLanguage != 0; |
| 33 | + return $this->filterLanguageId != 0; |
36 | 34 | } |
37 | 35 | } |
38 | 36 | |
Index: trunk/extensions/Wikidata/OmegaWiki/Transaction.php |
— | — | @@ -149,124 +149,7 @@ |
150 | 150 | // } |
151 | 151 | } |
152 | 152 | |
153 | | -class QueryAuthoritativeContributorTransactionInformation extends DefaultQueryTransactionInformation { |
154 | | - protected $availableAuthorities; |
155 | | - protected $authoritiesToShow; |
156 | | - protected $showCommunityContribution; |
157 | | - |
158 | | - public function __construct($availableAuthorities, $authoritiesToShow, $showCommunityContribution) { |
159 | | - $this->availableAuthorities = $availableAuthorities; |
160 | | - $this->authoritiesToShow = $authoritiesToShow; |
161 | | - $this->showCommunityContribution = $showCommunityContribution; |
162 | | - } |
163 | | - |
164 | | - protected function getKeyFieldRestrictions(Table $table, $prefix) { |
165 | | - $result = array(); |
166 | | - |
167 | | - foreach ($table->keyFields as $keyField) |
168 | | - $result[] = $table->identifier . "." . $keyField . "=" . $prefix . $table->identifier . "." . $keyField; |
169 | | - |
170 | | - return implode(" AND ", $result); |
171 | | - } |
172 | | - |
173 | | - public function getRestriction(Table $table) { |
174 | | - $dc=wdGetDataSetContext(); |
175 | | - $result = |
176 | | - $table->identifier . ".add_transaction_id={$dc}_transactions.transaction_id"; |
177 | 153 | |
178 | | - $showAnyAuthorities = count($this->authoritiesToShow) > 0; |
179 | | - |
180 | | - if ($this->showCommunityContribution || $showAnyAuthorities) { |
181 | | - $availableAuthorityIds = array_keys($this->availableAuthorities); |
182 | | - $availableAuthoritiesSet = "(" . implode(", ", $availableAuthorityIds) . ")"; |
183 | | - |
184 | | - $result = |
185 | | - $table->identifier . ".add_transaction_id={$dc}_transactions.transaction_id" . |
186 | | - " AND ("; |
187 | | - |
188 | | - if ($this->showCommunityContribution) |
189 | | - $result .= |
190 | | - "(" . |
191 | | - " {$dc}_transactions.user_id NOT IN " . $availableAuthoritiesSet . |
192 | | - " AND " .$table->identifier . ".add_transaction_id=(" . |
193 | | - " SELECT max(add_transaction_id) " . |
194 | | - " FROM " . $table->identifier . " AS latest_" . $table->identifier . ", {$dc}_transactions as latest_transactions" . |
195 | | - " WHERE " . $this->getKeyFieldRestrictions($table, 'latest_') . |
196 | | - " AND latest_transactions.transaction_id=latest_" . $table->identifier . ".add_transaction_id" . |
197 | | - " AND latest_transactions.user_id NOT IN (" . implode(", ", $availableAuthorityIds) . ")" . |
198 | | - ")" . |
199 | | - " AND NOT EXISTS (" . |
200 | | - " SELECT * " . |
201 | | - " FROM " . $table->identifier . " AS latest_" . $table->identifier . ", {$dc}_transactions as latest_transactions" . |
202 | | - " WHERE " . $this->getKeyFieldRestrictions($table, 'latest_') . |
203 | | - " AND latest_transactions.transaction_id=latest_" . $table->identifier . ".remove_transaction_id" . |
204 | | - " AND latest_transactions.user_id NOT IN " . $availableAuthoritiesSet . |
205 | | - " AND latest_" . $table->identifier . ".remove_transaction_id > " . $table->identifier . ".add_transaction_id" . |
206 | | - ")" . |
207 | | - " )"; |
208 | | - else |
209 | | - $result .= " 0 "; |
210 | | - |
211 | | - if ($showAnyAuthorities) |
212 | | - $result .= |
213 | | - " OR (" . |
214 | | - " {$dc}_transactions.user_id IN (" . implode(", ", $this->authoritiesToShow) . ") " . |
215 | | - " AND " .$table->identifier . ".add_transaction_id=(" . |
216 | | - " SELECT max(add_transaction_id) " . |
217 | | - " FROM " . $table->identifier . " AS latest_" . $table->identifier . ", {$dc}_transactions as latest_transactions" . |
218 | | - " WHERE " . $this->getKeyFieldRestrictions($table, 'latest_') . |
219 | | - " AND latest_transactions.transaction_id=latest_" . $table->identifier . ".add_transaction_id" . |
220 | | - " AND latest_transactions.user_id={$dc}_transactions.user_id" . |
221 | | - ")" . |
222 | | - " AND NOT EXISTS (" . |
223 | | - " SELECT * " . |
224 | | - " FROM " . $table->identifier . " AS latest_" . $table->identifier . ", {$dc}_transactions as latest_transactions" . |
225 | | - " WHERE " . $this->getKeyFieldRestrictions($table, 'latest_') . |
226 | | - " AND latest_transactions.transaction_id=latest_" . $table->identifier . ".remove_transaction_id" . |
227 | | - " AND latest_transactions.user_id={$dc}_transactions.user_id" . |
228 | | - " AND latest_" . $table->identifier . ".remove_transaction_id > " . $table->identifier . ".add_transaction_id" . |
229 | | - ")" . |
230 | | - " )"; |
231 | | - |
232 | | - $result .= " )"; |
233 | | - } |
234 | | - else |
235 | | - $result .= " AND 0"; |
236 | | - |
237 | | - return $result; |
238 | | - } |
239 | | - |
240 | | - public function getTables() { |
241 | | - $dc=wdGetDataSetContext(); |
242 | | - return array("{$dc}_transactions"); |
243 | | - } |
244 | | - |
245 | | - public function versioningAttributes() { |
246 | | - global |
247 | | - $authorityAttribute; |
248 | | - |
249 | | - return array($authorityAttribute); |
250 | | - } |
251 | | - |
252 | | - public function versioningFields($tableName) { |
253 | | - return array("{$dc}_transactions.user_id", $tableName . '.add_transaction_id'); |
254 | | - } |
255 | | - |
256 | | - public function setVersioningAttributes(Record $record, $row) { |
257 | | - global |
258 | | - $authorityAttribute; |
259 | | - |
260 | | - $userID = $row['user_id']; |
261 | | - |
262 | | - if (array_key_exists($userID, $this->availableAuthorities)) |
263 | | - $userName = $this->availableAuthorities[$userID]; //getUserName($userID); |
264 | | - else |
265 | | - $userName = "Community"; |
266 | | - |
267 | | - $record->setAttributeValue($authorityAttribute, $userName); |
268 | | - } |
269 | | -} |
270 | | - |
271 | 154 | global |
272 | 155 | $updateTransactionId; |
273 | 156 | |
— | — | @@ -339,12 +222,10 @@ |
340 | 223 | $transactionIdAttribute, $userAttribute, $userIPAttribute, $timestampAttribute, |
341 | 224 | $transactionStructure, $summaryAttribute, |
342 | 225 | $addTransactionAttribute, $removeTransactionAttribute, |
343 | | - $recordLifeSpanAttribute, $recordLifeSpanStructure, |
344 | | - $authorityAttribute, $wgAuthorityAttributeName; |
| 226 | + $recordLifeSpanAttribute, $recordLifeSpanStructure; |
345 | 227 | |
346 | 228 | $transactionIdAttribute = new Attribute('transaction-id', 'Transaction ID', 'integer'); |
347 | 229 | $userAttribute = new Attribute('user', 'User', 'user'); |
348 | | -$authorityAttribute = new Attribute('authority', $wgAuthorityAttributeName, 'authority'); |
349 | 230 | $userIPAttribute = new Attribute('user-ip', 'User IP', 'IP'); |
350 | 231 | $timestampAttribute = new Attribute('timestamp', 'Time', 'timestamp'); |
351 | 232 | $summaryAttribute = new Attribute('summary', 'Summary', 'text'); |
Index: trunk/extensions/Wikidata/OmegaWiki/Wikidata.php |
— | — | @@ -9,12 +9,9 @@ |
10 | 10 | protected $showRecordLifeSpan; |
11 | 11 | protected $transaction; |
12 | 12 | protected $queryTransactionInformation; |
13 | | - protected $shouldShowAuthorities; |
14 | 13 | protected $showCommunityContribution; |
15 | | - protected $authoritiesToShow; |
16 | 14 | |
17 | 15 | // The following member variables control some application specific preferences |
18 | | - protected $availableAuthorities = array(); // A map containing (userId => displayName) combination for authoritative contribution view |
19 | 16 | protected $filterLanguageId = 0; // Filter pages on this languageId, set to 0 to show all languages |
20 | 17 | protected $possiblySynonymousRelationTypeId = 0; // Put this relation type in a special section "Possibly synonymous" |
21 | 18 | protected $showLanguageSelector = true; // Show language selector at the top of each wiki data page |
— | — | @@ -27,12 +24,9 @@ |
28 | 25 | |
29 | 26 | public function __construct() { |
30 | 27 | global |
31 | | - $wgAvailableAuthorities, $wgFilterLanguageId, $wgShowLanguageSelector, |
| 28 | + $wgFilterLanguageId, $wgShowLanguageSelector, |
32 | 29 | $wgShowClassicPageTitles, $wgPossiblySynonymousRelationTypeId; |
33 | 30 | |
34 | | - if (isset($wgAvailableAuthorities)) |
35 | | - $this->availableAuthorities = $wgAvailableAuthorities; |
36 | | - |
37 | 31 | if (isset($wgFilterLanguageId)) |
38 | 32 | $this->filterLanguageId = $wgFilterLanguageId; |
39 | 33 | |
— | — | @@ -94,7 +88,6 @@ |
95 | 89 | $viewInformation->filterLanguageId = $this->filterLanguageId; |
96 | 90 | $viewInformation->possiblySynonymousRelationTypeId = $this->possiblySynonymousRelationTypeId; |
97 | 91 | $viewInformation->showRecordLifeSpan = false; |
98 | | - $viewInformation->showAuthority = $this->shouldShowAuthorities; |
99 | 92 | $viewInformation->queryTransactionInformation = $this->queryTransactionInformation; |
100 | 93 | |
101 | 94 | $this->viewInformation = $viewInformation; |
— | — | @@ -183,7 +176,6 @@ |
184 | 177 | $viewInformation->filterLanguageId = $this->filterLanguageId; |
185 | 178 | $viewInformation->possiblySynonymousRelationTypeId = $this->possiblySynonymousRelationTypeId; |
186 | 179 | $viewInformation->showRecordLifeSpan = false; |
187 | | - $viewInformation->showAuthority = false; |
188 | 180 | $viewInformation->queryTransactionInformation = new QueryLatestTransactionInformation(); |
189 | 181 | |
190 | 182 | $this->viewInformation = $viewInformation; |
— | — | @@ -240,7 +232,6 @@ |
241 | 233 | $viewInformation->filterLanguageId = $this->filterLanguageId; |
242 | 234 | $viewInformation->possiblySynonymousRelationTypeId = $this->possiblySynonymousRelationTypeId; |
243 | 235 | $viewInformation->showRecordLifeSpan = $this->showRecordLifeSpan; |
244 | | - $viewInformation->showAuthority = false; |
245 | 236 | $viewInformation->queryTransactionInformation = $this->queryTransactionInformation; |
246 | 237 | |
247 | 238 | $this->viewInformation = $viewInformation; |
Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataGlobals.php |
— | — | @@ -7,7 +7,6 @@ |
8 | 8 | $wgAlternativeDefinitionsAttributeName, |
9 | 9 | $wgAnnotationAttributeName, |
10 | 10 | $wgApproximateMeaningsAttributeName, |
11 | | - $wgAuthorityAttributeName, |
12 | 11 | $wgClassAttributeAttributeAttributeName, |
13 | 12 | $wgClassAttributesAttributeName, |
14 | 13 | $wgClassAttributeLevelAttributeName, |
— | — | @@ -56,7 +55,6 @@ |
57 | 56 | $wgAlternativeDefinitionsAttributeName = "Alternative definitions"; |
58 | 57 | $wgAnnotationAttributeName = "Annotation"; |
59 | 58 | $wgApproximateMeaningsAttributeName = "Approximate meanings"; |
60 | | -$wgAuthorityAttributeName = "Authority"; |
61 | 59 | $wgClassAttributeAttributeAttributeName = "Attribute"; |
62 | 60 | $wgClassAttributesAttributeName = "Class attributes"; |
63 | 61 | $wgClassAttributeLevelAttributeName = "Level"; |
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiEditors.php |
— | — | @@ -75,14 +75,6 @@ |
76 | 76 | $editor->addEditor(createTableLifeSpanEditor($recordLifeSpanAttribute)); |
77 | 77 | } |
78 | 78 | |
79 | | -function addTableAuthorityEditor(Editor $editor, $showAuthority) { |
80 | | - global |
81 | | - $authorityAttribute; |
82 | | - |
83 | | - if ($showAuthority) |
84 | | - $editor->addEditor(createShortTextViewer($authorityAttribute)); |
85 | | -} |
86 | | - |
87 | 79 | function addTableMetadataEditors($editor, ViewInformation $viewInformation) { |
88 | 80 | addTableLifeSpanEditor($editor, $viewInformation->showRecordLifeSpan); |
89 | 81 | } |
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes.php |
— | — | @@ -4,6 +4,27 @@ |
5 | 5 | require_once("WikiDataGlobals.php"); |
6 | 6 | require_once("ViewInformation.php"); |
7 | 7 | |
| 8 | +/** |
| 9 | + * |
| 10 | + * This file models the structure of the OmegaWiki database in a |
| 11 | + * database-independent fashion. To do so, it follows a simplified |
| 12 | + * relational model, consisting of Attribute objects which are hierarchically |
| 13 | + * grouped together using Structure objects. See Attribute.php for details. |
| 14 | + * |
| 15 | + * The actual data is stored in Records, grouped together as RecordSets. |
| 16 | + * See Record.php and RecordSet.php for details. |
| 17 | + * |
| 18 | + * TODO: |
| 19 | + * - The current model of a ton of hardcoded globals is highly inadequate |
| 20 | + * and should be replaced with a more abstract schema description. |
| 21 | + * - Attribute names are in WikidataGlobals.php, but should really be |
| 22 | + * localizable through MediaWiki's wfMsg() function. |
| 23 | + * - Records and RecordSets are currently capable of storing most (not all) |
| 24 | + * data, but can't actually commit them to the database again. To achieve |
| 25 | + * proper separation of architectural layers, the Records should learn |
| 26 | + * to talk directly with the DB layer. |
| 27 | + * |
| 28 | + */ |
8 | 29 | function initializeOmegaWikiAttributes(ViewInformation $viewInformation) { |
9 | 30 | global |
10 | 31 | $languageAttribute, $spellingAttribute, $textAttribute, |
— | — | @@ -281,6 +302,10 @@ |
282 | 303 | |
283 | 304 | global $wdDefinedMeaningAttributesOrder; |
284 | 305 | |
| 306 | + /** |
| 307 | + * This global determines the order of the different |
| 308 | + * attributes in the user interface. |
| 309 | + */ |
285 | 310 | $wdDefinedMeaningAttributesOrder=array( |
286 | 311 | $definitionAttribute->id, |
287 | 312 | $classAttributesAttribute->id, |