ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilAICCExplorer.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
32require_once("./Services/UIComponent/Explorer/classes/class.ilExplorer.php");
33require_once("./Modules/ScormAicc/classes/AICC/class.ilAICCTree.php");
34require_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMExplorer.php");
35
37{
38
45 function __construct($a_target, &$a_slm_obj)
46 {
47 parent::__construct($a_target);
48 $this->slm_obj = $a_slm_obj;
49 $this->tree = new ilAICCTree($a_slm_obj->getId());
50 $this->root_id = $this->tree->readRootId();
51 $this->checkPermissions(false);
52 $this->outputIcons(false);
53 $this->setOrderColumn("");
54 }
55
56 function getItem($a_node_id) {
57 return new ilAICCUnit($a_node_id);
58 }
59
61 return "scorm/";
62 }
63
64 function getNodesToSkip() {
65 return 1;
66 }
67
68 function isClickable($a_type, $a_id = 0)
69 {
70 if ($a_type=="sbl") {
71 $block_object = new ilAICCBlock($a_id);
72 return (strlen($block_object->getDescription())>0);
73 }
74
75 if ($a_type != "sau")
76 {
77 return false;
78 }
79 else
80 {
81 $sc_object = new ilAICCUnit($a_id);
82 return true;
83 }
84 return false;
85 }
86
87 function formatItemTable(&$tpl, $a_id, $a_type)
88 {
89 global $lng;
90 }
91
92
93
102 function formatObject($a_node_id,$a_option)
103 {
104 global $lng;
105
106 if (!isset($a_node_id) or !is_array($a_option))
107 {
108 $this->ilias->raiseError(get_class($this)."::formatObject(): Missing parameter or wrong datatype! ".
109 "node_id: ".$a_node_id." options:".var_dump($a_option),$this->ilias->error_obj->WARNING);
110 }
111
112 $tpl = new ilTemplate("tpl.sahs_tree.html", true, true, "Modules/ScormAicc");
113
114 if ($a_option["c_type"]=="sos")
115 return;
116
117 if ($a_option["c_type"]=="srs")
118 return;
119
120 if (is_array($a_option["tab"])) { //test if there are any tabs
121 foreach ($a_option["tab"] as $picture)
122 {
123 $pic = false;
124 if ($picture == 'plus')
125 {
126 $target = $this->createTarget('+',$a_node_id);
127 $tpl->setCurrentBlock("expander");
128 $tpl->setVariable("LINK_TARGET_EXPANDER", $target);
129 $tpl->setVariable("IMGPATH", ilUtil::getImagePath("browser/plus.png"));
130 $tpl->parseCurrentBlock();
131 $pic = true;
132 }
133
134 if ($picture == 'minus' && $this->show_minus)
135 {
136 $target = $this->createTarget('-',$a_node_id);
137 $tpl->setCurrentBlock("expander");
138 $tpl->setVariable("LINK_TARGET_EXPANDER", $target);
139 $tpl->setVariable("IMGPATH", ilUtil::getImagePath("browser/minus.png"));
140 $tpl->parseCurrentBlock();
141 $pic = true;
142 }
143
144 if (!$pic)
145 {
146 $picture = 'blank';
147 $tpl->setCurrentBlock("lines");
148 $tpl->setVariable("IMGPATH_LINES", ilUtil::getImagePath("browser/".$picture.".png"));
149 $tpl->parseCurrentBlock();
150 }
151 }
152 }
153
154 if ($this->output_icons) {
155 if ($this->isClickable($a_option["c_type"], $a_node_id) && !$a_option["c_type"]=="sbl")
156 $this->getOutputIcons($tpl, $a_option, $a_node_id);
157 }
158
159 if ($this->isClickable($a_option["c_type"], $a_node_id)) // output link
160 {
161 $tpl->setCurrentBlock("link");
162
163 $frame_target = $this->buildFrameTarget($a_option["c_type"], $a_node_id, $a_option["obj_id"]);
164 if ($frame_target != "")
165 {
166 if ($a_option["c_type"]=="sbl") {
167 $tpl->setVariable("TITLE", ilUtil::shortenText($a_option["title"]." ($a_node_id)", $this->textwidth, true));
168 $tpl->setVariable("TARGET", " target=\"".$frame_target."\"");
169 $tpl->setVariable("LINK_TARGET", $this->buildLinkTarget($a_node_id, $a_option["c_type"]));
170 } else {
171 $tpl->setVariable("TITLE", ilUtil::shortenText($a_option["title"]." ($a_node_id)", $this->textwidth, true));
172 $tpl->setVariable("LINK_TARGET", "javascript:void(0);");
173 $tpl->setVariable("ONCLICK", " onclick=\"parent.APIFRAME.setupApi();parent.APIFRAME.API.IliasLaunchSahs('".$a_node_id."');return false;\"");
174 }
175 }
176 $tpl->parseCurrentBlock();
177 }
178 else // output text only
179 {
180 $tpl->setCurrentBlock("text");
181 $tpl->setVariable("OBJ_TITLE", ilUtil::shortenText($a_option["title"], $this->textwidth, true));
182 $tpl->parseCurrentBlock();
183 }
184 $this->formatItemTable($tpl, $a_node_id, $a_option["c_type"]);
185
186 $tpl->setCurrentBlock("row");
187 $tpl->parseCurrentBlock();
188
189 $this->output[] = $tpl->get();
190 }
191
192 function setOutput($a_parent_id, $a_depth = 0)
193 {
194 global $rbacadmin, $rbacsystem;
195 static $counter = 0;
196
197 if (!isset($a_parent_id))
198 {
199 $this->ilias->raiseError(get_class($this)."::setOutput(): No node_id given!",$this->ilias->error_obj->WARNING);
200 }
201 if ($this->showChilds($a_parent_id))
202 {
203 $objects = $this->tree->getChilds($a_parent_id, $this->order_column);
204 }
205 else
206 {
207 $objects = array();
208 }
209 if (count($objects) > 0)
210 {
211
212 //moved the scorm-only constant parameter to a function
213 //to be able to reuse the code
214 //$tab = ++$a_depth - 2;
215 $tab = ++$a_depth - $this->getNodesToSkip();
216
217 foreach ($objects as $key => $object) {
218 //ask for FILTER
219 if ($this->filtered == false or $this->checkFilter($object["c_type"]) == false) {
220 if ($this->isVisible($object["obj_id"], $object["c_type"])) {
221 $this->addObjectToOutputArray($counter, $tab, $object);
222
223 $this->createPrefixArray($counter, $tab);
224
225 $this->makeObjectNodeExpandable($object["c_type"], $object["obj_id"]);
226
227 $parent_index = $this->getParentIndex($object["child"]);
228
229 if ($parent_index == 0) {
230 $this->setParentExpanded($object["parent"]);
231 }
232
233 $this->format_options["$counter"]["visible"] = !$this->shouldHideCurrentNode($object["child"], $parent_index, $object["parent"]);
234
235 // if object exists parent is container
236 if ($object["child"] != $this->tree->getRootId()) {
237 $this->format_options["$parent_index"]["container"] = true;
238
239 if ($this->expand_all or in_array($object["parent"],$this->expanded)) {
240 $this->format_options["$parent_index"]["tab"][($tab-2)] = 'minus';
241 } else {
242 $this->format_options["$parent_index"]["tab"][($tab-2)] = 'plus';
243 }
244 }
245 ++$counter;
246 // stop recursion if 2. level beyond expanded nodes is reached
247 if ($this->expand_all or in_array($object["parent"],$this->expanded) or ($object["parent"] == 0)) {
248 // recursive
249 $this->setOutput($object["child"],$a_depth);
250 }
251 } //if
252 } //if FILTER
253 } //foreach
254 } //if
255 } //function
256
257 protected function createPrefixArray($counter, $tab) {
258 for ($i = 0; $i < $tab; ++$i) {
259 $this->format_options["$counter"]["tab"][] = 'blank';
260 }
261 }
262
263 protected function addObjectToOutputArray($counter, $tab, $object) {
264 $this->format_options["$counter"]["parent"] = $object["parent"];
265 $this->format_options["$counter"]["child"] = $object["child"];
266 $this->format_options["$counter"]["title"] = $object["title"];
267 $this->format_options["$counter"]["c_type"] = $object["c_type"];
268 $this->format_options["$counter"]["obj_id"] = $object["obj_id"];
269 $this->format_options["$counter"]["desc"] = "obj_".$object["c_type"];
270 $this->format_options["$counter"]["depth"] = $tab;
271 $this->format_options["$counter"]["container"] = false;
272 $this->format_options["$counter"]["visible"] = true;
273 }
274
275 protected function makeObjectNodeExpandable($c_type, $obj_id) {
276 if ($c_type =="sos") {
277 $this->setExpand($obj_id);
278 }
279 }
280
281 protected function getParentIndex($child) {
282 if ($child != $this->tree->getRootId()) {
283 return $this->getIndex($object);
284 }
285 }
286
287 protected function setParentExpanded($parent) {
288 if (!$this->expand_all && !in_array($parent, $this->expanded)) {
289 $this->expanded[] = $parent;
290 }
291 }
292
293 protected function shouldHideCurrentNode($child, $parent_index, $parent) {
294 if ($child != $this->tree->getRootId()
295 && (!$this->expand_all and !in_array($parent, $this->expanded)
296 or !$this->format_options["$parent_index"]["visible"]))
297 {
298 return true;
299 }
300
301 return false;
302 }
303}
304?>
global $tpl
Definition: ilias.php:8
Explorer View for AICC Learning Modules.
formatItemTable(&$tpl, $a_id, $a_type)
setOutput($a_parent_id, $a_depth=0)
createPrefixArray($counter, $tab)
shouldHideCurrentNode($child, $parent_index, $parent)
addObjectToOutputArray($counter, $tab, $object)
makeObjectNodeExpandable($c_type, $obj_id)
formatObject($a_node_id, $a_option)
Creates output recursive method @access private.
isClickable($a_type, $a_id=0)
check if links for certain object type are activated
__construct($a_target, &$a_slm_obj)
Constructor @access public.
AICC Object Tree.
showChilds($a_parent_id)
determines wether the childs of an object should be shown or not note: this standard implementation a...
setExpand($a_node_id)
set the expand option this value is stored in a SESSION variable to save it different view (lo view,...
checkFilter($a_item)
check if item is in filter @access private
outputIcons($a_icons)
output icons
getIndex($a_data)
get index of format_options array from specific ref_id,parent_id @access private
checkPermissions($a_check)
check permissions via rbac
buildFrameTarget($a_type, $a_child=0, $a_obj_id=0)
get frame target (may be overwritten by derived classes)
setOrderColumn($a_column)
set the order column @access public
buildLinkTarget($a_node_id, $a_type)
get link target (may be overwritten by derived classes)
Explorer View for SCORM Learning Modules.
isVisible($a_id, $a_type)
createTarget($a_type, $a_child)
Creates Get Parameter @access private.
getOutputIcons(&$tpl, $a_option, $a_node_id, $scormtype="sco")
tpl is filled with option state
special template class to simplify handling of ITX/PEAR
static shortenText($a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
redirection script todo: (a better solution should control the processing via a xml file)
global $lng
Definition: privfeed.php:40