/** * init mapping form * * @param int $a_server_id * @return ilPropertyFormGUI $form * * @access protected */ protected function initMappingsForm($a_server_id, $mapping_type) { include_once './Services/Form/classes/class.ilPropertyFormGUI.php'; include_once './Services/WebServices/ECS/classes/class.ilECSDataMappingSettings.php'; $mapping_settings = ilECSDataMappingSettings::getInstanceByServerId($a_server_id); $form = new ilPropertyFormGUI(); if ($mapping_type == self::MAPPING_IMPORT) { $form->setTitle($this->lng->txt('ecs_mapping_tbl')); $form->addCommandButton('saveImportMappings', $this->lng->txt('save')); $form->addCommandButton('importMappings', $this->lng->txt('cancel')); } else { $form->setTitle($this->lng->txt('ecs_mapping_exp_tbl')); $form->addCommandButton('saveExportMappings', $this->lng->txt('save')); $form->addCommandButton('exportMappings', $this->lng->txt('cancel')); } $form->setFormAction($this->ctrl->getFormAction($this, 'saveMappings')); if ($mapping_type == self::MAPPING_IMPORT) { $assignments = new ilCustomInputGUI($this->lng->txt('ecs_mapping_crs')); $form->addItem($assignments); } include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php'; $fields = ilAdvancedMDFieldDefinition::_getActiveDefinitionsByObjType('crs'); $options = $this->prepareFieldSelection($fields); // get all optional ecourse fields include_once './Services/WebServices/ECS/classes/class.ilECSUtils.php'; $optional = ilECSUtils::_getOptionalECourseFields(); foreach ($optional as $field_name) { if ($mapping_type == self::MAPPING_IMPORT) { $select = new ilSelectInputGUI($this->lng->txt('ecs_field_' . $field_name), 'mapping' . '[' . ilECSDataMappingSetting::MAPPING_IMPORT_CRS . '][' . $field_name . ']'); $select->setValue($mapping_settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_CRS, $field_name)); $select->setOptions($options); $assignments->addSubItem($select); } else { $select = new ilSelectInputGUI($this->lng->txt('ecs_field_' . $field_name), 'mapping' . '[' . ilECSDataMappingSetting::MAPPING_EXPORT . '][' . $field_name . ']'); $select->setValue($mapping_settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_EXPORT, $field_name)); $select->setOptions($options); $form->addItem($select); } } $server = new ilHiddenInputGUI('ecs_mapping_server'); $server->setValue($a_server_id); $form->addItem($server); // Remote courses // no remote course settings for export if ($mapping_type == self::MAPPING_EXPORT) { return $form; } $rcrs = new ilCustomInputGUI($this->lng->txt('ecs_mapping_rcrs')); $form->addItem($rcrs); include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php'; $fields = ilAdvancedMDFieldDefinition::_getActiveDefinitionsByObjType('rcrs'); $options = $this->prepareFieldSelection($fields); // get all optional econtent fields include_once './Services/WebServices/ECS/classes/class.ilECSUtils.php'; $optional = ilECSUtils::_getOptionalEContentFields(); foreach ($optional as $field_name) { $select = new ilSelectInputGUI($this->lng->txt('ecs_field_' . $field_name), 'mapping[' . ilECSDataMappingSetting::MAPPING_IMPORT_RCRS . '][' . $field_name . ']'); $select->setValue($mapping_settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, $field_name)); $select->setOptions($options); $rcrs->addSubItem($select); } return $form; }
/** * * * @return * @static */ public static function getPossibleFields() { global $lng; $options = array("community" => $lng->txt("ecs_field_community"), "part_id" => $lng->txt("ecs_field_part_id"), "type" => $lng->txt("type")); // will be handled by server soon? // only courses for now include_once './Services/WebServices/ECS/classes/class.ilECSUtils.php'; $course_fields = ilECSUtils::_getOptionalECourseFields(); foreach ($course_fields as $field) { $options[$field] = $lng->txt("obj_rcrs") . " - " . $lng->txt("ecs_field_" . $field); } return $options; }