ILIAS  release_7 Revision v7.30-3-g800a261c036
RepositoryMainBarProvider.php
Go to the documentation of this file.
2
9use ilLink;
10use ilObject;
11use ilUtil;
12use InvalidArgumentException;
13
28{
29
30
34 public function getStaticTopItems() : array
35 {
36 return [];
37 }
38
39
43 public function getStaticSubItems() : array
44 {
46 $f = $this->dic->ui()->factory();
47
48 $top = StandardTopItemsProvider::getInstance()->getRepositoryIdentification();
50
51 $title = $this->getHomeItem()->getTitle();
52 $icon = $this->dic->ui()->factory()->symbol()->icon()->standard(Standard::ROOT, $title)->withIsOutlined(true);
53
54 // Home
55 $entries[] = $this->getHomeItem()
56 ->withVisibilityCallable($access_helper->isRepositoryVisible())
57 ->withParent($top)
58 ->withSymbol($icon)
59 ->withPosition(10);
60
61 // Tree-View
62 $title = $this->dic->language()->txt("mm_rep_tree_view");
63
64 $icon = $this->dic->ui()->factory()->symbol()->icon()->custom(\ilUtil::getImagePath("outlined/icon_reptr.svg"), $title);
65
66 /*
67 if ($_GET["baseClass"] == "ilRepositoryGUI") {
68 $entries[] = $this->mainmenu->link($this->if->identifier('tree_view'))
69 ->withAction($link)
70 ->withParent($top)
71 ->withPosition(30)
72 ->withSymbol($icon)
73 ->withTitle($title);
74 }*/
75
77 $ref_id = (int) $_GET["ref_id"];
79 $asynch = ($top_node === 0);
80 $entries[]
81 = $this->mainmenu->complex($this->if->identifier('rep_tree_view'))
82 ->withVisibilityCallable($access_helper->isRepositoryVisible())
83 ->withContentWrapper(function () use ($ref_id) {
84 return $this->dic->ui()->factory()->legacy($this->renderRepoTree($ref_id));
85 })
86 ->withSupportsAsynchronousLoading($asynch)
87 ->withTitle($title)
88 ->withSymbol($icon)
89 ->withParent($top)
90 ->withPosition(20);
91
92 $icon = $this->dic->ui()->factory()->symbol()->icon()->custom(\ilUtil::getImagePath("outlined/icon_lstv.svg"), $title);
93
94 $p = $this;
95 $entries[] = $this->mainmenu
96 ->complex($this->if->identifier('last_visited'))
97 ->withTitle($this->dic->language()->txt('last_visited'))
98 ->withSupportsAsynchronousLoading(true)
99 ->withVisibilityCallable($access_helper->isUserLoggedIn($access_helper->isRepositoryReadable()))
100 ->withPosition(30)
101 ->withSymbol($icon)
102 ->withParent($top)
103 ->withContentWrapper(function () use ($p) {
104 return $this->dic->ui()->factory()->legacy($p->renderLastVisited());
105 });
106
107 $title = $this->dic->language()->txt("mm_favorites");
108 $icon = $this->dic->ui()->factory()->symbol()->icon()->custom(\ilUtil::getImagePath("outlined/icon_fav.svg"), $title);
109 $entries[] = $this->mainmenu->complex($this->if->identifier('mm_pd_sel_items'))
110 ->withSupportsAsynchronousLoading(true)
111 ->withTitle($title)
112 ->withSymbol($icon)
113 ->withContentWrapper(function () use ($f) {
114 $fav_list = new \ilFavouritesListGUI();
115
116 return $f->legacy($fav_list->render());
117 })
118 ->withParent(StandardTopItemsProvider::getInstance()->getPersonalWorkspaceIdentification())
119 ->withPosition(10)
120 ->withAvailableCallable(
121 function () use ($dic) {
122 return (bool) $dic->settings()->get('rep_favourites', "0");
123 }
124 )
125 ->withVisibilityCallable(
126 $access_helper->isUserLoggedIn($access_helper->isRepositoryReadable(
127 static function () use ($dic) : bool {
128 return true;
129 $pdItemsViewSettings = new ilPDSelectedItemsBlockViewSettings($dic->user());
130
131 return (bool) $pdItemsViewSettings->allViewsEnabled() || $pdItemsViewSettings->enabledSelectedItems();
132 }
133 ))
134 );
135
136 return $entries;
137 }
138
139
140 private function getHomeItem() : Link
141 {
143
144 $title = function () use ($dic) : string {
145 try {
146 $nd = $dic['tree']->getNodeData(ROOT_FOLDER_ID);
147 $title = ($nd["title"] === "ILIAS" ? $dic->language()->txt("repository") : $nd["title"]);
149 } catch (InvalidArgumentException $e) {
150 return "";
151 }
152
153 return $title . " - " . $dic->language()->txt("rep_main_page");
154 };
155
156 $action = function () : string {
157 try {
158 $static_link = ilLink::_getStaticLink(1, 'root', true);
159 } catch (InvalidArgumentException $e) {
160 return "";
161 }
162
163 return $static_link;
164 };
165
166 return $this->mainmenu->link($this->if->identifier('rep_main_page'))
167 ->withTitle($title())
168 ->withAction($action());
169 }
170
171
172
178 protected function renderLastVisited()
179 {
180 $nav_items = [];
181 if (isset($this->dic['ilNavigationHistory'])) {
182 $nav_items = $this->dic['ilNavigationHistory']->getItems();
183 }
184 reset($nav_items);
185 $cnt = 0;
186 $first = true;
187 $item_groups = [];
188 $items = [];
189
190 $f = $this->dic->ui()->factory();
191 foreach ($nav_items as $k => $nav_item) {
192 if ($cnt++ >= 10) {
193 break;
194 }
195
196 if (!isset($nav_item["ref_id"]) || !isset($_GET["ref_id"])
197 || ($nav_item["ref_id"] != $_GET["ref_id"] || !$first)
198 ) { // do not list current item
199 $ititle = ilUtil::shortenText(strip_tags($nav_item["title"]), 50, true); // #11023
200 $obj_id = ilObject::_lookupObjectId($nav_item["ref_id"]);
201 $items[] = $f->item()->standard(
202 $f->link()->standard($ititle, $nav_item["link"])
203 )->withLeadIcon($f->symbol()->icon()->custom(ilObject::_getIcon($obj_id), $ititle));
204 }
205 $first = false;
206 }
207
208 if (count($items) > 0) {
209 $item_groups[] = $f->item()->group("", $items);
210 $panel = $f->panel()->secondary()->listing("", $item_groups);
211 return $this->dic->ui()->renderer()->render([$panel]);
212 }
213
214 return $this->dic->ui()->renderer()->render($this->getNoLastVisitedMessage());
215 }
216
222 public function getNoLastVisitedMessage() : \ILIAS\UI\Component\MessageBox\MessageBox
223 {
224 global $DIC;
225
226 $lng = $DIC->language();
227 $ui = $DIC->ui();
228 $lng->loadLanguageModule("rep");
229 $txt = $lng->txt("rep_no_last_visited_mess");
230 $mbox = $ui->factory()->messageBox()->info($txt);
231
232 return $mbox;
233 }
234
235
236
242 protected function renderRepoTree(int $ref_id)
243 {
244 global $DIC;
245 $tree = $DIC->repositoryTree();
246 if ($_GET["baseClass"] == "ilAdministrationGUI" || $ref_id <= 0 || !$tree->isInTree($ref_id)) {
247 $ref_id = $tree->readRootId();
248 }
249 $DIC->ctrl()->setParameterByClass("ilrepositorygui", "ref_id", $ref_id);
250 $exp = new \ilRepositoryExplorerGUI("ilrepositorygui", "showRepTree");
251 $exp->setSkipRootNode(true);
252 return $exp->getHTML()."<script>".$exp->getOnLoadCode()."</script>";
253 }
254}
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
static init($a_main_tpl=null)
Init JS.
Class ilObject Basic functions for all objects.
static _lookupObjId($a_id)
static _lookupObjectId($a_ref_id)
lookup object id
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
@noRector
static img($a_src, $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
if(!file_exists(getcwd() . '/ilias.ini.php'))
registration confirmation script for ilias
Definition: confirmReg.php:12
const ROOT_FOLDER_ID
Definition: constants.php:30
$nd
Definition: error.php:12
$txt
Definition: error.php:13
global $DIC
Definition: goto.php:24
if(isset($_FILES['img_file']) &&is_array($_FILES['img_file'])) $panel
Definition: imgupload.php:138
This describes the specific behavior of an ILIAS standard icon.
Definition: Standard.php:11
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.
$lng