ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 $DIC;
30
31 $ilTabs = $DIC['ilTabs'];
32
33 $this->tabs_gui = $ilTabs;
35 $this->initUserSearchCache();
36 }
37
41 public function executeCommand()
42 {
43 global $DIC;
44
45 $ilBench = $DIC['ilBench'];
46 $ilCtrl = $DIC['ilCtrl'];
47
48 $next_class = $this->ctrl->getNextClass($this);
49 $cmd = $this->ctrl->getCmd();
50
51 $this->prepareOutput();
52 switch ($next_class) {
53 case "ilpublicuserprofilegui":
54 include_once('./Services/User/classes/class.ilPublicUserProfileGUI.php');
55 $profile = new ilPublicUserProfileGUI((int) $_REQUEST['user']);
56 $profile->setBackUrl($this->ctrl->getLinkTarget($this, 'showSavedResults'));
57 $ret = $ilCtrl->forwardCommand($profile);
58 $GLOBALS['DIC']['tpl']->setContent($ret);
59 break;
60
61
62 default:
64 if (!$cmd) {
65 $cmd = "showSavedResults";
66 }
67 $this->handleCommand($cmd);
68 break;
69 }
70 return true;
71 }
72
77 public function prepareOutput()
78 {
79 parent::prepareOutput();
80 $this->getTabs();
81 return true;
82 }
83
84
85
91 protected function getType()
92 {
93 if (count($this->search_cache)) {
95 }
97 }
98
104 protected function getDetails()
105 {
106 return (array) $this->search_cache->getItemFilter();
107 }
108
109
113 protected function remoteSearch()
114 {
115 $_POST['query'] = $_POST['queryString'];
116 $this->search_cache->setRoot((int) $_POST['root_id']);
117 $this->search_cache->setQuery(ilUtil::stripSlashes($_POST['queryString']));
118 $this->search_cache->save();
119
120 $this->search();
121 }
122
127 protected function showSavedResults()
128 {
129 global $DIC;
130
131 $ilUser = $DIC['ilUser'];
132 $ilBench = $DIC['ilBench'];
133
134 if (strlen($this->search_cache->getQuery())) {
135 return $this->performSearch();
136 }
137
138 return $this->showSearchForm();
139 }
140
145 protected function search()
146 {
147 if (!$this->form->checkInput()) {
148 $this->search_cache->deleteCachedEntries();
149 // Reset details
150 include_once './Services/Object/classes/class.ilSubItemListGUI.php';
152 $this->showSearchForm();
153 return false;
154 }
155
156 unset($_SESSION['max_page']);
157 $this->search_cache->deleteCachedEntries();
158
159 // Reset details
160 include_once './Services/Object/classes/class.ilSubItemListGUI.php';
162
163 $this->performSearch();
164 }
165
169 protected function performSearch()
170 {
171 include_once './Services/Search/classes/Lucene/class.ilLuceneSearcher.php';
172 include_once './Services/Search/classes/Lucene/class.ilLuceneQueryParser.php';
173 $qp = new ilLuceneQueryParser($this->search_cache->getQuery());
174 $qp->parse();
175 $searcher = ilLuceneSearcher::getInstance($qp);
176 $searcher->setType(ilLuceneSearcher::TYPE_USER);
177 $searcher->search();
178
179 $this->showSearchForm();
180
181 include_once './Services/Search/classes/class.ilRepositoryUserResultTableGUI.php';
182 $user_table = new ilRepositoryUserResultTableGUI(
183 $this,
184 'performSearch',
185 false,
187 );
188 $user_table->setLuceneResult($searcher->getResult());
189 $user_table->parseUserIds($searcher->getResult()->getCandidates());
190
191 $GLOBALS['DIC']['tpl']->setVariable('SEARCH_RESULTS', $user_table->getHTML());
192
193 return true;
194 }
195
199 protected function getTabs()
200 {
201 global $DIC;
202
203 $ilHelp = $DIC['ilHelp'];
204
205 $ilHelp->setScreenIdComponent("src_luc");
206
207 $this->tabs_gui->addTarget('search', $this->ctrl->getLinkTargetByClass('illucenesearchgui'));
208
209 if (ilSearchSettings::getInstance()->isLuceneUserSearchEnabled()) {
210 $this->tabs_gui->addTarget('search_user', $this->ctrl->getLinkTargetByClass('illuceneusersearchgui'));
211 }
212
214
215 if (
216 !ilSearchSettings::getInstance()->getHideAdvancedSearch() and
217 $fields->getActiveFields()) {
218 $this->tabs_gui->addTarget('search_advanced', $this->ctrl->getLinkTargetByClass('illuceneadvancedsearchgui'));
219 }
220
221 $this->tabs_gui->setTabActive('search_user');
222 }
223
230 protected function initUserSearchCache()
231 {
232 global $DIC;
233
234 $ilUser = $DIC['ilUser'];
235
236 include_once('Services/Search/classes/class.ilUserSearchCache.php');
237 $this->search_cache = ilUserSearchCache::_getInstance($ilUser->getId());
238 $this->search_cache->switchSearchType(ilUserSearchCache::LUCENE_USER_SEARCH);
239 if ((int) $_GET['page_number']) {
240 $this->search_cache->setResultPageNumber((int) $_GET['page_number']);
241 }
242 if (isset($_POST['term'])) {
243 $this->search_cache->setQuery(ilUtil::stripSlashes($_POST['term']));
244 $this->search_cache->setItemFilter(array());
245 $this->search_cache->setMimeFilter(array());
246 $this->search_cache->save();
247 }
248 }
249
250
251
256 protected function showSearchForm()
257 {
258 global $DIC;
259
260 $ilCtrl = $DIC['ilCtrl'];
261 $lng = $DIC['lng'];
262
263 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.lucene_usr_search.html', 'Services/Search');
264
265 // include js needed
266 include_once("./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php");
268 $this->tpl->addJavascript("./Services/Search/js/Search.js");
269
270 $this->tpl->setVariable('FORM_ACTION', $GLOBALS['DIC']['ilCtrl']->getFormAction($this, 'performSearch'));
271 $this->tpl->setVariable("TERM", ilUtil::prepareFormOutput($this->search_cache->getQuery()));
272 $this->tpl->setVariable("SEARCH_LABEL", $lng->txt("search"));
273 include_once("./Services/UIComponent/Button/classes/class.ilSubmitButton.php");
275 $btn->setCommand("performSearch");
276 $btn->setCaption("search");
277 $this->tpl->setVariable("SUBMIT_BTN", $btn->render());
278
279 return true;
280 }
281}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$_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
global $ilBench
Definition: ilias.php:18
global $ilCtrl
Definition: ilias.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ret
Definition: parser.php:6
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46