ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjObjectFolderGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 
36 require_once "class.ilObjectGUI.php";
37 
39 {
48  function ilObjObjectFolderGUI($a_data,$a_id,$a_call_by_reference)
49  {
50  $this->type = "objf";
51  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,false);
52  }
53 
59  function viewObject()
60  {
61  global $rbacsystem;
62 
63  if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
64  {
65  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
66  }
67 
68  //prepare objectlist
69  $this->data = array();
70  $this->data["data"] = array();
71  $this->data["ctrl"] = array();
72 
73  $this->data["cols"] = array("type","title","last_change");
74 
75  $this->maxcount = count($this->data["data"]);
76 
77  // now compute control information
78  foreach ($this->data["data"] as $key => $val)
79  {
80  $this->data["ctrl"][$key] = array(
81  "ref_id" => $this->id,
82  "obj_id" => $val["obj_id"],
83  "type" => $val["type"],
84  );
85 
86  unset($this->data["data"][$key]["obj_id"]);
87  $this->data["data"][$key]["last_change"] = ilDatePresentation::formatDate(new ilDateTime($this->data["data"][$key]["last_change"],IL_CAL_DATETIME));
88  }
89 
90  $this->displayList();
91  }
92 
98  function displayList()
99  {
100  include_once "./Services/Table/classes/class.ilTableGUI.php";
101  return;
102 
103  // load template for table
104  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
105 
106  // load template for table content data
107  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
108 
109  $num = 0;
110 
111  $obj_str = ($this->call_by_reference) ? "" : "&obj_id=".$this->obj_id;
112  $this->tpl->setVariable("FORMACTION",
113  $this->ctrl->getFormAction($this));
114 
115  // create table
116  $tbl = new ilTableGUI();
117 
118  // title & header columns
119  $tbl->setTitle($this->object->getTitle(),"icon_".$this->object->getType()."_b.gif",$this->lng->txt("obj_".$this->object->getType()));
120  $tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
121 
122  foreach ($this->data["cols"] as $val)
123  {
124  $header_names[] = $this->lng->txt($val);
125  }
126 
127  $tbl->setHeaderNames($header_names);
128 
129  //$header_params = array("ref_id" => $this->ref_id);
130  $header_params = $this->ctrl->getParameterArray($this, "view");
131  $tbl->setHeaderVars($this->data["cols"],$header_params);
132  $tbl->setColumnWidth(array("15","75%","25%"));
133 
134  // control
135  $tbl->setOrderColumn($_GET["sort_by"]);
136  $tbl->setOrderDirection($_GET["sort_order"]);
137  $tbl->setLimit($_GET["limit"]);
138  $tbl->setOffset($_GET["offset"]);
139  $tbl->setMaxCount($this->maxcount);
140 
141  // footer
142  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
143  //$tbl->disable("footer");
144 
145  // render table
146  $tbl->render();
147 
148  if (is_array($this->data["data"][0]))
149  {
150  //table cell
151  for ($i=0; $i < count($this->data["data"]); $i++)
152  {
153  $data = $this->data["data"][$i];
154  $ctrl = $this->data["ctrl"][$i];
155 
156  // color changing
157  $css_row = ilUtil::switchColor($i+1,"tblrow1","tblrow2");
158 
159  $this->tpl->setCurrentBlock("table_cell");
160  $this->tpl->setVariable("CELLSTYLE", "tblrow1");
161  $this->tpl->parseCurrentBlock();
162 
163  foreach ($data as $key => $val)
164  {
165  //build link
166  /*
167 
168  $n = 0;
169 
170  foreach ($ctrl as $key2 => $val2)
171  {
172  $link .= $key2."=".$val2;
173 
174  if ($n < count($ctrl)-1)
175  {
176  $link .= "&";
177  $n++;
178  }
179  }
180 
181  if ($key == "title")
182  {
183  $name_field = explode("#separator#",$val);
184  }
185 
186  if ($key == "title" || $key == "type")
187  {
188  $this->tpl->setCurrentBlock("begin_link");
189  $this->tpl->setVariable("LINK_TARGET", $link);
190 
191  $this->tpl->parseCurrentBlock();
192  $this->tpl->touchBlock("end_link");
193  }
194 
195  $this->tpl->setCurrentBlock("text");
196 
197  if ($key == "type")
198  {
199  $val = ilUtil::getImageTagByType($val,$this->tpl->tplPath);
200  }
201 
202  if ($key == "title")
203  {
204  $this->tpl->setVariable("TEXT_CONTENT", $name_field[0]);
205 
206  $this->tpl->setCurrentBlock("subtitle");
207  $this->tpl->setVariable("DESC", $name_field[1]);
208  $this->tpl->parseCurrentBlock();
209  }
210  else
211  {
212  $this->tpl->setVariable("TEXT_CONTENT", $val);
213  }
214 
215  $this->tpl->parseCurrentBlock();
216 
217  $this->tpl->setCurrentBlock("table_cell");
218  $this->tpl->parseCurrentBlock();
219  */
220  } //foreach
221 
222  $this->tpl->setCurrentBlock("tbl_content");
223  $this->tpl->setVariable("CSS_ROW", $css_row);
224  $this->tpl->parseCurrentBlock();
225  } //for
226 
227  } //if is_array
228  else
229  {
230  $this->tpl->setCurrentBlock("notfound");
231  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
232  $this->tpl->setVariable("NUM_COLS", $num);
233  $this->tpl->parseCurrentBlock();
234  }
235  }
236 
237  function &executeCommand()
238  {
239  $next_class = $this->ctrl->getNextClass($this);
240  $cmd = $this->ctrl->getCmd();
241  $this->prepareOutput();
242 
243  switch($next_class)
244  {
245  case 'ilpermissiongui':
246  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
247  $perm_gui =& new ilPermissionGUI($this);
248  $ret =& $this->ctrl->forwardCommand($perm_gui);
249  break;
250 
251  default:
252  if(!$cmd)
253  {
254  $cmd = "view";
255  }
256  $cmd .= "Object";
257  $this->$cmd();
258 
259  break;
260  }
261  return true;
262  }
263 
269  function getTabs(&$tabs_gui)
270  {
271  global $rbacsystem;
272 
273  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
274  {
275  $tabs_gui->addTarget("settings",
276  $this->ctrl->getLinkTarget($this, "view"), array("view",""), "", "");
277 
278  $tabs_gui->addTarget("perm_settings",
279  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
280  }
281  }
282 } // END class.ilObjObjectFolderGUI
283 ?>