ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilFileSystemGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
14 {
15  var $ctrl;
16 
17  function ilFileSystemGUI($a_main_directory)
18  {
19  global $lng, $ilCtrl, $tpl, $ilias;
20 
21  $this->ctrl =& $ilCtrl;
22  $this->lng =& $lng;
23  $this->ilias =& $ilias;
24  $this->tpl =& $tpl;
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");
31 //echo "<br>main_dir:".$this->main_dir.":";
32  }
33 
39  function setTableId($a_val)
40  {
41  $this->table_id = $a_val;
42  }
43 
49  function getTableId()
50  {
51  return $this->table_id;
52  }
53 
57  function &executeCommand()
58  {
59  $next_class = $this->ctrl->getNextClass($this);
60  $cmd = $this->ctrl->getCmd();
61 
62  switch($next_class)
63  {
64 
65  default:
66  if (substr($cmd, 0, 11) == "extCommand_")
67  {
68  $ret =& $this->extCommand(substr($cmd, 11, strlen($cmd) - 11));
69  }
70  else
71  {
72  $ret =& $this->$cmd();
73  }
74  break;
75  }
76 
77  return $ret;
78  }
79 
80 
84  function addCommand(&$a_obj, $a_func, $a_name)
85  {
86  $i = count($this->commands);
87 
88  $this->commands[$i]["object"] =& $a_obj;
89  $this->commands[$i]["method"] = $a_func;
90  $this->commands[$i]["name"] = $a_name;
91 
92  //$this->commands[] = $arr;
93  }
94 
95 
99  function labelFile($a_file, $a_label)
100  {
101  $this->file_labels[$a_file][] = $a_label;
102  }
103 
107  function activateLabels($a_act, $a_label_header)
108  {
109  $this->label_enable = $a_act;
110  $this->label_header = $a_label_header;
111  }
112 
116  function &extCommand($a_nr)
117  {
118  if (!isset($_POST["file"]))
119  {
120  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
121  }
122 
123  if (count($_POST["file"]) > 1)
124  {
125  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
126  }
127 
128  if ($_POST["file"][0] == ".." )
129  {
130  $this->ilias->raiseError($this->lng->txt("select_a_file"),$this->ilias->error_obj->MESSAGE);
131  }
132 
133  $cur_subdir = str_replace(".", "", ilUtil::stripSlashes($_GET["cdir"]));
134  $file = (!empty($cur_subdir))
135  ? $this->main_dir."/".$cur_subdir."/".ilUtil::stripSlashes($_POST["file"][0])
136  : $this->main_dir."/".ilUtil::stripSlashes($_POST["file"][0]);
137 
138  // check wether selected item is a directory
139  if (@is_dir($file))
140  {
141  $this->ilias->raiseError($this->lng->txt("select_a_file"),$this->ilias->error_obj->MESSAGE);
142  }
143 
144  $file = (!empty($cur_subdir))
145  ? $cur_subdir."/".ilUtil::stripSlashes($_POST["file"][0])
146  : ilUtil::stripSlashes($_POST["file"][0]);
147 
148  $obj =& $this->commands[$a_nr]["object"];
149  $method = $this->commands[$a_nr]["method"];
150 
151 
152  return $obj->$method($file);
153  }
154 
155 
159  function listFiles()
160  {
161  global $ilToolbar, $lng, $ilCtrl;
162 
163  // create table
164  require_once("./Services/Table/classes/class.ilTableGUI.php");
165  $tbl = new ilTableGUI();
166 
167  // determine directory
168  // FIXME: I have to call stripSlashes here twice, because I could not
169  // determine where the second layer of slashes is added to the
170  // URL Parameter
171  $cur_subdir = ilUtil::stripSlashes(ilUtil::stripSlashes($_GET["cdir"]));
172  $new_subdir = ilUtil::stripSlashes(ilUtil::stripSlashes($_GET["newdir"]));
173 
174  if($new_subdir == "..")
175  {
176  $cur_subdir = substr($cur_subdir, 0, strrpos($cur_subdir, "/"));
177  }
178  else
179  {
180  if (!empty($new_subdir))
181  {
182  if (!empty($cur_subdir))
183  {
184  $cur_subdir = $cur_subdir."/".$new_subdir;
185  }
186  else
187  {
188  $cur_subdir = $new_subdir;
189  }
190  }
191  }
192 
193  $cur_subdir = str_replace("..", "", $cur_subdir);
194 
195  $cur_dir = (!empty($cur_subdir))
196  ? $this->main_dir."/".$cur_subdir
197  : $this->main_dir;
198 
199  $this->ctrl->setParameter($this, "cdir", $cur_subdir);
200 
201  // toolbar for adding files/directories
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");
205  $ti->setMaxLength(80);
206  $ti->setSize(10);
207  $ilToolbar->addInputItem($ti, true);
208  $ilToolbar->addFormButton($lng->txt("create"), "createDirectory");
209 
210  $ilToolbar->addSeparator();
211 
212  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
213  $fi = new ilFileInputGUI($this->lng->txt("cont_new_file"), "new_file");
214  $fi->setSize(10);
215  $ilToolbar->addInputItem($fi, true);
216  $ilToolbar->addFormButton($lng->txt("upload"), "uploadFile");
217 
218  include_once 'Services/FileSystemStorage/classes/class.ilUploadFiles.php';
220  {
221  $ilToolbar->addSeparator();
223  $options[""] = $lng->txt("cont_select_from_upload_dir");
224  foreach($files as $file)
225  {
226  $file = htmlspecialchars($file, ENT_QUOTES, "utf-8");
227  $options[$file] = $file;
228  }
229  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
230  $si = new ilSelectInputGUI($this->lng->txt("cont_uploaded_file"), "uploaded_file");
231  $si->setOptions($options);
232  $ilToolbar->addInputItem($si, true);
233  $ilToolbar->addFormButton($lng->txt("copy"), "uploadFile");
234  }
235 
236  // load files templates
237  //$this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.directory.html", false);
238  include_once("./Services/FileSystemStorage/classes/class.ilFileSystemTableGUI.php");
239  $fs_table = new ilFileSystemTableGUI($this, "listFiles", $cur_dir, $cur_subdir,
240  $this->label_enable, $this->file_labels, $this->label_header, $this->commands);
241  $fs_table->setId($this->getTableId());
242  if ($_GET["resetoffset"] == 1)
243  {
244  $fs_table->resetOffset();
245  }
246  $this->tpl->setContent($fs_table->getHTML());
247 return;
248  //
249  $this->tpl->addBlockfile("ADM_CONTENT", "files", "tpl.table.html");
250 
251  // load template for table content data
252  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.directory_row.html", false);
253 
254  $num = 0;
255 
256  $obj_str = ($this->call_by_reference) ? "" : "&obj_id=".$this->obj_id;
257  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
258 
259  $tbl->setTitle($this->lng->txt("cont_files")." ".$cur_subdir);
260  //$tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
261 
262  /*
263  $cols = array("", "", "dir_file", "size");
264  $header_params = array("ref_id" => $_GET["ref_id"], "obj_id" => $_GET["obj_id"],
265  "cmd" => "listFiles", "hier_id" => $_GET["hier_id"]);
266  $tbl->setHeaderVars($cols, $header_params);*/
267  //$tbl->setColumnWidth(array("1%", "1%", "60%", "40%"));
268 
269  // control
270  /*
271  $tbl->setOrderColumn($_GET["sort_by"]);
272  $tbl->setOrderDirection($_GET["sort_order"]);
273  $tbl->setLimit($_GET["limit"]);
274  $tbl->setOffset($_GET["offset"]);
275  $tbl->setMaxCount($this->maxcount);*/ // ???
276  //$tbl->setMaxCount(30); // ???
277 
278  if (!$this->label_enable)
279  {
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");
286  /*
287  $header_params = array("ref_id" => $_GET["ref_id"], "obj_id" => $_GET["obj_id"],
288  "cmd" => "listFiles", "cmdClass" => get_class($this),
289  "hier_id" => $_GET["hier_id"]);*/
290  $tbl->setHeaderVars($cols, $header_params);
291  }
292  else
293  {
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");
300  /*
301  $header_params = array("ref_id" => $_GET["ref_id"], "obj_id" => $_GET["obj_id"],
302  "cmd" => "listFiles", "cmdClass" => get_class($this), "hier_id" => $_GET["hier_id"]);*/
303  $tbl->setHeaderVars($cols, $header_params);
304  }
305 
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); // ???
311 
312  // delete button
313  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
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();
318 
319  // unzip button
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();
324 
325  // download button
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();
330 
331  // rename button
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();
336 
337  // additional commands
338  for ($i=0; $i < count($this->commands); $i++)
339  {
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();
344  }
345 
346 
347  // footer
348  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
349  //$tbl->disable("footer");
350 
351  if (is_dir($cur_dir))
352  {
353  $entries = ilUtil::getDir($cur_dir);
354  }
355  else
356  {
357  $entries = array(array("type" => "dir", "entry" => ".."));
358  }
359 
360  //$objs = ilUtil::sortArray($objs, $_GET["sort_by"], $_GET["sort_order"]);
361  $tbl->setMaxCount(count($entries));
362  $entries = array_slice($entries, $_GET["offset"], $_GET["limit"]);
363 
364  $tbl->render();
365  if(count($entries) > 0)
366  {
367  $i=0;
368  foreach($entries as $entry)
369  {
370  if(($entry["entry"] == ".") || ($entry["entry"] == ".." && empty($cur_subdir)))
371  {
372  continue;
373  }
374 
375  $cfile = (!empty($cur_subdir))
376  ? $cur_subdir."/".$entry["entry"]
377  : $entry["entry"];
378 
379  // label
380  if ($this->label_enable)
381  {
382  $this->tpl->setCurrentBlock("Label");
383  if ($this->file_labels[$cfile] != "")
384  {
385  $this->tpl->setVariable("TXT_LABEL", $this->file_labels[$cfile]);
386  }
387  else
388  {
389  $this->tpl->setVariable("TXT_LABEL", "&nbsp;");
390  }
391  $this->tpl->parseCurrentBlock();
392  }
393 
394  //$this->tpl->setVariable("ICON", $obj["title"]);
395  if($entry["type"] == "dir")
396  {
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();
403 
404  $this->tpl->setVariable("ICON", "<img src=\"".
405  ilUtil::getImagePath("icon_cat.gif")."\">");
406  }
407  else
408  {
409  $this->tpl->setCurrentBlock("File");
410  $this->tpl->setVariable("TXT_FILENAME2", $entry["entry"]);
411  $this->tpl->parseCurrentBlock();
412  }
413 
414  $this->tpl->setCurrentBlock("tbl_content");
415  $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
416  $this->tpl->setVariable("CSS_ROW", $css_row);
417 
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"]
422  : $entry["entry"];
423  $purpose = array();
424 
425  $this->tpl->parseCurrentBlock();
426  }
427  } //if is_array
428  else
429  {
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();
434  }
435 
436  $this->tpl->parseCurrentBlock();
437  }
438 
442  function renameFileForm()
443  {
444  if (!isset($_POST["file"]))
445  {
446  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
447  }
448 
449  if (count($_POST["file"]) > 1)
450  {
451  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
452  }
453 
454  if (ilUtil::stripSlashes($_POST["file"][0]) == ".." )
455  {
456  $this->ilias->raiseError($this->lng->txt("select_a_file"),$this->ilias->error_obj->MESSAGE);
457  }
458 
459  $cur_subdir = str_replace(".", "", ilUtil::stripSlashes($_GET["cdir"]));
460  $file = (!empty($cur_subdir))
461  ? $this->main_dir."/".$cur_subdir."/".ilUtil::stripSlashes($_POST["file"][0])
462  : $this->main_dir."/".ilUtil::stripSlashes($_POST["file"][0]);
463 
464  // load files templates
465  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.file_rename.html", false);
466 
467  $this->ctrl->setParameter($this, "old_name", ilUtil::stripSlashes($_POST["file"][0]));
468  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "renameFile"));
469  if (@is_dir($file))
470  {
471  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("cont_rename_dir"));
472  }
473  else
474  {
475  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("rename_file"));
476  }
477  $this->tpl->setVariable("TXT_NAME", $this->lng->txt("name"));
478  $this->tpl->setVariable("VAL_NAME", ilUtil::stripSlashes($_POST["file"][0]));
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"));
483 
484  $this->tpl->parseCurrentBlock();
485  }
486 
490  function renameFile()
491  {
492  global $lng;
493 
494  $new_name = str_replace("..", "", ilUtil::stripSlashes($_POST["new_name"]));
495  $new_name = str_replace("/", "", $new_name);
496  if ($new_name == "")
497  {
498  $this->ilias->raiseError($this->lng->txt("enter_new_name"),$this->ilias->error_obj->MESSAGE);
499  }
500 
501  $cur_subdir = str_replace(".", "", ilUtil::stripSlashes($_GET["cdir"]));
502  $dir = (!empty($cur_subdir))
503  ? $this->main_dir."/".$cur_subdir."/"
504  : $this->main_dir."/";
505 
506  rename($dir.ilUtil::stripSlashes($_GET["old_name"]), $dir.$new_name);
507 
508  ilUtil::renameExecutables($this->main_dir);
509  if (@is_dir($dir.$new_name))
510  {
511  ilUtil::sendSuccess($lng->txt("cont_dir_renamed"), true);
512  }
513  else
514  {
515  ilUtil::sendSuccess($lng->txt("cont_file_renamed"), true);
516  }
517  $this->ctrl->redirect($this, "listFiles");
518  }
519 
523  function cancelRename()
524  {
525  $this->ctrl->redirect($this, "listFiles");
526  }
527 
531  function createDirectory()
532  {
533  global $lng;
534 
535  // determine directory
536  $cur_subdir = str_replace(".", "", ilUtil::stripSlashes($_GET["cdir"]));
537  $cur_dir = (!empty($cur_subdir))
538  ? $this->main_dir."/".$cur_subdir
539  : $this->main_dir;
540 
541  $new_dir = str_replace(".", "", ilUtil::stripSlashes($_POST["new_dir"]));
542  $new_dir = str_replace("/", "", $new_dir);
543 
544  if (!empty($new_dir))
545  {
546  ilUtil::makeDir($cur_dir."/".$new_dir);
547  if (is_dir($cur_dir."/".$new_dir))
548  {
549  ilUtil::sendSuccess($lng->txt("cont_dir_created"), true);
550  }
551  }
552  else
553  {
554  ilUtil::sendFailure($lng->txt("cont_enter_a_dir_name"), true);
555  }
556  $this->ctrl->saveParameter($this, "cdir");
557  $this->ctrl->redirect($this, "listFiles");
558  }
559 
563  function uploadFile()
564  {
565  global $lng;
566 
567  // determine directory
568  $cur_subdir = str_replace(".", "", ilUtil::stripSlashes($_GET["cdir"]));
569  $cur_dir = (!empty($cur_subdir))
570  ? $this->main_dir."/".$cur_subdir
571  : $this->main_dir;
572 
573 
574  include_once 'Services/FileSystemStorage/classes/class.ilUploadFiles.php';
575 
576  if (is_file($_FILES["new_file"]["tmp_name"]))
577  {
578  move_uploaded_file($_FILES["new_file"]["tmp_name"],
579  $cur_dir."/".ilUtil::stripSlashes($_FILES["new_file"]["name"]));
580  if (is_file($cur_dir."/".ilUtil::stripSlashes($_FILES["new_file"]["name"])))
581  {
582  ilUtil::sendSuccess($lng->txt("cont_file_created"), true);
583  }
584  }
585  elseif ($_POST["uploaded_file"])
586  {
587  // check if the file is in the ftp directory and readable
588  if (ilUploadFiles::_checkUploadFile($_POST["uploaded_file"]))
589  {
590  // copy uploaded file to data directory
591  ilUploadFiles::_copyUploadFile($_POST["uploaded_file"],
592  $cur_dir."/".ilUtil::stripSlashes($_POST["uploaded_file"]));
593  }
594  if (is_file($cur_dir."/".ilUtil::stripSlashes($_POST["uploaded_file"])))
595  {
596  ilUtil::sendSuccess($lng->txt("cont_file_created"), true);
597  }
598  }
599  else if (trim($_FILES["new_file"]["name"]) == "")
600  {
601  ilUtil::sendFailure($lng->txt("cont_enter_a_file"), true);
602  }
603 
604  $this->ctrl->saveParameter($this, "cdir");
605 
606  ilUtil::renameExecutables($this->main_dir);
607 
608  $this->ctrl->redirect($this, "listFiles");
609  }
610 
611 
615  function deleteFile()
616  {
617  global $lng;
618 
619  if (!isset($_POST["file"]))
620  {
621  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
622  }
623 
624  foreach ($_POST["file"] as $post_file)
625  {
626  if (ilUtil::stripSlashes($post_file) == "..")
627  {
628  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
629  break;
630  }
631 
632  $cur_subdir = str_replace(".", "", ilUtil::stripSlashes($_GET["cdir"]));
633  $cur_dir = (!empty($cur_subdir))
634  ? $this->main_dir."/".$cur_subdir
635  : $this->main_dir;
636  $file = $cur_dir."/".ilUtil::stripSlashes($post_file);
637 
638  if (@is_file($file))
639  {
640  unlink($file);
641  }
642 
643  if (@is_dir($file))
644  {
645  $is_dir = true;
647  }
648  }
649 
650  $this->ctrl->saveParameter($this, "cdir");
651  if ($is_dir)
652  {
653  ilUtil::sendSuccess($lng->txt("cont_dir_deleted"), true);
654  }
655  else
656  {
657  ilUtil::sendSuccess($lng->txt("cont_file_deleted"), true);
658  }
659  $this->ctrl->redirect($this, "listFiles");
660  }
661 
665  function unzipFile()
666  {
667  global $lng;
668 
669  if (!isset($_POST["file"]))
670  {
671  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
672  }
673 
674  if (count($_POST["file"]) > 1)
675  {
676  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
677  }
678 
679  $cur_subdir = str_replace(".", "", ilUtil::stripSlashes($_GET["cdir"]));
680  $cur_dir = (!empty($cur_subdir))
681  ? $this->main_dir."/".$cur_subdir
682  : $this->main_dir;
683  $file = $cur_dir."/".ilUtil::stripSlashes($_POST["file"][0]);
684 
685  if (@is_file($file))
686  {
687  ilUtil::unzip($file, true);
688  }
689 
690  ilUtil::renameExecutables($this->main_dir);
691 
692  $this->ctrl->saveParameter($this, "cdir");
693  ilUtil::sendSuccess($lng->txt("cont_file_unzipped"), true);
694  $this->ctrl->redirect($this, "listFiles");
695  }
696 
700  function downloadFile()
701  {
702  if (!isset($_POST["file"]))
703  {
704  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
705  }
706 
707  if (count($_POST["file"]) > 1)
708  {
709  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
710  }
711 
712  $cur_subdir = str_replace(".", "", ilUtil::stripSlashes($_GET["cdir"]));
713  $cur_dir = (!empty($cur_subdir))
714  ? $this->main_dir."/".$cur_subdir
715  : $this->main_dir;
716  $file = $cur_dir."/".$_POST["file"][0];
717 
718  if (@is_file($file) && !(@is_dir($file)))
719  {
720  ilUtil::deliverFile($file, $_POST["file"][0]);
721  exit;
722  }
723  else
724  {
725  $this->ctrl->saveParameter($this, "cdir");
726  $this->ctrl->redirect($this, "listFiles");
727  }
728  }
729 
733  function getTabs(&$tabs_gui)
734  {
735  global $ilCtrl;
736 
737  $ilCtrl->setParameter($this, "resetoffset", 1);
738  $tabs_gui->addTarget("cont_list_files",
739  $this->ctrl->getLinkTarget($this, "listFiles"), "listFiles",
740  get_class($this));
741  $ilCtrl->setParameter($this, "resetoffset", "");
742  }
743 
744 }
745 ?>