ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilFileSystemTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Table/classes/class.ilTable2GUI.php");
5 
15 {
16 
20  function __construct($a_parent_obj, $a_parent_cmd, $a_cur_dir,
21  $a_cur_subdir, $a_label_enable = false,
22  $a_file_labels, $a_label_header = "", $a_commands = array())
23  {
24  global $ilCtrl, $lng, $ilAccess, $lng;
25 
26  $this->cur_dir = $a_cur_dir;
27  $this->cur_subdir = $a_cur_subdir;
28  $this->label_enable = $a_label_enable;
29  $this->label_header = $a_label_header;
30  $this->file_labels = $a_file_labels;
31 
32  parent::__construct($a_parent_obj, $a_parent_cmd);
33  $this->setTitle($lng->txt("cont_files")." ".$this->cur_subdir);
34  $this->setSelectAllCheckbox("file[]");
35 
36  $this->addColumn("", "", "1", true);
37  $this->addColumn("", "", "1");
38  if ($this->label_enable)
39  {
40  $this->addColumn($lng->txt("cont_dir_file"), "name", "50%");
41  $this->addColumn($lng->txt("cont_size"), "size", "20%");
42  $this->addColumn($this->label_header, "", "30%");
43  }
44  else
45  {
46  $this->addColumn($lng->txt("cont_dir_file"), "name", "60%");
47  $this->addColumn($lng->txt("cont_size"), "size", "40%");
48  }
49 
50  $this->setDefaultOrderField("name");
51  $this->setDefaultOrderDirection("asc");
52 
53  $this->setEnableHeader(true);
54  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
55  $this->setRowTemplate("tpl.directory_row.html");
56  $this->setEnableTitle(true);
57 
58  $this->addMultiCommand("deleteFile", $lng->txt("delete"));
59  $this->addMultiCommand("unzipFile", $lng->txt("unzip"));
60  $this->addMultiCommand("downloadFile", $lng->txt("download"));
61  $this->addMultiCommand("renameFileForm", $lng->txt("rename"));
62  for ($i=0; $i < count($a_commands); $i++)
63  {
64  $this->addMultiCommand("extCommand_".$i, $a_commands[$i]["name"]);
65  }
66  }
67 
68  function numericOrdering($a_field)
69  {
70  if ($a_field == "size")
71  {
72  return true;
73  }
74  return false;
75  }
76 
80  function prepareOutput()
81  {
82  $this->determineOffsetAndOrder(true);
83  $this->getEntries();
84  }
85 
86 
90  function getEntries()
91  {
92  if (is_dir($this->cur_dir))
93  {
94  $entries = ilUtil::getDir($this->cur_dir);
95  }
96  else
97  {
98  $entries = array(array("type" => "dir", "entry" => ".."));
99  }
100  $items = array();
101 //var_dump($entries);
102  foreach ($entries as $e)
103  {
104  if(($e["entry"] == ".") || ($e["entry"] == ".." && empty($this->cur_subdir)))
105  {
106  continue;
107  }
108  $cfile = (!empty($this->cur_subdir))
109  ? $this->cur_subdir."/".$e["entry"]
110  : $e["entry"];
111 
112  if ($this->label_enable)
113  {
114  $label = (is_array($this->file_labels[$cfile]))
115  ? implode($this->file_labels[$cfile], ", ")
116  : "";
117  }
118 
119  $pref = ($e["type"] == "dir")
120  ? ( $this->getOrderDirection() != "desc" ? "1_" : "9_")
121  : "5_";
122  $items[] = array("file" => $cfile, "entry" => $e["entry"],
123  "type" => $e["type"], "label" => $label, "size" => $e["size"],
124  "name" => $pref.$e["entry"]);
125  }
126 
127  $this->setData($items);
128  }
129 
130 
134  protected function fillRow($a_set)
135  {
136  global $ilCtrl;
137 
138  // label
139  if ($this->label_enable)
140  {
141  $this->tpl->setCurrentBlock("Label");
142  $this->tpl->setVariable("TXT_LABEL", $a_set["label"]);
143  $this->tpl->parseCurrentBlock();
144  }
145 
146  //$this->tpl->setVariable("ICON", $obj["title"]);
147  if($a_set["type"] == "dir")
148  {
149  $this->tpl->setCurrentBlock("FileLink");
150  $ilCtrl->setParameter($this->parent_obj, "cdir", $this->cur_subdir);
151  $ilCtrl->setParameter($this->parent_obj, "newdir", $a_set["entry"]);
152  $ilCtrl->setParameter($this->parent_obj, "resetoffset", 1);
153  $this->tpl->setVariable("LINK_FILENAME",
154  $ilCtrl->getLinkTarget($this->parent_obj, "listFiles"));
155  $this->tpl->setVariable("TXT_FILENAME", $a_set["entry"]);
156  $this->tpl->parseCurrentBlock();
157 
158  $this->tpl->setVariable("ICON", "<img src=\"".
159  ilUtil::getImagePath("icon_cat.gif")."\">");
160  $ilCtrl->setParameter($this->parent_obj, "resetoffset", "");
161  }
162  else
163  {
164  $this->tpl->setCurrentBlock("File");
165  $this->tpl->setVariable("TXT_FILENAME2", $a_set["entry"]);
166  $this->tpl->parseCurrentBlock();
167  }
168 
169  $this->tpl->setVariable("TXT_SIZE", $a_set["size"]);
170  $this->tpl->setVariable("CHECKBOX_ID", $a_set["entry"]);
171 
172  $ilCtrl->setParameter($this->parent_obj, "cdir", $_GET["cdir"]);
173  $ilCtrl->setParameter($this->parent_obj, "newdir", $_GET["newdir"]);
174  }
175 
176 }
177 ?>