public function __construct() { global $tpl, $ilCtrl, $ilToolbar, $ilTabs, $lng, $ilAccess, $ilDB, $rbacreview, $ilUser; /** @var ilCtrl ctrl */ $this->ctrl = $ilCtrl; $this->tpl = $tpl; $this->toolbar = $ilToolbar; $this->tabs = $ilTabs; $this->type = isset($_GET['type_id']) ? srCertificateType::find((int) $_GET['type_id']) : null; $this->pl = ilCertificatePlugin::getInstance(); $this->lng = $lng; $this->access = $ilAccess; $this->db = $ilDB; $this->tpl->addJavaScript($this->pl->getStyleSheetLocation('uihk_certificate.js')); $this->lng->loadLanguageModule('common'); $this->tpl->setTitleIcon(ilCertificatePlugin::getPluginIconImage()); $this->rbac = $rbacreview; $this->user = $ilUser; }
/** * @return \srCertificateType */ public function getType() { return srCertificateType::find($this->getTypeId()); }
/** * @return \srCertificateType */ public function getCertificateType() { if (is_null($this->type)) { $this->type = srCertificateType::find($this->getTypeId()); } return $this->type; }
/** * @param mixed $value */ public function setValue($value) { // This should be factored out, currently there is one exception where a value needs to be parsed before storing in DB if ($value && $this->getIdentifier() == srCertificateTypeSetting::IDENTIFIER_VALIDITY) { /** @var srCertificateType $type */ $type = srCertificateType::find($this->getTypeId()); $value = self::formatValidityBasedOnType($type->getSettingByIdentifier(self::IDENTIFIER_VALIDITY_TYPE)->getValue(), $value); } $this->value = $value; }
/** * Init your form * */ protected function initForm() { $title = $this->setting->getId() ? sprintf($this->pl->txt('edit_setting'), $this->setting->getIdentifier()) : $this->pl->txt('add_new_custom_setting'); $this->setTitle($title); $item = new ilHiddenInputGUI('custom_setting_id'); $item->setValue($this->setting->getId()); $this->addItem($item); $item = new ilTextInputGUI($this->pl->txt('identifier'), 'identifier'); $item->setRequired(true); $item->setValue($this->setting->getIdentifier()); $item->setInfo(sprintf($this->pl->txt('identifier_info'), srCertificatePlaceholder::REGEX_VALID_IDENTIFIER)); $this->addItem($item); $item = new ilRadioGroupInputGUI($this->pl->txt('custom_setting_type'), 'setting_type_id'); $item->setRequired(true); $option = new ilRadioOption($this->pl->txt('custom_setting_type_' . srCertificateCustomTypeSetting::SETTING_TYPE_BOOLEAN), srCertificateCustomTypeSetting::SETTING_TYPE_BOOLEAN); $item->addOption($option); $option = new ilRadioOption($this->pl->txt('custom_setting_type_' . srCertificateCustomTypeSetting::SETTING_TYPE_SELECT), srCertificateCustomTypeSetting::SETTING_TYPE_SELECT); $subitem = new ilTextAreaInputGUI($this->pl->txt('custom_setting_type_2_data'), 'data'); $subitem->setValue($this->setting->getData()); $subitem->setInfo($this->pl->txt('custom_setting_type_2_data_info')); $option->addSubItem($subitem); $item->setValue($this->setting->getSettingTypeId()); $item->addOption($option); $this->addItem($item); $item = new ilTextInputGUI($this->pl->txt('default_value'), "value"); $item->setInfo($this->pl->txt('custom_setting_default_value_info')); $item->setValue($this->setting->getValue()); $this->addItem($item); $item = new ilMultiSelectInputGUI($this->pl->txt('editable_in'), 'editable_in'); $options = array(); foreach (srCertificateType::getAllAvailableObjectTypes() as $type) { $options[$type] = $type; } $item->setOptions($options); $item->setValue($this->setting->getEditableIn()); $this->addItem($item); // Update definitions, add settings if (!$this->setting->getId()) { $item = new ilCheckboxInputGUI($this->pl->txt('update_cert_definitions'), 'update_definitions'); $item->setInfo($this->pl->txt('custom_setting_update_cert_definitions_info')); $this->addItem($item); } // Label per language /** @var srCertificateType $type */ $type = $this->setting->getId() ? srCertificateType::find($this->setting->getTypeId()) : srCertificateType::find((int) $_GET['type_id']); foreach ($type->getLanguages() as $lang_code) { $this->addLabelInput($lang_code); } }