r22952 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22951‎ | r22952 | r22953 >
Date:13:53, 13 June 2007
Author:erik
Status:old
Tags:
Comment:
More cleanup, comments, basic raw data dump support for DMs
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/Controller.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/DefinedMeaning.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/OmegaWikiEditors.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/Record.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/RecordSet.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/Wikidata.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/Controller.php
@@ -18,7 +18,7 @@
1919 public function allowRemovalOfValue($idPath, $value);
2020 }
2121
22 -class SimplePermissionController {
 22+class SimplePermissionController implements PermissionController {
2323 protected $allowUpdate;
2424 protected $allowRemove;
2525
@@ -44,7 +44,6 @@
4545 public function add($keyPath, $record) {
4646 global
4747 $definedMeaningIdAttribute, $languageAttribute, $textAttribute;
48 -
4948 $definedMeaningId = $keyPath->peek(0)->getAttributeValue($definedMeaningIdAttribute);
5049 $languageId = $record->getAttributeValue($languageAttribute);
5150 $text = $record->getAttributeValue($textAttribute);
Index: trunk/extensions/Wikidata/OmegaWiki/RecordSet.php
@@ -48,6 +48,13 @@
4949 public function getRecord($index) {
5050 return $this->records[$index];
5151 }
 52+
 53+ /**
 54+ * @return carriage return separated list of values
 55+ */
 56+ public function __tostring() {
 57+ return implode("\n",$this->records);
 58+ }
5259 }
5360
5461 class ConvertingRecordSet implements RecordSet {
Index: trunk/extensions/Wikidata/OmegaWiki/Wikidata.php
@@ -95,9 +95,8 @@
9696 initializeOmegaWikiAttributes($this->filterLanguageId != 0);
9797 initializeObjectAttributeEditors($this->filterLanguageId, false);
9898 $this->viewQueryTransactionInformation = new QueryLatestTransactionInformation();
 99+ }
99100
100 -}
101 -
102101 protected function getDataSetPanel() {
103102 global $wgTitle, $wgUser;
104103 $dc=wdGetDataSetContext();
@@ -118,12 +117,11 @@
119118 $html.="</table>";
120119 $html.="</div>";
121120 return $html;
122 -
123121 }
124122
125123 protected function save($referenceTransaction) {
126124 initializeOmegaWikiAttributes($this->filterLanguageId != 0, false);
127 - initializeObjectAttributeEditors($this->filterLanguageId, false, false);
 125+ initializeObjectAttributeEditors($this->filterLanguageId, false);
128126 }
129127
130128 public function saveWithinTransaction() {
@@ -132,10 +130,16 @@
133131
134132 $summary = $wgRequest->getText('summary');
135133
 134+ // Insert transaction information into the DB
136135 startNewTransaction($wgUser->getID(), wfGetIP(), $summary);
 136+
 137+ // Perform regular save
137138 $this->save(new QueryAtTransactionInformation($wgRequest->getInt('transaction'), false));
138139
 140+ // Update page caches
139141 Title::touchArray(array($wgTitle));
 142+
 143+ // Add change to RC log
140144 $now = wfTimestampNow();
141145 RecentChange::notifyEdit($now, $wgTitle, false, $wgUser, $summary, 0, $now, false, '', 0, 0, 0);
142146 }
@@ -177,7 +181,7 @@
178182
179183 $wgOut->setPageTitle(wfMsg('ow_history',$title));
180184
181 -
 185+ # Plain filter for the lifespan info about each record
182186 if (isset($_GET['show'])) {
183187 $this->showRecordLifeSpan = isset($_GET["show-record-life-span"]);
184188 $this->transaction = (int) $_GET["transaction"];
@@ -187,6 +191,7 @@
188192 $this->transaction = 0;
189193 }
190194
 195+ # Up to which transaction to view the data
191196 if ($this->transaction == 0)
192197 $this->queryTransactionInformation = new QueryHistoryTransactionInformation();
193198 else
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiEditors.php
@@ -83,9 +83,8 @@
8484 $editor->addEditor(createShortTextViewer($authorityAttribute));
8585 }
8686
87 -function addTableMetadataEditors($editor, $showRecordLifeSpan, $showAuthority) {
 87+function addTableMetadataEditors($editor, $showRecordLifeSpan) {
8888 addTableLifeSpanEditor($editor, $showRecordLifeSpan);
89 - addTableAuthorityEditor($editor, $showAuthority);
9089 }
9190
9291 function getDefinitionEditor($filterLanguageId, $showRecordLifeSpan, $showAuthority) {
@@ -98,24 +97,24 @@
9998 $controller = new DefinedMeaningFilteredDefinitionController($filterLanguageId);
10099
101100 $editor = new RecordDivListEditor($definitionAttribute);
102 - $editor->addEditor(getTranslatedTextEditor($translatedTextAttribute, $controller, $filterLanguageId, $showRecordLifeSpan, $showAuthority));
 101+ $editor->addEditor(getTranslatedTextEditor($translatedTextAttribute, $controller, $filterLanguageId, $showRecordLifeSpan));
103102 $editor->addEditor(new PopUpEditor($definitionObjectAttributesEditor, $wgPopupAnnotationName));
104103
105 - return $editor;
 104+ return $editor;
106105 }
107106
108 -function getTranslatedTextEditor($attribute, $controller, $filterLanguageId, $showRecordLifeSpan, $showAuthority) {
 107+function getTranslatedTextEditor($attribute, $controller, $filterLanguageId, $showRecordLifeSpan) {
109108 global
110109 $languageAttribute, $textAttribute;
111110
112 - if ($filterLanguageId == 0 || $showRecordLifeSpan || $showAuthority) {
 111+ if ($filterLanguageId == 0 || $showRecordLifeSpan) {
113112 $editor = new RecordSetTableEditor($attribute, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, true, $controller);
114113
115114 if ($filterLanguageId == 0)
116115 $editor->addEditor(new LanguageEditor($languageAttribute, new SimplePermissionController(false), true));
117116
118117 $editor->addEditor(new TextEditor($textAttribute, new SimplePermissionController(true), true));
119 - addTableMetadataEditors($editor, $showRecordLifeSpan, $showAuthority);
 118+ addTableMetadataEditors($editor, $showRecordLifeSpan);
120119 }
121120 else
122121 $editor = new TextEditor($attribute, new SimplePermissionController(true), true, false, 0, $controller);
@@ -140,10 +139,10 @@
141140 $alternativeDefinitionController = new DefinedMeaningFilteredAlternativeDefinitionController($filterLanguageId);
142141
143142 $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));
145144 $editor->addEditor(new DefinedMeaningReferenceEditor($sourceAttribute, new SimplePermissionController(false), true));
146145
147 - addTableMetadataEditors($editor, $showRecordLifeSpan, $showAuthority);
 146+ addTableMetadataEditors($editor, $showRecordLifeSpan);
148147
149148 return $editor;
150149 }
@@ -173,7 +172,7 @@
174173 $tableEditor->addEditor(new ClassAttributesTypeEditor($classAttributeTypeAttribute, new SimplePermissionController(false), true));
175174 $tableEditor->addEditor(new PopupEditor(getOptionAttributeOptionsEditor(), 'Options'));
176175
177 - addTableMetadataEditors($tableEditor, $showRecordLifeSpan, $showAuthority);
 176+ addTableMetadataEditors($tableEditor, $showRecordLifeSpan);
178177
179178 return $tableEditor;
180179 }
@@ -188,7 +187,7 @@
189188 $tableEditor->addEditor(new BooleanEditor($identicalMeaningAttribute, new SimplePermissionController(true), true, true));
190189 $tableEditor->addEditor(new PopUpEditor($synonymsAndTranslationsObjectAttributesEditor, $wgPopupAnnotationName));
191190
192 - addTableMetadataEditors($tableEditor, $showRecordLifeSpan, $showAuthority);
 191+ addTableMetadataEditors($tableEditor, $showRecordLifeSpan);
