Index: trunk/extensions/Wikidata/OmegaWiki/Controller.php |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | public function allowRemovalOfValue($idPath, $value); |
20 | 20 | } |
21 | 21 | |
22 | | -class SimplePermissionController { |
| 22 | +class SimplePermissionController implements PermissionController { |
23 | 23 | protected $allowUpdate; |
24 | 24 | protected $allowRemove; |
25 | 25 | |
— | — | @@ -44,7 +44,6 @@ |
45 | 45 | public function add($keyPath, $record) { |
46 | 46 | global |
47 | 47 | $definedMeaningIdAttribute, $languageAttribute, $textAttribute; |
48 | | - |
49 | 48 | $definedMeaningId = $keyPath->peek(0)->getAttributeValue($definedMeaningIdAttribute); |
50 | 49 | $languageId = $record->getAttributeValue($languageAttribute); |
51 | 50 | $text = $record->getAttributeValue($textAttribute); |
Index: trunk/extensions/Wikidata/OmegaWiki/RecordSet.php |
— | — | @@ -48,6 +48,13 @@ |
49 | 49 | public function getRecord($index) { |
50 | 50 | return $this->records[$index]; |
51 | 51 | } |
| 52 | + |
| 53 | + /** |
| 54 | + * @return carriage return separated list of values |
| 55 | + */ |
| 56 | + public function __tostring() { |
| 57 | + return implode("\n",$this->records); |
| 58 | + } |
52 | 59 | } |
53 | 60 | |
54 | 61 | class ConvertingRecordSet implements RecordSet { |
Index: trunk/extensions/Wikidata/OmegaWiki/Wikidata.php |
— | — | @@ -95,9 +95,8 @@ |
96 | 96 | initializeOmegaWikiAttributes($this->filterLanguageId != 0); |
97 | 97 | initializeObjectAttributeEditors($this->filterLanguageId, false); |
98 | 98 | $this->viewQueryTransactionInformation = new QueryLatestTransactionInformation(); |
| 99 | + } |
99 | 100 | |
100 | | -} |
101 | | - |
102 | 101 | protected function getDataSetPanel() { |
103 | 102 | global $wgTitle, $wgUser; |
104 | 103 | $dc=wdGetDataSetContext(); |
— | — | @@ -118,12 +117,11 @@ |
119 | 118 | $html.="</table>"; |
120 | 119 | $html.="</div>"; |
121 | 120 | return $html; |
122 | | - |
123 | 121 | } |
124 | 122 | |
125 | 123 | protected function save($referenceTransaction) { |
126 | 124 | initializeOmegaWikiAttributes($this->filterLanguageId != 0, false); |
127 | | - initializeObjectAttributeEditors($this->filterLanguageId, false, false); |
| 125 | + initializeObjectAttributeEditors($this->filterLanguageId, false); |
128 | 126 | } |
129 | 127 | |
130 | 128 | public function saveWithinTransaction() { |
— | — | @@ -132,10 +130,16 @@ |
133 | 131 | |
134 | 132 | $summary = $wgRequest->getText('summary'); |
135 | 133 | |
| 134 | + // Insert transaction information into the DB |
136 | 135 | startNewTransaction($wgUser->getID(), wfGetIP(), $summary); |
| 136 | + |
| 137 | + // Perform regular save |
137 | 138 | $this->save(new QueryAtTransactionInformation($wgRequest->getInt('transaction'), false)); |
138 | 139 | |
| 140 | + // Update page caches |
139 | 141 | Title::touchArray(array($wgTitle)); |
| 142 | + |
| 143 | + // Add change to RC log |
140 | 144 | $now = wfTimestampNow(); |
141 | 145 | RecentChange::notifyEdit($now, $wgTitle, false, $wgUser, $summary, 0, $now, false, '', 0, 0, 0); |
142 | 146 | } |
— | — | @@ -177,7 +181,7 @@ |
178 | 182 | |
179 | 183 | $wgOut->setPageTitle(wfMsg('ow_history',$title)); |
180 | 184 | |
181 | | - |
| 185 | + # Plain filter for the lifespan info about each record |
182 | 186 | if (isset($_GET['show'])) { |
183 | 187 | $this->showRecordLifeSpan = isset($_GET["show-record-life-span"]); |
184 | 188 | $this->transaction = (int) $_GET["transaction"]; |
— | — | @@ -187,6 +191,7 @@ |
188 | 192 | $this->transaction = 0; |
189 | 193 | } |
190 | 194 | |
| 195 | + # Up to which transaction to view the data |
191 | 196 | if ($this->transaction == 0) |
192 | 197 | $this->queryTransactionInformation = new QueryHistoryTransactionInformation(); |
193 | 198 | else |
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiEditors.php |
— | — | @@ -83,9 +83,8 @@ |
84 | 84 | $editor->addEditor(createShortTextViewer($authorityAttribute)); |
85 | 85 | } |
86 | 86 | |
87 | | -function addTableMetadataEditors($editor, $showRecordLifeSpan, $showAuthority) { |
| 87 | +function addTableMetadataEditors($editor, $showRecordLifeSpan) { |
88 | 88 | addTableLifeSpanEditor($editor, $showRecordLifeSpan); |
89 | | - addTableAuthorityEditor($editor, $showAuthority); |
90 | 89 | } |
91 | 90 | |
92 | 91 | function getDefinitionEditor($filterLanguageId, $showRecordLifeSpan, $showAuthority) { |
— | — | @@ -98,24 +97,24 @@ |
99 | 98 | $controller = new DefinedMeaningFilteredDefinitionController($filterLanguageId); |
100 | 99 | |
101 | 100 | $editor = new RecordDivListEditor($definitionAttribute); |
102 | | - $editor->addEditor(getTranslatedTextEditor($translatedTextAttribute, $controller, $filterLanguageId, $showRecordLifeSpan, $showAuthority)); |
| 101 | + $editor->addEditor(getTranslatedTextEditor($translatedTextAttribute, $controller, $filterLanguageId, $showRecordLifeSpan)); |
103 | 102 | $editor->addEditor(new PopUpEditor($definitionObjectAttributesEditor, $wgPopupAnnotationName)); |
104 | 103 | |
105 | | - return $editor; |
| 104 | + return $editor; |
106 | 105 | } |
107 | 106 | |
108 | | -function getTranslatedTextEditor($attribute, $controller, $filterLanguageId, $showRecordLifeSpan, $showAuthority) { |
| 107 | +function getTranslatedTextEditor($attribute, $controller, $filterLanguageId, $showRecordLifeSpan) { |
109 | 108 | global |
110 | 109 | $languageAttribute, $textAttribute; |
111 | 110 | |
112 | | - if ($filterLanguageId == 0 || $showRecordLifeSpan || $showAuthority) { |
| 111 | + if ($filterLanguageId == 0 || $showRecordLifeSpan) { |
113 | 112 | $editor = new RecordSetTableEditor($attribute, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, true, $controller); |
114 | 113 | |
115 | 114 | if ($filterLanguageId == 0) |
116 | 115 | $editor->addEditor(new LanguageEditor($languageAttribute, new SimplePermissionController(false), true)); |
117 | 116 | |
118 | 117 | $editor->addEditor(new TextEditor($textAttribute, new SimplePermissionController(true), true)); |
119 | | - addTableMetadataEditors($editor, $showRecordLifeSpan, $showAuthority); |
| 118 | + addTableMetadataEditors($editor, $showRecordLifeSpan); |
120 | 119 | } |
121 | 120 | else |
122 | 121 | $editor = new TextEditor($attribute, new SimplePermissionController(true), true, false, 0, $controller); |
— | — | @@ -140,10 +139,10 @@ |
141 | 140 | $alternativeDefinitionController = new DefinedMeaningFilteredAlternativeDefinitionController($filterLanguageId); |
142 | 141 | |
143 | 142 | $editor = new RecordSetTableEditor($alternativeDefinitionsAttribute, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, false, new DefinedMeaningAlternativeDefinitionsController($filterLanguageId)); |
144 | | - $editor->addEditor(getTranslatedTextEditor($alternativeDefinitionAttribute, $alternativeDefinitionController, $filterLanguageId, $showRecordLifeSpan, $showAuthority)); |
| 143 | + $editor->addEditor(getTranslatedTextEditor($alternativeDefinitionAttribute, $alternativeDefinitionController, $filterLanguageId, $showRecordLifeSpan)); |
145 | 144 | $editor->addEditor(new DefinedMeaningReferenceEditor($sourceAttribute, new SimplePermissionController(false), true)); |
146 | 145 | |
147 | | - addTableMetadataEditors($editor, $showRecordLifeSpan, $showAuthority); |
| 146 | + addTableMetadataEditors($editor, $showRecordLifeSpan); |
148 | 147 | |
149 | 148 | return $editor; |
150 | 149 | } |
— | — | @@ -173,7 +172,7 @@ |
174 | 173 | $tableEditor->addEditor(new ClassAttributesTypeEditor($classAttributeTypeAttribute, new SimplePermissionController(false), true)); |
175 | 174 | $tableEditor->addEditor(new PopupEditor(getOptionAttributeOptionsEditor(), 'Options')); |
176 | 175 | |
177 | | - addTableMetadataEditors($tableEditor, $showRecordLifeSpan, $showAuthority); |
| 176 | + addTableMetadataEditors($tableEditor, $showRecordLifeSpan); |
178 | 177 | |
179 | 178 | return $tableEditor; |
180 | 179 | } |
— | — | @@ -188,7 +187,7 @@ |
189 | 188 | $tableEditor->addEditor(new BooleanEditor($identicalMeaningAttribute, new SimplePermissionController(true), true, true)); |
190 | 189 | $tableEditor->addEditor(new PopUpEditor($synonymsAndTranslationsObjectAttributesEditor, $wgPopupAnnotationName)); |
191 | 190 | |
192 | | - addTableMetadataEditors($tableEditor, $showRecordLifeSpan, $showAuthority); |
| 191 | + addTableMetadataEditors($tableEditor, $showRecordLifeSpan); |
193 | 192 | |
194 | 193 | return $tableEditor; |
195 | 194 | } |
— | — | @@ -203,7 +202,7 @@ |
204 | 203 | $editor->addEditor(new DefinedMeaningReferenceEditor($otherDefinedMeaningAttribute, new SimplePermissionController(false), true)); |
205 | 204 | $editor->addEditor(new PopUpEditor($relationsObjectAttributesEditor, $wgPopupAnnotationName)); |
206 | 205 | |
207 | | - addTableMetadataEditors($editor, $showRecordLifeSpan, $showAuthority); |
| 206 | + addTableMetadataEditors($editor, $showRecordLifeSpan); |
208 | 207 | |
209 | 208 | return $editor; |
210 | 209 | } |
— | — | @@ -218,7 +217,7 @@ |
219 | 218 | $editor->addEditor(new RelationTypeReferenceEditor($relationTypeAttribute, new SimplePermissionController(false), true)); |
220 | 219 | $editor->addEditor(new PopUpEditor($relationsObjectAttributesEditor, $wgPopupAnnotationName)); |
221 | 220 | |
222 | | - addTableMetadataEditors($editor, $showRecordLifeSpan, $showAuthority); |
| 221 | + addTableMetadataEditors($editor, $showRecordLifeSpan); |
223 | 222 | |
224 | 223 | return $editor; |
225 | 224 | } |
— | — | @@ -230,7 +229,7 @@ |
231 | 230 | $editor = new RecordSetTableEditor($classMembershipAttribute, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, false, new DefinedMeaningClassMembershipController()); |
232 | 231 | $editor->addEditor(new ClassReferenceEditor($classAttribute, new SimplePermissionController(false), true)); |
233 | 232 | |
234 | | - addTableMetadataEditors($editor, $showRecordLifeSpan, $showAuthority); |
| 233 | + addTableMetadataEditors($editor, $showRecordLifeSpan); |
235 | 234 | |
236 | 235 | return $editor; |
237 | 236 | } |
— | — | @@ -254,7 +253,7 @@ |
255 | 254 | if ($objectAttributesEditor != null) |
256 | 255 | $editor->addEditor(new PopUpEditor($objectAttributesEditor, $wgPopupAnnotationName)); |
257 | 256 | |
258 | | - addTableMetadataEditors($editor, $showRecordLifeSpan, $showAuthority); |
| 257 | + addTableMetadataEditors($editor, $showRecordLifeSpan); |
259 | 258 | |
260 | 259 | return $editor; |
261 | 260 | } |
— | — | @@ -271,7 +270,7 @@ |
272 | 271 | if (count($wgGotoSourceTemplates) > 0) |
273 | 272 | $editor->addEditor(new GotoSourceEditor($gotoSourceAttribute, new SimplePermissionController(true), true)); |
274 | 273 | |
275 | | - addTableMetadataEditors($editor, $showRecordLifeSpan, $showAuthority); |
| 274 | + addTableMetadataEditors($editor, $showRecordLifeSpan); |
276 | 275 | |
277 | 276 | return $editor; |
278 | 277 | } |
— | — | @@ -286,7 +285,7 @@ |
287 | 286 | $editor->addEditor(new TextEditor($textAttribute, new SimplePermissionController(true), true)); |
288 | 287 | $editor->addEditor(new PopUpEditor($textValueObjectAttributesEditor, $wgPopupAnnotationName)); |
289 | 288 | |
290 | | - addTableMetadataEditors($editor, $showRecordLifeSpan, $showAuthority); |
| 289 | + addTableMetadataEditors($editor, $showRecordLifeSpan); |
291 | 290 | |
292 | 291 | return $editor; |
293 | 292 | } |
— | — | @@ -301,7 +300,7 @@ |
302 | 301 | $editor->addEditor(new URLEditor($urlAttribute, new SimplePermissionController(true), true)); |
303 | 302 | $editor->addEditor(new PopUpEditor($urlValueObjectAttributesEditor, $wgPopupAnnotationName)); |
304 | 303 | |
305 | | - addTableMetadataEditors($editor, $showRecordLifeSpan, $showAuthority); |
| 304 | + addTableMetadataEditors($editor, $showRecordLifeSpan); |
306 | 305 | |
307 | 306 | return $editor; |
308 | 307 | } |
— | — | @@ -318,10 +317,10 @@ |
319 | 318 | |
320 | 319 | $editor = new RecordSetTableEditor($translatedTextAttributeValuesAttribute, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, false, $controller); |
321 | 320 | $editor->addEditor(new TranslatedTextAttributeEditor($translatedTextAttributeAttribute, new SimplePermissionController(false), true, $levelDefinedMeaningName, $objectIdFetcher)); |
322 | | - $editor->addEditor(getTranslatedTextEditor($translatedTextValueAttribute, $translatedTextAttributeValueController, $filterLanguageId, $showRecordLifeSpan, $showAuthority)); |
| 321 | + $editor->addEditor(getTranslatedTextEditor($translatedTextValueAttribute, $translatedTextAttributeValueController, $filterLanguageId, $showRecordLifeSpan)); |
323 | 322 | $editor->addEditor(new PopUpEditor($translatedTextValueObjectAttributesEditor, $wgPopupAnnotationName)); |
324 | 323 | |
325 | | - addTableMetadataEditors($editor, $showRecordLifeSpan, $showAuthority); |
| 324 | + addTableMetadataEditors($editor, $showRecordLifeSpan); |
326 | 325 | |
327 | 326 | return $editor; |
328 | 327 | } |
— | — | @@ -337,7 +336,7 @@ |
338 | 337 | $editor->addEditor(new OptionSelectEditor($optionAttributeOptionAttribute, new SimplePermissionController(false), true)); |
339 | 338 | $editor->addEditor(new PopUpEditor($optionValueObjectAttributesEditor, $wgPopupAnnotationName)); |
340 | 339 | |
341 | | - addTableMetadataEditors($editor, $showRecordLifeSpan, $showAuthority); |
| 340 | + addTableMetadataEditors($editor, $showRecordLifeSpan); |
342 | 341 | |
343 | 342 | return $editor; |
344 | 343 | } |
Index: trunk/extensions/Wikidata/OmegaWiki/Record.php |
— | — | @@ -54,6 +54,13 @@ |
55 | 55 | foreach($record->getStructure()->attributes as $attribute) |
56 | 56 | $this->values[$attribute->id] = $record->getAttributeValue($attribute); |
57 | 57 | } |
| 58 | + |
| 59 | + /** |
| 60 | + * @return comma-separated values |
| 61 | + */ |
| 62 | + public function __tostring() { |
| 63 | + return implode(",",$this->values); |
| 64 | + } |
58 | 65 | } |
59 | 66 | |
60 | 67 | function project($record, $structure) { |
Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaning.php |
— | — | @@ -14,6 +14,7 @@ |
15 | 15 | |
16 | 16 | $this->outputViewHeader(); |
17 | 17 | |
| 18 | + // Obtain ID from title of the form "DefinedMeaning:Foo (1234)" for database lookup |
18 | 19 | $definedMeaningId = $this->getDefinedMeaningIdFromTitle($wgTitle->getText()); |
19 | 20 | |
20 | 21 | $wgOut->addHTML($this->getConceptPanel()); |
— | — | @@ -79,6 +80,19 @@ |
80 | 81 | $wgOut->addHTML("<script language='javascript'><!--\nexpandEditors();\n--></script>"); |
81 | 82 | } |
82 | 83 | |
| 84 | + /** |
| 85 | + @return Basic CSV data dump |
| 86 | + */ |
| 87 | + public function raw() { |
| 88 | + $record=getDefinedMeaningRecord( |
| 89 | + $definedMeaningId, |
| 90 | + $this->filterLanguageId, |
| 91 | + $this->possiblySynonymousRelationTypeId, |
| 92 | + $this->viewQueryTransactionInformation |
| 93 | + ); |
| 94 | + return $recurd; |
| 95 | + } |
| 96 | + |
83 | 97 | protected function save($referenceTransaction) { |
84 | 98 | global |
85 | 99 | $wgTitle; |