ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilECSImportedContentTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
30{
31 private ilTree $tree;
33
34 public function __construct(?object $a_parent_obj, string $a_parent_cmd = '')
35 {
36 parent::__construct($a_parent_obj, $a_parent_cmd);
37
38 global $DIC;
39 $this->tree = $DIC->repositoryTree();
40 $this->objDataCache = $DIC['ilObjDataCache'];
41
42 $this->addColumn($this->lng->txt('title'), 'title', '25%');
43 $this->addColumn($this->lng->txt('res_links_short'), 'link', '25%');
44 $this->addColumn($this->lng->txt('ecs_imported_from'), 'from', '15%');
45 $this->addColumn($this->lng->txt('ecs_meta_data'), 'md', '25%');
46 $this->addColumn($this->lng->txt('last_update'), 'last_update', '10%');
47 $this->setRowTemplate('tpl.content_row.html', 'components/ILIAS/WebServices/ECS');
48 $this->setDefaultOrderField('title');
49 $this->setDefaultOrderDirection('asc');
50 if ($a_parent_obj) {
51 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
52 }
53 }
54
62 protected function fillRow(array $a_set): void
63 {
64 $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
65 #$this->tpl->setVariable('VAL_LINK',ilLink::_getLink($a_set['ref_id'],'rcrs'));
66 $this->tpl->setVariable('VAL_DESC', $a_set['desc']);
67 $this->tpl->setVariable('VAL_REMOTE', $a_set['from']);
68 $this->tpl->setVariable('VAL_REMOTE_INFO', $a_set['from_info']);
69 $this->tpl->setVariable('TXT_EMAIL', $this->lng->txt('ecs_email'));
70 $this->tpl->setVariable('TXT_DNS', $this->lng->txt('ecs_dns'));
71 $this->tpl->setVariable('TXT_ABR', $this->lng->txt('ecs_abr'));
72 $this->tpl->setVariable(
73 'VAL_LAST_UPDATE',
75 );
76
77 // Links
78 foreach (ilObject::_getAllReferences($a_set['obj_id']) as $ref_id) {
79 $parent = $this->tree->getParentId($ref_id);
80 $p_obj_id = ilObject::_lookupObjId($parent);
81 $p_title = ilObject::_lookupTitle($p_obj_id);
82 $p_type = ilObject::_lookupType($p_obj_id);
83 $this->tpl->setCurrentBlock('link');
84 $this->tpl->setVariable('LINK_IMG', ilObject::_getIcon($p_obj_id, 'tiny', $p_type));
85 $this->tpl->setVariable('LINK_CONTAINER', $p_title);
86 $this->tpl->setVariable('LINK_LINK', ilLink::_getLink($parent, $p_type));
87 $this->tpl->parseCurrentBlock();
88 }
89
90 $this->tpl->setVariable('TXT_TERM', $this->lng->txt('ecs_field_term'));
91 $this->tpl->setVariable('TXT_CRS_TYPE', $this->lng->txt('ecs_field_courseType'));
92 $this->tpl->setVariable('TXT_CRS_ID', $this->lng->txt('ecs_field_courseID'));
93 $this->tpl->setVariable('TXT_CREDITS', $this->lng->txt('ecs_field_credits'));
94 $this->tpl->setVariable('TXT_ROOM', $this->lng->txt('ecs_field_room'));
95 $this->tpl->setVariable('TXT_CYCLE', $this->lng->txt('ecs_field_cycle'));
96 $this->tpl->setVariable('TXT_SWS', $this->lng->txt('ecs_field_semester_hours'));
97 $this->tpl->setVariable('TXT_START', $this->lng->txt('ecs_field_begin'));
98 $this->tpl->setVariable('TXT_END', $this->lng->txt('ecs_field_end'));
99 $this->tpl->setVariable('TXT_LECTURER', $this->lng->txt('ecs_field_lecturer'));
100
101 $settings = ilECSDataMappingSettings::getInstanceByServerId((int) $a_set['sid']);
102
103 $values = ilECSUtils::getAdvancedMDValuesForObjId($a_set['obj_id']);
104
105 if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'lecturer')) {
106 $this->tpl->setVariable('VAL_LECTURER', $values[$field] ?? '--');
107 }
108 if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'term')) {
109 $this->tpl->setVariable('VAL_TERM', $values[$field] ?? '--');
110 }
111 if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'courseID')) {
112 $this->tpl->setVariable('VAL_CRS_ID', $values[$field] ?? '--');
113 }
114 if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'courseType')) {
115 $this->tpl->setVariable('VAL_CRS_TYPE', $values[$field] ?? '--');
116 }
117 if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'credits')) {
118 $this->tpl->setVariable('VAL_CREDITS', $values[$field] ?? '--');
119 }
120 if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'semester_hours')) {
121 $this->tpl->setVariable('VAL_SWS', $values[$field] ?? '--');
122 }
123 if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'room')) {
124 $this->tpl->setVariable('VAL_ROOM', $values[$field] ?? '--');
125 }
126 if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'cycle')) {
127 $this->tpl->setVariable('VAL_CYCLE', $values[$field] ?? '--');
128 }
129 if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'begin')) {
130 $this->tpl->setVariable('VAL_START', isset($values[$field]) ? ilDatePresentation::formatDate(new ilDateTime($values[$field], IL_CAL_UNIX)) : '--');
131 }
132 if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'end')) {
133 $this->tpl->setVariable('VAL_END', isset($values[$field]) ? ilDatePresentation::formatDate(new ilDateTime($values[$field], IL_CAL_UNIX)) : '--');
134 }
135 }
136
144 public function parse($a_rcrs): void
145 {
146 // Preload object data
147 $this->objDataCache->preloadReferenceCache($a_rcrs);
148
149 // Read participants
150
151 // read obj_ids
152 $obj_ids = array();
153 foreach ($a_rcrs as $rcrs_ref_id) {
154 $obj_id = $this->objDataCache->lookupObjId((int) $rcrs_ref_id);
155 $obj_ids[$obj_id] = $this->objDataCache->lookupObjId((int) $rcrs_ref_id);
156 }
157 $content = array();
158 foreach ($obj_ids as $obj_id => $obj_id) {
159 //$rcourse = new ilObjRemoteCourse($obj_id, false);
160 $tmp_arr['obj_id'] = $obj_id;
161 $tmp_arr['sid'] = ilECSImportManager::getInstance()->lookupServerId($obj_id);
162 $tmp_arr['title'] = $this->objDataCache->lookupTitle($obj_id);
163 $tmp_arr['desc'] = $this->objDataCache->lookupDescription($obj_id);
164 $tmp_arr['md'] = '';
165
166 //$mid = ilECSImportManager::getInstance()->
167 $tmp_arr['from'] = "Broken with ILIAS8";
168 $tmp_arr['from_info'] = "";
169 /*if ($tmp_arr['sid']) {
170 try {
171 $reader = ilECSCommunityReader::getInstanceByServerId($tmp_arr['sid']);
172 } catch (ilECSConnectorException $e) {
173 $reader = null;
174 }
175
176 if ($reader && ($participant = $reader->getParticipantByMID($mid))) {
177 $tmp_arr['from'] = $participant->getParticipantName();
178 $tmp_arr['from_info'] = $participant->getDescription();
179 }
180 } else {
181 $tmp_arr['from'] = $this->lng->txt("ecs_server_deleted");
182 $tmp_arr['from_info'] = "";
183 }*/
184
185 $tmp_arr['last_update'] = $this->objDataCache->lookupLastUpdate((int) $obj_id);
186 $content[] = $tmp_arr;
187 }
188
189 $this->setData($content);
190 }
191}
const IL_CAL_UNIX
const IL_CAL_DATETIME
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
static getInstanceByServerId(int $a_server_id)
Get singleton instance.
static getInstance()
Get the singleton instance of this ilECSImportManager.
__construct(?object $a_parent_obj, string $a_parent_cmd='')
static getAdvancedMDValuesForObjId(int $a_obj_id)
Get advanced metadata values for object id.
class ilObjectDataCache
static _lookupType(int $id, bool $reference=false)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
setData(array $a_data)
Set table data.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
$ref_id
Definition: ltiauth.php:66
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26