22 $this->ilias =& $ilias;
24 $this->main_dir = $a_main_directory;
25 $this->post_dir_path =
false;
26 $this->commands = array(
29 "method" =>
"downloadFile",
30 "name" => $lng->txt(
"download"),
35 "method" =>
"confirmDeleteFile",
36 "name" => $lng->txt(
"delete"),
42 "method" =>
"unzipFile",
43 "name" => $lng->txt(
"unzip"),
48 "method" =>
"renameFileForm",
49 "name" => $lng->txt(
"rename"),
55 $this->file_labels = array();
56 $this->label_enable =
false;
57 $this->ctrl->saveParameter($this,
"cdir");
58 $lng->loadLanguageModule(
"content");
72 $this->allow_directories = $a_val;
82 return $this->allow_directories;
92 $this->post_dir_path = $a_val;
102 return $this->post_dir_path;
112 $this->table_id = $a_val;
122 return $this->table_id;
132 $this->title = $a_val;
153 if (!is_array($pars))
157 $_SESSION[
"fsys"][
"lastcomm"] = array_merge(
158 array(
"cmd" => $command), $pars);
178 $next_class = $this->ctrl->getNextClass($this);
179 $cmd = $this->ctrl->getCmd();
185 if (substr(
$cmd, 0, 11) ==
"extCommand_")
203 function addCommand(&$a_obj, $a_func, $a_name, $a_single =
true,
204 $a_allow_dir =
false)
206 $i = count($this->commands);
208 $this->commands[$i][
"object"] =& $a_obj;
209 $this->commands[$i][
"method"] = $a_func;
210 $this->commands[$i][
"name"] = $a_name;
211 $this->commands[$i][
"single"] = $a_single;
212 $this->commands[$i][
"allow_dir"] = $a_allow_dir;
222 $this->commands = array();
230 $this->file_labels[$a_file][] = $a_label;
238 $this->label_enable = $a_act;
239 $this->label_header = $a_label_header;
248 foreach (
$_POST[
"file"] as $k => $v)
250 if (
$_POST[
"file"][$k] ==
"..")
252 unset(
$_POST[
"file"][$k]);
257 if (!isset(
$_POST[
"file"]))
259 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
263 if (count(
$_POST[
"file"]) > 1 && $this->commands[$a_nr][
"single"])
265 $this->ilias->raiseError($this->lng->txt(
"cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
272 foreach (
$_POST[
"file"] as $k => $v)
274 $file = (!empty($cur_subdir))
279 if (@is_dir(
$file) && !$this->commands[$a_nr][
"allow_dir"])
281 $this->ilias->raiseError($this->lng->txt(
"select_a_file"),$this->ilias->error_obj->MESSAGE);
283 $file = (!empty($cur_subdir))
289 if ($this->commands[$a_nr][
"single"])
294 $obj =& $this->commands[$a_nr][
"object"];
295 $method = $this->commands[$a_nr][
"method"];
297 return $obj->$method($files);
305 $this->directory_creation = $a_val;
313 return $this->directory_creation;
321 $this->file_creation = $a_val;
329 return $this->file_creation;
347 if($new_subdir ==
"..")
349 $cur_subdir = substr($cur_subdir, 0, strrpos($cur_subdir,
"/"));
353 if (!empty($new_subdir))
355 if (!empty($cur_subdir))
357 $cur_subdir = $cur_subdir.
"/".$new_subdir;
361 $cur_subdir = $new_subdir;
366 $cur_subdir = str_replace(
"..",
"", $cur_subdir);
367 $cur_dir = (!empty($cur_subdir))
368 ? $this->main_dir.
"/".$cur_subdir
371 $this->ctrl->setParameter($this,
"cdir", $cur_subdir);
374 $ilToolbar->setFormAction($ilCtrl->getFormAction($this),
true);
375 include_once(
"./Services/Form/classes/class.ilTextInputGUI.php");
379 $ti =
new ilTextInputGUI($this->lng->txt(
"cont_new_dir"),
"new_dir");
382 $ilToolbar->addInputItem($ti,
true);
383 $ilToolbar->addFormButton($lng->txt(
"create"),
"createDirectory");
385 $ilToolbar->addSeparator();
388 include_once(
"./Services/Form/classes/class.ilFileInputGUI.php");
391 $fi =
new ilFileInputGUI($this->lng->txt(
"cont_new_file"),
"new_file");
393 $ilToolbar->addInputItem($fi,
true);
394 $ilToolbar->addFormButton($lng->txt(
"upload"),
"uploadFile");
397 include_once
'Services/FileSystem/classes/class.ilUploadFiles.php';
400 $ilToolbar->addSeparator();
402 $options[
""] = $lng->txt(
"cont_select_from_upload_dir");
403 foreach($files as
$file)
405 $file = htmlspecialchars($file, ENT_QUOTES,
"utf-8");
408 include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
410 $si->setOptions($options);
411 $ilToolbar->addInputItem(
$si,
true);
412 $ilToolbar->addFormButton($lng->txt(
"copy"),
"uploadFile");
416 include_once(
"./Services/FileSystem/classes/class.ilFileSystemTableGUI.php");
418 $this->label_enable, $this->file_labels, $this->label_header, $this->commands,
423 $fs_table->setTitle($this->
getTitle());
425 if (
$_GET[
"resetoffset"] == 1)
427 $fs_table->resetOffset();
429 $this->tpl->setContent($fs_table->getHTML());
439 if (!isset(
$_POST[
"file"]))
441 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
444 if (count(
$_POST[
"file"]) > 1)
446 $this->ilias->raiseError($this->lng->txt(
"cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
451 $this->ilias->raiseError($this->lng->txt(
"select_a_file"),$this->ilias->error_obj->MESSAGE);
455 $file = (!empty($cur_subdir))
461 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
472 $form->addCommandButton(
"renameFile", $lng->txt(
"rename"));
473 $form->addCommandButton(
"cancelRename", $lng->txt(
"cancel"));
474 $form->setFormAction($ilCtrl->getFormAction($this,
"renameFile"));
478 $form->setTitle($this->lng->txt(
"cont_rename_dir"));
482 $form->setTitle($this->lng->txt(
"rename_file"));
485 $this->tpl->setContent($form->getHTML());
496 $new_name = str_replace(
"/",
"", $new_name);
499 $this->ilias->raiseError($this->lng->txt(
"enter_new_name"),$this->ilias->error_obj->MESSAGE);
503 $dir = (!empty($cur_subdir))
504 ? $this->main_dir.
"/".$cur_subdir.
"/"
505 : $this->main_dir.
"/";
507 rename($dir.ilUtil::stripSlashes(
$_GET[
"old_name"]), $dir.$new_name);
510 if (@is_dir($dir.$new_name))
514 "new_name" => $new_name));
520 "new_name" => $new_name));
522 $this->ctrl->redirect($this,
"listFiles");
530 $this->ctrl->redirect($this,
"listFiles");
542 $cur_dir = (!empty($cur_subdir))
543 ? $this->main_dir.
"/".$cur_subdir
547 $new_dir = str_replace(
"/",
"", $new_dir);
549 if (!empty($new_dir))
552 if (is_dir($cur_dir.
"/".$new_dir))
562 $this->ctrl->saveParameter($this,
"cdir");
563 $this->ctrl->redirect($this,
"listFiles");
575 $cur_dir = (!empty($cur_subdir))
576 ? $this->main_dir.
"/".$cur_subdir
580 include_once
'Services/FileSystem/classes/class.ilUploadFiles.php';
582 if (is_file($_FILES[
"new_file"][
"tmp_name"]))
584 move_uploaded_file($_FILES[
"new_file"][
"tmp_name"],
594 elseif (
$_POST[
"uploaded_file"])
610 else if (trim($_FILES[
"new_file"][
"name"]) ==
"")
615 $this->ctrl->saveParameter($this,
"cdir");
619 $this->ctrl->redirect($this,
"listFiles");
629 if (!is_array(
$_POST[
"file"]) || count(
$_POST[
"file"]) == 0)
632 $ilCtrl->redirect($this,
"listFile");
636 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
638 $cgui->setFormAction($ilCtrl->getFormAction($this));
639 $cgui->setHeaderText($lng->txt(
"info_delete_sure"));
640 $cgui->setCancel($lng->txt(
"cancel"),
"listFiles");
641 $cgui->setConfirm($lng->txt(
"delete"),
"deleteFile");
643 foreach (
$_POST[
"file"] as $i)
645 $cgui->addItem(
"file[]", $i, $i);
648 $tpl->setContent($cgui->getHTML());
659 if (!isset(
$_POST[
"file"]))
661 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
664 foreach (
$_POST[
"file"] as $post_file)
668 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
673 $cur_dir = (!empty($cur_subdir))
674 ? $this->main_dir.
"/".$cur_subdir
690 $this->ctrl->saveParameter($this,
"cdir");
703 $this->ctrl->redirect($this,
"listFiles");
713 if (!isset(
$_POST[
"file"]))
715 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
718 if (count(
$_POST[
"file"]) > 1)
720 $this->ilias->raiseError($this->lng->txt(
"cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
724 $cur_dir = (!empty($cur_subdir))
725 ? $this->main_dir.
"/".$cur_subdir
743 $this->ctrl->saveParameter($this,
"cdir");
745 $this->ctrl->redirect($this,
"listFiles");
753 if (!isset(
$_POST[
"file"]))
755 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
758 if (count(
$_POST[
"file"]) > 1)
760 $this->ilias->raiseError($this->lng->txt(
"cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
764 $cur_dir = (!empty($cur_subdir))
765 ? $this->main_dir.
"/".$cur_subdir
773 if($entry[
"type"] ==
"file" &&
774 $cur_dir.
"/".$entry[
"entry"] ==
$file)
788 $this->ctrl->saveParameter($this,
"cdir");
789 $this->ctrl->redirect($this,
"listFiles");
800 $ilCtrl->setParameter($this,
"resetoffset", 1);
801 $tabs_gui->addTarget(
"cont_list_files",
802 $this->ctrl->getLinkTarget($this,
"listFiles"),
"listFiles",
804 $ilCtrl->setParameter($this,
"resetoffset",
"");