19 declare(strict_types=1);
35 $res = $searcher->getResult()->getCandidates();
44 foreach (
$res as $res_obj_id) {
45 if (self::checkObjectPermission($res_obj_id)) {
49 if ($num_entries >= $max_entries) {
56 foreach ($list as $entry) {
58 $result[$i]->value =
'"' . $entry .
'"';
62 return json_encode($result, JSON_THROW_ON_ERROR);
67 public static function getList(
string $a_str): string
71 $ilDB = $DIC->database();
74 return self::getLuceneList($a_str);
78 $a_str = str_replace(
'"',
"", $a_str);
82 $object_types = array(
'cat',
'dbk',
'crs',
'fold',
'frm',
'grp',
'lm',
'sahs',
'glo',
'mep',
'htlm',
'exc',
'file',
'qpl',
'tst',
'svy',
'spl',
83 'chat',
'webr',
'mcst',
'sess',
'pg',
'st',
'term',
'wiki',
'copa');
85 $set =
$ilDB->query(
"SELECT title, obj_id FROM object_data WHERE " 86 .
$ilDB->like(
'title',
'text', $a_str .
"%") .
" AND " 87 .
$ilDB->in(
'type', $object_types,
false,
'text') .
" ORDER BY title");
88 $max = ($settings->getAutoCompleteLength() > 0)
89 ? $settings->getAutoCompleteLength()
96 while (($rec =
$ilDB->fetchAssoc($set)) && $cnt < $max) {
97 if (strpos($rec[
"title"],
" ") > 0 || strpos($rec[
"title"],
"-") > 0) {
98 $rec[
"title"] =
'"' . $rec[
"title"] .
'"';
100 if (!in_array($rec[
"title"], $list) && !in_array($rec[
"obj_id"], $checked)) {
102 $list[] = $lim . $rec[
"title"];
105 $checked[] = $rec[
"obj_id"];
109 $set =
$ilDB->query(
"SELECT rbac_id,obj_id,obj_type, keyword FROM il_meta_keyword WHERE " 110 .
$ilDB->like(
'keyword',
'text', $a_str .
"%") .
" AND " 111 .
$ilDB->in(
'obj_type', $object_types,
false,
'text') .
" ORDER BY keyword");
112 while (($rec =
$ilDB->fetchAssoc($set)) && $cnt < $max) {
113 if (strpos($rec[
"keyword"],
" ") > 0) {
114 $rec[
"keyword"] =
'"' . $rec[
"keyword"] .
'"';
116 if (!in_array($rec[
"keyword"], $list) && !in_array($rec[
"rbac_id"], $checked)) {
118 $list[] = $lim . $rec[
"keyword"];
122 $checked[] = $rec[
"rbac_id"];
127 foreach ($list as $l) {
129 $result[$i]->value = $l;
133 return json_encode($result, JSON_THROW_ON_ERROR);
140 $ilAccess = $DIC->access();
143 foreach ($refs as $ref) {
144 if ($ilAccess->checkAccess(
"read",
"", $ref)) {
static getLuceneList(string $a_str)
static getList(string $a_str)
static _getAllReferences(int $id)
get all reference ids for object ID
static getInstance(ilLuceneQueryParser $qp)
Get singleton instance.
static _lookupTitle(int $obj_id)
Search Auto Completion Application Class.
static checkObjectPermission(int $a_obj_id)