ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
24 include_once('Services/Table/classes/class.ilTable2GUI.php');
25 include_once('./Services/Utilities/classes/class.ilFormat.php');
26 
36 {
37  protected $lng;
38  protected $ctrl;
39 
47  public function __construct($a_parent_obj,$a_parent_cmd = '')
48  {
49  global $lng,$ilCtrl;
50 
51  $this->lng = $lng;
52  $this->ctrl = $ilCtrl;
53 
54  parent::__construct($a_parent_obj,$a_parent_cmd);
55  $this->addColumn($this->lng->txt('title'),'title','25%');
56  $this->addColumn($this->lng->txt('res_links_short'),'link','25%');
57  $this->addColumn($this->lng->txt('ecs_imported_from'),'from','15%');
58  $this->addColumn($this->lng->txt('ecs_meta_data'),'md','25%');
59  $this->addColumn($this->lng->txt('last_update'),'last_update','10%');
60  $this->setRowTemplate('tpl.content_row.html','Services/WebServices/ECS');
61  $this->setDefaultOrderField('title');
62  $this->setDefaultOrderDirection('asc');
63  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
64 
65  }
66 
74  public function fillRow($a_set)
75  {
76  global $tree;
77 
78  include_once('./Services/Link/classes/class.ilLink.php');
79 
80  $this->tpl->setVariable('VAL_TITLE',$a_set['title']);
81  #$this->tpl->setVariable('VAL_LINK',ilLink::_getLink($a_set['ref_id'],'rcrs'));
82  $this->tpl->setVariable('VAL_DESC',$a_set['desc']);
83  $this->tpl->setVariable('VAL_REMOTE',$a_set['from']);
84  $this->tpl->setVariable('VAL_REMOTE_INFO',$a_set['from_info']);
85  $this->tpl->setVariable('TXT_EMAIL',$this->lng->txt('ecs_email'));
86  $this->tpl->setVariable('TXT_DNS',$this->lng->txt('ecs_dns'));
87  $this->tpl->setVariable('TXT_ABR',$this->lng->txt('ecs_abr'));
88  $this->tpl->setVariable('VAL_LAST_UPDATE',
90  );
91 
92  // Links
93  foreach(ilObject::_getAllReferences($a_set['obj_id']) as $ref_id)
94  {
95  $parent = $tree->getParentId($ref_id);
96  $p_obj_id = ilObject::_lookupObjId($parent);
97  $p_title = ilObject::_lookupTitle($p_obj_id);
98  $p_type = ilObject::_lookupType($p_obj_id);
99  $this->tpl->setCurrentBlock('link');
100  $this->tpl->setVariable('LINK_IMG',ilUtil::getTypeIconPath($p_type,$p_obj_id,'tiny'));
101  $this->tpl->setVariable('LINK_CONTAINER',$p_title);
102  $this->tpl->setVariable('LINK_LINK',ilLink::_getLink($parent,$p_type));
103  $this->tpl->parseCurrentBlock();
104  }
105 
106  $this->tpl->setVariable('TXT_TERM',$this->lng->txt('ecs_field_term'));
107  $this->tpl->setVariable('TXT_CRS_TYPE',$this->lng->txt('ecs_field_courseType'));
108  $this->tpl->setVariable('TXT_CRS_ID',$this->lng->txt('ecs_field_courseID'));
109  $this->tpl->setVariable('TXT_CREDITS',$this->lng->txt('ecs_field_credits'));
110  $this->tpl->setVariable('TXT_ROOM',$this->lng->txt('ecs_field_room'));
111  $this->tpl->setVariable('TXT_CYCLE',$this->lng->txt('ecs_field_cycle'));
112  $this->tpl->setVariable('TXT_SWS',$this->lng->txt('ecs_field_semester_hours'));
113  $this->tpl->setVariable('TXT_START',$this->lng->txt('ecs_field_begin'));
114  $this->tpl->setVariable('TXT_END',$this->lng->txt('ecs_field_end'));
115  $this->tpl->setVariable('TXT_LECTURER',$this->lng->txt('ecs_field_lecturer'));
116 
117  include_once('./Services/WebServices/ECS/classes/class.ilECSDataMappingSettings.php');
118  $settings = ilECSDataMappingSettings::getInstanceByServerId($a_set['sid']);
119 
120  include_once('./Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php');
121 
122  $values = ilAdvancedMDValues::_getValuesByObjId($a_set['obj_id']);
123 
124  if($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS,'lecturer'))
125  {
126  $this->tpl->setVariable('VAL_LECTURER',isset($values[$field]) ? $values[$field] : '--');
127  }
128  if($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS,'term'))
129  {
130  $this->tpl->setVariable('VAL_TERM',isset($values[$field]) ? $values[$field] : '--');
131  }
132  if($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS,'courseID'))
133  {
134  $this->tpl->setVariable('VAL_CRS_ID',isset($values[$field]) ? $values[$field] : '--');
135  }
136  if($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS,'courseType'))
137  {
138  $this->tpl->setVariable('VAL_CRS_TYPE',isset($values[$field]) ? $values[$field] : '--');
139  }
140  if($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS,'credits'))
141  {
142  $this->tpl->setVariable('VAL_CREDITS',isset($values[$field]) ? $values[$field] : '--');
143  }
144  if($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS,'semester_hours'))
145  {
146  $this->tpl->setVariable('VAL_SWS',isset($values[$field]) ? $values[$field] : '--');
147  }
148  if($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS,'room'))
149  {
150  $this->tpl->setVariable('VAL_ROOM',isset($values[$field]) ? $values[$field] : '--');
151  }
152  if($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS,'cycle'))
153  {
154  $this->tpl->setVariable('VAL_CYCLE',isset($values[$field]) ? $values[$field] : '--');
155  }
156  if($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS,'begin'))
157  {
158  $this->tpl->setVariable('VAL_START',isset($values[$field]) ? ilDatePresentation::formatDate(new ilDateTime($values[$field],IL_CAL_UNIX)) : '--');
159  }
160  if($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS,'end'))
161  {
162  $this->tpl->setVariable('VAL_END',isset($values[$field]) ? ilDatePresentation::formatDate(new ilDateTime($values[$field],IL_CAL_UNIX)) : '--');
163  }
164  }
165 
173  public function parse($a_rcrs)
174  {
175  global $ilObjDataCache;
176 
177  // Preload object data
178  $ilObjDataCache->preloadReferenceCache($a_rcrs);
179 
180  // Read participants
181  include_once('./Modules/RemoteCourse/classes/class.ilObjRemoteCourse.php');
182  include_once('./Services/WebServices/ECS/classes/class.ilECSCommunityReader.php');
183  include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
184 
185  // read obj_ids
186  $obj_ids = array();
187  foreach($a_rcrs as $rcrs_ref_id)
188  {
189  $obj_id = $ilObjDataCache->lookupObjId($rcrs_ref_id);
190  $obj_ids[$obj_id] = $ilObjDataCache->lookupObjId($rcrs_ref_id);
191  }
192 
193  foreach($obj_ids as $obj_id => $obj_id)
194  {
195  $tmp_arr['obj_id'] = $obj_id;
196  $tmp_arr['sid'] = ilECSImport::lookupServerId($obj_id);
197  $tmp_arr['title'] = $ilObjDataCache->lookupTitle($obj_id);
198  $tmp_arr['desc'] = $ilObjDataCache->lookupDescription($obj_id);
199  $tmp_arr['md'] = '';
200 
201  $mid = ilObjRemoteCourse::_lookupMID($obj_id);
202 
203  if($tmp_arr['sid'])
204  {
205  try {
207  }
208  catch(ilECSConnectorException $e)
209  {
210  $reader = null;
211  }
212 
213  if($reader and ($participant = $reader->getParticipantByMID($mid)))
214  {
215  $tmp_arr['from'] = $participant->getParticipantName();
216  $tmp_arr['from_info'] = $participant->getDescription();
217  }
218  }
219  else
220  {
221  $tmp_arr['from'] = $this->lng->txt("ecs_server_deleted");
222  }
223 
224  $tmp_arr['last_update'] = $ilObjDataCache->lookupLastUpdate($obj_id);
225  $content[] = $tmp_arr;
226  }
227 
228  $this->setData($content ? $content : array());
229  }
230 }
231 ?>