ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilLuceneAdvancedSearchGUI Class Reference

Meta Data search GUI. More...

+ Inheritance diagram for ilLuceneAdvancedSearchGUI:
+ Collaboration diagram for ilLuceneAdvancedSearchGUI:

Public Member Functions

 __construct ()
 Constructor. More...
 
 executeCommand ()
 Execute Command. More...
 
 showSavedResults ()
 Show saved results. More...
 
 prepareOutput ()
 Add admin panel command. More...
 
- Public Member Functions inherited from ilSearchBaseGUI
 __construct ()
 Constructor public. More...
 
 prepareOutput ()
 
 initStandardSearchForm ($a_mode)
 Init standard search form. More...
 
 getSearchAreaForm ()
 Init standard search form. More...
 
 handleCommand ($a_cmd)
 Handle command. More...
 
 addToDeskObject ()
 Interface methods. More...
 
 removeFromDeskObject ()
 Remove from dektop. More...
 
 delete ()
 Show deletion screen. More...
 
 cancelDelete ()
 Cancel delete. More...
 
 cancelMoveLinkObject ()
 Cancel move/link. More...
 
 performDelete ()
 Delete objects. More...
 
 cut ()
 Interface ilAdministrationCommandHandler. More...
 
 link ()
 Interface ilAdministrationCommandHandler. More...
 
 paste ()
 Paste. More...
 
 showLinkIntoMultipleObjectsTree ()
 Target selection link. More...
 
 showMoveIntoObjectTree ()
 Target selection cut. More...
 
 performPasteIntoMultipleObjects ()
 Perform paste into multiple objects. More...
 
 clear ()
 clear clipboard More...
 
 enableAdministrationPanel ()
 Enable administration panel. More...
 
 disableAdministrationPanel ()
 Disable administration panel. More...
 
 keepObjectsInClipboardObject ()
 cancel action but keep objects in clipboard
Returns
void
More...
 
 addLocator ()
 Add Locator. More...
 
 autoComplete ()
 Data resource for autoComplete. More...
 

Protected Member Functions

 initFormSearch ()
 Show search form. More...
 
 remoteSearch ()
 Search from main menu. More...
 
 search ()
 
 reset ()
 Reset search form. More...
 
 performSearch ()
 Perform search. More...
 
 getTabs ()
 get tabs More...
 
 initUserSearchCache ()
 Init user search cache. More...
 
 fillAdminPanel ()
 
 addAdminPanelCommand ($a_cmd, $a_txt)
 Add a command to the admin panel. More...
 
 setAdminViewButton ($a_link, $a_txt)
 Show admin view button. More...
 
 setPageFormAction ($a_action)
 
- Protected Member Functions inherited from ilSearchBaseGUI
 addPager ($result, $a_session_key)
 Add Pager. More...
 
 buildSearchAreaPath ($a_root_node)
 Build path for search area. More...
 
 getCreationDateForm ()
 
 getSearchCache ()
 Get user search cache. More...
 
 loadCreationFilter ()
 Load creation date filter. More...
 

Protected Attributes

 $ilTabs
 
 $fields = null
 
- Protected Attributes inherited from ilSearchBaseGUI
 $settings = null
 
 $ctrl = null
 

Additional Inherited Members

- Data Fields inherited from ilSearchBaseGUI
const SEARCH_FAST = 1
 
const SEARCH_DETAILS = 2
 
const SEARCH_AND = 'and'
 
const SEARCH_OR = 'or'
 
const SEARCH_FORM_LUCENE = 1
 
const SEARCH_FORM_STANDARD = 2
 
const SEARCH_FORM_USER = 3
 
 $ilias = null
 
 $lng = null
 
 $tpl = null
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilLuceneAdvancedSearchGUI::__construct ( )

Constructor.

Definition at line 51 of file class.ilLuceneAdvancedSearchGUI.php.

References $ilTabs, fields, ilLuceneAdvancedSearchFields\getInstance(), and initUserSearchCache().

52  {
53  global $ilTabs;
54 
55  $this->tabs_gui = $ilTabs;
56  parent::__construct();
57 
59  $this->initUserSearchCache();
60  }
$errors fields
Definition: imgupload.php:51
initUserSearchCache()
Init user search cache.
static getInstance()
Get singleton instance.
+ Here is the call graph for this function:

Member Function Documentation

◆ addAdminPanelCommand()

ilLuceneAdvancedSearchGUI::addAdminPanelCommand (   $a_cmd,
  $a_txt 
)
protected

