コード例 #1
0
 /**
  * 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;
 }
コード例 #2
0
 /**
  * Fill row
  *
  * @access public
  * @param array row data
  * 
  */
 public function fillRow($a_set)
 {
     global $tree;
     include_once './Services/Link/classes/class.ilLink.php';
     $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
     #$this->tpl->setVariable('VAL_LINK',ilLink::_getLink($a_set['ref_id'],'rcrs'));
     $this->tpl->setVariable('VAL_DESC', $a_set['desc']);
     $this->tpl->setVariable('VAL_REMOTE', $a_set['from']);
     $this->tpl->setVariable('VAL_REMOTE_INFO', $a_set['from_info']);
     $this->tpl->setVariable('TXT_EMAIL', $this->lng->txt('ecs_email'));
     $this->tpl->setVariable('TXT_DNS', $this->lng->txt('ecs_dns'));
     $this->tpl->setVariable('TXT_ABR', $this->lng->txt('ecs_abr'));
     $this->tpl->setVariable('VAL_LAST_UPDATE', ilDatePresentation::formatDate(new ilDateTime($a_set['last_update'], IL_CAL_DATETIME)));
     // Links
     foreach (ilObject::_getAllReferences($a_set['obj_id']) as $ref_id) {
         $parent = $tree->getParentId($ref_id);
         $p_obj_id = ilObject::_lookupObjId($parent);
         $p_title = ilObject::_lookupTitle($p_obj_id);
         $p_type = ilObject::_lookupType($p_obj_id);
         $this->tpl->setCurrentBlock('link');
         $this->tpl->setVariable('LINK_IMG', ilUtil::getTypeIconPath($p_type, $p_obj_id, 'tiny'));
         $this->tpl->setVariable('LINK_CONTAINER', $p_title);
         $this->tpl->setVariable('LINK_LINK', ilLink::_getLink($parent, $p_type));
         $this->tpl->parseCurrentBlock();
     }
     $this->tpl->setVariable('TXT_TERM', $this->lng->txt('ecs_field_term'));
     $this->tpl->setVariable('TXT_CRS_TYPE', $this->lng->txt('ecs_field_courseType'));
     $this->tpl->setVariable('TXT_CRS_ID', $this->lng->txt('ecs_field_courseID'));
     $this->tpl->setVariable('TXT_CREDITS', $this->lng->txt('ecs_field_credits'));
     $this->tpl->setVariable('TXT_ROOM', $this->lng->txt('ecs_field_room'));
     $this->tpl->setVariable('TXT_CYCLE', $this->lng->txt('ecs_field_cycle'));
     $this->tpl->setVariable('TXT_SWS', $this->lng->txt('ecs_field_semester_hours'));
     $this->tpl->setVariable('TXT_START', $this->lng->txt('ecs_field_begin'));
     $this->tpl->setVariable('TXT_END', $this->lng->txt('ecs_field_end'));
     $this->tpl->setVariable('TXT_LECTURER', $this->lng->txt('ecs_field_lecturer'));
     include_once './Services/WebServices/ECS/classes/class.ilECSDataMappingSettings.php';
     $settings = ilECSDataMappingSettings::getInstanceByServerId($a_set['sid']);
     include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php';
     $values = ilAdvancedMDValues::_getValuesByObjId($a_set['obj_id']);
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'lecturer')) {
         $this->tpl->setVariable('VAL_LECTURER', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'term')) {
         $this->tpl->setVariable('VAL_TERM', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'courseID')) {
         $this->tpl->setVariable('VAL_CRS_ID', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'courseType')) {
         $this->tpl->setVariable('VAL_CRS_TYPE', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'credits')) {
         $this->tpl->setVariable('VAL_CREDITS', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'semester_hours')) {
         $this->tpl->setVariable('VAL_SWS', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'room')) {
         $this->tpl->setVariable('VAL_ROOM', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'cycle')) {
         $this->tpl->setVariable('VAL_CYCLE', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'begin')) {
         $this->tpl->setVariable('VAL_START', isset($values[$field]) ? ilDatePresentation::formatDate(new ilDateTime($values[$field], IL_CAL_UNIX)) : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'end')) {
         $this->tpl->setVariable('VAL_END', isset($values[$field]) ? ilDatePresentation::formatDate(new ilDateTime($values[$field], IL_CAL_UNIX)) : '--');
     }
 }
