Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataAPI.php |
— | — | @@ -1449,13 +1449,23 @@ |
1450 | 1450 | } |
1451 | 1451 | } |
1452 | 1452 | |
1453 | | - public function filterClassAttributes($levelName, $type) { |
| 1453 | + public function filterClassAttributesOnLevelAndType($levelName, $type) { |
1454 | 1454 | $result = array(); |
1455 | 1455 | |
1456 | 1456 | foreach ($this->classAttributes as $classAttribute) |
1457 | | - if ($classAttribute->type == $type && $classAttribute->levelName == $levelName) |
| 1457 | + if ($classAttribute->levelName == $levelName && $classAttribute->type == $type) |
1458 | 1458 | $result[] = $classAttribute->attributeId; |
1459 | 1459 | |
1460 | 1460 | return $result; |
1461 | 1461 | } |
| 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 | + } |
1462 | 1472 | } |
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiEditors.php |
— | — | @@ -23,11 +23,14 @@ |
24 | 24 | protected $propertyAttribute; |
25 | 25 | protected $valueAttribute; |
26 | 26 | protected $attributeIDFilter; |
| 27 | + protected $levelName; |
27 | 28 | |
28 | | - public function __construct(Attribute $attribute, $propertyCaption, ViewInformation $viewInformation, AttributeIDFilter $attributeIDFilter) { |
| 29 | + public function __construct(Attribute $attribute, $propertyCaption, ViewInformation $viewInformation, $levelName, AttributeIDFilter $attributeIDFilter) { |
29 | 30 | parent::__construct(new RecordUnorderedListEditor($attribute, 5)); |
30 | 31 | |
| 32 | + $this->levelName = $levelName; |
31 | 33 | $this->attributeIDFilter = $attributeIDFilter; |
| 34 | + |
32 | 35 | $this->recordSetTableEditor = new RecordSetTableEditor( |
33 | 36 | $attribute, |
34 | 37 | new SimplePermissionController(false), |
— | — | @@ -54,6 +57,10 @@ |
55 | 58 | return $this->attributeIDFilter; |
56 | 59 | } |
57 | 60 | |
| 61 | + public function getLevelName() { |
| 62 | + return $this->levelName; |
| 63 | + } |
| 64 | + |
58 | 65 | protected function attributeInStructure(Attribute $attribute, Structure $structure) { |
59 | 66 | $result = false; |
60 | 67 | $attributes = $structure->getAttributes(); |
— | — | @@ -208,7 +215,10 @@ |
209 | 216 | } |
210 | 217 | |
211 | 218 | 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; |
213 | 223 | } |
214 | 224 | } |
215 | 225 | |
— | — | @@ -224,7 +234,7 @@ |
225 | 235 | } |
226 | 236 | |
227 | 237 | public function check(IdStack $idPath) { |
228 | | - $classAttributes = $idPath->getClassAttributes()->filterClassAttributes($this->levelDefinedMeaningName, $this->annotationType); |
| 238 | + $classAttributes = $idPath->getClassAttributes()->filterClassAttributesOnLevelAndType($this->levelDefinedMeaningName, $this->annotationType); |
229 | 239 | $classAttributes = $this->attributeIDFilter->filter($classAttributes); |
230 | 240 | |
231 | 241 | return count($classAttributes) > 0; |
— | — | @@ -236,8 +246,8 @@ |
237 | 247 | $textValueObjectAttributesEditors, |
238 | 248 | $linkValueObjectAttributesEditors, |
239 | 249 | $translatedTextValueObjectAttributesEditors, |
240 | | - $optionValueObjectAttributesEditors, $annotationMeaningName, |
241 | | - $wgPropertyAttributeName; |
| 250 | + $optionValueObjectAttributesEditors, |
| 251 | + $annotationMeaningName, $wgPropertyAttributeName; |
242 | 252 | |
243 | 253 | $o=OmegaWikiAttributes::getInstance($viewInformation); |
244 | 254 | |
— | — | @@ -251,30 +261,30 @@ |
252 | 262 | $propertyCaption = $propertyToColumnFilter->getPropertyCaption(); |
253 | 263 | $attributeIDfilter = $propertyToColumnFilter->getAttributeIDFilter(); |
254 | 264 | |
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); |
259 | 269 | } |
260 | 270 | |
261 | 271 | $leftOverAttributeIdFilter = $viewInformation->getLeftOverAttributeFilter(); |
262 | 272 | |
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); |
267 | 277 | |
268 | 278 | foreach ($textValueObjectAttributesEditors as $textValueObjectAttributesEditor) |
269 | | - addObjectAttributesEditors($textValueObjectAttributesEditor, $viewInformation, new ObjectIdFetcher(0, $o->textAttributeId), $annotationMeaningName); |
| 279 | + addObjectAttributesEditors($textValueObjectAttributesEditor, $viewInformation, new ObjectIdFetcher(0, $o->textAttributeId)); |
270 | 280 | |
271 | 281 | foreach ($linkValueObjectAttributesEditors as $linkValueObjectAttributesEditor) |
272 | | - addObjectAttributesEditors($linkValueObjectAttributesEditor, $viewInformation, new ObjectIdFetcher(0, $o->linkAttributeId), $annotationMeaningName); |
| 282 | + addObjectAttributesEditors($linkValueObjectAttributesEditor, $viewInformation, new ObjectIdFetcher(0, $o->linkAttributeId)); |
273 | 283 | |
274 | 284 | foreach ($translatedTextValueObjectAttributesEditors as $translatedTextValueObjectAttributesEditor) |
275 | | - addObjectAttributesEditors($translatedTextValueObjectAttributesEditor, $viewInformation, new ObjectIdFetcher(0, $o->translatedTextAttributeId), $annotationMeaningName); |
| 285 | + addObjectAttributesEditors($translatedTextValueObjectAttributesEditor, $viewInformation, new ObjectIdFetcher(0, $o->translatedTextAttributeId)); |
276 | 286 | |
277 | 287 | foreach ($optionValueObjectAttributesEditors as $optionValueObjectAttributesEditor) |
278 | | - addObjectAttributesEditors($optionValueObjectAttributesEditor, $viewInformation, new ObjectIdFetcher(0, $o->optionAttributeId), $annotationMeaningName); |
| 288 | + addObjectAttributesEditors($optionValueObjectAttributesEditor, $viewInformation, new ObjectIdFetcher(0, $o->optionAttributeId)); |
279 | 289 | } |
280 | 290 | |
281 | 291 | function getTransactionEditor(Attribute $attribute) { |
— | — | @@ -392,8 +402,9 @@ |
393 | 403 | return $editor; |
394 | 404 | } |
395 | 405 | |
396 | | -function addObjectAttributesEditors(ObjectAttributeValuesEditor $objectAttributesEditor, ViewInformation $viewInformation, ContextFetcher $annotatedObjectIdFetcher, $annotationLevelName) { |
| 406 | +function addObjectAttributesEditors(ObjectAttributeValuesEditor $objectAttributesEditor, ViewInformation $viewInformation, ContextFetcher $annotatedObjectIdFetcher) { |
397 | 407 | $attributeIDFilter = $objectAttributesEditor->getAttributeIDfilter(); |
| 408 | + $annotationLevelName = $objectAttributesEditor->getLevelName(); |
398 | 409 | |
399 | 410 | $objectAttributesEditor->addEditor(getTextAttributeValuesEditor($viewInformation, new TextAttributeValuesController($annotatedObjectIdFetcher), $annotationLevelName, $attributeIDFilter)); |
400 | 411 | $objectAttributesEditor->addEditor(getTranslatedTextAttributeValuesEditor($viewInformation, new TranslatedTextAttributeValuesController($annotatedObjectIdFetcher, $viewInformation->filterLanguageId), $annotationLevelName, $attributeIDFilter)); |
— | — | @@ -404,13 +415,12 @@ |
405 | 416 | function createObjectAttributesEditor(ViewInformation $viewInformation, Attribute $attribute, $propertyCaption, Attribute $idAttribute, $levelName, AttributeIDFilter $attributeIDFilter) { |
406 | 417 | $o=OmegaWikiAttributes::getInstance(); |
407 | 418 | |
408 | | - $result = new ObjectAttributeValuesEditor($attribute, $propertyCaption, $viewInformation, $attributeIDFilter); |
| 419 | + $result = new ObjectAttributeValuesEditor($attribute, $propertyCaption, $viewInformation, $levelName, $attributeIDFilter); |
409 | 420 | |
410 | 421 | addObjectAttributesEditors( |
411 | 422 | $result, |
412 | 423 | $viewInformation, |
413 | | - new ObjectIdFetcher(0, $idAttribute), |
414 | | - $levelName |
| 424 | + new ObjectIdFetcher(0, $idAttribute) |
415 | 425 | ); |
416 | 426 | |
417 | 427 | return $result; |
— | — | @@ -419,13 +429,12 @@ |
420 | 430 | function createDefinitionObjectAttributesEditor(ViewInformation $viewInformation, Attribute $attribute, $propertyCaption, Attribute $idAttribute, $levelName, AttributeIDFilter $attributeIDFilter) { |
421 | 431 | $o=OmegaWikiAttributes::getInstance(); |
422 | 432 | |
423 | | - $result = new ObjectAttributeValuesEditor($attribute, $propertyCaption, $viewInformation, $attributeIDFilter); |
| 433 | + $result = new ObjectAttributeValuesEditor($attribute, $propertyCaption, $viewInformation, $levelName, $attributeIDFilter); |
424 | 434 | |
425 | 435 | addObjectAttributesEditors( |
426 | 436 | $result, |
427 | 437 | $viewInformation, |
428 | | - new DefinitionObjectIdFetcher(0, $idAttribute), |
429 | | - $levelName |
| 438 | + new DefinitionObjectIdFetcher(0, $idAttribute) |
430 | 439 | ); |
431 | 440 | |
432 | 441 | return $result; |