eZ Publish  [4.0]
ezcontentclassattribute.php
Go to the documentation of this file.
00001 <?php
00002 //
00003 // Definition of eZContentClassAttribute class
00004 //
00005 // Created on: <16-Apr-2002 11:08:14 amos>
00006 //
00007 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
00008 // SOFTWARE NAME: eZ Publish
00009 // SOFTWARE RELEASE: 4.0.x
00010 // COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS
00011 // SOFTWARE LICENSE: GNU General Public License v2.0
00012 // NOTICE: >
00013 //   This program is free software; you can redistribute it and/or
00014 //   modify it under the terms of version 2.0  of the GNU General
00015 //   Public License as published by the Free Software Foundation.
00016 //
00017 //   This program is distributed in the hope that it will be useful,
00018 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 //   GNU General Public License for more details.
00021 //
00022 //   You should have received a copy of version 2.0 of the GNU General
00023 //   Public License along with this program; if not, write to the Free
00024 //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00025 //   MA 02110-1301, USA.
00026 //
00027 //
00028 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
00029 //
00030 
00031 /*!
00032   \class eZContentClassAttribute ezcontentclassattribute.php
00033   \ingroup eZKernel
00034   \brief Encapsulates data for a class attribute
00035 
00036 */
00037 
00038 //include_once( "lib/ezdb/classes/ezdb.php" );
00039 //include_once( "kernel/classes/ezpersistentobject.php" );
00040 //include_once( 'kernel/classes/ezcontentclassattributenamelist.php' );
00041 
00042 class eZContentClassAttribute extends eZPersistentObject
00043 {
00044     function eZContentClassAttribute( $row )
00045     {
00046         $this->eZPersistentObject( $row );
00047 
00048         $this->Content = null;
00049         $this->DisplayInfo = null;
00050         $this->Module = null;
00051 
00052         $this->NameList = new eZContentClassNameList();
00053         if ( isset( $row['serialized_name_list'] ) )
00054             $this->NameList = new eZContentClassAttributeNameList( $row['serialized_name_list'] );
00055         else
00056             $this->NameList->initDefault();
00057     }
00058 
00059     static function definition()
00060     {
00061         return array( 'fields' => array( 'id' => array( 'name' => 'ID',
00062                                                         'datatype' => 'integer',
00063                                                         'default' => 0,
00064                                                         'required' => true ),
00065                                          'serialized_name_list' => array( 'name' => 'SerializedNameList',
00066                                                                           'datatype' => 'string',
00067                                                                           'default' => '',
00068                                                                           'required' => true ),
00069                                          'version' => array( 'name' => 'Version',
00070                                                              'datatype' => 'integer',
00071                                                              'default' => 0,
00072                                                              'required' => true ),
00073                                          'contentclass_id' => array( 'name' => 'ContentClassID',
00074                                                                      'datatype' => 'integer',
00075                                                                      'default' => 0,
00076                                                                      'required' => true,
00077                                                                      'foreign_class' => 'eZContentClass',
00078                                                                      'foreign_attribute' => 'id',
00079                                                                      'multiplicity' => '1..*' ),
00080                                          'identifier' => array( 'name' => 'Identifier',
00081                                                                 'datatype' => 'string',
00082                                                                 'default' => '',
00083                                                                 'required' => true ),
00084                                          'placement' => array( 'name' => 'Position',
00085                                                                'datatype' => 'integer',
00086                                                                'default' => 0,
00087                                                                'required' => true ),
00088                                          'is_searchable' => array( 'name' => 'IsSearchable',
00089                                                                    'datatype' => 'integer',
00090                                                                    'default' => 0
00091                                                                    ),
00092                                          'is_required' => array( 'name' => 'IsRequired',
00093                                                                  'datatype' => 'integer',
00094                                                                  'default' => 0,
00095                                                                  'required' => true ),
00096                                          'can_translate' => array( 'name' => 'CanTranslate',
00097                                                                    'datatype' => 'integer',
00098                                                                    'default' => 0
00099                                                                    ),
00100                                          'is_information_collector' => array( 'name' => 'IsInformationCollector',
00101                                                                               'datatype' => 'integer',
00102                                                                               'default' => 0,
00103                                                                               'required' => true ),
00104                                          'data_type_string' => array( 'name' => 'DataTypeString',
00105                                                                       'datatype' => 'string',
00106                                                                       'default' => '',
00107                                                                       'required' => true ),
00108                                          'data_int1' => array( 'name' => 'DataInt1',
00109                                                                'datatype' => 'integer',
00110                                                                'default' => 0,
00111                                                                'required' => true ),
00112                                          'data_int2' => array( 'name' => 'DataInt2',
00113                                                                'datatype' => 'integer',
00114                                                                'default' => 0,
00115                                                                'required' => true ),
00116                                          'data_int3' => array( 'name' => 'DataInt3',
00117                                                                'datatype' => 'integer',
00118                                                                'default' => 0,
00119                                                                'required' => true ),
00120                                          'data_int4' => array( 'name' => 'DataInt4',
00121                                                                'datatype' => 'integer',
00122                                                                'default' => 0,
00123                                                                'required' => true ),
00124                                          'data_float1' => array( 'name' => 'DataFloat1',
00125                                                                  'datatype' => 'float',
00126                                                                  'default' => 0,
00127                                                                  'required' => true ),
00128                                          'data_float2' => array( 'name' => 'DataFloat2',
00129                                                                  'datatype' => 'float',
00130                                                                  'default' => 0,
00131                                                                  'required' => true ),
00132                                          'data_float3' => array( 'name' => 'DataFloat3',
00133                                                                  'datatype' => 'float',
00134                                                                  'default' => 0,
00135                                                                  'required' => true ),
00136                                          'data_float4' => array( 'name' => 'DataFloat4',
00137                                                                  'datatype' => 'float',
00138                                                                  'default' => 0,
00139                                                                  'required' => true ),
00140                                          'data_text1' => array( 'name' => 'DataText1',
00141                                                                 'datatype' => 'text',
00142                                                                 'default' => '',
00143                                                                 'required' => true ),
00144                                          'data_text2' => array( 'name' => 'DataText2',
00145                                                                 'datatype' => 'text',
00146                                                                 'default' => '',
00147                                                                 'required' => true ),
00148                                          'data_text3' => array( 'name' => 'DataText3',
00149                                                                 'datatype' => 'text',
00150                                                                 'default' => '',
00151                                                                 'required' => true ),
00152                                          'data_text4' => array( 'name' => 'DataText4',
00153                                                                 'datatype' => 'text',
00154                                                                 'default' => '',
00155                                                                 'required' => true ),
00156                                          'data_text5' => array( 'name' => 'DataText5',
00157                                                                 'datatype' => 'text',
00158                                                                 'default' => '',
00159                                                                 'required' => true ) ),
00160                       'keys' => array( 'id', 'version' ),
00161                       "function_attributes" => array( "content" => "content",
00162                                                       'temporary_object_attribute' => 'instantiateTemporary',
00163                                                       'data_type' => 'dataType',
00164                                                       'display_info' => 'displayInfo',
00165                                                       'name' => 'name',
00166                                                       'nameList' => 'nameList' ),
00167                       'set_functions' => array( 'name' => 'setName' ),
00168                       'increment_key' => 'id',
00169                       'sort' => array( 'placement' => 'asc' ),
00170                       'class_name' => 'eZContentClassAttribute',
00171                       'name' => 'ezcontentclass_attribute' );
00172     }
00173 
00174     function __clone()
00175     {
00176         $this->ID = null;
00177     }
00178 
00179     /*!
00180      Creates an 'eZContentClassAttribute' object.
00181 
00182      To specify contentclassattribute name use either $optionalValues['serialized_name_list'] or
00183      combination of $optionalValues['name'] and/or $languageLocale.
00184 
00185      In case of conflict(when both 'serialized_name_list' and 'name' with/without $languageLocale
00186      are specified) 'serialized_name_list' has top priority. This means that 'name' and
00187      $languageLocale will be ingnored because 'serialized_name_list' already has all needed info
00188      about names and languages.
00189 
00190      If 'name' is specified then the contentclassattribute will have a name in $languageLocale(if specified) or
00191      in default language.
00192 
00193      If neither of 'serialized_name_list' or 'name' isn't specified then the contentclassattribute will have an empty
00194      name in 'languageLocale'(if specified) or in default language.
00195 
00196      \return 'eZContentClassAttribute' object.
00197     */
00198     static function create( $class_id, $data_type_string, $optionalValues = array(), $languageLocale = false )
00199     {
00200         $nameList = new eZContentClassAttributeNameList();
00201         if ( isset( $optionalValues['serialized_name_list'] ) )
00202             $nameList->initFromSerializedList( $optionalValues['serialized_name_list'] );
00203         else if ( isset( $optionalValues['name'] ) )
00204             $nameList->initFromString( $optionalValues['name'], $languageLocale );
00205         else
00206             $nameList->initFromString( '', $languageLocale );
00207 
00208         $row = array(
00209             'id' => null,
00210             'version' => eZContentClass::VERSION_STATUS_TEMPORARY,
00211             'contentclass_id' => $class_id,
00212             'identifier' => '',
00213             'serialized_name_list' => $nameList->serializeNames(),
00214             'is_searchable' => 1,
00215             'is_required' => 0,
00216             'can_translate' => 1,
00217             'is_information_collector' => 0,
00218             'data_type_string' => $data_type_string,
00219             'placement' => eZPersistentObject::newObjectOrder( eZContentClassAttribute::definition(),
00220                                                                'placement',
00221                                                                array( 'version' => 1,
00222                                                                       'contentclass_id' => $class_id ) ) );
00223         $row = array_merge( $row, $optionalValues );
00224         $attribute = new eZContentClassAttribute( $row );
00225 
00226         return $attribute;
00227     }
00228 
00229     function instantiate( $contentobjectID, $languageCode = false, $version = 1 )
00230     {
00231         $attribute = eZContentObjectAttribute::create( $this->attribute( 'id' ), $contentobjectID, $version, $languageCode );
00232         $attribute->initialize();
00233         $attribute->store();
00234         $attribute->postInitialize();
00235     }
00236 
00237     /*!
00238      \note The reference for the return value is required to workaround
00239            a bug with PHP references.
00240     */
00241     function instantiateTemporary( $contentobjectID = false )
00242     {
00243         return eZContentObjectAttribute::create( $this->attribute( 'id' ), $contentobjectID );
00244     }
00245 
00246     function store( $fieldFilters = null )
00247     {
00248         $dataType = $this->dataType();
00249         if ( !$dataType )
00250         {
00251             return false;
00252         }
00253 
00254         global $eZContentClassAttributeCacheListFull;
00255         unset( $eZContentClassAttributeCacheListFull );
00256         global $eZContentClassAttributeCacheList;
00257         unset( $eZContentClassAttributeCacheList[$this->attribute( 'contentclass_id' )] );
00258         global $eZContentClassAttributeCache;
00259         unset( $eZContentClassAttributeCache[$this->ID] );
00260 
00261         $dataType->preStoreClassAttribute( $this, $this->attribute( 'version' ) );
00262 
00263         $this->setAttribute( 'serialized_name_list', $this->NameList->serializeNames() );
00264 
00265         $stored = eZPersistentObject::store( $fieldFilters );
00266 
00267         // store the content data for this attribute
00268         $info = $dataType->attribute( "information" );
00269         $dataType->storeClassAttribute( $this, $this->attribute( 'version' ) );
00270 
00271         return $stored;
00272     }
00273 
00274     /*!
00275      \note Transaction unsafe. If you call several transaction unsafe methods you must enclose
00276      the calls within a db transaction; thus within db->begin and db->commit.
00277      */
00278     function storeDefined()
00279     {
00280         $dataType = $this->dataType();
00281         if ( !$dataType )
00282         {
00283             return false;
00284         }
00285 
00286         global $eZContentClassAttributeCacheListFull;
00287         unset( $eZContentClassAttributeCacheListFull );
00288         global $eZContentClassAttributeCacheList;
00289         unset( $eZContentClassAttributeCacheList[$this->attribute( 'contentclass_id' )] );
00290         global $eZContentClassAttributeCache;
00291         unset( $eZContentClassAttributeCache[$this->ID] );
00292 
00293         $db = eZDB::instance();
00294         $db->begin();
00295         $dataType->preStoreDefinedClassAttribute( $this );
00296 
00297         $this->setAttribute( 'serialized_name_list', $this->NameList->serializeNames() );
00298 
00299         $stored = eZPersistentObject::store();
00300 
00301         // store the content data for this attribute
00302         $info = $dataType->attribute( "information" );
00303         $dataType->storeDefinedClassAttribute( $this );
00304         $db->commit();
00305 
00306         return $stored;
00307     }
00308 
00309     /*!
00310      \note Transaction unsafe. If you call several transaction unsafe methods you must enclose
00311      the calls within a db transaction; thus within db->begin and db->commit.
00312      */
00313     function removeThis( $quiet = false )
00314     {
00315         $dataType = $this->dataType();
00316         if ( $dataType->isClassAttributeRemovable( $this ) )
00317         {
00318             global $eZContentClassAttributeCacheListFull;
00319             unset( $eZContentClassAttributeCacheListFull );
00320             global $eZContentClassAttributeCacheList;
00321             unset( $eZContentClassAttributeCacheList[$this->attribute( 'contentclass_id' )] );
00322             global $eZContentClassAttributeCache;
00323             unset( $eZContentClassAttributeCache[$this->ID] );
00324 
00325             $db = eZDB::instance();
00326             $db->begin();
00327             $dataType->deleteStoredClassAttribute( $this, $this->Version );
00328             eZPersistentObject::remove();
00329             $db->commit();
00330             return true;
00331         }
00332         else
00333         {
00334             if ( !$quiet )
00335             {
00336                 eZDebug::writeError( 'Datatype [' . $dataType->attribute( 'name' ) . '] can not be deleted to avoid system crash' );
00337             }
00338             return false;
00339         }
00340     }
00341 
00342     static function fetch( $id, $asObject = true, $version = eZContentClass::VERSION_STATUS_DEFINED, $field_filters = null )
00343     {
00344         $object = null;
00345         if ( $field_filters === null and $asObject and
00346              isset( $GLOBALS['eZContentClassAttributeCache'][$id][$version] ) )
00347         {
00348             $object = $GLOBALS['eZContentClassAttributeCache'][$id][$version];
00349         }
00350         if ( $object === null )
00351         {
00352             $object = eZPersistentObject::fetchObject( eZContentClassAttribute::definition(),
00353                                                        $field_filters,
00354                                                        array( 'id' => $id,
00355                                                               'version' => $version ),
00356                                                        $asObject );
00357             if ( $field_filters === null and $asObject )
00358             {
00359                 $GLOBALS['eZContentClassAttributeCache'][$id][$version] = $object;
00360             }
00361         }
00362         return $object;
00363     }
00364 
00365     static function fetchList( $asObject = true, $parameters = array() )
00366     {
00367         $parameters = array_merge( array( 'data_type' => false,
00368                                           'version' => false ),
00369                                    $parameters );
00370         $dataType = $parameters['data_type'];
00371         $version = $parameters['version'];
00372         $objects = null;
00373         if ( $asObject &&
00374              $dataType === false &&
00375              $version === false )
00376         {
00377             $objects = $GLOBALS['eZContentClassAttributeCacheListFull'];
00378         }
00379         if ( !isset( $objects ) or
00380              $objects === null )
00381         {
00382             $conditions = null;
00383             if ( $dataType !== false or
00384                  $version !== false )
00385             {
00386                 $conditions = array();
00387                 if ( $dataType !== false )
00388                     $conditions['data_type_string'] = $dataType;
00389                 if ( $version !== false )
00390                     $conditions['version'] = $version;
00391             }
00392             $objects = eZPersistentObject::fetchObjectList( eZContentClassAttribute::definition(),
00393                                                                 null, $conditions, null, null,
00394                                                                 $asObject );
00395             if ( $asObject )
00396             {
00397                 foreach ( $objects as $objectItem )
00398                 {
00399                     $objectID = $objectItem->ID;
00400                     $objectVersion = $objectItem->Version;
00401                     $GLOBALS['eZContentClassAttributeCache'][$objectID][$objectVersion] = $objectItem;
00402                 }
00403                 if (  $dataType === false && $version === false )
00404                 {
00405                     $GLOBALS['eZContentClassAttributeCacheListFull'] = $objects;
00406                 }
00407             }
00408         }
00409         return $objects;
00410     }
00411 
00412     static function fetchListByClassID( $classID, $version = eZContentClass::VERSION_STATUS_DEFINED, $asObject = true )
00413     {
00414         $objects = null;
00415         if ( $asObject )
00416         {
00417             if ( isset( $GLOBALS['eZContentClassAttributeCacheList'][$classID][$version] ) )
00418                 $objects = $GLOBALS['eZContentClassAttributeCacheList'][$classID][$version];
00419         }
00420         if ( !isset( $objects ) or
00421              $objects === null )
00422         {
00423             $cond = array( 'contentclass_id' => $classID,
00424                            'version' => $version );
00425             $objects = eZPersistentObject::fetchObjectList( eZContentClassAttribute::definition(),
00426                                                                 null, $cond, null, null,
00427                                                                 $asObject );
00428             if ( $asObject )
00429             {
00430                 foreach ( $objects as $objectItem )
00431                 {
00432                     $objectID = $objectItem->ID;
00433                     $objectVersion = $objectItem->Version;
00434                     if ( !isset( $GLOBALS['eZContentClassAttributeCache'][$objectID][$objectVersion] ) )
00435                         $GLOBALS['eZContentClassAttributeCache'][$objectID][$objectVersion] = $objectItem;
00436                 }
00437                 $GLOBALS['eZContentClassAttributeCacheList'][$classID][$version] = $objects;
00438             }
00439         }
00440         return $objects;
00441     }
00442 
00443     static function fetchFilteredList( $cond, $asObject = true )
00444     {
00445         $objectList = eZPersistentObject::fetchObjectList( eZContentClassAttribute::definition(),
00446                                                            null, $cond, null, null,
00447                                                            $asObject );
00448         if ( $asObject )
00449         {
00450             foreach ( $objectList as $objectItem )
00451             {
00452                 $objectID = $objectItem->ID;
00453                 $objectVersion = $objectItem->Version;
00454                 if ( !isset( $GLOBALS['eZContentClassAttributeCache'][$objectID][$objectVersion] ) )
00455                     $GLOBALS['eZContentClassAttributeCache'][$objectID][$objectVersion] = $objectItem;
00456             }
00457         }
00458         return $objectList;
00459     }
00460 
00461     /*!
00462      Moves the object down if $down is true, otherwise up.
00463      If object is at either top or bottom it is wrapped around.
00464      \note Transaction unsafe. If you call several transaction unsafe methods you must enclose
00465      the calls within a db transaction; thus within db->begin and db->commit.
00466     */
00467     function move( $down, $params = null )
00468     {
00469         if ( is_array( $params ) )
00470         {
00471             $pos = $params['placement'];
00472             $cid = $params['contentclass_id'];
00473             $version = $params['version'];
00474         }
00475         else
00476         {
00477             $pos = $this->Position;
00478             $cid = $this->ContentClassID;
00479             $version = $this->Version;
00480         }
00481         eZPersistentObject::reorderObject( eZContentClassAttribute::definition(),
00482                                            array( 'placement' => $pos ),
00483                                            array( 'contentclass_id' => $cid,
00484                                                   'version' => $version ),
00485                                            $down );
00486     }
00487 
00488     function dataType()
00489     {
00490         //include_once( 'kernel/classes/ezdatatype.php' );
00491         return eZDataType::create( $this->DataTypeString );
00492     }
00493 
00494     /*!
00495      \return The content for this attribute.
00496      \note The reference for the return value is required to workaround
00497            a bug with PHP references.
00498     */
00499     function content()
00500     {
00501         if ( $this->Content === null )
00502         {
00503             $dataType = $this->dataType();
00504             $this->Content = $dataType->classAttributeContent( $this );
00505         }
00506 
00507         return $this->Content;
00508     }
00509 
00510     /*!
00511      Sets the content for the current attribute
00512     */
00513     function setContent( $content )
00514     {
00515         $this->Content = $content;
00516     }
00517 
00518     /*!
00519      \return Information on how to display the class attribute.
00520              See eZDataType::classDisplayInformation() for more information on what is returned.
00521     */
00522     function displayInfo()
00523     {
00524         if ( !$this->DisplayInfo )
00525         {
00526             $dataType = $this->dataType();
00527             if ( is_object( $dataType ) )
00528             {
00529                 $this->DisplayInfo = $dataType->classDisplayInformation( $this, false );
00530             }
00531         }
00532         return $this->DisplayInfo;
00533     }
00534 
00535     /*!
00536      Executes the custom HTTP action
00537     */
00538     function customHTTPAction( $module, $http, $action )
00539     {
00540         $dataType = $this->dataType();
00541         $this->Module = $module;
00542         $dataType->customClassAttributeHTTPAction( $http, $action, $this );
00543         unset( $this->Module );
00544         $this->Module = null;
00545     }
00546 
00547     /*!
00548      \return the module which uses this attribute or \c null if no module set.
00549      \note Currently only customHTTPAction sets this.
00550     */
00551     function currentModule()
00552     {
00553         return $this->Module;
00554     }
00555 
00556     static function cachedInfo()
00557     {
00558         //include_once( 'lib/ezutils/classes/ezphpcreator.php' );
00559         eZExpiryHandler::registerShutdownFunction();
00560 
00561         $info = array();
00562         $db = eZDB::instance();
00563         $dbName = $db->DB;
00564 
00565         $cacheDir = eZSys::cacheDirectory();
00566         $phpCache = new eZPHPCreator( "$cacheDir", "sortkey_$dbName.php", '', array( 'clustering' => 'sortkey' ) );
00567         $handler = eZExpiryHandler::instance();
00568         $expiryTime = 0;
00569 
00570         if ( $handler->hasTimestamp( 'sort-key-cache' ) )
00571         {
00572             $expiryTime = $handler->timestamp( 'sort-key-cache' );
00573         }
00574 
00575         if ( $phpCache->canRestore( $expiryTime ) )
00576         {
00577             $info = $phpCache->restore( array( 'sortkey_type_array' => 'sortKeyTypeArray',
00578                                                'attribute_type_array' => 'attributeTypeArray' ) );
00579         }
00580         else
00581         {
00582             // Fetch all datatypes and id's used
00583             $query = "SELECT id, data_type_string FROM ezcontentclass_attribute";
00584             $attributeArray = $db->arrayQuery( $query );
00585 
00586             $attributeTypeArray = array();
00587             $sortKeyTypeArray = array();
00588             foreach ( $attributeArray as $attribute )
00589             {
00590                 $attributeTypeArray[$attribute['id']] = $attribute['data_type_string'];
00591                 $sortKeyTypeArray[$attribute['data_type_string']] = 0;
00592             }
00593 
00594             //include_once( 'kernel/classes/ezdatatype.php' );
00595 
00596             // Fetch datatype for every unique datatype
00597             foreach ( array_keys( $sortKeyTypeArray ) as $key )
00598             {
00599                 unset( $dataType );
00600                 $dataType = eZDataType::create( $key );
00601                 if( is_object( $dataType ) )
00602                     $sortKeyTypeArray[$key] = $dataType->sortKeyType();
00603             }
00604             unset( $dataType );
00605 
00606             // Store identifier list to cache file
00607             $phpCache->addVariable( 'sortKeyTypeArray', $sortKeyTypeArray );
00608             $phpCache->addVariable( 'attributeTypeArray', $attributeTypeArray );
00609             $phpCache->store();
00610 
00611             $info['sortkey_type_array'] = $sortKeyTypeArray;
00612             $info['attribute_type_array'] = $attributeTypeArray;
00613         }
00614 
00615         return $info;
00616     }
00617 
00618     /*!
00619      \static
00620     */
00621     static function sortKeyTypeByID( $classAttributeID )
00622     {
00623         $sortKeyType = false;
00624 
00625         $info = eZContentClassAttribute::cachedInfo();
00626         if ( isset( $info['attribute_type_array'][$classAttributeID] ) )
00627         {
00628             $classAttributeType = $info['attribute_type_array'][$classAttributeID];
00629             $sortKeyType = $info['sortkey_type_array'][$classAttributeType];
00630         }
00631 
00632         return $sortKeyType;
00633     }
00634 
00635     /*!
00636      \static
00637     */
00638     static function dataTypeByID( $classAttributeID )
00639     {
00640         $dataTypeString = false;
00641         $info = eZContentClassAttribute::cachedInfo();
00642 
00643         if ( isset( $info['attribute_type_array'][$classAttributeID] ) )
00644             $dataTypeString = $info['attribute_type_array'][$classAttributeID];
00645 
00646         return $dataTypeString;
00647     }
00648 
00649     /*!
00650       This methods relay calls to the diff method inside the datatype.
00651     */
00652     function diff( $old, $new )
00653     {
00654         $datatype = $this->dataType();
00655         $result = $datatype->diff( $old, $new );
00656         return $result;
00657     }
00658 
00659     /*!
00660      \static
00661     */
00662     static function nameFromSerializedString( $serailizedNameList, $languageLocale = false )
00663     {
00664         return eZContentClassAttributeNameList::nameFromSerializedString( $serailizedNameList, $languageLocale );
00665     }
00666 
00667     function name( $languageLocale = false )
00668     {
00669         return $this->NameList->name( $languageLocale );
00670     }
00671 
00672     function setName( $name, $languageLocale = false )
00673     {
00674         $this->NameList->setName( $name, $languageLocale );
00675     }
00676 
00677     function nameList()
00678     {
00679         return $this->NameList->nameList();
00680     }
00681 
00682     function setAlwaysAvailableLanguage( $languageLocale )
00683     {
00684         if ( $languageLocale )
00685         {
00686             $this->NameList->setAlwaysAvailableLanguage( $languageLocale );
00687         }
00688         else
00689         {
00690             $this->NameList->setAlwaysAvailableLanguage( false );
00691         }
00692     }
00693 
00694     function removeTranslation( $languageLocale )
00695     {
00696         $this->NameList->removeName( $languageLocale );
00697     }
00698 
00699 
00700     /// \privatesection
00701     /// Contains the content for this attribute
00702     public $Content;
00703     /// Contains information on how to display the current attribute in various viewmodes
00704     public $DisplayInfo;
00705     public $ID;
00706     public $Version;
00707     public $ContentClassID;
00708     public $Identifier;
00709     // serialized array of translated names
00710     public $SerializedNameList;
00711     // unserialized attribute names
00712     public $NameList;
00713     public $DataTypeString;
00714     public $Position;
00715     public $IsSearchable;
00716     public $IsRequired;
00717     public $IsInformationCollector;
00718     public $Module;
00719 }
00720 
00721 ?>