Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezdatetimetype.php
Go to the documentation of this file.
1 <?php
18 class eZDateTimeType extends eZDataType
19 {
20 const DATA_TYPE_STRING = 'ezdatetime';
21
22 const DEFAULT_FIELD = 'data_int1';
23
24 const USE_SECONDS_FIELD = 'data_int2';
25
26 const ADJUSTMENT_FIELD = 'data_text5';
27
28 const DEFAULT_EMTPY = 0;
29
30 const DEFAULT_CURRENT_DATE = 1;
31
32 const DEFAULT_ADJUSTMENT = 2;
33
34 public function __construct()
35 {
36 parent::__construct( self::DATA_TYPE_STRING, ezpI18n::tr( 'kernel/classes/datatypes', "Date and time", 'Datatype name' ),
37 array( 'serialize_supported' => true ) );
38 }
39
43 function validateDateTimeHTTPInput( $day, $month, $year, $hour, $minute, $second, $contentObjectAttribute )
44 {
45 $state = eZDateTimeValidator::validateDate( $day, $month, $year );
46 if ( $state == eZInputValidator::STATE_INVALID )
47 {
48 $contentObjectAttribute->setValidationError( ezpI18n::tr( 'kernel/classes/datatypes',
49 'Date is not valid.' ) );
50 return eZInputValidator::STATE_INVALID;
51 }
52
53 $state = eZDateTimeValidator::validateTime( $hour, $minute, $second );
54
55 if ( $state == eZInputValidator::STATE_INVALID )
56 {
57 $contentObjectAttribute->setValidationError( ezpI18n::tr( 'kernel/classes/datatypes',
58 'Time is not valid.' ) );
59 return eZInputValidator::STATE_INVALID;
60 }
61 return $state;
62 }
63
68 function validateObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )
69 {
70 $classAttribute = $contentObjectAttribute->contentClassAttribute();
71 $useSeconds = ( $classAttribute->attribute( self::USE_SECONDS_FIELD ) == 1 );
72
73 if ( $http->hasPostVariable( $base . '_datetime_year_' . $contentObjectAttribute->attribute( 'id' ) ) and
74 $http->hasPostVariable( $base . '_datetime_month_' . $contentObjectAttribute->attribute( 'id' ) ) and
75 $http->hasPostVariable( $base . '_datetime_day_' . $contentObjectAttribute->attribute( 'id' ) ) and
76 $http->hasPostVariable( $base . '_datetime_hour_' . $contentObjectAttribute->attribute( 'id' ) ) and
77 $http->hasPostVariable( $base . '_datetime_minute_' . $contentObjectAttribute->attribute( 'id' ) ) and
78 ( !$useSeconds or $http->hasPostVariable( $base . '_datetime_second_' . $contentObjectAttribute->attribute( 'id' ) ) ) )
79 {
80 $year = $http->postVariable( $base . '_datetime_year_' . $contentObjectAttribute->attribute( 'id' ) );
81 $month = $http->postVariable( $base . '_datetime_month_' . $contentObjectAttribute->attribute( 'id' ) );
82 $day = $http->postVariable( $base . '_datetime_day_' . $contentObjectAttribute->attribute( 'id' ) );
83 $hour = $http->postVariable( $base . '_datetime_hour_' . $contentObjectAttribute->attribute( 'id' ) );
84 $minute = $http->postVariable( $base . '_datetime_minute_' . $contentObjectAttribute->attribute( 'id' ) );
85 $second = $useSeconds ? $http->postVariable( $base . '_datetime_second_' . $contentObjectAttribute->attribute( 'id' ) ) : 0;
86
87 if ( $year == '' or
88 $month == '' or
89 $day == '' or
90 $hour == '' or
91 $minute == '' or
92 ( $useSeconds and $second == '' ) )
93 {
94 if ( !( $year == '' and
95 $month == '' and
96 $day == '' and
97 $hour == '' and
98 $minute == '' and
99 ( !$useSeconds or $second == '' ) ) or
100 ( !$classAttribute->attribute( 'is_information_collector' ) and
101 $contentObjectAttribute->validateIsRequired() ) )
102 {
103 $contentObjectAttribute->setValidationError( ezpI18n::tr( 'kernel/classes/datatypes',
104 'Missing datetime input.' ) );
105 return eZInputValidator::STATE_INVALID;
106 }
107 else
108 return eZInputValidator::STATE_ACCEPTED;
109 }
110 else
111 {
112 return $this->validateDateTimeHTTPInput( $day, $month, $year, $hour, $minute, $second, $contentObjectAttribute );
113 }
114 }
115 else if ( !$classAttribute->attribute( 'is_information_collector' ) and $contentObjectAttribute->validateIsRequired() )
116 {
117 $contentObjectAttribute->setValidationError( ezpI18n::tr( 'kernel/classes/datatypes', 'Missing datetime input.' ) );
118 return eZInputValidator::STATE_INVALID;
119 }
120 else
121 return eZInputValidator::STATE_ACCEPTED;
122 }
123
127 function fetchObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )
128 {
129 $contentClassAttribute = $contentObjectAttribute->contentClassAttribute();
130 $useSeconds = ( $contentClassAttribute->attribute( self::USE_SECONDS_FIELD ) == 1 );
131
132 if ( $http->hasPostVariable( $base . '_datetime_year_' . $contentObjectAttribute->attribute( 'id' ) ) and
133 $http->hasPostVariable( $base . '_datetime_month_' . $contentObjectAttribute->attribute( 'id' ) ) and
134 $http->hasPostVariable( $base . '_datetime_day_' . $contentObjectAttribute->attribute( 'id' ) ) and
135 $http->hasPostVariable( $base . '_datetime_hour_' . $contentObjectAttribute->attribute( 'id' ) ) and
136 $http->hasPostVariable( $base . '_datetime_minute_' . $contentObjectAttribute->attribute( 'id' ) ) and
137 ( !$useSeconds or $http->hasPostVariable( $base . '_datetime_second_' . $contentObjectAttribute->attribute( 'id' ) ) ) )
138 {
139 $year = $http->postVariable( $base . '_datetime_year_' . $contentObjectAttribute->attribute( 'id' ) );
140 $month = $http->postVariable( $base . '_datetime_month_' . $contentObjectAttribute->attribute( 'id' ) );
141 $day = $http->postVariable( $base . '_datetime_day_' . $contentObjectAttribute->attribute( 'id' ) );
142 $hour = $http->postVariable( $base . '_datetime_hour_' . $contentObjectAttribute->attribute( 'id' ) );
143 $minute = $http->postVariable( $base . '_datetime_minute_' . $contentObjectAttribute->attribute( 'id' ) );
144 $second = $useSeconds ? $http->postVariable( $base . '_datetime_second_' . $contentObjectAttribute->attribute( 'id' ) ) : 0;
145
146 if ( ( $year == '' and $month == '' and $day == '' and
147 $hour == '' and $minute == '' and ( !$useSeconds or $second == '' ) ) or
148 !checkdate( $month, $day, $year ) )
149 {
150 $stamp = null;
151 }
152 else
153 {
154 $dateTime = new eZDateTime();
155 $dateTime->setMDYHMS( $month, $day, $year, $hour, $minute, $second );
156 $stamp = $dateTime->timeStamp();
157 }
158
159 $contentObjectAttribute->setAttribute( 'data_int', $stamp );
160 return true;
161 }
162 return false;
163 }
164
165 function validateCollectionAttributeHTTPInput( $http, $base, $contentObjectAttribute )
166 {
167 $contentClassAttribute = $contentObjectAttribute->contentClassAttribute();
168 $useSeconds = ( $contentClassAttribute->attribute( self::USE_SECONDS_FIELD ) == 1 );
169
170 if ( $http->hasPostVariable( $base . '_datetime_year_' . $contentObjectAttribute->attribute( 'id' ) ) and
171 $http->hasPostVariable( $base . '_datetime_month_' . $contentObjectAttribute->attribute( 'id' ) ) and
172 $http->hasPostVariable( $base . '_datetime_day_' . $contentObjectAttribute->attribute( 'id' ) ) and
173 $http->hasPostVariable( $base . '_datetime_hour_' . $contentObjectAttribute->attribute( 'id' ) ) and
174 $http->hasPostVariable( $base . '_datetime_minute_' . $contentObjectAttribute->attribute( 'id' ) ) and
175 ( !$useSeconds or $http->hasPostVariable( $base . '_datetime_second_' . $contentObjectAttribute->attribute( 'id' ) ) ) )
176
177 {
178 $year = $http->postVariable( $base . '_datetime_year_' . $contentObjectAttribute->attribute( 'id' ) );
179 $month = $http->postVariable( $base . '_datetime_month_' . $contentObjectAttribute->attribute( 'id' ) );
180 $day = $http->postVariable( $base . '_datetime_day_' . $contentObjectAttribute->attribute( 'id' ) );
181 $hour = $http->postVariable( $base . '_datetime_hour_' . $contentObjectAttribute->attribute( 'id' ) );
182 $minute = $http->postVariable( $base . '_datetime_minute_' . $contentObjectAttribute->attribute( 'id' ) );
183 $second = $useSeconds ? $http->postVariable( $base . '_datetime_second_' . $contentObjectAttribute->attribute( 'id' ) ) : 0;
184
185 if ( $year == '' or
186 $month == '' or
187 $day == '' or
188 $hour == '' or
189 $minute == '' or
190 ( $useSeconds and $second == '' ) )
191 {
192 if ( !( $year == '' and
193 $month == '' and
194 $day == '' and
195 $hour == '' and
196 $minute == '' and
197 ( !$useSeconds or $second == '' ) ) or
198 $contentObjectAttribute->validateIsRequired() )
199 {
200 $contentObjectAttribute->setValidationError( ezpI18n::tr( 'kernel/classes/datatypes',
201 'Missing datetime input.' ) );
202 return eZInputValidator::STATE_INVALID;
203 }
204 else
205 return eZInputValidator::STATE_ACCEPTED;
206 }
207 else
208 {
209 return $this->validateDateTimeHTTPInput( $day, $month, $year, $hour, $minute, $second, $contentObjectAttribute );
210 }
211 }
212 else
213 return eZInputValidator::STATE_INVALID;
214 }
215
219 function fetchCollectionAttributeHTTPInput( $collection, $collectionAttribute, $http, $base, $contentObjectAttribute )
220 {
221 $contentClassAttribute = $contentObjectAttribute->contentClassAttribute();
222 $useSeconds = ( $contentClassAttribute->attribute( self::USE_SECONDS_FIELD ) == 1 );
223
224 if ( $http->hasPostVariable( $base . '_datetime_year_' . $contentObjectAttribute->attribute( 'id' ) ) and
225 $http->hasPostVariable( $base . '_datetime_month_' . $contentObjectAttribute->attribute( 'id' ) ) and
226 $http->hasPostVariable( $base . '_datetime_day_' . $contentObjectAttribute->attribute( 'id' ) ) and
227 $http->hasPostVariable( $base . '_datetime_hour_' . $contentObjectAttribute->attribute( 'id' ) ) and
228 $http->hasPostVariable( $base . '_datetime_minute_' . $contentObjectAttribute->attribute( 'id' ) ) and
229 ( !$useSeconds or $http->hasPostVariable( $base . '_datetime_second_' . $contentObjectAttribute->attribute( 'id' ) ) ) )
230 {
231 $year = $http->postVariable( $base . '_datetime_year_' . $contentObjectAttribute->attribute( 'id' ) );
232 $month = $http->postVariable( $base . '_datetime_month_' . $contentObjectAttribute->attribute( 'id' ) );
233 $day = $http->postVariable( $base . '_datetime_day_' . $contentObjectAttribute->attribute( 'id' ) );
234 $hour = $http->postVariable( $base . '_datetime_hour_' . $contentObjectAttribute->attribute( 'id' ) );
235 $minute = $http->postVariable( $base . '_datetime_minute_' . $contentObjectAttribute->attribute( 'id' ) );
236 $second = $useSeconds ? $http->postVariable( $base . '_datetime_second_' . $contentObjectAttribute->attribute( 'id' ) ) : 0;
237
238 $contentClassAttribute = $contentObjectAttribute->contentClassAttribute();
239 if ( ( $year == '' and $month == ''and $day == '' and
240 $hour == '' and $minute == '' and ( !$useSeconds or $second == '' ) ) or
241 !checkdate( $month, $day, $year ) )
242 {
243 $stamp = null;
244 }
245 else
246 {
247 $dateTime = new eZDateTime();
248 $dateTime->setMDYHMS( $month, $day, $year, $hour, $minute, $second );
249 $stamp = $dateTime->timeStamp();
250 }
251
252 $collectionAttribute->setAttribute( 'data_int', $stamp );
253 return true;
254 }
255 return false;
256 }
257
261 function objectAttributeContent( $contentObjectAttribute )
262 {
263 $dateTime = new eZDateTime();
264 $stamp = $contentObjectAttribute->attribute( 'data_int' );
265 $dateTime->setTimeStamp( $stamp );
266 return $dateTime;
267 }
268
269 function isIndexable()
270 {
271 return true;
272 }
273
274 function isInformationCollector()
275 {
276 return true;
277 }
278
282 function metaData( $contentObjectAttribute )
283 {
284 return (int)$contentObjectAttribute->attribute( 'data_int' );
285 }
290 function toString( $contentObjectAttribute )
291 {
292 $stamp = $contentObjectAttribute->attribute( 'data_int' );
293 return $stamp === null ? '' : $stamp;
294 }
295
296 function fromString( $contentObjectAttribute, $string )
297 {
298 if ( empty( $string ) )
299 {
300 $string = null;
301 }
302
303 return $contentObjectAttribute->setAttribute( 'data_int', $string );
304 }
305
309 function initializeClassAttribute( $classAttribute )
310 {
311 if ( $classAttribute->attribute( self::DEFAULT_FIELD ) == null )
312 $classAttribute->setAttribute( self::DEFAULT_FIELD, 0 );
313 $classAttribute->store();
314 }
315
316 function parseXML( $xmlText )
317 {
318 $dom = new DOMDocument;
319 $success = $dom->loadXML( $xmlText );
320 return $dom;
321 }
322
323 function classAttributeContent( $classAttribute )
324 {
325 $xmlText = $classAttribute->attribute( 'data_text5' );
326 if ( trim( $xmlText ) == '' )
327 {
328 $classAttrContent = eZDateTimeType::defaultClassAttributeContent();
329 return $classAttrContent;
330 }
331 $doc = eZDateTimeType::parseXML( $xmlText );
332 $root = $doc->documentElement;
333 $type = $root->getElementsByTagName( 'year' )->item( 0 );
334 if ( $type )
335 {
336 $content['year'] = $type->getAttribute( 'value' );
337 }
338 $type = $root->getElementsByTagName( 'month' )->item( 0 );
339 if ( $type )
340 {
341 $content['month'] = $type->getAttribute( 'value' );
342 }
343 $type = $root->getElementsByTagName( 'day' )->item( 0 );
344 if ( $type )
345 {
346 $content['day'] = $type->getAttribute( 'value' );
347 }
348 $type = $root->getElementsByTagName( 'hour' )->item( 0 );
349 if ( $type )
350 {
351 $content['hour'] = $type->getAttribute( 'value' );
352 }
353 $type = $root->getElementsByTagName( 'minute' )->item( 0 );
354 if ( $type )
355 {
356 $content['minute'] = $type->getAttribute( 'value' );
357 }
358 $type = $root->getElementsByTagName( 'second' )->item( 0 );
359 if ( $type )
360 {
361 $content['second'] = $type->getAttribute( 'value' );
362 }
363 return $content;
364 }
365
366 function defaultClassAttributeContent()
367 {
368 return array( 'year' => '',
369 'month' => '',
370 'day' => '',
371 'hour' => '',
372 'minute' => '',
373 'second' => '' );
374 }
375
379 function initializeObjectAttribute( $contentObjectAttribute, $currentVersion, $originalContentObjectAttribute )
380 {
381 if ( $currentVersion != false )
382 {
383 $dataInt = $originalContentObjectAttribute->attribute( "data_int" );
384 $contentObjectAttribute->setAttribute( "data_int", $dataInt );
385 }
386 else
387 {
388 $contentClassAttribute = $contentObjectAttribute->contentClassAttribute();
389 $defaultType = $contentClassAttribute->attribute( self::DEFAULT_FIELD );
390 if ( $defaultType == self::DEFAULT_CURRENT_DATE )
391 {
392 $contentObjectAttribute->setAttribute( "data_int", time() );
393 }
394 else if ( $defaultType == self::DEFAULT_ADJUSTMENT )
395 {
396 $adjustments = $this->classAttributeContent( $contentClassAttribute );
397 $value = new eZDateTime();
398 $secondAdjustment = $contentClassAttribute->attribute( self::USE_SECONDS_FIELD ) == 1 ? $adjustments['second'] : 0;
399 $value->adjustDateTime( $adjustments['hour'], $adjustments['minute'], $secondAdjustment, $adjustments['month'], $adjustments['day'], $adjustments['year'] );
400 $contentObjectAttribute->setAttribute( "data_int", $value->timeStamp() );
401 }
402 else
403 $contentObjectAttribute->setAttribute( "data_int", null );
404 }
405 }
406
407 function fetchClassAttributeHTTPInput( $http, $base, $classAttribute )
408 {
409 $default = $base . "_ezdatetime_default_" . $classAttribute->attribute( 'id' );
410 if ( $http->hasPostVariable( $default ) )
411 {
412 $defaultValue = $http->postVariable( $default );
413 $classAttribute->setAttribute( self::DEFAULT_FIELD, $defaultValue );
414 if ( $defaultValue == self::DEFAULT_ADJUSTMENT )
415 {
416 $doc = new DOMDocument( '1.0', 'utf-8' );
417 $root = $doc->createElement( 'adjustment' );
418 $contentList = eZDateTimeType::contentObjectArrayXMLMap();
419 foreach ( $contentList as $key => $value )
420 {
421 $postValue = $http->postVariable( $base . '_ezdatetime_' . $value . '_' . $classAttribute->attribute( 'id' ) );
422 unset( $elementType );
423 $elementType = $doc->createElement( $key );
424 $elementType->setAttribute( 'value', $postValue );
425 $root->appendChild( $elementType );
426 }
427 $doc->appendChild( $root );
428 $docText = $doc->saveXML();
429 $classAttribute->setAttribute( self::ADJUSTMENT_FIELD , $docText );
430 }
431
432 $useSeconds = $base . "_ezdatetime_use_seconds_" . $classAttribute->attribute( 'id' );
433 $classAttribute->setAttribute( self::USE_SECONDS_FIELD, $http->hasPostVariable( $useSeconds ) ? 1 : 0 );
434 }
435
436 return true;
437 }
438
439 function contentObjectArrayXMLMap()
440 {
441 return array( 'year' => 'year',
442 'month' => 'month',
443 'day' => 'day',
444 'hour' => 'hour',
445 'minute' => 'minute',
446 'second' => 'second' );
447 }
448
449
453 function title( $contentObjectAttribute, $name = null )
454 {
455 $locale = eZLocale::instance();
456 $retVal = $contentObjectAttribute->attribute( "data_int" ) === null ? '' : $locale->formatDateTime( $contentObjectAttribute->attribute( "data_int" ) );
457 return $retVal;
458 }
459
460 function hasObjectAttributeContent( $contentObjectAttribute )
461 {
462 return $contentObjectAttribute->attribute( "data_int" ) !== null;
463 }
464
465 function sortKey( $contentObjectAttribute )
466 {
467 return (int)$contentObjectAttribute->attribute( 'data_int' );
468 }
469
470 function sortKeyType()
471 {
472 return 'int';
473 }
474
475 function serializeContentClassAttribute( $classAttribute, $attributeNode, $attributeParametersNode )
476 {
477 $dom = $attributeParametersNode->ownerDocument;
478 $defaultValue = $classAttribute->attribute( self::DEFAULT_FIELD );
479 $defaultValueNode = $dom->createElement( 'default-value' );
480
481 switch ( $defaultValue )
482 {
483 case self::DEFAULT_CURRENT_DATE:
484 {
485 $defaultValueNode->setAttribute( 'type', 'current-date' );
486 } break;
487 case self::DEFAULT_ADJUSTMENT:
488 {
489 $defaultValueNode->setAttribute( 'type', 'adjustment' );
490
491 $adjustDOMValue = new DOMDocument( '1.0', 'utf-8' );
492 $adjustValue = $classAttribute->attribute( self::ADJUSTMENT_FIELD );
493 $success = $adjustDOMValue->loadXML( $adjustValue );
494
495 if ( $success )
496 {
497 $adjustmentNode = $adjustDOMValue->getElementsByTagName( 'adjustment' )->item( 0 );
498
499 if ( $adjustmentNode )
500 {
501 $importedAdjustmentNode = $dom->importNode( $adjustmentNode, true );
502 $defaultValueNode->appendChild( $importedAdjustmentNode );
503 }
504 }
505 } break;
506 case self::DEFAULT_EMTPY:
507 {
508 $defaultValueNode->setAttribute( 'type', 'empty' );
509 } break;
510 default:
511 {
512 eZDebug::writeError( 'Unknown type of DateTime default value. Empty type used instead.', __METHOD__ );
513 $defaultValueNode->setAttribute( 'type', 'empty' );
514 } break;
515 }
516 $attributeParametersNode->appendChild( $defaultValueNode );
517
518 $useSeconds = $classAttribute->attribute( self::USE_SECONDS_FIELD );
519 $useSecondsNode = $dom->createElement( 'use-seconds' );
520 $useSecondsNode->appendChild( $dom->createTextNode( $useSeconds ) );
521 $attributeParametersNode->appendChild( $useSecondsNode );
522 }
523
524 function unserializeContentClassAttribute( $classAttribute, $attributeNode, $attributeParametersNode )
525 {
526 $defaultValue = '';
527 $defaultNode = $attributeParametersNode->getElementsByTagName( 'default-value' )->item( 0 );
528 if ( $defaultNode )
529 {
530 $defaultValue = strtolower( $defaultNode->getAttribute( 'type' ) );
531 }
532 switch ( $defaultValue )
533 {
534 case 'current-date':
535 {
536 $classAttribute->setAttribute( self::DEFAULT_FIELD, self::DEFAULT_CURRENT_DATE );
537 } break;
538 case 'adjustment':
539 {
540 $adjustmentValue = '';
541 $adjustmentNode = $defaultNode->getElementsByTagName( 'adjustment' )->item( 0 );
542 if ( $adjustmentNode )
543 {
544 $adjustmentDOMValue = new DOMDocument( '1.0', 'utf-8' );
545 $importedAdjustmentNode = $adjustmentDOMValue->importNode( $adjustmentNode, true );
546 $adjustmentDOMValue->appendChild( $importedAdjustmentNode );
547 $adjustmentValue = $adjustmentDOMValue->saveXML();
548 }
549
550 $classAttribute->setAttribute( self::DEFAULT_FIELD, self::DEFAULT_ADJUSTMENT );
551 $classAttribute->setAttribute( self::ADJUSTMENT_FIELD, $adjustmentValue );
552 } break;
553 case 'empty':
554 {
555 $classAttribute->setAttribute( self::DEFAULT_FIELD, self::DEFAULT_EMTPY );
556 } break;
557 default:
558 {
559 eZDebug::writeError( 'Type of DateTime default value is not set. Empty type used as default.', __METHOD__ );
560 $classAttribute->setAttribute( self::DEFAULT_FIELD, self::DEFAULT_EMTPY );
561 } break;
562 }
563
564 $useSecondsNode = $attributeParametersNode->getElementsByTagName( 'use-seconds' )->item( 0 );
565 if ( $useSecondsNode && $useSecondsNode->textContent === '1' )
566 {
567 $classAttribute->setAttribute( self::USE_SECONDS_FIELD, 1 );
568 }
569 }
570
574 function serializeContentObjectAttribute( $package, $objectAttribute )
575 {
576 $node = $this->createContentObjectAttributeDOMNode( $objectAttribute );
577
578 $stamp = $objectAttribute->attribute( 'data_int' );
579
580 if ( $stamp !== null )
581 {
582 $dom = $node->ownerDocument;
583 $dateTimeNode = $dom->createElement( 'date_time' );
584 $dateTimeNode->appendChild( $dom->createTextNode( eZDateUtils::rfc1123Date( $stamp ) ) );
585 $node->appendChild( $dateTimeNode );
586 }
587 return $node;
588 }
589
590 function unserializeContentObjectAttribute( $package, $objectAttribute, $attributeNode )
591 {
592 $dateTimeNode = $attributeNode->getElementsByTagName( 'date_time' )->item( 0 );
593 if ( is_object( $dateTimeNode ) )
594 {
595 $timestamp = eZDateUtils::textToDate( $dateTimeNode->textContent );
596 $objectAttribute->setAttribute( 'data_int', $timestamp );
597 }
598 }
599
600 function supportsBatchInitializeObjectAttribute()
601 {
602 return true;
603 }
604
605 function batchInitializeObjectAttributeData( $classAttribute )
606 {
607 $defaultType = $classAttribute->attribute( self::DEFAULT_FIELD );
608
609 switch( $defaultType )
610 {
611 case self::DEFAULT_CURRENT_DATE:
612 {
613 $default = time();
614 } break;
615
616 case self::DEFAULT_ADJUSTMENT:
617 {
618 $adjustments = $this->classAttributeContent( $classAttribute );
619 $value = new eZDateTime();
620 $secondAdjustment = $classAttribute->attribute( self::USE_SECONDS_FIELD ) == 1 ? $adjustments['second'] : 0;
621 $value->adjustDateTime( $adjustments['hour'], $adjustments['minute'], $secondAdjustment, $adjustments['month'], $adjustments['day'], $adjustments['year'] );
622
623 $default = $value->timeStamp();
624 } break;
625
626 default:
627 {
628 return array();
629 }
630 }
631
632 return array( 'data_int' => $default, 'sort_key_int' => $default );
633 }
634 }
635
636 eZDataType::register( eZDateTimeType::DATA_TYPE_STRING, "eZDateTimeType" );
637
638 ?>
eZDataType
Base class for content datatypes.
Definition: ezdatatype.php:46
eZDataType\register
static register( $dataTypeString, $className)
Definition: ezdatatype.php:203
eZDataType\createContentObjectAttributeDOMNode
createContentObjectAttributeDOMNode( $objectAttribute)
Definition: ezdatatype.php:1371
eZDateTimeType
Stores a date and time value.
Definition: ezdatetimetype.php:19
eZDateTimeType\ADJUSTMENT_FIELD
const ADJUSTMENT_FIELD
Definition: ezdatetimetype.php:26
eZDateTimeType\validateDateTimeHTTPInput
validateDateTimeHTTPInput( $day, $month, $year, $hour, $minute, $second, $contentObjectAttribute)
Definition: ezdatetimetype.php:43
eZDateTimeType\initializeObjectAttribute
initializeObjectAttribute( $contentObjectAttribute, $currentVersion, $originalContentObjectAttribute)
Definition: ezdatetimetype.php:379
eZDateTimeType\isIndexable
isIndexable()
Definition: ezdatetimetype.php:269
eZDateTimeType\sortKeyType
sortKeyType()
Definition: ezdatetimetype.php:470
eZDateTimeType\fromString
fromString( $contentObjectAttribute, $string)
Definition: ezdatetimetype.php:296
eZDateTimeType\DEFAULT_ADJUSTMENT
const DEFAULT_ADJUSTMENT
Definition: ezdatetimetype.php:32
eZDateTimeType\DEFAULT_CURRENT_DATE
const DEFAULT_CURRENT_DATE
Definition: ezdatetimetype.php:30
eZDateTimeType\sortKey
sortKey( $contentObjectAttribute)
Definition: ezdatetimetype.php:465
eZDateTimeType\fetchCollectionAttributeHTTPInput
fetchCollectionAttributeHTTPInput( $collection, $collectionAttribute, $http, $base, $contentObjectAttribute)
Definition: ezdatetimetype.php:219
eZDateTimeType\USE_SECONDS_FIELD
const USE_SECONDS_FIELD
Definition: ezdatetimetype.php:24
eZDateTimeType\batchInitializeObjectAttributeData
batchInitializeObjectAttributeData( $classAttribute)
Definition: ezdatetimetype.php:605
eZDateTimeType\title
title( $contentObjectAttribute, $name=null)
Definition: ezdatetimetype.php:453
eZDateTimeType\classAttributeContent
classAttributeContent( $classAttribute)
Definition: ezdatetimetype.php:323
eZDateTimeType\serializeContentObjectAttribute
serializeContentObjectAttribute( $package, $objectAttribute)
Definition: ezdatetimetype.php:574
eZDateTimeType\__construct
__construct()
Definition: ezdatetimetype.php:34
eZDateTimeType\DEFAULT_FIELD
const DEFAULT_FIELD
Definition: ezdatetimetype.php:22
eZDateTimeType\supportsBatchInitializeObjectAttribute
supportsBatchInitializeObjectAttribute()
Definition: ezdatetimetype.php:600
eZDateTimeType\initializeClassAttribute
initializeClassAttribute( $classAttribute)
Definition: ezdatetimetype.php:309
eZDateTimeType\hasObjectAttributeContent
hasObjectAttributeContent( $contentObjectAttribute)
Definition: ezdatetimetype.php:460
eZDateTimeType\DEFAULT_EMTPY
const DEFAULT_EMTPY
Definition: ezdatetimetype.php:28
eZDateTimeType\isInformationCollector
isInformationCollector()
Definition: ezdatetimetype.php:274
eZDateTimeType\fetchObjectAttributeHTTPInput
fetchObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute)
Definition: ezdatetimetype.php:127
eZDateTimeType\fetchClassAttributeHTTPInput
fetchClassAttributeHTTPInput( $http, $base, $classAttribute)
Definition: ezdatetimetype.php:407
eZDateTimeType\toString
toString( $contentObjectAttribute)
Definition: ezdatetimetype.php:290
eZDateTimeType\contentObjectArrayXMLMap
contentObjectArrayXMLMap()
Definition: ezdatetimetype.php:439
eZDateTimeType\metaData
metaData( $contentObjectAttribute)
Definition: ezdatetimetype.php:282
eZDateTimeType\DATA_TYPE_STRING
const DATA_TYPE_STRING
Definition: ezdatetimetype.php:20
eZDateTimeType\objectAttributeContent
objectAttributeContent( $contentObjectAttribute)
Definition: ezdatetimetype.php:261
eZDateTimeType\unserializeContentClassAttribute
unserializeContentClassAttribute( $classAttribute, $attributeNode, $attributeParametersNode)
Definition: ezdatetimetype.php:524
eZDateTimeType\serializeContentClassAttribute
serializeContentClassAttribute( $classAttribute, $attributeNode, $attributeParametersNode)
Definition: ezdatetimetype.php:475
eZDateTimeType\defaultClassAttributeContent
defaultClassAttributeContent()
Definition: ezdatetimetype.php:366
eZDateTimeType\parseXML
parseXML( $xmlText)
Definition: ezdatetimetype.php:316
eZDateTimeType\unserializeContentObjectAttribute
unserializeContentObjectAttribute( $package, $objectAttribute, $attributeNode)
Definition: ezdatetimetype.php:590
eZDateTimeType\validateCollectionAttributeHTTPInput
validateCollectionAttributeHTTPInput( $http, $base, $contentObjectAttribute)
Definition: ezdatetimetype.php:165
eZDateTimeType\validateObjectAttributeHTTPInput
validateObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute)
Definition: ezdatetimetype.php:68
eZDateTimeValidator\validateTime
static validateTime( $hour, $minute, $second=0)
Definition: ezdatetimevalidator.php:31
eZDateTimeValidator\validateDate
static validateDate( $day, $month, $year)
Definition: ezdatetimevalidator.php:19
eZDateTime
Locale aware date and time handler.
Definition: ezdatetime.php:62
eZDateUtils\textToDate
static textToDate( $dateText)
Definition: ezdateutils.php:88
eZDateUtils\rfc1123Date
static rfc1123Date( $timestamp=false)
Definition: ezdateutils.php:34
eZDebug\writeError
static writeError( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:545
eZInputValidator\STATE_ACCEPTED
const STATE_ACCEPTED
Definition: ezinputvalidator.php:79
eZInputValidator\STATE_INVALID
const STATE_INVALID
Definition: ezinputvalidator.php:81
eZLocale\instance
static instance( $localeString=false)
Definition: ezlocale.php:1536
ezpI18n\tr
static tr( $context, $source, $comment=null, $arguments=null)
Definition: ezpi18n.php:86
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.