23 $this->ilias =& $ilias;
25 $this->main_dir = $a_main_directory;
26 $this->commands = array();
27 $this->file_labels = array();
28 $this->label_enable =
false;
29 $this->ctrl->saveParameter($this,
"cdir");
30 $lng->loadLanguageModule(
"content");
41 $this->table_id = $a_val;
51 return $this->table_id;
59 $next_class = $this->ctrl->getNextClass($this);
60 $cmd = $this->ctrl->getCmd();
66 if (substr(
$cmd, 0, 11) ==
"extCommand_")
86 $i = count($this->commands);
88 $this->commands[$i][
"object"] =& $a_obj;
89 $this->commands[$i][
"method"] = $a_func;
90 $this->commands[$i][
"name"] = $a_name;
101 $this->file_labels[$a_file][] = $a_label;
109 $this->label_enable = $a_act;
110 $this->label_header = $a_label_header;
118 if (!isset(
$_POST[
"file"]))
120 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
123 if (count(
$_POST[
"file"]) > 1)
125 $this->ilias->raiseError($this->lng->txt(
"cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
128 if (
$_POST[
"file"][0] ==
".." )
130 $this->ilias->raiseError($this->lng->txt(
"select_a_file"),$this->ilias->error_obj->MESSAGE);
134 $file = (!empty($cur_subdir))
141 $this->ilias->raiseError($this->lng->txt(
"select_a_file"),$this->ilias->error_obj->MESSAGE);
144 $file = (!empty($cur_subdir))
148 $obj =& $this->commands[$a_nr][
"object"];
149 $method = $this->commands[$a_nr][
"method"];
152 return $obj->$method(
$file);
164 require_once(
"./Services/Table/classes/class.ilTableGUI.php");
174 if($new_subdir ==
"..")
176 $cur_subdir = substr($cur_subdir, 0, strrpos($cur_subdir,
"/"));
180 if (!empty($new_subdir))
182 if (!empty($cur_subdir))
184 $cur_subdir = $cur_subdir.
"/".$new_subdir;
188 $cur_subdir = $new_subdir;
193 $cur_subdir = str_replace(
"..",
"", $cur_subdir);
195 $cur_dir = (!empty($cur_subdir))
196 ? $this->main_dir.
"/".$cur_subdir
199 $this->ctrl->setParameter($this,
"cdir", $cur_subdir);
202 $ilToolbar->setFormAction($ilCtrl->getFormAction($this),
true);
203 include_once(
"./Services/Form/classes/class.ilTextInputGUI.php");
204 $ti =
new ilTextInputGUI($this->lng->txt(
"cont_new_dir"),
"new_dir");
207 $ilToolbar->addInputItem($ti,
true);
208 $ilToolbar->addFormButton($lng->txt(
"create"),
"createDirectory");
210 $ilToolbar->addSeparator();
212 include_once(
"./Services/Form/classes/class.ilFileInputGUI.php");
213 $fi =
new ilFileInputGUI($this->lng->txt(
"cont_new_file"),
"new_file");
215 $ilToolbar->addInputItem($fi,
true);
216 $ilToolbar->addFormButton($lng->txt(
"upload"),
"uploadFile");
218 include_once
'Services/FileSystemStorage/classes/class.ilUploadFiles.php';
221 $ilToolbar->addSeparator();
223 $options[
""] = $lng->txt(
"cont_select_from_upload_dir");
226 $file = htmlspecialchars($file, ENT_QUOTES,
"utf-8");
229 include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
230 $si =
new ilSelectInputGUI($this->lng->txt(
"cont_uploaded_file"),
"uploaded_file");
232 $ilToolbar->addInputItem($si,
true);
233 $ilToolbar->addFormButton($lng->txt(
"copy"),
"uploadFile");
238 include_once(
"./Services/FileSystemStorage/classes/class.ilFileSystemTableGUI.php");
240 $this->label_enable, $this->file_labels, $this->label_header, $this->commands);
242 if (
$_GET[
"resetoffset"] == 1)
244 $fs_table->resetOffset();
246 $this->tpl->setContent($fs_table->getHTML());
249 $this->tpl->addBlockfile(
"ADM_CONTENT",
"files",
"tpl.table.html");
252 $this->tpl->addBlockfile(
"TBL_CONTENT",
"tbl_content",
"tpl.directory_row.html",
false);
256 $obj_str = ($this->call_by_reference) ?
"" :
"&obj_id=".$this->obj_id;
257 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
259 $tbl->setTitle($this->lng->txt(
"cont_files").
" ".$cur_subdir);
278 if (!$this->label_enable)
280 $tbl->setHeaderNames(array(
"",
"", $this->lng->txt(
"cont_dir_file"),
281 $this->lng->txt(
"cont_size")));
282 $this->tpl->setVariable(
"COLUMN_COUNTS", 4);
283 $tbl->setColumnWidth(array(
"1%",
"1%",
"60%",
"40%"));
284 $cols = array(
"",
"",
"dir_file",
"size");
285 $header_params = $this->ctrl->getParameterArray($this,
"listFiles");
290 $tbl->setHeaderVars($cols, $header_params);
294 $tbl->setHeaderNames(array(
"",
"", $this->lng->txt(
"cont_dir_file"),
295 $this->lng->txt(
"cont_size"), $this->label_header));
296 $this->tpl->setVariable(
"COLUMN_COUNTS", 5);
297 $tbl->setColumnWidth(array(
"1%",
"1%",
"50%",
"25%",
"25%"));
298 $cols = array(
"",
"",
"dir_file",
"size",
"label");
299 $header_params = $this->ctrl->getParameterArray($this,
"listFiles");
303 $tbl->setHeaderVars($cols, $header_params);
306 $tbl->setOrderColumn(
$_GET[
"sort_by"]);
307 $tbl->setOrderDirection(
$_GET[
"sort_order"]);
308 $tbl->setLimit(
$_GET[
"limit"]);
309 $tbl->setOffset(
$_GET[
"offset"]);
310 $tbl->setMaxCount($this->maxcount);
314 $this->tpl->setCurrentBlock(
"tbl_action_btn");
315 $this->tpl->setVariable(
"BTN_NAME",
"deleteFile");
316 $this->tpl->setVariable(
"BTN_VALUE", $this->lng->txt(
"delete"));
317 $this->tpl->parseCurrentBlock();
320 $this->tpl->setCurrentBlock(
"tbl_action_btn");
321 $this->tpl->setVariable(
"BTN_NAME",
"unzipFile");
322 $this->tpl->setVariable(
"BTN_VALUE", $this->lng->txt(
"unzip"));
323 $this->tpl->parseCurrentBlock();
326 $this->tpl->setCurrentBlock(
"tbl_action_btn");
327 $this->tpl->setVariable(
"BTN_NAME",
"downloadFile");
328 $this->tpl->setVariable(
"BTN_VALUE", $this->lng->txt(
"download"));
329 $this->tpl->parseCurrentBlock();
332 $this->tpl->setCurrentBlock(
"tbl_action_btn");
333 $this->tpl->setVariable(
"BTN_NAME",
"renameFileForm");
334 $this->tpl->setVariable(
"BTN_VALUE", $this->lng->txt(
"rename"));
335 $this->tpl->parseCurrentBlock();
338 for ($i=0; $i < count($this->commands); $i++)
340 $this->tpl->setCurrentBlock(
"tbl_action_btn");
341 $this->tpl->setVariable(
"BTN_NAME",
"extCommand_".$i);
342 $this->tpl->setVariable(
"BTN_VALUE", $this->commands[$i][
"name"]);
343 $this->tpl->parseCurrentBlock();
348 $tbl->setFooter(
"tblfooter",$this->lng->txt(
"previous"),$this->lng->txt(
"next"));
351 if (is_dir($cur_dir))
357 $entries = array(array(
"type" =>
"dir",
"entry" =>
".."));
361 $tbl->setMaxCount(count($entries));
362 $entries = array_slice($entries,
$_GET[
"offset"],
$_GET[
"limit"]);
365 if(count($entries) > 0)
368 foreach($entries as $entry)
370 if(($entry[
"entry"] ==
".") || ($entry[
"entry"] ==
".." && empty($cur_subdir)))
375 $cfile = (!empty($cur_subdir))
376 ? $cur_subdir.
"/".$entry[
"entry"]
380 if ($this->label_enable)
382 $this->tpl->setCurrentBlock(
"Label");
383 if ($this->file_labels[$cfile] !=
"")
385 $this->tpl->setVariable(
"TXT_LABEL", $this->file_labels[$cfile]);
389 $this->tpl->setVariable(
"TXT_LABEL",
" ");
391 $this->tpl->parseCurrentBlock();
395 if($entry[
"type"] ==
"dir")
397 $this->tpl->setCurrentBlock(
"FileLink");
398 $this->ctrl->setParameter($this,
"cdir", $cur_subdir);
399 $this->ctrl->setParameter($this,
"newdir", $entry[
"entry"]);
400 $this->tpl->setVariable(
"LINK_FILENAME", $this->ctrl->getLinkTarget($this,
"listFiles"));
401 $this->tpl->setVariable(
"TXT_FILENAME", $entry[
"entry"]);
402 $this->tpl->parseCurrentBlock();
404 $this->tpl->setVariable(
"ICON",
"<img src=\"".
409 $this->tpl->setCurrentBlock(
"File");
410 $this->tpl->setVariable(
"TXT_FILENAME2", $entry[
"entry"]);
411 $this->tpl->parseCurrentBlock();
414 $this->tpl->setCurrentBlock(
"tbl_content");
416 $this->tpl->setVariable(
"CSS_ROW", $css_row);
418 $this->tpl->setVariable(
"TXT_SIZE", $entry[
"size"]);
419 $this->tpl->setVariable(
"CHECKBOX_ID", $entry[
"entry"]);
420 $compare = (!empty($cur_subdir))
421 ? $cur_subdir.
"/".$entry[
"entry"]
425 $this->tpl->parseCurrentBlock();
430 $this->tpl->setCurrentBlock(
"notfound");
431 $this->tpl->setVariable(
"TXT_OBJECT_NOT_FOUND", $this->lng->txt(
"obj_not_found"));
432 $this->tpl->setVariable(
"NUM_COLS", 4);
433 $this->tpl->parseCurrentBlock();
436 $this->tpl->parseCurrentBlock();
444 if (!isset(
$_POST[
"file"]))
446 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
449 if (count(
$_POST[
"file"]) > 1)
451 $this->ilias->raiseError($this->lng->txt(
"cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
456 $this->ilias->raiseError($this->lng->txt(
"select_a_file"),$this->ilias->error_obj->MESSAGE);
460 $file = (!empty($cur_subdir))
465 $this->tpl->addBlockfile(
"ADM_CONTENT",
"adm_content",
"tpl.file_rename.html",
false);
468 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this,
"renameFile"));
471 $this->tpl->setVariable(
"TXT_HEADER", $this->lng->txt(
"cont_rename_dir"));
475 $this->tpl->setVariable(
"TXT_HEADER", $this->lng->txt(
"rename_file"));
477 $this->tpl->setVariable(
"TXT_NAME", $this->lng->txt(
"name"));
479 $this->tpl->setVariable(
"CMD_CANCEL",
"cancelRename");
480 $this->tpl->setVariable(
"CMD_SUBMIT",
"renameFile");
481 $this->tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
"cancel"));
482 $this->tpl->setVariable(
"TXT_SUBMIT", $this->lng->txt(
"rename"));
484 $this->tpl->parseCurrentBlock();
495 $new_name = str_replace(
"/",
"", $new_name);
498 $this->ilias->raiseError($this->lng->txt(
"enter_new_name"),$this->ilias->error_obj->MESSAGE);
502 $dir = (!empty($cur_subdir))
503 ? $this->main_dir.
"/".$cur_subdir.
"/"
504 : $this->main_dir.
"/";
506 rename(
$dir.ilUtil::stripSlashes(
$_GET[
"old_name"]),
$dir.$new_name);
509 if (@is_dir(
$dir.$new_name))
517 $this->ctrl->redirect($this,
"listFiles");
525 $this->ctrl->redirect($this,
"listFiles");
537 $cur_dir = (!empty($cur_subdir))
538 ? $this->main_dir.
"/".$cur_subdir
542 $new_dir = str_replace(
"/",
"", $new_dir);
544 if (!empty($new_dir))
547 if (is_dir($cur_dir.
"/".$new_dir))
556 $this->ctrl->saveParameter($this,
"cdir");
557 $this->ctrl->redirect($this,
"listFiles");
569 $cur_dir = (!empty($cur_subdir))
570 ? $this->main_dir.
"/".$cur_subdir
574 include_once
'Services/FileSystemStorage/classes/class.ilUploadFiles.php';
576 if (is_file($_FILES[
"new_file"][
"tmp_name"]))
578 move_uploaded_file($_FILES[
"new_file"][
"tmp_name"],
599 else if (trim($_FILES[
"new_file"][
"name"]) ==
"")
604 $this->ctrl->saveParameter($this,
"cdir");
608 $this->ctrl->redirect($this,
"listFiles");
619 if (!isset(
$_POST[
"file"]))
621 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
624 foreach (
$_POST[
"file"] as $post_file)
628 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
633 $cur_dir = (!empty($cur_subdir))
634 ? $this->main_dir.
"/".$cur_subdir
650 $this->ctrl->saveParameter($this,
"cdir");
659 $this->ctrl->redirect($this,
"listFiles");
669 if (!isset(
$_POST[
"file"]))
671 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
674 if (count(
$_POST[
"file"]) > 1)
676 $this->ilias->raiseError($this->lng->txt(
"cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
680 $cur_dir = (!empty($cur_subdir))
681 ? $this->main_dir.
"/".$cur_subdir
692 $this->ctrl->saveParameter($this,
"cdir");
694 $this->ctrl->redirect($this,
"listFiles");
702 if (!isset(
$_POST[
"file"]))
704 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
707 if (count(
$_POST[
"file"]) > 1)
709 $this->ilias->raiseError($this->lng->txt(
"cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
713 $cur_dir = (!empty($cur_subdir))
714 ? $this->main_dir.
"/".$cur_subdir
725 $this->ctrl->saveParameter($this,
"cdir");
726 $this->ctrl->redirect($this,
"listFiles");
737 $ilCtrl->setParameter($this,
"resetoffset", 1);
738 $tabs_gui->addTarget(
"cont_list_files",
739 $this->ctrl->getLinkTarget($this,
"listFiles"),
"listFiles",
741 $ilCtrl->setParameter($this,
"resetoffset",
"");