Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataGlobals.php |
— | — | @@ -143,7 +143,6 @@ |
144 | 144 | $wgAlternativeDefinitionsAttributeId, |
145 | 145 | $wgSynonymsAndTranslationsAttributeId, |
146 | 146 | $wgPossiblySynonymousAttributeId, |
147 | | - $wgRelationsAttributeId, |
148 | 147 | $wgIncomingRelationsAttributeId, |
149 | 148 | $wgClassMembershipAttributeId, |
150 | 149 | $wgCollectionMembershipAttributeId, |
Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataBootstrappedMeanings.php |
— | — | @@ -18,7 +18,6 @@ |
19 | 19 | $classAttributeLevels = array( |
20 | 20 | $definedMeaningMeaningName, |
21 | 21 | $definitionMeaningName, |
22 | | - $relationMeaningName, |
23 | 22 | $synTransMeaningName, |
24 | 23 | $annotationMeaningName |
25 | 24 | ); |
Index: trunk/extensions/Wikidata/OmegaWiki/SpecialSuggest.php |
— | — | @@ -63,18 +63,21 @@ |
64 | 64 | $sqlFallback = getSQLForCollectionOfType('CLAS', 'en'); |
65 | 65 | $sql=constructSQLWithFallback($sqlActual, $sqlFallback, array("member_mid", "spelling", "collection_mid")); |
66 | 66 | break; |
67 | | - case 'option-attribute': |
68 | | - $sql = getSQLToSelectPossibleAttributes($definedMeaningId, $attributesLevel, $annotationAttributeId, 'OPTN'); |
| 67 | + case 'defined-meaning-attribute': |
| 68 | + $sql = getSQLToSelectPossibleAttributes($definedMeaningId, $attributesLevel, $annotationAttributeId, 'DM'); |
69 | 69 | break; |
| 70 | + case 'text-attribute': |
| 71 | + $sql = getSQLToSelectPossibleAttributes($definedMeaningId, $attributesLevel, $annotationAttributeId, 'TEXT'); |
| 72 | + break; |
70 | 73 | case 'translated-text-attribute': |
71 | 74 | $sql = getSQLToSelectPossibleAttributes($definedMeaningId, $attributesLevel, $annotationAttributeId, 'TRNS'); |
72 | 75 | break; |
73 | | - case 'text-attribute': |
74 | | - $sql = getSQLToSelectPossibleAttributes($definedMeaningId, $attributesLevel, $annotationAttributeId, 'TEXT'); |
75 | | - break; |
76 | 76 | case 'link-attribute': |
77 | 77 | $sql = getSQLToSelectPossibleAttributes($definedMeaningId, $attributesLevel, $annotationAttributeId, 'URL'); |
78 | 78 | break; |
| 79 | + case 'option-attribute': |
| 80 | + $sql = getSQLToSelectPossibleAttributes($definedMeaningId, $attributesLevel, $annotationAttributeId, 'OPTN'); |
| 81 | + break; |
79 | 82 | case 'language': |
80 | 83 | require_once('languages.php'); |
81 | 84 | $sql = getSQLForLanguageNames($wgUser->getOption('language')); |
— | — | @@ -154,18 +157,21 @@ |
155 | 158 | case 'class': |
156 | 159 | list($recordSet, $editor) = getClassAsRecordSet($queryResult); |
157 | 160 | break; |
| 161 | + case 'defined-meaning-attribute': |
| 162 | + list($recordSet, $editor) = getDefinedMeaningAttributeAsRecordSet($queryResult); |
| 163 | + break; |
158 | 164 | case 'text-attribute': |
159 | 165 | list($recordSet, $editor) = getTextAttributeAsRecordSet($queryResult); |
160 | 166 | break; |
161 | 167 | case 'translated-text-attribute': |
162 | 168 | list($recordSet, $editor) = getTranslatedTextAttributeAsRecordSet($queryResult); |
163 | 169 | break; |
| 170 | + case 'link-attribute': |
| 171 | + list($recordSet, $editor) = getLinkAttributeAsRecordSet($queryResult); |
| 172 | + break; |
164 | 173 | case 'option-attribute': |
165 | 174 | list($recordSet, $editor) = getOptionAttributeAsRecordSet($queryResult); |
166 | 175 | break; |
167 | | - case 'link-attribute': |
168 | | - list($recordSet, $editor) = getLinkAttributeAsRecordSet($queryResult); |
169 | | - break; |
170 | 176 | case 'defined-meaning': |
171 | 177 | list($recordSet, $editor) = getDefinedMeaningAsRecordSet($queryResult); |
172 | 178 | break; |
— | — | @@ -463,6 +469,23 @@ |
464 | 470 | return array($recordSet, $editor); |
465 | 471 | } |
466 | 472 | |
| 473 | +function getDefinedMeaningAttributeAsRecordSet($queryResult) { |
| 474 | + $o=OmegaWikiAttributes::getInstance(); |
| 475 | + |
| 476 | + $dbr =& wfGetDB(DB_SLAVE); |
| 477 | + |
| 478 | + $definedMeaningAttributeAttribute = new Attribute("defined-meaning-attribute", "Relation type", "short-text"); |
| 479 | + $recordSet = new ArrayRecordSet(new Structure($o->id, $definedMeaningAttributeAttribute), new Structure($o->id)); |
| 480 | + |
| 481 | + while ($row = $dbr->fetchObject($queryResult)) |
| 482 | + $recordSet->addRecord(array($row->attribute_mid, $row->spelling)); |
| 483 | + |
| 484 | + $editor = createSuggestionsTableViewer(null); |
| 485 | + $editor->addEditor(createShortTextViewer($definedMeaningAttributeAttribute)); |
| 486 | + |
| 487 | + return array($recordSet, $editor); |
| 488 | +} |
| 489 | + |
467 | 490 | function getTextAttributeAsRecordSet($queryResult) { |
468 | 491 | |
469 | 492 | $o=OmegaWikiAttributes::getInstance(); |
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes.php |
— | — | @@ -203,20 +203,22 @@ |
204 | 204 | $t->translatedTextAttributeValuesStructure = new Structure("translated-text-attribute-values",$t->translatedTextAttributeId, $t->attributeObjectId, $t->translatedTextAttribute, $t->translatedTextValueId, $t->translatedTextValue); |
205 | 205 | $t->translatedTextAttributeValues = new Attribute(null, wfMsgSc("TranslatedTextAttributeValues"), $t->translatedTextAttributeValuesStructure); |
206 | 206 | $t->attributeObject = new Attribute("attribute-object-id", "Attribute object", "object-id"); |
| 207 | + |
207 | 208 | $t->textAttributeId = new Attribute("text-attribute-id", "Attribute identifier", "object-id"); |
208 | 209 | $t->textAttributeObject = new Attribute("text-attribute-object-id", "Attribute object", "object-id"); |
209 | 210 | $t->textAttribute = new Attribute("text-attribute", wfMsgSc("TextAttribute"), $t->definedMeaningReferenceStructure); |
210 | 211 | $t->textAttributeValuesStructure = new Structure("text-attribute-values", $t->textAttributeId, $t->textAttributeObject, $t->textAttribute, $t->text); |
211 | 212 | $t->textAttributeValues = new Attribute(null, wfMsgSc("TextAttributeValues"), $t->textAttributeValuesStructure); |
| 213 | + |
212 | 214 | $t->linkLabel = new Attribute("label", "Label", "short-text"); |
213 | 215 | $t->linkURL = new Attribute("url", "URL", "url"); |
214 | 216 | $t->link = new Attribute("link", "Link", new Structure($t->linkLabel, $t->linkURL)); |
215 | | - |
216 | 217 | $t->linkAttributeId = new Attribute("link-attribute-id", "Attribute identifier", "object-id"); |
217 | 218 | $t->linkAttributeObject = new Attribute("link-attribute-object-id", "Attribute object", "object-id"); |
218 | 219 | $t->linkAttribute = new Attribute("link-attribute", wfMsgSc("LinkAttribute"), $t->definedMeaningReferenceStructure); |
219 | 220 | $t->linkAttributeValuesStructure = new Structure("link-attribute-values", $t->linkAttributeId, $t->linkAttributeObject, $t->linkAttribute, $t->link); |
220 | 221 | $t->linkAttributeValues = new Attribute(null, wfMsgSc("LinkAttributeValues"), $t->linkAttributeValuesStructure); |
| 222 | + |
221 | 223 | $t->optionAttributeId = new Attribute("option-attribute-id", "Attribute identifier", "object-id"); |
222 | 224 | $t->optionAttributeObject = new Attribute("option-attribute-object-id", "Attribute object", "object-id"); |
223 | 225 | $t->optionAttribute = new Attribute("option-attribute", wfMsgSc("OptionAttribute"), $definedMeaningReferenceType); |
— | — | @@ -253,7 +255,6 @@ |
254 | 256 | $t->classAttributes, |
255 | 257 | $t->alternativeDefinitions, |
256 | 258 | $t->synonymsAndTranslations, |
257 | | - $t->relations, |
258 | 259 | $t->reciprocalRelations, |
259 | 260 | $t->classMembership, |
260 | 261 | $t->collectionMembership, |
— | — | @@ -268,8 +269,17 @@ |
269 | 270 | $t->expressionMeanings = new Attribute(null, wfMsgSc("ExpressionMeanings"), $t->expressionMeaningsStructure); |
270 | 271 | $t->expressionsStructure = new Structure("expressions", $t->expressionId, $t->expression, $t->expressionMeanings); |
271 | 272 | $t->expressions = new Attribute(null, wfMsgSc("Expressions"), $t->expressionsStructure); |
| 273 | + |
272 | 274 | $t->objectId = new Attribute("object-id", "Object identifier", "object-id"); |
273 | | - $t->objectAttributesStructure = new Structure("object-attributes", $t->objectId, $t->textAttributeValues, $t->translatedTextAttributeValues, $t->linkAttributeValues, $t->optionAttributeValues); |
| 275 | + $t->objectAttributesStructure = new Structure("object-attributes", |
| 276 | + $t->objectId, |
| 277 | + $t->relations, |
| 278 | + $t->textAttributeValues, |
| 279 | + $t->translatedTextAttributeValues, |
| 280 | + $t->linkAttributeValues, |
| 281 | + $t->optionAttributeValues |
| 282 | + ); |
| 283 | + |
274 | 284 | $t->objectAttributes->setAttributeType($t->objectAttributesStructure); |
275 | 285 | $t->definedMeaningAttributes->setAttributeType($t->objectAttributesStructure); |
276 | 286 | |
Index: trunk/extensions/Wikidata/OmegaWiki/Controller.php |
— | — | @@ -266,31 +266,6 @@ |
267 | 267 | } |
268 | 268 | } |
269 | 269 | |
270 | | -class DefinedMeaningRelationController implements UpdateController { |
271 | | - public function add($keyPath, $record) { |
272 | | - |
273 | | - $o=OmegaWikiAttributes::getInstance(); |
274 | | - |
275 | | - $definedMeaningId = $keyPath->peek(0)->definedMeaningId; |
276 | | - $relationTypeId = $record->relationType; |
277 | | - $otherDefinedMeaningId = $record->otherDefinedMeaning; |
278 | | - |
279 | | - if ($relationTypeId != 0 && $otherDefinedMeaningId != 0) |
280 | | - addRelation($definedMeaningId, $relationTypeId, $otherDefinedMeaningId); |
281 | | - } |
282 | | - |
283 | | - public function remove($keyPath) { |
284 | | - |
285 | | - $o=OmegaWikiAttributes::getInstance(); |
286 | | - |
287 | | - $relationId = $keyPath->peek(0)->relationId; |
288 | | - removeRelationWithId($relationId); |
289 | | - } |
290 | | - |
291 | | - public function update($keyPath, $record) { |
292 | | - } |
293 | | -} |
294 | | - |
295 | 270 | class GroupedRelationTypeController implements UpdateController { |
296 | 271 | protected $relationTypeId; |
297 | 272 | protected $groupedRelationIdAttribute; |
— | — | @@ -486,6 +461,25 @@ |
487 | 462 | } |
488 | 463 | } |
489 | 464 | |
| 465 | +class DefinedMeaningAttributeValuesController extends ObjectAttributeValuesController { |
| 466 | + public function add($keyPath, $record) { |
| 467 | + $objectId = $this->objectIdFetcher->fetch($keyPath); |
| 468 | + $definedMeaningAttributeId = $record->relationType; |
| 469 | + $definedMeaningValue = $record->otherDefinedMeaning; |
| 470 | + |
| 471 | + if ($definedMeaningAttributeId != 0 && $definedMeaningValue != "") |
| 472 | + addRelation($objectId, $definedMeaningAttributeId, $definedMeaningValue); |
| 473 | + } |
| 474 | + |
| 475 | + public function remove($keyPath) { |
| 476 | + $valueId = $keyPath->peek(0)->relationId; |
| 477 | + removeRelationWithId($valueId); |
| 478 | + } |
| 479 | + |
| 480 | + public function update($keyPath, $record) { |
| 481 | + } |
| 482 | +} |
| 483 | + |
490 | 484 | class TextAttributeValuesController extends ObjectAttributeValuesController { |
491 | 485 | public function add($keyPath, $record) { |
492 | 486 | |
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiEditors.php |
— | — | @@ -243,6 +243,7 @@ |
244 | 244 | |
245 | 245 | function initializeObjectAttributeEditors(ViewInformation $viewInformation) { |
246 | 246 | global |
| 247 | + $definedMeaningValueObjectAttributesEditors, |
247 | 248 | $textValueObjectAttributesEditors, |
248 | 249 | $linkValueObjectAttributesEditors, |
249 | 250 | $translatedTextValueObjectAttributesEditors, |
— | — | @@ -251,9 +252,10 @@ |
252 | 253 | |
253 | 254 | $o=OmegaWikiAttributes::getInstance($viewInformation); |
254 | 255 | |
255 | | - $linkValueObjectAttributesEditors = array(); |
| 256 | + $definedMeaningValueObjectAttributesEditors = array(); |
256 | 257 | $textValueObjectAttributesEditors = array(); |
257 | 258 | $translatedTextValueObjectAttributesEditors = array(); |
| 259 | + $linkValueObjectAttributesEditors = array(); |
258 | 260 | $optionValueObjectAttributesEditors = array(); |
259 | 261 | |
260 | 262 | foreach ($viewInformation->getPropertyToColumnFilters() as $propertyToColumnFilter) { |
— | — | @@ -262,6 +264,7 @@ |
263 | 265 | $valueCaption = $propertyToColumnFilter->getValueCaption(); |
264 | 266 | $attributeIDfilter = $propertyToColumnFilter->getAttributeIDFilter(); |
265 | 267 | |
| 268 | + $definedMeaningValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($attribute, $propertyCaption, $valueCaption, $viewInformation, $annotationMeaningName, $attributeIDfilter); |
266 | 269 | $textValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($attribute, $propertyCaption, $valueCaption, $viewInformation, $annotationMeaningName, $attributeIDfilter); |
267 | 270 | $linkValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($attribute, $propertyCaption, $valueCaption, $viewInformation, $annotationMeaningName, $attributeIDfilter); |
268 | 271 | $translatedTextValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($attribute, $propertyCaption, $valueCaption, $viewInformation, $annotationMeaningName, $attributeIDfilter); |
— | — | @@ -270,11 +273,15 @@ |
271 | 274 | |
272 | 275 | $leftOverAttributeIdFilter = $viewInformation->getLeftOverAttributeFilter(); |
273 | 276 | |
274 | | - $textValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($o->objectAttributes, wfMsgSc("Property"), wfMsgSc("Value"), $viewInformation, $annotationMeaningName, $leftOverAttributeIdFilter); |
| 277 | + $definedMeaningValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($o->objectAttributes, wfMsgSc("Property"), wfMsgSc("Value"), $viewInformation, $annotationMeaningName, $leftOverAttributeIdFilter); |
| 278 | + $textValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($o->objectAttributes, wfMsgSc("Property"), wfMsgSc("Value"), $viewInformation, $annotationMeaningName, $leftOverAttributeIdFilter); |
275 | 279 | $linkValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($o->objectAttributes, wfMsgSc("Property"), wfMsgSc("Value"), $viewInformation, $annotationMeaningName, $leftOverAttributeIdFilter); |
276 | 280 | $translatedTextValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($o->objectAttributes, wfMsgSc("Property"), wfMsgSc("Value"), $viewInformation, $annotationMeaningName, $leftOverAttributeIdFilter); |
277 | 281 | $optionValueObjectAttributesEditors[] = new ObjectAttributeValuesEditor($o->objectAttributes, wfMsgSc("Property"), wfMsgSc("Value"), $viewInformation, $annotationMeaningName, $leftOverAttributeIdFilter); |
278 | 282 | |
| 283 | + foreach ($definedMeaningValueObjectAttributesEditors as $definedMeaningValueObjectAttributesEditor) |
| 284 | + addObjectAttributesEditors($definedMeaningValueObjectAttributesEditor, $viewInformation, new ObjectIdFetcher(0, $o->relationType)); |
| 285 | + |
279 | 286 | foreach ($textValueObjectAttributesEditors as $textValueObjectAttributesEditor) |
280 | 287 | addObjectAttributesEditors($textValueObjectAttributesEditor, $viewInformation, new ObjectIdFetcher(0, $o->textAttributeId)); |
281 | 288 | |
— | — | @@ -419,6 +426,7 @@ |
420 | 427 | $attributeIDFilter = $objectAttributesEditor->getAttributeIDfilter(); |
421 | 428 | $annotationLevelName = $objectAttributesEditor->getLevelName(); |
422 | 429 | |
| 430 | + $objectAttributesEditor->addEditor(getDefinedMeaningAttributeValuesEditor($viewInformation, new DefinedMeaningAttributeValuesController($annotatedObjectIdFetcher), $annotationLevelName, $attributeIDFilter)); |
423 | 431 | $objectAttributesEditor->addEditor(getTextAttributeValuesEditor($viewInformation, new TextAttributeValuesController($annotatedObjectIdFetcher), $annotationLevelName, $attributeIDFilter)); |
424 | 432 | $objectAttributesEditor->addEditor(getTranslatedTextAttributeValuesEditor($viewInformation, new TranslatedTextAttributeValuesController($annotatedObjectIdFetcher, $viewInformation->filterLanguageId), $annotationLevelName, $attributeIDFilter)); |
425 | 433 | $objectAttributesEditor->addEditor(getLinkAttributeValuesEditor($viewInformation, new LinkAttributeValuesController($annotatedObjectIdFetcher), $annotationLevelName, $attributeIDFilter)); |
— | — | @@ -538,23 +546,19 @@ |
539 | 547 | return $tableEditor; |
540 | 548 | } |
541 | 549 | |
542 | | -function getDefinedMeaningRelationsEditor(ViewInformation $viewInformation) { |
| 550 | +function getDefinedMeaningAttributeValuesEditor(ViewInformation $viewInformation, UpdateController $controller, $levelDefinedMeaningName, AttributeIDFilter $attributeIDFilter) { |
543 | 551 | global |
544 | | - $relationsObjectAttributesEditor, $relationMeaningName, $wgPopupAnnotationName; |
| 552 | + $definedMeaningValueObjectAttributesEditors; |
545 | 553 | |
546 | 554 | $o=OmegaWikiAttributes::getInstance(); |
547 | 555 | |
548 | | - $editor = new RecordSetTableEditor($o->relations, new SimplePermissionController(true), new ShowEditFieldChecker(true), new AllowAddController(true), true, false, new DefinedMeaningRelationController()); |
549 | | - $editor->addEditor(new RelationTypeReferenceEditor($o->relationType, new SimplePermissionController(false), true)); |
| 556 | + $showEditFieldChecker = new ShowEditFieldForAttributeValuesChecker($levelDefinedMeaningName, "DM", $attributeIDFilter); |
| 557 | + |
| 558 | + $editor = new RecordSetTableEditor($o->relations, new SimplePermissionController(true), $showEditFieldChecker, new AllowAddController(true), true, false, $controller); |
| 559 | + $editor->addEditor(new DefinedMeaningAttributeEditor($o->relationType, new SimplePermissionController(false), true, $levelDefinedMeaningName)); |
550 | 560 | $editor->addEditor(new DefinedMeaningReferenceEditor($o->otherDefinedMeaning, new SimplePermissionController(false), true)); |
551 | | - |
552 | | - addPropertyToColumnFilterEditors($editor, $viewInformation, $o->relationId, $relationMeaningName); |
553 | | - |
554 | | - $editor->addEditor(new PopUpEditor( |
555 | | - createObjectAttributesEditor($viewInformation, $o->objectAttributes, wfMsgSc("Property"), wfMsgSc("Value"), $o->relationId, $relationMeaningName, $viewInformation->getLeftOverAttributeFilter()), |
556 | | - $wgPopupAnnotationName |
557 | | - )); |
558 | 561 | |
| 562 | + addPopupEditors($editor, $definedMeaningValueObjectAttributesEditors); |
559 | 563 | addTableMetadataEditors($editor, $viewInformation); |
560 | 564 | |
561 | 565 | return $editor; |
— | — | @@ -810,7 +814,6 @@ |
811 | 815 | $alternativeDefinitionsEditor = getAlternativeDefinitionsEditor($viewInformation); |
812 | 816 | $classAttributesEditor = getClassAttributesEditor($viewInformation); |
813 | 817 | $synonymsAndTranslationsEditor = getSynonymsAndTranslationsEditor($viewInformation); |
814 | | - $relationsEditor = getDefinedMeaningRelationsEditor($viewInformation); |
815 | 818 | $reciprocalRelationsEditor = getDefinedMeaningReciprocalRelationsEditor($viewInformation); |
816 | 819 | $classMembershipEditor = getDefinedMeaningClassMembershipEditor($viewInformation); |
817 | 820 | $collectionMembershipEditor = getDefinedMeaningCollectionMembershipEditor($viewInformation); |
— | — | @@ -830,7 +833,6 @@ |
831 | 834 | $availableEditors->addEditor($alternativeDefinitionsEditor); |
832 | 835 | $availableEditors->addEditor($classAttributesEditor); |
833 | 836 | $availableEditors->addEditor($synonymsAndTranslationsEditor); |
834 | | - $availableEditors->addEditor($relationsEditor); |
835 | 837 | $availableEditors->addEditor($reciprocalRelationsEditor); |
836 | 838 | $availableEditors->addEditor($classMembershipEditor); |
837 | 839 | $availableEditors->addEditor($collectionMembershipEditor); |
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiRecordSets.php |
— | — | @@ -561,6 +561,7 @@ |
562 | 562 | $record = new ArrayRecord($o->definedMeaningAttributes->type); |
563 | 563 | |
564 | 564 | $record->objectId = $objectId; |
| 565 | + $record->relations = getDefinedMeaningAttributeValuesRecordSet(array($objectId), array(), $viewInformation); |
565 | 566 | $record->textAttributeValues = getTextAttributesValuesRecordSet(array($objectId), $viewInformation); |
566 | 567 | $record->translatedTextAttributeValues = getTranslatedTextAttributeValuesRecordSet(array($objectId), $viewInformation); |
567 | 568 | $record->linkAttributeValues = getLinkAttributeValuesRecordSet(array($objectId), $viewInformation); |
— | — | @@ -588,12 +589,17 @@ |
589 | 590 | } |
590 | 591 | |
591 | 592 | function filterObjectAttributesRecord(Record $sourceRecord, array &$attributeIds) { |
592 | | - |
593 | 593 | $o=OmegaWikiAttributes::getInstance(); |
594 | 594 | |
595 | 595 | $result = new ArrayRecord($sourceRecord->getStructure()); |
596 | 596 | $result->objectId = $sourceRecord->objectId; |
597 | 597 | |
| 598 | + $result->setAttributeValue($o->relations, filterAttributeValues( |
| 599 | + $sourceRecord->relations, |
| 600 | + $o->relationType, |
| 601 | + $attributeIds |
| 602 | + )); |
| 603 | + |
598 | 604 | $result->setAttributeValue($o->textAttributeValues, filterAttributeValues( |
599 | 605 | $sourceRecord->textAttributeValues, |
600 | 606 | $o->textAttribute, |
— | — | @@ -622,32 +628,29 @@ |
623 | 629 | } |
624 | 630 | |
625 | 631 | function getTranslatedContentValue($translatedContentId, ViewInformation $viewInformation) { |
626 | | - |
627 | 632 | $o=OmegaWikiAttributes::getInstance(); |
628 | 633 | |
629 | 634 | if ($viewInformation->filterLanguageId == 0) { |
630 | 635 | return getTranslatedContentRecordSet($translatedContentId, $viewInformation); |
631 | 636 | |
632 | | - } else { |
| 637 | + } |
| 638 | + else { |
633 | 639 | $recordSet = getFilteredTranslatedContentRecordSet($translatedContentId, $viewInformation); |
634 | 640 | |
635 | 641 | if (count($viewInformation->queryTransactionInformation->versioningAttributes()) > 0) |
636 | 642 | return $recordSet; |
637 | 643 | else { |
638 | | - if ($recordSet->getRecordCount() > 0) { |
| 644 | + if ($recordSet->getRecordCount() > 0) |
639 | 645 | return $recordSet->getRecord(0)->text; |
640 | | - } else |
| 646 | + else |
641 | 647 | return ""; |
642 | 648 | } |
643 | 649 | } |
644 | 650 | } |
645 | 651 | |
646 | 652 | function getTranslatedContentRecordSet($translatedContentId, ViewInformation $viewInformation) { |
647 | | - |
648 | | - $o=OmegaWikiAttributes::getInstance(); |
649 | 653 | global |
650 | 654 | $translatedContentTable; |
651 | | - |
652 | 655 | |
653 | 656 | $o=OmegaWikiAttributes::getInstance(); |
654 | 657 | |
— | — | @@ -754,6 +757,16 @@ |
755 | 758 | $objectAttributesRecords[$objectIds[$i]] = $record; |
756 | 759 | } |
757 | 760 | |
| 761 | + // Defined meaning attributes |
| 762 | + $allDefinedMeaningAttributeValuesRecordSet = getDefinedMeaningAttributeValuesRecordSet($objectIds, array(), $viewInformation); |
| 763 | + $definedMeaningAttributeValuesRecordSets = |
| 764 | + splitRecordSet( |
| 765 | + $allDefinedMeaningAttributeValuesRecordSet, |
| 766 | + $o->relationType |
| 767 | + ); |
| 768 | + |
| 769 | + $emptyDefinedMeaningAttributesRecordSet = new ArrayRecordSet($allDefinedMeaningAttributeValuesRecordSet->getStructure(), $allDefinedMeaningAttributeValuesRecordSet->getKey()); |
| 770 | + |
758 | 771 | // Text attributes |
759 | 772 | $allTextAttributeValuesRecordSet = getTextAttributesValuesRecordSet($objectIds, $viewInformation); |
760 | 773 | $textAttributeValuesRecordSets = |
— | — | @@ -799,6 +812,12 @@ |
800 | 813 | $record = $recordSet->getRecord($i); |
801 | 814 | $objectId = $record->getAttributeValue($objectIdAttribute); |
802 | 815 | |
| 816 | + // Defined meaning attributes |
| 817 | + if (isset($definedMeaningAttributeValuesRecordSets[$objectId])) |
| 818 | + $definedMeaningAttributeValuesRecordSet = $definedMeaningAttributeValuesRecordSets[$objectId]; |
| 819 | + else |
| 820 | + $definedMeaningAttributeValuesRecordSet = $emptyDefinedMeaningAttributesRecordSet; |
| 821 | + |
803 | 822 | // Text attributes |
804 | 823 | if (isset($textAttributeValuesRecordSets[$objectId])) |
805 | 824 | $textAttributeValuesRecordSet = $textAttributeValuesRecordSets[$objectId]; |
— | — | @@ -825,6 +844,7 @@ |
826 | 845 | |
827 | 846 | $objectAttributesRecord = new ArrayRecord($objectAttributesRecordStructure); |
828 | 847 | $objectAttributesRecord->objectId = $objectId; |
| 848 | + $objectAttributesRecord->relations = $definedMeaningAttributeValuesRecordSet; |
829 | 849 | $objectAttributesRecord->textAttributeValues = $textAttributeValuesRecordSet; |
830 | 850 | $objectAttributesRecord->translatedTextAttributeValues = $translatedTextAttributeValuesRecordSet; |
831 | 851 | $objectAttributesRecord->linkAttributeValues = $linkAttributeValuesRecordSet; |
— | — | @@ -848,17 +868,16 @@ |
849 | 869 | return $record; |
850 | 870 | } |
851 | 871 | |
852 | | -function getDefinedMeaningRelationsRecordSet($definedMeaningId, array $filterRelationTypes, ViewInformation $viewInformation) { |
853 | | - |
854 | | - $o=OmegaWikiAttributes::getInstance(); |
| 872 | +function getDefinedMeaningAttributeValuesRecordSet(array $objectIds, array $filterRelationTypes, ViewInformation $viewInformation) { |
855 | 873 | global |
856 | 874 | $meaningRelationsTable; |
857 | 875 | |
858 | | - $restrictions = array("meaning1_mid=$definedMeaningId"); |
| 876 | + $o=OmegaWikiAttributes::getInstance(); |
| 877 | +// $restrictions = array("meaning1_mid=$definedMeaningId"); |
| 878 | +// |
| 879 | +// if (count($filterRelationTypes) > 0) |
| 880 | +// $restrictions[] = "relationtype_mid NOT IN (". implode(", ", $filterRelationTypes) .")"; |
859 | 881 | |
860 | | - if (count($filterRelationTypes) > 0) |
861 | | - $restrictions[] = "relationtype_mid NOT IN (". implode(", ", $filterRelationTypes) .")"; |
862 | | - |
863 | 882 | $recordSet = queryRecordSet( |
864 | 883 | $o->relationStructure->getStructureType(), |
865 | 884 | $viewInformation->queryTransactionInformation, |
— | — | @@ -869,7 +888,7 @@ |
870 | 889 | new TableColumnsToAttribute(array('meaning2_mid'), $o->otherDefinedMeaning) |
871 | 890 | ), |
872 | 891 | $meaningRelationsTable, |
873 | | - $restrictions, |
| 892 | + array("meaning1_mid IN (" . implode(", ", $objectIds) . ")"), |
874 | 893 | array('add_transaction_id') |
875 | 894 | ); |
876 | 895 | |
Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php |
— | — | @@ -156,7 +156,7 @@ |
157 | 157 | $record->possiblySynonymous = getPossiblySynonymousRecordSet($id, $view); |
158 | 158 | $filterRelationTypes[] = $view->possiblySynonymousRelationTypeId; |
159 | 159 | } |
160 | | - $record->relations = getDefinedMeaningRelationsRecordSet($id, $filterRelationTypes, $view); |
| 160 | + |
161 | 161 | $record->reciprocalRelations = getDefinedMeaningReciprocalRelationsRecordSet($id, $view); |
162 | 162 | $record->classMembership = getDefinedMeaningClassMembershipRecordSet($id, $view); |
163 | 163 | $record->collectionMembership= getDefinedMeaningCollectionMembershipRecordSet($id, $view); |
Index: trunk/extensions/Wikidata/OmegaWiki/Editor.php |
— | — | @@ -1254,9 +1254,10 @@ |
1255 | 1255 | class ClassAttributesTypeEditor extends SelectEditor { |
1256 | 1256 | protected function getOptions() { |
1257 | 1257 | return array( |
| 1258 | + 'DM' => 'Defined meaning', |
1258 | 1259 | 'TRNS' => 'Translatable text', |
1259 | 1260 | 'TEXT' => 'Plain text', |
1260 | | - 'URL' => 'URL', |
| 1261 | + 'URL' => 'Link', |
1261 | 1262 | 'OPTN' => 'Option list' |
1262 | 1263 | ); |
1263 | 1264 | } |
— | — | @@ -1323,6 +1324,12 @@ |
1324 | 1325 | } |
1325 | 1326 | } |
1326 | 1327 | |
| 1328 | +class DefinedMeaningAttributeEditor extends AttributeEditor { |
| 1329 | + protected function suggestType() { |
| 1330 | + return "defined-meaning-attribute"; |
| 1331 | + } |
| 1332 | +} |
| 1333 | + |
1327 | 1334 | class TextAttributeEditor extends AttributeEditor { |
1328 | 1335 | protected function suggestType() { |
1329 | 1336 | return "text-attribute"; |
— | — | @@ -1343,7 +1350,7 @@ |
1344 | 1351 | |
1345 | 1352 | class OptionAttributeEditor extends AttributeEditor { |
1346 | 1353 | protected function suggestType() { |
1347 | | - return 'option-attribute'; |
| 1354 | + return "option-attribute"; |
1348 | 1355 | } |
1349 | 1356 | |
1350 | 1357 | public function add(IdStack $idPath) { |