24 $this->ilias =& $ilias;
26 $this->main_dir = $a_main_directory;
27 $this->post_dir_path =
false;
28 $this->commands = array(
31 "method" =>
"downloadFile",
32 "name" => $lng->txt(
"download"),
37 "method" =>
"confirmDeleteFile",
38 "name" => $lng->txt(
"delete"),
44 "method" =>
"unzipFile",
45 "name" => $lng->txt(
"unzip"),
50 "method" =>
"renameFileForm",
51 "name" => $lng->txt(
"rename"),
57 $this->file_labels = array();
58 $this->label_enable =
false;
59 $this->ctrl->saveParameter($this,
"cdir");
60 $lng->loadLanguageModule(
"content");
74 $this->allow_directories = $a_val;
84 return $this->allow_directories;
94 $this->post_dir_path = $a_val;
104 return $this->post_dir_path;
114 $this->table_id = $a_val;
124 return $this->table_id;
134 $this->title = $a_val;
154 $this->use_upload_directory = $a_val;
175 if (!is_array($pars))
179 $_SESSION[
"fsys"][
"lastcomm"] = array_merge(
180 array(
"cmd" => $command), $pars);
200 $next_class = $this->ctrl->getNextClass($this);
201 $cmd = $this->ctrl->getCmd(
"listFiles");
207 if (substr(
$cmd, 0, 11) ==
"extCommand_")
225 function addCommand(&$a_obj, $a_func, $a_name, $a_single =
true,
226 $a_allow_dir =
false)
228 $i = count($this->commands);
230 $this->commands[$i][
"object"] =& $a_obj;
231 $this->commands[$i][
"method"] = $a_func;
232 $this->commands[$i][
"name"] = $a_name;
233 $this->commands[$i][
"single"] = $a_single;
234 $this->commands[$i][
"allow_dir"] = $a_allow_dir;
244 $this->commands = array();
252 $this->file_labels[$a_file][] = $a_label;
260 $this->label_enable = $a_act;
261 $this->label_header = $a_label_header;
269 if (isset(
$_POST[
"file"]))
272 foreach (
$_POST[
"file"] as $k => $v)
274 if (
$_POST[
"file"][$k] ==
"..")
276 unset(
$_POST[
"file"][$k]);
283 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
287 if (count(
$_POST[
"file"]) > 1 && $this->commands[$a_nr][
"single"])
289 $this->ilias->raiseError($this->lng->txt(
"cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
296 foreach (
$_POST[
"file"] as $k => $v)
298 $file = (!empty($cur_subdir))
303 if (@is_dir(
$file) && !$this->commands[$a_nr][
"allow_dir"])
305 $this->ilias->raiseError($this->lng->txt(
"select_a_file"),$this->ilias->error_obj->MESSAGE);
307 $file = (!empty($cur_subdir))
313 if ($this->commands[$a_nr][
"single"])
318 $obj =& $this->commands[$a_nr][
"object"];
319 $method = $this->commands[$a_nr][
"method"];
321 return $obj->$method($files);
329 $this->directory_creation = $a_val;
337 return $this->directory_creation;
345 $this->file_creation = $a_val;
353 return $this->file_creation;
371 if($new_subdir ==
"..")
373 $cur_subdir = substr($cur_subdir, 0, strrpos($cur_subdir,
"/"));
377 if (!empty($new_subdir))
379 if (!empty($cur_subdir))
381 $cur_subdir = $cur_subdir.
"/".$new_subdir;
385 $cur_subdir = $new_subdir;
390 $cur_subdir = str_replace(
"..",
"", $cur_subdir);
391 $cur_dir = (!empty($cur_subdir))
392 ? $this->main_dir.
"/".$cur_subdir
395 $this->ctrl->setParameter($this,
"cdir", $cur_subdir);
398 $ilToolbar->setFormAction($ilCtrl->getFormAction($this),
true);
399 include_once(
"./Services/Form/classes/class.ilTextInputGUI.php");
403 $ti =
new ilTextInputGUI($this->lng->txt(
"cont_new_dir"),
"new_dir");
406 $ilToolbar->addInputItem($ti,
true);
407 $ilToolbar->addFormButton($lng->txt(
"create"),
"createDirectory");
409 $ilToolbar->addSeparator();
412 include_once(
"./Services/Form/classes/class.ilFileInputGUI.php");
415 $fi =
new ilFileInputGUI($this->lng->txt(
"cont_new_file"),
"new_file");
417 $ilToolbar->addInputItem($fi,
true);
418 $ilToolbar->addFormButton($lng->txt(
"upload"),
"uploadFile");
421 include_once
'Services/FileSystem/classes/class.ilUploadFiles.php';
424 $ilToolbar->addSeparator();
426 $options[
""] = $lng->txt(
"cont_select_from_upload_dir");
427 foreach($files as
$file)
429 $file = htmlspecialchars($file, ENT_QUOTES,
"utf-8");
432 include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
435 $ilToolbar->addInputItem(
$si,
true);
436 $ilToolbar->addFormButton($lng->txt(
"copy"),
"uploadFile");
440 include_once(
"./Services/FileSystem/classes/class.ilFileSystemTableGUI.php");
442 $this->label_enable, $this->file_labels, $this->label_header, $this->commands,
446 $fs_table->setTitle($this->
getTitle());
448 if (
$_GET[
"resetoffset"] == 1)
450 $fs_table->resetOffset();
452 $this->tpl->setContent($fs_table->getHTML());
462 if (!isset(
$_POST[
"file"]))
464 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
467 if (count(
$_POST[
"file"]) > 1)
469 $this->ilias->raiseError($this->lng->txt(
"cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
474 $this->ilias->raiseError($this->lng->txt(
"select_a_file"),$this->ilias->error_obj->MESSAGE);
478 $file = (!empty($cur_subdir))
484 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
495 $form->addCommandButton(
"renameFile", $lng->txt(
"rename"));
496 $form->addCommandButton(
"cancelRename", $lng->txt(
"cancel"));
497 $form->setFormAction($ilCtrl->getFormAction($this,
"renameFile"));
501 $form->setTitle($this->lng->txt(
"cont_rename_dir"));
505 $form->setTitle($this->lng->txt(
"rename_file"));
508 $this->tpl->setContent($form->getHTML());
519 $new_name = str_replace(
"/",
"", $new_name);
522 $this->ilias->raiseError($this->lng->txt(
"enter_new_name"),$this->ilias->error_obj->MESSAGE);
526 $dir = (!empty($cur_subdir))
527 ? $this->main_dir.
"/".$cur_subdir.
"/"
528 : $this->main_dir.
"/";
530 rename($dir.ilUtil::stripSlashes(
$_GET[
"old_name"]), $dir.$new_name);
533 if (@is_dir($dir.$new_name))
537 "new_name" => $new_name));
543 "new_name" => $new_name));
545 $this->ctrl->redirect($this,
"listFiles");
553 $this->ctrl->redirect($this,
"listFiles");
565 $cur_dir = (!empty($cur_subdir))
566 ? $this->main_dir.
"/".$cur_subdir
570 $new_dir = str_replace(
"/",
"", $new_dir);
572 if (!empty($new_dir))
575 if (is_dir($cur_dir.
"/".$new_dir))
585 $this->ctrl->saveParameter($this,
"cdir");
586 $this->ctrl->redirect($this,
"listFiles");
598 $cur_dir = (!empty($cur_subdir))
599 ? $this->main_dir.
"/".$cur_subdir
604 if (is_file($_FILES[
"new_file"][
"tmp_name"]))
608 move_uploaded_file($_FILES[
"new_file"][
"tmp_name"], $tgt_file);
611 elseif (
$_POST[
"uploaded_file"])
613 include_once
'Services/FileSystem/classes/class.ilUploadFiles.php';
624 else if (trim($_FILES[
"new_file"][
"name"]) ==
"")
629 if($tgt_file && is_file($tgt_file))
634 include_once(
"./Services/Utilities/classes/class.ilMimeTypeUtil.php");
637 $this->ctrl->setParameter($this,
"upfile", basename($tgt_file));
638 $url = $this->ctrl->getLinkTarget($this,
"unzipFile");
639 $this->ctrl->setParameter($this,
"upfile",
"");
641 include_once
"Services/UIComponent/Button/classes/class.ilLinkButton.php";
643 $unzip->setCaption(
"unzip");
644 $unzip->setUrl($url);
645 $unzip =
" ".$unzip->render();
651 array(
"name" => substr($tgt_file, strlen($this->main_dir)+1)));
654 $this->ctrl->saveParameter($this,
"cdir");
658 $this->ctrl->redirect($this,
"listFiles");
668 if (!is_array(
$_POST[
"file"]) || count(
$_POST[
"file"]) == 0)
671 $ilCtrl->redirect($this,
"listFile");
675 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
677 $cgui->setFormAction($ilCtrl->getFormAction($this));
678 $cgui->setHeaderText($lng->txt(
"info_delete_sure"));
679 $cgui->setCancel($lng->txt(
"cancel"),
"listFiles");
680 $cgui->setConfirm($lng->txt(
"delete"),
"deleteFile");
682 foreach (
$_POST[
"file"] as $i)
684 $cgui->addItem(
"file[]", $i, $i);
687 $tpl->setContent($cgui->getHTML());
698 if (!isset(
$_POST[
"file"]))
700 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
703 foreach (
$_POST[
"file"] as $post_file)
707 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
712 $cur_dir = (!empty($cur_subdir))
713 ? $this->main_dir.
"/".$cur_subdir
729 $this->ctrl->saveParameter($this,
"cdir");
742 $this->ctrl->redirect($this,
"listFiles");
752 if (isset(
$_GET[
"upfile"]))
758 if (!isset(
$_POST[
"file"]))
760 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
763 if (count(
$_POST[
"file"]) > 1)
765 $this->ilias->raiseError($this->lng->txt(
"cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
772 $cur_dir = (!empty($cur_subdir))
773 ? $this->main_dir.
"/".$cur_subdir
792 $diff = array_diff($new_files, $cur_files);
797 include_once(
"./Services/Utilities/classes/class.ilFileUtils.php");
798 $new_files = array();
800 foreach($diff as $new_item)
802 if(is_dir($cur_dir.
"/".$new_item))
808 if(is_array($new_files[
"path"]))
810 foreach($new_files[
"path"] as $idx =>
$path)
812 $path = substr(
$path, strlen($this->main_dir)+1);
813 $diff[] =
$path.$new_files[
"file"][$idx];
819 array(
"name" => substr(
$file, strlen($this->main_dir)+1),
826 $this->ctrl->saveParameter($this,
"cdir");
828 $this->ctrl->redirect($this,
"listFiles");
836 if (!isset(
$_POST[
"file"]))
838 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
841 if (count(
$_POST[
"file"]) > 1)
843 $this->ilias->raiseError($this->lng->txt(
"cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
847 $cur_dir = (!empty($cur_subdir))
848 ? $this->main_dir.
"/".$cur_subdir
856 if($entry[
"type"] ==
"file" &&
857 $cur_dir.
"/".$entry[
"entry"] ==
$file)
871 $this->ctrl->saveParameter($this,
"cdir");
872 $this->ctrl->redirect($this,
"listFiles");
883 $ilCtrl->setParameter($this,
"resetoffset", 1);
884 $tabs_gui->addTarget(
"cont_list_files",
885 $this->ctrl->getLinkTarget($this,
"listFiles"),
"listFiles",
887 $ilCtrl->setParameter($this,
"resetoffset",
"");