ILIAS  release_8 Revision v8.24
class.ilSearchControllerGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
23
36{
37 public const TYPE_USER_SEARCH = -1;
38 protected ilObjUser $user;
39
40 protected ilCtrl $ctrl;
41 protected ILIAS $ilias;
42 protected ilLanguage $lng;
46 protected Factory $refinery;
47
48
53 public function __construct()
54 {
55 global $DIC;
56
57 $this->ctrl = $DIC->ctrl();
58 $this->ilias = $DIC['ilias'];
59 $this->lng = $DIC->language();
60 $this->tpl = $DIC->ui()->mainTemplate();
61 $this->system = $DIC->rbac()->system();
62 $this->http = $DIC->http();
63 $this->refinery = $DIC->refinery();
64 $this->user = $DIC->user();
65 }
66
67 public function getLastClass(): string
68 {
69 if (ilSearchSettings::getInstance()->enabledLucene()) {
70 $default = 'illucenesearchgui';
71 } else {
72 $default = 'ilsearchgui';
73 }
74
75 $root_id = 0;
76 if ($this->http->wrapper()->post()->has('root_id')) {
77 $root_id = $this->http->wrapper()->post()->retrieve(
78 'root_id',
79 $this->refinery->kindlyTo()->int()
80 );
81 }
82 if ($root_id == self::TYPE_USER_SEARCH) {
83 $default = 'illuceneusersearchgui';
84 }
85
86 $this->setLastClass($default);
87 return ilSession::get('search_last_class') ?? $default;
88 }
89 public function setLastClass(string $a_class): void
90 {
91 ilSession::set('search_last_class', $a_class);
92 }
93
94 public function setCmdClass(string $a_cmd_class): void
95 {
96 if ($this->ctrl->getNextClass($this) === '') {
97 $this->ctrl->setCmdClass($a_cmd_class);
98 }
99 }
100
101 public function executeCommand(): void
102 {
103 // Check hacks
104 if (!$this->system->checkAccess('search', ilSearchSettings::_getSearchSettingRefId())) {
105 $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE);
106 }
107 $forward_class = $this->ctrl->getNextClass($this) ? $this->ctrl->getNextClass($this) : $this->getLastClass();
108 switch ($forward_class) {
109 case 'illucenesearchgui':
110 $this->setLastClass('illucenesearchgui');
111 $this->setCmdClass(ilLuceneSearchGUI::class);
112 $this->ctrl->forwardCommand(new ilLuceneSearchGUI());
113 break;
114
115 case 'illuceneadvancedsearchgui':
116 $this->setLastClass('illuceneadvancedsearchgui');
117 $this->setCmdClass(ilLuceneAdvancedSearchGUI::class);
118 $this->ctrl->forwardCommand(new ilLuceneAdvancedSearchGUI());
119 break;
120
121 case 'illuceneusersearchgui':
122 if ($this->user->getId() === ANONYMOUS_USER_ID) {
123 $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE);
124 }
125 $this->setLastClass('illuceneusersearchgui');
126 $this->setCmdClass(ilLuceneUserSearchGUI::class);
127 $this->ctrl->forwardCommand(new ilLuceneUserSearchGUI());
128 break;
129
130 case 'iladvancedsearchgui':
131 // Remember last class
132 $this->setLastClass('iladvancedsearchgui');
133 $this->setCmdClass(ilAdvancedSearchGUI::class);
134 $this->ctrl->forwardCommand(new ilAdvancedSearchGUI());
135 break;
136
137 case 'ilsearchgui':
138 // Remember last class
139 $this->setLastClass('ilsearchgui');
140 // no break
141 default:
142 $search_gui = new ilSearchGUI();
143 $this->setCmdClass(ilSearchGUI::class);
144 $this->ctrl->forwardCommand($search_gui);
145 break;
146 }
147 $this->tpl->printToStdout();
148 }
149}
Builds data types.
Definition: Factory.php:21
Class ilCtrl provides processing control methods.
language handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
@classDescription GUI for Lucene user search
User class.
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
__construct()
Constructor @access public.
ilGlobalTemplateInterface $tpl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getSearchSettingRefId()
Read the ref_id of Search Settings object.
static get(string $a_var)
static set(string $a_var, $a_val)
Set a value.
const ANONYMOUS_USER_ID
Definition: constants.php:27
global $DIC
Definition: feed.php:28
Interface GlobalHttpState.
Interface ilCtrlBaseClassInterface describes ilCtrl base classes.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.
Class ChatMainBarProvider \MainMenu\Provider.
header include for all ilias files.