ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ilMainMenuSearchGUI Class Reference

Add a search box to main menu. More...

+ Collaboration diagram for ilMainMenuSearchGUI:

Public Member Functions

 __construct ()
 
 getHTML ()
 
 getStandardSearchAction ()
 
 getUserSearchAction ()
 
 getAutocompleteSource ()
 

Protected Member Functions

 initRefIdFromQuery ()
 
 buildSearchLink (string $cmd)
 

Protected Attributes

ilTemplate $tpl = null
 
ilLanguage $lng
 
ilTree $tree
 
ilCtrl $ctrl
 
ilObjUser $user
 
ilGlobalTemplateInterface $global_template
 

Private Attributes

GlobalHttpState $http
 
Factory $refinery
 
int $ref_id
 

Detailed Description

Add a search box to main menu.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 32 of file class.ilMainMenuSearchGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilMainMenuSearchGUI::__construct ( )

Definition at line 47 of file class.ilMainMenuSearchGUI.php.

48 {
49 global $DIC;
50
51 $this->lng = $DIC->language();
52 $this->lng->loadLanguageModule("search");
53 $this->tree = $DIC->repositoryTree();
54 $this->ctrl = $DIC->ctrl();
55 $this->user = $DIC->user();
56
57 $this->http = $DIC->http();
58 $this->refinery = $DIC->refinery();
59 $this->global_template = $DIC->ui()->mainTemplate();
60
61 $this->initRefIdFromQuery();
62 }
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), initRefIdFromQuery(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ buildSearchLink()

ilMainMenuSearchGUI::buildSearchLink ( string  $cmd)
protected

Definition at line 133 of file class.ilMainMenuSearchGUI.php.

133 : string
134 {
135 return $this->ctrl->getLinkTargetByClass(
136 [strtolower(ilSearchControllerGUI::class), strtolower(ilSearchGUI::class)],
137 $cmd
138 );
139 }

References ILIAS\Repository\ctrl().

Referenced by getHTML(), and getStandardSearchAction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAutocompleteSource()

ilMainMenuSearchGUI::getAutocompleteSource ( )

Definition at line 154 of file class.ilMainMenuSearchGUI.php.

154 : string
155 {
156 return $this->ctrl->getLinkTargetByClass(
157 [strtolower(ilSearchControllerGUI::class)],
158 'autoComplete',
159 null,
160 true
161 );
162 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ getHTML()

ilMainMenuSearchGUI::getHTML ( )

Definition at line 75 of file class.ilMainMenuSearchGUI.php.

75 : string
76 {
78
79 $this->global_template->addJavaScript('assets/js/legacyAutocomplete.js', true, 3);
80 $this->global_template->addJavascript('assets/js/SearchMainMenu.js');
81
82 $this->tpl = new ilTemplate('tpl.main_menu_search.html', true, true, 'components/ILIAS/Search');
83 if ($this->user->getId() != ANONYMOUS_USER_ID) {
84 $this->tpl->setVariable('LABEL_SEARCH_OPTIONS', $this->lng->txt("label_search_options"));
85 if (ilSearchSettings::getInstance()->isLuceneUserSearchEnabled() || ($this->ref_id != ROOT_FOLDER_ID)) {
86 $this->tpl->setCurrentBlock("position");
87 $this->tpl->setVariable('TXT_GLOBALLY', $this->lng->txt("search_globally"));
88 $this->tpl->setVariable('ROOT_ID', ROOT_FOLDER_ID);
89 $this->tpl->parseCurrentBlock();
90 } else {
91 $this->tpl->setCurrentBlock("position_hid");
92 $this->tpl->setVariable('ROOT_ID_HID', ROOT_FOLDER_ID);
93 $this->tpl->parseCurrentBlock();
94 }
95 if ($this->ref_id != ROOT_FOLDER_ID) {
96 $this->tpl->setCurrentBlock('position_rep');
97 $this->tpl->setVariable('TXT_CURRENT_POSITION', $this->lng->txt("search_at_current_position"));
98 $this->tpl->setVariable('REF_ID', $this->ref_id);
99 $this->tpl->parseCurrentBlock();
100 }
101 }
102
103 if ($this->user->getId() != ANONYMOUS_USER_ID && ilSearchSettings::getInstance()->isLuceneUserSearchEnabled()) {
104 $this->tpl->setCurrentBlock('usr_search');
105 $this->tpl->setVariable('TXT_USR_SEARCH', $this->lng->txt('search_users'));
106 $this->tpl->setVariable('USER_SEARCH_ID', ilSearchControllerGUI::TYPE_USER_SEARCH);
107 $this->tpl->parseCurrentBlock();
108 }
109 $this->tpl->setVariable(
110 'FORMACTION',
111 $this->buildSearchLink('remoteSearch', false)
112 );
113 $this->tpl->setVariable('BTN_SEARCH', $this->lng->txt('search'));
114 $this->tpl->setVariable('SEARCH_INPUT_LABEL', $this->lng->txt('search_field'));
115
116 $this->tpl->setVariable('IMG_MM_SEARCH', ilUtil::img(
117 ilUtil::getImagePath("standard/icon_seas.svg"),
118 $this->lng->txt("search")
119 ));
120
121 if ($this->user->getId() != ANONYMOUS_USER_ID) {
122 $this->tpl->setVariable(
123 'HREF_SEARCH_LINK',
124 $this->buildSearchLink('')
125 );
126 $this->tpl->setVariable('TXT_SEARCH_LINK', $this->lng->txt("last_search_result"));
127 }
128 $this->tpl->setVariable('TXT_SEARCH', $this->lng->txt("search"));
129
130 return $this->tpl->get();
131 }
special template class to simplify handling of ITX/PEAR
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static img(string $a_src, ?string $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static initjQuery(?ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
const ANONYMOUS_USER_ID
Definition: constants.php:27
const ROOT_FOLDER_ID
Definition: constants.php:32

References ANONYMOUS_USER_ID, buildSearchLink(), ilUtil\getImagePath(), ilSearchSettings\getInstance(), ilUtil\img(), iljQueryUtil\initjQuery(), ILIAS\Repository\lng(), ROOT_FOLDER_ID, ilSearchControllerGUI\TYPE_USER_SEARCH, and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ getStandardSearchAction()

ilMainMenuSearchGUI::getStandardSearchAction ( )

Definition at line 141 of file class.ilMainMenuSearchGUI.php.

141 : string
142 {
143 return $this->buildSearchLink('remoteSearch');
144 }

References buildSearchLink().

+ Here is the call graph for this function:

◆ getUserSearchAction()

ilMainMenuSearchGUI::getUserSearchAction ( )

Definition at line 146 of file class.ilMainMenuSearchGUI.php.

146 : string
147 {
148 return $this->ctrl->getLinkTargetByClass(
149 [strtolower(ilSearchControllerGUI::class), strtolower(ilLuceneUserSearchGUI::class)],
150 'remoteSearch'
151 );
152 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ initRefIdFromQuery()

ilMainMenuSearchGUI::initRefIdFromQuery ( )
protected

Definition at line 64 of file class.ilMainMenuSearchGUI.php.

64 : void
65 {
66 $this->ref_id = ROOT_FOLDER_ID;
67 if ($this->http->wrapper()->query()->has('ref_id')) {
68 $this->ref_id = $this->http->wrapper()->query()->retrieve(
69 'ref_id',
70 $this->refinery->kindlyTo()->int()
71 );
72 }
73 }

References ILIAS\FileDelivery\http(), ILIAS\Repository\refinery(), and ROOT_FOLDER_ID.

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ilMainMenuSearchGUI::$ctrl
protected

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

◆ $global_template

ilGlobalTemplateInterface ilMainMenuSearchGUI::$global_template
protected

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

◆ $http

GlobalHttpState ilMainMenuSearchGUI::$http
private

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

◆ $lng

ilLanguage ilMainMenuSearchGUI::$lng
protected

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

◆ $ref_id

int ilMainMenuSearchGUI::$ref_id
private

Definition at line 45 of file class.ilMainMenuSearchGUI.php.

◆ $refinery

Factory ilMainMenuSearchGUI::$refinery
private

Definition at line 42 of file class.ilMainMenuSearchGUI.php.

◆ $tpl

ilTemplate ilMainMenuSearchGUI::$tpl = null
protected

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

◆ $tree

ilTree ilMainMenuSearchGUI::$tree
protected

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

◆ $user

ilObjUser ilMainMenuSearchGUI::$user
protected

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


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