eZ Publish  [4.0]
ezdatetimetype.php
Go to the documentation of this file.
00001 <?php
00002 //
00003 // Definition of eZDateTimeType class
00004 //
00005 //
00006 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
00007 // SOFTWARE NAME: eZ Publish
00008 // SOFTWARE RELEASE: 4.0.x
00009 // COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS
00010 // SOFTWARE LICENSE: GNU General Public License v2.0
00011 // NOTICE: >
00012 //   This program is free software; you can redistribute it and/or
00013 //   modify it under the terms of version 2.0  of the GNU General
00014 //   Public License as published by the Free Software Foundation.
00015 //
00016 //   This program is distributed in the hope that it will be useful,
00017 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 //   GNU General Public License for more details.
00020 //
00021 //   You should have received a copy of version 2.0 of the GNU General
00022 //   Public License along with this program; if not, write to the Free
00023 //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00024 //   MA 02110-1301, USA.
00025 //
00026 //
00027 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
00028 //
00029 
00030 /*!
00031   \class eZDateTimeType ezdatetimetype.php
00032   \ingroup eZDatatype
00033   \brief Stores a date and time value
00034 
00035 */
00036 
00037 //include_once( "kernel/classes/ezdatatype.php" );
00038 //include_once( "lib/ezlocale/classes/ezdatetime.php" );
00039 
00040 class eZDateTimeType extends eZDataType
00041 {
00042     const DATA_TYPE_STRING = 'ezdatetime';
00043 
00044     const DEFAULT_FIELD = 'data_int1';
00045 
00046     const ADJUSTMENT_FIELD = 'data_text5';
00047 
00048     const DEFAULT_EMTPY = 0;
00049 
00050     const DEFAULT_CURRENT_DATE = 1;
00051 
00052     const DEFAULT_ADJUSTMENT = 2;
00053 
00054     function eZDateTimeType()
00055     {
00056         $this->eZDataType( self::DATA_TYPE_STRING, ezi18n( 'kernel/classes/datatypes', "Date and time", 'Datatype name' ),
00057                            array( 'serialize_supported' => true ) );
00058     }
00059 
00060     /*!
00061      Private method only for use inside this class
00062     */
00063     function validateDateTimeHTTPInput( $day, $month, $year, $hour, $minute, $contentObjectAttribute )
00064     {
00065         //include_once( 'lib/ezutils/classes/ezdatetimevalidator.php' );
00066 
00067         $state = eZDateTimeValidator::validateDate( $day, $month, $year );
00068         if ( $state == eZInputValidator::STATE_INVALID )
00069         {
00070             $contentObjectAttribute->setValidationError( ezi18n( 'kernel/classes/datatypes',
00071                                                                  'Date is not valid.' ) );
00072             return eZInputValidator::STATE_INVALID;
00073         }
00074 
00075         $state = eZDateTimeValidator::validateTime( $hour, $minute );
00076         if ( $state == eZInputValidator::STATE_INVALID )
00077         {
00078             $contentObjectAttribute->setValidationError( ezi18n( 'kernel/classes/datatypes',
00079                                                                  'Time is not valid.' ) );
00080             return eZInputValidator::STATE_INVALID;
00081         }
00082         return $state;
00083     }
00084 
00085     /*!
00086      Validates the input and returns true if the input was
00087      valid for this datatype.
00088     */
00089     function validateObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )
00090     {
00091         if ( $http->hasPostVariable( $base . '_datetime_year_' . $contentObjectAttribute->attribute( 'id' ) ) and
00092              $http->hasPostVariable( $base . '_datetime_month_' . $contentObjectAttribute->attribute( 'id' ) ) and
00093              $http->hasPostVariable( $base . '_datetime_day_' . $contentObjectAttribute->attribute( 'id' ) ) and
00094              $http->hasPostVariable( $base . '_datetime_hour_' . $contentObjectAttribute->attribute( 'id' ) ) and
00095              $http->hasPostVariable( $base . '_datetime_minute_' . $contentObjectAttribute->attribute( 'id' ) ) )
00096         {
00097             $year   = $http->postVariable( $base . '_datetime_year_' . $contentObjectAttribute->attribute( 'id' ) );
00098             $month  = $http->postVariable( $base . '_datetime_month_' . $contentObjectAttribute->attribute( 'id' ) );
00099             $day    = $http->postVariable( $base . '_datetime_day_' . $contentObjectAttribute->attribute( 'id' ) );
00100             $hour   = $http->postVariable( $base . '_datetime_hour_' . $contentObjectAttribute->attribute( 'id' ) );
00101             $minute = $http->postVariable( $base . '_datetime_minute_' . $contentObjectAttribute->attribute( 'id' ) );
00102             $classAttribute = $contentObjectAttribute->contentClassAttribute();
00103 
00104             if ( $year == '' or
00105                  $month == '' or
00106                  $day == '' or
00107                  $hour == '' or
00108                  $minute == '' )
00109             {
00110                 if ( !( $year == '' and
00111                         $month == '' and
00112                         $day == '' and
00113                         $hour == '' and
00114                         $minute == '') or
00115                      ( !$classAttribute->attribute( 'is_information_collector' ) and
00116                        $contentObjectAttribute->validateIsRequired() ) )
00117                 {
00118                     $contentObjectAttribute->setValidationError( ezi18n( 'kernel/classes/datatypes',
00119                                                                          'Missing datetime input.' ) );
00120                     return eZInputValidator::STATE_INVALID;
00121                 }
00122                 else
00123                     return eZInputValidator::STATE_ACCEPTED;
00124             }
00125             else
00126             {
00127                 return $this->validateDateTimeHTTPInput( $day, $month, $year, $hour, $minute, $contentObjectAttribute );
00128             }
00129         }
00130         else
00131             return eZInputValidator::STATE_ACCEPTED;
00132     }
00133 
00134     /*!
00135      Fetches the http post var integer input and stores it in the data instance.
00136     */
00137     function fetchObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )
00138     {
00139         if ( $http->hasPostVariable( $base . '_datetime_year_' . $contentObjectAttribute->attribute( 'id' ) ) and
00140              $http->hasPostVariable( $base . '_datetime_month_' . $contentObjectAttribute->attribute( 'id' ) ) and
00141              $http->hasPostVariable( $base . '_datetime_day_' . $contentObjectAttribute->attribute( 'id' ) ) and
00142              $http->hasPostVariable( $base . '_datetime_hour_' . $contentObjectAttribute->attribute( 'id' ) ) and
00143              $http->hasPostVariable( $base . '_datetime_minute_' . $contentObjectAttribute->attribute( 'id' ) ) )
00144         {
00145             $year   = $http->postVariable( $base . '_datetime_year_' . $contentObjectAttribute->attribute( 'id' ) );
00146             $month  = $http->postVariable( $base . '_datetime_month_' . $contentObjectAttribute->attribute( 'id' ) );
00147             $day    = $http->postVariable( $base . '_datetime_day_' . $contentObjectAttribute->attribute( 'id' ) );
00148             $hour   = $http->postVariable( $base . '_datetime_hour_' . $contentObjectAttribute->attribute( 'id' ) );
00149             $minute = $http->postVariable( $base . '_datetime_minute_' . $contentObjectAttribute->attribute( 'id' ) );
00150 
00151             $dateTime = new eZDateTime();
00152             $contentClassAttribute = $contentObjectAttribute->contentClassAttribute();
00153             if ( ( $year == '' and $month == ''and $day == '' and
00154                    $hour == '' and $minute == '' ) or
00155                  !checkdate( $month, $day, $year ) or $year < 1970 )
00156             {
00157                     $dateTime->setTimeStamp( 0 );
00158             }
00159             else
00160             {
00161                 $dateTime->setMDYHMS( $month, $day, $year, $hour, $minute, 0 );
00162             }
00163 
00164             $contentObjectAttribute->setAttribute( 'data_int', $dateTime->timeStamp() );
00165             return true;
00166         }
00167         return false;
00168     }
00169 
00170     /*!
00171      \reimp
00172     */
00173     function validateCollectionAttributeHTTPInput( $http, $base, $contentObjectAttribute )
00174     {
00175         if ( $http->hasPostVariable( $base . '_datetime_year_' . $contentObjectAttribute->attribute( 'id' ) ) and
00176              $http->hasPostVariable( $base . '_datetime_month_' . $contentObjectAttribute->attribute( 'id' ) ) and
00177              $http->hasPostVariable( $base . '_datetime_day_' . $contentObjectAttribute->attribute( 'id' ) ) and
00178              $http->hasPostVariable( $base . '_datetime_hour_' . $contentObjectAttribute->attribute( 'id' ) ) and
00179              $http->hasPostVariable( $base . '_datetime_minute_' . $contentObjectAttribute->attribute( 'id' ) ) )
00180         {
00181             $year   = $http->postVariable( $base . '_datetime_year_' . $contentObjectAttribute->attribute( 'id' ) );
00182             $month  = $http->postVariable( $base . '_datetime_month_' . $contentObjectAttribute->attribute( 'id' ) );
00183             $day    = $http->postVariable( $base . '_datetime_day_' . $contentObjectAttribute->attribute( 'id' ) );
00184             $hour   = $http->postVariable( $base . '_datetime_hour_' . $contentObjectAttribute->attribute( 'id' ) );
00185             $minute = $http->postVariable( $base . '_datetime_minute_' . $contentObjectAttribute->attribute( 'id' ) );
00186             $classAttribute = $contentObjectAttribute->contentClassAttribute();
00187 
00188             if ( $year == '' or
00189                  $month == '' or
00190                  $day == '' or
00191                  $hour == '' or
00192                  $minute == '' )
00193             {
00194                 if ( !( $year == '' and
00195                         $month == '' and
00196                         $day == '' and
00197                         $hour == '' and
00198                         $minute == '') or
00199                      $contentObjectAttribute->validateIsRequired() )
00200                 {
00201                     $contentObjectAttribute->setValidationError( ezi18n( 'kernel/classes/datatypes',
00202                                                                          'Missing datetime input.' ) );
00203                     return eZInputValidator::STATE_INVALID;
00204                 }
00205                 else
00206                     return eZInputValidator::STATE_ACCEPTED;
00207             }
00208             else
00209             {
00210                 return $this->validateDateTimeHTTPInput( $day, $month, $year, $hour, $minute, $contentObjectAttribute );
00211             }
00212         }
00213         else
00214             return eZInputValidator::STATE_INVALID;
00215     }
00216 
00217    /*!
00218     \reimp
00219     Fetches the http post variables for collected information
00220    */
00221     function fetchCollectionAttributeHTTPInput( $collection, $collectionAttribute, $http, $base, $contentObjectAttribute )
00222     {
00223         if ( $http->hasPostVariable( $base . '_datetime_year_' . $contentObjectAttribute->attribute( 'id' ) ) and
00224              $http->hasPostVariable( $base . '_datetime_month_' . $contentObjectAttribute->attribute( 'id' ) ) and
00225              $http->hasPostVariable( $base . '_datetime_day_' . $contentObjectAttribute->attribute( 'id' ) ) and
00226              $http->hasPostVariable( $base . '_datetime_hour_' . $contentObjectAttribute->attribute( 'id' ) ) and
00227              $http->hasPostVariable( $base . '_datetime_minute_' . $contentObjectAttribute->attribute( 'id' ) ) )
00228         {
00229             $year   = $http->postVariable( $base . '_datetime_year_' . $contentObjectAttribute->attribute( 'id' ) );
00230             $month  = $http->postVariable( $base . '_datetime_month_' . $contentObjectAttribute->attribute( 'id' ) );
00231             $day    = $http->postVariable( $base . '_datetime_day_' . $contentObjectAttribute->attribute( 'id' ) );
00232             $hour   = $http->postVariable( $base . '_datetime_hour_' . $contentObjectAttribute->attribute( 'id' ) );
00233             $minute = $http->postVariable( $base . '_datetime_minute_' . $contentObjectAttribute->attribute( 'id' ) );
00234 
00235             $dateTime = new eZDateTime();
00236             $contentClassAttribute = $contentObjectAttribute->contentClassAttribute();
00237             if ( ( $year == '' and $month == ''and $day == '' and
00238                    $hour == '' and $minute == '' ) or
00239                  !checkdate( $month, $day, $year ) or $year < 1970 )
00240             {
00241                     $dateTime->setTimeStamp( 0 );
00242             }
00243             else
00244             {
00245                 $dateTime->setMDYHMS( $month, $day, $year, $hour, $minute, 0 );
00246             }
00247 
00248             $collectionAttribute->setAttribute( 'data_int', $dateTime->timeStamp() );
00249             return true;
00250         }
00251         return false;
00252     }
00253 
00254     /*!
00255      Returns the content.
00256     */
00257     function objectAttributeContent( $contentObjectAttribute )
00258     {
00259         $dateTime = new eZDateTime();
00260         $stamp = $contentObjectAttribute->attribute( 'data_int' );
00261         $dateTime->setTimeStamp( $stamp );
00262         return $dateTime;
00263     }
00264 
00265     /*!
00266      \reimp
00267     */
00268     function isIndexable()
00269     {
00270         return true;
00271     }
00272 
00273     /*!
00274      \reimp
00275     */
00276     function isInformationCollector()
00277     {
00278         return true;
00279     }
00280 
00281     /*!
00282      Returns the meta data used for storing search indeces.
00283     */
00284     function metaData( $contentObjectAttribute )
00285     {
00286         return $contentObjectAttribute->attribute( 'data_int' );
00287     }
00288     /*!
00289      \return string representation of an contentobjectattribute data for simplified export
00290 
00291     */
00292     function toString( $contentObjectAttribute )
00293     {
00294         return $contentObjectAttribute->attribute( 'data_int' );
00295     }
00296 
00297     function fromString( $contentObjectAttribute, $string )
00298     {
00299         return $contentObjectAttribute->setAttribute( 'data_int', $string );
00300     }
00301 
00302     /*!
00303      Set class attribute value for template version
00304     */
00305     function initializeClassAttribute( $classAttribute )
00306     {
00307         if ( $classAttribute->attribute( self::DEFAULT_FIELD ) == null )
00308             $classAttribute->setAttribute( self::DEFAULT_FIELD, 0 );
00309         $classAttribute->store();
00310     }
00311 
00312     function parseXML( $xmlText )
00313     {
00314         $dom = new DOMDocument;
00315         $success = $dom->loadXML( $xmlText );
00316         return $dom;
00317     }
00318 
00319     function classAttributeContent( $classAttribute )
00320     {
00321         $xmlText = $classAttribute->attribute( 'data_text5' );
00322         if ( trim( $xmlText ) == '' )
00323         {
00324             $classAttrContent = eZDateTimeType::defaultClassAttributeContent();
00325             return $classAttrContent;
00326         }
00327         $doc = eZDateTimeType::parseXML( $xmlText );
00328         $root = $doc->documentElement;
00329         $type = $root->getElementsByTagName( 'year' )->item( 0 );
00330         if ( $type )
00331         {
00332             $content['year'] = $type->getAttribute( 'value' );
00333         }
00334         $type = $root->getElementsByTagName( 'month' )->item( 0 );
00335         if ( $type )
00336         {
00337             $content['month'] = $type->getAttribute( 'value' );
00338         }
00339         $type = $root->getElementsByTagName( 'day' )->item( 0 );
00340         if ( $type )
00341         {
00342             $content['day'] = $type->getAttribute( 'value' );
00343         }
00344         $type = $root->getElementsByTagName( 'hour' )->item( 0 );
00345         if ( $type )
00346         {
00347             $content['hour'] = $type->getAttribute( 'value' );
00348         }
00349         $type = $root->getElementsByTagName( 'minute' )->item( 0 );
00350         if ( $type )
00351         {
00352             $content['minute'] = $type->getAttribute( 'value' );
00353         }
00354         return $content;
00355     }
00356 
00357     function defaultClassAttributeContent()
00358     {
00359         return array( 'year' => '',
00360                       'month' => '',
00361                       'day' => '',
00362                       'hour' => '',
00363                       'minute' => '' );
00364     }
00365 
00366     /*!
00367      Sets the default value.
00368     */
00369     function initializeObjectAttribute( $contentObjectAttribute, $currentVersion, $originalContentObjectAttribute )
00370     {
00371         if ( $currentVersion != false )
00372         {
00373             $dataInt = $originalContentObjectAttribute->attribute( "data_int" );
00374             $contentObjectAttribute->setAttribute( "data_int", $dataInt );
00375         }
00376         else
00377         {
00378             $contentClassAttribute = $contentObjectAttribute->contentClassAttribute();
00379             $defaultType = $contentClassAttribute->attribute( self::DEFAULT_FIELD );
00380             if ( $defaultType == self::DEFAULT_CURRENT_DATE )
00381             {
00382                 $contentObjectAttribute->setAttribute( "data_int", time() );
00383             }
00384             else if ( $defaultType == self::DEFAULT_ADJUSTMENT )
00385             {
00386                 $adjustments = $this->classAttributeContent( $contentClassAttribute );
00387                 $value = new eZDateTime();
00388                 $value->adjustDateTime( $adjustments['hour'], $adjustments['minute'], 0, $adjustments['month'], $adjustments['day'], $adjustments['year'] );
00389                 $contentObjectAttribute->setAttribute( "data_int", $value->timeStamp() );
00390             }
00391             else
00392                 $contentObjectAttribute->setAttribute( "data_int", 0 );
00393         }
00394     }
00395 
00396     function fetchClassAttributeHTTPInput( $http, $base, $classAttribute )
00397     {
00398         $default = $base . "_ezdatetime_default_" . $classAttribute->attribute( 'id' );
00399         if ( $http->hasPostVariable( $default ) )
00400         {
00401             $defaultValue = $http->postVariable( $default );
00402             $classAttribute->setAttribute( self::DEFAULT_FIELD,  $defaultValue );
00403             if ( $defaultValue == self::DEFAULT_ADJUSTMENT )
00404             {
00405                 $doc = new DOMDocument( '1.0', 'utf-8' );
00406                 $root = $doc->createElement( 'adjustment' );
00407                 $contentList = eZDateTimeType::contentObjectArrayXMLMap();
00408                 foreach ( $contentList as $key => $value )
00409                 {
00410                     $postValue = $http->postVariable( $base . '_ezdatetime_' . $value . '_' . $classAttribute->attribute( 'id' ) );
00411                     unset( $elementType );
00412                     $elementType = $doc->createElement( $key );
00413                     $elementType->setAttribute( 'value', $postValue );
00414                     $root->appendChild( $elementType );
00415                 }
00416                 $doc->appendChild( $root );
00417                 $docText = $doc->saveXML();
00418                 $classAttribute->setAttribute( self::ADJUSTMENT_FIELD , $docText );
00419             }
00420         }
00421         return true;
00422     }
00423 
00424     function contentObjectArrayXMLMap()
00425     {
00426         return array( 'year' => 'year',
00427                       'month' => 'month',
00428                       'day' => 'day',
00429                       'hour' => 'hour',
00430                       'minute' => 'minute' );
00431     }
00432 
00433 
00434     /*!
00435      Returns the date.
00436     */
00437     function title( $contentObjectAttribute, $name = null )
00438     {
00439         $locale = eZLocale::instance();
00440         $retVal = $contentObjectAttribute->attribute( "data_int" ) == 0 ? '' : $locale->formatDateTime( $contentObjectAttribute->attribute( "data_int" ) );
00441         return $retVal;
00442     }
00443 
00444     function hasObjectAttributeContent( $contentObjectAttribute )
00445     {
00446         return $contentObjectAttribute->attribute( "data_int" ) != 0;
00447     }
00448 
00449     /*!
00450      \reimp
00451     */
00452     function sortKey( $contentObjectAttribute )
00453     {
00454         return (int)$contentObjectAttribute->attribute( 'data_int' );
00455     }
00456 
00457         /*!
00458      \reimp
00459     */
00460     function sortKeyType()
00461     {
00462         return 'int';
00463     }
00464 
00465     /*!
00466      \reimp
00467     */
00468     function serializeContentClassAttribute( $classAttribute, $attributeNode, $attributeParametersNode )
00469     {
00470         $dom = $attributeParametersNode->ownerDocument;
00471         $defaultValue = $classAttribute->attribute( self::DEFAULT_FIELD );
00472         $defaultValueNode = $dom->createElement( 'default-value' );
00473 
00474         switch ( $defaultValue )
00475         {
00476             case self::DEFAULT_CURRENT_DATE:
00477             {
00478                 $defaultValueNode->setAttribute( 'type', 'current-date' );
00479             } break;
00480             case self::DEFAULT_ADJUSTMENT:
00481             {
00482                 $defaultValueNode->setAttribute( 'type', 'adjustment' );
00483 
00484                 $adjustDOMValue = new DOMDocument( '1.0', 'utf-8' );
00485                 $adjustValue = $classAttribute->attribute( self::ADJUSTMENT_FIELD );
00486                 $success = $adjustDOMValue->loadXML( $adjustValue );
00487 
00488                 if ( $success )
00489                 {
00490                     $adjustmentNode = $adjustDOMValue->getElementsByTagName( 'adjustment' )->item( 0 );
00491 
00492                     if ( $adjustmentNode )
00493                     {
00494                         $importedAdjustmentNode = $dom->importNode( $adjustmentNode, true );
00495                         $defaultValueNode->appendChild( $importedAdjustmentNode );
00496                     }
00497                 }
00498             } break;
00499             case self::DEFAULT_EMTPY:
00500             {
00501                 $defaultValueNode->setAttribute( 'type', 'empty' );
00502             } break;
00503             default:
00504             {
00505                 eZDebug::writeError( 'Unknown type of DateTime default value. Empty type used instead.',
00506                                     'eZDateTimeType::serializeContentClassAttribute()' );
00507                 $defaultValueNode->setAttribute( 'type', 'empty' );
00508             } break;
00509         }
00510 
00511         $attributeParametersNode->appendChild( $defaultValueNode );
00512     }
00513 
00514     /*!
00515      \reimp
00516     */
00517     function unserializeContentClassAttribute( $classAttribute, $attributeNode, $attributeParametersNode )
00518     {
00519         $defaultValue = '';
00520         $defaultNode = $attributeParametersNode->getElementsByTagName( 'default-value' )->item( 0 );
00521         if ( $defaultNode )
00522         {
00523             $defaultValue = strtolower( $defaultNode->getAttribute( 'type' ) );
00524         }
00525         switch ( $defaultValue )
00526         {
00527             case 'current-date':
00528             {
00529                 $classAttribute->setAttribute( self::DEFAULT_FIELD, self::DEFAULT_CURRENT_DATE );
00530             } break;
00531             case 'adjustment':
00532             {
00533                 $adjustmentValue = '';
00534                 $adjustmentNode = $defaultNode->getElementsByTagName( 'adjustment' )->item( 0 );
00535                 if ( $adjustmentNode )
00536                 {
00537                     $adjustmentDOMValue = new DOMDocument( '1.0', 'utf-8' );
00538                     $importedAdjustmentNode = $adjustmentDOMValue->importNode( $adjustmentNode, true );
00539                     $adjustmentDOMValue->appendChild( $importedAdjustmentNode );
00540                     $adjustmentValue = $adjustmentDOMValue->saveXML();
00541                 }
00542 
00543                 $classAttribute->setAttribute( self::DEFAULT_FIELD, self::DEFAULT_ADJUSTMENT );
00544                 $classAttribute->setAttribute( self::ADJUSTMENT_FIELD, $adjustmentValue );
00545             } break;
00546             case 'empty':
00547             {
00548                 $classAttribute->setAttribute( self::DEFAULT_FIELD, self::DEFAULT_EMTPY );
00549             } break;
00550             default:
00551             {
00552                 eZDebug::writeError( 'Type of DateTime default value is not set. Empty type used as default.',
00553                                     'eZDateTimeType::unserializeContentClassAttribute()' );
00554                 $classAttribute->setAttribute( self::DEFAULT_FIELD, self::DEFAULT_EMTPY );
00555             } break;
00556         }
00557     }
00558 
00559     /*!
00560      \reimp
00561      \return a DOM representation of the content object attribute
00562     */
00563     function serializeContentObjectAttribute( $package, $objectAttribute )
00564     {
00565         $node = $this->createContentObjectAttributeDOMNode( $objectAttribute );
00566 
00567         $stamp = $objectAttribute->attribute( 'data_int' );
00568 
00569         if ( $stamp !== null )
00570         {
00571             $dom = $node->ownerDocument;
00572             $dateTimeNode = $dom->createElement( 'date_time' );
00573             $dateTimeNode->appendChild( $dom->createTextNode( eZDateUtils::rfc1123Date( $stamp ) ) );
00574             $node->appendChild( $dateTimeNode );
00575         }
00576         return $node;
00577     }
00578 
00579     /*!
00580      \reimp
00581     */
00582     function unserializeContentObjectAttribute( $package, $objectAttribute, $attributeNode )
00583     {
00584         $dateTimeNode = $attributeNode->getElementsByTagName( 'date_time' )->item( 0 );
00585         if ( is_object( $dateTimeNode ) )
00586         {
00587             //include_once( 'lib/ezlocale/classes/ezdateutils.php' );
00588             $timestamp = eZDateUtils::textToDate( $dateTimeNode->textContent );
00589             $objectAttribute->setAttribute( 'data_int', $timestamp );
00590         }
00591     }
00592 }
00593 
00594 eZDataType::register( eZDateTimeType::DATA_TYPE_STRING, "eZDateTimeType" );
00595 
00596 ?>