ILIAS  Release_5_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  $a_post_dir_path = false, $a_table_id = "")
24  {
25  global $ilCtrl, $lng, $ilAccess, $lng;
26 
27  $this->setId($a_table_id);
28  $this->cur_dir = $a_cur_dir;
29  $this->cur_subdir = $a_cur_subdir;
30  $this->label_enable = $a_label_enable;
31  $this->label_header = $a_label_header;
32  $this->file_labels = $a_file_labels;
33  $this->post_dir_path = $a_post_dir_path;
34 
35  parent::__construct($a_parent_obj, $a_parent_cmd);
36  $this->setTitle($lng->txt("cont_files")." ".$this->cur_subdir);
37  $this->setSelectAllCheckbox("file[]");
38 
39  $this->addColumn("", "", "1", true);
40  $this->addColumn("", "", "1");
41  if ($this->label_enable)
42  {
43  $this->addColumn($lng->txt("cont_dir_file"), "name", "50%");
44  $this->addColumn($lng->txt("cont_size"), "size", "20%");
45  $this->addColumn($this->label_header, "", "30%");
46  }
47  else
48  {
49  $this->addColumn($lng->txt("cont_dir_file"), "name", "60%");
50  $this->addColumn($lng->txt("cont_size"), "size", "40%");
51  }
52 
53  $this->setDefaultOrderField("name");
54  $this->setDefaultOrderDirection("asc");
55 
56  $this->setEnableHeader(true);
57  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
58  $this->setRowTemplate("tpl.directory_row.html",
59  "Services/FileSystem");
60  $this->setEnableTitle(true);
61 
62  //$this->addMultiCommand("downloadFile", $lng->txt("download"));
63  //$this->addMultiCommand("confirmDeleteFile", $lng->txt("delete"));
64  //$this->addMultiCommand("unzipFile", $lng->txt("unzip"));
65  //$this->addMultiCommand("renameFileForm", $lng->txt("rename"));
66  for ($i=0; $i < count($a_commands); $i++)
67  {
68  if ($a_commands["int"])
69  {
70  $this->addMultiCommand($a_commands[$i]["method"],
71  $a_commands[$i]["name"]);
72  }
73  else
74  {
75  $this->addMultiCommand("extCommand_".$i, $a_commands[$i]["name"]);
76  }
77  }
78  }
79 
80  function numericOrdering($a_field)
81  {
82  if ($a_field == "size")
83  {
84  return true;
85  }
86  return false;
87  }
88 
92  function prepareOutput()
93  {
94  $this->determineOffsetAndOrder(true);
95  $this->getEntries();
96  }
97 
98 
102  function getEntries()
103  {
104  if (is_dir($this->cur_dir))
105  {
106  $entries = ilUtil::getDir($this->cur_dir);
107  }
108  else
109  {
110  $entries = array(array("type" => "dir", "entry" => ".."));
111  }
112  $items = array();
113 //var_dump($entries);
114  foreach ($entries as $e)
115  {
116  if(($e["entry"] == ".") || ($e["entry"] == ".." && empty($this->cur_subdir)))
117  {
118  continue;
119  }
120  $cfile = (!empty($this->cur_subdir))
121  ? $this->cur_subdir."/".$e["entry"]
122  : $e["entry"];
123 
124  if ($this->label_enable)
125  {
126  $label = (is_array($this->file_labels[$cfile]))
127  ? implode($this->file_labels[$cfile], ", ")
128  : "";
129  }
130 
131  $pref = ($e["type"] == "dir")
132  ? ( $this->getOrderDirection() != "desc" ? "1_" : "9_")
133  : "5_";
134  $items[] = array("file" => $cfile, "entry" => $e["entry"],
135  "type" => $e["type"], "label" => $label, "size" => $e["size"],
136  "name" => $pref.$e["entry"]);
137  }
138 
139  $this->setData($items);
140  }
141 
142 
146  protected function fillRow($a_set)
147  {
148  global $ilCtrl;
149 
150  if ($a_set["entry"] != "..")
151  {
152  if ($this->post_dir_path)
153  {
154  $this->tpl->setVariable("CHECKBOX_ID", $a_set["file"]);
155  }
156  else
157  {
158  $this->tpl->setVariable("CHECKBOX_ID", $a_set["entry"]);
159  }
160  }
161 
162  // label
163  if ($this->label_enable)
164  {
165  $this->tpl->setCurrentBlock("Label");
166  $this->tpl->setVariable("TXT_LABEL", $a_set["label"]);
167  $this->tpl->parseCurrentBlock();
168  }
169 
170  //$this->tpl->setVariable("ICON", $obj["title"]);
171  if($a_set["type"] == "dir")
172  {
173  $this->tpl->setCurrentBlock("FileLink");
174  $ilCtrl->setParameter($this->parent_obj, "cdir", $this->cur_subdir);
175  $ilCtrl->setParameter($this->parent_obj, "newdir", $a_set["entry"]);
176  $ilCtrl->setParameter($this->parent_obj, "resetoffset", 1);
177  $this->tpl->setVariable("LINK_FILENAME",
178  $ilCtrl->getLinkTarget($this->parent_obj, "listFiles"));
179  $this->tpl->setVariable("TXT_FILENAME", $a_set["entry"]);
180  $this->tpl->parseCurrentBlock();
181 
182  $this->tpl->setVariable("ICON", "<img src=\"".
183  ilUtil::getImagePath("icon_cat.svg")."\">");
184  $ilCtrl->setParameter($this->parent_obj, "resetoffset", "");
185  }
186  else
187  {
188  $this->tpl->setCurrentBlock("File");
189  $this->tpl->setVariable("TXT_FILENAME2", $a_set["entry"]);
190  $this->tpl->parseCurrentBlock();
191  }
192 
193  $this->tpl->setVariable("TXT_SIZE", $a_set["size"]);
194 
195  $ilCtrl->setParameter($this->parent_obj, "cdir", $_GET["cdir"]);
196  $ilCtrl->setParameter($this->parent_obj, "newdir", $_GET["newdir"]);
197  }
198 
199 }
200 ?>