r25438 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25437‎ | r25438 | r25439 >
Date:13:18, 3 September 2007
Author:proes
Status:old
Tags:
Comment:
* Renamed Fetcher to ContextFetcher
* Refactored annotation a bit
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/ContextFetcher.php (added) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/ContextFetcher.php (added) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/Editor.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/Fetcher.php (deleted) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/OmegaWikiEditors.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/Fetcher.php
@@ -1,56 +0,0 @@
2 -<?php
3 -
4 -interface Fetcher {
5 - public function __construct($attributeLevel, $attribute);
6 - public function fetch($keyPath);
7 -}
8 -
9 -class DefaultFetcher implements Fetcher {
10 - protected $attributeLevel;
11 - protected $attribute;
12 -
13 - public function __construct($attributeLevel, $attribute) {
14 - $this->attributeLevel = $attributeLevel;
15 - $this->attribute = $attribute;
16 - }
17 - public function fetch($keyPath) {
18 - if ($keyPath->peek($this->attributeLevel)->getStructure()->supportsAttribute($this->attribute))
19 - return $keyPath->peek($this->attributeLevel)->getAttributeValue($this->attribute);
20 - else
21 - return null; # FIXME: Should not happen, check should leave when the reason of the attribute not being support by the record is determined
22 - }
23 -}
24 -
25 -class ObjectIdFetcher extends DefaultFetcher {
26 -// protected $objectIdAttributeLevel;
27 -// protected $objectIdAttribute;
28 -//
29 -// public function __construct($objectIdAttributeLevel, $objectIdAttribute) {
30 -// $this->objectIdAttributeLevel = $objectIdAttributeLevel;
31 -// $this->objectIdAttribute = $objectIdAttribute;
32 -// }
33 -// public function fetch($keyPath, $record) {
34 -// return $keyPath->peek($this->objectIdAttributeLevel)->getAttributeValue($this->objectIdAttribute);
35 -// }
36 - function __tostring(){
37 - $attributeLevel=$this->attributeLevel;
38 - $attribute=$this->attribute;
39 - return "ObjectIdFetcher($attributeLevel, $attribute)";
40 - }
41 -
42 -}
43 -
44 -class DefinitionObjectIdFetcher extends DefaultFetcher {
45 - public function fetch($keyPath) {
46 - $definedMeaningId = $keyPath->peek($this->attributeLevel)->getAttributeValue($this->attribute);
47 - return getDefinedMeaningDefinitionId($definedMeaningId);
48 - }
49 -
50 - function __tostring(){
51 - $attributeLevel=$this->attributeLevel;
52 - $attribute=$this->attribute;
53 - return "DefinitionObjectIdFetcher($attributeLevel, $attribute)";
54 - }
55 -}
56 -
57 -
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiEditors.php
@@ -1,12 +1,12 @@
22 <?php
33
4 -require_once('Editor.php');
5 -require_once('OmegaWikiAttributes.php');
6 -require_once('WikiDataBootstrappedMeanings.php');
7 -require_once('Fetcher.php');
8 -require_once('WikiDataGlobals.php');
9 -require_once('GotoSourceTemplate.php');
10 -require_once('ViewInformation.php');
 4+require_once("Editor.php");
 5+require_once("OmegaWikiAttributes.php");
 6+require_once("WikiDataBootstrappedMeanings.php");
 7+require_once("ContextFetcher.php");
 8+require_once("WikiDataGlobals.php");
 9+require_once("GotoSourceTemplate.php");
 10+require_once("ViewInformation.php");
