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"]))
274 $item->setValueByArray($a_values);
295 if(!$this->
getRequired() && $this->
getMode() == self::MODE_INPUT && $post[
"date"] ==
"")
300 if($this->
getMode() == self::MODE_SELECT)
305 $dt[
'year'] = (int) $post[
'date'][
'y'];
306 $dt[
'mon'] = (int) $post[
'date'][
'm'];
307 $dt[
'mday'] = (int) $post[
'date'][
'd'];
314 $dt[
'hours'] = (int) $post[
'time'][
'h'];
315 $dt[
'minutes'] = (int) $post[
'time'][
'm'];
316 $dt[
'seconds'] = (int) $post[
'time'][
's'];
326 switch($ilUser->getDateFormat())
329 $date = explode(
".", $post[
"date"]);
330 $dt[
'mday'] = (int)
$date[0];
331 $dt[
'mon'] = (int)
$date[1];
332 $dt[
'year'] = (int)
$date[2];
336 $date = explode(
"-", $post[
"date"]);
337 $dt[
'mday'] = (int)
$date[2];
338 $dt[
'mon'] = (int)
$date[1];
339 $dt[
'year'] = (int)
$date[0];
343 $date = explode(
"/", $post[
"date"]);
344 $dt[
'mday'] = (int)
$date[1];
345 $dt[
'mon'] = (int)
$date[0];
346 $dt[
'year'] = (int)
$date[2];
357 $seconds =
":\s*([0-9]{1,2})\s*";
359 if(preg_match(
"/([0-9]{1,2})\s*:\s*([0-9]{1,2})\s*".$seconds.
"(am|pm)/", trim(strtolower($post[
"time"])), $matches))
361 $dt[
'hours'] = (int)$matches[1];
362 $dt[
'minutes'] = (int)$matches[2];
365 $dt[
'seconds'] = (int)
$time[2];
373 if($dt[
'hours'] == 12)
380 else if($ampm ==
"pm")
388 $time = explode(
":", $post[
"time"]);
389 $dt[
'hours'] = (int)
$time[0];
390 $dt[
'minutes'] = (int)
$time[1];
391 $dt[
'seconds'] = (int)
$time[2];
398 if($dt[
'mday'] == 0 || $dt[
'mon'] == 0 || $dt[
'year'] == 0 || $dt[
'mday'] > 31 || $dt[
'mon'] > 12)
402 else if($this->
getShowTime() && ($dt[
'hours'] > 23 || $dt[
'minutes'] > 59 || $dt[
'seconds'] > 59))
425 $tpl =
new ilTemplate(
"tpl.prop_datetime.html",
true,
true,
"Services/Form");
427 $lng->loadLanguageModule(
"jscalendar");
428 require_once(
"./Services/Calendar/classes/class.ilCalendarUtil.php");
433 $tpl->setCurrentBlock(
'prop_date_activation');
435 $tpl->setVariable(
'TXT_DATE_ENABLED',$this->activation_title);
436 $tpl->setVariable(
'CHECKED_ENABLED',$this->activation_checked ?
'checked="checked"' :
'');
437 $tpl->setVariable(
'CHECKED_DISABLED',$this->
getDisabled() ?
'disabled="disabled" ' :
'');
438 $tpl->parseCurrentBlock();
441 if($this->
getMode() == self::MODE_SELECT)
443 if(is_a($this->
getDate(),
'ilDate'))
447 elseif(is_a($this->
getDate(),
'ilDateTime'))
462 $tpl->setCurrentBlock(
"prop_date_input_select_setup");
463 $tpl->setVariable(
"INPUT_FIELDS_DATE", $this->
getPostVar().
"[date]");
464 $tpl->parseCurrentBlock();
466 $tpl->setCurrentBlock(
"prop_date");
467 $tpl->setVariable(
"DATE_SELECT",
477 $day = substr($value, 8, 2);
478 $month = substr($value, 5, 2);
479 $year = substr($value, 0, 4);
482 switch($ilUser->getDateFormat())
487 $value = date(
"d.m.Y", mktime(0, 0, 0, $month, $day, $year));
489 $format =
"%d.%m.%Y";
490 $input_hint = $lng->txt(
"dd_mm_yyyy");
496 $value = date(
"Y-m-d", mktime(0, 0, 0, $month, $day, $year));
498 $format =
"%Y-%m-%d";
499 $input_hint = $lng->txt(
"yyyy_mm_dd");
505 $value = date(
"m/d/Y", mktime(0, 0, 0, $month, $day, $year));
507 $format =
"%m/%d/%Y";
508 $input_hint = $lng->txt(
"mm_dd_yyyy");
512 $tpl->setCurrentBlock(
"prop_date_input_field");
514 $tpl->setVariable(
"DATE_VALUE", $value);
515 $tpl->setVariable(
"DISABLED", $this->
getDisabled() ?
" disabled=\"disabled\"" :
"");
516 $tpl->parseCurrentBlock();
518 $tpl->setCurrentBlock(
"prop_date_input_field_info");
519 $tpl->setVariable(
"TXT_INPUT_FORMAT", $input_hint);
520 $tpl->parseCurrentBlock();
522 $tpl->setCurrentBlock(
"prop_date_input_field_setup");
524 $tpl->setVariable(
"DATE_FIELD_FORMAT", $format);
525 $tpl->parseCurrentBlock();
528 $tpl->setCurrentBlock(
"prop_date");
530 $tpl->setVariable(
"TXT_DATE_CALENDAR", $lng->txt(
"open_calendar"));
533 include_once
'./Services/Calendar/classes/class.ilCalendarUserSettings.php';
536 $tpl->parseCurrentBlock();
540 if($this->
getMode() == self::MODE_INPUT)
550 $value = date(
"g:ia", mktime(substr($value, 0, 2), substr($value, 3, 2)));
558 $value = date(
"g:i:sa", mktime(substr($value, 0, 2), substr($value, 3, 2), substr($value, 6, 2)));
563 $tpl->setCurrentBlock(
"prop_time_input_field");
565 $tpl->setVariable(
"TIME_VALUE", $value);
566 $tpl->setVariable(
"DISABLED", $this->
getDisabled() ?
" disabled=\"disabled\"" :
"");
567 $tpl->parseCurrentBlock();
570 $tpl->setCurrentBlock(
"prop_time");
572 if($this->
getMode() == self::MODE_SELECT)
574 $tpl->setVariable(
"TIME_SELECT",
576 $date_info[
'hours'], $date_info[
'minutes'], $date_info[
'seconds'],
582 ?
"(".$lng->txt(
"hh_mm_ss").
")"
583 :
"(".$lng->txt(
"hh_mm").
")");
585 $tpl->parseCurrentBlock();
590 $tpl->setVariable(
"DELIM",
"<br />");
605 $a_tpl->setCurrentBlock(
"prop_generic");
606 $a_tpl->setVariable(
"PROP_GENERIC", $html);
607 $a_tpl->parseCurrentBlock();
624 return serialize($this->
getDate());
632 $data = unserialize($a_data);
634 if (is_object(
$data))