/*!
Returns the attributes for the current content object version.
If \a $language is not specified it will use the initial language of the version.
765504
function contentObjectAttributes( $languageCode = false, $asObject = true )
    {
        if ( $languageCode == false )
        {
            if ( $this->Status == eZContentObjectVersion::STATUS_DRAFT || $this->Status == eZContentObjectVersion::STATUS_INTERNAL_DRAFT || $this->Status == eZContentObjectVersion::STATUS_PENDING )
            {
                $languageCode = $this->initialLanguageCode();
            }
            else if ( $this->CurrentLanguage )
            {
                $languageCode = $this->CurrentLanguage;
            }
        }

        return eZContentObjectVersion::fetchAttributes( $this->Version, $this->ContentObjectID, $languageCode, $asObject );
    }
978066
function objectAttributeContent( $contentObjectAttribute )
    {
        $value = $contentObjectAttribute->attribute( 'data_text' );

        $countryList = explode( ',', $value );
        $resultList = array();
        foreach ( $countryList as $alpha2 )
        {
            $eZCountry = eZCountryType::fetchCountry( $alpha2, 'Alpha2' );
            $resultList[$alpha2] = $eZCountry ? $eZCountry : '';
        }
        // Supporting of previous version format.
        // For backwards compatibility.
        if ( count( $resultList ) == 1 and $resultList[$value] == '' )
            $resultList = $value;

        $content = array( 'value' => $resultList );
        return $content;
    }
785773
function metaData( $contentObjectAttribute )
    {
        $metaData = "";

        $dom = new DOMDocument( '1.0', 'utf-8' );
        $text = eZXMLTextType::rawXMLText( $contentObjectAttribute );
        if ( trim( $text ) == '' )
        {
            return $metaData;
        }
        $success = $dom->loadXML( $text );

        if ( $success )
        {
            $metaData = trim( eZXMLTextType::concatTextContent( $dom->documentElement ) );
        }
        return $metaData;
    }
534610
function originalAttributeData()
    {
        $contentObjectAttributeData = $this->ContentObjectAttributeData;
        if ( isset( $contentObjectAttributeData['DataTypeCustom']['original_data'] ) )
            return $contentObjectAttributeData['DataTypeCustom']['original_data'];

        $originalData = array( 'attribute_id' => $contentObjectAttributeData['id'],
                               'attribute_version' => $contentObjectAttributeData['version'],
                               'attribute_language' => $contentObjectAttributeData['language_code'] );
        $this->setOriginalAttributeData( $originalData );
        return $originalData;
    }
532187
function getBaseList( eZContentObjectVersion $objectVersion )
    {
        $returnList = array();
        // Get ezfSolrDocumentFieldBase instance for all attributes in related object
        if ( eZContentObject::recursionProtect( $this->ContentObjectAttribute->attribute( 'contentobject_id' ) ) )
        {
            foreach ( $objectVersion->contentObjectAttributes( $this->ContentObjectAttribute->attribute( 'language_code' ) ) as $attribute )
            {
                if ( $attribute->attribute( 'contentclass_attribute' )->attribute( 'is_searchable' ) )
                {
                    $returnList[] = ezfSolrDocumentFieldBase::getInstance( $attribute );
                }
            }
        }
        return $returnList;
    }
1257289
function initializeObjectAttribute( $contentObjectAttribute, $currentVersion, $originalContentObjectAttribute )
    {
        if ( $currentVersion == false )
        {
            $option = $contentObjectAttribute->content();
            $contentClassAttribute = $contentObjectAttribute->contentClassAttribute();
            if ( !$option )
            {
                $option = new eZRangeOption( $contentClassAttribute->attribute( 'data_text1' ) );
            }
            else
            {
                $option->setName( $contentClassAttribute->attribute( 'data_text1' ) );
            }
            $contentObjectAttribute->setAttribute( "data_text", $option->xmlString() );
            $contentObjectAttribute->setContent( $option );
        }
    }
911488
function attribute( $name )
    {
        if ( $name === 'is_editor_enabled' )
            $attr = self::isEditorEnabled();
        else if ( $name === 'can_disable' )
            $attr = $this->currentUserHasAccess( 'disable_editor' );
        else if ( $name === 'editor_layout_settings' )
            $attr = $this->getEditorLayoutSettings();
        else if ( $name === 'browser_supports_dhtml_type' )
            $attr = self::browserSupportsDHTMLType();
        else if ( $name === 'is_compatible_version' )
            $attr = $this->isCompatibleVersion();
        else if ( $name === 'version' )
            $attr = self::version();
        else if ( $name === 'ezpublish_version' )
            $attr = $this->eZPublishVersion;
        else if ( $name === 'xml_tag_alias' )
            $attr =  self::getXmlTagAliasList();
        else if ( $name === 'json_xml_tag_alias' )
            $attr =  json_encode( self::getXmlTagAliasList() );
        else
            $attr = parent::attribute( $name );
        return $attr;
    }
16952
function metaData( $contentObjectAttribute )
    {
        $selected = $this->objectAttributeContent( $contentObjectAttribute );
        $classContent = $this->classAttributeContent( $contentObjectAttribute->attribute( 'contentclass_attribute' ) );
        $return = '';
        if ( count( $selected ) == 0)
        {
            return '';
        }

        $count = 0;
        $optionArray = $classContent['options'];
        foreach ( $selected as $id )
        {
            if ( $count++ != 0 )
                $return .= ' ';
            foreach ( $optionArray as $option )
            {
                $optionID = $option['id'];
                if ( $optionID == $id )
                    $return .= $option['name'];
            }
        }
        return $return;
    }
1345941
function objectAttributeContent( $contentObjectAttribute )
    {
        $objectId = $contentObjectAttribute->attribute('contentobject_id');
        $attributeId = $contentObjectAttribute->attribute('id');
        $ratingObj = null;
        if ( $objectId && $attributeId )
        {
            $ratingObj = ezsrRatingObject::fetchByObjectId( $objectId, $attributeId );
    
            // Create empty object if none could be fetched
            if (  !$ratingObj instanceof ezsrRatingObject )
            {
                $ratingObj = ezsrRatingObject::create( array('contentobject_id' => $objectId,
                                                             'contentobject_attribute_id' => $attributeId ) );
            }
        }
        return $ratingObj;
    }
1263096
function translationList( $language = false, $asObject = true )
    {
        $db = eZDB::instance();

        $languageSQL = '';
        if ( $language !== false )
        {
            $language = $db->escapeString( $language );
            $languageSQL = "AND language_code!='$language'";
        }

        $query = "SELECT DISTINCT language_code
                  FROM ezcontentobject_attribute
                  WHERE contentobject_id='$this->ContentObjectID' AND version='$this->Version'
                  $languageSQL
                  ORDER BY language_code";

        $languageCodes = $db->arrayQuery( $query );

        $translations = array();
        if ( $asObject )
        {
            foreach ( $languageCodes as $languageCode )
            {
                $translations[] = new eZContentObjectTranslation( $this->ContentObjectID, $this->Version, $languageCode["language_code"] );
            }
        }
        else
        {
            foreach ( $languageCodes as $languageCode )
            {
                $translations[] = $languageCode["language_code"];
            }
        }

        return $translations;
    }
941335
function fetchAttributeTranslations( $asObject = true )
    {
        return eZPersistentObject::fetchObjectList( eZContentObjectAttribute::definition(),
                                                    null,
                                                    array( "contentclassattribute_id" => $this->ContentClassAttributeID,
                                                           "contentobject_id" => $this->ContentObjectID,
                                                           "version" => $this->Version ),
                                                    null,
                                                    null,
                                                    $asObject);
    }
1232698
function objectAttributeContent( $contentObjectAttribute )
    {
        if ( $contentObjectAttribute->attribute( 'data_int' ) != 0 )
        {
           $gmapObject = eZGmapLocation::fetch( $contentObjectAttribute->attribute( 'id' ), $contentObjectAttribute->attribute( 'version' ) );
           if ( !$gmapObject instanceof eZGmapLocation )
           {
               $gmapObject = eZGmapLocation::create( $contentObjectAttribute->attribute( 'id' ), $contentObjectAttribute->attribute( 'version' ), '', '' );
               // This happens when attribute is cloned, since sync() is called before init() on attribute.
               //eZDebug::writeWarning( 'eZGmapLocation::fetch returned empty, even though data_int says there is content. Might be data corruption! ' . var_export(debug_backtrace( false ), true), __METHOD__ );
           }
        }
        else
        {
    	   $gmapObject = eZGmapLocation::create( $contentObjectAttribute->attribute( 'id' ), $contentObjectAttribute->attribute( 'version' ), '', '' );
        }

        return $gmapObject;
    }
1090858
function initializeObjectAttribute( $contentObjectAttribute, $currentVersion, $originalContentObjectAttribute )
    {
        if ( $currentVersion != false )
        {
            $contentObjectAttributeID = $originalContentObjectAttribute->attribute( "id" );
            $version = $contentObjectAttribute->attribute( "version" );
            $oldfile = eZBinaryFile::fetch( $contentObjectAttributeID, $currentVersion );
            if ( $oldfile != null )
            {
                $oldfile->setAttribute( 'contentobject_attribute_id', $contentObjectAttribute->attribute( 'id' ) );
                $oldfile->setAttribute( "version",  $version );
                $oldfile->store();
            }
        }
    }
1110387
function title( $contentObjectAttribute, $name = null )
    {
        $locale = eZLocale::instance();
        $retVal = $contentObjectAttribute->attribute( "data_int" ) === null ? '' : $locale->formatDate( $contentObjectAttribute->attribute( "data_int" ) );
        return $retVal;
    }
1029570
private function getNamesForAllLanguages(array $contentInfo)
    {
        $nameDataArray = $this->contentGateway->loadVersionedNameData([
            [
                'id' => $contentInfo['id'],
                'version' => $contentInfo['current_version'],
            ],
        ]);

        $namesForAllLanguages = [];
        foreach ($nameDataArray as $nameData) {
            $namesForAllLanguages[$nameData['ezcontentobject_name_content_translation']]
                = $nameData['ezcontentobject_name_name'];
        }

        return $namesForAllLanguages;
    }
253101
function contentObjectName( eZContentObject $contentObject, $version = false, $translation = false )
    {
        $contentObjectNamePattern = $this->ContentObjectName;

        $ini = eZINI::instance();
        $length = (int) $ini->variable('ContentSettings', 'ContentObjectNameLimit');
        $sequence = $ini->variable('ContentSettings', 'ContentObjectNameLimitSequence');
        if ( $length < 1 || $length > self::CONTENT_OBJECT_NAME_MAX_LENGTH )
        {
            $length = self::CONTENT_OBJECT_NAME_MAX_LENGTH;
        }
        $nameResolver = new eZNamePatternResolver( $contentObjectNamePattern, $contentObject, $version, $translation );
        $contentObjectName = $nameResolver->resolveNamePattern( $length, $sequence );

        return $contentObjectName;
    }
1251777
function objectAttributeContent( $contentObjectAttribute )
    {
        $paexID = $contentObjectAttribute->attribute( "contentobject_id" );
        $paex = eZPaEx::fetch( $paexID );
        return $paex;
    }