diff --git a/classes/ezfsolrdocumentfieldbase.php b/classes/ezfsolrdocumentfieldbase.php index 0ce3548b..f99093e2 100644 --- a/classes/ezfsolrdocumentfieldbase.php +++ b/classes/ezfsolrdocumentfieldbase.php @@ -233,6 +233,23 @@ public static function getFieldNameList( eZContentClassAttribute $classAttribute } } + $customAttributeMap = $eZFindIni->variable('SolrFieldMapSettings', 'CustomAttributeMap'); + if ($customAttributeMap) { + $identifier = $classAttribute->attribute('identifier'); + $contentClass = eZContentClass::fetch($classAttribute->attribute('contentclass_id')); + $identifierComposite = sprintf( + '%s/%s', + $contentClass->attribute('identifier'), + $identifier + ); + if (array_key_exists($identifierComposite, $customAttributeMap)) { + $returnValue = call_user_func_array([$customAttributeMap[$identifierComposite], 'getFieldNameList'], [$classAttribute, $exclusiveTypeFilter]); + if ($returnValue) { + return $returnValue; + } + } + } + // fallback behaviour : if ( empty( $exclusiveTypeFilter ) or !in_array( self::getClassAttributeType( $classAttribute ), $exclusiveTypeFilter ) ) return array( self::getFieldName( $classAttribute ) ); @@ -303,7 +320,22 @@ public static function getFieldName( eZContentClassAttribute $classAttribute, $s static function getInstance( eZContentObjectAttribute $objectAttribute ) { $eZFindIni = eZINI::instance( 'ezfind.ini' ); - + + $attributeMapList = $eZFindIni->variable('SolrFieldMapSettings', 'CustomAttributeMap'); + if (!empty($attributeMapList)) { + $contentClassId = $objectAttribute->attribute('contentclass_attribute')->attribute('contentclass_id'); + $contentClass = eZContentClass::fetch($contentClassId); + $identifierComposite = sprintf( + '%s/%s', + $contentClass->attribute('identifier'), + $objectAttribute->attribute('contentclass_attribute_identifier') + ); + if (array_key_exists($identifierComposite, $attributeMapList)) { + return self::$singletons[$objectAttribute->attribute('id')] = new $attributeMapList[$identifierComposite]($objectAttribute); + } + unset($identifierComposite, $contentClass); + } + $datatypeString = $objectAttribute->attribute( 'data_type_string' ); // Check if using custom handler. diff --git a/search/plugins/ezsolr/ezsolr.php b/search/plugins/ezsolr/ezsolr.php index ae7cef2f..2e2e6e55 100644 --- a/search/plugins/ezsolr/ezsolr.php +++ b/search/plugins/ezsolr/ezsolr.php @@ -1654,11 +1654,14 @@ protected function buildResultObjects( $resultArray, &$searchCount, $asObjects = { $tmpNodeRowList = array( $tmpNodeRowList ); } - if ( $tmpNodeRowList ) - { - foreach ( $tmpNodeRowList as $nodeRow ) - { - $nodeRowList[$nodeRow['node_id']] = $nodeRow; + + if ($tmpNodeRowList) { + if (isset($tmpNodeRowList[0])) { + foreach ($tmpNodeRowList as $nodeRow) { + $nodeRowList[$nodeRow['node_id']] = $nodeRow; + } + } else { + $nodeRowList[$tmpNodeRowList['node_id']] = $tmpNodeRowList; } } unset( $tmpNodeRowList ); diff --git a/settings/ezfind.ini b/settings/ezfind.ini index 8ef3cb06..f23430e5 100644 --- a/settings/ezfind.ini +++ b/settings/ezfind.ini @@ -166,11 +166,11 @@ DatatypeMapFilter[ezselection]=string Default=text -#Allows to have specific handlers for atributes instead of generalizing it for datatypes -#This makes it easier for example to store structured content inside eztext attributes +# Allows to have specific handlers for atributes instead of generalizing it for datatypes +# This makes it easier for example to store structured content inside eztext attributes +# YourCustomMapperClass should extend ezfSolrDocumentFieldBase and overwrite the getFieldNameList and getData methods CustomAttributeMap[] -# -#CustomAttributeMap[class_identifier/attribute_identifier]=ezfSolrDocumentFieldMetaData +#CustomAttributeMap[class_identifier/attribute_identifier]=YourCustomMapperClass [IndexOptions]