ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilSearchResultPresentation Class Reference

Presentation of search results using object list gui. More...

+ Collaboration diagram for ilSearchResultPresentation:

Public Member Functions

 __construct ($container=null, $a_mode=self::MODE_LUCENE)
 Constructor.
 getContainer ()
 Get container gui.
 getMode ()
 setResults ($a_result_data)
 Set result array.
 getResults ()
 get results
 setSubitemIds ($a_subids)
 Set subitem ids Used for like and fulltext search.
 getSubitemIds ()
 Get subitem ids.
 getSubitemIdsByObject ($a_obj_id)
 Get subitem ids for an object.
 getHTML ($a_new=false)
 Get HTML.
 setSearcher ($a_searcher)
 set searcher
 render ()
 Parse results.
 setPreviousNext ($a_p, $a_n)
 Set previous next.
 getRelevance ($a_obj_id)
 get relevance
 lookupTitle ($a_obj_id, $a_sub_id)
 lookupDescription ($a_obj_id, $a_sub_id)
 lookupContent ($a_obj_id, $a_sub_id)
 get content
 appendAdditionalInformation ($item_list_gui, $ref_id, $obj_id, $type)
 Append path, relevance information.

Data Fields

const MODE_LUCENE = 1
const MODE_STANDARD = 2

Protected Member Functions

 parseResultReferences ()
 Check if more than one reference is visible.
 hasMoreReferences ($a_ref_id)
 getAllReferences ($a_ref_id)
 renderItemList ()
 Render item list.
 appendPath ($a_ref_id)
 Append path.
 appendMorePathes ($a_ref_id)
 Append more occurences link.
 appendRelevance ($a_obj_id)
 Append relevance.
 appendSubItems ($item_list_gui, $ref_id, $obj_id, $a_type)
 Append subitems.
 initReferences ()

Protected Attributes

 $mode
 $tpl
 $lng

Private Attributes

 $results = array()
 $subitem_ids = array()
 $has_more_ref_ids = array()
 $all_references = null
 $searcher = null
 $container = null

Detailed Description

Presentation of search results using object list gui.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 33 of file class.ilSearchResultPresentation.php.

Constructor & Destructor Documentation

ilSearchResultPresentation::__construct (   $container = null,
  $a_mode = self::MODE_LUCENE 
)

Constructor.

Parameters
object$containercontainer gui object

Definition at line 55 of file class.ilSearchResultPresentation.php.

References $_GET, $container, $ilCtrl, $lng, $tpl, initReferences(), and ilSubItemListGUI\setShowDetails().

{
global $tpl,$lng,$ilCtrl;
$this->mode = $a_mode;
$this->lng = $lng;
$this->container = $container;
$this->ctrl = $ilCtrl;
$this->initReferences();
if(isset($_GET['details']))
{
include_once './Services/Object/classes/class.ilSubItemListGUI.php';
}
}

+ Here is the call graph for this function:

Member Function Documentation

ilSearchResultPresentation::appendAdditionalInformation (   $item_list_gui,
  $ref_id,
  $obj_id,
  $type 
)

Append path, relevance information.

Definition at line 358 of file class.ilSearchResultPresentation.php.

References $ref_id, $tpl, $type, appendMorePathes(), appendPath(), and appendSubItems().

{
$sub = $this->appendSubItems($item_list_gui,$ref_id,$obj_id,$type);
$path = $this->appendPath($ref_id);
$more = $this->appendMorePathes($ref_id);
#$rel = $this->appendRelevance($obj_id);
if(!strlen($sub) and
!strlen($path) and
!strlen($more) and
!strlen($rel))
{
return '';
}
$tpl = new ilTemplate('tpl.lucene_additional_information.html',true,true,'Services/Search');
$tpl->setVariable('SUBITEM',$sub);
if(strlen($path)) {
$tpl->setVariable('PATH',$path);
}
if(strlen($more)) {
$tpl->setVariable('MORE_PATH',$more);
}
if(strlen($rel)) {
$tpl->setVariable('RELEVANCE',$rel);
}
$item_list_gui->setAdditionalInformation($tpl->get());
//$item_list_gui->setAdditionalInformation("Hello");
}

+ Here is the call graph for this function:

ilSearchResultPresentation::appendMorePathes (   $a_ref_id)
protected

Append more occurences link.

Returns

Definition at line 409 of file class.ilSearchResultPresentation.php.

References $tpl, getContainer(), getMode(), and hasMoreReferences().

Referenced by appendAdditionalInformation().

