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

Search Auto Completion Application Class. More...

+ Collaboration diagram for ilSearchAutoComplete:

Static Public Member Functions

static getLuceneList ($a_str)
 Performs better than standard like search on huge installations.
static getList ($a_str)
 Get completion list.
static checkObjectPermission ($a_obj_id)
 Checks read permission on obj id.

Detailed Description

Search Auto Completion Application Class.

Definition at line 10 of file class.ilSearchAutoComplete.php.

Member Function Documentation

static ilSearchAutoComplete::checkObjectPermission (   $a_obj_id)
static

Checks read permission on obj id.

Definition at line 148 of file class.ilSearchAutoComplete.php.

References ilObject\_getAllReferences().

Referenced by getList().

{
global $ilAccess;
$refs = ilObject::_getAllReferences($a_obj_id);
foreach ($refs as $ref)
{
if ($ilAccess->checkAccess("read", "", $ref))
{
return true;
}
}
return false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilSearchAutoComplete::getList (   $a_str)
static

Get completion list.

Definition at line 66 of file class.ilSearchAutoComplete.php.

References $result, checkObjectPermission(), ilJsonUtil\encode(), ilSearchSettings\getInstance(), and getLuceneList().

Referenced by ilSearchGUI\autoComplete(), and ilSearchBaseGUI\autoComplete().

{
global $ilDB;
include_once './Services/Search/classes/class.ilSearchSettings.php';
if(ilSearchSettings::getInstance()->isLuceneUserSearchEnabled())
{
return self::getLuceneList($a_str);
}
$a_str = str_replace('"', "", $a_str);
$settings = new ilSearchSettings();
$object_types = array('cat','dbk','crs','fold','frm','grp','lm','sahs','glo','mep','htlm','exc','file','qpl','tst','svy','spl',
'chat','icrs','icla','webr','mcst','sess','pg','st','gdf','wiki');
$set = $ilDB->query("SELECT title, obj_id FROM object_data WHERE "
.$ilDB->like('title', 'text', $a_str."%")." AND "
.$ilDB->in('type', $object_types, false, 'text')." ORDER BY title");
$max = ($settings->getAutoCompleteLength() > 0)
? $settings->getAutoCompleteLength()
: 10;
$cnt = 0;
$list = array();
$checked = array();
$lim = "";
while (($rec = $ilDB->fetchAssoc($set)) && $cnt < $max)
{
if (strpos($rec["title"], " ") > 0 || strpos($rec["title"], "-") > 0)
{
$rec["title"] = '"'.$rec["title"].'"';
}
if (!in_array($rec["title"], $list) && !in_array($rec["obj_id"], $checked))
{
{
$list[] = $lim.$rec["title"];
$cnt++;
}
$checked[] = $rec["obj_id"];
}
}
$set = $ilDB->query("SELECT rbac_id,obj_id,obj_type, keyword FROM il_meta_keyword WHERE "
.$ilDB->like('keyword', 'text', $a_str."%")." AND "
.$ilDB->in('obj_type', $object_types, false, 'text')." ORDER BY keyword");
while (($rec = $ilDB->fetchAssoc($set)) && $cnt < $max)
{
if (strpos($rec["keyword"], " ") > 0)
{
$rec["keyword"] = '"'.$rec["keyword"].'"';
}
if (!in_array($rec["keyword"], $list) && !in_array($rec["rbac_id"], $checked))
{
{
$list[] = $lim.$rec["keyword"];
$cnt++;
}
}
$checked[] = $rec["rbac_id"];
}
$i = 0;
$result = array();
foreach ($list as $l)
{
$result[$i] = new stdClass();
$result[$i]->value = $l;
$i++;
}
include_once './Services/JSON/classes/class.ilJsonUtil.php';
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilSearchAutoComplete::getLuceneList (   $a_str)
static

Performs better than standard like search on huge installations.

Definition at line 16 of file class.ilSearchAutoComplete.php.

References $res, $result, ilObject\_lookupTitle(), ilJsonUtil\encode(), ilSearchSettings\getInstance(), ilLuceneSearcher\getInstance(), and ilLuceneSearcher\TYPE_STANDARD.

Referenced by getList().

{
include_once './Services/Search/classes/Lucene/class.ilLuceneQueryParser.php';
$qp = new ilLuceneQueryParser('title:'.$a_str.'*');
$qp->parse();
include_once './Services/Search/classes/Lucene/class.ilLuceneSearcher.php';
$searcher->setType(ilLuceneSearcher::TYPE_STANDARD);
$searcher->search();
$res = $searcher->getResult()->getCandidates();
$max_entries = ilSearchSettings::getInstance()->getAutoCompleteLength() ?
ilSearchSettings::getInstance()->getAutoCompleteLength() :
10;
$list = array();
$num_entries = 0;
foreach($res as $res_obj_id)
{
if(self::checkObjectPermission($res_obj_id))
{
$list[] = ilObject::_lookupTitle($res_obj_id,true);
$num_entries++;
}
if($num_entries >= $max_entries)
{
break;
}
}
$i = 0;
$result = array();
foreach($list as $entry)
{
$result[$i] = new stdClass();
$result[$i]->value = $entry;
$i++;
}
include_once './Services/JSON/classes/class.ilJsonUtil.php';
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


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