/** * Get solr field name, from base name. The base name may either be a * meta-data name, or an eZ Publish content class attribute, specified by * <class identifier>/<attribute identifier>[/<option>] * * @param string $baseName Base field name. * @param boolean $includingClassID conditions the structure of the answer. See return value explanation. * @param $context is introduced in ez find 2.2 to allow for more optimal sorting, faceting, filtering * * @return mixed Internal base name. Returns null if no valid base name was provided. * If $includingClassID is true, an associative array will be returned, as shown below : * <code> * array( 'fieldName' => 'attr_title_t', * 'contentClassId' => 16 ); * </code> */ static function getFieldName( $baseName, $includingClassID = false, $context = 'search' ) { // If the base name is a meta field, get the correct field name. if ( eZSolr::hasMetaAttributeType( $baseName, $context ) ) { return eZSolr::getMetaFieldName( $baseName, $context ); } else { // Get class and attribute identifiers + optional option. $subattribute = null; $fieldDef = explode( '/', $baseName ); // Check if content class attribute ID is provided. if ( is_numeric( $fieldDef[0] ) ) { if ( count( $fieldDef ) == 1 ) { $contentClassAttributeID = $fieldDef[0]; } else if ( count( $fieldDef ) == 2 ) { list( $contentClassAttributeID, $subattribute ) = $fieldDef; } } else { switch( count( $fieldDef ) ) { case 1: { // Return fieldname as is. return $baseName; } break; case 2: { // Field def contains class indentifier and class attribute identifier. list( $classIdentifier, $attributeIdentifier ) = $fieldDef; } break; case 3: { // Field def contains class indentifier, class attribute identifier and optional specification. list( $classIdentifier, $attributeIdentifier, $subattribute ) = $fieldDef; } break; } $contentClassAttributeID = eZContentObjectTreeNode::classAttributeIDByIdentifier( $classIdentifier . '/' . $attributeIdentifier ); } if ( !$contentClassAttributeID ) { eZDebug::writeNotice( 'Could not get content class from base name: ' . $baseName, __METHOD__ ); return null; } $contentClassAttribute = eZContentClassAttribute::fetch( $contentClassAttributeID ); $fieldName = ezfSolrDocumentFieldBase::getFieldName( $contentClassAttribute, $subattribute, $context ); if ( $includingClassID ) { return array( 'fieldName' => $fieldName, 'contentClassId' => $contentClassAttribute->attribute( 'contentclass_id' ) ); } else return $fieldName; } }