コード例 #3
0
 /**
  * Add advanced metadata to json (export)
  * 
  * @param object $a_json
  * @param ilECSSetting $a_server
  * @param array $a_definition
  * @param int $a_mapping_mode
  */
 protected function importMetadataFromJson($a_json, ilECSSetting $a_server, array $a_definition, $a_mapping_mode)
 {
     global $ilLog;
     $ilLog->write("importing metadata from json: " . print_r($a_definition, true));
     include_once './Services/WebServices/ECS/classes/class.ilECSDataMappingSettings.php';
     include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php';
     include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php';
     $mappings = ilECSDataMappingSettings::getInstanceByServerId($a_server->getServerId());
     foreach ($a_definition as $id => $type) {
         if (is_array($type)) {
             $target = $type[1];
             $type = $type[0];
         } else {
             $target = $id;
         }
         $timePlace = null;
         if ($field = $mappings->getMappingByECSName($a_mapping_mode, $id)) {
             switch ($type) {
                 case ilECSUtils::TYPE_ARRAY:
                     $value = implode(',', (array) $a_json->{$target});
                     break;
                 case ilECSUtils::TYPE_INT:
                     $value = (int) $a_json->{$target};
                     break;
                 case ilECSUtils::TYPE_STRING:
                     $value = (string) $a_json->{$target};
                     break;
                 case ilECSUtils::TYPE_TIMEPLACE:
                     if (!is_object($timePlace)) {
                         include_once './Services/WebServices/ECS/classes/class.ilECSTimePlace.php';
                         if (is_object($a_json->{$target})) {
                             $timePlace = new ilECSTimePlace();
                             $timePlace->loadFromJSON($a_json->{$target});
                         } else {
                             $timePlace = new ilECSTimePlace();
                         }
                     }
                     switch ($id) {
                         case 'begin':
                         case 'end':
                             $field_type = ilAdvancedMDFieldDefinition::_lookupFieldType($field);
                             if ($field_type == ilAdvancedMDFieldDefinition::TYPE_DATE || $field_type == ilAdvancedMDFieldDefinition::TYPE_DATETIME) {
                                 $value = $timePlace->{'getUT' . ucfirst($id)}();
                                 break;
                             }
                             // fallthrough
                         // fallthrough
                         case 'room':
                         case 'cycle':
                             $value = $timePlace->{'get' . ucfirst($id)}();
                             break;
                     }
                     break;
             }
             include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDValue.php';
             $mdv = ilAdvancedMDValue::_getInstance($this->getId(), $field);
             $mdv->toggleDisabledStatus(true);
             $mdv->setValue($value);
             $mdv->save();
         }
     }
 }
コード例 #4
0
 /**
  * Add advanced metadata to json (export)
  * 
  * @param object $a_json
  * @param ilECSSetting $a_server
  * @param array $a_definition
  */
 protected function addMetadataToJson(&$a_json, ilECSSetting $a_server, array $a_definition)
 {
     include_once './Services/WebServices/ECS/classes/class.ilECSDataMappingSettings.php';
     include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php';
     include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php';
     $mappings = ilECSDataMappingSettings::getInstanceByServerId($a_server->getServerId());
     $values = ilAdvancedMDValues::_getValuesByObjId($this->content_obj->getId());
     foreach ($a_definition as $id => $type) {
         if (is_array($type)) {
             $target = $type[1];
             $type = $type[0];
         } else {
             $target = $id;
         }
         if ($field = $mappings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_EXPORT, $id)) {
             $value = isset($values[$field]) ? $values[$field] : '';
             switch ($type) {
                 case ilECSUtils::TYPE_ARRAY:
                     $a_json->{$target} = explode(',', $value);
                     break;
                 case ilECSUtils::TYPE_INT:
                     $a_json->{$target} = (int) $value;
                     break;
                 case ilECSUtils::TYPE_STRING:
                     $a_json->{$target} = (string) $value;
                     break;
                 case ilECSUtils::TYPE_TIMEPLACE:
                     if (!isset($a_json->{$target})) {
                         include_once './Services/WebServices/ECS/classes/class.ilECSTimePlace.php';
                         $a_json->{$target} = new ilECSTimePlace();
                     }
                     $a_json->{$target}->{'set' . ucfirst($id)}($value);
                     break;
             }
         }
     }
 }
