23 $this->ilias =& $ilias;
25 $this->main_dir = $a_main_directory;
26 $this->post_dir_path =
false;
27 $this->commands = array(
30 "method" =>
"downloadFile",
31 "name" => $lng->txt(
"download"),
36 "method" =>
"confirmDeleteFile",
37 "name" => $lng->txt(
"delete"),
43 "method" =>
"unzipFile",
44 "name" => $lng->txt(
"unzip"),
49 "method" =>
"renameFileForm",
50 "name" => $lng->txt(
"rename"),
56 $this->file_labels = array();
57 $this->label_enable =
false;
58 $this->ctrl->saveParameter($this,
"cdir");
59 $lng->loadLanguageModule(
"content");
73 $this->allow_directories = $a_val;
83 return $this->allow_directories;
93 $this->post_dir_path = $a_val;
103 return $this->post_dir_path;
113 $this->table_id = $a_val;
123 return $this->table_id;
133 $this->title = $a_val;
154 if (!is_array($pars))
158 $_SESSION[
"fsys"][
"lastcomm"] = array_merge(
179 $next_class = $this->ctrl->getNextClass($this);
180 $cmd = $this->ctrl->getCmd();
186 if (substr(
$cmd, 0, 11) ==
"extCommand_")
204 function addCommand(&$a_obj, $a_func, $a_name, $a_single =
true,
205 $a_allow_dir =
false)
207 $i = count($this->commands);
209 $this->commands[$i][
"object"] =& $a_obj;
210 $this->commands[$i][
"method"] = $a_func;
211 $this->commands[$i][
"name"] = $a_name;
212 $this->commands[$i][
"single"] = $a_single;
213 $this->commands[$i][
"allow_dir"] = $a_allow_dir;
223 $this->commands = array();
231 $this->file_labels[$a_file][] = $a_label;
239 $this->label_enable = $a_act;
240 $this->label_header = $a_label_header;
249 foreach (
$_POST[
"file"] as $k => $v)
251 if (
$_POST[
"file"][$k] ==
"..")
253 unset(
$_POST[
"file"][$k]);
258 if (!isset(
$_POST[
"file"]))
260 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
264 if (count(
$_POST[
"file"]) > 1 && $this->commands[$a_nr][
"single"])
266 $this->ilias->raiseError($this->lng->txt(
"cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
273 foreach (
$_POST[
"file"] as $k => $v)
275 $file = (!empty($cur_subdir))
280 if (@is_dir(
$file) && !$this->commands[$a_nr][
"allow_dir"])
282 $this->ilias->raiseError($this->lng->txt(
"select_a_file"),$this->ilias->error_obj->MESSAGE);
284 $file = (!empty($cur_subdir))
290 if ($this->commands[$a_nr][
"single"])
295 $obj =& $this->commands[$a_nr][
"object"];
296 $method = $this->commands[$a_nr][
"method"];
298 return $obj->$method(
$files);
306 $this->directory_creation = $a_val;
314 return $this->directory_creation;
322 $this->file_creation = $a_val;
330 return $this->file_creation;
348 if($new_subdir ==
"..")
350 $cur_subdir = substr($cur_subdir, 0, strrpos($cur_subdir,
"/"));
354 if (!empty($new_subdir))
356 if (!empty($cur_subdir))
358 $cur_subdir = $cur_subdir.
"/".$new_subdir;
362 $cur_subdir = $new_subdir;
367 $cur_subdir = str_replace(
"..",
"", $cur_subdir);
369 $cur_dir = (!empty($cur_subdir))
370 ? $this->main_dir.
"/".$cur_subdir
373 $this->ctrl->setParameter($this,
"cdir", $cur_subdir);
376 $ilToolbar->setFormAction($ilCtrl->getFormAction($this),
true);
377 include_once(
"./Services/Form/classes/class.ilTextInputGUI.php");
381 $ti =
new ilTextInputGUI($this->lng->txt(
"cont_new_dir"),
"new_dir");
384 $ilToolbar->addInputItem($ti,
true);
385 $ilToolbar->addFormButton($lng->txt(
"create"),
"createDirectory");
387 $ilToolbar->addSeparator();
390 include_once(
"./Services/Form/classes/class.ilFileInputGUI.php");
393 $fi =
new ilFileInputGUI($this->lng->txt(
"cont_new_file"),
"new_file");
395 $ilToolbar->addInputItem($fi,
true);
396 $ilToolbar->addFormButton($lng->txt(
"upload"),
"uploadFile");
399 include_once
'Services/FileSystemStorage/classes/class.ilUploadFiles.php';
402 $ilToolbar->addSeparator();
404 $options[
""] = $lng->txt(
"cont_select_from_upload_dir");
407 $file = htmlspecialchars($file, ENT_QUOTES,
"utf-8");
410 include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
411 $si =
new ilSelectInputGUI($this->lng->txt(
"cont_uploaded_file"),
"uploaded_file");
413 $ilToolbar->addInputItem($si,
true);
414 $ilToolbar->addFormButton($lng->txt(
"copy"),
"uploadFile");
419 include_once(
"./Services/FileSystemStorage/classes/class.ilFileSystemTableGUI.php");
421 $this->label_enable, $this->file_labels, $this->label_header, $this->commands,
426 $fs_table->setTitle($this->
getTitle());
428 if (
$_GET[
"resetoffset"] == 1)
430 $fs_table->resetOffset();
432 $this->tpl->setContent($fs_table->getHTML());
442 if (!isset(
$_POST[
"file"]))
444 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
447 if (count(
$_POST[
"file"]) > 1)
449 $this->ilias->raiseError($this->lng->txt(
"cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
454 $this->ilias->raiseError($this->lng->txt(
"select_a_file"),$this->ilias->error_obj->MESSAGE);
458 $file = (!empty($cur_subdir))
464 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
475 $form->addCommandButton(
"renameFile", $lng->txt(
"rename"));
476 $form->addCommandButton(
"cancelRename", $lng->txt(
"cancel"));
477 $form->setFormAction($ilCtrl->getFormAction($this,
"renameFile"));
481 $form->setTitle($this->lng->txt(
"cont_rename_dir"));
485 $form->setTitle($this->lng->txt(
"rename_file"));
488 $this->tpl->setContent($form->getHTML());
499 $new_name = str_replace(
"/",
"", $new_name);
502 $this->ilias->raiseError($this->lng->txt(
"enter_new_name"),$this->ilias->error_obj->MESSAGE);
506 $dir = (!empty($cur_subdir))
507 ? $this->main_dir.
"/".$cur_subdir.
"/"
508 : $this->main_dir.
"/";
510 rename(
$dir.ilUtil::stripSlashes(
$_GET[
"old_name"]),
$dir.$new_name);
513 if (@is_dir(
$dir.$new_name))
517 "new_name" => $new_name));
523 "new_name" => $new_name));
525 $this->ctrl->redirect($this,
"listFiles");
533 $this->ctrl->redirect($this,
"listFiles");
545 $cur_dir = (!empty($cur_subdir))
546 ? $this->main_dir.
"/".$cur_subdir
550 $new_dir = str_replace(
"/",
"", $new_dir);
552 if (!empty($new_dir))
555 if (is_dir($cur_dir.
"/".$new_dir))
565 $this->ctrl->saveParameter($this,
"cdir");
566 $this->ctrl->redirect($this,
"listFiles");
578 $cur_dir = (!empty($cur_subdir))
579 ? $this->main_dir.
"/".$cur_subdir
583 include_once
'Services/FileSystemStorage/classes/class.ilUploadFiles.php';
585 if (is_file($_FILES[
"new_file"][
"tmp_name"]))
587 move_uploaded_file($_FILES[
"new_file"][
"tmp_name"],
597 elseif (
$_POST[
"uploaded_file"])
613 else if (trim($_FILES[
"new_file"][
"name"]) ==
"")
618 $this->ctrl->saveParameter($this,
"cdir");
622 $this->ctrl->redirect($this,
"listFiles");
632 if (!is_array(
$_POST[
"file"]) || count(
$_POST[
"file"]) == 0)
635 $ilCtrl->redirect($this,
"listFile");
639 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
641 $cgui->setFormAction($ilCtrl->getFormAction($this));
642 $cgui->setHeaderText($lng->txt(
"info_delete_sure"));
643 $cgui->setCancel($lng->txt(
"cancel"),
"listFiles");
644 $cgui->setConfirm($lng->txt(
"delete"),
"deleteFile");
646 foreach (
$_POST[
"file"] as $i)
648 $cgui->addItem(
"file[]", $i, $i);
651 $tpl->setContent($cgui->getHTML());
662 if (!isset(
$_POST[
"file"]))
664 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
667 foreach (
$_POST[
"file"] as $post_file)
671 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
676 $cur_dir = (!empty($cur_subdir))
677 ? $this->main_dir.
"/".$cur_subdir
693 $this->ctrl->saveParameter($this,
"cdir");
706 $this->ctrl->redirect($this,
"listFiles");
716 if (!isset(
$_POST[
"file"]))
718 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
721 if (count(
$_POST[
"file"]) > 1)
723 $this->ilias->raiseError($this->lng->txt(
"cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
727 $cur_dir = (!empty($cur_subdir))
728 ? $this->main_dir.
"/".$cur_subdir
746 $this->ctrl->saveParameter($this,
"cdir");
748 $this->ctrl->redirect($this,
"listFiles");
756 if (!isset(
$_POST[
"file"]))
758 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
761 if (count(
$_POST[
"file"]) > 1)
763 $this->ilias->raiseError($this->lng->txt(
"cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
767 $cur_dir = (!empty($cur_subdir))
768 ? $this->main_dir.
"/".$cur_subdir
776 if($entry[
"type"] ==
"file" &&
777 $cur_dir.
"/".$entry[
"entry"] ==
$file)
791 $this->ctrl->saveParameter($this,
"cdir");
792 $this->ctrl->redirect($this,
"listFiles");
803 $ilCtrl->setParameter($this,
"resetoffset", 1);
804 $tabs_gui->addTarget(
"cont_list_files",
805 $this->ctrl->getLinkTarget($this,
"listFiles"),
"listFiles",
807 $ilCtrl->setParameter($this,
"resetoffset",
"");