|
eZ Publish
[4.0]
|
00001 <?php 00002 // 00003 // Definition of eZContentObjectAttribute class 00004 // 00005 // Created on: <22-Apr-2002 09:31:57 bf> 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 eZContentObjectAttribute ezcontentobjectattribute.php 00033 \ingroup eZKernel 00034 \brief Encapsulates the data for an object attribute 00035 00036 \sa eZContentObject eZContentClass eZContentClassAttribute 00037 */ 00038 00039 //include_once( "lib/ezdb/classes/ezdb.php" ); 00040 //include_once( "kernel/classes/ezpersistentobject.php" ); 00041 //include_once( "kernel/classes/ezcontentobject.php" ); 00042 //include_once( "kernel/classes/ezcontentclassattribute.php" ); 00043 //include_once( 'kernel/classes/ezdatatype.php' ); 00044 //include_once( 'kernel/classes/ezcontentlanguage.php' ); 00045 00046 class eZContentObjectAttribute extends eZPersistentObject 00047 { 00048 /*! 00049 */ 00050 function eZContentObjectAttribute( $row ) 00051 { 00052 $this->Content = null; 00053 $this->DisplayInfo = null; 00054 $this->HTTPValue = null; 00055 $this->ValidationError = null; 00056 $this->ValidationLog = null; 00057 $this->ContentClassAttributeIdentifier = null; 00058 $this->ContentClassAttributeID = null; 00059 $this->InputParameters = false; 00060 $this->HasValidationError = false; 00061 $this->DataTypeCustom = null; 00062 $this->eZPersistentObject( $row ); 00063 } 00064 00065 static function definition() 00066 { 00067 return array( "fields" => array( "id" => array( 'name' => 'ID', 00068 'datatype' => 'integer', 00069 'default' => 0, 00070 'required' => true ), 00071 "contentobject_id" => array( 'name' => "ContentObjectID", 00072 'datatype' => 'integer', 00073 'default' => 0, 00074 'required' => true, 00075 'foreign_class' => 'eZContentObject', 00076 'foreign_attribute' => 'id', 00077 'multiplicity' => '1..*' ), 00078 "version" => array( 'name' => "Version", 00079 'datatype' => 'integer', 00080 'default' => 0, 00081 'required' => true ), 00082 "language_code" => array( 'name' => "LanguageCode", 00083 'datatype' => 'string', 00084 'default' => '', 00085 'required' => true ), 00086 'language_id' => array( 'name' => "LanguageID", 00087 'datatype' => 'integer', 00088 'default' => '0', 00089 'required' => true, 00090 'foreign_class' => 'eZContentLanguage', 00091 'foreign_attribute' => 'id', 00092 'multiplicity' => '1..*' ), 00093 "contentclassattribute_id" => array( 'name' => "ContentClassAttributeID", 00094 'datatype' => 'integer', 00095 'default' => 0, 00096 'required' => true, 00097 'foreign_class' => 'eZContentClassAttribute', 00098 'foreign_attribute' => 'id', 00099 'multiplicity' => '1..*' ), 00100 "attribute_original_id" => array( 'name' => "AttributeOriginalID", 00101 'datatype' => 'integer', 00102 'default' => 0, 00103 'required' => true, 00104 'foreign_class' => 'eZContentObjectAttribute', 00105 'foreign_attribute' => 'id', 00106 'multiplicity' => '1..*' ), 00107 "sort_key_int" => array( 'name' => "SortKeyInt", 00108 'datatype' => 'integer', 00109 'default' => '0', 00110 'required' => true ), 00111 "sort_key_string" => array( 'name' => "SortKeyString", 00112 'datatype' => 'string', 00113 'max_length' => 255, 00114 'default' => '', 00115 'required' => true ), 00116 "data_type_string" => array( 'name' => "DataTypeString", 00117 'datatype' => 'string', 00118 'default' => '', 00119 'required' => true ), 00120 "data_text" => array( 'name' => "DataText", 00121 'datatype' => 'text', 00122 'default' => '', 00123 'required' => true ), 00124 "data_int" => array( 'name' => "DataInt", 00125 'datatype' => 'integer', 00126 'default' => null, 00127 'required' => false ), 00128 "data_float" => array( 'name' => "DataFloat", 00129 'datatype' => 'float', 00130 'default' => 0, 00131 'required' => true ) ), 00132 "keys" => array( "id", "contentobject_id", "version", "language_code" ), 00133 "function_attributes" => array( "contentclass_attribute" => "contentClassAttribute", 00134 "contentclass_attribute_identifier" => "contentClassAttributeIdentifier", 00135 "contentclass_attribute_name" => "contentClassAttributeName", 00136 "can_translate" => "contentClassAttributeCanTranslate", 00137 "is_information_collector" => "contentClassAttributeIsInformationCollector", 00138 "is_required" => "contentClassAttributeIsRequired", 00139 "content" => "content", 00140 'has_http_value' => 'hasHTTPValue', 00141 'value' => 'value', 00142 'has_content' => 'hasContent', 00143 "class_content" => "classContent", 00144 "object" => "object", 00145 'object_version' => 'objectVersion', 00146 'view_template' => 'viewTemplateName', 00147 'edit_template' => 'editTemplateName', 00148 'result_template' => 'resultTemplate', 00149 "has_validation_error" => "hasValidationError", 00150 "validation_error" => "validationError", 00151 "validation_log" => "validationLog", 00152 "language" => "language", 00153 "is_a" => "isA", 00154 'display_info' => 'displayInfo', 00155 'class_display_info' => 'classDisplayInfo' ), 00156 "increment_key" => "id", 00157 "class_name" => "eZContentObjectAttribute", 00158 "sort" => array( "id" => "asc" ), 00159 "name" => "ezcontentobject_attribute" ); 00160 } 00161 00162 static function fetch( $id, $version, $asObject = true, $field_filters = null ) 00163 { 00164 return eZPersistentObject::fetchObject( eZContentObjectAttribute::definition(), 00165 $field_filters, 00166 array( "id" => $id, 00167 "version" => $version ), 00168 $asObject ); 00169 } 00170 00171 static function fetchListByClassID( $id, $version = false, $limit = null, $asObject = true, $asCount = false ) 00172 { 00173 $conditions = array(); 00174 if ( is_array( $id ) ) 00175 $conditions['contentclassattribute_id'] = array( $id ); 00176 else 00177 $conditions['contentclassattribute_id'] = $id; 00178 if ( $version !== false ) 00179 $conditions["version"] = $version; 00180 $fieldFilters = null; 00181 $customFields = null; 00182 if ( $asCount ) 00183 { 00184 $limit = null; 00185 $asObject = false; 00186 $fieldFilters = array(); 00187 $customFields = array( array( 'operation' => 'count( id )', 00188 'name' => 'count' ) ); 00189 } 00190 $objectList = eZPersistentObject::fetchObjectList( eZContentObjectAttribute::definition(), 00191 $fieldFilters, 00192 $conditions, 00193 ( $asCount ? false : null ), 00194 $limit, 00195 $asObject, 00196 null, 00197 $customFields ); 00198 if ( $asCount ) 00199 { 00200 return $objectList[0]['count']; 00201 } 00202 else 00203 { 00204 return $objectList; 00205 } 00206 } 00207 00208 static function fetchByClassAttributeID( $classAttributeID, $objectID, $version, $languageID, $asObject = true ) 00209 { 00210 return eZPersistentObject::fetchObject( eZContentObjectAttribute::definition(), 00211 null, 00212 array( 'contentclassattribute_id' => $classAttributeID, 00213 'contentobject_id' => $objectID, 00214 'version' => $version, 00215 'language_id' => $languageID ), 00216 $asObject ); 00217 } 00218 00219 /*! 00220 Fetches all contentobject attributes which relates to the contentclass attribute \a $contentClassAttributeID. 00221 \return An array with contentobject attributes. 00222 \param $contentClassAttributeID The ID of the contentclass attribute 00223 \param $asObject If \c true objects will be returned, otherwise associative arrays are returned. 00224 \param $version The version the of contentobject attributes to fetch or all version if \c false. 00225 \param $contentObjectID The ID the of contentobject to fetch or all objects if \c false. 00226 */ 00227 static function fetchSameClassAttributeIDList( $contentClassAttributeID, $asObject = true, $version = false, $contentObjectID = false ) 00228 { 00229 $conditions = array( "contentclassattribute_id" => $contentClassAttributeID ); 00230 if ( $version !== false ) 00231 $conditions['version'] = $version; 00232 if ( $contentObjectID !== false ) 00233 $conditions['contentobject_id'] = $contentObjectID; 00234 return eZPersistentObject::fetchObjectList( eZContentObjectAttribute::definition(), 00235 null, 00236 $conditions, 00237 null, 00238 null, 00239 $asObject); 00240 } 00241 00242 /*! 00243 \return the attributes with alternative translations for the current attribute version and class attribute id 00244 */ 00245 function fetchAttributeTranslations( $asObject = true ) 00246 { 00247 return eZPersistentObject::fetchObjectList( eZContentObjectAttribute::definition(), 00248 null, 00249 array( "contentclassattribute_id" => $this->ContentClassAttributeID, 00250 "contentobject_id" => $this->ContentObjectID, 00251 "version" => $this->Version ), 00252 null, 00253 null, 00254 $asObject); 00255 } 00256 00257 static function create( $contentclassAttributeID, $contentobjectID, $version = 1, $languageCode = false ) 00258 { 00259 //include_once( 'kernel/classes/ezcontentlanguage.php' ); 00260 //include_once( 'lib/ezlocale/classes/ezlocale.php' ); 00261 00262 if ( $languageCode == false ) 00263 { 00264 $languageCode = eZContentObject::defaultLanguage(); 00265 } 00266 00267 $languageID = eZContentLanguage::idByLocale( $languageCode ); 00268 00269 $row = array( 00270 "id" => null, 00271 "contentobject_id" => $contentobjectID, 00272 "version" => $version, 00273 "language_code" => $languageCode, 00274 'language_id' => $languageID, 00275 "contentclassattribute_id" => $contentclassAttributeID, 00276 'data_text' => '', 00277 'data_int' => null, 00278 'data_float' => 0.0 ); 00279 return new eZContentObjectAttribute( $row ); 00280 } 00281 00282 /*! 00283 \reimp 00284 \note Transaction unsafe. If you call several transaction unsafe methods you must enclose 00285 the calls within a db transaction; thus within db->begin and db->commit. 00286 */ 00287 function store( $fieldFilters = null ) 00288 { 00289 require_once( 'kernel/classes/ezcontentlanguage.php' ); 00290 00291 // Unset the cache 00292 global $eZContentObjectContentObjectCache; 00293 unset( $eZContentObjectContentObjectCache[$this->ContentObjectID] ); 00294 global $eZContentObjectDataMapCache; 00295 unset( $eZContentObjectDataMapCache[$this->ContentObjectID] ); 00296 00297 $classAttribute = $this->contentClassAttribute(); 00298 00299 $dataType = $classAttribute->dataType(); 00300 if ( $dataType ) 00301 { 00302 $this->setAttribute( 'data_type_string', $classAttribute->attribute( 'data_type_string' ) ); 00303 $this->updateSortKey( false ); 00304 00305 $db = eZDB::instance(); 00306 $db->begin(); 00307 00308 // store the content data for this attribute 00309 $dataType->storeObjectAttribute( $this ); 00310 00311 eZPersistentObject::store( $fieldFilters ); 00312 $dataType->postStore( $this ); 00313 $db->commit(); 00314 } 00315 } 00316 00317 /*! 00318 Similar to store() but does not call eZDataType::storeObjectAttribute(). 00319 00320 If you have some datatype code that needs to store attribute data you should 00321 call this instead of store(), this function will avoid infinite recursion. 00322 \note Transaction unsafe. If you call several transaction unsafe methods you must enclose 00323 the calls within a db transaction; thus within db->begin and db->commit. 00324 */ 00325 function storeData() 00326 { 00327 require_once( 'kernel/classes/ezcontentlanguage.php' ); 00328 00329 // Unset the cache 00330 global $eZContentObjectContentObjectCache; 00331 unset( $eZContentObjectContentObjectCache[$this->ContentObjectID] ); 00332 global $eZContentObjectDataMapCache; 00333 unset( $eZContentObjectDataMapCache[$this->ContentObjectID] ); 00334 00335 $classAttribute = $this->contentClassAttribute(); 00336 $dataType = $classAttribute->dataType(); 00337 $this->setAttribute( 'data_type_string', $classAttribute->attribute( 'data_type_string' ) ); 00338 $this->updateSortKey( false ); 00339 00340 eZPersistentObject::store(); 00341 } 00342 00343 /*! 00344 Copies the sort key value from the attribute according to the datatype rules. 00345 \note The attribute is not stored 00346 \note Transaction unsafe. If you call several transaction unsafe methods you must enclose 00347 the calls within a db transaction; thus within db->begin and db->commit. 00348 */ 00349 function updateSortKey( $storeData = true ) 00350 { 00351 $classAttribute = $this->contentClassAttribute(); 00352 $dataType = $classAttribute->dataType(); 00353 00354 $return = false; 00355 00356 if ( $dataType ) 00357 { 00358 $return = true; 00359 00360 $sortKey = $dataType->sortKey( $this ); 00361 $this->setAttribute( 'sort_key_string', "" ); 00362 $this->setAttribute( 'sort_key_int', 0 ); 00363 if ( $dataType->sortKeyType() == 'string' ) 00364 { 00365 $this->setAttribute( 'sort_key_string', $sortKey ); 00366 $this->setAttribute( 'sort_key_int', 0 ); 00367 00368 } 00369 else if ( $dataType->sortKeyType() == 'int' ) 00370 { 00371 $this->setAttribute( 'sort_key_int', $sortKey ); 00372 } 00373 00374 if ( $storeData ) 00375 { 00376 $dataType->storeObjectAttribute( $this ); 00377 $return = eZPersistentObject::store(); 00378 } 00379 } 00380 00381 return $return; 00382 } 00383 00384 /*! 00385 Store one row into content attribute table 00386 \note Transaction unsafe. If you call several transaction unsafe methods you must enclose 00387 the calls within a db transaction; thus within db->begin and db->commit. 00388 */ 00389 function storeNewRow() 00390 { 00391 return eZPersistentObject::store(); 00392 } 00393 00394 /*! 00395 * Fetch a node by identifier (unique data_text ) 00396 00397 \param identifier 00398 00399 \return object attribute 00400 */ 00401 static function fetchByIdentifier( $identifier, $asObject = true ) 00402 { 00403 return eZPersistentObject::fetchObject( eZContentObjectAttribute::definition(), 00404 null, 00405 array( 'sort_key_string' => $identifier, 'data_type_string' => 'ezstring' ), 00406 $asObject ); 00407 } 00408 00409 function language( $languageCode = false, $asObject = true ) 00410 { 00411 if ( !$languageCode ) 00412 { 00413 $object = $this->object(); 00414 if ( !$object ) 00415 { 00416 return null; 00417 } 00418 $languageCode = $object->initialLanguageCode(); 00419 } 00420 return eZPersistentObject::fetchObject( eZContentObjectAttribute::definition(), 00421 null, 00422 array( "contentclassattribute_id" => $this->ContentClassAttributeID, 00423 "contentobject_id" => $this->ContentObjectID, 00424 "version" => $this->Version, 00425 "language_code" => $languageCode ), 00426 $asObject ); 00427 } 00428 00429 /*! 00430 */ 00431 function object() 00432 { 00433 if( isset( $this->ContentObjectID ) and $this->ContentObjectID ) 00434 { 00435 return eZContentObject::fetch( $this->ContentObjectID ); 00436 } 00437 return null; 00438 } 00439 00440 function objectVersion() 00441 { 00442 return eZContentObjectVersion::fetchVersion( $this->Version, $this->ContentObjectID ); 00443 } 00444 00445 /*! 00446 Returns the attribute for the current data attribute instance 00447 */ 00448 function contentClassAttribute() 00449 { 00450 eZDebug::accumulatorStart( 'instantiate_class_attribute', 'class_abstraction', 'Instantiating content class attribute' ); 00451 $classAttribute = eZContentClassAttribute::fetch( $this->ContentClassAttributeID ); 00452 eZDebug::accumulatorStop( 'instantiate_class_attribute' ); 00453 return $classAttribute; 00454 } 00455 00456 /*! 00457 Sets the cached content class attribute identifier 00458 */ 00459 function setContentClassAttributeIdentifier( $identifier ) 00460 { 00461 $this->ContentClassAttributeIdentifier = $identifier; 00462 } 00463 00464 /*! 00465 Sets the cached content class attribute can_translate 00466 */ 00467 function setContentClassAttributeCanTranslate( $canTranslate ) 00468 { 00469 $this->ContentClassAttributeCanTranslate = $canTranslate; 00470 } 00471 00472 /*! 00473 Sets the cached content class attribute name 00474 */ 00475 function setContentClassAttributeName( $name ) 00476 { 00477 $this->ContentClassAttributeName = $name; 00478 } 00479 00480 /*! 00481 \returns the cached value of the IsRequired value 00482 \note The reference for the return value is required to workaround 00483 a bug with PHP references. 00484 */ 00485 function contentClassAttributeIsRequired() 00486 { 00487 if ( $this->ContentClassAttributeIsRequired === null ) 00488 { 00489 eZDebug::accumulatorStart( 'class_a_is_req', 'Sytem overhead', 'Fetch class attribute is_required' ); 00490 00491 $classAttribute = eZContentClassAttribute::fetch( $this->ContentClassAttributeID ); 00492 $this->ContentClassAttributeIsRequired = $classAttribute->attribute( 'is_required' ); 00493 eZDebug::accumulatorStop( 'class_a_is_req' ); 00494 } 00495 00496 return $this->ContentClassAttributeIsRequired; 00497 } 00498 00499 /*! 00500 \returns the cached value of the is_informationcollector value 00501 \note The reference for the return value is required to workaround 00502 a bug with PHP references. 00503 */ 00504 function contentClassAttributeIsInformationCollector() 00505 { 00506 if ( $this->ContentClassAttributeIsInformationCollector === null ) 00507 { 00508 eZDebug::accumulatorStart( 'class_a_is_ic', 'Sytem overhead', 'Fetch class attribute name' ); 00509 00510 $classAttribute = eZContentClassAttribute::fetch( $this->ContentClassAttributeID ); 00511 $this->ContentClassAttributeIsInformationCollector = $classAttribute->attribute( 'is_information_collector' ); 00512 eZDebug::accumulatorStop( 'class_a_is_ic' ); 00513 } 00514 00515 return $this->ContentClassAttributeIsInformationCollector; 00516 } 00517 00518 /*! 00519 \returns the cached value of the class attribute name 00520 \note The reference for the return value is required to workaround 00521 a bug with PHP references. 00522 */ 00523 function contentClassAttributeName() 00524 { 00525 if ( $this->ContentClassAttributeName === null ) 00526 { 00527 eZDebug::accumulatorStart( 'class_a_name', 'Sytem overhead', 'Fetch class attribute name' ); 00528 00529 $classAttribute = eZContentClassAttribute::fetch( $this->ContentClassAttributeID ); 00530 $this->ContentClassAttributeName = $classAttribute->attribute( 'name' ); 00531 eZDebug::accumulatorStop( 'class_a_name' ); 00532 } 00533 00534 return $this->ContentClassAttributeName; 00535 } 00536 00537 /*! 00538 \returns the cached value if the attribute can be translated or not 00539 \note The reference for the return value is required to workaround 00540 a bug with PHP references. 00541 */ 00542 function contentClassAttributeCanTranslate() 00543 { 00544 if ( $this->ContentClassAttributeCanTranslate === null ) 00545 { 00546 eZDebug::accumulatorStart( 'class_a_can_translate', 'Sytem overhead', 'Fetch class attribute can translate value' ); 00547 00548 $classAttribute = eZContentClassAttribute::fetch( $this->ContentClassAttributeID ); 00549 00550 $dataType = $classAttribute->dataType(); 00551 00552 if ( $dataType && 00553 $dataType->Attributes["properties"]["translation_allowed"] && 00554 $classAttribute->attribute( 'can_translate' ) ) 00555 $this->ContentClassAttributeCanTranslate = 1; 00556 else 00557 $this->ContentClassAttributeCanTranslate = 0; 00558 eZDebug::accumulatorStop( 'class_a_can_translate' ); 00559 } 00560 00561 return $this->ContentClassAttributeCanTranslate; 00562 } 00563 00564 /*! 00565 \return the idenfifier for the content class attribute 00566 \note The reference for the return value is required to workaround 00567 a bug with PHP references. 00568 */ 00569 function contentClassAttributeIdentifier() 00570 { 00571 if ( $this->ContentClassAttributeIdentifier === null ) 00572 { 00573 eZDebug::accumulatorStart( 'class_a_id', 'Sytem overhead', 'Fetch class attribute identifier' ); 00574 00575 $classAttribute = eZContentClassAttribute::fetch( $this->ContentClassAttributeID ); 00576 $this->ContentClassAttributeIdentifier = $classAttribute->attribute( 'identifier' ); 00577 eZDebug::accumulatorStop( 'class_a_id' ); 00578 } 00579 00580 return $this->ContentClassAttributeIdentifier; 00581 } 00582 00583 /*! 00584 Validates the data contents, returns true on success false if the data 00585 does not validate. 00586 */ 00587 function validateInput( $http, $base, 00588 &$inputParameters, $validationParameters = array() ) 00589 { 00590 $dataType = $this->dataType(); 00591 if ( $dataType ) 00592 { 00593 $this->setInputParameters( $inputParameters ); 00594 $this->setValidationParameters( $validationParameters ); 00595 $this->IsValid = $dataType->validateObjectAttributeHTTPInput( $http, $base, $this ); 00596 $this->unsetValidationParameters(); 00597 $this->unsetInputParameters(); 00598 } 00599 return $this->IsValid; 00600 } 00601 00602 /*! 00603 Validates the data contents, returns true on success false if the data 00604 does not validate. 00605 */ 00606 function validateAddToBasket( $data, &$errors ) 00607 { 00608 $dataType = $this->dataType(); 00609 if ( $dataType ) 00610 { 00611 $this->AddToBasketIsValid = $dataType->validateAddToBasket( $this, $data, $errors ); 00612 } 00613 return $this->AddToBasketIsValid; 00614 } 00615 00616 /*! 00617 Sets the current input parameters to \a $parameters. 00618 The input parameters are set by validateInput() and made avaiable to 00619 datatypes trough the function inputParameters(). 00620 \note The input parameters will only be available for the duration of validateInput(). 00621 \sa inputParameters 00622 */ 00623 function setInputParameters( $parameters ) 00624 { 00625 $this->InputParameters = $parameters; 00626 } 00627 00628 /*! 00629 Unsets the input parameters previously set by setInputParameters(). 00630 \sa inputParameters 00631 */ 00632 function unsetInputParameters() 00633 { 00634 unset( $this->InputParameters ); 00635 $this->InputParameters = false; 00636 } 00637 00638 /*! 00639 \return the current input parameters or \c false if no parameters has been set. 00640 \sa setInputParameters, unsetInputParameters 00641 */ 00642 function inputParameters() 00643 { 00644 return $this->InputParameters; 00645 } 00646 00647 /*! 00648 Sets the current validation parameters to \a $parameters. 00649 The validation parameters are set by validateInput() and made avaiable to 00650 datatypes trough the function validationParameters(). 00651 \note The validation parameters will only be available for the duration of validateInput(). 00652 \sa validationParameters 00653 */ 00654 function setValidationParameters( $parameters ) 00655 { 00656 $this->ValidationParameters = $parameters; 00657 } 00658 00659 /*! 00660 Unsets the validation parameters previously set by setValidationParameters(). 00661 \sa validationParameters 00662 */ 00663 function unsetValidationParameters() 00664 { 00665 unset( $this->ValidationParameters ); 00666 $this->ValidationParameters = false; 00667 } 00668 00669 /*! 00670 \return the current validation parameters or \c false if no parameters has been set. 00671 \sa setValidationParameters, unsetValidationParameters 00672 */ 00673 function validationParameters() 00674 { 00675 return $this->ValidationParameters; 00676 } 00677 00678 /*! 00679 \return \c true if 'is_required' validation should be done otherwise \c false; 00680 */ 00681 function validateIsRequired() 00682 { 00683 $classAttribute = $this->contentClassAttribute(); 00684 $validationParameters = $this->validationParameters(); 00685 if ( !( isset( $validationParameters['skip-isRequired'] ) && $validationParameters['skip-isRequired'] === true ) && $classAttribute->attribute( "is_required" ) ) 00686 return true; 00687 00688 return false; 00689 } 00690 00691 /*! 00692 Tries to fixup the input text to be acceptable. 00693 */ 00694 function fixupInput( $http, $base ) 00695 { 00696 $dataType = $this->dataType(); 00697 if ( $dataType ) 00698 $dataType->fixupObjectAttributeHTTPInput( $http, $base, $this ); 00699 } 00700 00701 /*! 00702 Fetches the data from http post vars and sets them correctly. 00703 */ 00704 function fetchInput( $http, $base ) 00705 { 00706 $dataType = $this->dataType(); 00707 if ( $dataType ) 00708 return $dataType->fetchObjectAttributeHTTPInput( $http, $base, $this ); 00709 00710 return false; 00711 } 00712 00713 /*! 00714 Validates the information collection data. 00715 */ 00716 function validateInformation( $http, $base, 00717 &$inputParameters, $validationParameters = array() ) 00718 { 00719 $dataType = $this->dataType(); 00720 if ( $dataType ) 00721 { 00722 $this->setInputParameters( $inputParameters ); 00723 $this->setValidationParameters( $validationParameters ); 00724 $this->IsValid = $dataType->validateCollectionAttributeHTTPInput( $http, $base, $this ); 00725 $this->unsetValidationParameters(); 00726 $this->unsetInputParameters(); 00727 } 00728 return $this->IsValid; 00729 } 00730 00731 /*! 00732 Collects the information entered by the user from http post vars 00733 */ 00734 function collectInformation( $collection, &$collectionAttribute, $http, $base ) 00735 { 00736 $dataType = $this->dataType(); 00737 if ( $dataType ) 00738 { 00739 $collectionAttribute->setAttribute( 'contentclass_attribute_id', $this->attribute( 'contentclassattribute_id' ) ); 00740 $collectionAttribute->setAttribute( 'contentobject_attribute_id', $this->attribute( 'id' ) ); 00741 $collectionAttribute->setAttribute( 'contentobject_id', $this->attribute( 'contentobject_id' ) ); 00742 return $dataType->fetchCollectionAttributeHTTPInput( $collection, $collectionAttribute, $http, $base, $this ); 00743 } 00744 00745 return false; 00746 } 00747 00748 /*! 00749 Executes the custom HTTP action 00750 */ 00751 function customHTTPAction( $http, $action, $parameters = array() ) 00752 { 00753 $dataType = $this->dataType(); 00754 if ( $dataType ) 00755 $dataType->customObjectAttributeHTTPAction( $http, $action, $this, $parameters ); 00756 } 00757 00758 /*! 00759 Sends custom actions to datatype for custom handling. 00760 */ 00761 function handleCustomHTTPActions( $http, $attributeDataBaseName, 00762 $customActionAttributeArray, $customActionParameters ) 00763 { 00764 $dataType = $this->dataType(); 00765 if ( $dataType ) 00766 { 00767 $customActionParameters['contentobject_attribute'] = $this; 00768 $dataType->handleCustomObjectHTTPActions( $http, $attributeDataBaseName, 00769 $customActionAttributeArray, $customActionParameters ); 00770 } 00771 } 00772 00773 /*! 00774 \note Transaction unsafe. If you call several transaction unsafe methods you must enclose 00775 the calls within a db transaction; thus within db->begin and db->commit. 00776 */ 00777 function onPublish( $object, $nodes ) 00778 { 00779 $dataType = $this->dataType(); 00780 if ( $dataType ) 00781 $dataType->onPublish( $this, $object, $nodes ); 00782 } 00783 00784 /*! 00785 Inserts the HTTP file \a $httpFile to the content object attribute \a $objectAttribute 00786 by calling eZDataType::insertHTTPFile on the current datatype. 00787 00788 The parameters are passed directly to the datatype with the exception of 00789 \a $object, \a $objectVersion and \a $objectLanguage. 00790 If \c false is passed to any of these parameters they will be fetched from the 00791 current attribute, if these are available it is adviced to pass them since it will save time. 00792 */ 00793 function insertHTTPFile( $object, $objectVersion, $objectLanguage, 00794 $httpFile, $mimeData, 00795 &$result ) 00796 { 00797 if ( !$object ) 00798 $object = $this->object(); 00799 if ( $objectVersion === false ) 00800 $objectVersion = $object->attribute( 'current_version' ); 00801 if ( $objectLanguage === false ) 00802 $objectLanguage = $object->attribute( 'default_language' ); 00803 $dataType = $this->dataType(); 00804 return $dataType->insertHTTPFile( $object, $objectVersion, $objectLanguage, 00805 $this, $httpFile, $mimeData, 00806 $result ); 00807 } 00808 00809 /*! 00810 Inserts the file named \a $filePath to the content object attribute \a $objectAttribute. 00811 by calling eZDataType::insertRegularFile on the current datatype. 00812 00813 The parameters are passed directly to the datatype with the exception of 00814 \a $object, \a $objectVersion and \a $objectLanguage. 00815 If \c false is passed to any of these parameters they will be fetched from the 00816 current attribute, if these are available it is adviced to pass them since it will save time. 00817 */ 00818 function insertRegularFile( $object, $objectVersion, $objectLanguage, 00819 $filePath, 00820 &$result ) 00821 { 00822 if ( !$object ) 00823 $object = $this->object(); 00824 if ( $objectVersion === false ) 00825 $objectVersion = $object->attribute( 'current_version' ); 00826 if ( $objectLanguage === false ) 00827 $objectLanguage = $object->attribute( 'default_language' ); 00828 $dataType = $this->dataType(); 00829 return $dataType->insertRegularFile( $object, $objectVersion, $objectLanguage, 00830 $this, $filePath, 00831 $result ); 00832 } 00833 00834 /*! 00835 Inserts the string \a $string to the content object attribute \a $objectAttribute. 00836 by calling eZDataType::insertSimpleString on the current datatype. 00837 00838 The parameters are passed directly to the datatype with the exception of 00839 \a $object, \a $objectVersion and \a $objectLanguage. 00840 If \c false is passed to any of these parameters they will be fetched from the 00841 current attribute, if these are available it is adviced to pass them since it will save time. 00842 */ 00843 function insertSimpleString( $object, $objectVersion, $objectLanguage, 00844 $string, 00845 &$result ) 00846 { 00847 if ( !$object ) 00848 $object = $this->object(); 00849 if ( $objectVersion === false ) 00850 $objectVersion = $object->attribute( 'current_version' ); 00851 if ( $objectLanguage === false ) 00852 $objectLanguage = $object->attribute( 'default_language' ); 00853 $dataType = $this->dataType(); 00854 return $dataType->insertSimpleString( $object, $objectVersion, $objectLanguage, 00855 $this, $string, 00856 $result ); 00857 } 00858 00859 /*! 00860 Calls hasStoredFileInformation() on the current datatype and returns the result. 00861 */ 00862 function hasStoredFileInformation( $object, $objectVersion, $objectLanguage ) 00863 { 00864 if ( !$object ) 00865 $object = $this->object(); 00866 if ( $objectVersion === false ) 00867 $objectVersion = $object->attribute( 'current_version' ); 00868 if ( $objectLanguage === false ) 00869 $objectLanguage = $object->attribute( 'default_language' ); 00870 $dataType = $this->dataType(); 00871 return $dataType->hasStoredFileInformation( $object, $objectVersion, $objectLanguage, 00872 $this ); 00873 } 00874 00875 /*! 00876 Calls storedFileInformation() on the current datatype and returns the result. 00877 */ 00878 function storedFileInformation( $object, $objectVersion, $objectLanguage ) 00879 { 00880 if ( !$object ) 00881 $object = $this->object(); 00882 if ( $objectVersion === false ) 00883 $objectVersion = $object->attribute( 'current_version' ); 00884 if ( $objectLanguage === false ) 00885 $objectLanguage = $object->attribute( 'default_language' ); 00886 $dataType = $this->dataType(); 00887 return $dataType->storedFileInformation( $object, $objectVersion, $objectLanguage, 00888 $this ); 00889 } 00890 00891 /*! 00892 Calls handleDownload() on the current datatype and returns the result. 00893 */ 00894 function handleDownload( $object, $objectVersion, $objectLanguage ) 00895 { 00896 if ( !$object ) 00897 $object = $this->object(); 00898 if ( $objectVersion === false ) 00899 $objectVersion = $object->attribute( 'current_version' ); 00900 if ( $objectLanguage === false ) 00901 $objectLanguage = $object->attribute( 'default_language' ); 00902 $dataType = $this->dataType(); 00903 return $dataType->handleDownload( $object, $objectVersion, $objectLanguage, 00904 $this ); 00905 } 00906 00907 /** 00908 * Initializes the attribute by using the datatype 00909 * 00910 * @param int $currentVersion Current version number 00911 * @param eZContentObjectAttribute $originalContentObjectAttribute 00912 * Optional eZContentObjectAttribute the content will be initialized 00913 * from 00914 * @return void 00915 **/ 00916 function initialize( $currentVersion = null, $originalContentObjectAttribute = null ) 00917 { 00918 if ( $originalContentObjectAttribute === null ) 00919 $originalContentObjectAttribute = $this; 00920 $classAttribute = $this->contentClassAttribute(); 00921 $dataType = $classAttribute->dataType(); 00922 if ( $dataType ) 00923 $dataType->initializeObjectAttribute( $this, $currentVersion, $originalContentObjectAttribute ); 00924 } 00925 00926 /*! 00927 Initialized the attribute by using the datatype after the actual attribute is stored. 00928 */ 00929 function postInitialize( $currentVersion = null, $originalContentObjectAttribute = null ) 00930 { 00931 if ( $originalContentObjectAttribute === null ) 00932 $originalContentObjectAttribute = $this; 00933 $classAttribute = $this->contentClassAttribute(); 00934 $dataType = $classAttribute->dataType(); 00935 if ( $dataType ) 00936 $dataType->postInitializeObjectAttribute( $this, $currentVersion, $originalContentObjectAttribute ); 00937 } 00938 00939 /*! 00940 Remove the attribute by using the datatype. 00941 \note Transaction unsafe. If you call several transaction unsafe methods you must enclose 00942 the calls within a db transaction; thus within db->begin and db->commit. 00943 */ 00944 function removeThis( $id, $currentVersion = null ) 00945 { 00946 $dataType = $this->dataType(); 00947 if ( !$dataType ) 00948 return false; 00949 $dataType->deleteStoredObjectAttribute( $this, $currentVersion ); 00950 if( $currentVersion == null ) 00951 { 00952 eZPersistentObject::removeObject( eZContentObjectAttribute::definition(), 00953 array( "id" => $id ) ); 00954 } 00955 else 00956 { 00957 eZPersistentObject::removeObject( eZContentObjectAttribute::definition(), 00958 array( "id" => $id, 00959 "version" => $currentVersion ) ); 00960 } 00961 } 00962 00963 /** 00964 * Clones the attribute to a new version 00965 * 00966 * @param int $newVersionNumber Target version number 00967 * @param int $currentVersionNumnber Source version number 00968 * @param int $contentObjectID 00969 * @param string $newLanguageCode 00970 * 00971 * @note The cloned attribute isn't stored automatically 00972 * 00973 * @return eZContentObjectAttribute The cloned attribute 00974 * 00975 * @todo Deprecate this in favor of a real __clone 00976 **/ 00977 function cloneContentObjectAttribute( $newVersionNumber, $currentVersionNumber, $contentObjectID = false, $newLanguageCode = false ) 00978 { 00979 $tmp = clone $this; 00980 $tmp->setAttribute( "version", $newVersionNumber ); 00981 if ( $contentObjectID != false ) 00982 { 00983 // if copying the whole object 00984 if ( $contentObjectID != $tmp->attribute( 'contentobject_id' ) ) 00985 { 00986 $exAttr = eZPersistentObject::fetchObject( eZContentObjectAttribute::definition(), 00987 null, 00988 array( 'contentobject_id' => $contentObjectID, 00989 'contentclassattribute_id' => $tmp->attribute( 'contentclassattribute_id' ), 00990 'language_code' => $tmp->attribute( 'language_code' ) ), 00991 true ); 00992 00993 // if the new object already contains the same attribute with another version 00994 if ( is_object( $exAttr ) ) 00995 // we take attribute id from it 00996 $id = $exAttr->attribute( 'id' ); 00997 else 00998 // otherwise new attribute id will be generated 00999 $id = null; 01000 01001 $tmp->setAttribute( 'id', $id ); 01002 } 01003 $tmp->setAttribute( 'contentobject_id', $contentObjectID ); 01004 } 01005 else 01006 { 01007 // if not copying, we will remove the information on which language has to be always shown 01008 $tmp->setAttribute( 'language_id', $tmp->attribute( 'language_id' ) & ~1 ); 01009 } 01010 01011 if ( $newLanguageCode != false && $tmp->attribute( 'language_code' ) != $newLanguageCode ) 01012 { 01013 $exAttr = eZPersistentObject::fetchObject( eZContentObjectAttribute::definition(), 01014 null, 01015 array( 'contentobject_id' => $contentObjectID? $contentObjectID: $tmp->attribute( 'contentobject_id' ), 01016 'contentclassattribute_id' => $tmp->attribute( 'contentclassattribute_id' ), 01017 'language_code' => $newLanguageCode ), 01018 true ); 01019 // if the new object already contains the same attribute with another version 01020 if ( is_object( $exAttr ) ) 01021 { 01022 $id = $exAttr->attribute( 'id' ); 01023 } 01024 else 01025 { 01026 $id = null; 01027 } 01028 $tmp->setAttribute( 'id', $id ); 01029 $tmp->setAttribute( 'language_code', $newLanguageCode ); 01030 $tmp->setAttribute( 'language_id', eZContentLanguage::idByLocale( $newLanguageCode ) ); 01031 } 01032 01033 $db = eZDB::instance(); 01034 $db->begin(); 01035 $tmp->sync(); 01036 $tmp->initialize( $currentVersionNumber, $this ); 01037 $tmp->sync(); 01038 $tmp->postInitialize( $currentVersionNumber, $this ); 01039 $db->commit(); 01040 01041 return $tmp; 01042 } 01043 01044 /*! 01045 Clones the attribute to the translation \a $languageCode. 01046 \note The cloned attribute is not stored. 01047 \note Transaction unsafe. If you call several transaction unsafe methods you must enclose 01048 the calls within a db transaction; thus within db->begin and db->commit. 01049 \note Deprecated. 01050 */ 01051 function translateTo( $languageCode, $updateLanguageMask = true ) 01052 { 01053 $languageID = eZContentLanguage::idByLocale( $languageCode ); 01054 01055 $tmp = clone $this; 01056 $tmp->setAttribute( 'id', null ); 01057 $tmp->setAttribute( 'language_code', $languageCode ); 01058 $tmp->setAttribute( 'language_id', $languageID ); 01059 01060 $db = eZDB::instance(); 01061 $db->begin(); 01062 $tmp->sync(); 01063 $currentVersionNumber = $this->attribute( 'version' ); 01064 $tmp->initialize( $currentVersionNumber, $this ); 01065 $tmp->sync(); 01066 $tmp->postInitialize( $currentVersionNumber, $this ); 01067 if ( $updateLanguageMask ) 01068 { 01069 $version = $tmp->objectVersion(); 01070 $version->updateLanguageMask( (int) $version->languageMask() | (int) $languageID, false ); 01071 } 01072 $db->commit(); 01073 01074 // Clear in-memory content cache 01075 $tmpnull = null; 01076 $tmp->setContent( $tmpnull ); 01077 01078 return $tmp; 01079 } 01080 01081 /*! 01082 Returns the data type class for the current attribute. 01083 */ 01084 function dataType() 01085 { 01086 $dataType = null; 01087 if( !is_null( $this->DataTypeString ) ) 01088 $dataType = eZDataType::create( $this->DataTypeString ); 01089 01090 return $dataType; 01091 } 01092 01093 /*! 01094 Fetches the title of the data instance which is to form the title of the object. 01095 */ 01096 function title() 01097 { 01098 $dataType = $this->dataType(); 01099 if ( $dataType ) 01100 return $dataType->title( $this ); 01101 01102 return ''; 01103 } 01104 01105 /*! 01106 \return the content for the contentclass attribute which defines this contentobject attribute. 01107 \note The reference for the return value is required to workaround 01108 a bug with PHP references. 01109 */ 01110 function classContent() 01111 { 01112 $attribute = $this->contentClassAttribute(); 01113 return $attribute->content(); 01114 } 01115 01116 /*! 01117 Sets the content of variable for the content of the relevant value(s) submitted in HTTP form. 01118 */ 01119 function setHTTPValue( $value ) 01120 { 01121 $this->HTTPValue = $value; 01122 } 01123 01124 /*! 01125 Returns the content of the relevant value(s) submitted in HTTP form. 01126 */ 01127 function value() 01128 { 01129 if ( $this->HTTPValue !== null ) 01130 return $this->HTTPValue; 01131 else 01132 return $this->content(); 01133 } 01134 01135 /*! 01136 \return \c true if the attribute has relavant value(s) submitted in HTTP form. 01137 \note The reference for the return value is required to workaround 01138 a bug with PHP references. 01139 */ 01140 function hasHTTPValue() 01141 { 01142 if ( $this->HTTPValue !== null ) 01143 { 01144 return true; 01145 } 01146 return false; 01147 } 01148 01149 /*! 01150 Returns the content for this attribute. 01151 */ 01152 function content() 01153 { 01154 if ( $this->Content === null ) 01155 { 01156 $dataType = $this->dataType(); 01157 if ( $dataType ) 01158 $this->Content = $dataType->objectAttributeContent( $this ); 01159 } 01160 return $this->Content; 01161 } 01162 01163 /*! 01164 \return \c true if the attribute is considered to have any content at all (ie. non-empty). 01165 01166 It will call the hasObjectAttributeContent() for the current datatype to figure this out. 01167 \note The reference for the return value is required to workaround 01168 a bug with PHP references. 01169 */ 01170 function hasContent() 01171 { 01172 $dataType = $this->dataType(); 01173 if ( $dataType ) 01174 { 01175 return $dataType->hasObjectAttributeContent( $this ); 01176 } 01177 return false; 01178 } 01179 01180 /*! 01181 Returns the metadata. This is the pure content of the attribute used for 01182 indexing data for search engines. 01183 */ 01184 function metaData() 01185 { 01186 $dataType = $this->dataType(); 01187 if ( $dataType ) 01188 return $dataType->metaData( $this ); 01189 else 01190 return false; 01191 } 01192 /*! 01193 Returns the string representation of attribute. This is the pure content of the attribute in string 01194 representation used for simplified import/export. 01195 */ 01196 function toString() 01197 { 01198 $dataType = $this->dataType(); 01199 if ( $dataType ) 01200 return $dataType->toString( $this ); 01201 else 01202 return false; 01203 } 01204 /*! 01205 imports string to attribute content 01206 used for simplified import/export. 01207 */ 01208 function fromString( $string ) 01209 { 01210 $dataType = $this->dataType(); 01211 if ( $dataType ) 01212 return $dataType->fromString( $this, $string ); 01213 else 01214 return false; 01215 } 01216 01217 01218 /*! 01219 \static 01220 Goes trough all attributes and fetches metadata for the ones that is searchable. 01221 \return an array with metadata information. 01222 */ 01223 static function metaDataArray( &$attributes ) 01224 { 01225 $metaDataArray = array(); 01226 if ( !is_array( $attributes ) ) 01227 return false; 01228 foreach( $attributes as $attribute ) 01229 { 01230 $classAttribute = $attribute->contentClassAttribute(); 01231 if ( $classAttribute->attribute( 'is_searchable' ) ) 01232 { 01233 $attributeMetaData = $attribute->metaData(); 01234 if ( $attributeMetaData !== false ) 01235 { 01236 if ( !is_array( $attributeMetaData ) ) 01237 { 01238 $attributeMetaData = array( array( 'id' => '', 01239 'text' => $attributeMetaData ) ); 01240 } 01241 $metaDataArray = array_merge( $metaDataArray, $attributeMetaData ); 01242 } 01243 } 01244 } 01245 return $metaDataArray; 01246 } 01247 01248 01249 /*! 01250 Sets the content for the current attribute 01251 */ 01252 function setContent( $content ) 01253 { 01254 $this->Content = $content; 01255 } 01256 01257 /*! 01258 \return Information on how to display the current attribute. 01259 See eZDataType::objectDisplayInformation() for more information on what is returned. 01260 */ 01261 function displayInfo() 01262 { 01263 if ( !$this->DisplayInfo ) 01264 { 01265 $dataType = $this->dataType(); 01266 if ( $dataType ) 01267 $this->DisplayInfo = $dataType->objectDisplayInformation( $this, false ); 01268 } 01269 return $this->DisplayInfo; 01270 } 01271 01272 /*! 01273 \return Information on how to display the class attribute. 01274 See eZDataType::classDisplayInformation() for more information on what is returned. 01275 \note This is a copy of eZContentClassAttribute::displayInfo() 01276 */ 01277 function classDisplayInfo() 01278 { 01279 $classAttribute = $this->contentClassAttribute(); 01280 if ( !$classAttribute->DisplayInfo ) 01281 { 01282 $dataType = $this->dataType(); 01283 if ( $dataType ) 01284 { 01285 $classAttribute->DisplayInfo = $dataType->classDisplayInformation( $classAttribute, false ); 01286 } 01287 } 01288 return $classAttribute->DisplayInfo; 01289 } 01290 01291 /*! 01292 Returns the content action(s) for this attribute 01293 */ 01294 function contentActionList() 01295 { 01296 $dataType = $this->dataType(); 01297 if ( $dataType ) 01298 { 01299 return $dataType->contentActionList( $this->contentClassAttribute() ); 01300 } 01301 return false; 01302 } 01303 01304 function setValidationError() 01305 { 01306 $numargs = func_num_args(); 01307 if ( $numargs < 1 ) 01308 { 01309 trigger_error( 'Function must take at least one parameter', WARNING ); 01310 return; 01311 } 01312 $argList = func_get_args(); 01313 $text = eZContentObjectAttribute::generateValidationErrorText( $numargs, $argList ); 01314 $this->ValidationError = $text; 01315 $this->HasValidationError = true; 01316 } 01317 01318 function setHasValidationError( $hasError = true ) 01319 { 01320 $this->HasValidationError = $hasError; 01321 } 01322 01323 /*! 01324 \note The reference for the return value is required to workaround 01325 a bug with PHP references. 01326 */ 01327 function hasValidationError() 01328 { 01329 return $this->HasValidationError; 01330 } 01331 01332 static function generateValidationErrorText( $numargs, $argList ) 01333 { 01334 $text = $argList[0]; 01335 for ( $i = 1; $i < $numargs; ++$i ) 01336 { 01337 $arg = $argList[$i]; 01338 $text = str_replace( "%$i", $arg, $text ); 01339 } 01340 return $text; 01341 } 01342 01343 function setValidationLog( $text ) 01344 { 01345 if ( is_string( $text ) ) 01346 { 01347 $logMessage = array(); 01348 $logMessage[] = $text; 01349 $this->ValidationLog = $logMessage; 01350 } 01351 elseif ( is_array( $text ) ) 01352 { 01353 $this->ValidationLog = $text; 01354 } 01355 else 01356 { 01357 $this->ValidationLog = null; 01358 } 01359 } 01360 01361 /*! 01362 \note The reference for the return value is required to workaround 01363 a bug with PHP references. 01364 */ 01365 function validationError() 01366 { 01367 return $this->ValidationError; 01368 } 01369 01370 /*! 01371 \note The reference for the return value is required to workaround 01372 a bug with PHP references. 01373 */ 01374 function validationLog() 01375 { 01376 return $this->ValidationLog; 01377 } 01378 01379 /*! 01380 */ 01381 function serialize( $package ) 01382 { 01383 $result = false; 01384 $dataType = $this->dataType(); 01385 if ( $dataType ) 01386 $result = $dataType->serializeContentObjectAttribute( $package, $this ); 01387 01388 return $result; 01389 } 01390 01391 function unserialize( $package, $attributeDOMNode ) 01392 { 01393 $dataType = $this->dataType(); 01394 if ( $dataType ) 01395 $dataType->unserializeContentObjectAttribute( $package, $this, $attributeDOMNode ); 01396 } 01397 01398 function postUnserialize( $package ) 01399 { 01400 $dataType = $this->dataType(); 01401 if ( $dataType ) 01402 { 01403 $result = $dataType->postUnserializeContentObjectAttribute( $package, $this ); 01404 if ( $result ) 01405 { 01406 $this->store(); 01407 } 01408 } 01409 } 01410 01411 /*! 01412 */ 01413 function isA() 01414 { 01415 $dataType = $this->dataType(); 01416 if ( $dataType ) 01417 { 01418 return $dataType->isA(); 01419 } 01420 return false; 01421 } 01422 01423 /*! 01424 \return the template name to use for viewing the attribute or 01425 if the attribute is an information collector the information 01426 template name is returned. 01427 \note The returned template name does not include the .tpl extension. 01428 \sa editTemplate, informationTemplate 01429 */ 01430 function viewTemplateName() 01431 { 01432 /* This will not work, datatypes should be able to override this .e.g Online Editor 01433 // Don't need to do lookup since we already know the datatype string, which is the result 01434 return $this->DataTypeString; 01435 */ 01436 01437 $classAttribute = $this->contentClassAttribute(); 01438 if ( $classAttribute->attribute( 'is_information_collector' ) ) 01439 { 01440 return $this->informationTemplate(); 01441 } 01442 return $this->viewTemplate(); 01443 } 01444 01445 /*! 01446 \return the template name to use for editing the attribute. 01447 */ 01448 function editTemplateName() 01449 { 01450 return $this->editTemplate(); 01451 } 01452 01453 /*! 01454 \return the template name to use for viewing the attribute. 01455 \note The returned template name does not include the .tpl extension. 01456 \sa editTemplate, informationTemplate 01457 */ 01458 function viewTemplate() 01459 { 01460 /* This will not work, datatypes should be able to override this .e.g Online Editor 01461 return $this->DataTypeString; 01462 // We really don't need to do a lookup via the datatype since we already have the string 01463 */ 01464 $dataType = $this->dataType(); 01465 if ( $dataType ) 01466 { 01467 return $dataType->viewTemplate( $this ); 01468 } 01469 return false; 01470 } 01471 01472 /*! 01473 \return the template name to use for editing the attribute. 01474 \note The returned template name does not include the .tpl extension. 01475 \sa viewTemplate, informationTemplate 01476 */ 01477 function editTemplate() 01478 { 01479 $dataType = $this->dataType(); 01480 if ( $dataType ) 01481 { 01482 return $dataType->editTemplate( $this ); 01483 } 01484 return false; 01485 } 01486 01487 /*! 01488 \return the template name to use for information collection for the attribute. 01489 \note The returned template name does not include the .tpl extension. 01490 \sa viewTemplate, editTemplate 01491 */ 01492 function informationTemplate() 01493 { 01494 /* This will not work, datatypes should be able to override this .e.g Online Editor 01495 return $this->DataTypeString; 01496 */ 01497 $dataType = $this->dataType(); 01498 if ( $dataType ) 01499 { 01500 return $dataType->informationTemplate( $this ); 01501 } 01502 return false; 01503 } 01504 01505 /*! 01506 \return the template name to use for information collection result view for the attribute. 01507 \note The returned template name does not include the .tpl extension. 01508 \sa viewTemplate, editTemplate, informationTemplate 01509 */ 01510 function resultTemplate() 01511 { 01512 /* This will not work, datatypes should be able to override this .e.g Online Editor 01513 return $this->DataTypeString; 01514 */ 01515 $dataType = $this->dataType(); 01516 if ( $dataType ) 01517 { 01518 return $dataType->resultTemplate( $this ); 01519 } 01520 return false; 01521 } 01522 01523 /// Contains the value(s) submitted in HTTP form 01524 public $HTTPValue; 01525 01526 /// Contains the content for this attribute 01527 public $Content; 01528 01529 /// Contains information on how to display the current attribute in various viewmodes 01530 public $DisplayInfo; 01531 01532 /// Stores the is valid 01533 public $IsValid; 01534 01535 public $ContentClassAttributeID; 01536 01537 /// Contains the last validation error 01538 public $ValidationError; 01539 01540 /// Contains the last validation error 01541 public $ValidationLog; 01542 01543 /// 01544 public $ContentClassAttributeIdentifier; 01545 public $ContentClassAttributeCanTranslate; 01546 public $ContentClassAttributeName; 01547 public $ContentClassAttributeIsInformationCollector; 01548 public $ContentClassAttributeIsRequired; 01549 } 01550 01551 ?>