ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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. More...
 
static getList ($a_str)
 Get completion list. More...
 
static checkObjectPermission ($a_obj_id)
 Checks read permission on obj id. More...
 

Detailed Description

Search Auto Completion Application Class.

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

Member Function Documentation

◆ checkObjectPermission()

static ilSearchAutoComplete::checkObjectPermission (   $a_obj_id)
static

Checks read permission on obj id.

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

135 {
136 global $ilAccess;
137
138 $refs = ilObject::_getAllReferences($a_obj_id);
139 foreach ($refs as $ref) {
140 if ($ilAccess->checkAccess("read", "", $ref)) {
141 return true;
142 }
143 }
144 return false;
145 }
static _getAllReferences($a_id)
get all reference ids of object

References ilObject\_getAllReferences().

Referenced by getList().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getList()

static ilSearchAutoComplete::getList (   $a_str)
static

Get completion list.

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

63 {
64 global $ilDB;
65
66 include_once './Services/Search/classes/class.ilSearchSettings.php';
67 if (ilSearchSettings::getInstance()->enabledLucene()) {
68 return self::getLuceneList($a_str);
69 }
70
71
72 $a_str = str_replace('"', "", $a_str);
73
74 $settings = new ilSearchSettings();
75
76 $object_types = array('cat','dbk','crs','fold','frm','grp','lm','sahs','glo','mep','htlm','exc','file','qpl','tst','svy','spl',
77 'chat', 'webr','mcst','sess','pg','st','gdf','wiki');
78
79 $set = $ilDB->query("SELECT title, obj_id FROM object_data WHERE "
80 . $ilDB->like('title', 'text', $a_str . "%") . " AND "
81 . $ilDB->in('type', $object_types, false, 'text') . " ORDER BY title");
82 $max = ($settings->getAutoCompleteLength() > 0)
83 ? $settings->getAutoCompleteLength()
84 : 10;
85
86 $cnt = 0;
87 $list = array();
88 $checked = array();
89 $lim = "";
90 while (($rec = $ilDB->fetchAssoc($set)) && $cnt < $max) {
91 if (strpos($rec["title"], " ") > 0 || strpos($rec["title"], "-") > 0) {
92 $rec["title"] = '"' . $rec["title"] . '"';
93 }
94 if (!in_array($rec["title"], $list) && !in_array($rec["obj_id"], $checked)) {
96 $list[] = $lim . $rec["title"];
97 $cnt++;
98 }
99 $checked[] = $rec["obj_id"];
100 }
101 }
102
103 $set = $ilDB->query("SELECT rbac_id,obj_id,obj_type, keyword FROM il_meta_keyword WHERE "
104 . $ilDB->like('keyword', 'text', $a_str . "%") . " AND "
105 . $ilDB->in('obj_type', $object_types, false, 'text') . " ORDER BY keyword");
106 while (($rec = $ilDB->fetchAssoc($set)) && $cnt < $max) {
107 if (strpos($rec["keyword"], " ") > 0) {
108 $rec["keyword"] = '"' . $rec["keyword"] . '"';
109 }
110 if (!in_array($rec["keyword"], $list) && !in_array($rec["rbac_id"], $checked)) {
111 if (ilSearchAutoComplete::checkObjectPermission($rec["rbac_id"])) {
112 $list[] = $lim . $rec["keyword"];
113 $cnt++;
114 }
115 }
116 $checked[] = $rec["rbac_id"];
117 }
118
119 $i = 0;
120 $result = array();
121 foreach ($list as $l) {
122 $result[$i] = new stdClass();
123 $result[$i]->value = $l;
124 $i++;
125 }
126
127 include_once './Services/JSON/classes/class.ilJsonUtil.php';
129 }
$result
global $l
Definition: afr.php:30
static encode($mixed, $suppress_native=false)
static checkObjectPermission($a_obj_id)
Checks read permission on obj id.
static getLuceneList($a_str)
Performs better than standard like search on huge installations.
$i
Definition: disco.tpl.php:19
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
global $ilDB

References $i, $ilDB, $l, $list, $result, checkObjectPermission(), ilJsonUtil\encode(), ilSearchSettings\getInstance(), and getLuceneList().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLuceneList()

static ilSearchAutoComplete::getLuceneList (   $a_str)
static

Performs better than standard like search on huge installations.

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

17 {
18 include_once './Services/Search/classes/Lucene/class.ilLuceneQueryParser.php';
19 $qp = new ilLuceneQueryParser('title:' . $a_str . '*');
20 $qp->parse();
21
22 include_once './Services/Search/classes/Lucene/class.ilLuceneSearcher.php';
23 $searcher = ilLuceneSearcher::getInstance($qp);
24 $searcher->setType(ilLuceneSearcher::TYPE_STANDARD);
25 $searcher->search();
26
27 $res = $searcher->getResult()->getCandidates();
28
29 $max_entries = ilSearchSettings::getInstance()->getAutoCompleteLength() ?
30 ilSearchSettings::getInstance()->getAutoCompleteLength() :
31 10;
32
33
34 $list = array();
35 $num_entries = 0;
36 foreach ($res as $res_obj_id) {
37 if (self::checkObjectPermission($res_obj_id)) {
38 $list[] = ilObject::_lookupTitle($res_obj_id, true);
39 $num_entries++;
40 }
41 if ($num_entries >= $max_entries) {
42 break;
43 }
44 }
45
46 $i = 0;
47 $result = array();
48 foreach ($list as $entry) {
49 $result[$i] = new stdClass();
50 $result[$i]->value = '"' . $entry . '"';
51 $i++;
52 }
53 include_once './Services/JSON/classes/class.ilJsonUtil.php';
55 }
static getInstance(ilLuceneQueryParser $qp)
Get singleton instance.
static _lookupTitle($a_id)
lookup object title
foreach($_POST as $key=> $value) $res

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

Referenced by getList().

+ 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: