ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilRepositoryGlobalScreenProvider.php
Go to the documentation of this file.
1 <?php
2 
5 
12 {
13 
17  protected $top_item;
18 
19 
25  public function __construct(\ILIAS\DI\Container $dic)
26  {
27  parent::__construct($dic);
28  $this->top_item = $this->if->identifier('rep');
29  }
30 
31 
39  public function getTopItem() : IdentificationInterface
40  {
41  return $this->top_item;
42  }
43 
44 
48  public function getStaticTopItems() : array
49  {
50  $dic = $this->dic;
51 
52  return [$this->mainmenu->topParentItem($this->getTopItem())
53  ->withTitle($this->dic->language()->txt("repository"))
54  ->withPosition(2)
55  ->withVisibilityCallable(
56  function () use ($dic) {
57  return (bool) ($dic->access()->checkAccess('visible', '', ROOT_FOLDER_ID));
58  }
59  )];
60  }
61 
62 
66  public function getStaticSubItems() : array
67  {
68  $dic = $this->dic;
69 
70  $title = function () use ($dic) : string {
71  try {
72  $nd = $dic['tree']->getNodeData(ROOT_FOLDER_ID);
73  $title = ($nd["title"] === "ILIAS" ? $dic->language()->txt("repository") : $nd["title"]);
74  $icon = ilUtil::img(ilObject::_getIcon(ilObject::_lookupObjId(1), "tiny"));
75  } catch (InvalidArgumentException $e) {
76  return "";
77  }
78 
79  return $title . " - " . $dic->language()->txt("rep_main_page");
80  };
81 
82  $action = function () : string {
83  try {
84  $static_link = ilLink::_getStaticLink(1, 'root', true);
85  } catch (InvalidArgumentException $e) {
86  return "";
87  }
88 
89  return $static_link;
90  };
91 
92  $entries[] = $this->mainmenu->link($this->if->identifier('rep_main_page'))
93  ->withTitle($title())
94  ->withAction($action())
95  ->withParent($this->getTopItem());
96 
97  // LastVisited
98  $links = function () : array {
99  $items = [];
100  if (isset($this->dic['ilNavigationHistory'])) {
101  $items = $this->dic['ilNavigationHistory']->getItems();
102  }
103  $links = [];
104  reset($items);
105  $cnt = 0;
106  $first = true;
107 
108  foreach ($items as $k => $item) {
109  if ($cnt >= 10) {
110  break;
111  }
112 
113  if (!isset($item["ref_id"]) || !isset($_GET["ref_id"])
114  || ($item["ref_id"] != $_GET["ref_id"] || !$first)
115  ) { // do not list current item
116  $obj_id = ilObject::_lookupObjId($item["ref_id"]);
117  $icon = ilUtil::img(ilObject::_getIcon($obj_id, "tiny"), $this->dic->language()->txt("obj_".
118  ilObject::_lookupType($obj_id)));
119  $ititle = ilUtil::shortenText(strip_tags($item["title"]), 50, true); // #11023
120  $links[] = $this->mainmenu->link($this->if->identifier('last_visited_' . $obj_id))
121  ->withTitle($icon . " " . $ititle)
122  ->withAction($item["link"]);
123  }
124  $first = false;
125  }
126 
127  return $links;
128  };
129  $entries[] = $this->mainmenu->linkList($this->if->identifier('last_visited'))
130  ->withLinks($links)
131  ->withTitle($this->dic->language()->txt('last_visited'))
132  ->withParent($this->getTopItem())->withVisibilityCallable(
133  function () use ($dic) {
134  return ($dic->user()->getId() != ANONYMOUS_USER_ID);
135  }
136  );
137 
138  return $entries;
139  }
140 }
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
$action
__construct(\ILIAS\DI\Container $dic)
ilRepositoryGlobalScreenProvider constructor.
$_GET["client_id"]
Class BaseForm.
$nd
Definition: error.php:10
if(!file_exists(getcwd() . '/ilias.ini.php'))
registration confirmation script for ilias
Definition: confirmReg.php:12
Class HTTPServicesTest.
static _lookupObjId($a_id)
static img($a_src, $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static _lookupType($a_id, $a_reference=false)
lookup object type
$links
getTopItem()
Some other components want to provide Items for the main menu which are located at the PD TopTitem by...
Class ilRepositoryGlobalScreenProvider.