public function __construct( Attribute $attribute, $propertyCaption, $valueCaption, ViewInformation $viewInformation, $levelName, AttributeIDFilter $attributeIDFilter ) { parent::__construct( new RecordUnorderedListEditor( $attribute, 5 ) ); $this->levelName = $levelName; $this->attributeIDFilter = $attributeIDFilter; $this->showPropertyColumn = !$attributeIDFilter->leavesOnlyOneOption(); $this->recordSetTableEditor = new RecordSetTableEditor( $attribute, new SimplePermissionController( false ), new ShowEditFieldChecker( true ), new AllowAddController( false ), false, false, null ); $this->propertyAttribute = new Attribute( "property", $propertyCaption, "short-text" ); $this->valueAttribute = new Attribute( "value", $valueCaption, "short-text" ); foreach ( $viewInformation->getPropertyToColumnFilters() as $propertyToColumnFilter ) $this->recordSetTableEditor->addEditor( new DummyViewer( $propertyToColumnFilter->getAttribute() ) ); $o = OmegaWikiAttributes::getInstance(); $this->recordSetTableEditor->addEditor( new DummyViewer( $o->objectAttributes ) ); addTableMetadataEditors( $this->recordSetTableEditor, $viewInformation ); }
function expandObjectAttributesAttribute( RecordSet $recordSet, Attribute $attributeToExpand, Attribute $objectIdAttribute, ViewInformation $viewInformation ) { $o = OmegaWikiAttributes::getInstance(); $recordSetStructure = $recordSet->getStructure(); $recordSetStructure->addAttribute( $attributeToExpand ); foreach ( $viewInformation->getPropertyToColumnFilters() as $propertyToColumnFilter ) $recordSetStructure->addAttribute( $propertyToColumnFilter->getAttribute() ); $objectAttributesRecordStructure = $attributeToExpand->type; $objectIds = getUniqueIdsInRecordSet( $recordSet, array( $objectIdAttribute ) ); if ( count( $objectIds ) > 0 ) { for ( $i = 0; $i < count( $objectIds ); $i++ ) if ( isset( $objectIds[$i] ) ) { $record = new ArrayRecord( $objectAttributesRecordStructure ); $objectAttributesRecords[$objectIds[$i]] = $record; } // Defined meaning attributes $allDefinedMeaningAttributeValuesRecordSet = getDefinedMeaningAttributeValuesRecordSet( $objectIds, $viewInformation ); $definedMeaningAttributeValuesRecordSets = splitRecordSet( $allDefinedMeaningAttributeValuesRecordSet, $o->relationType ); $emptyDefinedMeaningAttributesRecordSet = new ArrayRecordSet( $allDefinedMeaningAttributeValuesRecordSet->getStructure(), $allDefinedMeaningAttributeValuesRecordSet->getKey() ); // Text attributes $allTextAttributeValuesRecordSet = getTextAttributesValuesRecordSet( $objectIds, $viewInformation ); $textAttributeValuesRecordSets = splitRecordSet( $allTextAttributeValuesRecordSet, $o->textAttributeObject ); $emptyTextAttributesRecordSet = new ArrayRecordSet( $allTextAttributeValuesRecordSet->getStructure(), $allTextAttributeValuesRecordSet->getKey() ); // Translated text attributes $allTranslatedTextAttributeValuesRecordSet = getTranslatedTextAttributeValuesRecordSet( $objectIds, $viewInformation ); $translatedTextAttributeValuesRecordSets = splitRecordSet( $allTranslatedTextAttributeValuesRecordSet, $o->attributeObject ); $emptyTranslatedTextAttributesRecordSet = new ArrayRecordSet( $allTranslatedTextAttributeValuesRecordSet->getStructure(), $allTranslatedTextAttributeValuesRecordSet->getKey() ); // Link attributes $allLinkAttributeValuesRecordSet = getLinkAttributeValuesRecordSet( $objectIds, $viewInformation ); $linkAttributeValuesRecordSets = splitRecordSet( $allLinkAttributeValuesRecordSet, $o->linkAttributeObject ); $emptyLinkAttributesRecordSet = new ArrayRecordSet( $allLinkAttributeValuesRecordSet->getStructure(), $allLinkAttributeValuesRecordSet->getKey() ); // Option attributes $allOptionAttributeValuesRecordSet = getOptionAttributeValuesRecordSet( $objectIds, $viewInformation ); $optionAttributeValuesRecordSets = splitRecordSet( $allOptionAttributeValuesRecordSet, $o->optionAttributeObject ); $emptyOptionAttributesRecordSet = new ArrayRecordSet( $allOptionAttributeValuesRecordSet->getStructure(), $allOptionAttributeValuesRecordSet->getKey() ); for ( $i = 0; $i < $recordSet->getRecordCount(); $i++ ) { $record = $recordSet->getRecord( $i ); $objectId = $record->getAttributeValue( $objectIdAttribute ); // Defined meaning attributes if ( isset( $definedMeaningAttributeValuesRecordSets[$objectId] ) ) $definedMeaningAttributeValuesRecordSet = $definedMeaningAttributeValuesRecordSets[$objectId]; else $definedMeaningAttributeValuesRecordSet = $emptyDefinedMeaningAttributesRecordSet; // Text attributes if ( isset( $textAttributeValuesRecordSets[$objectId] ) ) $textAttributeValuesRecordSet = $textAttributeValuesRecordSets[$objectId]; else $textAttributeValuesRecordSet = $emptyTextAttributesRecordSet; // Translated text attributes if ( isset( $translatedTextAttributeValuesRecordSets[$objectId] ) ) $translatedTextAttributeValuesRecordSet = $translatedTextAttributeValuesRecordSets[$objectId]; else $translatedTextAttributeValuesRecordSet = $emptyTranslatedTextAttributesRecordSet; // Link attributes if ( isset( $linkAttributeValuesRecordSets[$objectId] ) ) $linkAttributeValuesRecordSet = $linkAttributeValuesRecordSets[$objectId]; else $linkAttributeValuesRecordSet = $emptyLinkAttributesRecordSet; // Option attributes if ( isset( $optionAttributeValuesRecordSets[$objectId] ) ) $optionAttributeValuesRecordSet = $optionAttributeValuesRecordSets[$objectId]; else $optionAttributeValuesRecordSet = $emptyOptionAttributesRecordSet; $objectAttributesRecord = new ArrayRecord( $objectAttributesRecordStructure ); $objectAttributesRecord->objectId = $objectId; $objectAttributesRecord->relations = $definedMeaningAttributeValuesRecordSet; $objectAttributesRecord->textAttributeValues = $textAttributeValuesRecordSet; $objectAttributesRecord->translatedTextAttributeValues = $translatedTextAttributeValuesRecordSet; $objectAttributesRecord->linkAttributeValues = $linkAttributeValuesRecordSet; $objectAttributesRecord->optionAttributeValues = $optionAttributeValuesRecordSet; $record->setAttributeValue( $attributeToExpand, $objectAttributesRecord ); applyPropertyToColumnFiltersToRecord( $record, $objectAttributesRecord, $viewInformation ); } } }