ILIAS  Release_4_0_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.
 handleCommand ($a_cmd)
 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

 remoteSearch ()
 Search from main menu.
 showSavedResults ()
 Show saved results.
 search ()
 Search (button pressed)
 performSearch ()
 Perform search.
 initFormSearch ()
 Show search form.
 chooseRoot ()
 Show root node selection.
 selectRoot ()
 Select root.
 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 ()
- 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
 $settings = null
 $ilias = null
 $lng = null
 $tpl = null

Detailed Description

Constructor & Destructor Documentation

ilLuceneSearchGUI::__construct ( )

Constructor.

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

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

{
global $ilTabs;
$this->tabs_gui = $ilTabs;
}

+ 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 603 of file class.ilLuceneSearchGUI.php.

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

Show root node selection.

Parameters
@return

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

References $_GET, ilUtil\sendInfo(), and ilSearchRootSelector\setTargetClass().

{
global $tree;
$this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.search_root_selector.html','Services/Search');
include_once 'Services/Search/classes/class.ilSearchRootSelector.php';
ilUtil::sendInfo($this->lng->txt('search_area_info'));
$exp = new ilSearchRootSelector($this->ctrl->getLinkTarget($this,'chooseRoot'));
$exp->setTargetClass(get_class($this));
$exp->setExpand($_GET["search_root_expand"] ? $_GET["search_root_expand"] : $tree->readRootId());
$exp->setExpandTarget($this->ctrl->getLinkTarget($this,'chooseRoot'));
// build html-output
$exp->setOutput(0);
$this->tpl->setVariable("EXPLORER",$exp->getOutput());
}

+ Here is the call graph for this function:

ilLuceneSearchGUI::executeCommand ( )

Execute Command.

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

References $cmd, $ilBench, ilSearchBaseGUI\handleCommand(), and prepareOutput().