コード例 #5
0
 /**
  * Fill row
  *
  * @access public
  * @param array row data
  * 
  */
 public function fillRow($a_set)
 {
     include_once './Services/Link/classes/class.ilLink.php';
     $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
     $this->tpl->setVariable('VAL_LINK', ilLink::_getLink($a_set['ref_id'], 'rcrs'));
     $this->tpl->setVariable('VAL_DESC', $a_set['desc']);
     $this->tpl->setVariable('VAL_REMOTE', $a_set['from']);
     $this->tpl->setVariable('VAL_REMOTE_INFO', $a_set['from_info']);
     $this->tpl->setVariable('TXT_EMAIL', $this->lng->txt('ecs_email'));
     $this->tpl->setVariable('TXT_DNS', $this->lng->txt('ecs_dns'));
     $this->tpl->setVariable('TXT_ABR', $this->lng->txt('ecs_abr'));
     $this->tpl->setVariable('VAL_LAST_UPDATE', $a_set['last_update']);
     $this->tpl->setVariable('TXT_TERM', $this->lng->txt('ecs_field_term'));
     $this->tpl->setVariable('TXT_CRS_TYPE', $this->lng->txt('ecs_field_courseType'));
     $this->tpl->setVariable('TXT_CRS_ID', $this->lng->txt('ecs_field_courseID'));
     $this->tpl->setVariable('TXT_CREDITS', $this->lng->txt('ecs_field_credits'));
     $this->tpl->setVariable('TXT_ROOM', $this->lng->txt('ecs_field_room'));
     $this->tpl->setVariable('TXT_CYCLE', $this->lng->txt('ecs_field_cycle'));
     $this->tpl->setVariable('TXT_SWS', $this->lng->txt('ecs_field_semester_hours'));
     $this->tpl->setVariable('TXT_START', $this->lng->txt('ecs_field_begin'));
     $this->tpl->setVariable('TXT_END', $this->lng->txt('ecs_field_end'));
     $this->tpl->setVariable('TXT_LECTURER', $this->lng->txt('ecs_field_lecturer'));
     $sid = array_pop($a_set['sids']);
     include_once './Services/WebServices/ECS/classes/class.ilECSDataMappingSettings.php';
     $settings = ilECSDataMappingSettings::getInstanceByServerId($sid);
     include_once "Services/WebServices/ECS/classes/class.ilECSUtils.php";
     $values = ilECSUtils::getAdvancedMDValuesForObjId($a_set['obj_id']);
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_EXPORT, 'lecturer')) {
         $this->tpl->setVariable('VAL_LECTURER', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_EXPORT, 'term')) {
         $this->tpl->setVariable('VAL_TERM', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_EXPORT, 'courseID')) {
         $this->tpl->setVariable('VAL_CRS_ID', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_EXPORT, 'courseType')) {
         $this->tpl->setVariable('VAL_CRS_TYPE', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_EXPORT, 'credits')) {
         $this->tpl->setVariable('VAL_CREDITS', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_EXPORT, 'semester_hours')) {
         $this->tpl->setVariable('VAL_SWS', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_EXPORT, 'room')) {
         $this->tpl->setVariable('VAL_ROOM', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_EXPORT, 'cycle')) {
         $this->tpl->setVariable('VAL_CYCLE', isset($values[$field]) ? $values[$field] : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_EXPORT, 'begin')) {
         $this->tpl->setVariable('VAL_START', isset($values[$field]) ? ilDatePresentation::formatDate(new ilDateTime($values[$field], IL_CAL_UNIX)) : '--');
     }
     if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_EXPORT, 'end')) {
         $this->tpl->setVariable('VAL_END', isset($values[$field]) ? ilDatePresentation::formatDate(new ilDateTime($values[$field], IL_CAL_UNIX)) : '--');
     }
 }
コード例 #6
0
 /**
  * Add advanced metadata to json (export)
  * 
  * @param object $a_json
  * @param ilECSSetting $a_server
  * @param array $a_definition
  * @param int $a_mapping_mode
  */
 protected function importMetadataFromJson($a_json, ilECSSetting $a_server, array $a_definition, $a_mapping_mode)
 {
     global $ilLog;
     $ilLog->write("importing metadata from json: " . print_r($a_json, true));
     include_once './Services/WebServices/ECS/classes/class.ilECSDataMappingSettings.php';
     include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php';
     include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php';
     $mappings = ilECSDataMappingSettings::getInstanceByServerId($a_server->getServerId());
     $values_records = ilAdvancedMDValues::getInstancesForObjectId($this->getId(), $this->getType());
     foreach ($values_records as $values_record) {
         // this correctly binds group and definitions
         $values_record->read();
     }
     $do_save = false;
     foreach ($a_definition as $id => $type) {
         if (is_array($type)) {
             $target = $type[1];
             $type = $type[0];
         } else {
             $target = $id;
         }
         $timePlace = null;
         if ($field = $mappings->getMappingByECSName($a_mapping_mode, $id)) {
             // find element in records
             $adv_md_def = null;
             foreach ($values_records as $values_record) {
                 $adv_md_defs = $values_record->getDefinitions();
                 if (isset($adv_md_defs[$field])) {
                     $adv_md_def = $adv_md_defs[$field];
                     break;
                 }
             }
             if (!$adv_md_def) {
                 continue;
             }
             $raw_value = $a_json->{$target};
             if ($type == ilECSUtils::TYPE_TIMEPLACE) {
                 if (!is_object($timePlace)) {
                     include_once './Services/WebServices/ECS/classes/class.ilECSTimePlace.php';
                     if (is_object($raw_value)) {
                         $timePlace = new ilECSTimePlace();
                         $timePlace->loadFromJSON($raw_value);
                     } else {
                         $timePlace = new ilECSTimePlace();
                     }
                 }
                 $raw_value = $timePlace;
             }
             if ($adv_md_def->importFromECS($type, $raw_value, $id)) {
                 $do_save = true;
             }
         }
     }
     if ($do_save) {
         foreach ($values_records as $values_record) {
             $additional = array();
             foreach ($values_record->getADTGroup()->getElements() as $element_id => $element) {
                 if (!$element->isNull()) {
                     $additional[$element_id] = array("disabled" => array("integer", 1));
                 }
             }
             $values_record->write($additional);
         }
     }
 }