ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilRepositoryGUI Class Reference

Class ilRepositoryGUI. More...

+ Collaboration diagram for ilRepositoryGUI:

Public Member Functions

 __construct ()
 Constructor public. More...
 
 executeCommand ()
 execute command More...
 
 show ()
 
 frameset ()
 output tree frameset More...
 
 showTree ()
 display tree view More...
 
 showRepTree ()
 Show tree. More...
 

Data Fields

 $lng
 
 $tpl
 
 $tree
 
 $rbacsystem
 
 $cur_ref_id
 
 $cmd
 
 $mode
 
 $ctrl
 

Protected Attributes

 $objDefinition
 
 $log
 
 $user
 
 $settings
 
 $help
 
 $error
 
 $access
 
 $tool_context
 

Private Attributes

 $http
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilRepositoryGUI::__construct ( )

Constructor public.

Definition at line 89 of file class.ilRepositoryGUI.php.

References $_GET, $_POST, $_SESSION, $cur_ref_id, $DIC, $ilSetting, $ilUser, $lng, $objDefinition, $rbacsystem, $tpl, $tree, $type, ilObject\_lookupType(), ANONYMOUS_USER_ID, help(), ILIAS\FileDelivery\http(), ilUtil\isAPICall(), settings(), and user().

90  {
91  global $DIC;
92 
93  $this->log = $DIC["ilLog"];
94  $this->user = $DIC->user();
95  $this->settings = $DIC->settings();
96  $this->help = $DIC["ilHelp"];
97  $this->error = $DIC["ilErr"];
98  $this->access = $DIC->access();
99  $lng = $DIC->language();
100  $tpl = $DIC["tpl"];
101  $tree = $DIC->repositoryTree();
102  $rbacsystem = $DIC->rbac()->system();
103  $objDefinition = $DIC["objDefinition"];
104  $ilCtrl = $DIC->ctrl();
105  $ilLog = $DIC["ilLog"];
106  $ilUser = $DIC->user();
107  $ilSetting = $DIC->settings();
108  $this->tool_context = $DIC->globalScreen()->tool()->context();
109  $this->http = $DIC->http();
110 
111  $this->lng = $lng;
112  $this->tpl = $tpl;
113  $this->tree = $tree;
114  $this->rbacsystem = $rbacsystem;
115  $this->objDefinition = $objDefinition;
116 
117  $this->ctrl = $ilCtrl;
118 
119  $this->creation_mode = false;
120 
121  $this->ctrl->saveParameter($this, array("ref_id"));
122  if (!ilUtil::isAPICall()) {
123  $this->ctrl->setReturn($this, "");
124  }
125 
126  // determine current ref id and mode
127  if (!empty($_GET["ref_id"]) || $this->ctrl->getCmd() == "showTree") {
128  $this->cur_ref_id = $_GET["ref_id"];
129  } else {
130  //echo "1-".$_SESSION["il_rep_ref_id"]."-";
131  if (!empty($_SESSION["il_rep_ref_id"]) && !empty($_GET["getlast"])) {
132  $this->cur_ref_id = $_SESSION["il_rep_ref_id"];
133  //echo "2-".$this->cur_ref_id."-";
134  } else {
135  $this->cur_ref_id = $this->tree->getRootId();
136 
137  if ($_GET["cmd"] != "" && $_GET["cmd"] != "frameset") {
138  //echo "hhh";
139  $get_str = $post_str = "";
140  foreach ($_GET as $key => $value) {
141  $get_str .= "-$key:$value";
142  }
143  foreach ($_POST as $key => $value) {
144  $post_str .= "-$key:$value";
145  }
146  $ilLog->write("Repository: command called without ref_id." .
147  "GET:" . $get_str . "-POST:" . $post_str, $ilLog->WARNING);
148  }
149  // #10033
150  $_GET = array("baseClass" => "ilRepositoryGUI");
151  $_POST = array();
152  $this->ctrl->setCmd("frameset");
153  }
154  }
155  //echo "<br>+".$_GET["ref_id"]."+";
156  if (!$tree->isInTree($this->cur_ref_id) && $this->ctrl->getCmd() != "showTree") {
157  $this->cur_ref_id = $this->tree->getRootId();
158 
159  // check wether command has been called with
160  // item that is not in tree
161  if ($_GET["cmd"] != "" && $_GET["cmd"] != "frameset") {
162  $get_str = $post_str = "";
163  foreach ($_GET as $key => $value) {
164  $get_str .= "-$key:$value";
165  }
166  foreach ($_POST as $key => $value) {
167  $post_str .= "-$key:$value";
168  }
169  $ilLog->write("Repository: command called with ref_id that is not in tree." .
170  "GET:" . $get_str . "-POST:" . $post_str, $ilLog->WARNING);
171  }
172  $_GET = array();
173  $_POST = array();
174  $this->ctrl->setCmd("frameset");
175  }
176 
177  // set current repository view mode
178  if (!empty($_GET["set_mode"])) {
179  $_SESSION["il_rep_mode"] = $_GET["set_mode"];
180  if ($ilUser->getId() != ANONYMOUS_USER_ID) {
181  $ilUser->writePref("il_rep_mode", $_GET["set_mode"]);
182  }
183  }
184 
185  // get user setting
186  if ($_SESSION["il_rep_mode"] == "") {
187  if ($ilUser->getId() != ANONYMOUS_USER_ID) {
188  $_SESSION["il_rep_mode"] = $ilUser->getPref("il_rep_mode");
189  }
190  }
191 
192  // if nothing set, get default view
193  if ($_SESSION["il_rep_mode"] == "") {
194  $_SESSION["il_rep_mode"] = $ilSetting->get("default_repository_view");
195  }
196 
197  $this->mode = ($_SESSION["il_rep_mode"] != "")
198  ? $_SESSION["il_rep_mode"]
199  : "flat";
200 
201  // store current ref id
202  if ($this->ctrl->getCmd() != "showTree" &&
203  $rbacsystem->checkAccess("read", $this->cur_ref_id)) {
204  $type = ilObject::_lookupType($this->cur_ref_id, true);
205  if ($type == "cat" || $type == "grp" || $type == "crs"
206  || $type == "root") {
207  $_SESSION["il_rep_ref_id"] = $this->cur_ref_id;
208  }
209  }
210 
211  $_GET["ref_id"] = $this->cur_ref_id;
212  }
settings()
Definition: settings.php:2
const ANONYMOUS_USER_ID
Definition: constants.php:25
$_SESSION["AccountId"]
$type
$_GET["client_id"]
user()
Definition: user.php:4
help()
Definition: help.php:2
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: goto.php:24
static _lookupType($a_id, $a_reference=false)
lookup object type
global $ilSetting
Definition: privfeed.php:17
$ilUser
Definition: imgupload.php:18
$_POST["username"]
static isAPICall()
+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilRepositoryGUI::executeCommand ( )

