ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilWorkspaceFolderExplorer.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 /*
25 * Explorer View for Workspace Folders
26 *
27 * @author Jörg Lützenkirchen <luetzenkirchen@leifos.com>
28 * @version $Id: class.ilBookmarkExplorer.php 23354 2010-03-24 13:25:09Z akill $
29 *
30 */
31 
32 include_once("./Services/UIComponent/Explorer/classes/class.ilExplorer.php");
33 include_once("Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php");
34 
36 {
40  protected $ctrl;
41 
47  public $user_id;
48 
54  public $root_id;
55 
62 
69  public function __construct($a_target, $a_user_id)
70  {
71  global $DIC;
72 
73  $this->lng = $DIC->language();
74  $this->ctrl = $DIC->ctrl();
75  $this->tpl = $DIC["tpl"];
76  parent::__construct($a_target);
77  $this->tree = new ilWorkspaceTree($a_user_id);
78  $this->root_id = $this->tree->readRootId();
79  $this->user_id = $a_user_id;
80  $this->allowed_types= array('wfld', 'wsrt');
81  $this->enablesmallmode = false;
82  }
83 
89  public function setEnableSmallMode($a_enablesmallmode)
90  {
91  $this->enablesmallmode = $a_enablesmallmode;
92  }
93 
99  public function getEnableSmallMode()
100  {
101  return $this->enablesmallmode;
102  }
103 
104 
113  public function setOutput($a_parent, $a_depth = 1, $a_obj_id = 0, $a_highlighted_subtree = false)
114  {
115  $lng = $this->lng;
116  static $counter = 0;
117 
118  if ($objects = $this->tree->getChilds($a_parent, "type DESC,title")) {
119  $tab = ++$a_depth - 2;
120 
121  foreach ($objects as $key => $object) {
122  if (!in_array($object["type"], $this->allowed_types)) {
123  continue;
124  }
125 
126  //ask for FILTER
127  if ($object["child"] != $this->root_id) {
128  //$data = $this->tree->getParentNodeData($object["child"]);
129  $parent_index = $this->getIndex($object);
130  }
131 
132  $this->format_options["$counter"]["parent"] = $object["parent"];
133  $this->format_options["$counter"]["child"] = $object["child"];
134  $this->format_options["$counter"]["title"] = $object["title"];
135  $this->format_options["$counter"]["description"] = $object["description"];
136  $this->format_options["$counter"]["type"] = $object["type"];
137  $this->format_options["$counter"]["depth"] = $tab;
138  $this->format_options["$counter"]["container"] = false;
139  $this->format_options["$counter"]["visible"] = true;
140 
141  // Create prefix array
142  for ($i = 0; $i < $tab; ++$i) {
143  $this->format_options["$counter"]["tab"][] = 'blank';
144  }
145  // only if parent is expanded and visible, object is visible
146  if ($object["child"] != $this->root_id and (!in_array($object["parent"], $this->expanded)
147  or !$this->format_options["$parent_index"]["visible"])) {
148  $this->format_options["$counter"]["visible"] = false;
149  }
150 
151  // if object exists parent is container
152  if ($object["child"] != $this->root_id) {
153  $this->format_options["$parent_index"]["container"] = true;
154 
155  if (in_array($object["parent"], $this->expanded)) {
156  $this->format_options["$parent_index"]["tab"][($tab-2)] = 'minus';
157  } else {
158  $this->format_options["$parent_index"]["tab"][($tab-2)] = 'plus';
159  }
160  }
161 
162  ++$counter;
163 
164  // Recursive
165  $this->setOutput($object["child"], $a_depth);
166  } //foreach
167  } //if
168  } //function
169 
177  public function formatHeader($tpl, $a_obj_id, $a_option)
178  {
179  $lng = $this->lng;
181 
182  $title = $lng->txt("wsp_personal_workspace");
183 
184  $tpl->setCurrentBlock("icon");
185  $tpl->setVariable("ICON_IMAGE", ilUtil::getImagePath("icon_wsrt.svg"));
186  $tpl->setVariable("TXT_ALT_IMG", $title);
187  $tpl->parseCurrentBlock();
188 
189  $tpl->setCurrentBlock("link");
190  $tpl->setVariable("LINK_TARGET", $this->buildLinkTarget($this->root_id, "wsrt"));
191  $tpl->setVariable("TITLE", $title);
192 
193  // highlighting
194  $style_class = $this->getNodeStyleClass($this->root_id, "wsrt");
195  if ($style_class != "") {
196  $tpl->setVariable("A_CLASS", ' class="' . $style_class . '" ');
197  }
198 
199  $tpl->parseCurrentBlock();
200  }
201 
208  public function setExpand($a_node_id)
209  {
210  if ($a_node_id == "") {
211  $a_node_id = $this->root_id;
212  }
213 
214  // IF ISN'T SET CREATE SESSION VARIABLE
215  if (!is_array($_SESSION[$this->expand_variable])) {
217  }
218  // IF $_GET["expand"] is positive => expand this node
219  if ($a_node_id > 0 && !in_array($a_node_id, $_SESSION[$this->expand_variable])) {
220  array_push($_SESSION[$this->expand_variable], $a_node_id);
221  }
222  // IF $_GET["expand"] is negative => compress this node
223  if ($a_node_id < 0) {
224  $key = array_keys($_SESSION[$this->expand_variable], -(int) $a_node_id);
225  unset($_SESSION[$this->expand_variable][$key[0]]);
226  }
227  $this->expanded = $_SESSION[$this->expand_variable];
228  }
233  public function buildLinkTarget($a_node_id, $a_type)
234  {
236 
237  switch ($a_type) {
238  case "wsrt":
239  $ilCtrl->setParameterByClass("ilobjworkspacerootfoldergui", "wsp_id", $a_node_id);
240  return $ilCtrl->getLinkTargetByClass("ilobjworkspacerootfoldergui", "");
241 
242  case "wfld":
243  $ilCtrl->setParameterByClass("ilobjworkspacefoldergui", "wsp_id", $a_node_id);
244  return $ilCtrl->getLinkTargetByClass("ilobjworkspacefoldergui", "");
245 
246  default:
247  return;
248  }
249  }
254  public function buildFrameTarget($a_type, $a_child = 0, $a_obj_id = 0)
255  {
256  return '';
257  }
258 
264  public function setAllowedTypes($a_types)
265  {
266  $this->allowed_types = $a_types;
267  }
273  public function setShowDetails($s_details)
274  {
275  $this->show_details = $s_details;
276  }
277 
282  public function buildDescription($a_desc, $a_id, $a_type)
283  {
284  if ($this->show_details=='y' && !empty($a_desc)) {
285  return $a_desc;
286  } else {
287  return "";
288  }
289  }
290 
291  public function getImageAlt($a_def, $a_type = "", $a_obj_id = "")
292  {
293  $lng = $this->lng;
294 
295  return $lng->txt("icon") . " " . $lng->txt($a_type);
296  }
297 
298  public function hasFolders($a_node_id)
299  {
300  return sizeof($this->tree->getChildsByType($a_node_id, "wfld"));
301  }
302 
303  public function getParentNode($a_node_id)
304  {
305  return $this->tree->getParentId($a_node_id);
306  }
307 
308  public function getOutput()
309  {
310  $tpl = $this->tpl;
311 
312  $html = parent::getOutput();
313  $tpl->setBodyClass("std");
314  return $html;
315  }
316 }
getNodeStyleClass($a_id, $a_type)
get style class for node
$_SESSION["AccountId"]
global $DIC
Definition: saml.php:7
getEnableSmallMode()
Get Enable Small Mode.
buildFrameTarget($a_type, $a_child=0, $a_obj_id=0)
overwritten method from base class buid link target
getIndex($a_data)
get index of format_options array from specific ref_id,parent_id private
Tree handler for personal workspace.
global $ilCtrl
Definition: ilias.php:18
$counter
$a_type
Definition: workflow.php:92
setOutput($a_parent, $a_depth=1, $a_obj_id=0, $a_highlighted_subtree=false)
Overwritten method from class.Explorer.php to avoid checkAccess selects recursive method public...
formatHeader($tpl, $a_obj_id, $a_option)
overwritten method from base class public
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
setAllowedTypes($a_types)
set the alowed object types private
setExpand($a_node_id)
set the expand option this value is stored in a SESSION variable to save it different view (lo view...
buildDescription($a_desc, $a_id, $a_type)
overwritten method from base class buid decription
setShowDetails($s_details)
set details mode public
getImageAlt($a_def, $a_type="", $a_obj_id="")
Create styles array
The data for the language used.
Class ilExplorer class for explorer view in admin frame.
$i
Definition: disco.tpl.php:19
setEnableSmallMode($a_enablesmallmode)
Set Enable Small Mode.
buildLinkTarget($a_node_id, $a_type)
overwritten method from base class get link target
__construct($a_target, $a_user_id)
Constructor public.
$key
Definition: croninfo.php:18
$html
Definition: example_001.php:87