r18223 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r18222‎ | r18223 | r18224 >
Date:10:55, 8 December 2006
Author:proes
Status:old
Tags:
Comment:
Implemented authoritative version view.
Modified paths:
  • /trunk/extensions/Wikidata/WiktionaryZ/DefinedMeaning.php (modified) (history)
  • /trunk/extensions/Wikidata/WiktionaryZ/Transaction.php (modified) (history)
  • /trunk/extensions/Wikidata/WiktionaryZ/WikiDataTables.php (modified) (history)
  • /trunk/extensions/Wikidata/WiktionaryZ/Wikidata.php (modified) (history)
  • /trunk/extensions/Wikidata/WiktionaryZ/WiktionaryZ.php (modified) (history)
  • /trunk/extensions/Wikidata/WiktionaryZ/WiktionaryZEditors.php (modified) (history)
  • /trunk/extensions/Wikidata/WiktionaryZ/WiktionaryZRecordSets.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/WiktionaryZ/WiktionaryZ.php
@@ -25,7 +25,7 @@
2626 parent::view();
2727
2828 $spelling = $wgTitle->getText();
29 - $wgOut->addHTML(getExpressionsEditor($spelling, false)->view(new IdStack("expression"), getExpressionsRecordSet($spelling, new QueryLatestTransactionInformation())));
 29+ $wgOut->addHTML(getExpressionsEditor($spelling, false, $this->shouldShowAuthorities)->view(new IdStack("expression"), getExpressionsRecordSet($spelling, $this->viewQueryTransactionInformation)));
3030 $wgOut->addHTML(DefaultEditor::getExpansionCss());
3131 $wgOut->addHTML("<script language='javascript'><!--\nexpandEditors();\n--></script>");
3232
@@ -40,7 +40,7 @@
4141 parent::history();
4242
4343 $spelling = $wgTitle->getText();
44 - $wgOut->addHTML(getExpressionsEditor($spelling, $this->showRecordLifeSpan)->view(new IdStack("expression"), getExpressionsRecordSet($spelling, $this->queryTransactionInformation)));
 44+ $wgOut->addHTML(getExpressionsEditor($spelling, $this->showRecordLifeSpan, false)->view(new IdStack("expression"), getExpressionsRecordSet($spelling, $this->queryTransactionInformation)));
4545 $wgOut->addHTML(DefaultEditor::getExpansionCss());
4646 $wgOut->addHTML("<script language='javascript'><!--\nexpandEditors();\n--></script>");
4747
@@ -54,7 +54,7 @@
5555 $wgTitle;
5656
5757 $spelling = $wgTitle->getText();
58 - getExpressionsEditor($spelling, false)->save(new IdStack("expression"), getExpressionsRecordSet($spelling, $referenceTransaction));
 58+ getExpressionsEditor($spelling, false, false)->save(new IdStack("expression"), getExpressionsRecordSet($spelling, $referenceTransaction));
5959 }
6060
6161 public function edit() {
@@ -66,7 +66,7 @@
6767 $spelling = $wgTitle->getText();
6868
6969 $this->outputEditHeader();
70 - $wgOut->addHTML(getExpressionsEditor($spelling, false)->edit(new IdStack("expression"), getExpressionsRecordSet($spelling, new QueryLatestTransactionInformation())));
 70+ $wgOut->addHTML(getExpressionsEditor($spelling, false, false)->edit(new IdStack("expression"), getExpressionsRecordSet($spelling, new QueryLatestTransactionInformation())));
7171 $this->outputEditFooter();
7272 }
7373 }
Index: trunk/extensions/Wikidata/WiktionaryZ/DefinedMeaning.php
@@ -13,7 +13,7 @@
1414
1515 // $definedMeaningId = $wgTitle->getText();
1616 $definedMeaningId = $this->getDefinedMeaningIdFromTitle($wgTitle->getText());
17 - $wgOut->addHTML(getDefinedMeaningEditor(false)->view($this->getIdStack($definedMeaningId), getDefinedMeaningRecord($definedMeaningId, new QueryLatestTransactionInformation())));
 17+ $wgOut->addHTML(getDefinedMeaningEditor(false, $this->shouldShowAuthorities)->view($this->getIdStack($definedMeaningId), getDefinedMeaningRecord($definedMeaningId, $this->viewQueryTransactionInformation)));
1818 $wgOut->addHTML(DefaultEditor::getExpansionCss());
1919 $wgOut->addHTML("<script language='javascript'><!--\nexpandEditors();\n--></script>");
2020 }
@@ -28,7 +28,7 @@
2929 $definedMeaningId = $this->getDefinedMeaningIdFromTitle($wgTitle->getText());
3030
3131 $this->outputEditHeader();
32 - $wgOut->addHTML(getDefinedMeaningEditor(false)->edit($this->getIdStack($definedMeaningId), getDefinedMeaningRecord($definedMeaningId, new QueryLatestTransactionInformation())));
 32+ $wgOut->addHTML(getDefinedMeaningEditor(false, false)->edit($this->getIdStack($definedMeaningId), getDefinedMeaningRecord($definedMeaningId, new QueryLatestTransactionInformation())));
