r25582 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25581‎ | r25582 | r25583 >
Date:12:30, 6 September 2007
Author:proes
Status:old
Tags:
Comment:
Further clean up of edit page: Empty pop-ups are now hidden.
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/OmegaWikiEditors.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/WikiDataAPI.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataAPI.php
@@ -1449,13 +1449,23 @@
14501450 }
14511451 }
14521452
1453 - public function filterClassAttributes($levelName, $type) {
 1453+ public function filterClassAttributesOnLevelAndType($levelName, $type) {
14541454 $result = array();
14551455
14561456 foreach ($this->classAttributes as $classAttribute)
1457 - if ($classAttribute->type == $type && $classAttribute->levelName == $levelName)
 1457+ if ($classAttribute->levelName == $levelName && $classAttribute->type == $type)
14581458 $result[] = $classAttribute->attributeId;
14591459
14601460 return $result;
14611461 }
 1462+
 1463+ public function filterClassAttributesOnLevel($levelName) {
 1464+ $result = array();
 1465+
 1466+ foreach ($this->classAttributes as $classAttribute)
 1467+ if ($classAttribute->levelName == $levelName)
 1468+ $result[] = $classAttribute->attributeId;
 1469+
 1470+ return $result;
 1471+ }
14621472 }
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiEditors.php
@@ -23,11 +23,14 @@
2424 protected $propertyAttribute;
2525 protected $valueAttribute;
2626 protected $attributeIDFilter;
 27+ protected $levelName;
2728
28 - public function __construct(Attribute $attribute, $propertyCaption, ViewInformation $viewInformation, AttributeIDFilter $attributeIDFilter) {
 29+ public function __construct(Attribute $attribute, $propertyCaption, ViewInformation $viewInformation, $levelName, AttributeIDFilter $attributeIDFilter) {
2930 parent::__construct(new RecordUnorderedListEditor($attribute, 5));
3031
 32+ $this->levelName = $levelName;
3133 $this->attributeIDFilter = $attributeIDFilter;
 34+
3235 $this->recordSetTableEditor = new RecordSetTableEditor(
3336 $attribute,
3437 new SimplePermissionController(false),
@@ -54,6 +57,10 @@
5558 return $this->attributeIDFilter;
5659 }
5760
 61+ public function getLevelName() {
 62+ return $this->levelName;
 63+ }
 64+
5865 protected function attributeInStructure(Attribute $attribute, Structure $structure) {
5966 $result = false;
6067 $attributes = $structure->getAttributes();
@@ -208,7 +215,10 @@
209216 }
210217
211218 public function showEditField(IdStack $idPath) {
212 - return true;
 219+ $classAttributes = $idPath->getClassAttributes()->filterClassAttributesOnLevel($this->getLevelName());
 220+ $classAttributes = $this->getAttributeIDFilter()->filter($classAttributes);
 221+
 222+ return count($classAttributes) > 0;
213223 }
214224 }
215225
@@ -224,7 +234,7 @@
225235 }
226236
227237 public function check(IdStack $idPath) {
228 - $classAttributes = $idPath->getClassAttributes()->filterClassAttributes($this->levelDefinedMeaningName, $this->annotationType);
 238+ $classAttributes = $idPath->getClassAttributes()->filterClassAttributesOnLevelAndType($this->levelDefinedMeaningName, $this->annotationType);
229239 $classAttributes = $this->attributeIDFilter->filter($classAttributes);
230240
231241 return count($classAttributes) > 0;
@@ -236,8 +246,8 @@
237247 $textValueObjectAttributesEditors,
238248 $linkValueObjectAttributesEditors,
239249 $translatedTextValueObjectAttributesEditors,
240 - $optionValueObjectAttributesEditors, $annotationMeaningName,
241 - $wgPropertyAttributeName;
 250+ $optionValueObjectAttributesEditors,
 251+ $annotationMeaningName, $wgPropertyAttributeName;
242252
243253 $o=OmegaWikiAttributes::getInstance($viewInformation);
244254
@@ -251,30 +261,30 @@
252262 $propertyCaption = $propertyToColumnFilter->getPropertyCaption();
253263 $attributeIDfilter = $propertyToColumnFilter->getAttributeIDFilter();
254264
255 - $textValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($attribute, $propertyCaption, $viewInformation, $attributeIDfilter);
256 - $linkValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($attribute, $propertyCaption, $viewInformation, $attributeIDfilter);
257 - $translatedTextValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($attribute, $propertyCaption, $viewInformation, $attributeIDfilter);
258 - $optionValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($attribute, $propertyCaption, $viewInformation, $attributeIDfilter);
 265+ $textValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($attribute, $propertyCaption, $viewInformation, $annotationMeaningName, $attributeIDfilter);
 266+ $linkValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($attribute, $propertyCaption, $viewInformation, $annotationMeaningName, $attributeIDfilter);
 267+ $translatedTextValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($attribute, $propertyCaption, $viewInformation, $annotationMeaningName, $attributeIDfilter);
 268+ $optionValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($attribute, $propertyCaption, $viewInformation, $annotationMeaningName, $attributeIDfilter);
259269 }
260270
261271 $leftOverAttributeIdFilter = $viewInformation->getLeftOverAttributeFilter();
262272
263 - $textValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($o->objectAttributes, $wgPropertyAttributeName, $viewInformation, $leftOverAttributeIdFilter);
264 - $linkValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($o->objectAttributes, $wgPropertyAttributeName, $viewInformation, $leftOverAttributeIdFilter);
265 - $translatedTextValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($o->objectAttributes, $wgPropertyAttributeName, $viewInformation, $leftOverAttributeIdFilter);
266 - $optionValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($o->objectAttributes, $wgPropertyAttributeName, $viewInformation, $leftOverAttributeIdFilter);
 273+ $textValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($o->objectAttributes, $wgPropertyAttributeName, $viewInformation, $annotationMeaningName, $leftOverAttributeIdFilter);
 274+ $linkValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($o->objectAttributes, $wgPropertyAttributeName, $viewInformation, $annotationMeaningName, $leftOverAttributeIdFilter);
 275+ $translatedTextValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($o->objectAttributes, $wgPropertyAttributeName, $viewInformation, $annotationMeaningName, $leftOverAttributeIdFilter);
 276+ $optionValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($o->objectAttributes, $wgPropertyAttributeName, $viewInformation, $annotationMeaningName, $leftOverAttributeIdFilter);
