ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilRepositoryObjectDetailSearch Class Reference
+ Collaboration diagram for ilRepositoryObjectDetailSearch:

Public Member Functions

 __construct (int $a_obj_id)
 
 getSettings ()
 
 getObjId ()
 
 getType ()
 
 setQueryString (string $a_query)
 
 getQueryString ()
 
 performSearch ()
 

Protected Member Functions

 performLuceneSearch ()
 
 performDBSearch ()
 

Protected Attributes

ilSearchSettings $settings
 
int $obj_id
 
string $type
 
string $query_string
 

Detailed Description

Definition at line 30 of file class.ilRepositoryObjectDetailSearch.php.

Constructor & Destructor Documentation

◆ __construct()

ilRepositoryObjectDetailSearch::__construct ( int  $a_obj_id)

Definition at line 39 of file class.ilRepositoryObjectDetailSearch.php.

40 {
41 $this->obj_id = $a_obj_id;
42 $this->type = ilObject::_lookupType($this->getObjId());
43
45 }
static _lookupType(int $id, bool $reference=false)

References ilObject\_lookupType(), ilSearchSettings\getInstance(), getObjId(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

Member Function Documentation

◆ getObjId()

ilRepositoryObjectDetailSearch::getObjId ( )

Definition at line 52 of file class.ilRepositoryObjectDetailSearch.php.

References $obj_id.

Referenced by __construct(), performDBSearch(), and performLuceneSearch().

+ Here is the caller graph for this function:

◆ getQueryString()

ilRepositoryObjectDetailSearch::getQueryString ( )

Definition at line 69 of file class.ilRepositoryObjectDetailSearch.php.

References $query_string.

Referenced by performDBSearch(), and performLuceneSearch().

+ Here is the caller graph for this function:

◆ getSettings()

ilRepositoryObjectDetailSearch::getSettings ( )

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

References $settings.

Referenced by performDBSearch(), and performSearch().

+ Here is the caller graph for this function:

◆ getType()

ilRepositoryObjectDetailSearch::getType ( )

Definition at line 57 of file class.ilRepositoryObjectDetailSearch.php.

57 : string
58 {
59 return $this->type;
60 }

References $type.

Referenced by performDBSearch().

+ Here is the caller graph for this function:

◆ performDBSearch()

ilRepositoryObjectDetailSearch::performDBSearch ( )
protected
Exceptions
Exception

Definition at line 120 of file class.ilRepositoryObjectDetailSearch.php.

121 {
122 $query_parser = new ilQueryParser($this->getQueryString());
123
124 $query_parser->setCombination(
125 ($this->getSettings()->getDefaultOperator() == ilSearchSettings::OPERATOR_AND) ?
128 );
129 $query_parser->parse();
130
131 if (!$query_parser->validate()) {
132 throw new Exception($query_parser->getMessage());
133 }
134 $search_result = new ilSearchResult();
135
136 $search = ilObjectSearchFactory::getByTypeSearchInstance($this->getType(), $query_parser);
137
138 switch ($this->getType()) {
139 case 'wiki':
140 $search->setFilter(array('wpg'));
141 break;
142 }
143
144 $search->setIdFilter(array($this->getObjId()));
145
146 $search_result->mergeEntries($search->performSearch());
147
148 $detail_search_result = new ilRepositoryObjectDetailSearchResult();
149
150 foreach ($search_result->getEntries() as $entry) {
151 foreach ((array) $entry['child'] as $child) {
152 $detail_search_result->addResultSet(
153 array(
154 'obj_id' => $entry['obj_id'],
155 'item_id' => $child
156 )
157 );
158 }
159 }
160 return $detail_search_result;
161 }
static getByTypeSearchInstance(string $a_object_type, ilQueryParser $a_query_parser)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ilObjectSearchFactory\getByTypeSearchInstance(), getObjId(), getQueryString(), getSettings(), getType(), ilSearchSettings\OPERATOR_AND, ilQueryParser\QP_COMBINATION_AND, and ilQueryParser\QP_COMBINATION_OR.

Referenced by performSearch().

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

◆ performLuceneSearch()

ilRepositoryObjectDetailSearch::performLuceneSearch ( )
protected
Exceptions
ilLuceneQueryParserException

Definition at line 86 of file class.ilRepositoryObjectDetailSearch.php.

87 {
88 try {
89 $qp = new ilLuceneQueryParser($this->getQueryString());
90 $qp->parse();
92 ilLoggerFactory::getLogger('src')->warning('Invalid query: ' . $e->getMessage());
93 throw $e;
94 }
95
96 $searcher = ilLuceneSearcher::getInstance($qp);
97 $searcher->highlight(array($this->getObjId()));
98
99 $detail_search_result = new ilRepositoryObjectDetailSearchResult();
100
101 if ($searcher->getHighlighter() instanceof ilLuceneHighlighterResultParser) {
102 foreach ($searcher->getHighlighter()->getSubItemIds($this->getObjId()) as $sub_id) {
103 $detail_search_result->addResultSet(
104 array(
105 'obj_id' => $this->getObjId(),
106 'item_id' => $sub_id,
107 'relevance' => $searcher->getHighlighter()->getRelevance($this->getObjId(), $sub_id),
108 'content' => $searcher->getHighlighter()->getContent($this->getObjId(), $sub_id)
109 )
110 );
111 }
112 }
113 return $detail_search_result;
114 }
static getLogger(string $a_component_id)
Get component logger.
Parses result XML from lucene search highlight.
static getInstance(ilLuceneQueryParser $qp)
Get singleton instance.

References Vendor\Package\$e, ilLuceneSearcher\getInstance(), ilLoggerFactory\getLogger(), getObjId(), and getQueryString().

Referenced by performSearch().

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

◆ performSearch()

ilRepositoryObjectDetailSearch::performSearch ( )

Definition at line 74 of file class.ilRepositoryObjectDetailSearch.php.

75 {
76 if ($this->getSettings()->enabledLucene()) {
77 return $this->performLuceneSearch();
78 } else {
79 return $this->performDBSearch();
80 }
81 }

References getSettings(), performDBSearch(), and performLuceneSearch().

+ Here is the call graph for this function:

◆ setQueryString()

ilRepositoryObjectDetailSearch::setQueryString ( string  $a_query)

Definition at line 63 of file class.ilRepositoryObjectDetailSearch.php.

63 : void
64 {
65 $this->query_string = $a_query;
66 }

Field Documentation

◆ $obj_id

int ilRepositoryObjectDetailSearch::$obj_id
protected

Definition at line 34 of file class.ilRepositoryObjectDetailSearch.php.

Referenced by getObjId().

◆ $query_string

string ilRepositoryObjectDetailSearch::$query_string
protected

Definition at line 36 of file class.ilRepositoryObjectDetailSearch.php.

Referenced by getQueryString().

◆ $settings

ilSearchSettings ilRepositoryObjectDetailSearch::$settings
protected

Definition at line 32 of file class.ilRepositoryObjectDetailSearch.php.

Referenced by getSettings().

◆ $type

string ilRepositoryObjectDetailSearch::$type
protected

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

Referenced by getType().


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