ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
SearchMetaBarProvider.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
29
35class SearchMetaBarProvider extends AbstractStaticMetaBarProvider implements StaticMetaBarProvider
36{
40 private function getId(): IdentificationInterface
41 {
42 return $this->if->identifier('search');
43 }
44
45
49 public function getAllIdentifications(): array
50 {
51 return [$this->getId()];
52 }
53
54
58 public function getMetaBarItems(): array
59 {
60 $content = function () {
61 $main_search = new ilMainMenuSearchGUI();
62 $html = "";
63
64 // user interface plugin slot + default rendering
65 $uip = new ilUIHookProcessor(
66 "components/ILIAS/MainMenu",
67 "main_menu_search",
68 array("main_menu_gui" => $this, "main_menu_search_gui" => $main_search)
69 );
70 if (!$uip->replaced()) {
71 $html = $main_search->getHTML();
72 }
73
74 $ac_datasource = $main_search->getAutocompleteSource();
75 $standard_search_action = $main_search->getStandardSearchAction();
76 $user_search_action = $main_search->getUserSearchAction();
77
78 return $this->dic->ui()->factory()->legacy()->content($uip->getHTML($html))->withAdditionalOnLoadCode(
79 fn($id) => <<<JS
80 il.SearchMainMenu.init(
81 "$ac_datasource",
82 "$standard_search_action",
83 "$user_search_action"
84 )
85 JS
86 );
87 };
88
89 $mb = $this->globalScreen()->metaBar();
90
91 $item = $mb
92 ->topLegacyItem($this->getId())
93 ->withLegacyContent($content())
94 ->withSymbol($this->dic->ui()->factory()->symbol()->glyph()->search())
95 ->withTitle($this->dic->language()->txt("search"))
96 ->withPosition(2)
97 ->withAvailableCallable(
98 function () {
99 return $this->dic->rbac()->system()->checkAccess('search', ilSearchSettings::_getSearchSettingRefId());
100 }
101 );
102
103 return [$item];
104 }
105}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Add a search box to main menu.
static _getSearchSettingRefId()
Read the ref_id of Search Settings object.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...