ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilLuceneSearchGUI Class Reference

GUI for simple Lucene search More...

+ Inheritance diagram for ilLuceneSearchGUI:
+ Collaboration diagram for ilLuceneSearchGUI:

Public Member Functions

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

Protected Member Functions

 getType ()
 Get type of search (details | fast)
 getDetails ()
 Needed for base class search form.
 getMimeDetails ()
 Needed for base class search form.
 remoteSearch ()
 Search from main menu.
 showSavedResults ()
 Show saved results.
 search ()
 Search (button pressed)
 performSearch ()
 Perform search.
 storeRoot ()
 Store new root node.
 getTabs ()
 get tabs
 initUserSearchCache ()
 Init user search cache.
 fillAdminPanel ()
 Put admin panel into template:
 addAdminPanelCommand ($a_cmd, $a_txt)
 Add a command to the admin panel.
 setAdminViewButton ($a_link, $a_txt)
 Show admin view button.
 setPageFormAction ($a_action)
 showSearchForm ()
 Show search form.
- Protected Member Functions inherited from ilSearchBaseGUI
 addPager ($result, $a_session_key)
 Add Pager.
 buildSearchAreaPath ($a_root_node)
 Build path for search area.

Protected Attributes

 $ilTabs
- Protected Attributes inherited from ilSearchBaseGUI
 $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
 $settings = null
 $ilias = null
 $lng = null
 $tpl = null

Detailed Description

Constructor & Destructor Documentation

ilLuceneSearchGUI::__construct ( )

Constructor.

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

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

+ Here is the call graph for this function:

Member Function Documentation

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

Add a command to the admin panel.

Definition at line 508 of file class.ilLuceneSearchGUI.php.

{
$this->admin_panel_commands[] =
array("cmd" => $a_cmd, "txt" => $a_txt);
}
ilLuceneSearchGUI::executeCommand ( )

Execute Command.

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

References $cmd, $ilBench, $ilCtrl, ilSearchBaseGUI\getSearchAreaForm(), ilSearchBaseGUI\handleCommand(), ilSearchBaseGUI\initStandardSearchForm(), prepareOutput(), and ilSearchBaseGUI\SEARCH_FORM_LUCENE.

{
global $ilBench, $ilCtrl;
$ilBench->start('Lucene','0900_executeCommand');
$next_class = $this->ctrl->getNextClass($this);
$cmd = $this->ctrl->getCmd();
$this->prepareOutput();
switch($next_class)
{
case "ilpropertyformgui":
/*$this->initStandardSearchForm(ilSearchBaseGUI::SEARCH_FORM_LUCENE);
$ilCtrl->setReturn($this, 'storeRoot');
$ilCtrl->forwardCommand($this->form);*/
$form = $this->getSearchAreaForm();
$ilCtrl->setReturn($this, 'storeRoot');
$ilCtrl->forwardCommand($form);
break;
case 'ilobjectcopygui':
include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
$cp = new ilObjectCopyGUI($this);
$this->ctrl->forwardCommand($cp);
break;
default:
if(!$cmd)
{
$cmd = "showSavedResults";
}
break;
}
$ilBench->stop('Lucene','0900_executeCommand');
return true;
}

+ Here is the call graph for this function:

ilLuceneSearchGUI::fillAdminPanel ( )
protected

Put admin panel into template:

  • creation selector
  • admin view on/off button

Definition at line 432 of file class.ilLuceneSearchGUI.php.

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

