public function appendToolbarSwitch(ilToolbarGUI $toolbar, $a_obj_type, $a_ref_id) { include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateSettings.php'; $tpls = ilDidacticTemplateSettings::getInstanceByObjectType($a_obj_type)->getTemplates(); if (!count($tpls)) { return false; } // Add template switch $toolbar->addText($this->lng->txt('didactic_selected_tpl_option')); // Show template options $options = array(0 => $this->lng->txt('didactic_default_type')); foreach ($tpls as $tpl) { $options[$tpl->getId()] = $tpl->getTitle(); } include_once './Services/Form/classes/class.ilSelectInputGUI.php'; include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php'; $tpl_selection = new ilSelectInputGUI('', 'tplid'); $tpl_selection->setOptions($options); $tpl_selection->setValue(ilDidacticTemplateObjSettings::lookupTemplateId($this->getParentObject()->object->getRefId())); $toolbar->addInputItem($tpl_selection); // Apply templates switch $toolbar->addFormButton($this->lng->txt('change'), 'confirmTemplateSwitch'); return true; }
/** * Show didactic template types * @param ilPropertyFormGUI $form * @return ilPropertyFormGUI $form */ protected function initDidacticTemplate(ilPropertyFormGUI $form) { global $lng; $lng->loadLanguageModule('didactic'); $options = array(); $options['dtpl_0'] = array($this->lng->txt('didactic_default_type'), sprintf($this->lng->txt('didactic_default_type_info'), $this->lng->txt('objs_' . $this->type))); include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateSettings.php'; $templates = ilDidacticTemplateSettings::getInstanceByObjectType($this->type)->getTemplates(); if ($templates) { foreach ($templates as $template) { $options["dtpl_" . $template->getId()] = array($template->getTitle(), $template->getDescription()); } } $this->addDidacticTemplateOptions($options); if (sizeof($options) > 1) { $type = new ilRadioGroupInputGUI($this->lng->txt('type'), 'didactic_type'); // workaround for containers in edit mode if (!$this->getCreationMode()) { include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php'; $type->setValue('dtpl_' . ilDidacticTemplateObjSettings::lookupTemplateId($this->object->getRefId())); } else { $type->setValue('dtpl_0'); } $form->addItem($type); ilUtil::sortArray($options, 0); foreach ($options as $id => $data) { $option = new ilRadioOption($data[0], $id, $data[1]); $type->addOption($option); } } return $form; }