Add a command to the admin panel.

Definition at line 407 of file class.ilLuceneAdvancedSearchGUI.php.

References array.

408  {
409  $this->admin_panel_commands[] =
410  array("cmd" => $a_cmd, "txt" => $a_txt);
411  }
Create styles array
The data for the language used.

◆ executeCommand()

ilLuceneAdvancedSearchGUI::executeCommand ( )

Execute Command.

Definition at line 65 of file class.ilLuceneAdvancedSearchGUI.php.

References ilSearchBaseGUI\handleCommand(), and prepareOutput().

66  {
67  $next_class = $this->ctrl->getNextClass($this);
68  $cmd = $this->ctrl->getCmd();
69 
70  $this->prepareOutput();
71  switch ($next_class) {
72  case 'ilobjectcopygui':
73  $this->ctrl->setReturn($this);
74  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
75  $cp = new ilObjectCopyGUI($this, '');
76  $this->ctrl->forwardCommand($cp);
77  break;
78 
79 
80  default:
81  if (!$cmd) {
82  $cmd = "showSavedResults";
83  }
84  $this->handleCommand($cmd);
85  break;
86  }
87  return true;
88  }
GUI class for the workflow of copying objects.
prepareOutput()
Add admin panel command.
handleCommand($a_cmd)
Handle command.
+ Here is the call graph for this function:

◆ fillAdminPanel()

ilLuceneAdvancedSearchGUI::fillAdminPanel ( )
protected

Definition at line 330 of file class.ilLuceneAdvancedSearchGUI.php.

References ilSearchBaseGUI\$lng, and ilUtil\getImagePath().

Referenced by performSearch(), and showSavedResults().

331  {
332  global $lng;
333 
334  $adm_view_cmp = $adm_cmds = $creation_selector = $adm_view = false;
335 
336  // admin panel commands
337  if ((count($this->admin_panel_commands) > 0)) {
338  foreach ($this->admin_panel_commands as $cmd) {
339  $this->tpl->setCurrentBlock("lucene_admin_panel_cmd");
340  $this->tpl->setVariable("LUCENE_PANEL_CMD", $cmd["cmd"]);
341  $this->tpl->setVariable("LUCENE_TXT_PANEL_CMD", $cmd["txt"]);
342  $this->tpl->parseCurrentBlock();
343  }
344 
345  $adm_cmds = true;
346  }
347  if ($adm_cmds) {
348  $this->tpl->setCurrentBlock("lucene_adm_view_components");
349  $this->tpl->setVariable("LUCENE_ADM_IMG_ARROW", ilUtil::getImagePath("arrow_upright.svg"));
350  $this->tpl->setVariable("LUCENE_ADM_ALT_ARROW", $lng->txt("actions"));
351  $this->tpl->parseCurrentBlock();
352  $adm_view_cmp = true;
353  }
354 
355  // admin view button
356  if (is_array($this->admin_view_button)) {
357  if (is_array($this->admin_view_button)) {
358  $this->tpl->setCurrentBlock("lucene_admin_button");
359  $this->tpl->setVariable(
360  "LUCENE_ADMIN_MODE_LINK",
361  $this->admin_view_button["link"]
362  );
363  $this->tpl->setVariable(
364  "LUCENE_TXT_ADMIN_MODE",
365  $this->admin_view_button["txt"]
366  );
367  $this->tpl->parseCurrentBlock();
368  }
369  $this->tpl->setCurrentBlock("lucene_admin_view");
370  $this->tpl->parseCurrentBlock();
371  $adm_view = true;
372  }
373 
374  // creation selector
375  if (is_array($this->creation_selector)) {
376  $this->tpl->setCurrentBlock("lucene_add_commands");
377  if ($adm_cmds) {
378  $this->tpl->setVariable("LUCENE_ADD_COM_WIDTH", 'width="1"');
379  }
380  $this->tpl->setVariable(
381  "LUCENE_SELECT_OBJTYPE_REPOS",
382  $this->creation_selector["options"]
383  );
384  $this->tpl->setVariable(
385  "LUCENE_BTN_NAME_REPOS",
386  $this->creation_selector["command"]
387  );
388  $this->tpl->setVariable(
389  "LUCENE_TXT_ADD_REPOS",
390  $this->creation_selector["txt"]
391  );
392  $this->tpl->parseCurrentBlock();
393  $creation_selector = true;
394  }
395  if ($adm_view || $creation_selector) {
396  $this->tpl->setCurrentBlock("lucene_adm_panel");
397  if ($adm_view_cmp) {
398  $this->tpl->setVariable("LUCENE_ADM_TBL_WIDTH", 'width:"100%";');
399  }
400  $this->tpl->parseCurrentBlock();
401  }
402  }
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTabs()

ilLuceneAdvancedSearchGUI::getTabs ( )
protected

get tabs

Definition at line 289 of file class.ilLuceneAdvancedSearchGUI.php.

References fields, and ilSearchSettings\getInstance().

Referenced by prepareOutput().

290  {
291  global $ilHelp;
292 
293  $ilHelp->setScreenIdComponent("src_luc");
294 
295  $this->tabs_gui->addTarget('search', $this->ctrl->getLinkTargetByClass('illucenesearchgui'));
296 
297  if (ilSearchSettings::getInstance()->isLuceneUserSearchEnabled()) {
298  $this->tabs_gui->addTarget('search_user', $this->ctrl->getLinkTargetByClass('illuceneusersearchgui'));
299  }
300 
301  if (
302  !ilSearchSettings::getInstance()->getHideAdvancedSearch() and
303  $this->fields->getActiveFields()) {
304  $this->tabs_gui->addTarget('search_advanced', $this->ctrl->getLinkTarget($this));
305  }
306 
307  $this->tabs_gui->setTabActive('search_advanced');
308  }
$errors fields
Definition: imgupload.php:51
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initFormSearch()

ilLuceneAdvancedSearchGUI::initFormSearch ( )
protected

Show search form.

Definition at line 145 of file class.ilLuceneAdvancedSearchGUI.php.

References $form, $section, and fields.

Referenced by performSearch(), and showSavedResults().

146  {
147  global $tree;
148 
149  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
150 
151  $this->form = new ilPropertyFormGUI();
152  $this->form->setFormAction($this->ctrl->getFormAction($this, 'search'));
153  $this->form->setTitle($this->lng->txt('search_advanced'));
154  $this->form->addCommandButton('search', $this->lng->txt('search'));
155  $this->form->addCommandButton('reset', $this->lng->txt('reset'));
156 
157  foreach ($this->fields->getActiveSections() as $definition) {
158  if ($definition['name'] != 'default') {
160  $section->setTitle($definition['name']);
161  $this->form->addItem($section);
162  }
163 
164  foreach ($definition['fields'] as $field_name) {
165  if (is_object($element = $this->fields->getFormElement($this->search_cache->getQuery(), $field_name, $this->form))) {
166  $this->form->addItem($element);
167  }
168  }
169  }
170  return true;
171  }
This class represents a property form user interface.
This class represents a section header in a property form.
$errors fields
Definition: imgupload.php:51
$section
Definition: Utf8Test.php:83
if(isset($_POST['submit'])) $form
+ Here is the caller graph for this function:

◆ initUserSearchCache()

ilLuceneAdvancedSearchGUI::initUserSearchCache ( )
protected

Init user search cache.

private

Definition at line 316 of file class.ilLuceneAdvancedSearchGUI.php.

References $_GET, $_POST, $ilUser, ilUserSearchCache\_getInstance(), and ilUserSearchCache\LUCENE_ADVANCED.

Referenced by __construct().

317  {
318  global $ilUser;
319 
320  include_once('Services/Search/classes/class.ilUserSearchCache.php');
321  $this->search_cache = ilUserSearchCache::_getInstance($ilUser->getId());
322  $this->search_cache->switchSearchType(ilUserSearchCache::LUCENE_ADVANCED);
323  if ((int) $_GET['page_number']) {
324  $this->search_cache->setResultPageNumber((int) $_GET['page_number']);
325  }
326  if (isset($_POST['query'])) {
327  $this->search_cache->setQuery($_POST['query']);
328  }
329  }
$_GET["client_id"]
static _getInstance($a_usr_id)
Get singleton instance.
$ilUser
Definition: imgupload.php:18
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performSearch()

ilLuceneAdvancedSearchGUI::performSearch ( )
protected

Perform search.

Definition at line 215 of file class.ilLuceneAdvancedSearchGUI.php.

References $_SESSION, $ilBench, $ilUser, ilSearchBaseGUI\addPager(), fillAdminPanel(), ilLuceneSearcher\getInstance(), ilLuceneSearchResultFilter\getInstance(), initFormSearch(), ilLuceneAdvancedQueryParser\parse(), ilUtil\sendInfo(), and showSavedResults().

