kernel/classes/ezcontentobjectattribute.php
function cloneContentObjectAttribute( $newVersionNumber, $currentVersionNumber, $contentObjectID = false, $newLanguageCode = false )
    {
        $tmp = clone $this;
        $tmp->setAttribute( "version", $newVersionNumber );
        if ( $contentObjectID != false )
        {
            // if copying the whole object
            if ( $contentObjectID != $tmp->attribute( 'contentobject_id' ) )
            {
                $exAttr =  eZPersistentObject::fetchObject( eZContentObjectAttribute::definition(),
                                                            null,
                                                            array( 'contentobject_id'         => $contentObjectID,
                                                                   'contentclassattribute_id' => $tmp->attribute( 'contentclassattribute_id' ),
                                                                   'language_code'            => $tmp->attribute( 'language_code' ) ),
                                                            true );

                // if the new object already contains the same attribute with another version
                if ( is_object( $exAttr ) )
                    // we take attribute id from it
                    $id = $exAttr->attribute( 'id' );
                else
                    // otherwise new attribute id will be generated
                    $id = null;

                $tmp->setAttribute( 'id', $id );
            }
            $tmp->setAttribute( 'contentobject_id', $contentObjectID );
        }
        else
        {
            // if not copying, we will remove the information on which language has to be always shown
            $tmp->setAttribute( 'language_id', $tmp->attribute( 'language_id' ) & ~1 );
        }

        if ( $newLanguageCode != false && $tmp->attribute( 'language_code' ) != $newLanguageCode )
        {
            $exAttr = eZPersistentObject::fetchObject( eZContentObjectAttribute::definition(),
                                                       null,
                                                       array( 'contentobject_id'         => $contentObjectID? $contentObjectID: $tmp->attribute( 'contentobject_id' ),
                                                              'contentclassattribute_id' => $tmp->attribute( 'contentclassattribute_id' ),
                                                              'language_code'            => $newLanguageCode ),
                                                       true );
            // if the new object already contains the same attribute with another version
            if ( is_object( $exAttr ) )
            {
                $id = $exAttr->attribute( 'id' );
            }
            else
            {
                $id = null;
            }
            $tmp->setAttribute( 'id', $id );
            $tmp->setAttribute( 'language_code', $newLanguageCode );
            $tmp->setAttribute( 'language_id', eZContentLanguage::idByLocale( $newLanguageCode ) );
        }

        $db = eZDB::instance();
        $db->begin();
        $tmp->sync();
        $tmp->initialize( $currentVersionNumber, $this );
        $tmp->sync();
        $tmp->postInitialize( $currentVersionNumber, $this );
        $db->commit();

        return $tmp;
    }
function cloneContentObjectAttribute( $newVersionNumber, $currentVersionNumber, $contentObjectID = false, $newLanguageCode = false )
    {
        $tmp = clone $this;
        $tmp->setAttribute( "version", $newVersionNumber );
        if ( $contentObjectID != false )
        {
            // if copying the whole object
            if ( $contentObjectID != $tmp->attribute( 'contentobject_id' ) )
            {
                $exAttr =  eZPersistentObject::fetchObject( eZContentObjectAttribute::definition(),
                                                            null,
                                                            array( 'contentobject_id'         => $contentObjectID,
                                                                   'contentclassattribute_id' => $tmp->attribute( 'contentclassattribute_id' ),
                                                                   'language_code'            => $tmp->attribute( 'language_code' ) ),
                                                            true );

                // if the new object already contains the same attribute with another version
                if ( is_object( $exAttr ) )
                    // we take attribute id from it
                    $id = $exAttr->attribute( 'id' );
                else
                    // otherwise new attribute id will be generated
                    $id = null;

                $tmp->setAttribute( 'id', $id );
            }
            $tmp->setAttribute( 'contentobject_id', $contentObjectID );
        }
        else
        {
            // if not copying, we will remove the information on which language has to be always shown
            $tmp->setAttribute( 'language_id', $tmp->attribute( 'language_id' ) & ~1 );
        }

        if ( $newLanguageCode != false && $tmp->attribute( 'language_code' ) != $newLanguageCode )
        {
            $exAttr = eZPersistentObject::fetchObject( eZContentObjectAttribute::definition(),
                                                       null,
                                                       array( 'contentobject_id'         => $contentObjectID? $contentObjectID: $tmp->attribute( 'contentobject_id' ),
                                                              'contentclassattribute_id' => $tmp->attribute( 'contentclassattribute_id' ),
                                                              'language_code'            => $newLanguageCode ),
                                                       true );
            // if the new object already contains the same attribute with another version
            if ( is_object( $exAttr ) )
            {
                $id = $exAttr->attribute( 'id' );
            }
            else
            {
                $id = null;
            }
            $tmp->setAttribute( 'id', $id );
            $tmp->setAttribute( 'language_code', $newLanguageCode );
            $tmp->setAttribute( 'language_id', eZContentLanguage::idByLocale( $newLanguageCode ) );
        }

        $db = eZDB::instance();
        $db->begin();
        $tmp->sync();
        $tmp->initialize( $currentVersionNumber, $this );
        $tmp->sync();
        $tmp->postInitialize( $currentVersionNumber, $this );
        $db->commit();

        return $tmp;
    }
function cloneContentObjectAttribute ( $ newVersionNumber , $ currentVersionNumber , $ contentObjectID = false , $ newLanguageCode = false ) { $ tmp = clone $ this ; $ tmp -> setAttribute ( "version" , $ newVersionNumber ) ; if ( $ contentObjectID != false ) { // if copying the whole object if ( $ contentObjectID != $ tmp -> attribute ( 'contentobject_id' ) ) { $ exAttr = eZPersistentObject :: fetchObject ( eZContentObjectAttribute :: definition ( ) , null , array ( 'contentobject_id' => $ contentObjectID , 'contentclassattribute_id' => $ tmp -> attribute ( 'contentclassattribute_id' ) , 'language_code' => $ tmp -> attribute ( 'language_code' ) ) , true ) ; // if the new object already contains the same attribute with another version if ( is_object ( $ exAttr ) ) // we take attribute id from it $ id = $ exAttr -> attribute ( 'id' ) ; else // otherwise new attribute id will be generated $ id = null ; $ tmp -> setAttribute ( 'id' , $ id ) ; } $ tmp -> setAttribute ( 'contentobject_id' , $ contentObjectID ) ; } else { // if not copying, we will remove the information on which language has to be always shown $ tmp -> setAttribute ( 'language_id' , $ tmp -> attribute ( 'language_id' ) & ~ 1 ) ; } if ( $ newLanguageCode != false && $ tmp -> attribute ( 'language_code' ) != $ newLanguageCode ) { $ exAttr = eZPersistentObject :: fetchObject ( eZContentObjectAttribute :: definition ( ) , null , array ( 'contentobject_id' => $ contentObjectID ? $ contentObjectID : $ tmp -> attribute ( 'contentobject_id' ) , 'contentclassattribute_id' => $ tmp -> attribute ( 'contentclassattribute_id' ) , 'language_code' => $ newLanguageCode ) , true ) ; // if the new object already contains the same attribute with another version if ( is_object ( $ exAttr ) ) { $ id = $ exAttr -> attribute ( 'id' ) ; } else { $ id = null ; } $ tmp -> setAttribute ( 'id' , $ id ) ; $ tmp -> setAttribute ( 'language_code' , $ newLanguageCode ) ; $ tmp -> setAttribute ( 'language_id' , eZContentLanguage :: idByLocale ( $ newLanguageCode ) ) ; } $ db = eZDB :: instance ( ) ; $ db -> begin ( ) ; $ tmp -> sync ( ) ; $ tmp -> initialize ( $ currentVersionNumber , $ this ) ; $ tmp -> sync ( ) ; $ tmp -> postInitialize ( $ currentVersionNumber , $ this ) ; $ db -> commit ( ) ; return $ tmp ; }
Clones the attribute to a new version

@param int $newVersionNumber Target version number
@param int $currentVersionNumnber Source version number
@param int $contentObjectID
@param string $newLanguageCode

@note The cloned attribute isn't stored automatically

@return eZContentObjectAttribute The cloned attribute

@todo Deprecate this in favor of a real __clone
Clones the attribute to a new version