/** * Get input GUI depending on identifier * * @return ilFormPropertyGUI|null */ protected function getInputByIdentifier() { $name = 'default_value'; $title = $this->pl->txt('default_value'); switch ($this->identifier) { case srCertificateTypeSetting::IDENTIFIER_DEFAULT_LANG: $input = new ilSelectInputGUI($title, $name); $options = array(); foreach ($this->type->getLanguages() as $lang) { $options[$lang] = $this->lng->txt("meta_l_{$lang}"); } $input->setOptions($options); $input->setValue($this->setting->getValue()); break; case srCertificateTypeSetting::IDENTIFIER_GENERATION: $input = new ilRadioGroupInputGUI($title, $name); $option = new ilRadioOption($this->pl->txt('setting_generation_auto'), srCertificateTypeSetting::GENERATION_AUTO); $input->addOption($option); $option = new ilRadioOption($this->pl->txt('setting_generation_manually'), srCertificateTypeSetting::GENERATION_MANUAL); $input->addOption($option); $input->setValue($this->setting->getValue()); break; case srCertificateTypeSetting::IDENTIFIER_VALIDITY_TYPE: $input = new ilRadioGroupInputGUI($title, $name); $option = new ilRadioOption($this->pl->txt('always'), srCertificateTypeSetting::VALIDITY_TYPE_ALWAYS); $input->addOption($option); $option = new ilRadioOption($this->pl->txt('setting_validity_range'), srCertificateTypeSetting::VALIDITY_TYPE_DATE_RANGE); $input->addOption($option); $option = new ilRadioOption($this->pl->txt('setting_validity_date'), srCertificateTypeSetting::VALIDITY_TYPE_DATE); $input->addOption($option); $input->setValue($this->setting->getValue()); break; case srCertificateTypeSetting::IDENTIFIER_VALIDITY: $validity_value = $this->setting->getValue(); switch ($this->type->getSettingByIdentifier(srCertificateTypeSetting::IDENTIFIER_VALIDITY_TYPE)->getValue()) { case srCertificateTypeSetting::VALIDITY_TYPE_DATE_RANGE: $input = new ilDurationInputGUI($title, $name); $input->setShowMinutes(false); $input->setShowHours(false); $input->setShowDays(true); $input->setShowMonths(true); if ($validity_value) { $range_array = json_decode($validity_value, true); $data = array(); $data[$input->getPostVar()]['MM'] = $range_array['m']; $data[$input->getPostVar()]['dd'] = $range_array['d']; $input->setValueByArray($data); } break; case srCertificateTypeSetting::VALIDITY_TYPE_DATE: $input = new ilDateTimeInputGUI($title, $name); $input->setMode(ilDateTimeInputGUI::MODE_INPUT); if ($validity_value) { $input->setDate(new ilDateTime($validity_value, IL_CAL_DATE)); } break; case srCertificateTypeSetting::VALIDITY_TYPE_ALWAYS: // Makes no sence to configure this further $input = null; break; default: $input = new ilTextInputGUI($title, $name); } break; case srCertificateTypeSetting::IDENTIFIER_DOWNLOADABLE: case srCertificateTypeSetting::IDENTIFIER_SCORM_TIMING: case srCertificateTypeSetting::IDENTIFIER_NOTIFICATION_USER: $input = new ilCheckboxInputGUI($title, $name); if ($this->setting->getValue()) { $input->setChecked(true); } break; default: $input = new ilTextInputGUI($title, $name); $input->setValue($this->setting->getValue()); } return $input; }
/** * Build ValidityInput * * @param srCertificateDefinitionSetting $setting * @return ilRadioGroupInputGUI */ protected function getValidityInput(srCertificateDefinitionSetting $setting) { $validity_value = $this->definition->getValidity(); // Always $input = new ilRadioGroupInputGUI($this->pl->txt('setting_id_validity'), $setting->getIdentifier()); $input->setRequired(true); $option = new ilRadioOption($this->pl->txt('always'), srCertificateTypeSetting::VALIDITY_TYPE_ALWAYS); $input->addOption($option); // Date range $option = new ilRadioOption($this->pl->txt('setting_validity_range'), srCertificateTypeSetting::VALIDITY_TYPE_DATE_RANGE); $subitem = new ilDurationInputGUI($this->pl->txt('date_range'), $setting->getIdentifier() . '_' . srCertificateTypeSetting::VALIDITY_TYPE_DATE_RANGE); $subitem->setShowMinutes(false); $subitem->setShowHours(false); $subitem->setShowDays(true); $subitem->setShowMonths(true); if ($setting->getValue() == srCertificateTypeSetting::VALIDITY_TYPE_DATE_RANGE && $validity_value) { $range_array = json_decode($validity_value, true); $data = array(); $data[$subitem->getPostVar()]['MM'] = $range_array['m']; $data[$subitem->getPostVar()]['dd'] = $range_array['d']; $subitem->setValueByArray($data); } $option->addSubItem($subitem); $input->addOption($option); // Date $option = new ilRadioOption($this->pl->txt('setting_validity_date'), srCertificateTypeSetting::VALIDITY_TYPE_DATE); $subitem = new ilDateTimeInputGUI($this->pl->txt('date'), $setting->getIdentifier() . '_' . srCertificateTypeSetting::VALIDITY_TYPE_DATE); $subitem->setMode(ilDateTimeInputGUI::MODE_INPUT); if ($setting->getValue() == srCertificateTypeSetting::VALIDITY_TYPE_DATE && $validity_value) { $subitem->setDate(new ilDateTime($validity_value, IL_CAL_DATE)); } $option->addSubItem($subitem); $input->addOption($option); $subitem->setDisabled(!$setting->isEditable()); // SW This seems to have no effect... return $input; }