Referenced by search().

216  {
217  global $ilUser,$ilBench;
218 
219  unset($_SESSION['vis_references']);
220 
221  include_once './Services/Search/classes/Lucene/class.ilLuceneSearcher.php';
222  include_once './Services/Search/classes/Lucene/class.ilLuceneAdvancedQueryParser.php';
223  $qp = new ilLuceneAdvancedQueryParser($this->search_cache->getQuery());
224  $qp->parse();
225  if (!strlen(trim($qp->getQuery()))) {
226  ilUtil::sendInfo($this->lng->txt('msg_no_search_string'));
227  $this->showSavedResults();
228  return false;
229  }
230 
231  $searcher = ilLuceneSearcher::getInstance($qp);
232  $searcher->search();
233 
234  // Filter results
235  $ilBench->start('Lucene', 'ResultFilter');
236  include_once './Services/Search/classes/Lucene/class.ilLuceneSearchResultFilter.php';
237  include_once './Services/Search/classes/Lucene/class.ilLucenePathFilter.php';
238  $filter = ilLuceneSearchResultFilter::getInstance($ilUser->getId());
239  $filter->addFilter(new ilLucenePathFilter($this->search_cache->getRoot()));
240  $filter->setCandidates($searcher->getResult());
241  $filter->filter();
242  $ilBench->stop('Lucene', 'ResultFilter');
243 
244  if ($filter->getResultObjIds()) {
245  $searcher->highlight($filter->getResultObjIds());
246  }
247 
248  // Show results
249  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.lucene_adv_search.html', 'Services/Search');
250  include_once './Services/Search/classes/class.ilSearchResultPresentation.php';
251  $presentation = new ilSearchResultPresentation($this);
252  $presentation->setResults($filter->getResultIds());
253  $presentation->setSearcher($searcher);
254 
255  // TODO: other handling required
256  $ilBench->start('Lucene', '1500_fo');
257  $this->addPager($filter, 'max_page');
258  $ilBench->stop('Lucene', '1500_fo');
259  $presentation->setPreviousNext($this->prev_link, $this->next_link);
260 
261  if ($presentation->render()) {
262  $this->tpl->setVariable('SEARCH_RESULTS', $presentation->getHTML(true));
263  } else {
264  ilUtil::sendInfo($this->lng->txt('search_no_match'));
265  }
266 
267  // and finally add search form
268  $this->initFormSearch();
269  $this->tpl->setVariable('SEARCH_TABLE', $this->form->getHTML());
270 
271  if ($filter->getResultIds()) {
272  $this->fillAdminPanel();
273  }
274  }
$_SESSION["AccountId"]
static getInstance(ilLuceneQueryParser $qp)
Get singleton instance.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
addPager($result, $a_session_key)
Add Pager.
Presentation of search results using object list gui.
$ilUser
Definition: imgupload.php:18
global $ilBench
Definition: ilias.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prepareOutput()

ilLuceneAdvancedSearchGUI::prepareOutput ( )

Add admin panel command.

Definition at line 279 of file class.ilLuceneAdvancedSearchGUI.php.

References getTabs().

Referenced by executeCommand().

