ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilLuceneUserSearchGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once './Services/Search/classes/class.ilSearchSettings.php';
5include_once './Services/Search/classes/class.ilSearchBaseGUI.php';
6include_once './Services/Search/classes/Lucene/class.ilLuceneAdvancedSearchFields.php';
7
8
21{
22 protected $ilTabs;
23
27 public function __construct()
28 {
29 global $ilTabs;
30
31 $this->tabs_gui = $ilTabs;
32 parent::__construct();
33 $this->initUserSearchCache();
34 }
35
39 public function executeCommand()
40 {
41 global $ilBench, $ilCtrl;
42
43 $next_class = $this->ctrl->getNextClass($this);
44 $cmd = $this->ctrl->getCmd();
45
46 $this->prepareOutput();
47 switch ($next_class) {
48 case "ilpublicuserprofilegui":
49 include_once('./Services/User/classes/class.ilPublicUserProfileGUI.php');
50 $profile = new ilPublicUserProfileGUI((int) $_REQUEST['user']);
51 $profile->setBackUrl($this->ctrl->getLinkTarget($this, 'showSavedResults'));
52 $ret = $ilCtrl->forwardCommand($profile);
53 $GLOBALS['tpl']->setContent($ret);
54 break;
55
56
57 default:
59 if (!$cmd) {
60 $cmd = "showSavedResults";
61 }
62 $this->handleCommand($cmd);
63 break;
64 }
65 return true;
66 }
67
72 public function prepareOutput()
73 {
74 parent::prepareOutput();
75 $this->getTabs();
76 return true;
77 }
78
79
80
86 protected function getType()
87 {
88 if (count($this->search_cache)) {
90 }
92 }
93
99 protected function getDetails()
100 {
101 return (array) $this->search_cache->getItemFilter();
102 }
103
104
108 protected function remoteSearch()
109 {
110 $_POST['query'] = $_POST['queryString'];
111 $this->search_cache->setRoot((int) $_POST['root_id']);
112 $this->search_cache->setQuery(ilUtil::stripSlashes($_POST['queryString']));
113 $this->search_cache->save();
114
115 $this->search();
116 }
117
122 protected function showSavedResults()
123 {
124 global $ilUser,$ilBench;
125
126 if (strlen($this->search_cache->getQuery())) {
127 return $this->performSearch();
128 }
129
130 return $this->showSearchForm();
131 }
132
137 protected function search()
138 {
139 if (!$this->form->checkInput()) {
140 $this->search_cache->deleteCachedEntries();
141 // Reset details
142 include_once './Services/Object/classes/class.ilSubItemListGUI.php';
144 $this->showSearchForm();
145 return false;
146 }
147
148 unset($_SESSION['max_page']);
149 $this->search_cache->deleteCachedEntries();
150
151 // Reset details
152 include_once './Services/Object/classes/class.ilSubItemListGUI.php';
154
155 $this->performSearch();
156 }
157
161 protected function performSearch()
162 {
163 include_once './Services/Search/classes/Lucene/class.ilLuceneSearcher.php';
164 include_once './Services/Search/classes/Lucene/class.ilLuceneQueryParser.php';
165 $qp = new ilLuceneQueryParser($this->search_cache->getQuery());
166 $qp->parse();
167 $searcher = ilLuceneSearcher::getInstance($qp);
168 $searcher->setType(ilLuceneSearcher::TYPE_USER);
169 $searcher->search();
170
171 $this->showSearchForm();
172
173 include_once './Services/Search/classes/class.ilRepositoryUserResultTableGUI.php';
174 $user_table = new ilRepositoryUserResultTableGUI(
175 $this,
176 'performSearch',
177 false,
179 );
180 $user_table->setLuceneResult($searcher->getResult());
181 $user_table->parseUserIds($searcher->getResult()->getCandidates());
182
183 $GLOBALS['tpl']->setVariable('SEARCH_RESULTS', $user_table->getHTML());
184
185 return true;
186 }
187
191 protected function getTabs()
192 {
193 global $ilHelp;
194
195 $ilHelp->setScreenIdComponent("src_luc");
196
197 $this->tabs_gui->addTarget('search', $this->ctrl->getLinkTargetByClass('illucenesearchgui'));
198
199 if (ilSearchSettings::getInstance()->isLuceneUserSearchEnabled()) {
200 $this->tabs_gui->addTarget('search_user', $this->ctrl->getLinkTargetByClass('illuceneusersearchgui'));
201 }
202
204
205 if (
206 !ilSearchSettings::getInstance()->getHideAdvancedSearch() and
207 $fields->getActiveFields()) {
208 $this->tabs_gui->addTarget('search_advanced', $this->ctrl->getLinkTargetByClass('illuceneadvancedsearchgui'));
209 }
210
211 $this->tabs_gui->setTabActive('search_user');
212 }
213
220 protected function initUserSearchCache()
221 {
222 global $ilUser;
223
224 include_once('Services/Search/classes/class.ilUserSearchCache.php');
225 $this->search_cache = ilUserSearchCache::_getInstance($ilUser->getId());
226 $this->search_cache->switchSearchType(ilUserSearchCache::LUCENE_USER_SEARCH);
227 if ((int) $_GET['page_number']) {
228 $this->search_cache->setResultPageNumber((int) $_GET['page_number']);
229 }
230 if (isset($_POST['term'])) {
231 $this->search_cache->setQuery(ilUtil::stripSlashes($_POST['term']));
232 $this->search_cache->setItemFilter(array());
233 $this->search_cache->setMimeFilter(array());
234 $this->search_cache->save();
235 }
236 }
237
238
239
244 protected function showSearchForm()
245 {
246 global $ilCtrl, $lng;
247
248 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.lucene_usr_search.html', 'Services/Search');
249
250 // include js needed
251 include_once("./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php");
253 $this->tpl->addJavascript("./Services/Search/js/Search.js");
254
255 $this->tpl->setVariable('FORM_ACTION', $GLOBALS['ilCtrl']->getFormAction($this, 'performSearch'));
256 $this->tpl->setVariable("TERM", ilUtil::prepareFormOutput($this->search_cache->getQuery()));
257 include_once("./Services/UIComponent/Button/classes/class.ilSubmitButton.php");
259 $btn->setCommand("performSearch");
260 $btn->setCaption("search");
261 $this->tpl->setVariable("SUBMIT_BTN", $btn->render());
262
263 return true;
264 }
265}
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
static getInstance()
Get singleton instance.
static getInstance(ilLuceneQueryParser $qp)
Get singleton instance.
@classDescription GUI for Lucene user search
initUserSearchCache()
Init user search cache.
getType()
Get type of search (details | fast)
showSavedResults()
Show saved results.
prepareOutput()
Add admin panel command.
search()
Search (button pressed)
getDetails()
Needed for base class search form.
remoteSearch()
Search from main menu.
static initJavascript()
Init javascript.
GUI class for public user profile presentation.
initStandardSearchForm($a_mode)
Init standard search form.
handleCommand($a_cmd)
Handle command.
static resetDetails()
reset details As long as static::resetDetails is not possible this method is final
static getInstance()
Factory.
static _getInstance($a_usr_id)
Get singleton instance.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $ilBench
Definition: ilias.php:18
global $ilCtrl
Definition: ilias.php:18
$ret
Definition: parser.php:6
$ilUser
Definition: imgupload.php:18