/** * @return array */ public function getData() { $contentClassAttribute = $this->ContentObjectAttribute->attribute( 'contentclass_attribute' ); switch( $contentClassAttribute->attribute( 'identifier' ) ) { case 'additional_keywords': $data = parent::getData(); $content = $data['attr_' . $contentClassAttribute->attribute('identifier') . '_t']; $data['attr_' . $contentClassAttribute->attribute('identifier') . '_lk'] = $content[0]; unset($data['attr_' . $contentClassAttribute->attribute('identifier') . '_t']); return $data; break; default: return parent::getData(); break; } }
/** * @see ezfSolrDocumentFieldBase::getData() */ public function getData() { $returnArray = parent::getData(); $contentClassAttributeIdentifier = $this->ContentObjectAttribute->ContentClassAttributeIdentifier; $eZType = eZDataType::create( $this->ContentObjectAttribute->DataTypeString ); $attributeContent = $eZType->getValues( $this->ContentObjectAttribute->ID ); foreach( $attributeContent as $key => $value ) { if ( $value > 0 ) { $suffix = self::getPostFix( $contentClassAttributeIdentifier ); $attribute = 'attr_'.$contentClassAttributeIdentifier.'_'.$key.$suffix; $returnArray[$attribute] = $value; } } return $returnArray; }
/** * @see ezfSolrDocumentFieldBase::getData() * @return array */ public function getData() { $data = parent::getData(); $content = $this->ContentObjectAttribute->content(); /* @var $content array */ foreach ( array_merge( self::taxonomyAttribute(), array_keys($content) ) as $taxonomyIdentifier ) { $taxonomyValues = isset( $content[$taxonomyIdentifier] ) ? $content[$taxonomyIdentifier] : array(); $subattrSourceIdValues = array(); $subattrSourceIdFieldName = self::getCustomSubattributeFieldName( $taxonomyIdentifier, 'source_id'); foreach ( $taxonomyValues as $taxonomyValue ) { if( preg_match( '#^symptom_.*$#', $taxonomyValue ) ) { $sourceKey = $taxonomyValue; $subattrSourceIdValues[] = $sourceKey; // we need a few more things for the symptoms /* @type $node eZContentObjectTreeNode */ $contentObject = $this->ContentObjectAttribute->object(); $node = $contentObject->mainNode(); $clusters = NodeTool::getArticleClusters($node); foreach( $clusters as $cluster ) { ClusterTool::setCurrentCluster($cluster); $ini = eZINI::fetchFromFile('extension/'.$cluster.'/settings/site.ini'); $node->setCurrentLanguage( $ini->variable('RegionalSettings', 'ContentObjectLocale') ); $applicationLocalized = CacheApplicationTool::buildLocalizedApplicationByIdentifier( MerckManualShowcase::mainApplicationIdentifier() ); if ( !$applicationLocalized ) continue; $customSymptomAttributeKey = 'attr_custom_symptom_'.$cluster.'_s'; $labelTranslations = FacetFilteringTool::getTaxonomyTranslation( 'symptom' ); $label = $labelTranslations[$sourceKey]; $url = preg_replace( '#^[^/]+#', '', MerckManualFunctionCollection::getMerckManualNodeUrl( 'meck-manual-showcase', $node, $ini->variable('RegionalSettings', 'ContentObjectLocale') ) ); ClusterTool::resetCurrentCluster(); $customSymptomAttributeValueParts = array( mb_strtolower(mb_substr(StringTool::removeAccents( StringTool::CJK2Pinyin($label) ), 0, 1)), $label, $url ); $data[$customSymptomAttributeKey] = implode( '##', $customSymptomAttributeValueParts ); } } else if ( preg_match('#^222\.[0-9]+$#', $taxonomyValue ) ) { $sourceKey = $taxonomyValue; $subattrSourceIdValues[] = $sourceKey; /* @type $node eZContentObjectTreeNode */ /* @type $dataMap eZContentObjectAttribute[] */ $contentObject = $this->ContentObjectAttribute->object(); $node = $contentObject->mainNode(); $clusters = NodeTool::getArticleClusters($node); $customSymptomAttributeValueParts = array( $content['layer_natom'][0], $content['sub_layer_natom'][0], ); foreach( $clusters as $cluster ) { ClusterTool::setCurrentCluster($cluster); $customSymptomAttributeKey = 'attr_custom_layer_sublayer_natom_'.$cluster.'_s'; $data[$customSymptomAttributeKey] = implode( '##', $customSymptomAttributeValueParts ); ClusterTool::resetCurrentCluster(); } } else $subattrSourceIdValues[] = trim( $taxonomyValue ); } $data[$subattrSourceIdFieldName] = empty($subattrSourceIdValues) ? '' : $subattrSourceIdValues; } return $data; }
/** * Add instance of ezfSolrDocumentFieldBase to Solr document. * * @param ezfSolrDocumentFieldBase Instance of ezfSolrDocumentFieldBase * @param eZSolrDoc Solr document */ function addFieldBaseToDoc( ezfSolrDocumentFieldBase $fieldBase, eZSolrDoc $doc, $boost = false ) { $fieldBaseData = $fieldBase->getData(); if ( empty( $fieldBaseData ) ) { if ( is_object( $fieldBase ) ) { $contentClassAttribute = $fieldBase->ContentObjectAttribute->attribute( 'contentclass_attribute' ); $fieldName = $fieldBase->getFieldName( $contentClassAttribute ); $errorMessage = 'empty array for ' . $fieldName; } else { $errorMessage = '$fieldBase not an object'; } eZDebug::writeNotice( $errorMessage , __METHOD__ ); return false; } else { foreach ( $fieldBaseData as $key => $value ) { // since ezfind 2.3, a NULL value returned from $fieldBase in the $value elements is used as a flag not to index if ( !is_null( $value ) ) { $doc->addField( $key, $value, $boost ); } } return true; } }