3declare(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;
68 return $this->toggle_fulltime;
82 $this->start = $a_date;
87 $this->start_text = $a_txt;
92 return $this->start_text;
97 $this->end_text = $a_txt;
102 return $this->end_text;
121 $this->end = $a_date;
131 $this->showtime = $a_showtime;
136 return $this->showtime;
146 $this->startyear = $a_year;
151 return $this->startyear;
161 $this->minute_step_size = $a_step_size;
166 return $this->minute_step_size;
171 $incoming = $a_values[$this->getPostVar()] ?? [];
172 if (is_array($incoming) && $incoming !== []) {
173 $format = isset($incoming[
'tgl']) ? 0 : $this->getDatePickerTimeFormat();
174 $this->toggle_fulltime_checked = (bool) ($incoming[
'tgl'] ??
false);
176 if ($this->openIntervalsAllowed()) {
177 if (isset($incoming[
'start']) && is_string($incoming[
'start']) && trim($incoming[
'start']) !==
'') {
183 if (isset($incoming[
'end']) && is_string($incoming[
'end']) && trim($incoming[
'end']) !==
'') {
190 if ($incoming[
'start'] instanceof
ilDateTime) {
191 $this->setStart($incoming[
'start']);
196 $this->setEnd($incoming[
'end']);
203 foreach ($this->getSubItems() as $item) {
204 $item->setValueByArray($a_values);
212 if ($this->getDisabled()) {
218 $start =
$post[
"start"] ??
'';
219 $end =
$post[
"end"] ??
'';
224 : $this->getDatePickerTimeFormat();
230 $valid_start =
false;
234 $this->setStart($parsed);
238 if (!$this->getRequired() && !trim($end)) {
241 if ($this->openIntervalsAllowed() && !strlen(trim($start))) {
251 $this->setEnd($parsed);
255 if (!$this->getRequired() && !trim($start)) {
258 if ($this->openIntervalsAllowed() && !strlen(trim($end))) {
264 if ($this->getStartYear()) {
266 $this->getStart()->
get(
IL_CAL_FKT_DATE,
"Y") < $this->getStartYear()) {
267 $valid_start =
false;
274 $valid = ($valid_start && $valid_end);
283 if ($this->openIntervalsAllowed()) {
286 $this->invalid_input_start = $start;
287 $this->invalid_input_end = $end;
288 $this->setAlert(
$lng->txt(
"form_msg_wrong_date"));
292 $valid = $this->checkSubItemsInput();
300 $ret = $this->
strArray($this->getPostVar());
302 if ($this->openIntervalsAllowed()) {
303 if (!$this->getStart()) {
304 $ret[
"start"] =
null;
307 if (!$this->getEnd()) {
312 !$this->getStart() ||
315 $ret[
"start"] =
null;
319 $ret[
"fullday"] = (bool) ($ret[
"tgl"] ??
false);
325 return (
int) $this->getShowTime() + (
int) $this->getShowSeconds();
334 if ($this->getMinuteStepSize()) {
335 $config[
'stepping'] = $this->getMinuteStepSize();
337 if ($this->getStartYear()) {
338 $config[
'minDate'] = $this->getStartYear() .
'-01-01';
349 $tpl =
new ilTemplate(
"tpl.prop_datetime_duration.html",
true,
true,
"Services/Form");
351 if ($this->enabledToggleFullTime()) {
352 $this->setShowTime(
true);
354 $toggle_id = md5($this->getPostVar() .
'_fulltime');
356 $tpl->setCurrentBlock(
'toggle_fullday');
357 $tpl->setVariable(
'DATE_TOGGLE_ID', $this->getPostVar() .
'[tgl]');
358 $tpl->setVariable(
'FULLDAY_TOGGLE_ID', $toggle_id);
359 $tpl->setVariable(
'FULLDAY_TOGGLE_CHECKED', $this->toggle_fulltime_checked ?
'checked="checked"' :
'');
360 $tpl->setVariable(
'FULLDAY_TOGGLE_DISABLED', $this->getDisabled() ?
'disabled="disabled"' :
'');
361 $tpl->setVariable(
'TXT_TOGGLE_FULLDAY', $this->toggle_fulltime_txt);
362 $tpl->parseCurrentBlock();
366 if (!$this->getDisabled()) {
368 $picker_start_id = md5($this->getPostVar() .
'_start');
369 $picker_end_id = md5($this->getPostVar() .
'_end');
371 $tpl->setVariable(
'DATEPICKER_START_ID', $picker_start_id);
372 $tpl->setVariable(
'DATEPICKER_END_ID', $picker_end_id);
376 $this->getDatePickerTimeFormat(),
377 $this->parseDatePickerConfig(),
379 $this->parseDatePickerConfig(),
381 "subform_" . $this->getPostVar()
384 $tpl->setVariable(
'DATEPICKER_START_DISABLED',
'disabled="disabled" ');
385 $tpl->setVariable(
'DATEPICKER_END_DISABLED',
'disabled="disabled" ');
388 $start_txt = $this->getStartText();
389 if ($start_txt ===
null) {
390 $start_txt =
$lng->txt(
"form_date_duration_start");
392 if (trim($start_txt)) {
393 $tpl->setVariable(
'START_LABEL', $start_txt);
395 $tpl->touchBlock(
'start_width_bl');
398 $end_txt = $this->getEndText();
399 if ($end_txt ===
null) {
400 $end_txt =
$lng->txt(
"form_date_duration_end");
402 if (trim($end_txt)) {
403 $tpl->setVariable(
'END_LABEL', $end_txt);
405 $tpl->touchBlock(
'end_width_bl');
409 $tpl->setVariable(
'DATE_START_ID', $this->getPostVar() .
'[start]');
410 $tpl->setVariable(
'DATE_END_ID', $this->getPostVar() .
'[end]');
415 $tpl->setVariable(
'START_PLACEHOLDER', $pl_format);
416 $tpl->setVariable(
'END_PLACEHOLDER', $pl_format);
427 $date_value = htmlspecialchars($this->invalid_input_start);
433 $tpl->setVariable(
'DATEPICKER_START_VALUE', $date_value);
435 $date_value = htmlspecialchars($this->invalid_input_end);
441 $tpl->setVariable(
'DATEPICKER_END_VALUE', $date_value);
443 if ($this->getRequired()) {
444 $tpl->setVariable(
"START_REQUIRED",
"required=\"required\"");
445 $tpl->setVariable(
"END_REQUIRED",
"required=\"required\"");
454 $html = $this->render();
463 return $this->render();
469 'start' => $this->getStart() ? $this->getStart()->
get(
IL_CAL_UNIX) :
null,
470 'end' => $this->getEnd() ? $this->getEnd()->
get(
IL_CAL_UNIX) :
null
482 if (is_array($value)) {
490 if ($this->invalid_input_start ||
491 $this->invalid_input_end) {
495 return ((!$this->getStart() || $this->getStart()->isNull()) &&
496 (!$this->getEnd() || $this->getEnd()->isNull()));
501 return $this->allowOpenIntervals;
506 $this->allowOpenIntervals = $allowOpenInterval;
511 return $this->getFieldId() .
"[start]";
516 return $this->getFieldId() .
"[start]";
setVariable($variable, $value='')
Sets a variable value.
static getUserDateFormat(int $a_add_time=0, bool $a_for_parsing=false)
Parse current user setting into date/time format.
static parseIncomingDate($a_value, bool $a_add_time=false)
Try to parse incoming value to date object.
static addDateTimePicker(string $a_id, ?int $a_add_time=null, ?array $a_custom_config=null, ?string $a_id2=null, ?array $a_custom_config2=null, ?string $a_toggle_id=null, ?string $a_subform_id=null)
Add date time picker to element.
@classDescription Date and time handling
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.
special template class to simplify handling of ITX/PEAR
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc