41 $this->ilias =& $ilias;
43 $this->main_dir = $a_main_directory;
44 $this->commands = array();
45 $this->file_labels = array();
46 $this->label_enable =
false;
47 $this->ctrl->saveParameter($this,
"cdir");
56 $next_class = $this->ctrl->getNextClass($this);
57 $cmd = $this->ctrl->getCmd();
63 if (substr(
$cmd, 0, 11) ==
"extCommand_")
83 $i = count($this->commands);
85 $this->commands[$i][
"object"] =& $a_obj;
86 $this->commands[$i][
"method"] = $a_func;
87 $this->commands[$i][
"name"] = $a_name;
98 $this->file_labels[$a_file] = $a_label;
106 $this->label_enable = $a_act;
107 $this->label_header = $a_label_header;
115 if (!isset($_POST[
"file"]))
117 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
120 if (count($_POST[
"file"]) > 1)
122 $this->ilias->raiseError($this->lng->txt(
"cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
125 if ($_POST[
"file"][0] ==
".." )
127 $this->ilias->raiseError($this->lng->txt(
"select_a_file"),$this->ilias->error_obj->MESSAGE);
131 $file = (!empty($cur_subdir))
138 $this->ilias->raiseError($this->lng->txt(
"select_a_file"),$this->ilias->error_obj->MESSAGE);
141 $file = (!empty($cur_subdir))
145 $obj =& $this->commands[$a_nr][
"object"];
146 $method = $this->commands[$a_nr][
"method"];
149 return $obj->$method(
$file);
159 require_once(
"./Services/Table/classes/class.ilTableGUI.php");
169 if($new_subdir ==
"..")
171 $cur_subdir = substr($cur_subdir, 0, strrpos($cur_subdir,
"/"));
175 if (!empty($new_subdir))
177 if (!empty($cur_subdir))
179 $cur_subdir = $cur_subdir.
"/".$new_subdir;
183 $cur_subdir = $new_subdir;
188 $cur_subdir = str_replace(
"..",
"", $cur_subdir);
190 $cur_dir = (!empty($cur_subdir))
191 ? $this->main_dir.
"/".$cur_subdir
195 $this->tpl->addBlockfile(
"ADM_CONTENT",
"adm_content",
"tpl.directory.html",
false);
197 $this->ctrl->setParameter($this,
"cdir", $cur_subdir);
198 $this->tpl->setVariable(
"FORMACTION1", $this->ctrl->getFormAction($this,
"createDirectory"));
199 $this->tpl->setVariable(
"TXT_NEW_DIRECTORY", $this->lng->txt(
"cont_new_dir"));
200 $this->tpl->setVariable(
"TXT_NEW_FILE", $this->lng->txt(
"cont_new_file"));
201 $this->tpl->setVariable(
"CMD_NEW_DIR",
"createDirectory");
202 $this->tpl->setVariable(
"CMD_NEW_FILE",
"uploadFile");
203 $this->tpl->setVariable(
"BTN_NEW_DIR", $this->lng->txt(
"create"));
204 $this->tpl->setVariable(
"BTN_NEW_FILE", $this->lng->txt(
"upload"));
207 $this->tpl->addBlockfile(
"FILE_TABLE",
"files",
"tpl.table.html");
210 $this->tpl->addBlockfile(
"TBL_CONTENT",
"tbl_content",
"tpl.directory_row.html",
false);
214 $obj_str = ($this->call_by_reference) ?
"" :
"&obj_id=".$this->obj_id;
215 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
217 $tbl->setTitle($this->lng->txt(
"cont_files").
" ".$cur_subdir);
236 if (!$this->label_enable)
238 $tbl->setHeaderNames(array(
"",
"", $this->lng->txt(
"cont_dir_file"),
239 $this->lng->txt(
"cont_size")));
240 $this->tpl->setVariable(
"COLUMN_COUNTS", 4);
241 $tbl->setColumnWidth(array(
"1%",
"1%",
"60%",
"40%"));
242 $cols = array(
"",
"",
"dir_file",
"size");
243 $header_params = $this->ctrl->getParameterArray($this,
"listFiles");
248 $tbl->setHeaderVars($cols, $header_params);
252 $tbl->setHeaderNames(array(
"",
"", $this->lng->txt(
"cont_dir_file"),
253 $this->lng->txt(
"cont_size"), $this->label_header));
254 $this->tpl->setVariable(
"COLUMN_COUNTS", 5);
255 $tbl->setColumnWidth(array(
"1%",
"1%",
"50%",
"25%",
"25%"));
256 $cols = array(
"",
"",
"dir_file",
"size",
"label");
257 $header_params = $this->ctrl->getParameterArray($this,
"listFiles");
261 $tbl->setHeaderVars($cols, $header_params);
264 $tbl->setOrderColumn(
$_GET[
"sort_by"]);
265 $tbl->setOrderDirection(
$_GET[
"sort_order"]);
266 $tbl->setLimit(
$_GET[
"limit"]);
267 $tbl->setOffset(
$_GET[
"offset"]);
268 $tbl->setMaxCount($this->maxcount);
272 $this->tpl->setCurrentBlock(
"tbl_action_btn");
273 $this->tpl->setVariable(
"BTN_NAME",
"deleteFile");
274 $this->tpl->setVariable(
"BTN_VALUE", $this->lng->txt(
"delete"));
275 $this->tpl->parseCurrentBlock();
278 $this->tpl->setCurrentBlock(
"tbl_action_btn");
279 $this->tpl->setVariable(
"BTN_NAME",
"unzipFile");
280 $this->tpl->setVariable(
"BTN_VALUE", $this->lng->txt(
"unzip"));
281 $this->tpl->parseCurrentBlock();
284 $this->tpl->setCurrentBlock(
"tbl_action_btn");
285 $this->tpl->setVariable(
"BTN_NAME",
"downloadFile");
286 $this->tpl->setVariable(
"BTN_VALUE", $this->lng->txt(
"download"));
287 $this->tpl->parseCurrentBlock();
290 $this->tpl->setCurrentBlock(
"tbl_action_btn");
291 $this->tpl->setVariable(
"BTN_NAME",
"renameFileForm");
292 $this->tpl->setVariable(
"BTN_VALUE", $this->lng->txt(
"rename"));
293 $this->tpl->parseCurrentBlock();
296 for ($i=0; $i < count($this->commands); $i++)
298 $this->tpl->setCurrentBlock(
"tbl_action_btn");
299 $this->tpl->setVariable(
"BTN_NAME",
"extCommand_".$i);
300 $this->tpl->setVariable(
"BTN_VALUE", $this->commands[$i][
"name"]);
301 $this->tpl->parseCurrentBlock();
306 $tbl->setFooter(
"tblfooter",$this->lng->txt(
"previous"),$this->lng->txt(
"next"));
309 if (is_dir($cur_dir))
315 $entries = array(array(
"type" =>
"dir",
"entry" =>
".."));
319 $tbl->setMaxCount(count($entries));
320 $entries = array_slice($entries,
$_GET[
"offset"],
$_GET[
"limit"]);
323 if(count($entries) > 0)
326 foreach($entries as $entry)
328 if(($entry[
"entry"] ==
".") || ($entry[
"entry"] ==
".." && empty($cur_subdir)))
333 $cfile = (!empty($cur_subdir))
334 ? $cur_subdir.
"/".$entry[
"entry"]
338 if ($this->label_enable)
340 $this->tpl->setCurrentBlock(
"Label");
341 if ($this->file_labels[$cfile] !=
"")
343 $this->tpl->setVariable(
"TXT_LABEL", $this->file_labels[$cfile]);
347 $this->tpl->setVariable(
"TXT_LABEL",
" ");
349 $this->tpl->parseCurrentBlock();
353 if($entry[
"type"] ==
"dir")
355 $this->tpl->setCurrentBlock(
"FileLink");
356 $this->ctrl->setParameter($this,
"cdir", $cur_subdir);
357 $this->ctrl->setParameter($this,
"newdir", $entry[
"entry"]);
358 $this->tpl->setVariable(
"LINK_FILENAME", $this->ctrl->getLinkTarget($this,
"listFiles"));
359 $this->tpl->setVariable(
"TXT_FILENAME", $entry[
"entry"]);
360 $this->tpl->parseCurrentBlock();
362 $this->tpl->setVariable(
"ICON",
"<img src=\"".
367 $this->tpl->setCurrentBlock(
"File");
368 $this->tpl->setVariable(
"TXT_FILENAME2", $entry[
"entry"]);
369 $this->tpl->parseCurrentBlock();
372 $this->tpl->setCurrentBlock(
"tbl_content");
374 $this->tpl->setVariable(
"CSS_ROW", $css_row);
376 $this->tpl->setVariable(
"TXT_SIZE", $entry[
"size"]);
377 $this->tpl->setVariable(
"CHECKBOX_ID", $entry[
"entry"]);
378 $compare = (!empty($cur_subdir))
379 ? $cur_subdir.
"/".$entry[
"entry"]
383 $this->tpl->parseCurrentBlock();
388 $this->tpl->setCurrentBlock(
"notfound");
389 $this->tpl->setVariable(
"TXT_OBJECT_NOT_FOUND", $this->lng->txt(
"obj_not_found"));
390 $this->tpl->setVariable(
"NUM_COLS", 4);
391 $this->tpl->parseCurrentBlock();
394 $this->tpl->parseCurrentBlock();
402 if (!isset($_POST[
"file"]))
404 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
407 if (count($_POST[
"file"]) > 1)
409 $this->ilias->raiseError($this->lng->txt(
"cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
414 $this->ilias->raiseError($this->lng->txt(
"select_a_file"),$this->ilias->error_obj->MESSAGE);
418 $file = (!empty($cur_subdir))
423 $this->tpl->addBlockfile(
"ADM_CONTENT",
"adm_content",
"tpl.file_rename.html",
false);
426 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this,
"renameFile"));
429 $this->tpl->setVariable(
"TXT_HEADER", $this->lng->txt(
"rename_dir"));
433 $this->tpl->setVariable(
"TXT_HEADER", $this->lng->txt(
"rename_file"));
435 $this->tpl->setVariable(
"TXT_NAME", $this->lng->txt(
"name"));
437 $this->tpl->setVariable(
"CMD_CANCEL",
"cancelRename");
438 $this->tpl->setVariable(
"CMD_SUBMIT",
"renameFile");
439 $this->tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
"cancel"));
440 $this->tpl->setVariable(
"TXT_SUBMIT", $this->lng->txt(
"rename"));
442 $this->tpl->parseCurrentBlock();
451 $new_name = str_replace(
"/",
"", $new_name);
454 $this->ilias->raiseError($this->lng->txt(
"enter_new_name"),$this->ilias->error_obj->MESSAGE);
458 $dir = (!empty($cur_subdir))
459 ? $this->main_dir.
"/".$cur_subdir.
"/"
460 : $this->main_dir.
"/";
462 rename(
$dir.ilUtil::stripSlashes(
$_GET[
"old_name"]),
$dir.$new_name);
466 $this->ctrl->redirect($this,
"listFiles");
474 $this->ctrl->redirect($this,
"listFiles");
485 $cur_dir = (!empty($cur_subdir))
486 ? $this->main_dir.
"/".$cur_subdir
490 $new_dir = str_replace(
"/",
"", $new_dir);
492 if (!empty($new_dir))
496 $this->ctrl->saveParameter($this,
"cdir");
497 $this->ctrl->redirect($this,
"listFiles");
507 $cur_dir = (!empty($cur_subdir))
508 ? $this->main_dir.
"/".$cur_subdir
510 if (is_file($_FILES[
"new_file"][
"tmp_name"]))
512 move_uploaded_file($_FILES[
"new_file"][
"tmp_name"],
515 $this->ctrl->saveParameter($this,
"cdir");
519 $this->ctrl->redirect($this,
"listFiles");
528 if (!isset($_POST[
"file"]))
530 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
533 foreach ($_POST[
"file"] as $post_file)
537 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
542 $cur_dir = (!empty($cur_subdir))
543 ? $this->main_dir.
"/".$cur_subdir
558 $this->ctrl->saveParameter($this,
"cdir");
559 $this->ctrl->redirect($this,
"listFiles");
567 if (!isset($_POST[
"file"]))
569 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
572 if (count($_POST[
"file"]) > 1)
574 $this->ilias->raiseError($this->lng->txt(
"cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
578 $cur_dir = (!empty($cur_subdir))
579 ? $this->main_dir.
"/".$cur_subdir
590 $this->ctrl->saveParameter($this,
"cdir");
591 $this->ctrl->redirect($this,
"listFiles");
599 if (!isset($_POST[
"file"]))
601 $this->ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
604 if (count($_POST[
"file"]) > 1)
606 $this->ilias->raiseError($this->lng->txt(
"cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
610 $cur_dir = (!empty($cur_subdir))
611 ? $this->main_dir.
"/".$cur_subdir
613 $file = $cur_dir.
"/".$_POST[
"file"][0];
622 $this->ctrl->saveParameter($this,
"cdir");
623 $this->ctrl->redirect($this,
"listFiles");
633 $tabs_gui->addTarget(
"cont_list_files",
634 $this->ctrl->getLinkTarget($this,
"listFiles"),
"listFiles",