ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilRepositoryGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/Table/classes/class.ilTableGUI.php");
5include_once("Services/Payment/classes/class.ilPaymentObject.php");
6
7
29{
30 var $lng;
31 var $ilias;
32 var $tpl;
33 var $tree;
36 var $cmd;
37 var $mode;
38 var $ctrl;
39
44 function ilRepositoryGUI()
45 {
46 global $lng, $ilias, $tpl, $tree, $rbacsystem, $objDefinition,
48//var_dump($_SESSION['il_rep_clipboard']);
49 $this->lng =& $lng;
50 $this->ilias =& $ilias;
51 $this->tpl =& $tpl;
52 $this->tree =& $tree;
53 $this->rbacsystem =& $rbacsystem;
54 $this->objDefinition =& $objDefinition;
55
56 $this->ctrl =& $ilCtrl;
57
58 $this->creation_mode = false;
59
60 $this->ctrl->saveParameter($this, array("ref_id"));
61 if (!ilUtil::isAPICall())
62 $this->ctrl->setReturn($this,"");
63
64 // determine current ref id and mode
65 if (!empty($_GET["ref_id"]) || $this->ctrl->getCmd() == "showTree")
66 {
67 $this->cur_ref_id = $_GET["ref_id"];
68 }
69 else
70 {
71//echo "1-".$_SESSION["il_rep_ref_id"]."-";
72 if (!empty($_SESSION["il_rep_ref_id"]) && !empty($_GET["getlast"]))
73 {
74 $this->cur_ref_id = $_SESSION["il_rep_ref_id"];
75//echo "2-".$this->cur_ref_id."-";
76 }
77 else
78 {
79 $this->cur_ref_id = $this->tree->getRootId();
80
81 if ($_GET["cmd"] != "" && $_GET["cmd"] != "frameset")
82 {
83//echo "hhh";
84 $get_str = $post_str = "";
85 foreach($_GET as $key => $value)
86 {
87 $get_str.= "-$key:$value";
88 }
89 foreach($_POST as $key => $value)
90 {
91 $post_str.= "-$key:$value";
92 }
93 $ilLog->write("Repository: command called without ref_id.".
94 "GET:".$get_str."-POST:".$post_str, $ilLog->WARNING);
95 }
96 // #10033
97 $_GET = array("baseClass"=>"ilRepositoryGUI");
98 $_POST = array();
99 $this->ctrl->setCmd("frameset");
100 }
101 }
102//echo "<br>+".$_GET["ref_id"]."+";
103 if (!$tree->isInTree($this->cur_ref_id) && $this->ctrl->getCmd() != "showTree")
104 {
105 $this->cur_ref_id = $this->tree->getRootId();
106
107 // check wether command has been called with
108 // item that is not in tree
109 if ($_GET["cmd"] != "" && $_GET["cmd"] != "frameset")
110 {
111 $get_str = $post_str = "";
112 foreach($_GET as $key => $value)
113 {
114 $get_str.= "-$key:$value";
115 }
116 foreach($_POST as $key => $value)
117 {
118 $post_str.= "-$key:$value";
119 }
120 $ilLog->write("Repository: command called with ref_id that is not in tree.".
121 "GET:".$get_str."-POST:".$post_str, $ilLog->WARNING);
122 }
123 $_GET = array();
124 $_POST = array();
125 $this->ctrl->setCmd("frameset");
126 }
127
128 // set current repository view mode
129 if (!empty($_GET["set_mode"]))
130 {
131 $_SESSION["il_rep_mode"] = $_GET["set_mode"];
132 if ($this->ilias->account->getId() != ANONYMOUS_USER_ID)
133 {
134 $this->ilias->account->writePref("il_rep_mode", $_GET["set_mode"]);
135 }
136 }
137
138 // get user setting
139 if ($_SESSION["il_rep_mode"] == "")
140 {
141 if ($this->ilias->account->getId() != ANONYMOUS_USER_ID)
142 {
143 $_SESSION["il_rep_mode"] = $this->ilias->account->getPref("il_rep_mode");
144 }
145 }
146
147 // if nothing set, get default view
148 if ($_SESSION["il_rep_mode"] == "")
149 {
150 $_SESSION["il_rep_mode"] = $this->ilias->getSetting("default_repository_view");
151 }
152
153 $this->mode = ($_SESSION["il_rep_mode"] != "")
154 ? $_SESSION["il_rep_mode"]
155 : "flat";
156
157 // store current ref id
158 if ($this->ctrl->getCmd() != "showTree" &&
159 $rbacsystem->checkAccess("read", $this->cur_ref_id))
160 {
161 $type = ilObject::_lookupType($this->cur_ref_id, true);
162 if ($type == "cat" || $type == "grp" || $type == "crs"
163 || $type == "root")
164 {
165 $_SESSION["il_rep_ref_id"] = $this->cur_ref_id;
166 }
167 }
168
169 $_GET["ref_id"] = $this->cur_ref_id;
170
171 }
172
173
177 function &executeCommand()
178 {
179 global $rbacsystem, $ilias, $lng, $ilCtrl, $ilHelp;
180
181 // check creation mode
182 // determined by "new_type" parameter
183 $new_type = ($_POST["new_type"] != "" && $ilCtrl->getCmd() == "create")
184 ? $_POST["new_type"]
185 : $_GET["new_type"];
186
187 if ($new_type != "" && $new_type != "sty")
188 {
189 $this->creation_mode = true;
190 $ilHelp->setScreenIdComponent($new_type);
191 $ilHelp->setDefaultScreenId(ilHelpGUI::ID_PART_SCREEN, "create");
192 }
193
194 // handle frameset command
195 $cmd = $this->ctrl->getCmd();
196 if (($cmd == "frameset" || $_GET["rep_frame"] == 1) && $_SESSION["il_rep_mode"] == "tree")
197 {
198 $next_class = "";
199 $cmd = "frameset";
200 }
201 else if ($cmd == "frameset" && $_SESSION["il_rep_mode"] != "tree")
202 {
203 $this->ctrl->setCmd("");
204 $cmd = "";
205 }
206
207 // determine next class
208 if ($cmd != "frameset")
209 {
210 if ($this->creation_mode)
211 {
212 $obj_type = $new_type;
213 $class_name = $this->objDefinition->getClassName($obj_type);
214 if (strtolower($class_name) != "user")
215 {
216 $next_class = strtolower("ilObj".$class_name."GUI");
217 }
218 else
219 {
220 $next_class = $this->ctrl->getNextClass();
221 }
222 // Only set the fixed cmdClass if the next class is different to
223 // the GUI class of the new object.
224 // An example:
225 // Copy Category uses this call structure:
226 // RespositoryGUI -> CategoryGUI -> ilObjectCopyGUI
227 // Without this fix, the cmdClass ilObjectCopyGUI would never be reached
228 if($this->ctrl->getNextClass() != strtolower('ilObj'.$class_name.'GUI'))
229 {
230 $this->ctrl->setCmdClass($next_class);
231 }
232 }
233 else if ((($next_class = $this->ctrl->getNextClass($this)) == "")
234 || ($next_class == "ilrepositorygui" && $this->ctrl->getCmd() == "return"))
235 {
236 if ($cmd != "frameset" && $cmd != "showTree")
237 {
238 // get GUI of current object
239 $obj_type = ilObject::_lookupType($this->cur_ref_id,true);
240 $class_name = $this->objDefinition->getClassName($obj_type);
241 $next_class = strtolower("ilObj".$class_name."GUI");
242
243 $this->ctrl->setCmdClass($next_class);
244 if ($this->ctrl->getCmd() == "return")
245 {
246 $this->ctrl->setCmd("");
247 }
248 }
249 }
250 }
251
252 // commands that are always handled by repository gui
253 // to do: move to container
254 //if ($cmd == "showTree" || $cmd == "linkSelector" || $cmd == "linkChilds")
255 if ($cmd == "showTree")
256 {
257 $next_class = "";
258 }
259
260 switch ($next_class)
261 {
262 default:
263 // forward all other classes to gui commands
264 if ($next_class != "" && $next_class != "ilrepositorygui")
265 {
266 $class_path = $this->ctrl->lookupClassPath($next_class);
267 // get gui class instance
268 require_once($class_path);
269 $class_name = $this->ctrl->getClassForClasspath($class_path);
270 if (!$this->creation_mode)
271 {
272 if(is_subclass_of($class_name, "ilObject2GUI"))
273 {
274 $this->gui_obj = new $class_name($this->cur_ref_id, ilObject2GUI::REPOSITORY_NODE_ID);
275 }
276 else
277 {
278 $this->gui_obj = new $class_name("", $this->cur_ref_id, true, false);
279 }
280 }
281 else
282 {
283 if(is_subclass_of($class_name, "ilObject2GUI"))
284 {
285 $this->gui_obj = new $class_name(null, ilObject2GUI::REPOSITORY_NODE_ID, $this->cur_ref_id);
286 }
287 // dirty walkaround for ilinc classrooms which need passed the ref_id of the parent iLinc course
288 else if ($class_name == 'ilObjiLincClassroomGUI')
289 {
290 $this->gui_obj = new $class_name("", $this->cur_ref_id, true, false);
291 }
292 else
293 {
294 $this->gui_obj = new $class_name("", 0, true, false);
295 }
296 }
297 //$this->gui_obj = new $class_name("", $this->cur_ref_id, true, false);
298
299
300 $tabs_out = ($new_type == "")
301 ? true
302 : false;
303 $this->gui_obj->setCreationMode($this->creation_mode);
304 $this->ctrl->setReturn($this, "return");
305
306 $this->show();
307 }
308 else //
309 {
310 // process repository frameset
311 if ($cmd == "frameset")
312 {
313 if ($_SESSION["il_rep_mode"] == "tree")
314 {
315 $this->frameset();
316 return;
317 }
318 $cmd = "";
319 $this->ctrl->setCmd("");
320 }
321
322 // process tree command
323 if ($cmd == "showTree")
324 {
325 $this->showTree();
326 return;
327 }
328
329 $cmd = $this->ctrl->getCmd("");
330
331 // check read access for category
332 if ($this->cur_ref_id > 0 && !$rbacsystem->checkAccess("read", $this->cur_ref_id))
333 {
334 $_SESSION["il_rep_ref_id"] = "";
335 $ilias->raiseError($lng->txt("permission_denied"), $ilias->error_obj->MESSAGE);
336 $this->tpl->show();
337 }
338 else
339 {
340 $this->cmd = $cmd;
341 $this->$cmd();
342 }
343 }
344 break;
345 }
346 }
347
348
349 function show()
350 {
351 // normal command processing
352 $ret =& $this->ctrl->forwardCommand($this->gui_obj);
353 $this->tpl->setVariable("OBJECTS", $this->gui_obj->getHTML());
354
355 $this->tpl->show();
356 }
357
361 function frameset()
362 {
363 global $lng, $ilCtrl, $ilAccess;
364
365$ilCtrl->redirectByClass("ilrepositorygui", "");
366
367 include_once("Services/Frameset/classes/class.ilFramesetGUI.php");
368 $fs_gui = new ilFramesetGUI();
369
370 if ($_GET["rep_frame"] == 1)
371 {
372 // workaround for passing anchors (e.g. used in ilNoteGUI)
373 $anchor = ($_GET["anchor"] != "")
374 ? "#".$_GET["anchor"]
375 : "";
376 $fs_gui->setMainFrameSource(
377 str_replace("rep_frame", "rep_frame_done", $_SERVER["REQUEST_URI"]).$anchor);
378 }
379 else
380 {
381 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->cur_ref_id);
382 $ilCtrl->setParameterByClass("ilrepositorygui", "getlast", "true");
383 if ($ilAccess->checkAccess("read", "", $this->cur_ref_id))
384 {
385 $fs_gui->setMainFrameSource(
386 $ilCtrl->getLinkTargetByClass("ilrepositorygui", ""));
387 }
388 else
389 {
390 // if no read permission is given, do not display frameset
391 // see bug http://www.ilias.de/mantis/view.php?id=10305
392 $ilCtrl->redirectByClass("ilrepositorygui", "");
393 }
394 $ilCtrl->clearParametersByClass("ilrepositorygui");
395 }
396 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->cur_ref_id);
397 $fs_gui->setSideFrameSource(
398 $ilCtrl->getLinkTargetByClass("ilrepositorygui", "showTree"));
399 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
400
401 $fs_gui->setSideFrameName("tree");
402 $fs_gui->setMainFrameName("rep_content");
403 $fs_gui->setFramesetTitle($this->lng->txt("repository"));
404 $fs_gui->show();
405 exit;
406 }
407
408
412 function showTree()
413 {
414 global $ilCtrl, $tree, $ilSetting, $lng;
415
416 $ilCtrl->setParameter($this, "active_node", $_GET["active_node"]);
417
418 $this->tpl = new ilTemplate("tpl.main.html", true, true);
419 $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
420
421 $this->tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
422
423 include_once ("./Services/Repository/classes/class.ilRepositoryExplorer.php");
424
425 $active_node = ($_GET["active_node"] > 1)
426 ? $_GET["active_node"]
427 : ($_GET["ref_id"] > 1)
428 ? $_GET["ref_id"]
429 : 0;
430 $top_node = 0;
431 if ($ilSetting->get("rep_tree_limit_grp_crs") && $active_node > 0)
432 {
433 $path = $tree->getPathId($active_node);
434 foreach ($path as $n)
435 {
436 if ($top_node > 0)
437 {
438 break;
439 }
441 array("crs", "grp")))
442 {
443 $top_node = $n;
444 }
445 }
446 }
447
448 $exp = new ilRepositoryExplorer("ilias.php?baseClass=ilRepositoryGUI&amp;cmd=goto", $top_node);
449 $exp->setUseStandardFrame(false);
450 $exp->setExpandTarget($ilCtrl->getLinkTarget($this, "showTree"));
451 $exp->setFrameUpdater("tree", "updater");
452 $exp->setTargetGet("ref_id");
453
454 if ($_GET["repexpand"] == "")
455 {
456 $expanded = $this->tree->readRootId();
457 }
458 else
459 {
460 $expanded = $_GET["repexpand"];
461 }
462
463 $exp->setExpand($expanded);
464
465 if ($active_node > 0)
466 {
467 $path = $tree->getPathId($active_node);
468 if ($top_node > 0)
469 {
470 $exp->setForceOpenPath($path);
471 $exp->setExpand($expanded);
472 }
473 else
474 {
475 $exp->setForceOpenPath($path + array($top_node));
476 }
477 $exp->highlightNode($active_node);
478 }
479
480 // build html-output
481 if ($top_node > 0)
482 {
483 $head_tpl = new ilTemplate("tpl.cont_tree_head.html", true, true,
484 "Services/Repository");
485 $path = ilObject::_getIcon(ROOT_FOLDER_ID, "tiny", "root");
486 $nd = $tree->getNodeData(ROOT_FOLDER_ID);
487 $title = $nd["title"];
488 if ($title == "ILIAS")
489 {
490 $title = $lng->txt("repository");
491 }
492 $head_tpl->setVariable("IMG_SRC", $path);
493 $head_tpl->setVariable("ALT_IMG", $lng->txt("icon")." ".$title);
494 $head_tpl->setVariable("LINK_TXT", $title);
495 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", "1");
496 $head_tpl->setVariable("LINK_HREF",
497 $ilCtrl->getLinkTargetByClass("ilrepositorygui", "frameset"));
498 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
499 $exp->setTreeLead($head_tpl->get());
500
501 $exp->initItemCounter(1);
502 $exp->setOutput($tree->getParentId($top_node), 1,
503 ilObject::_lookupObjId($tree->getParentId($top_node)));
504 }
505 else
506 {
507 $exp->setOutput(0);
508 }
509 $output = $exp->getOutput(false);
510
511//if ($GLOBALS["ilUser"]->getLogin() == "alex") echo "topnode:$top_node:activenode:$active_node:";
512
513
514 // asynchronous output
515 if ($ilCtrl->isAsynch())
516 {
517 echo $output; exit;
518 }
519
520 $this->tpl->setCurrentBlock("content");
521 $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("overview"));
522 $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
523 $this->tpl->setVariable("EXPLORER",$output);
524 $ilCtrl->setParameter($this, "repexpand", $_GET["repexpand"]);
525 $this->tpl->setVariable("ACTION", $ilCtrl->getLinkTarget($this, "showTree", "", false, false));
526 $this->tpl->parseCurrentBlock();
527
528 include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
529 iljQueryUtil::initjQuery($this->tpl);
530
531 $this->tpl->show(false);
532 exit;
533 }
534
535} // END class.ilRepository
536
537
538?>
$n
Definition: RandomTest.php:80
$_GET["client_id"]
Class ilFramesetGUI.
const ID_PART_SCREEN
static _lookupObjId($a_id)
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
static _lookupType($a_id, $a_reference=false)
lookup object type
Class ilRepositoryGUI.
frameset()
output tree frameset
ilRepositoryGUI()
Constructor @access public.
& executeCommand()
execute command
showTree()
display tree view
special template class to simplify handling of ITX/PEAR
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
static isAPICall()
static initjQuery($a_tpl=null)
Init jQuery.
$_POST['username']
Definition: cron.php:12
$nd
Definition: error.php:9
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
global $ilCtrl
Definition: ilias.php:18
exit
Definition: login.php:54
redirection script todo: (a better solution should control the processing via a xml file)
global $ilSetting
Definition: privfeed.php:40
$path
Definition: index.php:22