public static function attributeOutputData( ezpContentField $field )
    {
        // @TODO move to datatype representation layer
        switch ( $field->data_type_string )
        {
            case 'ezxmltext':
                $html = $field->content->attribute( 'output' )->attribute( 'output_text' );
                $attributeValue = array( strip_tags( $html ) );
                break;
            case 'ezimage':
                $strRepImage = $field->toString();
                $delimPos = strpos( $strRepImage, '|' );
                if ( $delimPos !== false )
                {
                    $strRepImage = substr( $strRepImage, 0, $delimPos );
                }
                $attributeValue = array( $strRepImage );
                break;
            default:
                $datatypeBlacklist = array_fill_keys(
                    eZINI::instance()->variable( 'ContentSettings', 'DatatypeBlackListForExternal' ),
                    true
                );
                if ( isset ( $datatypeBlacklist[$field->data_type_string] ) )
                    $attributeValue = array( null );
                else
                    $attributeValue = array( $field->toString() );
                break;
        }

        // cleanup values so that the result is consistent:
        // - no array if one item
        // - false if no values
        if ( count( $attributeValue ) == 0 )
        {
            $attributeValue = false;
        }
        else if ( count( $attributeValue ) == 1 )
        {
            $attributeValue = current( $attributeValue );
        }

        return array(
            'type'                  => $field->data_type_string,
            'identifier'            => $field->contentclass_attribute_identifier,
            'value'                 => $attributeValue,
            'id'                    => (int)$field->id,
            'classattribute_id'     => (int)$field->contentclassattribute_id
        );
    }
public static function attributeOutputData( ezpContentField $field )
    {
        // @TODO move to datatype representation layer
        switch ( $field->data_type_string )
        {
            case 'ezxmltext':
                $html = $field->content->attribute( 'output' )->attribute( 'output_text' );
                $attributeValue = array( strip_tags( $html ) );
                break;
            case 'ezimage':
                $strRepImage = $field->toString();
                $delimPos = strpos( $strRepImage, '|' );
                if ( $delimPos !== false )
                {
                    $strRepImage = substr( $strRepImage, 0, $delimPos );
                }
                $attributeValue = array( $strRepImage );
                break;
            default:
                $datatypeBlacklist = array_fill_keys(
                    eZINI::instance()->variable( 'ContentSettings', 'DatatypeBlackListForExternal' ),
                    true
                );
                if ( isset ( $datatypeBlacklist[$field->data_type_string] ) )
                    $attributeValue = array( null );
                else
                    $attributeValue = array( $field->toString() );
                break;
        }

        // cleanup values so that the result is consistent:
        // - no array if one item
        // - false if no values
        if ( count( $attributeValue ) == 0 )
        {
            $attributeValue = false;
        }
        else if ( count( $attributeValue ) == 1 )
        {
            $attributeValue = current( $attributeValue );
        }

        return array(
            'type'                  => $field->data_type_string,
            'identifier'            => $field->contentclass_attribute_identifier,
            'value'                 => $attributeValue,
            'id'                    => (int)$field->id,
            'classattribute_id'     => (int)$field->contentclassattribute_id
        );
    }
public static function attributeOutputData ( ezpContentField $ field ) { // @TODO move to datatype representation layer switch ( $ field -> data_type_string ) { case 'ezxmltext' : $ html = $ field -> content -> attribute ( 'output' ) -> attribute ( 'output_text' ) ; $ attributeValue = array ( strip_tags ( $ html ) ) ; break ; case 'ezimage' : $ strRepImage = $ field -> toString ( ) ; $ delimPos = strpos ( $ strRepImage , '|' ) ; if ( $ delimPos !== false ) { $ strRepImage = substr ( $ strRepImage , 0 , $ delimPos ) ; } $ attributeValue = array ( $ strRepImage ) ; break ; default : $ datatypeBlacklist = array_fill_keys ( eZINI :: instance ( ) -> variable ( 'ContentSettings' , 'DatatypeBlackListForExternal' ) , true ) ; if ( isset ( $ datatypeBlacklist [ $ field -> data_type_string ] ) ) $ attributeValue = array ( null ) ; else $ attributeValue = array ( $ field -> toString ( ) ) ; break ; } // cleanup values so that the result is consistent: // - no array if one item // - false if no values if ( count ( $ attributeValue ) == 0 ) { $ attributeValue = false ; } else if ( count ( $ attributeValue ) == 1 ) { $ attributeValue = current ( $ attributeValue ) ; } return array ( 'type' => $ field -> data_type_string , 'identifier' => $ field -> contentclass_attribute_identifier , 'value' => $ attributeValue , 'id' => ( int ) $ field -> id , 'classattribute_id' => ( int ) $ field -> contentclassattribute_id ) ; }
Transforms an ezpContentField in an array representation
@todo Refactor, this doesn't really belong here. Either in ezpContentField, or in an extend class
@param ezpContentField $field
@return array Associative array with following keys :
- type => Field type (datatype string)
- identifier => Attribute identifier
- value => String representation of field content
- id => Attribute numerical ID
- classattribute_id => Numerical class attribute ID
Transforms an ezpContentField in an array representation