{
if($this->getMode() != self::MODE_LUCENE)
{
return '';
}
if(!$num_refs = $this->hasMoreReferences($a_ref_id))
{
return '';
}
$tpl = new ilTemplate('tpl.lucene_more_references.html',true,true,'Services/Search');
$this->ctrl->setParameter($this->getContainer(),'refs',$a_ref_id);
$tpl->setVariable('MORE_REFS_LINK',$this->ctrl->getLinkTarget($this->getContainer(),''));
$this->ctrl->clearParameters($this->getContainer());
$tpl->setVariable('TXT_MORE_REFS',sprintf($this->lng->txt('lucene_all_occurrences'),$num_refs));
return $tpl->get();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilSearchResultPresentation::appendPath (   $a_ref_id)
protected

Append path.

Returns

Definition at line 393 of file class.ilSearchResultPresentation.php.

References $tpl.

Referenced by appendAdditionalInformation().

{
include_once './Services/Tree/classes/class.ilPathGUI.php';
$path_gui = new ilPathGUI();
$path_gui->enableTextOnly(false);
$path_gui->setUseImages(false);
$tpl = new ilTemplate('tpl.lucene_path.html',true,true,'Services/Search');
$tpl->setVariable('PATH_ITEM',$path_gui->getPath(ROOT_FOLDER_ID,$a_ref_id));
return $tpl->get();
}

+ Here is the caller graph for this function:

ilSearchResultPresentation::appendRelevance (   $a_obj_id)
protected

Append relevance.

Returns

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

References $tpl, ilUtil\getImagePath(), ilSearchSettings\getInstance(), getMode(), and getRelevance().

{
if($this->getMode() != self::MODE_LUCENE)
{
return '';
}
if(!((int) $this->getRelevance($a_obj_id)))
{
return '';
}
include_once './Services/Search/classes/class.ilSearchSettings.php';
if(!ilSearchSettings::getInstance()->isRelevanceVisible())
{
return '';
}
$tpl = new ilTemplate('tpl.lucene_relevance.html',true,true,'Services/Search');
$width1 = (int) $this->getRelevance($a_obj_id);
$width2 = (int) (100 - $width1);
$tpl->setCurrentBlock('relevance');
$tpl->setVariable('VAL_REL',sprintf("%d %%",$this->getRelevance($a_obj_id)));
$tpl->setVariable('WIDTH_A',$width1);
$tpl->setVariable('WIDTH_B',$width2);
$tpl->setVariable('IMG_A',ilUtil::getImagePath("relevance_blue.gif"));
$tpl->setVariable('IMG_B',ilUtil::getImagePath("relevance_dark.gif"));
$tpl->parseCurrentBlock();
$html = $tpl->get();
return $html;
}

+ Here is the call graph for this function:

ilSearchResultPresentation::appendSubItems (   $item_list_gui,
  $ref_id,
  $obj_id,
  $a_type 
)
protected

Append subitems.

Returns

Definition at line 472 of file class.ilSearchResultPresentation.php.

References $ref_id, $subitem_ids, elseif(), getContainer(), ilLuceneSubItemListGUIFactory\getInstanceByType(), getMode(), and getSubitemIdsByObject().

Referenced by appendAdditionalInformation().

{
$subitem_ids = array();
if($this->getMode() == self::MODE_STANDARD)
{
$highlighter = null;
}
elseif(is_object($this->searcher->getHighlighter()))
{
$subitem_ids = $this->searcher->getHighlighter()->getSubitemIds($obj_id);
$highlighter = $this->searcher->getHighlighter();
}
if(!count($subitem_ids))
{
return;
}
// Build subitem list
include_once './Services/Search/classes/Lucene/class.ilLuceneSubItemListGUIFactory.php';
$sub_list->setHighlighter($highlighter);
$sub_list->init($item_list_gui,$ref_id,$subitem_ids);
return $sub_list->getHTML();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilSearchResultPresentation::getAllReferences (   $a_ref_id)
protected

Definition at line 178 of file class.ilSearchResultPresentation.php.

References $_SESSION.

Referenced by renderItemList().

{
if(isset($_SESSION['vis_references'][$a_ref_id]))
{
return $this->all_references[$a_ref_id] ? $this->all_references[$a_ref_id] : array();
}
else
{
return array($a_ref_id);
}
}

+ Here is the caller graph for this function:

ilSearchResultPresentation::getContainer ( )

Get container gui.

Definition at line 76 of file class.ilSearchResultPresentation.php.

References $container.

Referenced by appendMorePathes(), and appendSubItems().

{
}

+ Here is the caller graph for this function:

ilSearchResultPresentation::getHTML (   $a_new = false)

Get HTML.

Returns
string HTML

Definition at line 194 of file class.ilSearchResultPresentation.php.

{
return $this->thtml;
}
ilSearchResultPresentation::getMode ( )

Definition at line 81 of file class.ilSearchResultPresentation.php.

References $mode.

Referenced by appendMorePathes(), appendRelevance(), appendSubItems(), getRelevance(), lookupContent(), lookupDescription(), and lookupTitle().

{
return $this->mode;
}

+ Here is the caller graph for this function:

ilSearchResultPresentation::getRelevance (   $a_obj_id)

get relevance

Parameters
@return

Definition at line 296 of file class.ilSearchResultPresentation.php.

References getMode().

Referenced by appendRelevance(), and renderItemList().

{
if($this->getMode() == self::MODE_LUCENE)
{
return $this->searcher->getResult()->getRelevance($a_obj_id);
}
return 0;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilSearchResultPresentation::getResults ( )

get results

Returns
array result array

Definition at line 99 of file class.ilSearchResultPresentation.php.

Referenced by parseResultReferences(), and renderItemList().

{
return $this->results ? $this->results : array();
}

+ Here is the caller graph for this function:

ilSearchResultPresentation::getSubitemIds ( )

Get subitem ids.

Returns

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

{
return $this->subitem_ids ? $this->subitem_ids : array();
}
ilSearchResultPresentation::getSubitemIdsByObject (   $a_obj_id)

Get subitem ids for an object.

Parameters
int$a_obj_id
Returns

Definition at line 129 of file class.ilSearchResultPresentation.php.

Referenced by appendSubItems().

{
return (isset($this->subitem_ids[$a_obj_id]) and $this->subitem_ids[$a_obj_id]) ?
$this->subitem_ids[$a_obj_id] :
array();
}

+ Here is the caller graph for this function:

ilSearchResultPresentation::hasMoreReferences (   $a_ref_id)
protected

Definition at line 166 of file class.ilSearchResultPresentation.php.

References $_SESSION.

Referenced by appendMorePathes().

{
if(!isset($this->has_more_ref_ids[$a_ref_id]) or
!$this->has_more_ref_ids[$a_ref_id] or
isset($_SESSION['vis_references'][$a_ref_id]))
{
return false;
}
return $this->has_more_ref_ids[$a_ref_id];
}

+ Here is the caller graph for this function:

ilSearchResultPresentation::initReferences ( )
protected

Definition at line 500 of file class.ilSearchResultPresentation.php.

References $_SESSION.

Referenced by __construct().

{
if(isset($_REQUEST['refs']))
{
$_SESSION['vis_references'][(int) $_REQUEST['refs']] = (int) $_REQUEST['refs'];
}
}

+ Here is the caller graph for this function:

ilSearchResultPresentation::lookupContent (   $a_obj_id,
  $a_sub_id 
)

get content

Parameters
@return

Definition at line 346 of file class.ilSearchResultPresentation.php.

References getMode().

{
if($this->getMode() != self::MODE_LUCENE or !is_object($this->searcher->getHighlighter()))
{
return '';
}
return $this->searcher->getHighlighter()->getContent($a_obj_id,$a_sub_id);
}

+ Here is the call graph for this function:

ilSearchResultPresentation::lookupDescription (   $a_obj_id,
  $a_sub_id 
)
Parameters
@return

Definition at line 328 of file class.ilSearchResultPresentation.php.

References $title, ilObject\_lookupDescription(), and getMode().

Referenced by renderItemList().

{
if($this->getMode() != self::MODE_LUCENE or !is_object($this->searcher->getHighlighter()))
{
return ilObject::_lookupDescription($a_obj_id);
}
if(strlen($title = $this->searcher->getHighlighter()->getDescription($a_obj_id,$a_sub_id)))
{
return $title;
}
return ilObject::_lookupDescription($a_obj_id);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilSearchResultPresentation::lookupTitle (   $a_obj_id,
  $a_sub_id 
)
Parameters
@return

Definition at line 310 of file class.ilSearchResultPresentation.php.

References $title, ilObject\_lookupTitle(), and getMode().

Referenced by renderItemList().

{
if($this->getMode() != self::MODE_LUCENE or !is_object($this->searcher->getHighlighter()))
{
return ilObject::_lookupTitle($a_obj_id);
}
if(strlen($title = $this->searcher->getHighlighter()->getTitle($a_obj_id,$a_sub_id)))
{
return $title;
}
return ilObject::_lookupTitle($a_obj_id);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilSearchResultPresentation::parseResultReferences ( )
protected

Check if more than one reference is visible.

Definition at line 141 of file class.ilSearchResultPresentation.php.

References $ref_id, ilObject\_getAllReferences(), and getResults().

Referenced by renderItemList().

{
global $ilAccess;
foreach($this->getResults() as $ref_id => $obj_id)
{
$this->all_references[$ref_id][] = $ref_id;
$counter = 0;
foreach(ilObject::_getAllReferences($obj_id) as $new_ref)
{
if($new_ref == $ref_id)
{
continue;
}
if(!$ilAccess->checkAccess('read','',$new_ref))
{
continue;
}
$this->all_references[$ref_id][] = $new_ref;
++$counter;
}
$this->has_more_ref_ids[$ref_id] = $counter;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilSearchResultPresentation::render ( )

Parse results.

Parameters
void
Returns
string html

Definition at line 214 of file class.ilSearchResultPresentation.php.

References renderItemList().

{
return $this->renderItemList();
}

+ Here is the call graph for this function:

ilSearchResultPresentation::renderItemList ( )
protected

Render item list.

Returns
void

Definition at line 233 of file class.ilSearchResultPresentation.php.

References $ilBench, $ref_id, ilObject\_lookupTitle(), ilObject\_lookupType(), getAllReferences(), getRelevance(), getResults(), lookupDescription(), lookupTitle(), and parseResultReferences().

Referenced by render().

{
global $tree,$ilBench;
$this->html = '';
$ilBench->start('Lucene','2000_pr');
$item_html = array();
$ilBench->stop('Lucene','2000_pr');
$set = array();
foreach($this->getResults() as $c_ref_id => $res_data)
{
$ilBench->start('Lucene','2100_res');
foreach($this->getAllReferences($c_ref_id) as $ref_id)
{
$ilBench->start('Lucene','2120_tree');
if(!$tree->isInTree($ref_id))
{
continue;
}
$ilBench->stop('Lucene','2120_tree');
$set[] = array(
"ref_id" => $ref_id,
"obj_id" => $res_data,
"title" => $this->lookupTitle($res_data,0),
"title_sort"=> ilObject::_lookupTitle($res_data),
"description" => $this->lookupDescription($res_data,0),
"type" => ilObject::_lookupType($res_data),
"relevance" => $this->getRelevance($res_data),
"s_relevance" => sprintf("%03d",$this->getRelevance($res_data))
);
}
$ilBench->stop('Lucene','2100_res');
}
if(!count($set))
{
return false;
}
$ilBench->start('Lucene','2900_tb');
include_once("./Services/Search/classes/class.ilSearchResultTableGUI.php");
$result_table = new ilSearchResultTableGUI($this->container, "showSavedResults", $this);
$result_table->setCustomPreviousNext($this->prev, $this->next);
$result_table->setData($set);
$this->thtml = $result_table->getHTML();
$ilBench->stop('Lucene','2900_tb');
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilSearchResultPresentation::setPreviousNext (   $a_p,
  $a_n 
)

Set previous next.

Definition at line 222 of file class.ilSearchResultPresentation.php.

{
$this->prev = $a_p;
$this->next = $a_n;
}
ilSearchResultPresentation::setResults (   $a_result_data)

Set result array.

Parameters
array$a_result_dataresult array

Definition at line 90 of file class.ilSearchResultPresentation.php.

{
$this->results = $a_result_data;
}
ilSearchResultPresentation::setSearcher (   $a_searcher)

set searcher

Parameters
@return

Definition at line 204 of file class.ilSearchResultPresentation.php.

{
$this->searcher = $a_searcher;
}
ilSearchResultPresentation::setSubitemIds (   $a_subids)

Set subitem ids Used for like and fulltext search.

Parameters
array$a_subidsarray ($obj_id => array(page1_id,page2_id);
Returns

Definition at line 110 of file class.ilSearchResultPresentation.php.

{
$this->subitem_ids = $a_subids;
}

Field Documentation

ilSearchResultPresentation::$all_references = null
private

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

ilSearchResultPresentation::$container = null
private

Definition at line 49 of file class.ilSearchResultPresentation.php.

Referenced by __construct(), and getContainer().

ilSearchResultPresentation::$has_more_ref_ids = array()
private

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

ilSearchResultPresentation::$lng
protected

Definition at line 41 of file class.ilSearchResultPresentation.php.

Referenced by __construct().

ilSearchResultPresentation::$mode
protected

Definition at line 38 of file class.ilSearchResultPresentation.php.

Referenced by getMode().

ilSearchResultPresentation::$results = array()
private

Definition at line 43 of file class.ilSearchResultPresentation.php.

ilSearchResultPresentation::$searcher = null
private

Definition at line 47 of file class.ilSearchResultPresentation.php.

ilSearchResultPresentation::$subitem_ids = array()
private

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

Referenced by appendSubItems().

ilSearchResultPresentation::$tpl
protected
const ilSearchResultPresentation::MODE_LUCENE = 1

Definition at line 35 of file class.ilSearchResultPresentation.php.


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