/** * @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; }
public static function fetchSymptomsLetters($related_infos = false) { if ( is_null(self::$_symptomsLetters) ) { $field = 'attr_custom_symptom_'.ClusterTool::clusterIdentifier().'_s'; $params = array( 'indent' => 'on', 'q' => '', 'start' => 0, 'rows' => 0, 'fl' => 'score', 'qt' => 'ezpublish', 'explainOther' => '', 'hl.fl' => '', 'facet' => 'true', 'facet.field' => $field, 'facet.mincount' => 1 ); $solrResult = self::rawSearch($params); $translations = FacetFilteringTool::getTaxonomyTranslation( 'symptom' ); $letters = array(); foreach( $solrResult['facet_counts']['facet_fields'][$field] as $key => $v) { list( $letter, $symptomLabel, $url ) = explode('##', $key); if( !isset($letters[$letter]) ) $letters[$letter] = array(); $letters[$letter][$symptomLabel] = $url; } ksort($letters); foreach ( $letters as $letter => $symptoms) { uksort($symptoms, function($a, $b) { return strcmp(StringTool::CJK2Pinyin($a), StringTool::CJK2Pinyin($b)); }); $letters[$letter] = $symptoms; } self::$_symptomsLetters = $letters; } return array( 'result' => self::$_symptomsLetters ); }