ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilECSImportedContentTableGUI.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24include_once('Services/Table/classes/class.ilTable2GUI.php');
25
35{
36 protected $lng;
37 protected $ctrl;
38
46 public function __construct($a_parent_obj, $a_parent_cmd = '')
47 {
48 global $lng,$ilCtrl;
49
50 $this->lng = $lng;
51 $this->ctrl = $ilCtrl;
52
53 parent::__construct($a_parent_obj, $a_parent_cmd);
54 $this->addColumn($this->lng->txt('title'), 'title', '25%');
55 $this->addColumn($this->lng->txt('res_links_short'), 'link', '25%');
56 $this->addColumn($this->lng->txt('ecs_imported_from'), 'from', '15%');
57 $this->addColumn($this->lng->txt('ecs_meta_data'), 'md', '25%');
58 $this->addColumn($this->lng->txt('last_update'), 'last_update', '10%');
59 $this->setRowTemplate('tpl.content_row.html', 'Services/WebServices/ECS');
60 $this->setDefaultOrderField('title');
61 $this->setDefaultOrderDirection('asc');
62 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
63 }
64
72 public function fillRow($a_set)
73 {
74 global $tree;
75
76 include_once('./Services/Link/classes/class.ilLink.php');
77
78 $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
79 #$this->tpl->setVariable('VAL_LINK',ilLink::_getLink($a_set['ref_id'],'rcrs'));
80 $this->tpl->setVariable('VAL_DESC', $a_set['desc']);
81 $this->tpl->setVariable('VAL_REMOTE', $a_set['from']);
82 $this->tpl->setVariable('VAL_REMOTE_INFO', $a_set['from_info']);
83 $this->tpl->setVariable('TXT_EMAIL', $this->lng->txt('ecs_email'));
84 $this->tpl->setVariable('TXT_DNS', $this->lng->txt('ecs_dns'));
85 $this->tpl->setVariable('TXT_ABR', $this->lng->txt('ecs_abr'));
86 $this->tpl->setVariable(
87 'VAL_LAST_UPDATE',
89 );
90
91 // Links
92 foreach (ilObject::_getAllReferences($a_set['obj_id']) as $ref_id) {
93 $parent = $tree->getParentId($ref_id);
94 $p_obj_id = ilObject::_lookupObjId($parent);
95 $p_title = ilObject::_lookupTitle($p_obj_id);
96 $p_type = ilObject::_lookupType($p_obj_id);
97 $this->tpl->setCurrentBlock('link');
98 $this->tpl->setVariable('LINK_IMG', ilUtil::getTypeIconPath($p_type, $p_obj_id, 'tiny'));
99 $this->tpl->setVariable('LINK_CONTAINER', $p_title);
100 $this->tpl->setVariable('LINK_LINK', ilLink::_getLink($parent, $p_type));
101 $this->tpl->parseCurrentBlock();
102 }
103
104 $this->tpl->setVariable('TXT_TERM', $this->lng->txt('ecs_field_term'));
105 $this->tpl->setVariable('TXT_CRS_TYPE', $this->lng->txt('ecs_field_courseType'));
106 $this->tpl->setVariable('TXT_CRS_ID', $this->lng->txt('ecs_field_courseID'));
107 $this->tpl->setVariable('TXT_CREDITS', $this->lng->txt('ecs_field_credits'));
108 $this->tpl->setVariable('TXT_ROOM', $this->lng->txt('ecs_field_room'));
109 $this->tpl->setVariable('TXT_CYCLE', $this->lng->txt('ecs_field_cycle'));
110 $this->tpl->setVariable('TXT_SWS', $this->lng->txt('ecs_field_semester_hours'));
111 $this->tpl->setVariable('TXT_START', $this->lng->txt('ecs_field_begin'));
112 $this->tpl->setVariable('TXT_END', $this->lng->txt('ecs_field_end'));
113 $this->tpl->setVariable('TXT_LECTURER', $this->lng->txt('ecs_field_lecturer'));
114
115 include_once('./Services/WebServices/ECS/classes/class.ilECSDataMappingSettings.php');
116 $settings = ilECSDataMappingSettings::getInstanceByServerId($a_set['sid']);
117
118 include_once "Services/WebServices/ECS/classes/class.ilECSUtils.php";
119 $values = ilECSUtils::getAdvancedMDValuesForObjId($a_set['obj_id']);
120
121 if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'lecturer')) {
122 $this->tpl->setVariable('VAL_LECTURER', isset($values[$field]) ? $values[$field] : '--');
123 }
124 if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'term')) {
125 $this->tpl->setVariable('VAL_TERM', isset($values[$field]) ? $values[$field] : '--');
126 }
127 if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'courseID')) {
128 $this->tpl->setVariable('VAL_CRS_ID', isset($values[$field]) ? $values[$field] : '--');
129 }
130 if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'courseType')) {
131 $this->tpl->setVariable('VAL_CRS_TYPE', isset($values[$field]) ? $values[$field] : '--');
132 }
133 if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'credits')) {
134 $this->tpl->setVariable('VAL_CREDITS', isset($values[$field]) ? $values[$field] : '--');
135 }
136 if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'semester_hours')) {
137 $this->tpl->setVariable('VAL_SWS', isset($values[$field]) ? $values[$field] : '--');
138 }
139 if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'room')) {
140 $this->tpl->setVariable('VAL_ROOM', isset($values[$field]) ? $values[$field] : '--');
141 }
142 if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'cycle')) {
143 $this->tpl->setVariable('VAL_CYCLE', isset($values[$field]) ? $values[$field] : '--');
144 }
145 if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'begin')) {
146 $this->tpl->setVariable('VAL_START', isset($values[$field]) ? ilDatePresentation::formatDate(new ilDateTime($values[$field], IL_CAL_UNIX)) : '--');
147 }
148 if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'end')) {
149 $this->tpl->setVariable('VAL_END', isset($values[$field]) ? ilDatePresentation::formatDate(new ilDateTime($values[$field], IL_CAL_UNIX)) : '--');
150 }
151 }
152
160 public function parse($a_rcrs)
161 {
162 global $ilObjDataCache;
163
164 // Preload object data
165 $ilObjDataCache->preloadReferenceCache($a_rcrs);
166
167 // Read participants
168 include_once('./Modules/RemoteCourse/classes/class.ilObjRemoteCourse.php');
169 include_once('./Services/WebServices/ECS/classes/class.ilECSCommunityReader.php');
170 include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
171
172 // read obj_ids
173 $obj_ids = array();
174 foreach ($a_rcrs as $rcrs_ref_id) {
175 $obj_id = $ilObjDataCache->lookupObjId($rcrs_ref_id);
176 $obj_ids[$obj_id] = $ilObjDataCache->lookupObjId($rcrs_ref_id);
177 }
178
179 foreach ($obj_ids as $obj_id => $obj_id) {
180 $tmp_arr['obj_id'] = $obj_id;
181 $tmp_arr['sid'] = ilECSImport::lookupServerId($obj_id);
182 $tmp_arr['title'] = $ilObjDataCache->lookupTitle($obj_id);
183 $tmp_arr['desc'] = $ilObjDataCache->lookupDescription($obj_id);
184 $tmp_arr['md'] = '';
185
186 $mid = ilObjRemoteCourse::_lookupMID($obj_id);
187
188 if ($tmp_arr['sid']) {
189 try {
191 } catch (ilECSConnectorException $e) {
192 $reader = null;
193 }
194
195 if ($reader and ($participant = $reader->getParticipantByMID($mid))) {
196 $tmp_arr['from'] = $participant->getParticipantName();
197 $tmp_arr['from_info'] = $participant->getDescription();
198 }
199 } else {
200 $tmp_arr['from'] = $this->lng->txt("ecs_server_deleted");
201 }
202
203 $tmp_arr['last_update'] = $ilObjDataCache->lookupLastUpdate($obj_id);
204 $content[] = $tmp_arr;
205 }
206
207 $this->setData($content ? $content : array());
208 }
209}
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
const IL_CAL_DATETIME
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date @access public.
@classDescription Date and time handling
static getInstanceByServerId($a_server_id)
Get instance by server id.
static getInstanceByServerId($a_server_id)
Get singleton instance.
static lookupServerId($a_obj_id)
Lookup server id of imported content @global <type> $ilDB.
__construct($a_parent_obj, $a_parent_cmd='')
constructor
static getAdvancedMDValuesForObjId($a_obj_id)
Get advanced metadata values for object id.
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
static _getAllReferences($a_id)
get all reference ids of object
static _lookupType($a_id, $a_reference=false)
lookup object type
static _lookupMID($a_obj_id)
lookup owner mid
Class ilTable2GUI.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
static getTypeIconPath($a_type, $a_obj_id, $a_size='small')
Get type icon path path Return image path for icon_xxx.pngs Or (if enabled) path to custom icon Depre...
global $ilCtrl
Definition: ilias.php:18