1111
1212 class DummyViewer extends Viewer {
1313 public function view(IdStack $idPath, $value) {
@@ -179,16 +179,15 @@
180180 }
181181
182182 function initializeObjectAttributeEditors(ViewInformation $viewInformation) {
183 -
184 - $o=OmegaWikiAttributes::getInstance($viewInformation);
185183 global
186 -
187184 $textValueObjectAttributesEditors,
188185 $linkValueObjectAttributesEditors,
189186 $translatedTextValueObjectAttributesEditors,
190187 $optionValueObjectAttributesEditors, $annotationMeaningName,
191188 $wgPropertyAttributeName;
192189
 190+ $o=OmegaWikiAttributes::getInstance($viewInformation);
 191+
193192 $linkValueObjectAttributesEditors = array();
194193 $textValueObjectAttributesEditors = array();
195194 $translatedTextValueObjectAttributesEditors = array();
@@ -223,7 +222,6 @@
224223 }
225224
226225 function getTransactionEditor(Attribute $attribute) {
227 -
228226 $o=OmegaWikiAttributes::getInstance();
229227
230228 $transactionEditor = new RecordTableCellEditor($attribute);
@@ -234,7 +232,6 @@
235233 }
236234
237235 function createTableLifeSpanEditor(Attribute $attribute) {
238 -
239236 $o=OmegaWikiAttributes::getInstance();
240237
241238 $result = new RecordTableCellEditor($attribute);
@@ -245,10 +242,10 @@
246243 }
247244
248245 function getTableLifeSpanEditor($showRecordLifeSpan) {
 246+ global
 247+ $wgRequest;
249248
250249 $o=OmegaWikiAttributes::getInstance();
251 - global
252 - $wgRequest;
253250
254251 $result = array();
255252
@@ -270,12 +267,10 @@
271268 }
272269
273270 function getDefinitionEditor(ViewInformation $viewInformation) {
 271+ global
 272+ $wgPopupAnnotationName, $definitionMeaningName, $wgPropertyAttributeName;
274273
275274 $o=OmegaWikiAttributes::getInstance();
276 - global
277 - $wgPopupAnnotationName,
278 - $definitionMeaningName,
279 - $wgPropertyAttributeName;
280275
281276 $editor = new RecordDivListEditor($o->definition);
282277 $editor->addEditor(getTranslatedTextEditor(
@@ -302,27 +297,28 @@
303298 return $editor;
304299 }
305300
306 -function createPropertyToColumnFilterEditors(ViewInformation $viewInformation, Attribute $idAttribute, $levelsFromDefinedMeaning, $levelName) {
 301+function createPropertyToColumnFilterEditors(ViewInformation $viewInformation, Attribute $idAttribute, $levelsToLookUpwards, $levelName) {
307302 $result = array();
308303
309304 foreach ($viewInformation->getPropertyToColumnFilters() as $propertyToColumnFilter) {
310305 $attribute = $propertyToColumnFilter->getAttribute();
311306 $propertyCaption = $propertyToColumnFilter->getPropertyCaption();
312 - $result[] = createObjectAttributesEditor($viewInformation, $attribute, $propertyCaption, $idAttribute, $levelsFromDefinedMeaning, $levelName);
 307+ $result[] = createObjectAttributesEditor($viewInformation, $attribute, $propertyCaption, $idAttribute, $levelsToLookUpwards, $levelName);
313308 }
314309
315310 return $result;
316311 }
317312
318 -function addPropertyToColumnFilterEditors(Editor $editor, ViewInformation $viewInformation, Attribute $idAttribute, $levelsFromDefinedMeaning, $levelName) {
319 - foreach (createPropertyToColumnFilterEditors($viewInformation, $idAttribute, $levelsFromDefinedMeaning, $levelName) as $propertyToColumnEditor) {
 313+function addPropertyToColumnFilterEditors(Editor $editor, ViewInformation $viewInformation, Attribute $idAttribute, $levelsToLookUpwards, $levelName) {
 314+ foreach (createPropertyToColumnFilterEditors($viewInformation, $idAttribute, $levelsToLookUpwards, $levelName) as $propertyToColumnEditor) {
320315 $attribute = $propertyToColumnEditor->getAttribute();
321316 $editor->addEditor(new PopUpEditor($propertyToColumnEditor, $attribute->name));
322317 }
323318 }
324319
325320 function getTranslatedTextEditor(Attribute $attribute, UpdateController $updateController, UpdateAttributeController $updateAttributeController, ViewInformation $viewInformation) {
326 - $o=OmegaWikiAttributes::getInstance();
 321+ $o=OmegaWikiAttributes::getInstance();
 322+
327323 if ($viewInformation->filterLanguageId == 0 || $viewInformation->showRecordLifeSpan) {
328324 $editor = new RecordSetTableEditor($attribute, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, true, $updateController);
329325
@@ -338,15 +334,14 @@
339335 return $editor;
340336 }
341337
342 -function addObjectAttributesEditors(Editor $objectAttributesEditor, ViewInformation $viewInformation, Fetcher $objectIdFetcher, $levelDefinedMeaningName, Fetcher $dmObjectIdFetcher) {
343 - $objectAttributesEditor->addEditor(getTextAttributeValuesEditor($viewInformation, new TextAttributeValuesController($objectIdFetcher), $levelDefinedMeaningName, $dmObjectIdFetcher));
344 - $objectAttributesEditor->addEditor(getTranslatedTextAttributeValuesEditor($viewInformation, new TranslatedTextAttributeValuesController($objectIdFetcher, $viewInformation->filterLanguageId), $levelDefinedMeaningName, $dmObjectIdFetcher));
345 - $objectAttributesEditor->addEditor(getLinkAttributeValuesEditor($viewInformation, new LinkAttributeValuesController($objectIdFetcher), $levelDefinedMeaningName, $dmObjectIdFetcher));
346 - $objectAttributesEditor->addEditor(getOptionAttributeValuesEditor($viewInformation, new OptionAttributeValuesController($objectIdFetcher), $levelDefinedMeaningName, $dmObjectIdFetcher));
 338+function addObjectAttributesEditors(Editor $objectAttributesEditor, ViewInformation $viewInformation, ContextFetcher $annotatedObjectIdFetcher, $annotationLevelName, ContextFetcher $definedMeaningIdFetcher) {
 339+ $objectAttributesEditor->addEditor(getTextAttributeValuesEditor($viewInformation, new TextAttributeValuesController($annotatedObjectIdFetcher), $annotationLevelName, $definedMeaningIdFetcher));
 340+ $objectAttributesEditor->addEditor(getTranslatedTextAttributeValuesEditor($viewInformation, new TranslatedTextAttributeValuesController($annotatedObjectIdFetcher, $viewInformation->filterLanguageId), $annotationLevelName, $definedMeaningIdFetcher));
 341+ $objectAttributesEditor->addEditor(getLinkAttributeValuesEditor($viewInformation, new LinkAttributeValuesController($annotatedObjectIdFetcher), $annotationLevelName, $definedMeaningIdFetcher));
 342+ $objectAttributesEditor->addEditor(getOptionAttributeValuesEditor($viewInformation, new OptionAttributeValuesController($annotatedObjectIdFetcher), $annotationLevelName, $definedMeaningIdFetcher));
347343 }
348344
349 -function createObjectAttributesEditor(ViewInformation $viewInformation, Attribute $attribute, $propertyCaption, Attribute $idAttribute, $levelsFromDefinedMeaning, $levelName) {
350 -
 345+function createObjectAttributesEditor(ViewInformation $viewInformation, Attribute $attribute, $propertyCaption, Attribute $idAttribute, $levelsToLookUpwards, $levelName) {
351346 $o=OmegaWikiAttributes::getInstance();
352347
353348 $result = new ObjectAttributeValuesEditor($attribute, $propertyCaption, $viewInformation);
@@ -356,14 +351,13 @@
357352 $viewInformation,
358353 new ObjectIdFetcher(0, $idAttribute),
359354 $levelName,
360 - new ObjectIdFetcher($levelsFromDefinedMeaning, $o->definedMeaningId)
 355+ new ObjectIdFetcher($levelsToLookUpwards, $o->definedMeaningId)
361356 );
362357
363358 return $result;
364359 }
365360
366 -function createDefinitionObjectAttributesEditor(ViewInformation $viewInformation, Attribute $attribute, $propertyCaption, Attribute $idAttribute, $levelsFromDefinedMeaning, $levelName) {
367 -
 361+function createDefinitionObjectAttributesEditor(ViewInformation $viewInformation, Attribute $attribute, $propertyCaption, Attribute $idAttribute, $levelsToLookUpwards, $levelName) {
368362 $o=OmegaWikiAttributes::getInstance();
369363
370364 $result = new ObjectAttributeValuesEditor($attribute, $propertyCaption, $viewInformation);
@@ -373,14 +367,13 @@
374368 $viewInformation,
375369 new DefinitionObjectIdFetcher(0, $idAttribute),
376370 $levelName,
377 - new ObjectIdFetcher($levelsFromDefinedMeaning, $o->definedMeaningId)
 371+ new ObjectIdFetcher($levelsToLookUpwards, $o->definedMeaningId)
378372 );
379373
380374 return $result;
381375 }
382376
383377 function getAlternativeDefinitionsEditor(ViewInformation $viewInformation) {
384 -
385378 $o=OmegaWikiAttributes::getInstance();
386379
387380 $editor = new RecordSetTableEditor(
@@ -407,7 +400,6 @@
408401 }
409402
410403 function getExpressionTableCellEditor(Attribute $attribute, ViewInformation $viewInformation) {
411 -
412404 $o=OmegaWikiAttributes::getInstance();
413405
414406 if ($viewInformation->filterLanguageId == 0) {
@@ -422,7 +414,6 @@
423415 }
424416
425417 function getClassAttributesEditor(ViewInformation $viewInformation) {
426 -
427418 $o=OmegaWikiAttributes::getInstance();
428419
429420 $tableEditor = new RecordSetTableEditor($o->classAttributes, new SimplePermissionController(true), new ShowEditFieldForClassesChecker(0, $o->definedMeaningId), new AllowAddController(true), true, false, new ClassAttributesController());
@@ -437,14 +428,11 @@
438429 }
439430
440431 function getSynonymsAndTranslationsEditor(ViewInformation $viewInformation) {
 432+ global
 433+ $wgPopupAnnotationName, $synTransMeaningName, $wgPropertyAttributeName;
441434
442435 $o=OmegaWikiAttributes::getInstance();
443 - global
444436
445 - $wgPopupAnnotationName,
446 - $synTransMeaningName,
447 - $wgPropertyAttributeName;
448 -
449437 $tableEditor = new RecordSetTableEditor(
450438 $o->synonymsAndTranslations,
451439 new SimplePermissionController(true),
@@ -471,13 +459,12 @@
472460 }
473461
474462 function getDefinedMeaningRelationsEditor(ViewInformation $viewInformation) {
475 -
476 - $o=OmegaWikiAttributes::getInstance();
477463 global
478 -
479464 $relationsObjectAttributesEditor, $relationMeaningName, $wgPopupAnnotationName,
480465 $wgPropertyAttributeName;
481466
 467+ $o=OmegaWikiAttributes::getInstance();
 468+
482469 $editor = new RecordSetTableEditor($o->relations, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, false, new DefinedMeaningRelationController());
483470 $editor->addEditor(new RelationTypeReferenceEditor($o->relationType, new SimplePermissionController(false), true));
484471 $editor->addEditor(new DefinedMeaningReferenceEditor($o->otherDefinedMeaning, new SimplePermissionController(false), true));
@@ -495,13 +482,12 @@
496483 }
497484
498485 function getDefinedMeaningReciprocalRelationsEditor(ViewInformation $viewInformation) {
499 -
500 - $o=OmegaWikiAttributes::getInstance();
501486 global
502 -
503 - $relationsObjectAttributesEditor, $relationMeaningName, $wgPopupAnnotationName,
 487+ $relationsObjectAttributesEditor, $relationMeaningName, $wgPopupAnnotationName,
504488 $wgPropertyAttributeName;
505489
 490+ $o=OmegaWikiAttributes::getInstance();
 491+
506492 $editor = new RecordSetTableEditor($o->reciprocalRelations, new SimplePermissionController(false), new ShowEditFieldChecker(true), new AllowAddController(false), false, false, null);
507493 $editor->addEditor(new DefinedMeaningReferenceEditor($o->otherDefinedMeaning, new SimplePermissionController(false), true));
508494 $editor->addEditor(new RelationTypeReferenceEditor($o->relationType, new SimplePermissionController(false), true));
@@ -519,7 +505,6 @@
520506 }
521507
522508 function getDefinedMeaningClassMembershipEditor(ViewInformation $viewInformation) {
523 -
524509 $o=OmegaWikiAttributes::getInstance();
525510
526511 $editor = new RecordSetTableEditor($o->classMembership, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, false, new DefinedMeaningClassMembershipController());
@@ -555,12 +540,11 @@
556541 }
557542
558543 function getDefinedMeaningCollectionMembershipEditor(ViewInformation $viewInformation) {
559 -
560 - $o=OmegaWikiAttributes::getInstance();
561544 global
562 -
563545 $wgGotoSourceTemplates;
564546
 547+ $o=OmegaWikiAttributes::getInstance();
 548+
565549 $editor = new RecordSetTableEditor($o->collectionMembership, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, false, new DefinedMeaningCollectionController());
566550 $editor->addEditor(new CollectionReferenceEditor($o->collectionMeaning, new SimplePermissionController(false), true));
567551 $editor->addEditor(new ShortTextEditor($o->sourceIdentifier, new SimplePermissionController(true), true));
@@ -578,11 +562,11 @@
579563 $editor->addEditor(new PopUpEditor($columnEditor, $columnEditor->getAttribute()->name));
580564 }
581565
582 -function getTextAttributeValuesEditor(ViewInformation $viewInformation, $controller, $levelDefinedMeaningName, Fetcher $objectIdFetcher) {
 566+function getTextAttributeValuesEditor(ViewInformation $viewInformation, $controller, $levelDefinedMeaningName, ContextFetcher $objectIdFetcher) {
 567+ global
 568+ $textValueObjectAttributesEditors;
583569
584570 $o=OmegaWikiAttributes::getInstance();
585 - global
586 - $textValueObjectAttributesEditors;
587571
588572 $editor = new RecordSetTableEditor($o->textAttributeValues, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, false, $controller);
589573 $editor->addEditor(new TextAttributeEditor($o->textAttribute, new SimplePermissionController(false), true, $levelDefinedMeaningName, $objectIdFetcher));
@@ -594,11 +578,11 @@
595579 return $editor;
596580 }
597581
598 -function getLinkAttributeValuesEditor(ViewInformation $viewInformation, UpdateController $controller, $levelDefinedMeaningName, Fetcher $objectIdFetcher) {
 582+function getLinkAttributeValuesEditor(ViewInformation $viewInformation, UpdateController $controller, $levelDefinedMeaningName, ContextFetcher $objectIdFetcher) {
 583+ global
 584+ $linkValueObjectAttributesEditors;
599585
600586 $o=OmegaWikiAttributes::getInstance();
601 - global
602 - $linkValueObjectAttributesEditors;
603587
604588 $editor = new RecordSetTableEditor($o->linkAttributeValues, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, false, $controller);
605589 $editor->addEditor(new LinkAttributeEditor($o->linkAttribute, new SimplePermissionController(false), true, $levelDefinedMeaningName, $objectIdFetcher));
@@ -619,13 +603,12 @@
620604 return $editor;
621605 }
622606
623 -function getTranslatedTextAttributeValuesEditor(ViewInformation $viewInformation, UpdateController $controller, $levelDefinedMeaningName, Fetcher $objectIdFetcher) {
624 -
625 - $o=OmegaWikiAttributes::getInstance();
 607+function getTranslatedTextAttributeValuesEditor(ViewInformation $viewInformation, UpdateController $controller, $levelDefinedMeaningName, ContextFetcher $objectIdFetcher) {
626608 global
627 -
628609 $translatedTextValueObjectAttributesEditors;
629610
 611+ $o=OmegaWikiAttributes::getInstance();
 612+
630613 $editor = new RecordSetTableEditor($o->translatedTextAttributeValues, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, false, $controller);
631614 $editor->addEditor(new TranslatedTextAttributeEditor($o->translatedTextAttribute, new SimplePermissionController(false), true, $levelDefinedMeaningName, $objectIdFetcher));
632615 $editor->addEditor(getTranslatedTextEditor(
@@ -641,13 +624,12 @@
642625 return $editor;
643626 }
644627
645 -function getOptionAttributeValuesEditor(ViewInformation $viewInformation, UpdateController $controller, $levelDefinedMeaningName, Fetcher $objectIdFetcher) {
646 -
647 - $o=OmegaWikiAttributes::getInstance();
 628+function getOptionAttributeValuesEditor(ViewInformation $viewInformation, UpdateController $controller, $levelDefinedMeaningName, ContextFetcher $objectIdFetcher) {
648629 global
649 -
650630 $optionValueObjectAttributesEditors;
651631
 632+ $o=OmegaWikiAttributes::getInstance();
 633+
652634 $editor = new RecordSetTableEditor($o->optionAttributeValues, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, false, $controller);
653635
654636 $editor->addEditor(new OptionAttributeEditor($o->optionAttribute, new SimplePermissionController(false), true, $levelDefinedMeaningName, $objectIdFetcher));
@@ -660,7 +642,6 @@
661643 }
662644
663645 function getOptionAttributeOptionsEditor() {
664 -
665646 $o=OmegaWikiAttributes::getInstance();
666647
667648 $editor = new RecordSetTableEditor($o->optionAttributeOptions, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, false, new OptionAttributeOptionsController());
@@ -671,7 +652,6 @@
672653 }
673654
674655 function getExpressionMeaningsEditor(Attribute $attribute, $allowAdd, ViewInformation $viewInformation) {
675 -
676656 $o=OmegaWikiAttributes::getInstance();
677657
678658 $definedMeaningEditor = getDefinedMeaningEditor($viewInformation);
@@ -687,7 +667,6 @@
688668 }
689669
690670 function getExpressionsEditor($spelling, ViewInformation $viewInformation) {
691 -
692671 $o=OmegaWikiAttributes::getInstance();
693672
694673 $expressionMeaningsRecordEditor = new RecordUnorderedListEditor($o->expressionMeanings, 3);
@@ -736,13 +715,11 @@
737716 }
738717
739718 function getDefinedMeaningEditor(ViewInformation $viewInformation) {
740 -
741 - $o=OmegaWikiAttributes::getInstance();
742719 global
743720 $wdDefinedMeaningAttributesOrder, $definedMeaningMeaningName,
744 -
745 - $relationMeaningName,
746 - $wgPropertyAttributeName;
 721+ $relationMeaningName, $wgPropertyAttributeName;
 722+
 723+ $o=OmegaWikiAttributes::getInstance();
747724
748725 $definitionEditor = getDefinitionEditor($viewInformation);
749726 $alternativeDefinitionsEditor = getAlternativeDefinitionsEditor($viewInformation);
Index: trunk/extensions/Wikidata/OmegaWiki/ContextFetcher.php
@@ -0,0 +1,60 @@
 2+<?php
 3+
 4+/**
 5+ * Interface ContextFetcher is used to look upwards in a keyPath in
 6+ * search for a specific attribute value. This attribute value establishes a
 7+ * context for an operation that works within a hierarchy of Records (like an Editor does).
 8+ *
 9+ * It might be better to adopt another strategy that pushes the desired context
 10+ * down the hierarchy of Editors instead of letting an Editor look up the hierarchy.
 11+ * We possibly can extend/replace the IdStack to store context during rendering.
 12+ */
 13+
 14+interface ContextFetcher {
 15+ public function fetch($keyPath);
 16+}
 17+
 18+/**
 19+ * Class DefaultContextFetcher implements ContextFetcher by looking up a specified number of levels
 20+ * in the keypath and returning the value for the specified attribute.
 21+ */
 22+
 23+class DefaultContextFetcher implements ContextFetcher {
 24+ protected $levelsToLookUp;
 25+ protected $attribute;
 26+
 27+ public function __construct($levelsToLookUp, $attribute) {
 28+ $this->levelsToLookUp = $levelsToLookUp;
 29+ $this->attribute = $attribute;
 30+ }
 31+ public function fetch($keyPath) {
 32+ if ($keyPath->peek($this->levelsToLookUp)->getStructure()->supportsAttribute($this->attribute))
 33+ return $keyPath->peek($this->levelsToLookUp)->getAttributeValue($this->attribute);
 34+ else
 35+ return null; # FIXME: Should not happen, check should leave when the reason of the attribute not being support by the record is determined
 36+ }
 37+}
 38+
 39+class ObjectIdFetcher extends DefaultContextFetcher {
 40+ function __tostring(){
 41+ $levelsToLookUp = $this->attributeLevel;
 42+ $attribute = $this->attribute;
 43+
 44+ return "ObjectIdFetcher($levelsToLookUp, $attribute)";
 45+ }
 46+}
 47+
 48+class DefinitionObjectIdFetcher extends DefaultContextFetcher {
 49+ public function fetch($keyPath) {
 50+ $definedMeaningId = $keyPath->peek($this->levelsToLookUp)->getAttributeValue($this->attribute);
 51+ return getDefinedMeaningDefinitionId($definedMeaningId);
 52+ }
 53+
 54+ function __tostring(){
 55+ $levelsToLookUp = $this->attributeLevel;
 56+ $attribute = $this->attribute;
 57+ return "DefinitionObjectIdFetcher($levelsToLookUp, $attribute)";
 58+ }
 59+}
 60+
 61+
Property changes on: trunk/extensions/Wikidata/OmegaWiki/ContextFetcher.php
___________________________________________________________________
Added: svn:eol-style
162 + native
Index: trunk/extensions/Wikidata/OmegaWiki/Editor.php
@@ -5,6 +5,7 @@
66 require_once("type.php");
77 require_once("GotoSourceTemplate.php");
88 require_once("Wikidata.php");
 9+require_once("ContextFetcher.php");
910
1011 function addCollapsablePrefixToClass($class) {
1112 return "collapsable-$class";
@@ -1230,7 +1231,7 @@
12311232 protected $attributesLevelName;
12321233 protected $objectIdFetcher;
12331234
1234 - public function __construct(Attribute $attribute = null, PermissionController $permissionController, $isAddField, $attributesLevelName, Fetcher $objectIdFetcher) {
 1235+ public function __construct(Attribute $attribute = null, PermissionController $permissionController, $isAddField, $attributesLevelName, ContextFetcher $objectIdFetcher) {
12351236 parent::__construct($attribute, $permissionController, $isAddField);
12361237
12371238 $this->attributesLevelName = $attributesLevelName;

Status & tagging log