{
global $ilBench;
$ilBench->start('Lucene','0900_executeCommand');
$next_class = $this->ctrl->getNextClass($this);
$cmd = $this->ctrl->getCmd();
$this->prepareOutput();
switch($next_class)
{
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 527 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.gif"));
$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::getTabs ( )
protected

get tabs

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

References ilSearchSettings\getInstance().

Referenced by prepareOutput().

{
if(ilSearchSettings::getInstance()->getHideAdvancedSearch())
{
return false;
}
$this->tabs_gui->addTarget('search',$this->ctrl->getLinkTarget($this));
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::initFormSearch ( )
protected

Show search form.

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

References $ilCtrl, $ref_id, $title, ilSearchBaseGUI\$tpl, ilObject\_lookupObjId(), ilObject\_lookupTitle(), ilSearchSettings\getInstance(), ilTextInputGUI\setValue(), ilCheckboxInputGUI\setValue(), and ilUtil\shortenText().

Referenced by remoteSearch(), search(), and showSearchForm().

{
global $tree, $ilCtrl;
include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
if(is_object($this->form))
{
return true;
}
$this->form = new ilPropertyFormGUI();
$this->form->setFormAction($this->ctrl->getFormAction($this,'search'));
$this->form->setTitle($this->lng->txt('search'));
$this->form->addCommandButton('search',$this->lng->txt('search'));
include_once './Services/Search/classes/Form/class.ilLuceneQueryInputGUI.php';
$term = new ilLuceneQueryInputGUI($this->lng->txt('search_search_term'),'query');
$term->setValue($this->search_cache->getQuery());
$term->setSize(40);
$term->setMaxLength(255);
$term->setRequired(true);
$dsSchema = array("resultsList" => 'response.results',
"fields" => array('term'));
$term->setDataSource($ilCtrl->getLinkTarget($this, "autoComplete"));
$term->setDataSourceSchema($dsSchema);
$term->setDataSourceResultFormat($dsFormatCallback);
$term->setDataSourceDelimiter($dsDelimiter);
$this->form->addItem($term);
$path = new ilCustomInputGUI($this->lng->txt('search_area'),'root');
$tpl = new ilTemplate('tpl.root_selection.html',true,true,'Services/Search');
switch($this->search_cache->getRoot())
{
default:
$pathIds = $tree->getPathId($this->search_cache->getRoot(),ROOT_FOLDER_ID);
$counter = 0;
foreach($pathIds as $ref_id)
{
if($counter++) {
$tpl->touchBlock('path_separator');
}
if(($counter % 3) == 0) {
$tpl->touchBlock('line_break');
}
if($ref_id == ROOT_FOLDER_ID) {
$title = $this->lng->txt('search_in_magazin');
}
else {
}
$this->ctrl->setParameter($this,'root_id',$ref_id);
$tpl->setCurrentBlock('item');
$tpl->setVariable('ITEM_LINK',$this->ctrl->getLinkTarget($this,'selectRoot'));
$tpl->setVariable('NAME_WITH_DOTS',$title);
$tpl->parseCurrentBlock();
}
$tpl->setVariable('LINK_SELECT',$this->ctrl->getLinkTarget($this,'chooseRoot'));
$tpl->setVariable('TXT_CHANGE',$this->lng->txt('change'));
break;
}
$path->setHTML($tpl->get());
$this->form->addItem($path);
// object filter
$itemFilter = ilSearchSettings::getInstance()->getEnabledLuceneItemFilterDefinitions();
$currentFilter = $this->search_cache->getItemFilter();
if(count($itemFilter))
{
$if = new ilCheckboxInputGUI($this->lng->txt('search_item_filter'),'item_filter_enabled');
$if->setValue(1);
$if->setChecked(count($currentFilter));
$this->form->addItem($if);
foreach($itemFilter as $obj => $def)
{
$ch = new ilCheckboxInputGUI($this->lng->txt($def['trans']),'filter['.$obj.']');
$ch->setChecked(isset($currentFilter[$obj]));
$ch->setValue(1);
$if->addSubItem($ch);
}
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilLuceneSearchGUI::initUserSearchCache ( )
protected

Init user search cache.

private

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

References $_GET, $_POST, ilUserSearchCache\_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['query']))
{
$this->search_cache->setQuery(ilUtil::stripSlashes($_POST['query']));
if($_POST['item_filter_enabled'])
{
$this->search_cache->setItemFilter($_POST['filter']);
}
else
{
$this->search_cache->setItemFilter(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 259 of file class.ilLuceneSearchGUI.php.

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

Referenced by search().

{
global $ilUser,$ilBench;
unset($_SESSION['vis_references']);
$filter_query = '';
if($this->search_cache->getItemFilter())
{
$filter_settings = ilSearchSettings::getInstance()->getEnabledLuceneItemFilterDefinitions();
foreach($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 .= ') ';
}
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
$ilBench->start('Lucene','ResultFilter');
include_once './Services/Search/classes/Lucene/class.ilLuceneSearchResultFilter.php';
include_once './Services/Search/classes/Lucene/class.ilLucenePathFilter.php';
$filter->addFilter(new ilLucenePathFilter($this->search_cache->getRoot()));
$filter->setCandidates($searcher->getResult());
$filter->filter();
$ilBench->stop('Lucene','ResultFilter');
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()));
}
if($filter->getResultIds())
{
#$this->fillAdminPanel();
}
}

+ 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 96 of file class.ilLuceneSearchGUI.php.

References $_SESSION, $GLOBALS, $ilSetting, elseif(), and getTabs().

Referenced by executeCommand().

{
$this->getTabs();
return true;
global $ilAccess, $ilSetting;
global $ilUser;
if($_SESSION['il_cont_admin_panel'])
{
$GLOBALS["tpl"]->setAdminViewButton(
$this->ctrl->getLinkTarget($this, "disableAdministrationPanel"),
$this->lng->txt("basic_commands"));
$GLOBALS["tpl"]->addAdminPanelCommand("delete",
$this->lng->txt("delete_selected_items"));
if(!$_SESSION["clipboard"])
{
$GLOBALS["tpl"]->addAdminPanelCommand("cut",
$this->lng->txt("move_selected_items"));
$GLOBALS["tpl"]->addAdminPanelCommand("link",
$this->lng->txt("link_selected_items"));
}
else
{
$GLOBALS["tpl"]->addAdminPanelCommand("paste",
$this->lng->txt("paste_clipboard_items"));
$GLOBALS["tpl"]->addAdminPanelCommand("clear",
$this->lng->txt("clear_clipboard"));
}
}
elseif($ilUser->getId() != ANONYMOUS_USER_ID)
{
$GLOBALS["tpl"]->setAdminViewButton(
$this->ctrl->getLinkTarget($this, "enableAdministrationPanel"),
$this->lng->txt("all_commands"));
}
$this->ctrl->setParameter($this, "type", "");
$this->ctrl->setParameter($this, "item_ref_id", "");
$GLOBALS["tpl"]->setPageFormAction($this->ctrl->getFormAction($this));
}

+ 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 147 of file class.ilLuceneSearchGUI.php.

References $_POST, initFormSearch(), 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->initFormSearch();
$this->search();
}

+ Here is the call graph for this function:

ilLuceneSearchGUI::search ( )
protected

Search (button pressed)

Returns

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

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

Referenced by remoteSearch().

{
$this->initFormSearch();
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::selectRoot ( )
protected

Select root.

Returns

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

References $_GET, ilSubItemListGUI\resetDetails(), and showSearchForm().

{
$this->search_cache->setRoot((int) $_GET['root_id']);
$this->search_cache->save();
$this->search_cache->deleteCachedEntries();
// Reset details
include_once './Services/Object/classes/class.ilSubItemListGUI.php';
$this->showSearchForm();
}

+ Here is the call graph for this function:

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

Show admin view button.

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

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

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

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

Show saved results.

Returns

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

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

{
global $ilUser,$ilBench;
$ilBench->start('Lucene','1000_savedResults');
$ilBench->start('Lucene','1000_qp');
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();
$ilBench->stop('Lucene','1000_qp');
$ilBench->start('Lucene','1100_lr');
// Load saved results
include_once './Services/Search/classes/Lucene/class.ilLuceneSearchResultFilter.php';
$filter->loadFromDb();
$ilBench->stop('Lucene','1100_lr');
// Highlight
$ilBench->start('Lucene','1200_hi');
$searcher->highlight($filter->getResultObjIds());
$ilBench->stop('Lucene','1200_hi');
$ilBench->start('Lucene','1300_pr');
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);
$ilBench->stop('Lucene','1300_pr');
$ilBench->start('Lucene','1400_re');
$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()));
}
$ilBench->stop('Lucene','1400_re');
$ilBench->stop('Lucene','1000_savedResults');
}

+ Here is the call graph for this function:

ilLuceneSearchGUI::showSearchForm ( )
protected

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

References initFormSearch().

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

{
$this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.lucene_search.html','Services/Search');
$this->initFormSearch();
$this->tpl->setVariable('SEARCH_TABLE',$this->form->getHTML());
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilLuceneSearchGUI::$ilTabs
protected

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

Referenced by __construct().


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