ILIAS  trunk Revision v11.0_alpha-1861-g09f3d197f78
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilLocatorGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilLocatorGUI:

Public Member Functions

 __construct ()
 
 setTextOnly (bool $a_textonly)
 
 setOffline (bool $a_offline)
 
 getOffline ()
 
 getTextOnly ()
 
 addRepositoryItems (int $a_ref_id=0)
 
 addAdministrationItems (int $a_ref_id=0)
 add administration tree items More...
 
 addContextItems (int $a_ref_id, bool $a_omit_node=false, int $a_stop=0)
 
 clearItems ()
 
 getItems ()
 
 getHTML ()
 
 getTextVersion ()
 Get text version. More...
 

Protected Member Functions

 init ()
 

Protected Attributes

int $ref_id = null
 
bool $textonly
 
bool $offline = false
 
ilTree $tree
 
ilCtrl $ctrl
 
ilObjectDefinition $obj_definition
 
ilAccessHandler $access
 
ilSetting $settings
 
ilLanguage $lng
 
array $entries = []
 
bool $initialised = false
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning locator handling class

This class supplies an implementation for the locator. The locator will send its output to ist own frame, enabling more flexibility in the design of the desktop.

Author
Arjan Ammerlaan a.l.a.nosp@m.mmer.nosp@m.laan@.nosp@m.web..nosp@m.de

Definition at line 27 of file class.ilLocatorGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilLocatorGUI::__construct ( )

Definition at line 41 of file class.ilLocatorGUI.php.

References setTextOnly().

42  {
43  $this->entries = array();
44  $this->offline = false;
45  $this->setTextOnly(false);
46  }
setTextOnly(bool $a_textonly)
+ Here is the call graph for this function:

Member Function Documentation

◆ addAdministrationItems()

ilLocatorGUI::addAdministrationItems ( int  $a_ref_id = 0)

add administration tree items

Exceptions
ilCtrlException

Definition at line 161 of file class.ilLocatorGUI.php.

References $ctrl, $lng, $obj_definition, $path, $ref_id, $tree, ilTree\getPathFull(), init(), ROOT_FOLDER_ID, and ilLanguage\txt().

161  : void
162  {
163  $this->init();
164  $tree = $this->tree;
165  $ilCtrl = $this->ctrl;
166  $objDefinition = $this->obj_definition;
167  $lng = $this->lng;
168 
169  if ($a_ref_id == 0) {
170  $a_ref_id = $this->ref_id;
171  }
172 
173  if ($a_ref_id > 0) {
174  $path = $tree->getPathFull($a_ref_id);
175 
176  // add item for each node on path
177  foreach ($path as $key => $row) {
178  if (!in_array($row["type"], array("root", "cat", "crs", "fold", "grp"))) {
179  continue;
180  }
181 
182  if ($row["child"] == ROOT_FOLDER_ID) {
183  $row["title"] = $lng->txt("repository");
184  }
185 
186  $class_name = $objDefinition->getClassName($row["type"]);
187  $class = strtolower("ilObj" . $class_name . "GUI");
188  $ilCtrl->setParameterByClass($class, "ref_id", $row["child"]);
189  $this->addItem(
190  $row["title"],
191  $ilCtrl->getLinkTargetByClass($class, "view"),
192  "",
193  $row["child"]
194  );
195  }
196  }
197  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
const ROOT_FOLDER_ID
Definition: constants.php:32
getPathFull(int $a_endnode_id, int $a_startnode_id=0)
get path from a given startnode to a given endnode if startnode is not given the rootnode is startnod...
$path
Definition: ltiservices.php:29
ilObjectDefinition $obj_definition
+ Here is the call graph for this function:

◆ addContextItems()

ilLocatorGUI::addContextItems ( int  $a_ref_id,
bool  $a_omit_node = false,
int  $a_stop = 0 
)

Definition at line 199 of file class.ilLocatorGUI.php.

References $access, $DIC, $path, $tree, CLIENT_ID, ilTree\getPathFull(), init(), ILIAS\Repository\lng(), and null.

203  : void {
204  $this->init();
205  $tree = $this->tree;
206 
207  if ($a_ref_id > 0) {
208  $path = $tree->getPathFull($a_ref_id);
209 
210  // we want to show the full path, from the major container to the item
211  // (folders are not! treated as containers here), at least one parent item
212  $r_path = array_reverse($path);
213  $first = "";
214  $omit = array();
215  $do_omit = false;
216  foreach ($r_path as $key => $row) {
217  if ($first == "") {
218  if (in_array($row["type"], array("root", "cat", "grp", "crs")) &&
219  $row["child"] != $a_ref_id) {
220  $first = $row["child"];
221  }
222  }
223  if ($a_stop == $row["child"]) {
224  $do_omit = true;
225  }
226  $omit[$row["child"]] = $do_omit;
227  }
228 
229  $add_it = false;
230  foreach ($path as $key => $row) {
231  if ($first == $row["child"]) {
232  $add_it = true;
233  }
234 
235 
236  if ($add_it && !$omit[$row["child"]] &&
237  (!$a_omit_node || ($row["child"] != $a_ref_id))) {
238  //echo "-".ilObject::_lookupTitle($row["obj_id"])."-";
239  if ($row["title"] == "ILIAS" && $row["type"] == "root") {
240  $row["title"] = $this->lng->txt("repository");
241  }
242  $this->addItem(
243  $row["title"],
244  "./goto.php?client_id=" . rawurlencode(CLIENT_ID) . "&target=" . $row["type"] . "_" . $row["child"],
245  "_top",
246  $row["child"],
247  $row["type"]
248  );
249  }
250  }
251  }
252  }
getPathFull(int $a_endnode_id, int $a_startnode_id=0)
get path from a given startnode to a given endnode if startnode is not given the rootnode is startnod...
$path
Definition: ltiservices.php:29
const CLIENT_ID
Definition: constants.php:41
+ Here is the call graph for this function:

◆ addRepositoryItems()

ilLocatorGUI::addRepositoryItems ( int  $a_ref_id = 0)
Parameters
int$a_ref_id
Returns
void
Exceptions
ilCtrlException

Definition at line 96 of file class.ilLocatorGUI.php.

References $ctrl, $path, $ref_id, $settings, $tree, ilFrameTargetInfo\_getFrame(), ilContainer\_lookupContainerSetting(), ilObject\_lookupObjId(), ilObjCourseGUI\BREADCRUMB_DEFAULT, ilObjCourseGUI\BREADCRUMB_FULL_PATH, ilTree\getPathFull(), init(), ILIAS\Repository\lng(), and ROOT_FOLDER_ID.

96  : void
97  {
98  $this->init();
99  $setting = $this->settings;
100  $tree = $this->tree;
101  $ilCtrl = $this->ctrl;
102 
103  if ($a_ref_id == 0) {
104  $a_ref_id = $this->ref_id;
105  }
106 
107  $a_start = ROOT_FOLDER_ID;
108  if ($a_ref_id > 0) {
109  $path = $tree->getPathFull($a_ref_id, $a_start);
110 
111  // check if path contains crs
112  $crs_ref_id = 0;
113  foreach ($path as $k => $v) {
114  if ($v["type"] == "crs") {
115  $crs_ref_id = $v["child"];
116  }
117  }
118  if (!$setting->get("rep_breadcr_crs")) { // no overwrite
119  $crs_ref_id = 0;
120  } elseif ($setting->get("rep_breadcr_crs_overwrite")) { // overwrite
121  // course wants full path
123  $crs_ref_id = 0;
124  }
125  // course wants default and default wants full path
126  if (ilContainer::_lookupContainerSetting(ilObject::_lookupObjId($crs_ref_id), "rep_breacrumb") == ilObjCourseGUI::BREADCRUMB_DEFAULT && !$setting->get("rep_breadcr_crs_default")) {
127  $crs_ref_id = 0;
128  }
129  }
130 
131  // add item for each node on path
132  foreach ($path as $key => $row) {
133  if (!in_array($row["type"], array("root", "cat", "crs", "fold", "grp", "prg", "lso"))) {
134  continue;
135  }
136  if ($crs_ref_id > 0 && $row["child"] == $crs_ref_id) {
137  $crs_ref_id = 0;
138  }
139  if ($crs_ref_id > 0) {
140  continue;
141  }
142 
143  if ($row["title"] == "ILIAS" && $row["type"] == "root") {
144  $row["title"] = $this->lng->txt("repository");
145  }
146 
147  $this->addItem(
148  $row["title"],
149  ilLink::_getLink((int) $row["child"]),
150  ilFrameTargetInfo::_getFrame("MainContent"),
151  $row["child"]
152  );
153  }
154  }
155  }
const ROOT_FOLDER_ID
Definition: constants.php:32
getPathFull(int $a_endnode_id, int $a_startnode_id=0)
get path from a given startnode to a given endnode if startnode is not given the rootnode is startnod...
$path
Definition: ltiservices.php:29
static _lookupObjId(int $ref_id)
static _lookupContainerSetting(int $a_id, string $a_keyword, ?string $a_default_value=null)
static _getFrame(string $a_class)
+ Here is the call graph for this function:

◆ clearItems()

ilLocatorGUI::clearItems ( )

Definition at line 287 of file class.ilLocatorGUI.php.

Referenced by ilObjSkillTreeGUI\showLocator().

287  : void
288  {
289  $this->entries = array();
290  }
+ Here is the caller graph for this function:

◆ getHTML()

ilLocatorGUI::getHTML ( )

Definition at line 297 of file class.ilLocatorGUI.php.

References $lng, ilObject\_getIcon(), ilObject\_lookupObjId(), ilObject\_lookupType(), getItems(), getOffline(), getTextOnly(), init(), and ilLanguage\txt().

297  : string
298  {
299  $this->init();
300  $lng = $this->lng;
301  $icon_path = "";
302 
303  if ($this->getTextOnly()) {
304  $loc_tpl = new ilTemplate("tpl.locator_text_only.html", true, true, "components/ILIAS/Locator");
305  } else {
306  $loc_tpl = new ilTemplate("tpl.locator.html", true, true, "components/ILIAS/Locator");
307  }
308 
309  $items = $this->getItems();
310  $first = true;
311  if (count($items) > 0) {
312  foreach ($items as $item) {
313  if (!$first) {
314  $loc_tpl->touchBlock("locator_separator_prefix");
315  }
316 
317  if ($item["ref_id"] > 0) {
318  $obj_id = ilObject::_lookupObjId($item["ref_id"]);
319  $type = ilObject::_lookupType($obj_id);
320 
321  if (!$this->getTextOnly()) {
322  $icon_path = ilObject::_getIcon(
323  $obj_id,
324  "tiny",
325  $type,
326  $this->getOffline()
327  );
328  }
329 
330  $loc_tpl->setCurrentBlock("locator_img");
331  $loc_tpl->setVariable("IMG_SRC", $icon_path);
332  $loc_tpl->setVariable(
333  "IMG_ALT",
334  $lng->txt("obj_" . $type)
335  );
336  $loc_tpl->parseCurrentBlock();
337  }
338 
339  $loc_tpl->setCurrentBlock("locator_item");
340  if ($item["link"] != "") {
341  $loc_tpl->setVariable("LINK_ITEM", $item["link"]);
342  if ($item["frame"] != "") {
343  $loc_tpl->setVariable("LINK_TARGET", ' target="' . $item["frame"] . '" ');
344  }
345  $loc_tpl->setVariable("ITEM", $item["title"]);
346  } else {
347  $loc_tpl->setVariable("PREFIX", $item["title"]);
348  }
349  $loc_tpl->parseCurrentBlock();
350 
351  $first = false;
352  }
353  } else {
354  // $loc_tpl->setVariable("NOITEM", " ");
355  // $loc_tpl->touchBlock("locator");
356  }
357 
358  return trim($loc_tpl->get());
359  }
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static _lookupObjId(int $ref_id)
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

◆ getItems()

ilLocatorGUI::getItems ( )

Definition at line 292 of file class.ilLocatorGUI.php.

References $entries.

Referenced by getHTML(), and getTextVersion().

292  : array
293  {
294  return $this->entries;
295  }
+ Here is the caller graph for this function:

◆ getOffline()

ilLocatorGUI::getOffline ( )

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

References $offline.

Referenced by getHTML().

81  : bool
82  {
83  return $this->offline;
84  }
+ Here is the caller graph for this function:

◆ getTextOnly()

ilLocatorGUI::getTextOnly ( )

Definition at line 86 of file class.ilLocatorGUI.php.

References $textonly.

Referenced by getHTML().

86  : bool
87  {
88  return $this->textonly;
89  }
+ Here is the caller graph for this function:

◆ getTextVersion()

ilLocatorGUI::getTextVersion ( )

Get text version.

Definition at line 364 of file class.ilLocatorGUI.php.

References getItems(), and init().

364  : string
365  {
366  $this->init();
367  $items = $this->getItems();
368  $first = true;
369 
370  $str = "";
371  foreach ($items as $item) {
372  if (!$first) {
373  $str .= " > ";
374  }
375 
376  $str .= $item["title"];
377 
378  $first = false;
379  }
380 
381  return $str;
382  }
+ Here is the call graph for this function:

◆ init()

ilLocatorGUI::init ( )
protected

Definition at line 48 of file class.ilLocatorGUI.php.

References $DIC, $lng, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), null, and ILIAS\Repository\settings().

Referenced by addAdministrationItems(), addContextItems(), addRepositoryItems(), getHTML(), and getTextVersion().

48  : void
49  {
50  global $DIC;
51 
52  if ($this->initialised) {
53  return;
54  }
55  $this->tree = $DIC->repositoryTree();
56  $this->ctrl = $DIC->ctrl();
57  $this->obj_definition = $DIC["objDefinition"];
58  $this->access = $DIC->access();
59  $this->settings = $DIC->settings();
60  $lng = $DIC->language();
61 
62  $this->lng = $lng;
63  $this->ref_id = ($DIC->http()->wrapper()->query()->has("ref_id"))
64  ? $DIC->http()->wrapper()->query()->retrieve("ref_id", $DIC->refinery()->kindlyTo()->int())
65  : null;
66  if ($this->ref_id == 0) {
67  $this->ref_id = null;
68  }
69  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setOffline()

ilLocatorGUI::setOffline ( bool  $a_offline)

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

76  : void
77  {
78  $this->offline = $a_offline;
79  }

◆ setTextOnly()

ilLocatorGUI::setTextOnly ( bool  $a_textonly)

Definition at line 71 of file class.ilLocatorGUI.php.

Referenced by __construct().

71  : void
72  {
73  $this->textonly = $a_textonly;
74  }
+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilLocatorGUI::$access
protected

Definition at line 35 of file class.ilLocatorGUI.php.

Referenced by addContextItems().

◆ $ctrl

ilCtrl ilLocatorGUI::$ctrl
protected

Definition at line 33 of file class.ilLocatorGUI.php.

Referenced by addAdministrationItems(), and addRepositoryItems().

◆ $entries

array ilLocatorGUI::$entries = []
protected

Definition at line 38 of file class.ilLocatorGUI.php.

Referenced by getItems().

◆ $initialised

bool ilLocatorGUI::$initialised = false
protected

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

◆ $lng

ilLanguage ilLocatorGUI::$lng
protected

Definition at line 37 of file class.ilLocatorGUI.php.

Referenced by addAdministrationItems(), getHTML(), and init().

◆ $obj_definition

ilObjectDefinition ilLocatorGUI::$obj_definition
protected

Definition at line 34 of file class.ilLocatorGUI.php.

Referenced by addAdministrationItems().

◆ $offline

bool ilLocatorGUI::$offline = false
protected

Definition at line 31 of file class.ilLocatorGUI.php.

Referenced by getOffline().

◆ $ref_id

int ilLocatorGUI::$ref_id = null
protected

Definition at line 29 of file class.ilLocatorGUI.php.

Referenced by addAdministrationItems(), and addRepositoryItems().

◆ $settings

ilSetting ilLocatorGUI::$settings
protected

Definition at line 36 of file class.ilLocatorGUI.php.

Referenced by addRepositoryItems().

◆ $textonly

bool ilLocatorGUI::$textonly
protected

Definition at line 30 of file class.ilLocatorGUI.php.

Referenced by getTextOnly().

◆ $tree

ilTree ilLocatorGUI::$tree
protected

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