193192
194193 return $tableEditor;
195194 }
@@ -203,7 +202,7 @@
204203 $editor->addEditor(new DefinedMeaningReferenceEditor($otherDefinedMeaningAttribute, new SimplePermissionController(false), true));
205204 $editor->addEditor(new PopUpEditor($relationsObjectAttributesEditor, $wgPopupAnnotationName));
206205
207 - addTableMetadataEditors($editor, $showRecordLifeSpan, $showAuthority);
 206+ addTableMetadataEditors($editor, $showRecordLifeSpan);
208207
209208 return $editor;
210209 }
@@ -218,7 +217,7 @@
219218 $editor->addEditor(new RelationTypeReferenceEditor($relationTypeAttribute, new SimplePermissionController(false), true));
220219 $editor->addEditor(new PopUpEditor($relationsObjectAttributesEditor, $wgPopupAnnotationName));
221220
222 - addTableMetadataEditors($editor, $showRecordLifeSpan, $showAuthority);
 221+ addTableMetadataEditors($editor, $showRecordLifeSpan);
223222
224223 return $editor;
225224 }
@@ -230,7 +229,7 @@
231230 $editor = new RecordSetTableEditor($classMembershipAttribute, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, false, new DefinedMeaningClassMembershipController());
232231 $editor->addEditor(new ClassReferenceEditor($classAttribute, new SimplePermissionController(false), true));
233232
234 - addTableMetadataEditors($editor, $showRecordLifeSpan, $showAuthority);
 233+ addTableMetadataEditors($editor, $showRecordLifeSpan);