execute command

Definition at line 218 of file class.ilRepositoryGUI.php.

References $_GET, $_POST, $_SESSION, $cmd, $ctrl, $error, $help, $ilErr, $lng, $rbacsystem, ilObject\_lookupType(), frameset(), ilPublicSectionSettings\getInstance(), ilLoggerFactory\getLogger(), ILIAS\FileDelivery\http(), ilHelpGUI\ID_PART_SCREEN, ilObject2GUI\REPOSITORY_NODE_ID, show(), showTree(), and user().

219  {
221  $lng = $this->lng;
222  $ilCtrl = $this->ctrl;
223  $ilHelp = $this->help;
225 
226  if (
227  ($this->user->isAnonymous() || !($this->user->getId() >= 1)) &&
228  !ilPublicSectionSettings::getInstance()->isEnabledForDomain(
229  $this->http->request()->getServerParams()['SERVER_NAME']
230  )
231  ) {
232  $this->ctrl->redirectToURL('./login.php?cmd=force_login');
233  }
234 
235  $this->tool_context->claim()->repository();
236  $show_tree = ($_SESSION["il_rep_mode"] == "flat")
237  ? true
238  : false;
239 
240  // check creation mode
241  // determined by "new_type" parameter
242  $new_type = ($_POST["new_type"] != "" && $ilCtrl->getCmd() == "create")
243  ? $_POST["new_type"]
244  : $_GET["new_type"];
245 
246  if ($new_type != "" && $new_type != "sty") {
247  $this->creation_mode = true;
248  $ilHelp->setScreenIdComponent($new_type);
249  $ilHelp->setDefaultScreenId(ilHelpGUI::ID_PART_SCREEN, "create");
250  }
251 
252  // handle frameset command
253  $cmd = $this->ctrl->getCmd();
254  if (($cmd == "frameset" || $_GET["rep_frame"] == 1) && $_SESSION["il_rep_mode"] == "tree") {
255  $next_class = "";
256  $cmd = "frameset";
257  } elseif ($cmd == "frameset" && $_SESSION["il_rep_mode"] != "tree") {
258  $this->ctrl->setCmd("");
259  $cmd = "";
260  }
261 
262 
263  // determine next class
264  if ($cmd != "frameset") {
265  if ($this->creation_mode) {
266  $obj_type = $new_type;
267  $class_name = $this->objDefinition->getClassName($obj_type);
268  if (strtolower($class_name) != "user") {
269  $next_class = strtolower("ilObj" . $class_name . "GUI");
270  } else {
271  $next_class = $this->ctrl->getNextClass();
272  }
273  // Only set the fixed cmdClass if the next class is different to
274  // the GUI class of the new object.
275  // An example:
276  // Copy Category uses this call structure:
277  // RespositoryGUI -> CategoryGUI -> ilObjectCopyGUI
278  // Without this fix, the cmdClass ilObjectCopyGUI would never be reached
279 
280  ilLoggerFactory::getLogger('obj')->debug($this->ctrl->getNextClass() . ' <-> ' . $class_name);
281 
282  if ($this->ctrl->getNextClass() != strtolower('ilObj' . $class_name . 'GUI')) {
283  $this->ctrl->setCmdClass($next_class);
284  }
285  } elseif ((($next_class = $this->ctrl->getNextClass($this)) == "")
286  || ($next_class == "ilrepositorygui" && $this->ctrl->getCmd() == "return")) {
287  if ($cmd != "frameset" && $cmd != "showTree") {
288  // get GUI of current object
289  $obj_type = ilObject::_lookupType($this->cur_ref_id, true);
290  $class_name = $this->objDefinition->getClassName($obj_type);
291  $next_class = strtolower("ilObj" . $class_name . "GUI");
292 
293  $this->ctrl->setCmdClass($next_class);
294  if ($this->ctrl->getCmd() == "return") {
295  $this->ctrl->setCmd("");
296  }
297  }
298  }
299  }
300 
301  // commands that are always handled by repository gui
302  // to do: move to container
303  if ($cmd == "showRepTree") {
304  $next_class = "";
305  }
306 
307  switch ($next_class) {
308  default:
309  // forward all other classes to gui commands
310  if ($next_class != "" && $next_class != "ilrepositorygui") {
311  $class_path = $this->ctrl->lookupClassPath($next_class);
312  // get gui class instance
313  require_once($class_path);
314  $class_name = $this->ctrl->getClassForClasspath($class_path);
315  if (!$this->creation_mode) {
316  if (is_subclass_of($class_name, "ilObject2GUI")) {
317  $this->gui_obj = new $class_name($this->cur_ref_id, ilObject2GUI::REPOSITORY_NODE_ID);
318  } else {
319  $this->gui_obj = new $class_name("", $this->cur_ref_id, true, false);
320  }
321  } else {
322  if (is_subclass_of($class_name, "ilObject2GUI")) {
323  $this->gui_obj = new $class_name(null, ilObject2GUI::REPOSITORY_NODE_ID, $this->cur_ref_id);
324  } else {
325  $this->gui_obj = new $class_name("", 0, true, false);
326  }
327  }
328  //$this->gui_obj = new $class_name("", $this->cur_ref_id, true, false);
329 
330 
331  $tabs_out = ($new_type == "")
332  ? true
333  : false;
334  $this->gui_obj->setCreationMode($this->creation_mode);
335  $this->ctrl->setReturn($this, "return");
336 
337  $this->show();
338  } else { //
339  // process repository frameset
340  if ($cmd == "frameset") {
341  if ($_SESSION["il_rep_mode"] == "tree") {
342  $this->frameset();
343  return;
344  }
345  $cmd = "";
346  $this->ctrl->setCmd("");
347  }
348 
349  // process tree command
350  if ($cmd == "showTree") {
351  $this->showTree();
352  return;
353  }
354 
355  $cmd = $this->ctrl->getCmd("");
356 
357  // check read access for category
358  if ($this->cur_ref_id > 0 && !$rbacsystem->checkAccess("read", $this->cur_ref_id) && $cmd != "showRepTree") {
359  $_SESSION["il_rep_ref_id"] = "";
360  $ilErr->raiseError($lng->txt("permission_denied"), $ilErr->MESSAGE);
361  $this->tpl->printToStdout();
362  } else {
363  $this->cmd = $cmd;
364  $this->$cmd();
365  }
366  }
367  break;
368  }
369  }
$_SESSION["AccountId"]
$_GET["client_id"]
user()
Definition: user.php:4
$ilErr
Definition: raiseError.php:18
static http()
Fetches the global http state from ILIAS.
static _lookupType($a_id, $a_reference=false)
lookup object type
static getLogger($a_component_id)
Get component logger.
showTree()
display tree view
const ID_PART_SCREEN
frameset()
output tree frameset
$_POST["username"]
+ Here is the call graph for this function:

◆ frameset()

ilRepositoryGUI::frameset ( )

output tree frameset

Definition at line 383 of file class.ilRepositoryGUI.php.

References $access, $ctrl, and $lng.

Referenced by executeCommand().

384  {
385  $lng = $this->lng;
386  $ilCtrl = $this->ctrl;
387  $ilAccess = $this->access;
388 
389  $ilCtrl->redirectByClass("ilrepositorygui", "");
390  }
+ Here is the caller graph for this function:

◆ show()

ilRepositoryGUI::show ( )

Definition at line 372 of file class.ilRepositoryGUI.php.

References $ret.

Referenced by executeCommand().

373  {
374  // normal command processing
375  $ret = $this->ctrl->forwardCommand($this->gui_obj);
376  $this->tpl->setVariable("OBJECTS", $this->gui_obj->getHTML());
377  $this->tpl->printToStdout();
378  }
$ret
Definition: parser.php:6
+ Here is the caller graph for this function:

◆ showRepTree()

ilRepositoryGUI::showRepTree ( )

Show tree.

Definition at line 521 of file class.ilRepositoryGUI.php.

References exit.

522  {
523  $exp = new ilRepositoryExplorerGUI($this, "showRepTree");
524  // root node should be skipped, see #26787
525  $exp->setSkipRootNode(true);
526  $exp->handleCommand();
527  exit;
528  }
exit
Definition: login.php:29
Repository explorer GUI class.

◆ showTree()

ilRepositoryGUI::showTree ( )

display tree view

Definition at line 396 of file class.ilRepositoryGUI.php.

References $_GET, $ctrl, $ilSetting, $lng, $n, $nd, $settings, $tree, ilObject\_getIcon(), ilObject\_lookupObjId(), ilObject\_lookupType(), exit, ilUtil\getStyleSheetLocation(), iljQueryUtil\initjQuery(), and ROOT_FOLDER_ID.

Referenced by executeCommand().

397  {
398  $ilCtrl = $this->ctrl;
399  $tree = $this->tree;
401  $lng = $this->lng;
402 
403  $ilCtrl->setParameter($this, "active_node", $_GET["active_node"]);
404 
405  $this->tpl = new ilGlobalTemplate("tpl.main.html", true, true);
406  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
407 
408  $this->tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
409 
410  include_once("./Services/Repository/classes/class.ilRepositoryExplorer.php");
411 
412  $active_node = ($_GET["active_node"] > 1)
413  ? $_GET["active_node"]
414  : (($_GET["ref_id"] > 1)
415  ? $_GET["ref_id"]
416  : 0);
417  $top_node = 0;
418  if ($ilSetting->get("rep_tree_limit_grp_crs") && $active_node > 0) {
419  $path = $tree->getPathId($active_node);
420  foreach ($path as $n) {
421  if ($top_node > 0) {
422  break;
423  }
424  if (in_array(
426  array("crs", "grp")
427  )) {
428  $top_node = $n;
429  }
430  }
431  }
432 
433  $exp = new ilRepositoryExplorer("ilias.php?baseClass=ilRepositoryGUI&amp;cmd=goto", $top_node);
434  $exp->setUseStandardFrame(false);
435  $exp->setExpandTarget($ilCtrl->getLinkTarget($this, "showTree"));
436  $exp->setFrameUpdater("tree", "updater");
437  $exp->setTargetGet("ref_id");
438 
439  if ($_GET["repexpand"] == "") {
440  $expanded = $this->tree->readRootId();
441  } else {
442  $expanded = $_GET["repexpand"];
443  }
444 
445  $exp->setExpand($expanded);
446 
447  if ($active_node > 0) {
448  $path = $tree->getPathId($active_node);
449  if ($top_node > 0) {
450  $exp->setForceOpenPath($path);
451  $exp->setExpand($expanded);
452  } else {
453  $exp->setForceOpenPath($path + array($top_node));
454  }
455  $exp->highlightNode($active_node);
456  }
457 
458  // build html-output
459  if ($top_node > 0) {
460  $head_tpl = new ilTemplate(
461  "tpl.cont_tree_head.html",
462  true,
463  true,
464  "Services/Repository"
465  );
466  $path = ilObject::_getIcon(ROOT_FOLDER_ID, "tiny", "root");
467  $nd = $tree->getNodeData(ROOT_FOLDER_ID);
468  $title = $nd["title"];
469  if ($title == "ILIAS") {
470  $title = $lng->txt("repository");
471  }
472  $head_tpl->setVariable("IMG_SRC", $path);
473  $head_tpl->setVariable("ALT_IMG", $lng->txt("icon") . " " . $title);
474  $head_tpl->setVariable("LINK_TXT", $title);
475  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", "1");
476  $head_tpl->setVariable(
477  "LINK_HREF",
478  $ilCtrl->getLinkTargetByClass("ilrepositorygui", "frameset")
479  );
480  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
481  $exp->setTreeLead($head_tpl->get());
482 
483  $exp->initItemCounter(1);
484  $exp->setOutput(
485  $tree->getParentId($top_node),
486  1,
487  ilObject::_lookupObjId($tree->getParentId($top_node))
488  );
489  } else {
490  $exp->setOutput(0);
491  }
492  $output = $exp->getOutput(false);
493 
494  //if ($GLOBALS["ilUser"]->getLogin() == "alex") echo "topnode:$top_node:activenode:$active_node:";
495 
496 
497  // asynchronous output
498  if ($ilCtrl->isAsynch()) {
499  echo $output;
500  exit;
501  }
502 
503  $this->tpl->setCurrentBlock("content");
504  $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("overview"));
505  $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
506  $this->tpl->setVariable("EXPLORER", $output);
507  $ilCtrl->setParameter($this, "repexpand", $_GET["repexpand"]);
508  $this->tpl->setVariable("ACTION", $ilCtrl->getLinkTarget($this, "showTree", "", false, false));
509  $this->tpl->parseCurrentBlock();
510 
511  include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
512  iljQueryUtil::initjQuery($this->tpl);
513 
514  $this->tpl->printToStdout(false);
515  exit;
516  }
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
exit
Definition: login.php:29
special template class to simplify handling of ITX/PEAR
const ROOT_FOLDER_ID
Definition: constants.php:30
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
$_GET["client_id"]
$nd
Definition: error.php:12
static _lookupObjId($a_id)
$n
Definition: RandomTest.php:85
static _lookupType($a_id, $a_reference=false)
lookup object type
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
global $ilSetting
Definition: privfeed.php:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilRepositoryGUI::$access
protected

Definition at line 69 of file class.ilRepositoryGUI.php.

Referenced by frameset().

◆ $cmd

ilRepositoryGUI::$cmd

Definition at line 80 of file class.ilRepositoryGUI.php.

Referenced by executeCommand().

◆ $ctrl

ilRepositoryGUI::$ctrl

Definition at line 82 of file class.ilRepositoryGUI.php.

Referenced by executeCommand(), frameset(), and showTree().

◆ $cur_ref_id

ilRepositoryGUI::$cur_ref_id

Definition at line 79 of file class.ilRepositoryGUI.php.

Referenced by __construct().

◆ $error

ilRepositoryGUI::$error
protected

Definition at line 64 of file class.ilRepositoryGUI.php.

Referenced by executeCommand().

◆ $help

ilRepositoryGUI::$help
protected

Definition at line 59 of file class.ilRepositoryGUI.php.

Referenced by executeCommand().

◆ $http

ilRepositoryGUI::$http
private

Definition at line 83 of file class.ilRepositoryGUI.php.

◆ $lng

ilRepositoryGUI::$lng

Definition at line 75 of file class.ilRepositoryGUI.php.

Referenced by __construct(), executeCommand(), frameset(), and showTree().

◆ $log

ilRepositoryGUI::$log
protected

Definition at line 44 of file class.ilRepositoryGUI.php.

◆ $mode

ilRepositoryGUI::$mode

Definition at line 81 of file class.ilRepositoryGUI.php.

◆ $objDefinition

ilRepositoryGUI::$objDefinition
protected

Definition at line 39 of file class.ilRepositoryGUI.php.

Referenced by __construct().

◆ $rbacsystem

ilRepositoryGUI::$rbacsystem

Definition at line 78 of file class.ilRepositoryGUI.php.

Referenced by __construct(), and executeCommand().

◆ $settings

ilRepositoryGUI::$settings
protected

Definition at line 54 of file class.ilRepositoryGUI.php.

Referenced by showTree().

◆ $tool_context

ilRepositoryGUI::$tool_context
protected

Definition at line 73 of file class.ilRepositoryGUI.php.

◆ $tpl

ilRepositoryGUI::$tpl

Definition at line 76 of file class.ilRepositoryGUI.php.

Referenced by __construct().

◆ $tree

ilRepositoryGUI::$tree

Definition at line 77 of file class.ilRepositoryGUI.php.

Referenced by __construct(), and showTree().

◆ $user

ilRepositoryGUI::$user
protected

Definition at line 49 of file class.ilRepositoryGUI.php.


The documentation for this class was generated from the following file: