19 declare(strict_types=1);
46 string $a_postvar =
"" 50 $this->
lng = $DIC->language();
51 $this->
user = $DIC->user();
61 $this->toggle_fulltime_txt = $a_title;
62 $this->toggle_fulltime_checked = $a_checked;
63 $this->toggle_fulltime =
true;
82 $this->start = $a_date;
87 $this->start_text = $a_txt;
97 $this->end_text = $a_txt;
121 $this->end = $a_date;
131 $this->showtime = $a_showtime;
141 $this->startyear = $a_year;
156 $this->minute_step_size = $a_step_size;
169 $incoming = $a_values[$this->
getPostVar()] ?? [];
170 if (is_array($incoming) && $incoming !== []) {
172 $this->toggle_fulltime_checked = (bool) ($incoming[
'tgl'] ??
false);
175 if (isset($incoming[
'start']) && is_string($incoming[
'start']) && trim($incoming[
'start']) !==
'') {
181 if (isset($incoming[
'end']) && is_string($incoming[
'end']) && trim($incoming[
'end']) !==
'') {
188 if ($incoming[
'start'] instanceof
ilDateTime) {
189 $this->
setStart($incoming[
'start']);
193 if ($incoming[
'end'] instanceof ilDateTime) {
194 $this->
setEnd($incoming[
'end']);
202 $item->setValueByArray($a_values);
216 $start =
$post[
"start"] ??
'';
217 $end =
$post[
"end"] ??
'';
220 $format = isset(
$post[
'tgl'])
228 $valid_start =
false;
248 } elseif (!$this->
getRequired() && !trim($start)) {
257 $valid_start =
false;
264 $valid = ($valid_start && $valid_end);
276 $this->invalid_input_start =
$start;
277 $this->invalid_input_end =
$end;
294 $ret[
"start"] = null;
304 $ret[
"start"] = null;
307 $ret[
"fullday"] = (bool) ($ret[
"tgl"] ??
false);
331 $tpl =
new ilTemplate(
"tpl.prop_datetime_duration.html",
true,
true,
"components/ILIAS/Form");
336 $toggle_id =
't' . md5($this->
getPostVar() .
'_fulltime');
338 $tpl->setCurrentBlock(
'toggle_fullday');
339 $tpl->setVariable(
'DATE_TOGGLE_ID', $this->
getPostVar() .
'[tgl]');
340 $tpl->setVariable(
'FULLDAY_TOGGLE_ID', $toggle_id);
341 $tpl->setVariable(
'FULLDAY_TOGGLE_CHECKED', $this->toggle_fulltime_checked ?
'checked="checked"' :
'');
342 $tpl->setVariable(
'FULLDAY_TOGGLE_DISABLED', $this->
getDisabled() ?
'disabled="disabled"' :
'');
343 $tpl->setVariable(
'TXT_TOGGLE_FULLDAY', $this->toggle_fulltime_txt);
344 $tpl->parseCurrentBlock();
350 $picker_start_id =
'p' . md5($this->
getPostVar() .
'_start');
351 $picker_end_id =
'p' . md5($this->
getPostVar() .
'_end');
353 $tpl->setVariable(
'DATEPICKER_START_ID', $picker_start_id);
354 $tpl->setVariable(
'DATEPICKER_END_ID', $picker_end_id);
356 $this->global_tpl->addOnLoadCode(
357 'il.Form.initDateDurationPicker("' .
358 $picker_start_id .
'","' .
359 $picker_end_id .
'","' .
364 $tpl->setVariable(
'DATEPICKER_START_DISABLED',
'disabled="disabled" ');
365 $tpl->setVariable(
'DATEPICKER_END_DISABLED',
'disabled="disabled" ');
370 $type =
'datetime-local';
372 $tpl->setVariable(
'DATEPICKER_START_TYPE',
$type);
373 $tpl->setVariable(
'DATEPICKER_END_TYPE',
$type);
376 if ($start_txt === null) {
377 $start_txt =
$lng->
txt(
"form_date_duration_start");
379 if (trim($start_txt)) {
380 $tpl->setVariable(
'START_LABEL', $start_txt);
382 $tpl->touchBlock(
'start_width_bl');
386 if ($end_txt === null) {
387 $end_txt =
$lng->
txt(
"form_date_duration_end");
389 if (trim($end_txt)) {
390 $tpl->setVariable(
'END_LABEL', $end_txt);
392 $tpl->touchBlock(
'end_width_bl');
396 $tpl->setVariable(
'DATE_START_ID', $this->
getPostVar() .
'[start]');
397 $tpl->setVariable(
'DATE_END_ID', $this->
getPostVar() .
'[end]');
407 $tpl->setVariable(
'DATEPICKER_START_STEP', $step_size);
408 $tpl->setVariable(
'DATEPICKER_END_STEP', $step_size);
411 $min = DateTimeImmutable::createFromFormat(
415 $tpl->setVariable(
'DATEPICKER_START_MIN', $min);
416 $tpl->setVariable(
'DATEPICKER_END_MIN', $min);
427 $tpl->setVariable(
'DATEPICKER_START_VALUE', $date_value);
434 $tpl->setVariable(
'DATEPICKER_END_VALUE', $date_value);
437 $tpl->setVariable(
"START_REQUIRED",
"required=\"required\"");
438 $tpl->setVariable(
"END_REQUIRED",
"required=\"required\"");
446 $timestamp = strtotime(htmlspecialchars($invalid_input));
484 if (is_array($value)) {
492 if ($this->invalid_input_start ||
493 $this->invalid_input_end) {
508 $this->allowOpenIntervals = $allowOpenInterval;
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
static parseIncomingDate($value, bool $add_time=false)
Try to parse incoming value to date object.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
setVariable($variable, $value='')
Sets a variable value.
static _after(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
compare two dates and check start is after end This method does not consider tz offsets.
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
foreach($mandatory_scripts as $file) $timestamp
__construct(Container $dic, ilPlugin $plugin)