{
global $lng;
$adm_view_cmp = $adm_cmds = $creation_selector = $adm_view = false;
// admin panel commands
if ((count($this->admin_panel_commands) > 0))
{
foreach($this->admin_panel_commands as $cmd)
{
$this->tpl->setCurrentBlock("lucene_admin_panel_cmd");
$this->tpl->setVariable("LUCENE_PANEL_CMD", $cmd["cmd"]);
$this->tpl->setVariable("LUCENE_TXT_PANEL_CMD", $cmd["txt"]);
$this->tpl->parseCurrentBlock();
}
$adm_cmds = true;
}
if ($adm_cmds)
{
$this->tpl->setCurrentBlock("lucene_adm_view_components");
$this->tpl->setVariable("LUCENE_ADM_IMG_ARROW", ilUtil::getImagePath("arrow_upright.png"));
$this->tpl->setVariable("LUCENE_ADM_ALT_ARROW", $lng->txt("actions"));
$this->tpl->parseCurrentBlock();
$adm_view_cmp = true;
}
// admin view button
if (is_array($this->admin_view_button))
{
if (is_array($this->admin_view_button))
{
$this->tpl->setCurrentBlock("lucene_admin_button");
$this->tpl->setVariable("LUCENE_ADMIN_MODE_LINK",
$this->admin_view_button["link"]);
$this->tpl->setVariable("LUCENE_TXT_ADMIN_MODE",
$this->admin_view_button["txt"]);
$this->tpl->parseCurrentBlock();
}
$this->tpl->setCurrentBlock("lucene_admin_view");
$this->tpl->parseCurrentBlock();
$adm_view = true;
}
// creation selector
if (is_array($this->creation_selector))
{
$this->tpl->setCurrentBlock("lucene_add_commands");
if ($adm_cmds)
{
$this->tpl->setVariable("LUCENE_ADD_COM_WIDTH", 'width="1"');
}
$this->tpl->setVariable("LUCENE_SELECT_OBJTYPE_REPOS",
$this->creation_selector["options"]);
$this->tpl->setVariable("LUCENE_BTN_NAME_REPOS",
$this->creation_selector["command"]);
$this->tpl->setVariable("LUCENE_TXT_ADD_REPOS",
$this->creation_selector["txt"]);
$this->tpl->parseCurrentBlock();
$creation_selector = true;
}
if ($adm_view || $creation_selector)
{
$this->tpl->setCurrentBlock("lucene_adm_panel");
if ($adm_view_cmp)
{
$this->tpl->setVariable("LUCENE_ADM_TBL_WIDTH", 'width:"100%";');
}
$this->tpl->parseCurrentBlock();
}
}

+ Here is the call graph for this function:

ilLuceneSearchGUI::getDetails ( )
protected

Needed for base class search form.

Todo:
rename
Returns
type

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

{
return (array) $this->search_cache->getItemFilter();
}
ilLuceneSearchGUI::getMimeDetails ( )
protected

Needed for base class search form.

Todo:
rename
Returns
type

Definition at line 143 of file class.ilLuceneSearchGUI.php.

{
return (array) $this->search_cache->getMimeFilter();
}
ilLuceneSearchGUI::getTabs ( )
protected

get tabs

Definition at line 352 of file class.ilLuceneSearchGUI.php.

References fields, and ilSearchSettings\getInstance().

Referenced by prepareOutput().

