11 include_once(
"./Services/Table/interfaces/interface.ilTableFilterItem.php");
40 $this->
setMode(self::MODE_SELECT);
50 if(in_array(
$mode, array(self::MODE_INPUT, self::MODE_SELECT)))
78 $this->activation_title = $a_title;
79 $this->activation_post_var = $a_postvar;
80 $this->activation_checked = $a_checked;
107 $this->date = $a_date;
127 $this->showtime = $a_showtime;
147 $this->show_empty = $a_empty;
167 $this->startyear = $a_year;
190 $this->minute_step_size = $a_step_size;
213 $this->showseconds = $a_showseconds;
235 if($this->
getMode() == self::MODE_INPUT &&
236 (!isset($a_values[$this->
getPostVar()][
"date"]) || $a_values[$this->
getPostVar()][
"date"] ==
""))
240 else if(isset($a_values[$this->
getPostVar()][
"time"]))
245 else if (isset($a_values[$this->
getPostVar()][
"date"]))
251 if($this->activation_post_var)
253 $this->activation_checked = (bool)$a_values[$this->activation_post_var];
258 $item->setValueByArray($a_values);
279 if(!$this->
getRequired() && $this->
getMode() == self::MODE_INPUT && $post[
"date"] ==
"")
284 if($this->
getMode() == self::MODE_SELECT)
289 $dt[
'year'] = (int) $post[
'date'][
'y'];
290 $dt[
'mon'] = (int) $post[
'date'][
'm'];
291 $dt[
'mday'] = (int) $post[
'date'][
'd'];
298 $dt[
'hours'] = (int) $post[
'time'][
'h'];
299 $dt[
'minutes'] = (int) $post[
'time'][
'm'];
300 $dt[
'seconds'] = (int) $post[
'time'][
's'];
310 switch($ilUser->getDateFormat())
313 $date = explode(
".", $post[
"date"]);
314 $dt[
'mday'] = (int)
$date[0];
315 $dt[
'mon'] = (int)
$date[1];
316 $dt[
'year'] = (int)
$date[2];
320 $date = explode(
"-", $post[
"date"]);
321 $dt[
'mday'] = (int)
$date[2];
322 $dt[
'mon'] = (int)
$date[1];
323 $dt[
'year'] = (int)
$date[0];
327 $date = explode(
"/", $post[
"date"]);
328 $dt[
'mday'] = (int)
$date[1];
329 $dt[
'mon'] = (int)
$date[0];
330 $dt[
'year'] = (int)
$date[2];
341 $seconds =
":\s*([0-9]{1,2})\s*";
343 if(preg_match(
"/([0-9]{1,2})\s*:\s*([0-9]{1,2})\s*".$seconds.
"(am|pm)/", trim(strtolower($post[
"time"])), $matches))
345 $dt[
'hours'] = (int)$matches[1];
346 $dt[
'minutes'] = (int)$matches[2];
349 $dt[
'seconds'] = (int)
$time[2];
357 if($dt[
'hours'] == 12)
364 else if($ampm ==
"pm")
372 $time = explode(
":", $post[
"time"]);
373 $dt[
'hours'] = (int)
$time[0];
374 $dt[
'minutes'] = (int)
$time[1];
375 $dt[
'seconds'] = (int)
$time[2];
382 if($dt[
'mday'] == 0 || $dt[
'mon'] == 0 || $dt[
'year'] == 0 || $dt[
'mday'] > 31 || $dt[
'mon'] > 12)
386 else if($this->
getShowTime() && ($dt[
'hours'] > 23 || $dt[
'minutes'] > 59 || $dt[
'seconds'] > 59))
392 if(!checkdate($dt[
'mon'], $dt[
'mday'], $dt[
'year']))
395 $this->
setAlert($lng->txt(
"exc_date_not_valid"));
417 $tpl =
new ilTemplate(
"tpl.prop_datetime.html",
true,
true,
"Services/Form");
419 $lng->loadLanguageModule(
"jscalendar");
420 require_once(
"./Services/Calendar/classes/class.ilCalendarUtil.php");
425 $tpl->setCurrentBlock(
'prop_date_activation');
427 $tpl->setVariable(
'TXT_DATE_ENABLED',$this->activation_title);
428 $tpl->setVariable(
'CHECKED_ENABLED',$this->activation_checked ?
'checked="checked"' :
'');
429 $tpl->setVariable(
'CHECKED_DISABLED',$this->
getDisabled() ?
'disabled="disabled" ' :
'');
430 $tpl->parseCurrentBlock();
433 if($this->
getMode() == self::MODE_SELECT)
435 if(is_a($this->
getDate(),
'ilDate'))
439 elseif(is_a($this->
getDate(),
'ilDateTime'))
450 if(is_array($this->invalid_input))
452 $date_info[
'year'] = $this->invalid_input[
'y'];
453 $date_info[
'mon'] = $this->invalid_input[
'm'];
454 $date_info[
'mday'] = $this->invalid_input[
'd'];
460 $tpl->setCurrentBlock(
"prop_date_input_select_setup");
461 $tpl->setVariable(
"INPUT_FIELDS_DATE", $this->
getPostVar().
"[date]");
462 $tpl->parseCurrentBlock();
464 $tpl->setCurrentBlock(
"prop_date");
465 $tpl->setVariable(
"DATE_SELECT",
475 $day = substr($value, 8, 2);
476 $month = substr($value, 5, 2);
477 $year = substr($value, 0, 4);
480 switch($ilUser->getDateFormat())
485 $value = date(
"d.m.Y", mktime(0, 0, 0, $month, $day, $year));
487 $format =
"%d.%m.%Y";
488 $input_hint = $lng->txt(
"dd_mm_yyyy");
494 $value = date(
"Y-m-d", mktime(0, 0, 0, $month, $day, $year));
496 $format =
"%Y-%m-%d";
497 $input_hint = $lng->txt(
"yyyy_mm_dd");
503 $value = date(
"m/d/Y", mktime(0, 0, 0, $month, $day, $year));
505 $format =
"%m/%d/%Y";
506 $input_hint = $lng->txt(
"mm_dd_yyyy");
510 $tpl->setCurrentBlock(
"prop_date_input_field");
512 $tpl->setVariable(
"DATE_VALUE", $value);
513 $tpl->setVariable(
"DISABLED", $this->
getDisabled() ?
" disabled=\"disabled\"" :
"");
514 $tpl->parseCurrentBlock();
516 $tpl->setCurrentBlock(
"prop_date_input_field_info");
517 $tpl->setVariable(
"TXT_INPUT_FORMAT", $input_hint);
518 $tpl->parseCurrentBlock();
520 $tpl->setCurrentBlock(
"prop_date_input_field_setup");
522 $tpl->setVariable(
"DATE_FIELD_FORMAT", $format);
523 $tpl->parseCurrentBlock();
526 $tpl->setCurrentBlock(
"prop_date");
527 include_once(
"./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
531 include_once
'./Services/Calendar/classes/class.ilCalendarUserSettings.php';
534 $tpl->parseCurrentBlock();
538 if($this->
getMode() == self::MODE_INPUT)
548 $value = date(
"g:ia", mktime(substr($value, 0, 2), substr($value, 3, 2)));
556 $value = date(
"g:i:sa", mktime(substr($value, 0, 2), substr($value, 3, 2), substr($value, 6, 2)));
561 $tpl->setCurrentBlock(
"prop_time_input_field");
563 $tpl->setVariable(
"TIME_VALUE", $value);
564 $tpl->setVariable(
"DISABLED", $this->
getDisabled() ?
" disabled=\"disabled\"" :
"");
565 $tpl->parseCurrentBlock();
568 $tpl->setCurrentBlock(
"prop_time");
570 if($this->
getMode() == self::MODE_SELECT)
572 $tpl->setVariable(
"TIME_SELECT",
574 $date_info[
'hours'], $date_info[
'minutes'], $date_info[
'seconds'],
580 ?
"(".$lng->txt(
"hh_mm_ss").
")"
581 :
"(".$lng->txt(
"hh_mm").
")");
583 $tpl->parseCurrentBlock();
598 $a_tpl->setCurrentBlock(
"prop_generic");
599 $a_tpl->setVariable(
"PROP_GENERIC", $html);
600 $a_tpl->parseCurrentBlock();
617 return serialize($this->
getDate());
625 $data = unserialize($a_data);
627 if (is_object($data))
648 $html = $this->
render(
"toolbar");