Path

ez projects / data_import / forum / general / datatype ezenum


datatype ezenum

You need to be logged in to post messages in the forums. New users may register here.

Bin LIU

Member since:
11 May 2007

Posts: 15

Friday 19 September 2008 2:18:35 pm

I added the datatype ezenum in save attribute
	


 

function save_eZ_attribute( $contentObjectAttribute )


{       


        switch( $contentObjectAttribute->attribute( 'data_type_string' ) )


        {


                case 'ezenum':


                        //from string not supported. donc method traditionnal


                        //normalement, pas besoinde include_once, mais je ne sais pas pourquoi il ne trouve pas la class ezEnumValue.donc je le met en provisoire


                        include_once('kernel/classes/datatypes/ezenum/ezenumvalue.php');


                        $contentObjectAttributeID               = $contentObjectAttribute->attribute( 'id' );


                        $contentObjectAttributeVersion  = $contentObjectAttribute->attribute( 'version' );


                        $contentClassAttribute                  = $contentObjectAttribute->attribute( 'contentclass_attribute' );


                        $contentClassAttributeID                = $contentClassAttribute->attribute('id' );


                        $contentClassAttributeVersion   = $contentClassAttribute->attribute('version' );


                        $array_enumValue                                = ezEnumValue::fetchAllElements( $contentClassAttributeID, $contentClassAttributeVersion );


                        eZEnum::removeObjectEnumerations( $contentObjectAttributeID, $contentObjectAttributeVersion );


                        if(is_array($this->source_handler->getValueFromField()))


                        {


                                $array_selectedEnumElement = $this->source_handler->getValueFromField();


                        }


                        else


                        {


                                $array_selectedEnumElement = array($this->source_handler->getValueFromField());


                        }


                        foreach( $array_enumValue as $enumValue ) {


                                foreach( $array_selectedEnumElement as $selectedEnumElement ) {


                                        if( $enumValue->EnumElement === $selectedEnumElement ) {


                                                eZEnum::storeObjectEnumeration( $contentObjectAttributeID,$contentObjectAttributeVersion, $enumValue->ID,$enumValue->EnumElement, $enumValue->EnumValue );


                                        }


                                }


                        }


                        $contentObjectAttribute->store();


                break;


        }


}

=== Freelance Expert Ezpublish ===

Up

You need to be logged in to post messages in the forums. New users may register here.