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