/** * export released * * @access protected * @return */ protected function exportReleased() { global $ilObjDataCache; include_once './Services/WebServices/ECS/classes/class.ilECSExport.php'; $exported = ilECSExport::getExportedIds(); $ilObjDataCache->preloadObjectCache($exported); include_once 'Services/Utilities/classes/class.ilCSVWriter.php'; $writer = new ilCSVWriter(); $writer->addColumn($this->lng->txt('title')); $writer->addColumn($this->lng->txt('description')); $writer->addColumn($this->lng->txt('ecs_field_courseID')); $writer->addColumn($this->lng->txt('ecs_field_term')); $writer->addColumn($this->lng->txt('ecs_field_lecturer')); $writer->addColumn($this->lng->txt('ecs_field_courseType')); $writer->addColumn($this->lng->txt('ecs_field_semester_hours')); $writer->addColumn($this->lng->txt('ecs_field_credits')); $writer->addColumn($this->lng->txt('ecs_field_room')); $writer->addColumn($this->lng->txt('ecs_field_cycle')); $writer->addColumn($this->lng->txt('ecs_field_begin')); $writer->addColumn($this->lng->txt('ecs_field_end')); $writer->addColumn($this->lng->txt('last_update')); include_once './Services/WebServices/ECS/classes/class.ilECSDataMappingSettings.php'; $settings = ilECSDataMappingSettings::_getInstance(); foreach ($exported as $obj_id) { include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php'; $values = ilAdvancedMDValues::_getValuesByObjId($obj_id); $writer->addRow(); $writer->addColumn(ilObject::_lookupTitle($obj_id)); $writer->addColumn(ilObject::_lookupDescription($obj_id)); $field = $settings->getMappingByECSName('courseID'); $writer->addColumn(isset($values[$field]) ? $values[$field] : ''); $field = $settings->getMappingByECSName('term'); $writer->addColumn(isset($values[$field]) ? $values[$field] : ''); $field = $settings->getMappingByECSName('lecturer'); $writer->addColumn(isset($values[$field]) ? $values[$field] : ''); $field = $settings->getMappingByECSName('courseType'); $writer->addColumn(isset($values[$field]) ? $values[$field] : ''); $field = $settings->getMappingByECSName('semester_hours'); $writer->addColumn(isset($values[$field]) ? $values[$field] : ''); $field = $settings->getMappingByECSName('credits'); $writer->addColumn(isset($values[$field]) ? $values[$field] : ''); $field = $settings->getMappingByECSName('room'); $writer->addColumn(isset($values[$field]) ? $values[$field] : ''); $field = $settings->getMappingByECSName('cycle'); $writer->addColumn(isset($values[$field]) ? $values[$field] : ''); $field = $settings->getMappingByECSName('begin'); $writer->addColumn(isset($values[$field]) ? ilFormat::formatUnixTime($values[$field], true) : ''); $field = $settings->getMappingByECSName('end'); $writer->addColumn(isset($values[$field]) ? ilFormat::formatUnixTime($values[$field], true) : ''); $writer->addColumn($ilObjDataCache->lookupLastUpdate($obj_id)); } ilUtil::deliverData($writer->getCSVString(), date("Y_m_d") . "_ecs_export.csv", "text/csv"); }
/** * 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(); } } }
/** * 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)) : '--'); } }
/** * 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; } } } }
/** * Show special form for ecs start * * @access private * @param object ilAdvMDFieldDefinition */ private function showECSStart($def) { global $ilUser; $this->lng->loadLanguageModule('ecs'); include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDValue.php'; $value_start = ilAdvancedMDValue::_getInstance($this->obj_id, $def->getFieldId()); $unixtime = $value_start->getValue() ? $value_start->getValue() : mktime(8, 0, 0, date('m'), date('d'), date('Y')); $time = new ilDateTimeInputGUI($this->lng->txt('ecs_event_appointment'), 'md[' . $def->getFieldId() . ']'); $time->setShowTime(true); $time->setDate(new ilDateTime($unixtime, IL_CAL_UNIX)); $time->enableDateActivation($this->lng->txt('enabled'), 'md_activated[' . $def->getFieldId() . ']', $value_start->getValue() ? true : false); $time->setDisabled($value_start->isDisabled()); $mapping = ilECSDataMappingSettings::_getInstance(); if ($field_id = $mapping->getMappingByECSName('end')) { $value_end = ilAdvancedMDValue::_getInstance($this->obj_id, $field_id); list($hours, $minutes) = $this->parseDuration($value_start->getValue(), $value_end->getValue()); $duration = new ilDurationInputGUI($this->lng->txt('ecs_duration'), 'ecs_duration'); $duration->setHours($hours); $duration->setMinutes($minutes); #$duration->setInfo($this->lng->txt('ecs_duration_info')); $duration->setShowHours(true); $duration->setShowMinutes(true); $time->addSubItem($duration); } if ($field_id = $mapping->getMappingByECSName('cycle')) { $value = ilAdvancedMDValue::_getInstance($this->obj_id, $field_id); $cycle_def = ilAdvancedMDFieldDefinition::getInstance($field_id); switch ($cycle_def->getFieldType()) { case ilAdvancedMDFieldDefinition::TYPE_TEXT: $text = new ilTextInputGUI($cycle_def->getTitle(), 'md[' . $cycle_def->getFieldId() . ']'); $text->setValue($value->getValue()); $text->setSize(20); $text->setMaxLength(512); $text->setDisabled($value->isDisabled()); $time->addSubItem($text); break; case ilAdvancedMDFieldDefinition::TYPE_SELECT: $select = new ilSelectInputGUI($cycle_def->getTitle(), 'md[' . $cycle_def->getFieldId() . ']'); $select->setOptions($cycle_def->getFieldValuesForSelect()); $select->setValue($value->getValue()); $select->setDisabled($value->isDisabled()); $time->addSubItem($select); break; } } if ($field_id = $mapping->getMappingByECSName('room')) { $value = ilAdvancedMDValue::_getInstance($this->obj_id, $field_id); $room_def = ilAdvancedMDFieldDefinition::getInstance($field_id); switch ($room_def->getFieldType()) { case ilAdvancedMDFieldDefinition::TYPE_TEXT: $text = new ilTextInputGUI($room_def->getTitle(), 'md[' . $room_def->getFieldId() . ']'); $text->setValue($value->getValue()); $text->setSize(20); $text->setMaxLength(512); $text->setDisabled($value->isDisabled()); $time->addSubItem($text); break; case ilAdvancedMDFieldDefinition::TYPE_SELECT: $select = new ilSelectInputGUI($room_def->getTitle(), 'md[' . $room_def->getFieldId() . ']'); $select->setOptions($cycle_def->getFieldValuesForSelect()); $select->setValue($value->getValue()); $select->setDisabled($value->isDisabled()); $time->addSubItem($select); break; } } $this->form->addItem($time); }
/** * init ECS mappings * * @access private * */ private function initECSMappings() { return true; include_once './Services/WebServices/ECS/classes/class.ilECSDataMappingSettings.php'; if (isset(self::$mappings) and is_object(self::$mappings)) { return true; } self::$mappings = ilECSDataMappingSettings::_getInstance(); return true; }
/** * 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)) : '--'); } }
/** * 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); } } }