280  {
281  parent::prepareOutput();
282  $this->getTabs();
283  return true;
284  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ remoteSearch()

ilLuceneAdvancedSearchGUI::remoteSearch ( )
protected

Search from main menu.

Definition at line 176 of file class.ilLuceneAdvancedSearchGUI.php.

References $_POST, array, search(), and ilUtil\stripSlashes().

177  {
178  $this->search_cache->setRoot((int) $_POST['root_id']);
179  $this->search_cache->setQuery(array('lom_content' => ilUtil::stripSlashes($_POST['queryString'])));
180  $this->search_cache->save();
181  $this->search();
182  }
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
Create styles array
The data for the language used.
$_POST["username"]
+ Here is the call graph for this function:

◆ reset()

ilLuceneAdvancedSearchGUI::reset ( )
protected

Reset search form.

Definition at line 205 of file class.ilLuceneAdvancedSearchGUI.php.

References array, and showSavedResults().

206  {
207  $this->search_cache->setQuery(array());
208  $this->search_cache->save();
209  $this->showSavedResults();
210  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ search()

ilLuceneAdvancedSearchGUI::search ( )
protected

Definition at line 184 of file class.ilLuceneAdvancedSearchGUI.php.

References $_SESSION, performSearch(), ilSubItemListGUI\resetDetails(), ilUtil\sendInfo(), and showSavedResults().

Referenced by remoteSearch().

185  {
186  if (!is_array($this->search_cache->getQuery())) {
187  // TOD: handle empty advances search
188  ilUtil::sendInfo($this->lng->txt('msg_no_search_string'));
189  $this->showSavedResults();
190  return false;
191  }
192  unset($_SESSION['max_page']);
193  $this->search_cache->deleteCachedEntries();
194 
195  // Reset details
196  include_once './Services/Object/classes/class.ilSubItemListGUI.php';
198 
199  $this->performSearch();
200  }
$_SESSION["AccountId"]
static resetDetails()
reset details As long as static::resetDetails is not possible this method is final ...
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAdminViewButton()

ilLuceneAdvancedSearchGUI::setAdminViewButton (   $a_link,
  $a_txt 
)
protected

Show admin view button.

Definition at line 416 of file class.ilLuceneAdvancedSearchGUI.php.

References array.

417  {
418  $this->admin_view_button =
419  array("link" => $a_link, "txt" => $a_txt);
420  }
Create styles array
The data for the language used.

◆ setPageFormAction()

ilLuceneAdvancedSearchGUI::setPageFormAction (   $a_action)
protected

Definition at line 422 of file class.ilLuceneAdvancedSearchGUI.php.

423  {
424  $this->page_form_action = $a_action;
425  }

◆ showSavedResults()

ilLuceneAdvancedSearchGUI::showSavedResults ( )

Show saved results.

Returns

Definition at line 95 of file class.ilLuceneAdvancedSearchGUI.php.

References $ilBench, $ilUser, ilSearchBaseGUI\addPager(), fillAdminPanel(), ilLuceneSearcher\getInstance(), ilLuceneSearchResultFilter\getInstance(), initFormSearch(), ilLuceneAdvancedQueryParser\parse(), and ilUtil\sendInfo().

Referenced by performSearch(), reset(), and search().

96  {
97  global $ilUser,$ilBench;
98 
99  include_once './Services/Search/classes/Lucene/class.ilLuceneSearcher.php';
100  include_once './Services/Search/classes/Lucene/class.ilLuceneAdvancedQueryParser.php';
101  $qp = new ilLuceneAdvancedQueryParser($this->search_cache->getQuery());
102  $qp->parse();
103  $searcher = ilLuceneSearcher::getInstance($qp);
104  $searcher->search();
105 
106  // Load saved results
107  include_once './Services/Search/classes/Lucene/class.ilLuceneSearchResultFilter.php';
108  $filter = ilLuceneSearchResultFilter::getInstance($ilUser->getId());
109  $filter->loadFromDb();
110 
111  // Highlight
112  if ($filter->getResultObjIds()) {
113  $searcher->highlight($filter->getResultObjIds());
114  }
115 
116  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.lucene_adv_search.html', 'Services/Search');
117  include_once './Services/Search/classes/class.ilSearchResultPresentation.php';
118  $presentation = new ilSearchResultPresentation($this);
119  $presentation->setResults($filter->getResultIds());
120  $presentation->setSearcher($searcher);
121 
122 
123  // TODO: other handling required
124  $this->addPager($filter, 'max_page');
125  $presentation->setPreviousNext($this->prev_link, $this->next_link);
126 
127  if ($presentation->render()) {
128  $this->tpl->setVariable('SEARCH_RESULTS', $presentation->getHTML(true));
129  } elseif (strlen(trim($qp->getQuery()))) {
130  ilUtil::sendInfo($this->lng->txt('search_no_match'));
131  }
132 
133  // and finally add search form
134  $this->initFormSearch();
135  $this->tpl->setVariable('SEARCH_TABLE', $this->form->getHTML());
136 
137  if ($filter->getResultIds()) {
138  $this->fillAdminPanel();
139  }
140  }
static getInstance(ilLuceneQueryParser $qp)
Get singleton instance.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
addPager($result, $a_session_key)
Add Pager.
Presentation of search results using object list gui.
$ilUser
Definition: imgupload.php:18
global $ilBench
Definition: ilias.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $fields

ilLuceneAdvancedSearchGUI::$fields = null
protected

Definition at line 46 of file class.ilLuceneAdvancedSearchGUI.php.

◆ $ilTabs

ilLuceneAdvancedSearchGUI::$ilTabs
protected

Definition at line 44 of file class.ilLuceneAdvancedSearchGUI.php.

Referenced by __construct().


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