ILIAS  release_8 Revision v8.24
class.ilECSImportedContentTableGUI.php
Go to the documentation of this file.
1<?php
2
18declare(strict_types=1);
19
29{
30 private ilTree $tree;
32
33 public function __construct(?object $a_parent_obj, string $a_parent_cmd = '')
34 {
35 parent::__construct($a_parent_obj, $a_parent_cmd);
36
37 global $DIC;
38 $this->tree = $DIC->repositoryTree();
39 $this->objDataCache = $DIC['ilObjDataCache'];
40
41 $this->addColumn($this->lng->txt('title'), 'title', '25%');
42 $this->addColumn($this->lng->txt('res_links_short'), 'link', '25%');
43 $this->addColumn($this->lng->txt('ecs_imported_from'), 'from', '15%');
44 $this->addColumn($this->lng->txt('ecs_meta_data'), 'md', '25%');
45 $this->addColumn($this->lng->txt('last_update'), 'last_update', '10%');
46 $this->setRowTemplate('tpl.content_row.html', 'Services/WebServices/ECS');
47 $this->setDefaultOrderField('title');
48 $this->setDefaultOrderDirection('asc');
49 if ($a_parent_obj) {
50 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
51 }
52 }
53
61 protected function fillRow(array $a_set): void
62 {
63 $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
64 #$this->tpl->setVariable('VAL_LINK',ilLink::_getLink($a_set['ref_id'],'rcrs'));
65 $this->tpl->setVariable('VAL_DESC', $a_set['desc']);
66 $this->tpl->setVariable('VAL_REMOTE', $a_set['from']);
67 $this->tpl->setVariable('VAL_REMOTE_INFO', $a_set['from_info']);
68 $this->tpl->setVariable('TXT_EMAIL', $this->lng->txt('ecs_email'));
69 $this->tpl->setVariable('TXT_DNS', $this->lng->txt('ecs_dns'));
70 $this->tpl->setVariable('TXT_ABR', $this->lng->txt('ecs_abr'));
71 $this->tpl->setVariable(
72 'VAL_LAST_UPDATE',
74 );
75
76 // Links
77 foreach (ilObject::_getAllReferences($a_set['obj_id']) as $ref_id) {
78 $parent = $this->tree->getParentId($ref_id);
79 $p_obj_id = ilObject::_lookupObjId($parent);
80 $p_title = ilObject::_lookupTitle($p_obj_id);
81 $p_type = ilObject::_lookupType($p_obj_id);
82 $this->tpl->setCurrentBlock('link');
83 $this->tpl->setVariable('LINK_IMG', ilObject::_getIcon($p_obj_id, 'tiny', $p_type));
84 $this->tpl->setVariable('LINK_CONTAINER', $p_title);
85 $this->tpl->setVariable('LINK_LINK', ilLink::_getLink($parent, $p_type));
86 $this->tpl->parseCurrentBlock();
87 }
88
89 $this->tpl->setVariable('TXT_TERM', $this->lng->txt('ecs_field_term'));
90 $this->tpl->setVariable('TXT_CRS_TYPE', $this->lng->txt('ecs_field_courseType'));
91 $this->tpl->setVariable('TXT_CRS_ID', $this->lng->txt('ecs_field_courseID'));
92 $this->tpl->setVariable('TXT_CREDITS', $this->lng->txt('ecs_field_credits'));
93 $this->tpl->setVariable('TXT_ROOM', $this->lng->txt('ecs_field_room'));
94 $this->tpl->setVariable('TXT_CYCLE', $this->lng->txt('ecs_field_cycle'));
95 $this->tpl->setVariable('TXT_SWS', $this->lng->txt('ecs_field_semester_hours'));
96 $this->tpl->setVariable('TXT_START', $this->lng->txt('ecs_field_begin'));
97 $this->tpl->setVariable('TXT_END', $this->lng->txt('ecs_field_end'));
98 $this->tpl->setVariable('TXT_LECTURER', $this->lng->txt('ecs_field_lecturer'));
99
101
102 $values = ilECSUtils::getAdvancedMDValuesForObjId($a_set['obj_id']);
103
104 if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'lecturer')) {
105 $this->tpl->setVariable('VAL_LECTURER', $values[$field] ?? '--');
106 }
107 if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'term')) {
108 $this->tpl->setVariable('VAL_TERM', $values[$field] ?? '--');
109 }
110 if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'courseID')) {
111 $this->tpl->setVariable('VAL_CRS_ID', $values[$field] ?? '--');
112 }
113 if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'courseType')) {
114 $this->tpl->setVariable('VAL_CRS_TYPE', $values[$field] ?? '--');
115 }
116 if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'credits')) {
117 $this->tpl->setVariable('VAL_CREDITS', $values[$field] ?? '--');
118 }
119 if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'semester_hours')) {
120 $this->tpl->setVariable('VAL_SWS', $values[$field] ?? '--');
121 }
122 if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'room')) {
123 $this->tpl->setVariable('VAL_ROOM', $values[$field] ?? '--');
124 }
125 if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'cycle')) {
126 $this->tpl->setVariable('VAL_CYCLE', $values[$field] ?? '--');
127 }
128 if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'begin')) {
129 $this->tpl->setVariable('VAL_START', isset($values[$field]) ? ilDatePresentation::formatDate(new ilDateTime($values[$field], IL_CAL_UNIX)) : '--');
130 }
131 if ($field = $settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, 'end')) {
132 $this->tpl->setVariable('VAL_END', isset($values[$field]) ? ilDatePresentation::formatDate(new ilDateTime($values[$field], IL_CAL_UNIX)) : '--');
133 }
134 }
135
143 public function parse($a_rcrs): void
144 {
145 // Preload object data
146 $this->objDataCache->preloadReferenceCache($a_rcrs);
147
148 // Read participants
149
150 // read obj_ids
151 $obj_ids = array();
152 foreach ($a_rcrs as $rcrs_ref_id) {
153 $obj_id = $this->objDataCache->lookupObjId((int) $rcrs_ref_id);
154 $obj_ids[$obj_id] = $this->objDataCache->lookupObjId((int) $rcrs_ref_id);
155 }
156 $content = array();
157 foreach ($obj_ids as $obj_id => $obj_id) {
158 //$rcourse = new ilObjRemoteCourse($obj_id, false);
159 $tmp_arr['obj_id'] = $obj_id;
160 $tmp_arr['sid'] = ilECSImportManager::getInstance()->lookupServerId($obj_id);
161 $tmp_arr['title'] = $this->objDataCache->lookupTitle($obj_id);
162 $tmp_arr['desc'] = $this->objDataCache->lookupDescription($obj_id);
163 $tmp_arr['md'] = '';
164
165 //$mid = ilECSImportManager::getInstance()->
166 $tmp_arr['from'] = "Broken with ILIAS8";
167 $tmp_arr['from_info'] = "";
168 /*if ($tmp_arr['sid']) {
169 try {
170 $reader = ilECSCommunityReader::getInstanceByServerId($tmp_arr['sid']);
171 } catch (ilECSConnectorException $e) {
172 $reader = null;
173 }
174
175 if ($reader && ($participant = $reader->getParticipantByMID($mid))) {
176 $tmp_arr['from'] = $participant->getParticipantName();
177 $tmp_arr['from_info'] = $participant->getDescription();
178 }
179 } else {
180 $tmp_arr['from'] = $this->lng->txt("ecs_server_deleted");
181 $tmp_arr['from_info'] = "";
182 }*/
183
184 $tmp_arr['last_update'] = $this->objDataCache->lookupLastUpdate((int) $obj_id);
185 $content[] = $tmp_arr;
186 }
187
188 $this->setData($content);
189 }
190}
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)
@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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200