public function addToForm() { global $lng; if ($this->getForm() instanceof ilPropertyFormGUI) { // :TODO: use DateDurationInputGUI ?! if (!(bool) $this->text_input) { $check = new ilCheckboxInputGUI($this->getTitle(), $this->addToElementId("tgl")); $check->setValue(1); $checked = false; } else { $check = new ilCustomInputGUI($this->getTitle()); } $date_from = new ilDateTimeInputGUI($lng->txt('from'), $this->addToElementId("lower")); $date_from->setShowTime(true); $check->addSubItem($date_from); if ($this->getLowerADT()->getDate() && !$this->getLowerADT()->isNull()) { $date_from->setDate($this->getLowerADT()->getDate()); $checked = true; } $date_until = new ilDateTimeInputGUI($lng->txt('until'), $this->addToElementId("upper")); $date_until->setShowTime(true); $check->addSubItem($date_until); if ($this->getUpperADT()->getDate() && !$this->getUpperADT()->isNull()) { $date_until->setDate($this->getUpperADT()->getDate()); $checked = true; } if (!(bool) $this->text_input) { $check->setChecked($checked); } else { $date_from->setMode(ilDateTimeInputGUI::MODE_INPUT); $date_until->setMode(ilDateTimeInputGUI::MODE_INPUT); } $this->addToParentElement($check); } else { // see ilTable2GUI::addFilterItemByMetaType() include_once "./Services/Form/classes/class.ilCombinationInputGUI.php"; include_once "./Services/Form/classes/class.ilDateTimeInputGUI.php"; $item = new ilCombinationInputGUI($this->getTitle(), $this->getElementId()); $lower = new ilDateTimeInputGUI("", $this->addToElementId("lower")); $lower->setShowTime(true); $item->addCombinationItem("lower", $lower, $lng->txt("from")); if ($this->getLowerADT()->getDate() && !$this->getLowerADT()->isNull()) { $lower->setDate($this->getLowerADT()->getDate()); } $upper = new ilDateTimeInputGUI("", $this->addToElementId("upper")); $upper->setShowTime(true); $item->addCombinationItem("upper", $upper, $lng->txt("to")); if ($this->getUpperADT()->getDate() && !$this->getUpperADT()->isNull()) { $upper->setDate($this->getUpperADT()->getDate()); } $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING); $item->setMode(ilDateTimeInputGUI::MODE_INPUT); $this->addToParentElement($item); } }
/** * Add filter by standard type * * @param string $id * @param int $type * @param bool $a_optional * @param string $caption * @return object */ function addFilterItemByMetaType($id, $type = self::FILTER_TEXT, $a_optional = false, $caption = NULL) { global $lng; if (!$caption) { $caption = $lng->txt($id); } include_once "./Services/Form/classes/class.ilPropertyFormGUI.php"; switch ($type) { case self::FILTER_SELECT: include_once "./Services/Form/classes/class.ilSelectInputGUI.php"; $item = new ilSelectInputGUI($caption, $id); break; case self::FILTER_DATE: include_once "./Services/Form/classes/class.ilDateTimeInputGUI.php"; $item = new ilDateTimeInputGUI($caption, $id); $item->setMode(ilDateTimeInputGUI::MODE_INPUT); break; case self::FILTER_TEXT: include_once "./Services/Form/classes/class.ilTextInputGUI.php"; $item = new ilTextInputGUI($caption, $id); $item->setMaxLength(64); $item->setSize(20); // $item->setSubmitFormOnEnter(true); break; case self::FILTER_LANGUAGE: $lng->loadLanguageModule("meta"); include_once "./Services/Form/classes/class.ilSelectInputGUI.php"; $item = new ilSelectInputGUI($caption, $id); $options = array("" => $lng->txt("trac_all")); foreach ($lng->getInstalledLanguages() as $lang_key) { $options[$lang_key] = $lng->txt("meta_l_" . $lang_key); } $item->setOptions($options); break; case self::FILTER_NUMBER_RANGE: include_once "./Services/Form/classes/class.ilCombinationInputGUI.php"; include_once "./Services/Form/classes/class.ilNumberInputGUI.php"; $item = new ilCombinationInputGUI($caption, $id); $combi_item = new ilNumberInputGUI("", $id . "_from"); $item->addCombinationItem("from", $combi_item, $lng->txt("from")); $combi_item = new ilNumberInputGUI("", $id . "_to"); $item->addCombinationItem("to", $combi_item, $lng->txt("to")); $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING); $item->setMaxLength(7); $item->setSize(20); break; case self::FILTER_DATE_RANGE: include_once "./Services/Form/classes/class.ilCombinationInputGUI.php"; include_once "./Services/Form/classes/class.ilDateTimeInputGUI.php"; $item = new ilCombinationInputGUI($caption, $id); $combi_item = new ilDateTimeInputGUI("", $id . "_from"); $item->addCombinationItem("from", $combi_item, $lng->txt("from")); $combi_item = new ilDateTimeInputGUI("", $id . "_to"); $item->addCombinationItem("to", $combi_item, $lng->txt("to")); $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING); $item->setMode(ilDateTimeInputGUI::MODE_INPUT); break; case self::FILTER_DATETIME_RANGE: include_once "./Services/Form/classes/class.ilCombinationInputGUI.php"; include_once "./Services/Form/classes/class.ilDateTimeInputGUI.php"; $item = new ilCombinationInputGUI($caption, $id); $combi_item = new ilDateTimeInputGUI("", $id . "_from"); $combi_item->setShowTime(true); $item->addCombinationItem("from", $combi_item, $lng->txt("from")); $combi_item = new ilDateTimeInputGUI("", $id . "_to"); $combi_item->setShowTime(true); $item->addCombinationItem("to", $combi_item, $lng->txt("to")); $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING); $item->setMode(ilDateTimeInputGUI::MODE_INPUT); break; case self::FILTER_DURATION_RANGE: $lng->loadLanguageModule("form"); include_once "./Services/Form/classes/class.ilCombinationInputGUI.php"; include_once "./Services/Form/classes/class.ilDurationInputGUI.php"; $item = new ilCombinationInputGUI($caption, $id); $combi_item = new ilDurationInputGUI("", $id . "_from"); $combi_item->setShowMonths(false); $combi_item->setShowDays(true); $combi_item->setShowSeconds(true); $item->addCombinationItem("from", $combi_item, $lng->txt("from")); $combi_item = new ilDurationInputGUI("", $id . "_to"); $combi_item->setShowMonths(false); $combi_item->setShowDays(true); $combi_item->setShowSeconds(true); $item->addCombinationItem("to", $combi_item, $lng->txt("to")); $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING); break; default: return false; } $this->addFilterItem($item, $a_optional); $item->readFromSession(); return $item; }