ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables 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)
 
 addItem (string $a_title, string $a_link, string $a_frame="", int $a_ref_id=0, ?string $type=null)
 
 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, ILIAS\LTI\ToolProvider\$key, $lng, $obj_definition, $path, $ref_id, $tree, addItem(), 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:32
string $key
Consumer key/client ID value.
Definition: System.php:193
addItem(string $a_title, string $a_link, string $a_frame="", int $a_ref_id=0, ?string $type=null)
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 ILIAS\LTI\ToolProvider\$key, $path, $tree, addItem(), CLIENT_ID, ilTree\getPathFull(), init(), and ILIAS\Repository\lng().

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:32
const CLIENT_ID
Definition: constants.php:41
string $key
Consumer key/client ID value.
Definition: System.php:193
addItem(string $a_title, string $a_link, string $a_frame="", int $a_ref_id=0, ?string $type=null)
+ Here is the call graph for this function:

◆ addItem()

ilLocatorGUI::addItem ( string  $a_title,
string  $a_link,
string  $a_frame = "",
int  $a_ref_id = 0,
?string  $type = null 
)

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

References $access, $DIC, $type, ilObjectGUI\ALLOWED_TAGS_IN_TITLE_AND_DESCRIPTION, and init().

Referenced by addAdministrationItems(), addContextItems(), ilObjContentObjectGUI\addLocations(), ilObjPortfolioBaseGUI\addLocatorItems(), ilContainerReferenceGUI\addLocatorItems(), ilObjectPluginGUI\addLocatorItems(), ilObjCmiXapiGUI\addLocatorItems(), ilObjFileBasedLMGUI\addLocatorItems(), ilObjBookingPoolGUI\addLocatorItems(), ilObjSurveyQuestionPoolGUI\addLocatorItems(), ilObjSurveyGUI\addLocatorItems(), ilObjExerciseGUI\addLocatorItems(), ilObjLTIConsumerGUI\addLocatorItems(), ilObjWikiGUI\addLocatorItems(), ilObjMediaCastGUI\addLocatorItems(), ilObjSessionGUI\addLocatorItems(), ilObjBlogGUI\addLocatorItems(), addRepositoryItems(), and ilObjSkillTreeGUI\showLocator().

260  : void {
261  // LTI
262  global $DIC;
263  $ltiview = $DIC['lti'];
264 
265  $this->init();
266 
267  $ilAccess = $this->access;
268 
269  if ($a_ref_id > 0 && !$ilAccess->checkAccess("visible", "", $a_ref_id)) {
270  return;
271  }
272  // LTI
273  if ($ltiview->isActive()) {
274  $a_frame = "_self";
275  }
276  $this->entries[] = array(
277  "title" => strip_tags(
278  $a_title,
280  ),
281  "link" => $a_link,
282  "frame" => $a_frame,
283  "ref_id" => $a_ref_id,
284  "type" => $type
285  );
286  }
$type
ilAccessHandler $access
global $DIC
Definition: feed.php:28
const ALLOWED_TAGS_IN_TITLE_AND_DESCRIPTION
+ Here is the call graph for this function:
+ Here is the caller 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, ILIAS\LTI\ToolProvider\$key, $path, $ref_id, $settings, $tree, ilFrameTargetInfo\_getFrame(), ilLink\_getLink(), ilContainer\_lookupContainerSetting(), ilObject\_lookupObjId(), addItem(), 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:32
static _lookupContainerSetting(int $a_id, string $a_keyword, string $a_default_value=null)
static _lookupObjId(int $ref_id)
string $key
Consumer key/client ID value.
Definition: System.php:193
addItem(string $a_title, string $a_link, string $a_frame="", int $a_ref_id=0, ?string $type=null)
static _getFrame(string $a_class)
+ Here is the call graph for this function:

◆ clearItems()

ilLocatorGUI::clearItems ( )

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

Referenced by ilObjSkillTreeGUI\showLocator().

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

◆ getHTML()

ilLocatorGUI::getHTML ( )

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

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

298  : string
299  {
300  $this->init();
301  $lng = $this->lng;
302  $icon_path = "";
303 
304  if ($this->getTextOnly()) {
305  $loc_tpl = new ilTemplate("tpl.locator_text_only.html", true, true, "Services/Locator");
306  } else {
307  $loc_tpl = new ilTemplate("tpl.locator.html", true, true, "Services/Locator");
308  }
309 
310  $items = $this->getItems();
311  $first = true;
312  if (count($items) > 0) {
313  foreach ($items as $item) {
314  if (!$first) {
315  $loc_tpl->touchBlock("locator_separator_prefix");
316  }
317 
318  if ($item["ref_id"] > 0) {
319  $obj_id = ilObject::_lookupObjId($item["ref_id"]);
320  $type = ilObject::_lookupType($obj_id);
321 
322  if (!$this->getTextOnly()) {
323  $icon_path = ilObject::_getIcon(
324  $obj_id,
325  "tiny",
326  $type,
327  $this->getOffline()
328  );
329  }
330 
331  $loc_tpl->setCurrentBlock("locator_img");
332  $loc_tpl->setVariable("IMG_SRC", $icon_path);
333  $loc_tpl->setVariable(
334  "IMG_ALT",
335  $lng->txt("obj_" . $type)
336  );
337  $loc_tpl->parseCurrentBlock();
338  }
339 
340  $loc_tpl->setCurrentBlock("locator_item");
341  if ($item["link"] != "") {
342  $loc_tpl->setVariable("LINK_ITEM", $item["link"]);
343  if ($item["frame"] != "") {
344  $loc_tpl->setVariable("LINK_TARGET", ' target="' . $item["frame"] . '" ');
345  }
346  $loc_tpl->setVariable("ITEM", $item["title"]);
347  } else {
348  $loc_tpl->setVariable("PREFIX", $item["title"]);
349  }
350  $loc_tpl->parseCurrentBlock();
351 
352  $first = false;
353  }
354  } else {
355  // $loc_tpl->setVariable("NOITEM", " ");
356  // $loc_tpl->touchBlock("locator");
357  }
358  $loc_tpl->setVariable("TXT_BREADCRUMBS", $lng->txt("breadcrumb_navigation"));
359 
360  return trim($loc_tpl->get());
361  }
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...
$type
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 293 of file class.ilLocatorGUI.php.

References $entries.

Referenced by getHTML(), and getTextVersion().

293  : array
294  {
295  return $this->entries;
296  }
+ 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 366 of file class.ilLocatorGUI.php.

References getItems(), and init().

366  : string
367  {
368  $this->init();
369  $items = $this->getItems();
370  $first = true;
371 
372  $str = "";
373  foreach ($items as $item) {
374  if (!$first) {
375  $str .= " > ";
376  }
377 
378  $str .= $item["title"];
379 
380  $first = false;
381  }
382 
383  return $str;
384  }
+ 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(), and ILIAS\Repository\settings().

Referenced by addAdministrationItems(), addContextItems(), addItem(), 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  }
global $DIC
Definition: feed.php:28
+ 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 addItem().

◆ $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: