17 require_once SQ_FUDGE_PATH.
'/datetime_field/datetime_field.inc';
18 require_once dirname(__FILE__).
'/../../metadata_field/metadata_field.inc';
43 parent::__construct($assetid);
60 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
62 if (is_null($value_str)) {
63 $value = $this->
attr(
'default');
64 $value_components = $this->
attr(
'value_components');
67 $value_components = $this->
attr(
'value_components');
71 if (substr($value, 0, 1) ==
'%') {
74 $key = substr($value, 1, -1);
77 $format = str_replace(
' ',
'~', $this->
attr(
'format'));
80 $keyword = $key.
'_'.$format;
81 $offset = $this->
attr(
'offset');
82 if (!empty($offset)) {
83 $offset = str_replace(
' ',
'', $offset);
84 $keyword .=
'_'.$offset;
87 $metadata_values = $mm->generateKeywordReplacements($asset, Array($keyword), FALSE);
88 $value = $metadata_values[$keyword];
92 $value = $datetime_field->format();
112 $parameters = $this->
attr(
'setup_params');
113 if (empty($parameters)) {
116 'min' =>
'2003-01-01 00:00:00',
117 'max' => ($date[
'year'] + 1).
'-12-31 23:59:59',
118 'allow_circa' =>
'0',
119 'show' => Array(
'y',
'm',
'd',
'h',
'i',
's'),
131 $parameters[
'print_format'] = $this->
attr(
'format');
134 if (is_null($value)) {
135 if ((
boolean)$this->
attr(
'is_contextable') === TRUE) {
136 $value = $this->
attr(
'default');
138 $value = $GLOBALS[
'SQ_SYSTEM']->am->getAttributeValuesByName(
'default',
'metadata_field', Array($this->
id), 0);
139 $value = $value[$this->id];
142 if (!empty($value) && $value{0} ==
'%') {
143 $value = ts_iso8601(time());
145 $value = $parameters[
'min'];
149 $field =
new DateTime_Field($prefix.
'_datetime', $value, $parameters);