235234
236235 return $editor;
237236 }
@@ -254,7 +253,7 @@
255254 if ($objectAttributesEditor != null)
256255 $editor->addEditor(new PopUpEditor($objectAttributesEditor, $wgPopupAnnotationName));
257256
258 - addTableMetadataEditors($editor, $showRecordLifeSpan, $showAuthority);
 257+ addTableMetadataEditors($editor, $showRecordLifeSpan);
259258
260259 return $editor;
261260 }
@@ -271,7 +270,7 @@
272271 if (count($wgGotoSourceTemplates) > 0)
273272 $editor->addEditor(new GotoSourceEditor($gotoSourceAttribute, new SimplePermissionController(true), true));
274273
275 - addTableMetadataEditors($editor, $showRecordLifeSpan, $showAuthority);
 274+ addTableMetadataEditors($editor, $showRecordLifeSpan);
276275
277276 return $editor;
278277 }
@@ -286,7 +285,7 @@
287286 $editor->addEditor(new TextEditor($textAttribute, new SimplePermissionController(true), true));
288287 $editor->addEditor(new PopUpEditor($textValueObjectAttributesEditor, $wgPopupAnnotationName));
289288
290 - addTableMetadataEditors($editor, $showRecordLifeSpan, $showAuthority);
 289+ addTableMetadataEditors($editor, $showRecordLifeSpan);
291290
292291 return $editor;
293292 }
@@ -301,7 +300,7 @@
302301 $editor->addEditor(new URLEditor($urlAttribute, new SimplePermissionController(true), true));
303302 $editor->addEditor(new PopUpEditor($urlValueObjectAttributesEditor, $wgPopupAnnotationName));
304303
305 - addTableMetadataEditors($editor, $showRecordLifeSpan, $showAuthority);
 304+ addTableMetadataEditors($editor, $showRecordLifeSpan);
306305
307306 return $editor;
308307 }
@@ -318,10 +317,10 @@
319318
320319 $editor = new RecordSetTableEditor($translatedTextAttributeValuesAttribute, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, false, $controller);
321320 $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));
323322 $editor->addEditor(new PopUpEditor($translatedTextValueObjectAttributesEditor, $wgPopupAnnotationName));
324323
325 - addTableMetadataEditors($editor, $showRecordLifeSpan, $showAuthority);
 324+ addTableMetadataEditors($editor, $showRecordLifeSpan);
326325
327326 return $editor;
328327 }
@@ -337,7 +336,7 @@
338337 $editor->addEditor(new OptionSelectEditor($optionAttributeOptionAttribute, new SimplePermissionController(false), true));
339338 $editor->addEditor(new PopUpEditor($optionValueObjectAttributesEditor, $wgPopupAnnotationName));
340339
341 - addTableMetadataEditors($editor, $showRecordLifeSpan, $showAuthority);
 340+ addTableMetadataEditors($editor, $showRecordLifeSpan);
342341
343342 return $editor;
344343 }
Index: trunk/extensions/Wikidata/OmegaWiki/Record.php
@@ -54,6 +54,13 @@
5555 foreach($record->getStructure()->attributes as $attribute)
5656 $this->values[$attribute->id] = $record->getAttributeValue($attribute);
5757 }
 58+
 59+ /**
 60+ * @return comma-separated values
 61+ */
 62+ public function __tostring() {
 63+ return implode(",",$this->values);
 64+ }
5865 }
5966
6067 function project($record, $structure) {
Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaning.php
@@ -14,6 +14,7 @@
1515
1616 $this->outputViewHeader();
1717
 18+ // Obtain ID from title of the form "DefinedMeaning:Foo (1234)" for database lookup
1819 $definedMeaningId = $this->getDefinedMeaningIdFromTitle($wgTitle->getText());
1920
2021 $wgOut->addHTML($this->getConceptPanel());
@@ -79,6 +80,19 @@
8081 $wgOut->addHTML("<script language='javascript'><!--\nexpandEditors();\n--></script>");
8182 }
8283
 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+
8397 protected function save($referenceTransaction) {
8498 global
8599 $wgTitle;

Status & tagging log