ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilWorkspaceFolderExplorer.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
11{
15 protected $ctrl;
16
22 public $user_id;
23
29 public $root_id;
30
37
44 public function __construct($a_target, $a_user_id)
45 {
46 global $DIC;
47
48 $this->lng = $DIC->language();
49 $this->ctrl = $DIC->ctrl();
50 $this->tpl = $DIC["tpl"];
51 parent::__construct($a_target);
52 $this->tree = new ilWorkspaceTree($a_user_id);
53 $this->root_id = $this->tree->readRootId();
54 $this->user_id = $a_user_id;
55 $this->allowed_types = array('wfld', 'wsrt');
56 $this->enablesmallmode = false;
57 }
58
64 public function setEnableSmallMode($a_enablesmallmode)
65 {
66 $this->enablesmallmode = $a_enablesmallmode;
67 }
68
74 public function getEnableSmallMode()
75 {
76 return $this->enablesmallmode;
77 }
78
79
88 public function setOutput($a_parent, $a_depth = 1, $a_obj_id = 0, $a_highlighted_subtree = false)
89 {
91 static $counter = 0;
92
93 if ($objects = $this->tree->getChilds($a_parent, "type DESC,title")) {
94 $tab = ++$a_depth - 2;
95
96 foreach ($objects as $key => $object) {
97 if (!in_array($object["type"], $this->allowed_types)) {
98 continue;
99 }
100
101 //ask for FILTER
102 if ($object["child"] != $this->root_id) {
103 //$data = $this->tree->getParentNodeData($object["child"]);
104 $parent_index = $this->getIndex($object);
105 }
106
107 $this->format_options["$counter"]["parent"] = $object["parent"];
108 $this->format_options["$counter"]["child"] = $object["child"];
109 $this->format_options["$counter"]["title"] = $object["title"];
110 $this->format_options["$counter"]["description"] = $object["description"];
111 $this->format_options["$counter"]["type"] = $object["type"];
112 $this->format_options["$counter"]["depth"] = $tab;
113 $this->format_options["$counter"]["container"] = false;
114 $this->format_options["$counter"]["visible"] = true;
115
116 // Create prefix array
117 for ($i = 0; $i < $tab; ++$i) {
118 $this->format_options["$counter"]["tab"][] = 'blank';
119 }
120 // only if parent is expanded and visible, object is visible
121 if ($object["child"] != $this->root_id and (!in_array($object["parent"], $this->expanded)
122 or !$this->format_options["$parent_index"]["visible"])) {
123 $this->format_options["$counter"]["visible"] = false;
124 }
125
126 // if object exists parent is container
127 if ($object["child"] != $this->root_id) {
128 $this->format_options["$parent_index"]["container"] = true;
129
130 if (in_array($object["parent"], $this->expanded)) {
131 $this->format_options["$parent_index"]["tab"][($tab - 2)] = 'minus';
132 } else {
133 $this->format_options["$parent_index"]["tab"][($tab - 2)] = 'plus';
134 }
135 }
136
137 ++$counter;
138
139 // Recursive
140 $this->setOutput($object["child"], $a_depth);
141 } //foreach
142 } //if
143 } //function
144
152 public function formatHeader($tpl, $a_obj_id, $a_option)
153 {
156
157 $title = $lng->txt("personal_resources");
158
159 $tpl->setCurrentBlock("icon");
160 $tpl->setVariable("ICON_IMAGE", ilUtil::getImagePath("icon_wsrt.svg"));
161 $tpl->setVariable("TXT_ALT_IMG", $title);
162 $tpl->parseCurrentBlock();
163
164 $tpl->setCurrentBlock("link");
165 $tpl->setVariable("LINK_TARGET", $this->buildLinkTarget($this->root_id, "wsrt"));
166 $tpl->setVariable("TITLE", $title);
167
168 // highlighting
169 $style_class = $this->getNodeStyleClass($this->root_id, "wsrt");
170 if ($style_class != "") {
171 $tpl->setVariable("A_CLASS", ' class="' . $style_class . '" ');
172 }
173
174 $tpl->parseCurrentBlock();
175 }
176
183 public function setExpand($a_node_id)
184 {
185 if ($a_node_id == "") {
186 $a_node_id = $this->root_id;
187 }
188
189 // IF ISN'T SET CREATE SESSION VARIABLE
190 if (!is_array($_SESSION[$this->expand_variable])) {
192 }
193 // IF $_GET["expand"] is positive => expand this node
194 if ($a_node_id > 0 && !in_array($a_node_id, $_SESSION[$this->expand_variable])) {
195 array_push($_SESSION[$this->expand_variable], $a_node_id);
196 }
197 // IF $_GET["expand"] is negative => compress this node
198 if ($a_node_id < 0) {
199 $key = array_keys($_SESSION[$this->expand_variable], -(int) $a_node_id);
200 unset($_SESSION[$this->expand_variable][$key[0]]);
201 }
202 $this->expanded = $_SESSION[$this->expand_variable];
203 }
208 public function buildLinkTarget($a_node_id, $a_type)
209 {
211
212 switch ($a_type) {
213 case "wsrt":
214 $ilCtrl->setParameterByClass("ilobjworkspacerootfoldergui", "wsp_id", $a_node_id);
215 return $ilCtrl->getLinkTargetByClass("ilobjworkspacerootfoldergui", "");
216
217 case "wfld":
218 $ilCtrl->setParameterByClass("ilobjworkspacefoldergui", "wsp_id", $a_node_id);
219 return $ilCtrl->getLinkTargetByClass("ilobjworkspacefoldergui", "");
220
221 default:
222 return;
223 }
224 }
229 public function buildFrameTarget($a_type, $a_child = 0, $a_obj_id = 0)
230 {
231 return '';
232 }
233
239 public function setAllowedTypes($a_types)
240 {
241 $this->allowed_types = $a_types;
242 }
248 public function setShowDetails($s_details)
249 {
250 $this->show_details = $s_details;
251 }
252
257 public function buildDescription($a_desc, $a_id, $a_type)
258 {
259 if ($this->show_details == 'y' && !empty($a_desc)) {
260 return $a_desc;
261 } else {
262 return "";
263 }
264 }
265
266 public function getImageAlt($a_def, $a_type = "", $a_obj_id = "")
267 {
269
270 return $lng->txt("icon") . " " . $lng->txt($a_type);
271 }
272
273 public function hasFolders($a_node_id)
274 {
275 return sizeof($this->tree->getChildsByType($a_node_id, "wfld"));
276 }
277
278 public function getParentNode($a_node_id)
279 {
280 return $this->tree->getParentId($a_node_id);
281 }
282
283 public function getOutput()
284 {
286
287 $html = parent::getOutput();
288 $tpl->setBodyClass("std");
289 return $html;
290 }
291}
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
Class ilExplorer class for explorer view in admin frame.
getNodeStyleClass($a_id, $a_type)
get style class for node
getIndex($a_data)
get index of format_options array from specific ref_id,parent_id @access private
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
Explorer View for Workspace Folders.
getOutput()
Creates output recursive method @access public.
buildFrameTarget($a_type, $a_child=0, $a_obj_id=0)
overwritten method from base class buid link target
setAllowedTypes($a_types)
set the alowed object types @access private
setExpand($a_node_id)
set the expand option this value is stored in a SESSION variable to save it different view (lo view,...
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 @access publ...
buildLinkTarget($a_node_id, $a_type)
overwritten method from base class get link target
formatHeader($tpl, $a_obj_id, $a_option)
overwritten method from base class @access public
__construct($a_target, $a_user_id)
Constructor @access public.
getImageAlt($a_def, $a_type="", $a_obj_id="")
get image alt text
setShowDetails($s_details)
set details mode @access public
buildDescription($a_desc, $a_id, $a_type)
overwritten method from base class buid decription
setEnableSmallMode($a_enablesmallmode)
Set Enable Small Mode.
Tree handler for personal workspace.
global $ilCtrl
Definition: ilias.php:18
$i
Definition: metadata.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$a_type
Definition: workflow.php:92
$DIC
Definition: xapitoken.php:46