38 require_once realpath(dirname(__FILE__)).
"/../field_renderers.inc";
61 $label = isset($this->label) ? $this->label : $this->parent->prettifyFieldName($field);
63 $this->parent->validator->add(
new DateValidator($field, $label));
64 $this->parent->validator->add(
new TimeValidator($field, $label));
69 if($this->requireTime)
78 if (!$this->_includedDateScript)
80 echo
"<script src='{$this->parent->componentPath}/calendar/sonjara_calendar.js' type='text/javascript'></script>\n";
81 echo
"<link href='{$this->parent->componentPath}/calendar/sonjara_calendar.css' type='text/css' rel='stylesheet'>\n";
82 $this->_includedDateScript =
true;
85 $calendar =
"{$field}_calendar";
86 echo
"<script type='text/javascript'>\n";
87 echo
"var $calendar = new Calendar('$calendar', '', '{$this->parent->id}_{$field}');\n";
93 $obj = $this->parent->data;
94 $value = $obj->get($field);
98 if($value AND $value !=
'0000-00-00 00:00:00')
102 echo
"<input id='{$this->parent->id}_{$field}' type='text' name='$field' value='$date' size='12'> <img src='{$this->parent->componentPath}/calendar/calendar.gif' alt='Popup Calendar' align='absmiddle' border='0' onclick='{$field}_calendar.toggle(this)'>\n";
105 if ($value AND !preg_match(
"/00:00:00$/", $value))
107 $text = date(
"h/i/A", strtotime($value));
108 list($hh, $mm, $aa) = explode(
"/", $text);
111 echo
"<div id='{$this->parent->id}_{$field}_block' style='display: inline'>\n";
112 echo
" <input type='text' value='$hh' name='{$field}_hh' size='2' maxlength='2' onkeydown='return maskInput(event);'>
113 : <input type='text' value='$mm' name='{$field}_mm' size='2' maxlength='2' onkeydown='return maskInput(event);'>";
114 echo
" <select name='{$field}_aa'><option";
115 if ($aa ==
'AM') echo
" selected";
116 echo
">AM</option><option";
117 if ($aa ==
'PM') echo
" selected";
118 echo
">PM</option></select>";
128 if (!$this->_includedDateScript)
130 echo
"<script src='{$this->parent->componentPath}/calendar/sonjara_calendar.js' type='text/javascript'></script>\n";
131 echo
"<link href='{$this->parent->componentPath}/calendar/sonjara_calendar.css' type='text/css' rel='stylesheet'>\n";
132 $this->_includedDateScript =
true;
135 if ($mode ==
"range")
137 $calendar_from =
"{$field}_calendar_from";
138 $calendar_to =
"{$field}_calendar_to";
140 echo
"<script type='text/javascript'>\n";
141 echo
"var $calendar_from = new Calendar('$calendar_from', '{$this->parent->id}', '$field:from');\n";
142 echo
"var $calendar_to = new Calendar('$calendar_to', '{$this->parent->id}', '$field:to');\n";
147 $calendar =
"{$field}_calendar_{$mode}";
148 echo
"<script type='text/javascript'>\n";
149 echo
"var $calendar = new Calendar('$calendar', '{$this->parent->id}', '$field:$mode');\n";
156 if ($mode ==
"range")
158 $date_from = $this->parent->params->get($field,
"from");
159 $date_to = $this->parent->params->get($field,
"to");
163 echo
"<input type='text' name='$field:from' value='$date_from' size='12'> <img src='{$this->parent->componentPath}/calendar/calendar.gif' alt='Popup Calendar' align='absmiddle' border='0' onclick='{$field}_calendar_from.toggle(this)'>";
164 echo
" to <input type='text' name='$field:to' value='$date_to' size='12'> <img src='{$this->parent->componentPath}/calendar/calendar.gif' alt='Popup Calendar' align='absmiddle' border='0' onclick='{$field}_calendar_to.toggle(this)'></td>\n";
170 $date = $this->parent->params->get($field, $mode);
174 echo
"<input type='text' name='$field:$mode' value='$date' size='12'> <img src='{$this->parent->componentPath}/calendar/calendar.gif' alt='Popup Calendar' align='absmiddle' border='0' onclick='{$field}_calendar_{$mode}.toggle(this)'></td>\n";
184 echo $this->
format($field);
188 if (!$this->parent->readOnlyForm)
190 $obj = $this->parent->data;
191 $value = $obj->get($field);
192 echo
"<input type='hidden' name='$field' value='{$value}'/>";
201 if(intval($hh) == 0) $hh =
"00";
203 if(intval($mm) == 0) $mm =
"00";
204 $aa = $_POST[
"{$field}_aa"];
205 $dd = $_POST[
"{$field}"];
209 $this->parent->data->set($field, $this->parent->data->reformatToSQLDate(
"00/00/0000 00:00:00"));
212 if($hh ==
"00" && $mm ==
"00")
214 $this->parent->data->set($field, $this->parent->data->reformatToSQLDate(
"$dd"));
218 if ($aa !=
"AM" && $aa !=
"PM")
throw new FakoliException(
"Invalid meridiem");
219 if ($aa ==
"PM" && $hh !=
"12") $hh += 12;
220 if ($aa ==
"AM" && $hh ==
"12") $hh =
"00";
221 $this->parent->data->set($field, $this->parent->data->reformatToSQLDate(
"$dd $hh:$mm:00"));
Field renderer for date data fields.
renderSearchField($field, $mode)
FieldRenderers must override this method to provide the HTML implementation of the control displayed ...
renderSearchScript($field, $mode)
FieldRenderers can override this method to provide any Javascript that the control requires when bein...
renderField($field)
FieldRenderers must override this method to provide the HTML implementation of the control used to ed...
DateTimeFieldRenderer(&$parent)
renderScript($field)
FieldRenderers can override this method to provide any Javascript that their control requires for an ...
addValidatorsToForm($field, $required=false)
This method is called by the AutoForm to add any default input validators that are required by the Fi...
preProcess($field="")
FieldRenderers can override this method to provide behavior that occurs prior to the saving of the pa...
static format($datetime, $template="")
FieldRenderer is the abstract base class for all FieldRenderers.
_startField($field, $styles="")
Internal method to generate the starting HTML for the field (including the label)
_endField($field)
Internal method to generate the closing HTML for the field.
_printLabel($field, $colspan=1, $styles="", $annotation="")
Internal method to generate the HTML for the field label.
FieldRenderer($parent)
Constructor.
checkNumeric($p)
Security helper function.