11 include_once(
"./Services/Table/interfaces/interface.ilTableFilterItem.php");
41 $this->
setMode(self::MODE_SELECT);
51 if(in_array(
$mode, array(self::MODE_INPUT, self::MODE_SELECT)))
79 $this->activation_title = $a_title;
80 $this->activation_post_var = $a_postvar;
81 $this->activation_checked = $a_checked;
108 $this->date = $a_date;
128 $this->showdate = $a_showdate;
148 $this->showtime = $a_showtime;
168 $this->show_empty = $a_empty;
188 $this->startyear = $a_year;
211 $this->minute_step_size = $a_step_size;
234 $this->showseconds = $a_showseconds;
256 if($this->
getMode() == self::MODE_INPUT &&
257 (!isset($a_values[$this->
getPostVar()][
"date"]) || $a_values[$this->
getPostVar()][
"date"] ==
""))
261 else if(isset($a_values[$this->
getPostVar()][
"time"]))
266 else if (isset($a_values[$this->
getPostVar()][
"date"]))
272 if($this->activation_post_var)
274 $this->activation_checked = (bool)$a_values[$this->activation_post_var];
279 $item->setValueByArray($a_values);
300 if(!$this->
getRequired() && $this->
getMode() == self::MODE_INPUT && $post[
"date"] ==
"")
305 if($this->
getMode() == self::MODE_SELECT)
310 $dt[
'year'] = (int) $post[
'date'][
'y'];
311 $dt[
'mon'] = (int) $post[
'date'][
'm'];
312 $dt[
'mday'] = (int) $post[
'date'][
'd'];
319 $dt[
'hours'] = (int) $post[
'time'][
'h'];
320 $dt[
'minutes'] = (int) $post[
'time'][
'm'];
321 $dt[
'seconds'] = (int) $post[
'time'][
's'];
331 switch($ilUser->getDateFormat())
334 $date = explode(
".", $post[
"date"]);
335 $dt[
'mday'] = (int)
$date[0];
336 $dt[
'mon'] = (int)
$date[1];
337 $dt[
'year'] = (int)
$date[2];
341 $date = explode(
"-", $post[
"date"]);
342 $dt[
'mday'] = (int)
$date[2];
343 $dt[
'mon'] = (int)
$date[1];
344 $dt[
'year'] = (int)
$date[0];
348 $date = explode(
"/", $post[
"date"]);
349 $dt[
'mday'] = (int)
$date[1];
350 $dt[
'mon'] = (int)
$date[0];
351 $dt[
'year'] = (int)
$date[2];
362 $seconds =
":\s*([0-9]{1,2})\s*";
364 if(preg_match(
"/([0-9]{1,2})\s*:\s*([0-9]{1,2})\s*".$seconds.
"(am|pm)/", trim(strtolower($post[
"time"])), $matches))
366 $dt[
'hours'] = (int)$matches[1];
367 $dt[
'minutes'] = (int)$matches[2];
370 $dt[
'seconds'] = (int)
$time[2];
378 if($dt[
'hours'] == 12)
385 else if($ampm ==
"pm")
393 $time = explode(
":", $post[
"time"]);
394 $dt[
'hours'] = (int)
$time[0];
395 $dt[
'minutes'] = (int)
$time[1];
396 $dt[
'seconds'] = (int)
$time[2];
403 if($dt[
'mday'] == 0 || $dt[
'mon'] == 0 || $dt[
'year'] == 0 || $dt[
'mday'] > 31 || $dt[
'mon'] > 12)
407 else if($this->
getShowTime() && ($dt[
'hours'] > 23 || $dt[
'minutes'] > 59 || $dt[
'seconds'] > 59))
413 if(!checkdate($dt[
'mon'], $dt[
'mday'], $dt[
'year']))
416 $this->
setAlert($lng->txt(
"exc_date_not_valid"));
438 $tpl =
new ilTemplate(
"tpl.prop_datetime.html",
true,
true,
"Services/Form");
440 $lng->loadLanguageModule(
"jscalendar");
441 require_once(
"./Services/Calendar/classes/class.ilCalendarUtil.php");
446 $tpl->setCurrentBlock(
'prop_date_activation');
448 $tpl->setVariable(
'TXT_DATE_ENABLED',$this->activation_title);
449 $tpl->setVariable(
'CHECKED_ENABLED',$this->activation_checked ?
'checked="checked"' :
'');
450 $tpl->setVariable(
'CHECKED_DISABLED',$this->
getDisabled() ?
'disabled="disabled" ' :
'');
451 $tpl->parseCurrentBlock();
454 if($this->
getMode() == self::MODE_SELECT)
456 if(is_a($this->
getDate(),
'ilDate'))
460 elseif(is_a($this->
getDate(),
'ilDateTime'))
471 if(is_array($this->invalid_input))
473 $date_info[
'year'] = $this->invalid_input[
'y'];
474 $date_info[
'mon'] = $this->invalid_input[
'm'];
475 $date_info[
'mday'] = $this->invalid_input[
'd'];
483 $tpl->setCurrentBlock(
"prop_date_input_select_setup");
484 $tpl->setVariable(
"INPUT_FIELDS_DATE", $this->
getPostVar().
"[date]");
485 $tpl->parseCurrentBlock();
487 $tpl->setCurrentBlock(
"prop_date");
488 $tpl->setVariable(
"DATE_SELECT",
498 $day = substr($value, 8, 2);
499 $month = substr($value, 5, 2);
500 $year = substr($value, 0, 4);
503 switch($ilUser->getDateFormat())
508 $value = date(
"d.m.Y", mktime(0, 0, 0, $month, $day, $year));
510 $format =
"%d.%m.%Y";
511 $input_hint = $lng->txt(
"dd_mm_yyyy");
517 $value = date(
"Y-m-d", mktime(0, 0, 0, $month, $day, $year));
519 $format =
"%Y-%m-%d";
520 $input_hint = $lng->txt(
"yyyy_mm_dd");
526 $value = date(
"m/d/Y", mktime(0, 0, 0, $month, $day, $year));
528 $format =
"%m/%d/%Y";
529 $input_hint = $lng->txt(
"mm_dd_yyyy");
533 $tpl->setCurrentBlock(
"prop_date_input_field");
535 $tpl->setVariable(
"DATE_VALUE", $value);
536 $tpl->setVariable(
"DISABLED", $this->
getDisabled() ?
" disabled=\"disabled\"" :
"");
537 $tpl->parseCurrentBlock();
539 $tpl->setCurrentBlock(
"prop_date_input_field_info");
540 $tpl->setVariable(
"TXT_INPUT_FORMAT", $input_hint);
541 $tpl->parseCurrentBlock();
543 $tpl->setCurrentBlock(
"prop_date_input_field_setup");
545 $tpl->setVariable(
"DATE_FIELD_FORMAT", $format);
546 $tpl->parseCurrentBlock();
549 $tpl->setCurrentBlock(
"prop_date");
551 $tpl->setVariable(
"TXT_DATE_CALENDAR", $lng->txt(
"open_calendar"));
554 include_once
'./Services/Calendar/classes/class.ilCalendarUserSettings.php';
557 $tpl->parseCurrentBlock();
561 if($this->
getMode() == self::MODE_INPUT)
571 $value = date(
"g:ia", mktime(substr($value, 0, 2), substr($value, 3, 2)));
579 $value = date(
"g:i:sa", mktime(substr($value, 0, 2), substr($value, 3, 2), substr($value, 6, 2)));
584 $tpl->setCurrentBlock(
"prop_time_input_field");
586 $tpl->setVariable(
"TIME_VALUE", $value);
587 $tpl->setVariable(
"DISABLED", $this->
getDisabled() ?
" disabled=\"disabled\"" :
"");
588 $tpl->parseCurrentBlock();
591 $tpl->setCurrentBlock(
"prop_time");
593 if($this->
getMode() == self::MODE_SELECT)
595 $tpl->setVariable(
"TIME_SELECT",
597 $date_info[
'hours'], $date_info[
'minutes'], $date_info[
'seconds'],
603 ?
"(".$lng->txt(
"hh_mm_ss").
")"
604 :
"(".$lng->txt(
"hh_mm").
")");
606 $tpl->parseCurrentBlock();
611 $tpl->setVariable(
"DELIM",
"<br />");
626 $a_tpl->setCurrentBlock(
"prop_generic");
627 $a_tpl->setVariable(
"PROP_GENERIC", $html);
628 $a_tpl->parseCurrentBlock();
645 return serialize($this->
getDate());
653 $data = unserialize($a_data);
655 if (is_object($data))
676 $html = $this->
render(
"toolbar");