コード例 #1
0
 /**
  * Init settings form
  */
 protected function initFormCSettings()
 {
     include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingSettings.php';
     include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
     $form = new ilPropertyFormGUI();
     $form->setFormAction($this->ctrl->getFormAction($this));
     $form->setTitle($this->lng->txt('settings'));
     // individual course allocation
     $check = new ilCheckboxInputGUI($this->lng->txt('ecs_cmap_enable'), 'enabled');
     $check->setChecked(ilECSNodeMappingSettings::getInstanceByServerMid($this->getServer()->getServerId(), $this->getMid())->isCourseAllocationEnabled());
     $form->addItem($check);
     // add default container
     $imp = new ilCustomInputGUI($this->lng->txt('ecs_cmap_def_cat'), 'default_cat');
     $imp->setRequired(true);
     $tpl = new ilTemplate('tpl.ecs_import_id_form.html', true, true, 'Services/WebServices/ECS');
     $tpl->setVariable('SIZE', 5);
     $tpl->setVariable('MAXLENGTH', 11);
     $tpl->setVariable('POST_VAR', 'default_cat');
     $default = ilECSNodeMappingSettings::getInstanceByServerMid($this->getServer()->getServerId(), $this->getMid())->getDefaultCourseCategory();
     $tpl->setVariable('PROPERTY_VALUE', $default);
     if ($default) {
         include_once './Services/Tree/classes/class.ilPathGUI.php';
         $path = new ilPathGUI();
         $path->enableTextOnly(false);
         $path->enableHideLeaf(false);
         $tpl->setVariable('COMPLETE_PATH', $path->getPath(ROOT_FOLDER_ID, $default));
     }
     $imp->setHtml($tpl->get());
     $imp->setInfo($this->lng->txt('ecs_cmap_def_cat_info'));
     $form->addItem($imp);
     // all in one category
     $allinone = new ilCheckboxInputGUI($this->lng->txt('ecs_cmap_all_in_one'), 'allinone');
     $allinone->setChecked(ilECSNodeMappingSettings::getInstanceByServerMid($this->getServer()->getServerId(), $this->getMid())->isAllInOneCategoryEnabled());
     $allinone->setInfo($this->lng->txt('ecs_cmap_all_in_one_info'));
     $allinone_cat = new ilCustomInputGUI($this->lng->txt('ecs_cmap_all_in_one_cat'), 'allinone_cat');
     $allinone_cat->setRequired(true);
     $tpl = new ilTemplate('tpl.ecs_import_id_form.html', true, true, 'Services/WebServices/ECS');
     $tpl->setVariable('SIZE', 5);
     $tpl->setVariable('MAXLENGTH', 11);
     $tpl->setVariable('POST_VAR', 'allinone_cat');
     $cat = ilECSNodeMappingSettings::getInstanceByServerMid($this->getServer()->getServerId(), $this->getMid())->getAllInOneCategory();
     $tpl->setVariable('PROPERTY_VALUE', $cat);
     if ($cat) {
         include_once './Services/Tree/classes/class.ilPathGUI.php';
         $path = new ilPathGUI();
         $path->enableTextOnly(false);
         $path->enableHideLeaf(false);
         $tpl->setVariable('COMPLETE_PATH', $path->getPath(ROOT_FOLDER_ID, $default));
     }
     $allinone_cat->setHtml($tpl->get());
     $allinone->addSubItem($allinone_cat);
     $form->addItem($allinone);
     // multiple attributes
     $multiple = new ilCheckboxInputGUI($this->lng->txt('ecs_cmap_multiple_atts'), 'multiple');
     $multiple->setChecked(ilECSNodeMappingSettings::getInstanceByServerMid($this->getServer()->getServerId(), $this->getMid())->isAttributeMappingEnabled());
     // attribute selection
     include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSMappingUtils.php';
     include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseAttributes.php';
     $attributes = new ilSelectInputGUI($this->lng->txt('ecs_cmap_attributes'), 'atts');
     $attributes->setMulti(true);
     $attributes->setValue(ilECSCourseAttributes::getInstance($this->getServer()->getServerId(), $this->getMid())->getAttributeValues());
     $attributes->setRequired(true);
     $attributes->setOptions(ilECSMappingUtils::getCourseMappingFieldSelectOptions());
     $multiple->addSubItem($attributes);
     $form->addItem($multiple);
     // role mapping
     $rm = new ilFormSectionHeaderGUI();
     $rm->setTitle($this->lng->txt('ecs_role_mappings'));
     $form->addItem($rm);
     $mapping_defs = ilECSNodeMappingSettings::getInstanceByServerMid($this->getServer()->getServerId(), $this->getMid())->getRoleMappings();
     include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSMappingUtils.php';
     foreach (ilECSMappingUtils::getRoleMappingInfo() as $name => $info) {
         $role_map = new ilTextInputGUI($this->lng->txt($info['lang']), $name);
         $role_map->setValue($mapping_defs[$name]);
         $role_map->setSize(32);
         $role_map->setMaxLength(64);
         $role_map->setRequired($info['required']);
         $form->addItem($role_map);
     }
     $form->addCommandButton('cUpdateSettings', $this->lng->txt('save'));
     $form->addCommandButton('cSettings', $this->lng->txt('cancel'));
     return $form;
 }