/**
  * Get singelton instance
  * @return ilDidacticTemplateSetting
  */
 public static function getInstance()
 {
     if (self::$instance) {
         return self::$instance;
     }
     return self::$instance = new ilDidacticTemplateSettings();
 }
 /**
  * Parse didactic templates
  */
 public function parse()
 {
     include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateSettings.php';
     $tpls = ilDidacticTemplateSettings::getInstance();
     $tpls->readInactive();
     $counter = 0;
     foreach ($tpls->getTemplates() as $tpl) {
         /* @var $tpl ilDidacticTemplateSetting */
         $data[$counter]['id'] = $tpl->getId();
         $data[$counter]['title'] = $tpl->getTitle();
         $data[$counter]['description'] = $tpl->getDescription();
         $data[$counter]['info'] = $tpl->getInfo();
         $data[$counter]['enabled'] = (int) $tpl->isEnabled();
         $data[$counter]['assignments'] = $tpl->getAssignments();
         ++$counter;
     }
     $this->setData((array) $data);
 }
 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;
 }
Example #4
0
 /**
  * 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;
 }