11 include_once(
"./Services/Table/interfaces/interface.ilTableFilterItem.php");
38 parent::__construct($a_title, $a_postvar);
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"));
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 if(!$this->activation_checked)
435 $tpl->setCurrentBlock(
'sub_form_hide');
437 $tpl->parseCurrentBlock();
442 $tpl->setCurrentBlock(
'activation_description');
443 $tpl->setVariable(
'ACT_DESCRIPTION',$this->
getInfo());
444 $tpl->parseCurrentBlock();
450 $tpl->setCurrentBlock(
'prop_date_activation');
454 $tpl->setVariable(
'TXT_DATE_ENABLED',$this->activation_title);
455 $tpl->setVariable(
'CHECKED_ENABLED',$this->activation_checked ?
'checked="checked"' :
'');
456 $tpl->setVariable(
'CHECKED_DISABLED',$this->
getDisabled() ?
'disabled="disabled" ' :
'');
457 $tpl->parseCurrentBlock();
459 $tpl->touchBlock(
'prop_date_activation_out');
462 if($this->
getMode() == self::MODE_SELECT)
464 if(is_a($this->
getDate(),
'ilDate'))
468 elseif(is_a($this->
getDate(),
'ilDateTime'))
479 if(is_array($this->invalid_input))
481 $date_info[
'year'] = $this->invalid_input[
'y'];
482 $date_info[
'mon'] = $this->invalid_input[
'm'];
483 $date_info[
'mday'] = $this->invalid_input[
'd'];
487 if($this->
getMode() == self::MODE_SELECT)
489 $tpl->setCurrentBlock(
"prop_date_input_select_setup");
490 $tpl->setVariable(
"INPUT_FIELDS_DATE", $this->
getPostVar().
"[date]");
491 $tpl->parseCurrentBlock();
493 $tpl->setCurrentBlock(
"prop_date");
494 $tpl->setVariable(
"DATE_SELECT",
504 $day = substr($value, 8, 2);
505 $month = substr($value, 5, 2);
506 $year = substr($value, 0, 4);
509 switch($ilUser->getDateFormat())
514 $value = date(
"d.m.Y", mktime(0, 0, 0, $month, $day, $year));
516 $format =
"%d.%m.%Y";
517 $input_hint = $lng->txt(
"dd_mm_yyyy");
523 $value = date(
"Y-m-d", mktime(0, 0, 0, $month, $day, $year));
525 $format =
"%Y-%m-%d";
526 $input_hint = $lng->txt(
"yyyy_mm_dd");
532 $value = date(
"m/d/Y", mktime(0, 0, 0, $month, $day, $year));
534 $format =
"%m/%d/%Y";
535 $input_hint = $lng->txt(
"mm_dd_yyyy");
540 if($this->invalid_input)
542 $value = $this->invalid_input;
545 $tpl->setCurrentBlock(
"prop_date_input_field");
547 $tpl->setVariable(
"DATE_VALUE", $value);
548 $tpl->setVariable(
"DISABLED", $this->
getDisabled() ?
" disabled=\"disabled\"" :
"");
549 $tpl->parseCurrentBlock();
551 $tpl->setCurrentBlock(
"prop_date_input_field_info");
552 $tpl->setVariable(
"TXT_INPUT_FORMAT", $input_hint);
553 $tpl->parseCurrentBlock();
555 $tpl->setCurrentBlock(
"prop_date_input_field_setup");
557 $tpl->setVariable(
"DATE_FIELD_FORMAT", $format);
558 $tpl->parseCurrentBlock();
561 $tpl->setCurrentBlock(
"prop_date");
562 include_once(
"./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
566 include_once
'./Services/Calendar/classes/class.ilCalendarUserSettings.php';
569 $tpl->parseCurrentBlock();
573 if($this->
getMode() == self::MODE_INPUT)
583 $value = date(
"g:ia", mktime(substr($value, 0, 2), substr($value, 3, 2)));
591 $value = date(
"g:i:sa", mktime(substr($value, 0, 2), substr($value, 3, 2), substr($value, 6, 2)));
596 $tpl->setCurrentBlock(
"prop_time_input_field");
598 $tpl->setVariable(
"TIME_VALUE", $value);
599 $tpl->setVariable(
"DISABLED", $this->
getDisabled() ?
" disabled=\"disabled\"" :
"");
600 $tpl->parseCurrentBlock();
603 $tpl->setCurrentBlock(
"prop_time");
605 if($this->
getMode() == self::MODE_SELECT)
607 $tpl->setVariable(
"TIME_SELECT",
609 $date_info[
'hours'], $date_info[
'minutes'], $date_info[
'seconds'],
615 ?
"(".$lng->txt(
"hh_mm_ss").
")" 616 :
"(".$lng->txt(
"hh_mm").
")");
618 $tpl->parseCurrentBlock();
633 $a_tpl->setCurrentBlock(
"prop_generic");
634 $a_tpl->setVariable(
"PROP_GENERIC",
$html);
635 $a_tpl->parseCurrentBlock();
652 return serialize($this->
getDate());
660 $data = unserialize($a_data);
662 if (is_object(
$data))
Interface for property form input GUI classes that can be used in table filters.
static get($a_glyph, $a_text="")
Get glyph html.
static makeTimeSelect($prefix, $short=true, $hour="", $minute="", $second="", $a_use_default=true, $a_further_options=array())
Creates a combination of HTML selects for time inputs.
static _getInstance()
get instance for logged in user
special template class to simplify handling of ITX/PEAR
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static makeDateSelect($prefix, $year="", $month="", $day="", $startyear="", $a_long_month=true, $a_further_options=array(), $emptyoption=false)
Creates a combination of HTML selects for date inputs.
static initJSCalendar()
Init Javascript Calendar.