{
if(ilSearchSettings::getInstance()->getHideAdvancedSearch())
{
return false;
}
$this->tabs_gui->addTarget('search',$this->ctrl->getLinkTarget($this));
if(ilSearchSettings::getInstance()->isLuceneUserSearchEnabled())
{
$this->tabs_gui->addTarget('search_user',$this->ctrl->getLinkTargetByClass('illuceneusersearchgui'));
}
if($this->fields->getActiveFields())
{
$this->tabs_gui->addTarget('search_advanced',$this->ctrl->getLinkTargetByClass('illuceneAdvancedSearchgui'));
}
$this->tabs_gui->setTabActive('search');
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilLuceneSearchGUI::getType ( )
protected

Get type of search (details | fast)

Todo:
rename Needed for base class search form

Definition at line 119 of file class.ilLuceneSearchGUI.php.

References ilSearchBaseGUI\SEARCH_DETAILS, and ilSearchBaseGUI\SEARCH_FAST.

{
if(count($this->search_cache))
{
}
}
ilLuceneSearchGUI::initUserSearchCache ( )
protected

Init user search cache.

private

Definition at line 381 of file class.ilLuceneSearchGUI.php.

References $_GET, $_POST, $ilUser, ilUserSearchCache\_getInstance(), ilSearchSettings\getInstance(), ilUserSearchCache\LUCENE_DEFAULT, and ilUtil\stripSlashes().

Referenced by __construct().

{
global $ilUser;
include_once('Services/Search/classes/class.ilUserSearchCache.php');
$this->search_cache = ilUserSearchCache::_getInstance($ilUser->getId());
$this->search_cache->switchSearchType(ilUserSearchCache::LUCENE_DEFAULT);
if((int) $_GET['page_number'])
{
$this->search_cache->setResultPageNumber((int) $_GET['page_number']);
}
if(isset($_POST['term']))
{
$this->search_cache->setQuery(ilUtil::stripSlashes($_POST['term']));
if($_POST['item_filter_enabled'])
{
$filtered = array();
foreach(ilSearchSettings::getInstance()->getEnabledLuceneItemFilterDefinitions() as $type => $data)
{
if($_POST['filter_type'][$type])
{
$filtered[$type] = 1;
}
}
$this->search_cache->setItemFilter($filtered);
// Mime filter
$mime = array();
foreach(ilSearchSettings::getInstance()->getEnabledLuceneMimeFilterDefinitions() as $type => $data)
{
if($_POST['filter_type'][$type])
{
$mime[$type] = 1;
}
}
$this->search_cache->setMimeFilter($mime);
}
else
{
// @todo: keep item filter settings
$this->search_cache->setItemFilter(array());
$this->search_cache->setMimeFilter(array());
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilLuceneSearchGUI::performSearch ( )
protected

Perform search.

Definition at line 242 of file class.ilLuceneSearchGUI.php.

References $_SESSION, $ilBench, $ilUser, ilSearchBaseGUI\addPager(), ilSearchSettings\getInstance(), ilLuceneSearcher\getInstance(), ilLuceneSearchResultFilter\getInstance(), ilUtil\sendInfo(), and showSearchForm().

Referenced by search(), and storeRoot().

{
global $ilUser,$ilBench;
unset($_SESSION['vis_references']);
$filter_query = '';
if($this->search_cache->getItemFilter() and ilSearchSettings::getInstance()->isLuceneItemFilterEnabled())
{
$filter_settings = ilSearchSettings::getInstance()->getEnabledLuceneItemFilterDefinitions();
foreach((array) $this->search_cache->getItemFilter() as $obj => $value)
{
if(!$filter_query)
{
$filter_query .= '+( ';
}
else
{
$filter_query .= 'OR';
}
$filter_query .= (' '. (string) $filter_settings[$obj]['filter'].' ');
}
$filter_query .= ') ';
}
// begin-patch mime_filter
$mime_query = '';
if($this->search_cache->getMimeFilter() and ilSearchSettings::getInstance()->isLuceneMimeFilterEnabled())
{
$filter_settings = ilSearchSettings::getInstance()->getEnabledLuceneMimeFilterDefinitions();
foreach($this->search_cache->getMimeFilter() as $mime => $value)
{
if(!$mime_query)
{
$mime_query .= '+( ';
}
else
{
$mime_query .= 'OR';
}
$mime_query .= (' '. (string) $filter_settings[$mime]['filter'].' ');
}
$mime_query .= ') ';
}
$filter_query = $filter_query . ' '. $mime_query;
include_once './Services/Search/classes/Lucene/class.ilLuceneSearcher.php';
include_once './Services/Search/classes/Lucene/class.ilLuceneQueryParser.php';
$qp = new ilLuceneQueryParser($filter_query.' +('.$this->search_cache->getQuery().')');
$qp->parse();
$searcher->search();
// Filter results
include_once './Services/Search/classes/Lucene/class.ilLuceneSearchResultFilter.php';
include_once './Services/Search/classes/Lucene/class.ilLucenePathFilter.php';
$filter = ilLuceneSearchResultFilter::getInstance($ilUser->getId());
$filter->addFilter(new ilLucenePathFilter($this->search_cache->getRoot()));
$filter->setCandidates($searcher->getResult());
$filter->filter();
if($filter->getResultObjIds()) {
$searcher->highlight($filter->getResultObjIds());
}
// Show results
$this->showSearchForm();
include_once './Services/Search/classes/class.ilSearchResultPresentation.php';
$presentation = new ilSearchResultPresentation($this);
$presentation->setResults($filter->getResultIds());
$presentation->setSearcher($searcher);
// TODO: other handling required
$ilBench->start('Lucene','1500_fo');
$this->addPager($filter,'max_page');
$ilBench->stop('Lucene','1500_fo');
$presentation->setPreviousNext($this->prev_link, $this->next_link);
if($presentation->render())
{
$this->tpl->setVariable('SEARCH_RESULTS',$presentation->getHTML(true));
}
else
{
ilUtil::sendInfo(sprintf($this->lng->txt('search_no_match_hint'),$this->search_cache->getQuery()));
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilLuceneSearchGUI::prepareOutput ( )

Add admin panel command.

Reimplemented from ilSearchBaseGUI.

Definition at line 107 of file class.ilLuceneSearchGUI.php.

References getTabs().

Referenced by executeCommand().

{
$this->getTabs();
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilLuceneSearchGUI::remoteSearch ( )
protected

Search from main menu.

Definition at line 151 of file class.ilLuceneSearchGUI.php.

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

{
$_POST['query'] = $_POST['queryString'];
$this->search_cache->setRoot((int) $_POST['root_id']);
$this->search_cache->setQuery(ilUtil::stripSlashes($_POST['queryString']));
$this->search_cache->save();
$this->search();
}

+ Here is the call graph for this function:

ilLuceneSearchGUI::search ( )
protected

Search (button pressed)

Returns

Definition at line 217 of file class.ilLuceneSearchGUI.php.

References $_SESSION, performSearch(), ilSubItemListGUI\resetDetails(), and showSearchForm().

Referenced by remoteSearch().

{
if(!$this->form->checkInput())
{
$this->search_cache->deleteCachedEntries();
// Reset details
include_once './Services/Object/classes/class.ilSubItemListGUI.php';
$this->showSearchForm();
return false;
}
unset($_SESSION['max_page']);
$this->search_cache->deleteCachedEntries();
// Reset details
include_once './Services/Object/classes/class.ilSubItemListGUI.php';
$this->performSearch();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Show admin view button.

Definition at line 517 of file class.ilLuceneSearchGUI.php.

{
$this->admin_view_button =
array("link" => $a_link, "txt" => $a_txt);
}
ilLuceneSearchGUI::setPageFormAction (   $a_action)
protected

Definition at line 523 of file class.ilLuceneSearchGUI.php.

{
$this->page_form_action = $a_action;
}
ilLuceneSearchGUI::showSavedResults ( )
protected

Show saved results.

Returns

Definition at line 165 of file class.ilLuceneSearchGUI.php.

References $ilBench, $ilUser, ilSearchBaseGUI\addPager(), ilLuceneSearcher\getInstance(), ilLuceneSearchResultFilter\getInstance(), ilLuceneQueryParser\parse(), ilUtil\sendInfo(), and showSearchForm().

{
global $ilUser,$ilBench;
if(!strlen($this->search_cache->getQuery()))
{
$this->showSearchForm();
return false;
}
include_once './Services/Search/classes/Lucene/class.ilLuceneSearcher.php';
include_once './Services/Search/classes/Lucene/class.ilLuceneQueryParser.php';
$qp = new ilLuceneQueryParser($this->search_cache->getQuery());
$qp->parse();
$searcher->search();
// Load saved results
include_once './Services/Search/classes/Lucene/class.ilLuceneSearchResultFilter.php';
$filter = ilLuceneSearchResultFilter::getInstance($ilUser->getId());
$filter->loadFromDb();
// Highlight
$searcher->highlight($filter->getResultObjIds());
include_once './Services/Search/classes/class.ilSearchResultPresentation.php';
$presentation = new ilSearchResultPresentation($this);
$presentation->setResults($filter->getResultIds());
$presentation->setSearcher($searcher);
// TODO: other handling required
$this->addPager($filter,'max_page');
$presentation->setPreviousNext($this->prev_link, $this->next_link);
$this->showSearchForm();
if($presentation->render())
{
$this->tpl->setVariable('SEARCH_RESULTS',$presentation->getHTML(true));
}
elseif(strlen($this->search_cache->getQuery()))
{
ilUtil::sendInfo(sprintf($this->lng->txt('search_no_match_hint'),$qp->getQuery()));
}
}

+ Here is the call graph for this function:

ilLuceneSearchGUI::showSearchForm ( )
protected

Show search form.

Returns
boolean

Definition at line 532 of file class.ilLuceneSearchGUI.php.

References $ilCtrl, ilSearchBaseGUI\$lng, ilUtil\getImagePath(), ilSearchSettings\getInstance(), ilSearchBaseGUI\getSearchAreaForm(), ilUtil\img(), ilOverlayGUI\initJavascript(), ilSearchSettings\OPERATOR_AND, and ilUtil\prepareFormOutput().

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

{
global $ilCtrl, $lng;
$this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.lucene_search.html','Services/Search');
// include js needed
include_once("./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php");
$this->tpl->addJavascript("./Services/Search/js/Search.js");
$this->tpl->setVariable("FORM_ACTION", $ilCtrl->getFormAction($this,'performSearch'));
$this->tpl->setVariable("TERM", ilUtil::prepareFormOutput($this->search_cache->getQuery()));
$this->tpl->setVariable("TXT_SEARCH", $lng->txt("search"));
$this->tpl->setVariable("TXT_OPTIONS", $lng->txt("options"));
$this->tpl->setVariable("ARR_IMG", ilUtil::img(ilUtil::getImagePath("mm_down_arrow_dark.png")));
$this->tpl->setVariable("TXT_COMBINATION", $lng->txt("search_term_combination"));
$this->tpl->setVariable('TXT_COMBINATION_DEFAULT', ilSearchSettings::getInstance()->getDefaultOperator() == ilSearchSettings::OPERATOR_AND ? $lng->txt('search_all_words') : $lng->txt('search_any_word'));
$this->tpl->setVariable("TXT_AREA", $lng->txt("search_area"));
if (ilSearchSettings::getInstance()->isLuceneItemFilterEnabled())
{
$this->tpl->setCurrentBlock("type_sel");
$this->tpl->setVariable('TXT_TYPE_DEFAULT',$lng->txt("search_off"));
$this->tpl->setVariable("ARR_IMGT", ilUtil::img(ilUtil::getImagePath("mm_down_arrow_dark.png")));
$this->tpl->setVariable("TXT_FILTER_BY_TYPE", $lng->txt("search_filter_by_type"));
$this->tpl->setVariable('FORM',$this->form->getHTML());
$this->tpl->parseCurrentBlock();
}
// search area form
$this->tpl->setVariable('SEARCH_AREA_FORM', $this->getSearchAreaForm()->getHTML());
$this->tpl->setVariable("TXT_CHANGE", $lng->txt("change"));
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilLuceneSearchGUI::storeRoot ( )
protected

Store new root node.

Definition at line 334 of file class.ilLuceneSearchGUI.php.

References ilSearchBaseGUI\getSearchAreaForm(), performSearch(), and ilSubItemListGUI\resetDetails().

{
$form = $this->getSearchAreaForm();
$this->root_node = $form->getItemByPostVar('area')->getValue();
$this->search_cache->setRoot($this->root_node);
$this->search_cache->save();
$this->search_cache->deleteCachedEntries();
include_once './Services/Object/classes/class.ilSubItemListGUI.php';
$this->performSearch();
}

+ Here is the call graph for this function:

Field Documentation

ilLuceneSearchGUI::$ilTabs
protected

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

Referenced by __construct().


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