/**
  * 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");
 }
 /**
  * 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)) : '--');
     }
 }
 /**
  * Substitute
  *
  * @access public
  * @param int ref_id
  * @param int obj_id
  * @param string description
  * 
  */
 public function getParsedSubstitutions($a_ref_id, $a_obj_id)
 {
     if (!count($this->getSubstitutions())) {
         return array();
     }
     include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php';
     $values = ilAdvancedMDValues::_getValuesByObjId($a_obj_id);
     $counter = 0;
     foreach ($this->getSubstitutions() as $field_id) {
         if (!isset($this->active_fields[$field_id])) {
             continue;
         }
         if (!isset($values[$field_id]) or !$values[$field_id]) {
             if ($this->hasNewline($field_id) and $counter) {
                 $substituted[$counter - 1]['newline'] = true;
             }
             continue;
         }
         $value = $this->parseValue($field_id, $values);
         $substituted[$counter]['name'] = $this->active_fields[$field_id];
         $substituted[$counter]['value'] = $value;
         $substituted[$counter]['bold'] = $this->isBold($field_id);
         if ($this->hasNewline($field_id)) {
             $substituted[$counter]['newline'] = true;
         } else {
             $substituted[$counter]['newline'] = false;
         }
         $substituted[$counter]['show_field'] = $this->enabledFieldNames();
         $counter++;
     }
     return $substituted ? $substituted : array();
 }
 /**
  * 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;
             }
         }
     }
 }
 /**
  * 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/AdvancedMetaData/classes/class.ilAdvancedMDValues.php';
     $values = ilAdvancedMDValues::_getValuesByObjId($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)) : '--');
     }
 }