267277
268278 foreach ($textValueObjectAttributesEditors as $textValueObjectAttributesEditor)
269 - addObjectAttributesEditors($textValueObjectAttributesEditor, $viewInformation, new ObjectIdFetcher(0, $o->textAttributeId), $annotationMeaningName);
 279+ addObjectAttributesEditors($textValueObjectAttributesEditor, $viewInformation, new ObjectIdFetcher(0, $o->textAttributeId));
270280
271281 foreach ($linkValueObjectAttributesEditors as $linkValueObjectAttributesEditor)
272 - addObjectAttributesEditors($linkValueObjectAttributesEditor, $viewInformation, new ObjectIdFetcher(0, $o->linkAttributeId), $annotationMeaningName);
 282+ addObjectAttributesEditors($linkValueObjectAttributesEditor, $viewInformation, new ObjectIdFetcher(0, $o->linkAttributeId));
273283
274284 foreach ($translatedTextValueObjectAttributesEditors as $translatedTextValueObjectAttributesEditor)
275 - addObjectAttributesEditors($translatedTextValueObjectAttributesEditor, $viewInformation, new ObjectIdFetcher(0, $o->translatedTextAttributeId), $annotationMeaningName);
 285+ addObjectAttributesEditors($translatedTextValueObjectAttributesEditor, $viewInformation, new ObjectIdFetcher(0, $o->translatedTextAttributeId));
276286
277287 foreach ($optionValueObjectAttributesEditors as $optionValueObjectAttributesEditor)
278 - addObjectAttributesEditors($optionValueObjectAttributesEditor, $viewInformation, new ObjectIdFetcher(0, $o->optionAttributeId), $annotationMeaningName);
 288+ addObjectAttributesEditors($optionValueObjectAttributesEditor, $viewInformation, new ObjectIdFetcher(0, $o->optionAttributeId));
279289 }
280290
281291 function getTransactionEditor(Attribute $attribute) {
@@ -392,8 +402,9 @@
393403 return $editor;
394404 }
395405
396 -function addObjectAttributesEditors(ObjectAttributeValuesEditor $objectAttributesEditor, ViewInformation $viewInformation, ContextFetcher $annotatedObjectIdFetcher, $annotationLevelName) {
 406+function addObjectAttributesEditors(ObjectAttributeValuesEditor $objectAttributesEditor, ViewInformation $viewInformation, ContextFetcher $annotatedObjectIdFetcher) {
397407 $attributeIDFilter = $objectAttributesEditor->getAttributeIDfilter();
 408+ $annotationLevelName = $objectAttributesEditor->getLevelName();
398409
399410 $objectAttributesEditor->addEditor(getTextAttributeValuesEditor($viewInformation, new TextAttributeValuesController($annotatedObjectIdFetcher), $annotationLevelName, $attributeIDFilter));
400411 $objectAttributesEditor->addEditor(getTranslatedTextAttributeValuesEditor($viewInformation, new TranslatedTextAttributeValuesController($annotatedObjectIdFetcher, $viewInformation->filterLanguageId), $annotationLevelName, $attributeIDFilter));
@@ -404,13 +415,12 @@
405416 function createObjectAttributesEditor(ViewInformation $viewInformation, Attribute $attribute, $propertyCaption, Attribute $idAttribute, $levelName, AttributeIDFilter $attributeIDFilter) {
406417 $o=OmegaWikiAttributes::getInstance();
407418
408 - $result = new ObjectAttributeValuesEditor($attribute, $propertyCaption, $viewInformation, $attributeIDFilter);
 419+ $result = new ObjectAttributeValuesEditor($attribute, $propertyCaption, $viewInformation, $levelName, $attributeIDFilter);
409420
410421 addObjectAttributesEditors(
411422 $result,
412423 $viewInformation,
413 - new ObjectIdFetcher(0, $idAttribute),
414 - $levelName
 424+ new ObjectIdFetcher(0, $idAttribute)
415425 );
416426
417427 return $result;
@@ -419,13 +429,12 @@
420430 function createDefinitionObjectAttributesEditor(ViewInformation $viewInformation, Attribute $attribute, $propertyCaption, Attribute $idAttribute, $levelName, AttributeIDFilter $attributeIDFilter) {
421431 $o=OmegaWikiAttributes::getInstance();
422432
423 - $result = new ObjectAttributeValuesEditor($attribute, $propertyCaption, $viewInformation, $attributeIDFilter);
 433+ $result = new ObjectAttributeValuesEditor($attribute, $propertyCaption, $viewInformation, $levelName, $attributeIDFilter);
424434
425435 addObjectAttributesEditors(
426436 $result,
427437 $viewInformation,
428 - new DefinitionObjectIdFetcher(0, $idAttribute),
429 - $levelName
 438+ new DefinitionObjectIdFetcher(0, $idAttribute)
430439 );
431440
432441 return $result;

Status & tagging log