3333 $this->outputEditFooter();
3434 }
3535
@@ -40,7 +40,7 @@
4141
4242 // $definedMeaningId = $wgTitle->getText();
4343 $definedMeaningId = $this->getDefinedMeaningIdFromTitle($wgTitle->getText());
44 - $wgOut->addHTML(getDefinedMeaningEditor($this->showRecordLifeSpan)->view(
 44+ $wgOut->addHTML(getDefinedMeaningEditor($this->showRecordLifeSpan, false)->view(
4545 new IdStack("defined-meaning"),
4646 getDefinedMeaningRecord($definedMeaningId, $this->queryTransactionInformation))
4747 );
@@ -59,7 +59,7 @@
6060
6161 // $definedMeaningId = $wgTitle->getText();
6262 $definedMeaningId = $this->getDefinedMeaningIdFromTitle($wgTitle->getText());
63 - getDefinedMeaningEditor(false)->save($this->getIdStack($definedMeaningId), getDefinedMeaningRecord($definedMeaningId, $referenceTransaction));
 63+ getDefinedMeaningEditor(false, false)->save($this->getIdStack($definedMeaningId), getDefinedMeaningRecord($definedMeaningId, $referenceTransaction));
6464 }
6565
6666 protected function getIdStack($definedMeaningId) {
Index: trunk/extensions/Wikidata/WiktionaryZ/Wikidata.php
@@ -13,6 +13,10 @@
1414 protected $showRecordLifeSpan;
1515 protected $transaction;
1616 protected $queryTransactionInformation;
 17+ protected $viewQueryTransactionInformation;
 18+ protected $shouldShowAuthorities;
 19+
 20+ protected $availableAuthorities = array();
1721
1822 public function __construct() {
1923 global
@@ -44,6 +48,30 @@
4549
4650 $wgOut->enableClientCache(false);
4751 $wgOut->addHTML($this->getLanguageSelector());
 52+
 53+ $authorities = array();
 54+
 55+ if (count($this->availableAuthorities) > 0) {
 56+ $authorityOptions = array();
 57+
 58+ foreach($this->availableAuthorities as $authority) {
 59+ $showAuthority = isset($_GET['authority-' . $authority]);
 60+
 61+ if ($showAuthority)
 62+ $authorities[] = $authority;
 63+
 64+ $authorityOptions["Show " . getUserName($authority) . " version"] = getCheckBox('authority-' . $authority, $showAuthority);
 65+ }
 66+
 67+ $wgOut->addHTML(getOptionPanel($authorityOptions));
 68+ }
 69+
 70+ $this->shouldShowAuthorities = count($authorities) > 0;
 71+
 72+ if ($this->shouldShowAuthorities)
 73+ $this->viewQueryTransactionInformation = new QueryAuthoritativeTransactionInformation($authorities);
 74+ else
 75+ $this->viewQueryTransactionInformation = new QueryLatestTransactionInformation();
4876 }
4977
5078 protected function save($referenceTransaction) {
Index: trunk/extensions/Wikidata/WiktionaryZ/WiktionaryZEditors.php
@@ -5,8 +5,8 @@
66 require_once('WikiDataBootstrappedMeanings.php');
77 require_once('Fetcher.php');
88
9 -initializeObjectAttributeEditors(true);
10 -function initializeObjectAttributeEditors($showRecordLifeSpan) {
 9+initializeObjectAttributeEditors(true, true);
 10+function initializeObjectAttributeEditors($showRecordLifeSpan, $showAuthority) {
1111 global
1212 $objectAttributesAttribute,
1313 $definedMeaningObjectAttributesEditor, $definedMeaningIdAttribute,
@@ -26,12 +26,12 @@
2727 $textValueObjectAttributesEditor = new RecordUnorderedListEditor($objectAttributesAttribute, 5);
2828 $translatedTextValueObjectAttributesEditor = new RecordUnorderedListEditor($objectAttributesAttribute, 5);
2929
30 - setObjectAttributesEditor($definedMeaningObjectAttributesEditor, $showRecordLifeSpan, new ObjectIdFetcher(0, $definedMeaningIdAttribute), $definedMeaningMeaningName, new ObjectIdFetcher(0, $definedMeaningIdAttribute));
31 - setObjectAttributesEditor($definitionObjectAttributesEditor, $showRecordLifeSpan, new DefinitionObjectIdFetcher(0, $definedMeaningIdAttribute), $definitionMeaningName, new ObjectIdFetcher(0, $definedMeaningIdAttribute));
32 - setObjectAttributesEditor($synonymsAndTranslationsObjectAttributesEditor, $showRecordLifeSpan, new ObjectIdFetcher(0, $syntransIdAttribute), $synTransMeaningName, new ObjectIdFetcher(1, $definedMeaningIdAttribute));
33 - setObjectAttributesEditor($relationsObjectAttributesEditor, $showRecordLifeSpan, new ObjectIdFetcher(0, $relationIdAttribute), $relationMeaningName, new ObjectIdFetcher(1, $definedMeaningIdAttribute));
34 - setObjectAttributesEditor($textValueObjectAttributesEditor, $showRecordLifeSpan, new ObjectIdFetcher(0, $textAttributeIdAttribute), $annotationMeaningName, new ObjectIdFetcher(1, $definedMeaningIdAttribute));
35 - setObjectAttributesEditor($translatedTextValueObjectAttributesEditor, $showRecordLifeSpan, new ObjectIdFetcher(0, $translatedTextAttributeIdAttribute), $annotationMeaningName, new ObjectIdFetcher(1, $definedMeaningIdAttribute));
 30+ setObjectAttributesEditor($definedMeaningObjectAttributesEditor, $showRecordLifeSpan, $showAuthority, new ObjectIdFetcher(0, $definedMeaningIdAttribute), $definedMeaningMeaningName, new ObjectIdFetcher(0, $definedMeaningIdAttribute));
 31+ setObjectAttributesEditor($definitionObjectAttributesEditor, $showRecordLifeSpan, $showAuthority, new DefinitionObjectIdFetcher(0, $definedMeaningIdAttribute), $definitionMeaningName, new ObjectIdFetcher(0, $definedMeaningIdAttribute));
 32+ setObjectAttributesEditor($synonymsAndTranslationsObjectAttributesEditor, $showRecordLifeSpan, $showAuthority, new ObjectIdFetcher(0, $syntransIdAttribute), $synTransMeaningName, new ObjectIdFetcher(1, $definedMeaningIdAttribute));
 33+ setObjectAttributesEditor($relationsObjectAttributesEditor, $showRecordLifeSpan, $showAuthority, new ObjectIdFetcher(0, $relationIdAttribute), $relationMeaningName, new ObjectIdFetcher(1, $definedMeaningIdAttribute));
 34+ setObjectAttributesEditor($textValueObjectAttributesEditor, $showRecordLifeSpan, $showAuthority, new ObjectIdFetcher(0, $textAttributeIdAttribute), $annotationMeaningName, new ObjectIdFetcher(1, $definedMeaningIdAttribute));
 35+ setObjectAttributesEditor($translatedTextValueObjectAttributesEditor, $showRecordLifeSpan, $showAuthority, new ObjectIdFetcher(0, $translatedTextAttributeIdAttribute), $annotationMeaningName, new ObjectIdFetcher(1, $definedMeaningIdAttribute));
3636 }
3737
3838 function getTransactionEditor($attribute) {
@@ -39,7 +39,7 @@
4040 $userAttribute, $timestampAttribute;
4141
4242 $transactionEditor = new RecordTableCellEditor($attribute);
43 - $transactionEditor->addEditor(new UserEditor($userAttribute, new SimplePermissionController(false), true));
 43+ $transactionEditor->addEditor(createUserViewer($userAttribute));
4444 $transactionEditor->addEditor(new TimestampEditor($timestampAttribute, new SimplePermissionController(false), true));
4545
4646 return $transactionEditor;
@@ -64,18 +64,31 @@
6565 $editor->addEditor(createTableLifeSpanEditor($recordLifeSpanAttribute));
6666 }
6767
68 -function getDefinitionEditor($attribute, $controller, $showRecordLifeSpan) {
 68+function addTableAuthorityEditor($editor, $showAuthority) {
6969 global
 70+ $authorityAttribute;
 71+
 72+ if ($showAuthority)
 73+ $editor->addEditor(createUserViewer($authorityAttribute));
 74+}
 75+
 76+function addTableMedataEditors($editor, $showRecordLifeSpan, $showAuthority) {
 77+ addTableLifeSpanEditor($editor, $showRecordLifeSpan);
 78+ addTableAuthorityEditor($editor, $showAuthority);
 79+}
 80+
 81+function getDefinitionEditor($attribute, $controller, $showRecordLifeSpan, $showAuthority) {
 82+ global
7083 $translatedTextAttribute, $definitionObjectAttributesEditor;
7184
7285 $editor = new RecordDivListEditor($attribute);
73 - $editor->addEditor(getTranslatedTextEditor($translatedTextAttribute, new DefinedMeaningDefinitionController(), $showRecordLifeSpan));
 86+ $editor->addEditor(getTranslatedTextEditor($translatedTextAttribute, new DefinedMeaningDefinitionController(), $showRecordLifeSpan, $showAuthority));
7487 $editor->addEditor(new PopUpEditor($definitionObjectAttributesEditor, 'Annotation'));
7588
7689 return $editor;
7790 }
7891
79 -function getTranslatedTextEditor($attribute, $controller, $showRecordLifeSpan) {
 92+function getTranslatedTextEditor($attribute, $controller, $showRecordLifeSpan, $showAuthority) {
8093 global
8194 $languageAttribute, $textAttribute;
8295
@@ -83,26 +96,26 @@
8497 $editor->addEditor(new LanguageEditor($languageAttribute, new SimplePermissionController(false), true));
8598 $editor->addEditor(new TextEditor($textAttribute, new SimplePermissionController(true), true));
8699
87 - addTableLifeSpanEditor($editor, $showRecordLifeSpan);
 100+ addTableMedataEditors($editor, $showRecordLifeSpan, $showAuthority);
88101
89102 return $editor;
90103 }
91104
92 -function setObjectAttributesEditor($objectAttributesEditor, $showRecordLifeSpan, $objectIdFetcher, $levelDefinedMeaningName, $dmObjectIdFetcher) {
93 - $objectAttributesEditor->addEditor(getTextAttributeValuesEditor($showRecordLifeSpan, new TextAttributeValuesController($objectIdFetcher), $levelDefinedMeaningName, $dmObjectIdFetcher));
94 - $objectAttributesEditor->addEditor(getTranslatedTextAttributeValuesEditor($showRecordLifeSpan, new TranslatedTextAttributeValuesController($objectIdFetcher), $levelDefinedMeaningName, $dmObjectIdFetcher));
 105+function setObjectAttributesEditor($objectAttributesEditor, $showRecordLifeSpan, $showAuthority, $objectIdFetcher, $levelDefinedMeaningName, $dmObjectIdFetcher) {
 106+ $objectAttributesEditor->addEditor(getTextAttributeValuesEditor($showRecordLifeSpan, $showAuthority, new TextAttributeValuesController($objectIdFetcher), $levelDefinedMeaningName, $dmObjectIdFetcher));
 107+ $objectAttributesEditor->addEditor(getTranslatedTextAttributeValuesEditor($showRecordLifeSpan, $showAuthority, new TranslatedTextAttributeValuesController($objectIdFetcher), $levelDefinedMeaningName, $dmObjectIdFetcher));
95108 }
96109
97 -function getAlternativeDefinitionsEditor($showRecordLifeSpan) {
 110+function getAlternativeDefinitionsEditor($showRecordLifeSpan, $showAuthority) {
98111 global
99112 $alternativeDefinitionsAttribute, $alternativeDefinitionAttribute, $sourceAttribute;
100113
101114 $editor = new RecordSetTableEditor($alternativeDefinitionsAttribute, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, false, new DefinedMeaningAlternativeDefinitionsController());
102115 // $editor = new RecordSetTableEditor($alternativeDefinitionsAttribute, new AlternativeDefinitionsPermissionController(), new ShowEditFieldChecker(true), new AllowAddController(true), true, false, new DefinedMeaningAlternativeDefinitionsController());
103 - $editor->addEditor(getTranslatedTextEditor($alternativeDefinitionAttribute, new DefinedMeaningAlternativeDefinitionController(), $showRecordLifeSpan));
 116+ $editor->addEditor(getTranslatedTextEditor($alternativeDefinitionAttribute, new DefinedMeaningAlternativeDefinitionController(), $showRecordLifeSpan, $showAuthority));
104117 $editor->addEditor(new DefinedMeaningReferenceEditor($sourceAttribute, new SimplePermissionController(false), true));
105118
106 - addTableLifeSpanEditor($editor, $showRecordLifeSpan);
 119+ addTableMedataEditors($editor, $showRecordLifeSpan, $showAuthority);
107120
108121 return $editor;
109122 }
@@ -118,18 +131,20 @@
119132 return $editor;
120133 }
121134
122 -function getClassAttributesEditor($showRecordLifeSpan) {
 135+function getClassAttributesEditor($showRecordLifeSpan, $showAuthority) {
123136 global
124137 $definedMeaningIdAttribute, $classAttributesAttribute, $classAttributeLevelAttribute ,$classAttributeAttributeAttribute;
125138
126139 $tableEditor = new RecordSetTableEditor($classAttributesAttribute, new SimplePermissionController(true), new ShowEditFieldForClassesChecker(0, $definedMeaningIdAttribute), new AllowAddController(true), true, false, new ClassAttributesController());
127140 $tableEditor->addEditor(new ClassAttributesLevelDefinedMeaningEditor($classAttributeLevelAttribute, new SimplePermissionController(false), true));
128141 $tableEditor->addEditor(new DefinedMeaningReferenceEditor($classAttributeAttributeAttribute, new SimplePermissionController(false), true));
129 - addTableLifeSpanEditor($tableEditor, $showRecordLifeSpan);
 142+
 143+ addTableMedataEditors($tableEditor, $showRecordLifeSpan, $showAuthority);
 144+
130145 return $tableEditor;
131146 }
132147
133 -function getSynonymsAndTranslationsEditor($showRecordLifeSpan) {
 148+function getSynonymsAndTranslationsEditor($showRecordLifeSpan, $showAuthority) {
134149 global
135150 $synonymsAndTranslationsAttribute, $identicalMeaningAttribute, $expressionIdAttribute,
136151 $expressionAttribute, $synonymsAndTranslationsObjectAttributesEditor;
@@ -139,12 +154,12 @@
140155 $tableEditor->addEditor(new BooleanEditor($identicalMeaningAttribute, new SimplePermissionController(true), true, true));
141156 $tableEditor->addEditor(new PopUpEditor($synonymsAndTranslationsObjectAttributesEditor, 'Annotation'));
142157
143 - addTableLifeSpanEditor($tableEditor, $showRecordLifeSpan);
 158+ addTableMedataEditors($tableEditor, $showRecordLifeSpan, $showAuthority);
144159
145160 return $tableEditor;
146161 }
147162
148 -function getDefinedMeaningRelationsEditor($showRecordLifeSpan) {
 163+function getDefinedMeaningRelationsEditor($showRecordLifeSpan, $showAuthority) {
149164 global
150165 $relationsAttribute, $relationTypeAttribute, $otherDefinedMeaningAttribute,
151166 $relationsObjectAttributesEditor;
@@ -154,12 +169,12 @@
155170 $editor->addEditor(new DefinedMeaningReferenceEditor($otherDefinedMeaningAttribute, new SimplePermissionController(false), true));
156171 $editor->addEditor(new PopUpEditor($relationsObjectAttributesEditor, 'Annotation'));
157172
158 - addTableLifeSpanEditor($editor, $showRecordLifeSpan);
 173+ addTableMedataEditors($editor, $showRecordLifeSpan, $showAuthority);
159174
160175 return $editor;
161176 }
162177
163 -function getDefinedMeaningReciprocalRelationsEditor($showRecordLifeSpan) {
 178+function getDefinedMeaningReciprocalRelationsEditor($showRecordLifeSpan, $showAuthority) {
164179 global
165180 $reciprocalRelationsAttribute, $relationTypeAttribute, $otherDefinedMeaningAttribute,
166181 $relationsObjectAttributesEditor;
@@ -169,24 +184,24 @@
170185 $editor->addEditor(new RelationTypeReferenceEditor($relationTypeAttribute, new SimplePermissionController(false), true));
171186 $editor->addEditor(new PopUpEditor($relationsObjectAttributesEditor, 'Annotation'));
172187
173 - addTableLifeSpanEditor($editor, $showRecordLifeSpan);
 188+ addTableMedataEditors($editor, $showRecordLifeSpan, $showAuthority);
174189
175190 return $editor;
176191 }
177192
178 -function getDefinedMeaningClassMembershipEditor($showRecordLifeSpan) {
 193+function getDefinedMeaningClassMembershipEditor($showRecordLifeSpan, $showAuthority) {
179194 global
180195 $classMembershipAttribute, $classAttribute;
181196
182197 $editor = new RecordSetTableEditor($classMembershipAttribute, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, false, new DefinedMeaningClassMembershipController());
183198 $editor->addEditor(new ClassReferenceEditor($classAttribute, new SimplePermissionController(false), true));
184199
185 - addTableLifeSpanEditor($editor, $showRecordLifeSpan);
 200+ addTableMedataEditors($editor, $showRecordLifeSpan, $showAuthority);
186201
187202 return $editor;
188203 }
189204
190 -function getDefinedMeaningCollectionMembershipEditor($showRecordLifeSpan) {
 205+function getDefinedMeaningCollectionMembershipEditor($showRecordLifeSpan, $showAuthority) {
191206 global
192207 $collectionMembershipAttribute, $collectionMeaningAttribute, $sourceIdentifierAttribute;
193208
@@ -194,12 +209,12 @@
195210 $editor->addEditor(new CollectionReferenceEditor($collectionMeaningAttribute, new SimplePermissionController(false), true));
196211 $editor->addEditor(new ShortTextEditor($sourceIdentifierAttribute, new SimplePermissionController(true), true));
197212
198 - addTableLifeSpanEditor($editor, $showRecordLifeSpan);
 213+ addTableMedataEditors($editor, $showRecordLifeSpan, $showAuthority);
199214
200215 return $editor;
201216 }
202217
203 -function getTextAttributeValuesEditor($showRecordLifeSpan, $controller, $levelDefinedMeaningName, $objectIdFetcher) {
 218+function getTextAttributeValuesEditor($showRecordLifeSpan, $showAuthority, $controller, $levelDefinedMeaningName, $objectIdFetcher) {
204219 global
205220 $textAttributeAttribute, $textAttribute, $textAttributeValuesAttribute, $textValueObjectAttributesEditor;
206221
@@ -208,30 +223,30 @@
209224 $editor->addEditor(new TextEditor($textAttribute, new SimplePermissionController(true), true));
210225 $editor->addEditor(new PopUpEditor($textValueObjectAttributesEditor, 'Annotation'));
211226
212 - addTableLifeSpanEditor($editor, $showRecordLifeSpan);
 227+ addTableMedataEditors($editor, $showRecordLifeSpan, $showAuthority);
213228
214229 return $editor;
215230 }
216231
217 -function getTranslatedTextAttributeValuesEditor($showRecordLifeSpan, $controller, $levelDefinedMeaningName, $objectIdFetcher) {
 232+function getTranslatedTextAttributeValuesEditor($showRecordLifeSpan, $showAuthority, $controller, $levelDefinedMeaningName, $objectIdFetcher) {
218233 global
219234 $translatedTextAttributeAttribute, $translatedTextValueAttribute, $translatedTextAttributeValuesAttribute, $translatedTextValueObjectAttributesEditor;
220235
221236 $editor = new RecordSetTableEditor($translatedTextAttributeValuesAttribute, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, false, $controller);
222237 $editor->addEditor(new TranslatedTextAttributeEditor($translatedTextAttributeAttribute, new SimplePermissionController(false), true, $levelDefinedMeaningName, $objectIdFetcher));
223 - $editor->addEditor(getTranslatedTextEditor($translatedTextValueAttribute, new TranslatedTextAttributeValueController(), $showRecordLifeSpan));
 238+ $editor->addEditor(getTranslatedTextEditor($translatedTextValueAttribute, new TranslatedTextAttributeValueController(), $showRecordLifeSpan, $showAuthority));
224239 $editor->addEditor(new PopUpEditor($translatedTextValueObjectAttributesEditor, 'Annotation'));
225240
226 - addTableLifeSpanEditor($editor, $showRecordLifeSpan);
 241+ addTableMedataEditors($editor, $showRecordLifeSpan, $showAuthority);
227242
228243 return $editor;
229244 }
230245
231 -function getExpressionMeaningsEditor($attribute, $allowAdd, $showRecordLifeSpan) {
 246+function getExpressionMeaningsEditor($attribute, $allowAdd, $showRecordLifeSpan, $showAuthority) {
232247 global
233248 $definedMeaningIdAttribute;
234249
235 - $definedMeaningEditor = getDefinedMeaningEditor($showRecordLifeSpan);
 250+ $definedMeaningEditor = getDefinedMeaningEditor($showRecordLifeSpan, $showAuthority);
236251
237252 $definedMeaningCaptionEditor = new DefinedMeaningHeaderEditor($definedMeaningIdAttribute, new SimplePermissionController(false), true, 75);
238253 $definedMeaningCaptionEditor->setAddText("New exact meaning");
@@ -243,15 +258,15 @@
244259 return $expressionMeaningsEditor;
245260 }
246261
247 -function getExpressionsEditor($spelling, $showRecordLifeSpan) {
 262+function getExpressionsEditor($spelling, $showRecordLifeSpan, $showAuthority) {
248263 global
249264 $expressionMeaningsAttribute, $expressionExactMeaningsAttribute, $expressionApproximateMeaningsAttribute, $expressionAttribute, $languageAttribute, $expressionsAttribute;
250265
251266 $expressionMeaningsRecordEditor = new RecordUnorderedListEditor($expressionMeaningsAttribute, 3);
252267
253 - $exactMeaningsEditor = getExpressionMeaningsEditor($expressionExactMeaningsAttribute, true, $showRecordLifeSpan);
 268+ $exactMeaningsEditor = getExpressionMeaningsEditor($expressionExactMeaningsAttribute, true, $showRecordLifeSpan, $showAuthority);
254269 $expressionMeaningsRecordEditor->addEditor($exactMeaningsEditor);
255 - $expressionMeaningsRecordEditor->addEditor(getExpressionMeaningsEditor($expressionApproximateMeaningsAttribute, false, $showRecordLifeSpan));
 270+ $expressionMeaningsRecordEditor->addEditor(getExpressionMeaningsEditor($expressionApproximateMeaningsAttribute, false, $showRecordLifeSpan, $showAuthority));
256271
257272 $expressionMeaningsRecordEditor->expandEditor($exactMeaningsEditor);
258273
@@ -265,22 +280,22 @@
266281 return $expressionsEditor;
267282 }
268283
269 -function getDefinedMeaningEditor($showRecordLifeSpan) {
 284+function getDefinedMeaningEditor($showRecordLifeSpan, $showAuthority) {
270285 global
271286 $definitionAttribute, $definedMeaningAttribute, $definedMeaningObjectAttributesEditor;
272287
273 - $definitionEditor = getDefinitionEditor($definitionAttribute, new DefinedMeaningDefinitionController(), $showRecordLifeSpan);
274 - $classAttributesEditor = getClassAttributesEditor($showRecordLifeSpan);
275 - $synonymsAndTranslationsEditor = getSynonymsAndTranslationsEditor($showRecordLifeSpan);
276 - $relationsEditor = getDefinedMeaningRelationsEditor($showRecordLifeSpan);
277 - $reciprocalRelationsEditor = getDefinedMeaningReciprocalRelationsEditor($showRecordLifeSpan);
278 - $classMembershipEditor = getDefinedMeaningClassMembershipEditor($showRecordLifeSpan);
279 - $collectionMembershipEditor = getDefinedMeaningCollectionMembershipEditor($showRecordLifeSpan);
 288+ $definitionEditor = getDefinitionEditor($definitionAttribute, new DefinedMeaningDefinitionController(), $showRecordLifeSpan, $showAuthority);
 289+ $classAttributesEditor = getClassAttributesEditor($showRecordLifeSpan, $showAuthority);
 290+ $synonymsAndTranslationsEditor = getSynonymsAndTranslationsEditor($showRecordLifeSpan, $showAuthority);
 291+ $relationsEditor = getDefinedMeaningRelationsEditor($showRecordLifeSpan, $showAuthority);
 292+ $reciprocalRelationsEditor = getDefinedMeaningReciprocalRelationsEditor($showRecordLifeSpan, $showAuthority);
 293+ $classMembershipEditor = getDefinedMeaningClassMembershipEditor($showRecordLifeSpan, $showAuthority);
 294+ $collectionMembershipEditor = getDefinedMeaningCollectionMembershipEditor($showRecordLifeSpan, $showAuthority);
280295
281296 $definedMeaningEditor = new RecordUnorderedListEditor($definedMeaningAttribute, 4);
282297 $definedMeaningEditor->addEditor($definitionEditor);
283298 $definedMeaningEditor->addEditor($classAttributesEditor);
284 - $definedMeaningEditor->addEditor(getAlternativeDefinitionsEditor($showRecordLifeSpan));
 299+ $definedMeaningEditor->addEditor(getAlternativeDefinitionsEditor($showRecordLifeSpan, $showAuthority));
285300 $definedMeaningEditor->addEditor($synonymsAndTranslationsEditor);
286301 $definedMeaningEditor->addEditor($relationsEditor);
287302 $definedMeaningEditor->addEditor($reciprocalRelationsEditor);
@@ -339,4 +354,8 @@
340355 return $result;
341356 }
342357
 358+function createUserViewer($attribute) {
 359+ return new UserEditor($attribute, new SimplePermissionController(false), false);
 360+}
 361+
343362 ?>
Index: trunk/extensions/Wikidata/WiktionaryZ/Transaction.php
@@ -5,18 +5,24 @@
66 require_once('RecordSet.php');
77
88 interface QueryTransactionInformation {
9 - public function getRestriction($tableName);
 9+ public function getRestriction($table);
 10+ public function getTables();
1011 public function versioningAttributes();
1112 public function versioningFields($tableName);
1213 public function versioningOrderBy();
 14+ public function versioningGroupBy($table);
1315 public function setVersioningAttributes($record, $row);
1416 }
1517
16 -class QueryLatestTransactionInformation implements QueryTransactionInformation {
17 - public function getRestriction($tableName) {
18 - return getLatestTransactionRestriction($tableName);
 18+class DefaultQueryTransactionInformation {
 19+ public function getRestriction($table) {
 20+ return "1";
1921 }
2022
 23+ public function getTables() {
 24+ return array();
 25+ }
 26+
2127 public function versioningAttributes() {
2228 return array();
2329 }
@@ -29,15 +35,24 @@
3036 return array();
3137 }
3238
 39+ public function versioningGroupBy($table) {
 40+ return array();
 41+ }
 42+
3343 public function setVersioningAttributes($record, $row) {
3444 }
3545 }
3646
37 -class QueryHistoryTransactionInformation implements QueryTransactionInformation {
38 - public function getRestriction($tableName) {
39 - return "1";
 47+class QueryLatestTransactionInformation extends DefaultQueryTransactionInformation {
 48+ public function getRestriction($table) {
 49+ return getLatestTransactionRestriction($table->name);
4050 }
4151
 52+ public function setVersioningAttributes($record, $row) {
 53+ }
 54+}
 55+
 56+class QueryHistoryTransactionInformation extends DefaultQueryTransactionInformation {
4257 public function versioningAttributes() {
4358 global
4459 $recordLifeSpanAttribute;
@@ -61,15 +76,15 @@
6277 }
6378 }
6479
65 -class QueryAtTransactionInformation implements QueryTransactionInformation {
 80+class QueryAtTransactionInformation extends DefaultQueryTransactionInformation {
6681 protected $transactionId;
6782
6883 public function __construct($transactionId) {
6984 $this->transactionId = $transactionId;
7085 }
7186
72 - public function getRestriction($tableName) {
73 - return getAtTransactionRestriction($tableName, $this->transactionId);
 87+ public function getRestriction($table) {
 88+ return getAtTransactionRestriction($table->name, $this->transactionId);
7489 }
7590
7691 public function versioningAttributes() {
@@ -83,10 +98,6 @@
8499 return array($tableName . '.add_transaction_id', $tableName . '.remove_transaction_id', $tableName . '.remove_transaction_id IS NULL AS is_live');
85100 }
86101
87 - public function versioningOrderBy() {
88 - return array();
89 - }
90 -
91102 public function setVersioningAttributes($record, $row) {
92103 global
93104 $recordLifeSpanAttribute;
@@ -95,39 +106,108 @@
96107 }
97108 }
98109
99 -class QueryUpdateTransactionInformation implements QueryTransactionInformation {
 110+class QueryUpdateTransactionInformation extends DefaultQueryTransactionInformation {
100111 protected $transactionId;
101112
102113 public function __construct($transactionId) {
103114 $this->transactionId = $transactionId;
104115 }
105116
106 - public function getRestriction($tableName) {
107 - return " $tableName.add_transaction_id = $this->transactionId OR $tableName.removeTransactionId = $this->transactionId ";
 117+ public function getRestriction($table) {
 118+ return
 119+ " " . $table->name . ".add_transaction_id =". $this->transactionId .
 120+ " OR " . $table->name . ".removeTransactionId =" . $this->transactionId;
108121 }
109122
110 - public function versioningAttributes() {
 123+// public function versioningAttributes() {
111124 // global
112125 // $recordLifeSpanAttribute;
113 -
114 - return array();
115 - }
 126+//
 127+// return array();
 128+// }
116129
117 - public function versioningFields($tableName) {
 130+// public function versioningFields($tableName) {
118131 // return array($tableName . '.add_transaction_id', $tableName . '.remove_transaction_id', $tableName . '.remove_transaction_id IS NULL AS is_live');
119 - return array();
120 - }
 132+// }
121133
122 - public function versioningOrderBy() {
123 - return array();
124 - }
125 -
126 - public function setVersioningAttributes($record, $row) {
 134+// public function setVersioningAttributes($record, $row) {
127135 // global
128136 // $recordLifeSpanAttribute;
129137 //
130138 // $record->setAttributeValue($recordLifeSpanAttribute, getRecordLifeSpanTuple($row['add_transaction_id'], $row['remove_transaction_id']));
 139+// }
 140+}
 141+
 142+class QueryAuthoritativeTransactionInformation extends DefaultQueryTransactionInformation {
 143+ protected $authorities;
 144+
 145+ public function __construct($authorities) {
 146+ $this->authorities = $authorities;
131147 }
 148+
 149+ protected function getKeyFieldRestrictions($table, $prefix) {
 150+ $result = array();
 151+
 152+ foreach ($table->keyFields as $keyField)
 153+ $result[] = $table->name . "." . $keyField . "=" . $prefix . $table->name . "." . $keyField;
 154+
 155+ return implode(" AND ", $result);
 156+ }
 157+
 158+ public function getRestriction($table) {
 159+ return
 160+ $table->name . ".add_transaction_id=transactions.transaction_id" .
 161+ " AND (" .
 162+ getLatestTransactionRestriction($table->name) .
 163+ " OR (" .
 164+ " transactions.user_id IN (" . implode(", ", $this->authorities) . ") " .
 165+ " AND " .$table->name . ".add_transaction_id=(" .
 166+ " SELECT max(add_transaction_id) " .
 167+ " FROM " . $table->name . " AS latest_" . $table->name . ", transactions as latest_transactions" .
 168+ " WHERE " . $this->getKeyFieldRestrictions($table, 'latest_') .
 169+ " AND latest_transactions.transaction_id=latest_" . $table->name . ".add_transaction_id" .
 170+ " AND latest_transactions.user_id=transactions.user_id" .
 171+ ")" .
 172+ " AND NOT EXISTS (" .
 173+ " SELECT * " .
 174+ " FROM " . $table->name . " AS latest_" . $table->name . ", transactions as latest_transactions" .
 175+ " WHERE " . $this->getKeyFieldRestrictions($table, 'latest_') .
 176+ " AND latest_transactions.transaction_id=latest_" . $table->name . ".remove_transaction_id" .
 177+ " AND latest_transactions.user_id=transactions.user_id" .
 178+ " AND latest_" . $table->name . ".remove_transaction_id > " . $table->name . ".add_transaction_id" .
 179+ ")" .
 180+ " )" .
 181+ " )";
 182+ }
 183+
 184+ public function getTables() {
 185+ return array("transactions");
 186+ }
 187+
 188+ public function versioningAttributes() {
 189+ global
 190+ $authorityAttribute;
 191+
 192+ return array($authorityAttribute);
 193+ }
 194+
 195+ public function versioningFields($tableName) {
 196+ return array('transactions.user_id', $tableName . '.add_transaction_id');
 197+ }
 198+
 199+ public function setVersioningAttributes($record, $row) {
 200+ global
 201+ $authorityAttribute;
 202+
 203+ $userID = $row['user_id'];
 204+
 205+ if (in_array($userID, $this->authorities))
 206+ $userName = getUserName($userID);
 207+ else
 208+ $userName = "";
 209+
 210+ $record->setAttributeValue($authorityAttribute, $userName);
 211+ }
132212 }
133213
134214 global
@@ -196,10 +276,12 @@
197277 $transactionIdAttribute, $userAttribute, $userIPAttribute, $timestampAttribute,
198278 $transactionStructure, $summaryAttribute,
199279 $addTransactionAttribute, $removeTransactionAttribute,
200 - $recordLifeSpanAttribute, $recordLifeSpanStructure;
 280+ $recordLifeSpanAttribute, $recordLifeSpanStructure,
 281+ $authorityAttribute;
201282
202283 $transactionIdAttribute = new Attribute('transaction-id', 'Transaction ID', 'integer');
203284 $userAttribute = new Attribute('user', 'User', 'user');
 285+$authorityAttribute = new Attribute('authority', 'Authority', 'authority');
204286 $userIPAttribute = new Attribute('user-ip', 'User IP', 'IP');
205287 $timestampAttribute = new Attribute('timestamp', 'Time', 'timestamp');
206288 $summaryAttribute = new Attribute('summary', 'Summary', 'text');
Index: trunk/extensions/Wikidata/WiktionaryZ/WiktionaryZRecordSets.php
@@ -12,22 +12,30 @@
1313
1414 $selectFields = array_keys($fieldAttributeMapping);
1515 $attributes = array_values($fieldAttributeMapping);
 16+ $tableNames = array($table->name);
1617
1718 if ($table->isVersioned) {
18 - $restrictions[] = $transactionInformation->getRestriction($table->name);
 19+ $restrictions[] = $transactionInformation->getRestriction($table);
 20+ $tableNames = array_merge($tableNames, $transactionInformation->getTables());
1921 $orderBy = array_merge($orderBy, $transactionInformation->versioningOrderBy());
 22+ $groupBy = $transactionInformation->versioningGroupBy($table);
2023 $selectFields = array_merge($selectFields, $transactionInformation->versioningFields($table->name));
2124 $allAttributes = array_merge($attributes, $transactionInformation->versioningAttributes());
2225 }
23 - else
 26+ else {
2427 $allAttributes = $attributes;
 28+ $groupBy = array();
 29+ }
2530
2631 $query = "SELECT ". implode(", ", $selectFields) .
27 - " FROM ". $table->name;
 32+ " FROM ". implode(", ", $tableNames);
2833
2934 if (count($restrictions) > 0)
3035 $query .= " WHERE ". implode(' AND ', $restrictions);
3136
 37+ if (count($groupBy) > 0)
 38+ $query .= " GROUP BY " . implode(', ', $groupBy);
 39+
3240 if (count($orderBy) > 0)
3341 $query .= " ORDER BY " . implode(', ', $orderBy);
3442
Index: trunk/extensions/Wikidata/WiktionaryZ/WikiDataTables.php
@@ -3,10 +3,12 @@
44 class Table {
55 public $name;
66 public $isVersioned;
 7+ public $keyFields;
78
8 - public function __construct($name, $isVersioned) {
 9+ public function __construct($name, $isVersioned, $keyFields) {
910 $this->name = $name;
1011 $this->isVersioned = $isVersioned;
 12+ $this->keyFields = $keyFields;
1113 }
1214 }
1315
@@ -15,17 +17,17 @@
1618 $translatedContentTable, $alternativeDefinitionsTable, $translatedContentAttributeValuesTable, $transactionsTable,
1719 $textAttributeValuesTable, $classAttributesTable;
1820
19 -$transactionsTable = new Table('transactions', false);
20 -$meaningRelationsTable = new Table('uw_meaning_relations', true);
21 -$classMembershipsTable = new Table('uw_class_membership', true);
22 -$collectionMembershipsTable = new Table('uw_collection_contents', true);
23 -$syntransTable = new Table('uw_syntrans', true);
24 -$translatedContentTable = new Table('translated_content', true);
25 -$alternativeDefinitionsTable = new Table('uw_alt_meaningtexts', true);
26 -$classAttributesTable = new Table('uw_class_attributes', true);
 21+$transactionsTable = new Table('transactions', false, array('transaction_id'));
 22+$meaningRelationsTable = new Table('uw_meaning_relations', true, array('relation_id'));
 23+$classMembershipsTable = new Table('uw_class_membership', true, array('class_membership_id'));
 24+$collectionMembershipsTable = new Table('uw_collection_contents', true, array('collection_id', 'member_mid'));
 25+$syntransTable = new Table('uw_syntrans', true, array('syntrans_sid'));
 26+$translatedContentTable = new Table('translated_content', true, array('translated_content_id', 'language_id'));
 27+$alternativeDefinitionsTable = new Table('uw_alt_meaningtexts', true, array('meaning_mid', 'meaning_text_tcid'));
 28+$classAttributesTable = new Table('uw_class_attributes', true, array('object_id'));
2729
28 -$translatedContentAttributeValuesTable = new Table('uw_translated_content_attribute_values', true);
29 -$textAttributeValuesTable = new Table('uw_text_attribute_values', true);
30 -$urlAttributeValuesTable = new Table('uw_url_attribute_values', true);
 30+$translatedContentAttributeValuesTable = new Table('uw_translated_content_attribute_values', true, array('value_id'));
 31+$textAttributeValuesTable = new Table('uw_text_attribute_values', true, array('value_id'));
 32+$urlAttributeValuesTable = new Table('uw_url_attribute_values', true, array('value_id'));
3133
3234 ?>