54 $this->tabs_gui =& $ilTabs;
56 $this->content_gui =& $content_gui;
57 $this->content_obj =& $this->content_gui->object;
66 $cmd = $this->ctrl->getCmd();
67 if (!
$cmd = $this->ctrl->getCmd())
79 if(!$ilAccess->checkAccess(
"read",
'',$this->course_obj->getRefId()))
81 $ilErr->raiseError($this->lng->txt(
'msg_no_perm_write'),$ilErr->MESSAGE);
85 $this->is_tutor = $ilAccess->checkAccess(
'write',
'',$this->course_obj->getRefId());
86 $this->download_allowed = ($this->is_tutor or $this->course_obj->getArchiveType() == $this->course_obj->ARCHIVE_DOWNLOAD);
88 $this->course_obj->initCourseArchiveObject();
89 $this->course_obj->archives_obj->initCourseFilesObject();
92 $archives = $this->is_tutor ?
93 $this->course_obj->archives_obj->getArchives() :
94 $this->course_obj->archives_obj->getPublicArchives();
96 require_once(
"./Services/Table/classes/class.ilTableGUI.php");
100 $this->tpl->addBlockfile(
"ADM_CONTENT",
"adm_content",
"tpl.table.html");
101 $this->tpl->addBlockfile(
"TBL_CONTENT",
"tbl_content",
"tpl.crs_archives_row.html",
'Modules/Course');
103 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
105 $tbl->setTitle($this->lng->txt(
"crs_header_archives"));
108 if($this->download_allowed or $this->is_tutor)
110 $header_names = array(
'',
111 $this->lng->txt(
"type"),
112 $this->lng->txt(
"crs_file_name"),
113 $this->lng->txt(
"crs_size"),
114 $this->lng->txt(
"crs_create_date"),
115 $this->lng->txt(
"crs_archive_lang"));
117 $header_vars = array(
"",
123 $column_width = array(
"1%",
"9%",
"30%",
"20%",
"20%",
"20%");
124 $this->tpl->setVariable(
"COLUMN_COUNTS",6);
128 $header_names = array($this->lng->txt(
"type"),
129 $this->lng->txt(
"crs_file_name"),
130 $this->lng->txt(
"crs_create_date"),
131 $this->lng->txt(
"crs_size"),
132 $this->lng->txt(
"crs_archive_lang"));
134 $header_vars = array(
"type",
139 $column_width = array(
"10%",
"30%",
"20%",
"20%",
"20%");
140 $this->tpl->setVariable(
"COLUMN_COUNTS",5);
143 $tbl->setHeaderNames($header_names);
144 $tbl->setHeaderVars($header_vars,
145 array(
"ref_id" => $this->course_obj->getRefId(),
147 "cmdClass" => strtolower(get_class($this))));
148 $tbl->setColumnWidth($column_width);
152 $tbl->setOrderColumn(
$_GET[
"sort_by"]);
153 $tbl->setOrderDirection(
$_GET[
"sort_order"]);
154 $tbl->setLimit(
$_GET[
"limit"]);
155 $tbl->setOffset(
$_GET[
"offset"]);
156 $tbl->disable(
"sort");
158 if($this->download_allowed)
164 $this->tpl->setCurrentBlock(
"tbl_action_btn");
165 $this->tpl->setVariable(
"BTN_NAME",
"confirmDeleteArchives");
166 $this->tpl->setVariable(
"BTN_VALUE", $this->lng->txt(
"delete"));
167 $this->tpl->parseCurrentBlock();
171 $this->tpl->setCurrentBlock(
"tbl_action_btn");
172 $this->tpl->setVariable(
"BTN_NAME",
"downloadArchives");
173 $this->tpl->setVariable(
"BTN_VALUE", $this->lng->txt(
"download"));
174 $this->tpl->parseCurrentBlock();
177 $tbl->setFooter(
"tblfooter",$this->lng->txt(
"previous"),$this->lng->txt(
"next"));
178 $tbl->setMaxCount(count($archives));
179 $archives = array_slice($archives,
$_GET[
'offset'],
$_GET[
'limit']);
182 if(!count($archives))
184 $this->tpl->setCurrentBlock(
"notfound");
185 $this->tpl->setVariable(
"TXT_OBJECT_NOT_FOUND", $this->lng->txt(
"obj_not_found"));
186 $this->tpl->setVariable(
"NUM_COLS",6);
187 $this->tpl->parseCurrentBlock();
192 foreach($archives as $archive_data)
194 $this->tpl->setCurrentBlock(
"tbl_content");
198 if($this->download_allowed)
200 $this->tpl->setVariable(
"VAL_CHECK",
ilUtil::formCheckbox(0,
"archives[]",$archive_data[
'archive_id']));
203 switch($archive_data[
"archive_type"])
205 case $this->course_obj->archives_obj->ARCHIVE_XML:
206 $type = $this->lng->txt(
"crs_xml");
209 case $this->course_obj->archives_obj->ARCHIVE_HTML:
210 $type = $this->lng->txt(
"crs_html");
213 case $this->course_obj->archives_obj->ARCHIVE_PDF:
214 $type = $this->lng->txt(
"crs_pdf");
217 $this->tpl->setVariable(
"VAL_TYPE",$type);
220 if($archive_data[
'archive_type'] == $this->course_obj->archives_obj->ARCHIVE_HTML)
222 $link =
'<a href="'.$this->course_obj->archives_obj->course_files_obj->getOnlineLink($archive_data[
'archive_name']).
'"'.
223 ' target="_blank">'.$archive_data[
"archive_name"].
'</a>';
227 $link = $archive_data[
'archive_name'];
230 $this->tpl->setVariable(
"VAL_NAME",$link);
231 $this->tpl->setVariable(
"VAL_SIZE",$archive_data[
'archive_size']);
234 if($archive_data[
"archive_lang"])
236 $this->tpl->setVariable(
"VAL_LANG",$this->lng->txt(
'lang_'.$archive_data[
"archive_lang"]));
240 $this->tpl->setVariable(
"VAL_LANG",$this->lng->txt(
'crs_not_available'));
242 $this->tpl->parseCurrentBlock();
244 $this->tpl->parseCurrentBlock();
253 if(!$ilAccess->checkAccess(
"write",
'',$this->course_obj->getRefId()))
255 $ilErr->raiseError($this->lng->txt(
'msg_no_perm_write'),$ilErr->MESSAGE);
258 if(!$_POST[
'archives'])
264 $_SESSION[
"crs_archives"] = $_POST[
"archives"];
267 $this->tpl->addBlockfile(
'ADM_CONTENT',
'adm_content',
'tpl.crs_confirm_delete_archives.html',
'Modules/Course');
268 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
269 $this->tpl->setVariable(
"TXT_ARCHIVE_NAME",$this->lng->txt(
'crs_file_name'));
271 $this->course_obj->initCourseArchiveObject();
274 foreach($_POST[
'archives'] as $archive_id)
276 $archive = $this->course_obj->archives_obj->getArchive($archive_id);
277 $this->tpl->setCurrentBlock(
"archives");
279 $this->tpl->setVariable(
"ARCHIVE_NAME",$archive[
'archive_name']);
281 $this->tpl->parseCurrentBlock();
284 $this->tpl->setVariable(
"DELETE",$this->lng->txt(
'delete'));
285 $this->tpl->setVariable(
"CANCEL",$this->lng->txt(
'cancel'));
295 if(!$ilAccess->checkAccess(
"write",
'',$this->course_obj->getRefId()))
297 $ilErr->raiseError($this->lng->txt(
'msg_no_perm_write'),$ilErr->MESSAGE);
306 $this->course_obj->initCourseArchiveObject();
307 foreach(
$_SESSION[
'crs_archives'] as $archive_id)
309 $this->course_obj->archives_obj->delete($archive_id);
324 if(!$ilAccess->checkAccess(
"write",
'',$this->course_obj->getRefId()))
326 $ilErr->raiseError($this->lng->txt(
'msg_no_perm_write'),
$ilErr->MESSAGE);
329 $this->course_obj->initCourseArchiveObject();
330 $this->course_obj->archives_obj->addXML();
343 if(!$ilAccess->checkAccess(
"write",
'',$this->course_obj->getRefId()))
345 $ilErr->raiseError($this->lng->txt(
'msg_no_perm_write'),
$ilErr->MESSAGE);
348 foreach($this->lng->getInstalledLanguages() as $lang_code)
350 $actions[
"$lang_code"] = $this->lng->txt(
'lang_'.$lang_code);
352 if($this->lng->getLangKey() == $lang_code)
354 $selected = $lang_code;
358 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.crs_selectLanguage.html",
'Modules/Course');
360 $this->tpl->setVariable(
"LANGUAGE_SELECTION",$this->lng->txt(
'crs_archive_language_selection'));
361 $this->tpl->setVariable(
"LANGUAGE",$this->lng->txt(
'obj_lng'));
362 $this->tpl->setVariable(
"INFO_TXT",$this->lng->txt(
'crs_select_archive_language'));
363 $this->tpl->setVariable(
"SELECT_FORMACTION",$this->ctrl->getFormAction($this));
365 $this->tpl->setVariable(
"TXT_CANCEL",$this->lng->txt(
'cancel'));
366 $this->tpl->setVariable(
"TXT_SUBMIT",$this->lng->txt(
'crs_add_html_archive'));
376 if(!$ilAccess->checkAccess(
"write",
'',$this->course_obj->getRefId()))
378 $ilErr->raiseError($this->lng->txt(
'msg_no_perm_write'),
$ilErr->MESSAGE);
381 $this->course_obj->initCourseArchiveObject();
382 $this->course_obj->archives_obj->setLanguage($_POST[
'lang']);
383 $this->course_obj->archives_obj->addHTML();
396 if(!$ilAccess->checkAccess(
"read",
'',$this->course_obj->getRefId()))
398 $ilErr->raiseError($this->lng->txt(
'msg_no_perm_write'),
$ilErr->MESSAGE);
401 $_POST[
"archives"] = $_POST[
"archives"] ? $_POST[
"archives"] : array();
403 if(!count($_POST[
'archives']))
410 if(count($_POST[
'archives']) > 1)
418 $this->course_obj->initCourseArchiveObject();
420 $abs_path = $this->course_obj->archives_obj->getArchiveFile((
int) $_POST[
'archives'][0]);
421 $basename = basename($abs_path);
433 $this->tpl->addBlockfile(
"BUTTONS",
"buttons",
"tpl.buttons.html");
442 $this->tpl->setCurrentBlock(
"btn_cell");
443 $this->tpl->setVariable(
"BTN_LINK", $this->ctrl->getLinkTarget($this,
"addXMLArchive"));
444 $this->tpl->setVariable(
"BTN_TXT", $this->lng->txt(
"crs_add_archive_xml"));
445 $this->tpl->parseCurrentBlock();
447 $this->tpl->setCurrentBlock(
"btn_cell");
448 $this->tpl->setVariable(
"BTN_LINK", $this->ctrl->getLinkTarget($this,
"selectArchiveLanguage"));
449 $this->tpl->setVariable(
"BTN_TXT", $this->lng->txt(
"crs_add_archive_html"));
450 $this->tpl->parseCurrentBlock();
459 if($this->content_obj->getType() ==
'crs')
462 $this->course_obj =& $this->content_obj;
466 $course_ref_id = $tree->checkForParentType($this->content_obj->getRefId(),
'crs');