ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilSearchGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilSearchGUI:
+ Collaboration diagram for ilSearchGUI:

Public Member Functions

 __construct ()
 Constructor public. More...
 
 executeCommand ()
 Control public. More...
 
 setType (int $a_type)
 Set/get type of search (detail or 'fast' search) public. More...
 
 getType ()
 
 setCombination (string $a_combination)
 Set/get combination of search ('and' or 'or') public. More...
 
 getCombination ()
 
 setString (string $a_str)
 Set/get search string public. More...
 
 getString ()
 
 setDetails (array $a_details)
 Set/get details (object types for details search) public. More...
 
 getDetails ()
 
 getRootNode ()
 
 setRootNode (int $a_node_id)
 
 remoteSearch ()
 
 autoComplete ()
 Data resource for autoComplete. More...
 
 showSearch ()
 
 showSavedResults ()
 
 performSearch ()
 Perform search. More...
 
 prepareOutput ()
 
 __parseQueryString ()
 parse query string, using query parser instance More...
 
 __searchObjects (ilQueryParser $query_parser)
 Search in obect title,desctiption. More...
 
 parseCreationFilter (ilObjectSearch $search)
 
 __searchMeta (ilQueryParser $query_parser, string $a_type)
 Search in object meta data (keyword) More...
 
 __getFilter ()
 Get object type for filter (If detail search is enabled) More...
 
- Public Member Functions inherited from ilSearchBaseGUI
 __construct ()
 
 prepareOutput ()
 
 initStandardSearchForm (int $a_mode)
 
 getSearchAreaForm ()
 
 handleCommand (string $a_cmd)
 
 addToDeskObject ()
 
 removeFromDeskObject ()
 
 delete ()
 Show delete confirmation. More...
 
 cancelDelete ()
 Cancel delete. More...
 
 cancelObject ()
 
 cancelMoveLinkObject ()
 
 performDelete ()
 
 cut ()
 
 link ()
 
 paste ()
 
 showLinkIntoMultipleObjectsTree ()
 
 showPasteTree ()
 
 showMoveIntoObjectTree ()
 
 performPasteIntoMultipleObjects ()
 
 clear ()
 clear clipboard More...
 
 enableAdministrationPanel ()
 
 disableAdministrationPanel ()
 
 keepObjectsInClipboardObject ()
 
 addLocator ()
 
 autoComplete ()
 
- Public Member Functions inherited from ILIAS\Object\ImplementsCreationCallback
 callCreationCallback (\ilObject $object, \ilObjectDefinition $obj_definition, int $requested_crtcb)
 

Data Fields

int $root_node
 
string $combination
 
string $string
 
int $type
 
- Data Fields inherited from ilSearchBaseGUI
const SEARCH_FAST = 1
 
const SEARCH_DETAILS = 2
 
const SEARCH_AND = 'and'
 
const SEARCH_OR = 'or'
 
const SEARCH_FORM_LUCENE = 1
 
const SEARCH_FORM_STANDARD = 2
 
const SEARCH_FORM_USER = 3
 

Protected Member Functions

 storeRoot ()
 Store new root node. More...
 
 __performDetailsSearch (ilQueryParser $query_parser, ilSearchResult $result)
 
 parseDateFromCreationFilter ()
 
 parseOperatorFromCreationFilter ()
 
- Protected Member Functions inherited from ilSearchBaseGUI
 initPageNumberFromQuery ()
 
 addPager ($result, string $a_session_key)
 
 buildSearchAreaPath (int $a_root_node)
 
 getCreationDateForm ()
 
 getSearchCache ()
 
 loadCreationFilter ()
 

Protected Attributes

ilTabsGUI $tabs_gui
 
ilHelpGUI $help_gui
 
- Protected Attributes inherited from ilSearchBaseGUI
ilUserSearchCache $search_cache
 
string $search_mode = ''
 
ilSearchSettings $settings
 
ilPropertyFormGUI $form = null
 
ClipboardManager $clipboard
 
ViewManager $container_view_manager
 
ilFavouritesManager $favourites
 
ilCtrl $ctrl
 
ILIAS $ilias
 
ilLanguage $lng
 
ilGlobalTemplateInterface $tpl
 
ilLocatorGUI $locator
 
ilObjUser $user
 
ilTree $tree
 
GlobalHttpState $http
 
Factory $refinery
 
ilLogger $logger
 
string $prev_link = ''
 
string $next_link = ''
 

Private Attributes

array $details
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilSearchGUI

GUI class for 'simple' search

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e ilSearchGUI: ilPropertyFormGUI ilSearchGUI: ilObjectGUI, ilContainerGUI ilSearchGUI: ilObjCategoryGUI, ilObjCourseGUI, ilObjFolderGUI, ilObjGroupGUI ilSearchGUI: ilObjStudyProgrammeGUI ilSearchGUI: ilObjRootFolderGUI, ilObjectCopyGUI

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

Constructor & Destructor Documentation

◆ __construct()

ilSearchGUI::__construct ( )

Constructor public.

Definition at line 50 of file class.ilSearchGUI.php.

References $DIC, $type, ILIAS\MetaData\Repository\Validation\Data\__construct(), ILIAS\Repository\form(), ilSession\get(), ilSearchSettings\getInstance(), ilSearchBaseGUI\getSearchCache(), ILIAS\FileDelivery\http(), ilSearchBaseGUI\initStandardSearchForm(), ILIAS\Repository\int(), ILIAS\Repository\lng(), ilSearchBaseGUI\loadCreationFilter(), ilSearchSettings\OPERATOR_AND, ILIAS\Repository\refinery(), ROOT_FOLDER_ID, ilSearchBaseGUI\SEARCH_FAST, ilSearchBaseGUI\SEARCH_FORM_STANDARD, ilSession\set(), setCombination(), setDetails(), setString(), setType(), and ilUtil\stripSlashes().

51  {
52  global $DIC;
54  $this->tabs_gui = $DIC->tabs();
55  $this->help_gui = $DIC->help();
56  $this->lng->loadLanguageModule("search");
57 
58  $post_search = (array) ($this->http->request()->getParsedBody()['search'] ?? []);
59  $post_filter_type = (array) ($this->http->request()->getParsedBody()['filter_type'] ?? []);
60  $post_cmd = (array) ($this->http->request()->getParsedBody()['cmd'] ?? []);
61  $new_search = (bool) ($post_cmd['performSearch'] ?? false);
62 
63  // put form values into "old" post variables
65 
66  if ($new_search) {
67  // Only call `checkInput` if this is a new POST request, otherwise a `failure` will be shown (red message)
68  $this->form->checkInput();
69  }
70 
71  $enabled_types = ilSearchSettings::getInstance()->getEnabledLuceneItemFilterDefinitions();
72  foreach ($enabled_types as $type => $pval) {
73  if (isset($post_filter_type[$type]) && $post_filter_type[$type] == 1) {
74  $post_search["details"][$type] = $post_filter_type[$type];
75  }
76  }
77 
78  $post_term = $this->http->wrapper()->post()->retrieve(
79  'term',
80  $this->refinery->byTrying([
81  $this->refinery->kindlyTo()->string(),
82  $this->refinery->always(null)
83  ])
84  );
85  $post_combination = $this->http->wrapper()->post()->retrieve(
86  'combination',
87  $this->refinery->byTrying([
88  $this->refinery->kindlyTo()->string(),
89  $this->refinery->always(null)
90  ])
91  );
92  $post_type = $this->http->wrapper()->post()->retrieve(
93  'type',
94  $this->refinery->byTrying([
95  $this->refinery->kindlyTo()->int(),
96  $this->refinery->always(null)
97  ])
98  );
99  $post_area = $this->http->wrapper()->post()->retrieve(
100  'area',
101  $this->refinery->byTrying([
102  $this->refinery->kindlyTo()->int(),
103  $this->refinery->always(null)
104  ])
105  );
106 
107  if ($new_search) {
108  ilSession::set('search_root', $post_area);
109  }
110 
111  $post_search["string"] = $post_term;
112  $post_search["combination"] = $post_combination;
113  $post_search["type"] = $post_type;
114 
115  $this->root_node = (int) (ilSession::get('search_root') ?? ROOT_FOLDER_ID);
116 
117  $session_search = ilSession::get('search') ?? [];
118  $this->setType((int) ($post_search['type'] ?? ($session_search['type'] ?? ilSearchBaseGUI::SEARCH_FAST)));
119 
120  $this->setCombination(
122  self::SEARCH_AND :
123  self::SEARCH_OR
124  );
125  $this->setString((string) ($post_search['string'] ?? ($session_search['string'] ?? '')));
126  $this->setDetails(
127  $new_search ?
128  ($post_search['details'] ?? []) :
129  ($session_search['details'] ?? [])
130  );
131 
132  if ($new_search) {
133  $this->getSearchCache()->setQuery(ilUtil::stripSlashes($post_term));
134  $this->getSearchCache()->setCreationFilter($this->loadCreationFilter());
135  $this->getSearchCache()->save();
136  }
137  }
static get(string $a_var)
setString(string $a_str)
Set/get search string public.
setCombination(string $a_combination)
Set/get combination of search ('and' or 'or') public.
const ROOT_FOLDER_ID
Definition: constants.php:32
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
setType(int $a_type)
Set/get type of search (detail or 'fast' search) public.
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.
__construct(VocabulariesInterface $vocabularies)
form( $class_path, string $cmd, string $submit_caption="")
initStandardSearchForm(int $a_mode)
static set(string $a_var, $a_val)
Set a value.
setDetails(array $a_details)
Set/get details (object types for details search) public.
+ Here is the call graph for this function:

Member Function Documentation

◆ __getFilter()

ilSearchGUI::__getFilter ( )

Get object type for filter (If detail search is enabled)

Returns
string[]

Definition at line 716 of file class.ilSearchGUI.php.

References ILIAS\LTI\ToolProvider\$key, getDetails(), getType(), and ilSearchBaseGUI\SEARCH_DETAILS.

Referenced by __performDetailsSearch(), __searchMeta(), and __searchObjects().

716  : array
717  {
718  if ($this->getType() != ilSearchBaseGUI::SEARCH_DETAILS) {
719  return [];
720  }
721 
722  $filter = [];
723  foreach ($this->getDetails() as $key => $detail_type) {
724  if (!$detail_type) {
725  continue;
726  }
727 
728  switch ($key) {
729  case 'lms':
730  $filter[] = 'lm';
731  $filter[] = 'dbk';
732  $filter[] = 'pg';
733  $filter[] = 'st';
734  $filter[] = 'sahs';
735  $filter[] = 'htlm';
736  break;
737 
738  case 'frm':
739  $filter[] = 'frm';
740  break;
741 
742  case 'glo':
743  $filter[] = 'glo';
744  break;
745 
746  case 'exc':
747  $filter[] = 'exc';
748  break;
749 
750  case 'mcst':
751  $filter[] = 'mcst';
752  break;
753 
754  case 'tst':
755  $filter[] = 'tst';
756  $filter[] = 'svy';
757  $filter[] = 'qpl';
758  $filter[] = 'spl';
759  break;
760 
761  case 'mep':
762  $filter[] = 'mep';
763  $filter[] = 'mob';
764  break;
765 
766  case 'fil':
767  $filter[] = 'file';
768  break;
769 
770  case 'wiki':
771  $filter[] = 'wpg';
772  break;
773 
774  default:
775  $filter[] = $key;
776  }
777  }
778  return $filter;
779  }
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __parseQueryString()

ilSearchGUI::__parseQueryString ( )

parse query string, using query parser instance

Returns
ilQueryParser | string

Definition at line 612 of file class.ilSearchGUI.php.

References getCombination(), getString(), and ilUtil\stripSlashes().

Referenced by performSearch().

613  {
614  $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->getString()));
615  $query_parser->setCombination($this->getCombination());
616  $query_parser->parse();
617 
618  if (!$query_parser->validate()) {
619  return $query_parser->getMessage();
620  }
621  return $query_parser;
622  }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __performDetailsSearch()

ilSearchGUI::__performDetailsSearch ( ilQueryParser  $query_parser,
ilSearchResult  $result 
)
protected

Definition at line 522 of file class.ilSearchGUI.php.

References ILIAS\LTI\ToolProvider\$enabled, __getFilter(), ilObjectSearchFactory\_getExerciseSearchInstance(), ilObjectSearchFactory\_getForumSearchInstance(), ilObjectSearchFactory\_getGlossaryDefinitionSearchInstance(), ilObjectSearchFactory\_getLMContentSearchInstance(), ilObjectSearchFactory\_getMediacastSearchInstance(), ilObjectSearchFactory\_getMediaPoolSearchInstance(), ilObjectSearchFactory\_getObjectSearchInstance(), ilObjectSearchFactory\_getTestSearchInstance(), ilObjectSearchFactory\_getWikiContentSearchInstance(), getDetails(), and ilSearchResult\mergeEntries().

Referenced by performSearch().

523  {
524  foreach ($this->getDetails() as $type => $enabled) {
525  if (!$enabled) {
526  continue;
527  }
528 
529  switch ($type) {
530  case 'crs':
531  $crs_search = ilObjectSearchFactory::_getObjectSearchInstance($query_parser);
532  $crs_search->setFilter(array('crs'));
533  $result->mergeEntries($crs_search->performSearch());
534  break;
535 
536  case 'grp':
537  $grp_search = ilObjectSearchFactory::_getObjectSearchInstance($query_parser);
538  $grp_search->setFilter(array('grp'));
539  $result->mergeEntries($grp_search->performSearch());
540  break;
541 
542  case 'lms':
543  $content_search = ilObjectSearchFactory::_getLMContentSearchInstance($query_parser);
544  $content_search->setFilter($this->__getFilter());
545  $result->mergeEntries($content_search->performSearch());
546  break;
547 
548  case 'frm':
549  $forum_search = ilObjectSearchFactory::_getForumSearchInstance($query_parser);
550  $forum_search->setFilter($this->__getFilter());
551  $result->mergeEntries($forum_search->performSearch());
552  break;
553 
554  case 'glo':
555  // Glossary term definition pages
556  $gdf_search = ilObjectSearchFactory::_getLMContentSearchInstance($query_parser);
557  $gdf_search->setFilter(array('term'));
558  $result->mergeEntries($gdf_search->performSearch());
559  // Glossary terms
560  $gdf_term_search = ilObjectSearchFactory::_getGlossaryDefinitionSearchInstance($query_parser);
561  $result->mergeEntries($gdf_term_search->performSearch());
562  break;
563 
564  case 'exc':
565  $exc_search = ilObjectSearchFactory::_getExerciseSearchInstance($query_parser);
566  $exc_search->setFilter($this->__getFilter());
567  $result->mergeEntries($exc_search->performSearch());
568  break;
569 
570  case 'mcst':
571  $mcst_search = ilObjectSearchFactory::_getMediacastSearchInstance($query_parser);
572  $result->mergeEntries($mcst_search->performSearch());
573  break;
574 
575  case 'tst':
576  $tst_search = ilObjectSearchFactory::_getTestSearchInstance($query_parser);
577  $tst_search->setFilter($this->__getFilter());
578  $result->mergeEntries($tst_search->performSearch());
579  break;
580 
581  case 'mep':
582  $mep_search = ilObjectSearchFactory::_getMediaPoolSearchInstance($query_parser);
583  $mep_search->setFilter($this->__getFilter());
584  $result->mergeEntries($mep_search->performSearch());
585 
586  // Mob keyword search
587  $mob_search = ilObjectSearchFactory::_getMediaPoolSearchInstance($query_parser);
588  $mob_search->setFilter($this->__getFilter());
589  $result->mergeEntries($mob_search->performKeywordSearch());
590 
591  break;
592 
593  case 'wiki':
594  $wiki_search = ilObjectSearchFactory::_getWikiContentSearchInstance($query_parser);
595  $wiki_search->setFilter($this->__getFilter());
596  $result->mergeEntries($wiki_search->performSearch());
597 
598  /*$result_meta =& $this->__searchMeta($query_parser,'title');
599  $result->mergeEntries($result_meta);
600  $result_meta =& $this->__searchMeta($query_parser,'description');
601  $result->mergeEntries($result_meta);*/
602  break;
603  }
604  }
605  return $result;
606  }
bool $enabled
Whether the system instance is enabled to accept connection requests.
Definition: System.php:123
static _getLMContentSearchInstance(ilQueryParser $query_parser)
static _getMediaPoolSearchInstance(ilQueryParser $query_parser)
static _getMediacastSearchInstance(ilQueryParser $query_parser)
static _getWikiContentSearchInstance(ilQueryParser $query_parser)
static _getExerciseSearchInstance(ilQueryParser $query_parser)
static _getGlossaryDefinitionSearchInstance(ilQueryParser $query_parser)
static _getForumSearchInstance(ilQueryParser $query_parser)
static _getObjectSearchInstance(ilQueryParser $query_parser)
static _getTestSearchInstance(ilQueryParser $query_parser)
mergeEntries(ilSearchResult $result_obj)
merge entries of this instance and another result object
__getFilter()
Get object type for filter (If detail search is enabled)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __searchMeta()

ilSearchGUI::__searchMeta ( ilQueryParser  $query_parser,
string  $a_type 
)

Search in object meta data (keyword)

Returns
ilSearchResult result object public

Definition at line 687 of file class.ilSearchGUI.php.

References __getFilter(), ilObjectSearchFactory\_getMetaDataSearchInstance(), getType(), and ilSearchBaseGUI\SEARCH_DETAILS.

Referenced by performSearch().

688  {
689  $meta_search = ilObjectSearchFactory::_getMetaDataSearchInstance($query_parser);
690  if ($this->getType() == ilSearchBaseGUI::SEARCH_DETAILS) {
691  $meta_search->setFilter($this->__getFilter());
692  }
693  switch ($a_type) {
694  case 'keyword':
695  $meta_search->setMode('keyword');
696  break;
697 
698  case 'contribute':
699  $meta_search->setMode('contribute');
700  break;
701 
702  case 'title':
703  $meta_search->setMode('title');
704  break;
705 
706  case 'description':
707  $meta_search->setMode('description');
708  break;
709  }
710  return $meta_search->performSearch();
711  }
__getFilter()
Get object type for filter (If detail search is enabled)
static _getMetaDataSearchInstance(ilQueryParser $query_parser)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __searchObjects()

ilSearchGUI::__searchObjects ( ilQueryParser  $query_parser)

Search in obect title,desctiption.

Definition at line 626 of file class.ilSearchGUI.php.

References __getFilter(), ilObjectSearchFactory\_getObjectSearchInstance(), getType(), parseCreationFilter(), and ilSearchBaseGUI\SEARCH_DETAILS.

Referenced by performSearch().

627  {
628  $obj_search = ilObjectSearchFactory::_getObjectSearchInstance($query_parser);
629  if ($this->getType() == ilSearchBaseGUI::SEARCH_DETAILS) {
630  $obj_search->setFilter($this->__getFilter());
631  }
632  $this->parseCreationFilter($obj_search);
633  return $obj_search->performSearch();
634  }
static _getObjectSearchInstance(ilQueryParser $query_parser)
parseCreationFilter(ilObjectSearch $search)
__getFilter()
Get object type for filter (If detail search is enabled)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ autoComplete()

ilSearchGUI::autoComplete ( )

Data resource for autoComplete.

Definition at line 284 of file class.ilSearchGUI.php.

References $res, exit, ilSearchAutoComplete\getList(), ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

284  : void
285  {
286  $query = '';
287  if ($this->http->wrapper()->post()->has('term')) {
288  $query = $this->http->wrapper()->post()->retrieve(
289  'term',
290  $this->refinery->kindlyTo()->string()
291  );
292  } elseif ($this->http->wrapper()->query()->has('term')) {
293  $query = $this->http->wrapper()->query()->retrieve(
294  'term',
295  $this->refinery->kindlyTo()->string()
296  );
297  }
298  $search_type = 0;
299  if ($this->http->wrapper()->post()->has('search_type')) {
300  $search_type = $this->http->wrapper()->post()->retrieve(
301  'search_type',
302  $this->refinery->kindlyTo()->int()
303  );
304  } elseif ($this->http->wrapper()->query()->has('search_type')) {
305  $search_type = $this->http->wrapper()->query()->retrieve(
306  'search_type',
307  $this->refinery->kindlyTo()->int()
308  );
309  }
310  if ((int) $search_type === -1) {
311  $a_fields = array('login','firstname','lastname','email');
312  $result_field = 'login';
313 
314  // Starting user autocomplete search
315  $auto = new ilUserAutoComplete();
316 
317 
318  $auto->setMoreLinkAvailable(true);
319  $auto->setSearchFields($a_fields);
320  $auto->setResultField($result_field);
321  $auto->enableFieldSearchableCheck(true);
322  $auto->setUserLimitations(true);
323 
324  $res = $auto->getList($query);
325  $res_obj = json_decode($res);
326  if (is_array($res_obj->items)) {
327  echo json_encode($res_obj->items);
328  exit;
329  }
330  } else {
331  $list = ilSearchAutoComplete::getList($query);
332  echo $list;
333  exit;
334  }
335  }
$res
Definition: ltiservices.php:69
exit
Definition: login.php:29
static getList(string $a_str)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:

◆ executeCommand()

ilSearchGUI::executeCommand ( )

Control public.

Definition at line 144 of file class.ilSearchGUI.php.

References ilSearchBaseGUI\$form, ILIAS\Repository\ctrl(), ilSearchBaseGUI\getSearchAreaForm(), ilSearchBaseGUI\handleCommand(), and prepareOutput().

144  : void
145  {
146  $next_class = $this->ctrl->getNextClass($this);
147  $cmd = $this->ctrl->getCmd();
148 
149  switch ($next_class) {
150  case "ilpropertyformgui":
151  //$this->initStandardSearchForm(ilSearchBaseGUI::SEARCH_FORM_STANDARD);
152  $form = $this->getSearchAreaForm();
153  $this->prepareOutput();
154  $this->ctrl->setReturn($this, 'storeRoot');
155  $this->ctrl->forwardCommand($form);
156  return;
157 
158  case 'ilobjectcopygui':
159  $this->prepareOutput();
160  $this->ctrl->setReturn($this, '');
161  $cp = new ilObjectCopyGUI($this);
162  $this->ctrl->forwardCommand($cp);
163  break;
164 
165  default:
166  if (!$cmd) {
167  $cmd = "showSavedResults";
168  }
169  $this->prepareOutput();
170  $this->handleCommand($cmd);
171  break;
172  }
173  }
GUI class for the workflow of copying objects.
ilPropertyFormGUI $form
handleCommand(string $a_cmd)
+ Here is the call graph for this function:

◆ getCombination()

ilSearchGUI::getCombination ( )

Definition at line 200 of file class.ilSearchGUI.php.

References ilSearchBaseGUI\SEARCH_OR.

Referenced by __parseQueryString().

200  : string
201  {
202  return $this->combination ?: ilSearchBaseGUI::SEARCH_OR;
203  }
+ Here is the caller graph for this function:

◆ getDetails()

ilSearchGUI::getDetails ( )

Definition at line 228 of file class.ilSearchGUI.php.

Referenced by __getFilter(), __performDetailsSearch(), and performSearch().

228  : array
229  {
230  return $this->details ?? [];
231  }
+ Here is the caller graph for this function:

◆ getRootNode()

ilSearchGUI::getRootNode ( )

Definition at line 234 of file class.ilSearchGUI.php.

References ROOT_FOLDER_ID.

Referenced by performSearch(), and showSavedResults().

234  : int
235  {
236  return $this->root_node ?: ROOT_FOLDER_ID;
237  }
const ROOT_FOLDER_ID
Definition: constants.php:32
+ Here is the caller graph for this function:

◆ getString()

ilSearchGUI::getString ( )

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

References $string.

Referenced by __parseQueryString(), and showSearch().

214  : string
215  {
216  return $this->string;
217  }
+ Here is the caller graph for this function:

◆ getType()

ilSearchGUI::getType ( )

Definition at line 186 of file class.ilSearchGUI.php.

References ilSearchBaseGUI\SEARCH_FAST.

Referenced by __getFilter(), __searchMeta(), __searchObjects(), and performSearch().

186  : int
187  {
188  return $this->type ?? ilSearchBaseGUI::SEARCH_FAST;
189  }
+ Here is the caller graph for this function:

◆ parseCreationFilter()

ilSearchGUI::parseCreationFilter ( ilObjectSearch  $search)

Definition at line 636 of file class.ilSearchGUI.php.

References parseDateFromCreationFilter(), parseOperatorFromCreationFilter(), ilObjectSearch\setCreationDateFilterDate(), and ilObjectSearch\setCreationDateFilterOperator().

Referenced by __searchObjects().

636  : bool
637  {
638  $date = $this->parseDateFromCreationFilter();
639  $operator = $this->parseOperatorFromCreationFilter();
640 
641  if (is_null($date) || is_null($operator)) {
642  return true;
643  }
644 
645  $search->setCreationDateFilterDate($date);
646  $search->setCreationDateFilterOperator($operator);
647  return true;
648  }
setCreationDateFilterOperator(int $a_operator)
setCreationDateFilterDate(ilDate $day)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseDateFromCreationFilter()

ilSearchGUI::parseDateFromCreationFilter ( )
protected

Definition at line 650 of file class.ilSearchGUI.php.

References ilSearchBaseGUI\getSearchCache(), and IL_CAL_UNIX.

Referenced by parseCreationFilter(), and performSearch().

650  : ?ilDate
651  {
652  $options = $this->getSearchCache()->getCreationFilter();
653  if (!($options['enabled'] ?? false)) {
654  return null;
655  }
656  return new ilDate($options['date'] ?? 0, IL_CAL_UNIX);
657  }
const IL_CAL_UNIX
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseOperatorFromCreationFilter()

ilSearchGUI::parseOperatorFromCreationFilter ( )
protected

Definition at line 659 of file class.ilSearchGUI.php.

References ilObjectSearch\CDATE_OPERATOR_AFTER, ilObjectSearch\CDATE_OPERATOR_BEFORE, ilObjectSearch\CDATE_OPERATOR_ON, and ilSearchBaseGUI\getSearchCache().

Referenced by parseCreationFilter(), and performSearch().

659  : ?int
660  {
661  $options = $this->getSearchCache()->getCreationFilter();
662  if (!($options['enabled'] ?? false)) {
663  return null;
664  }
665 
666  switch ($options['ontype'] ?? 0) {
667  case 1:
669 
670  case 2:
672 
673  case 3:
675 
676  default:
677  return null;
678  }
679  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performSearch()

ilSearchGUI::performSearch ( )

Perform search.

Definition at line 412 of file class.ilSearchGUI.php.

References __parseQueryString(), __performDetailsSearch(), __searchMeta(), __searchObjects(), ilSearchBaseGUI\addPager(), ilSession\clear(), getDetails(), ilSearchSettings\getInstance(), getRootNode(), getType(), ilSearchBaseGUI\initPageNumberFromQuery(), ILIAS\Repository\lng(), ilSearchResultPresentation\MODE_STANDARD, ilSearchSettings\OPERATOR_AND, parseDateFromCreationFilter(), parseOperatorFromCreationFilter(), ilSearchResult\read(), ilSearchBaseGUI\SEARCH_DETAILS, showSearch(), and ILIAS\Repository\user().

Referenced by remoteSearch(), and storeRoot().

412  : bool
413  {
414  $page_number = $this->initPageNumberFromQuery();
415  if (!$page_number and $this->search_mode != 'in_results') {
416  ilSession::clear('max_page');
417  $this->search_cache->deleteCachedEntries();
418  }
419 
420  $this->search_cache->setResultPageNumber($page_number);
421 
422  if ($this->getType() == ilSearchBaseGUI::SEARCH_DETAILS and !$this->getDetails()) {
423  $this->tpl->setOnScreenMessage('info', $this->lng->txt('search_choose_object_type'));
424  $this->showSearch();
425  return false;
426  }
427 
428  // Step 1: parse query string
429  if (!is_object($query_parser = $this->__parseQueryString())) {
430  $this->tpl->setOnScreenMessage('info', $query_parser);
431  $this->showSearch();
432 
433  return false;
434  }
435  // Step 2: perform object search. Get an ObjectSearch object via factory. Depends on fulltext or like search type.
436  $result = $this->__searchObjects($query_parser);
437 
438  // Step 3: perform meta keyword search. Get an MetaDataSearch object.
439  $result_meta = $this->__searchMeta($query_parser, 'keyword');
440  $result->mergeEntries($result_meta);
441 
442  $result_meta = $this->__searchMeta($query_parser, 'contribute');
443  $result->mergeEntries($result_meta);
444 
445  $result_meta = $this->__searchMeta($query_parser, 'title');
446  $result->mergeEntries($result_meta);
447 
448  $result_meta = $this->__searchMeta($query_parser, 'description');
449  $result->mergeEntries($result_meta);
450 
451  // Perform details search in object specific tables
452  if ($this->getType() == ilSearchBaseGUI::SEARCH_DETAILS) {
453  $result = $this->__performDetailsSearch($query_parser, $result);
454  }
455  // Step 5: Search in results
456  if ($this->search_mode == 'in_results') {
457  $old_result_obj = new ilSearchResult($this->user->getId());
458  $old_result_obj->read();
459 
460  $result->diffEntriesFromResult();
461  }
462 
463 
464  // Step 4: merge and validate results
465  $result->filter(
466  $this->getRootNode(),
470  );
471  $result->save();
472  $this->showSearch();
473 
474  if (!count($result->getResults())) {
475  $this->tpl->setOnScreenMessage('info', $this->lng->txt('search_no_match'));
476  }
477 
478  if ($result->isLimitReached()) {
479  #$message = sprintf($this->lng->txt('search_limit_reached'),$this->settings->getMaxHits());
480  #ilUtil::sendInfo($message);
481  }
482 
483  // Step 6: show results
484  $this->addPager($result, 'max_page');
485 
487  $presentation->setResults($result->getResultsForPresentation());
488  $presentation->setSubitemIds($result->getSubitemIds());
489  $presentation->setPreviousNext($this->prev_link, $this->next_link);
490 
491  if ($presentation->render()) {
492  $this->tpl->setVariable('RESULTS_TABLE', $presentation->getHTML());
493  }
494  return true;
495  }
read(int $a_type=ilUserSearchCache::DEFAULT_SEARCH)
read search results
__searchMeta(ilQueryParser $query_parser, string $a_type)
Search in object meta data (keyword)
__searchObjects(ilQueryParser $query_parser)
Search in obect title,desctiption.
__performDetailsSearch(ilQueryParser $query_parser, ilSearchResult $result)
__parseQueryString()
parse query string, using query parser instance
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addPager($result, string $a_session_key)
static clear(string $a_var)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prepareOutput()

ilSearchGUI::prepareOutput ( )

Definition at line 499 of file class.ilSearchGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\settings().

Referenced by executeCommand().

499  : void
500  {
501  parent::prepareOutput();
502 
503  $this->help_gui->setScreenIdComponent("src");
504 
505  $this->tabs_gui->addTab(
506  "search",
507  $this->lng->txt("search"),
508  $this->ctrl->getLinkTarget($this)
509  );
510 
511  if (!$this->settings->getHideAdvancedSearch()) {
512  $this->tabs_gui->addTab(
513  "adv_search",
514  $this->lng->txt("search_advanced"),
515  $this->ctrl->getLinkTargetByClass('iladvancedsearchgui')
516  );
517  }
518 
519  $this->tabs_gui->activateTab("search");
520  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ remoteSearch()

ilSearchGUI::remoteSearch ( )

Definition at line 245 of file class.ilSearchGUI.php.

References ILIAS\FileDelivery\http(), performSearch(), ILIAS\Repository\refinery(), setRootNode(), and setString().

245  : void
246  {
247  $root_id = 0;
248  if ($this->http->wrapper()->post()->has('root_id')) {
249  $root_id = $this->http->wrapper()->post()->retrieve(
250  'root_id',
251  $this->refinery->kindlyTo()->int()
252  );
253  }
254  $queryString = '';
255  if ($this->http->wrapper()->post()->has('queryString')) {
256  $queryString = $this->http->wrapper()->post()->retrieve(
257  'queryString',
258  $this->refinery->kindlyTo()->string()
259  );
260  }
261  $this->setString($queryString);
262  $this->setRootNode($root_id);
263  $this->performSearch();
264  }
setString(string $a_str)
Set/get search string public.
performSearch()
Perform search.
setRootNode(int $a_node_id)
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:

◆ setCombination()

ilSearchGUI::setCombination ( string  $a_combination)

Set/get combination of search ('and' or 'or') public.

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

References ilSession\get(), and ilSession\set().

Referenced by __construct().

194  : void
195  {
196  $session_search = ilSession::get('search') ?? [];
197  $session_search['combination'] = $this->combination = $a_combination;
198  ilSession::set('search', $session_search);
199  }
static get(string $a_var)
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDetails()

ilSearchGUI::setDetails ( array  $a_details)

Set/get details (object types for details search) public.

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

References ilSession\get(), and ilSession\set().

Referenced by __construct().

222  : void
223  {
224  $session_search = ilSession::get('search') ?? [];
225  $session_search['details'] = $this->details = $a_details;
226  ilSession::set('search', $session_search);
227  }
static get(string $a_var)
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setRootNode()

ilSearchGUI::setRootNode ( int  $a_node_id)

Definition at line 239 of file class.ilSearchGUI.php.

References ilSession\set().

Referenced by remoteSearch().

239  : void
240  {
241  ilSession::set('search_root', $this->root_node = $a_node_id);
242  }
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setString()

ilSearchGUI::setString ( string  $a_str)

Set/get search string public.

Definition at line 208 of file class.ilSearchGUI.php.

References ilSession\get(), and ilSession\set().

Referenced by __construct(), and remoteSearch().

208  : void
209  {
210  $session_search = ilSession::get('search') ?? [];
211  $session_search['string'] = $this->string = $a_str;
212  ilSession::set('search', $session_search);
213  }
static get(string $a_var)
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setType()

ilSearchGUI::setType ( int  $a_type)

Set/get type of search (detail or 'fast' search) public.

Definition at line 179 of file class.ilSearchGUI.php.

References ilSession\get(), and ilSession\set().

Referenced by __construct().

179  : void
180  {
181  $session_search = ilSession::get('search');
182  $session_search['type'] = $this->type = $a_type;
183  ilSession::set('search', $session_search);
184  }
static get(string $a_var)
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showSavedResults()

ilSearchGUI::showSavedResults ( )

Definition at line 382 of file class.ilSearchGUI.php.

References ilSearchBaseGUI\addPager(), getRootNode(), ilSearchResultPresentation\MODE_STANDARD, ilSearchResult\read(), showSearch(), and ILIAS\Repository\user().

382  : void
383  {
384  // Read old result sets
385 
386  $result_obj = new ilSearchResult($this->user->getId());
387  $result_obj->read();
388  $result_obj->filterResults($this->getRootNode());
389 
390  $this->showSearch();
391 
392  // Show them
393  if (count($result_obj->getResults())) {
394  $this->addPager($result_obj, 'max_page');
395 
397  $presentation->setResults($result_obj->getResultsForPresentation());
398  $presentation->setSubitemIds($result_obj->getSubitemIds());
399  $presentation->setPreviousNext($this->prev_link, $this->next_link);
400  #$presentation->setSearcher($searcher);
401 
402  if ($presentation->render()) {
403  // $this->tpl->setVariable('SEARCH_RESULTS',$presentation->getHTML());
404  $this->tpl->setVariable('RESULTS_TABLE', $presentation->getHTML());
405  }
406  }
407  }
read(int $a_type=ilUserSearchCache::DEFAULT_SEARCH)
read search results
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addPager($result, string $a_session_key)
+ Here is the call graph for this function:

◆ showSearch()

ilSearchGUI::showSearch ( )

Definition at line 337 of file class.ilSearchGUI.php.

References ilGlyphGUI\CARET, ILIAS\Repository\ctrl(), ILIAS\Repository\form(), ilGlyphGUI\get(), ilSearchBaseGUI\getCreationDateForm(), ilSubmitButton\getInstance(), ilSearchSettings\getInstance(), ilSearchBaseGUI\getSearchAreaForm(), getString(), ilSearchBaseGUI\initStandardSearchForm(), ILIAS\Repository\lng(), ilSearchSettings\OPERATOR_AND, ilLegacyFormElementsUtil\prepareFormOutput(), and ilSearchBaseGUI\SEARCH_FORM_STANDARD.

Referenced by performSearch(), and showSavedResults().

337  : void
338  {
339  ilOverlayGUI::initJavascript();
340  $this->tpl->addJavascript("./Services/Search/js/Search.js");
341 
342 
343  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.search.html', 'Services/Search');
344  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, 'performSearch'));
345  $this->tpl->setVariable("TERM", ilLegacyFormElementsUtil::prepareFormOutput($this->getString()));
346  $this->tpl->setVariable("SEARCH_LABEL", $this->lng->txt("search"));
348  $btn->setCommand("performSearch");
349  $btn->setCaption("search");
350  $this->tpl->setVariable("SUBMIT_BTN", $btn->render());
351  $this->tpl->setVariable("TXT_OPTIONS", $this->lng->txt("options"));
352  $this->tpl->setVariable("ARR_IMG", ilGlyphGUI::get(ilGlyphGUI::CARET));
353  $this->tpl->setVariable("TXT_COMBINATION", $this->lng->txt("search_term_combination"));
354  $this->tpl->setVariable('TXT_COMBINATION_DEFAULT', ilSearchSettings::getInstance()->getDefaultOperator() == ilSearchSettings::OPERATOR_AND ? $this->lng->txt('search_all_words') : $this->lng->txt('search_any_word'));
355 
356  if (ilSearchSettings::getInstance()->isLuceneItemFilterEnabled()) {
357  $this->tpl->setCurrentBlock("type_sel");
358  $this->tpl->setVariable('TXT_TYPE_DEFAULT', $this->lng->txt("search_fast_info"));
359  $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("search_type"));
361  $this->tpl->setVariable("ARR_IMGT", ilGlyphGUI::get(ilGlyphGUI::CARET));
362  $this->tpl->setVariable("FORM", $this->form->getHTML());
363  $this->tpl->parseCurrentBlock();
364  }
365 
366  if (ilSearchSettings::getInstance()->isDateFilterEnabled()) {
367  // begin-patch creation_date
368  $this->tpl->setVariable('TXT_FILTER_BY_CDATE', $this->lng->txt('search_filter_cd'));
369  $this->tpl->setVariable('TXT_CD_OFF', $this->lng->txt('search_off'));
370  $this->tpl->setVariable('FORM_CD', $this->getCreationDateForm()->getHTML());
371  $this->tpl->setVariable("ARR_IMG_CD", ilGlyphGUI::get(ilGlyphGUI::CARET));
372  // end-patch creation_date
373  }
374 
375 
376  $this->tpl->setVariable("TXT_AREA", $this->lng->txt("search_area"));
377 
378  // search area form
379  $this->tpl->setVariable('SEARCH_AREA_FORM', $this->getSearchAreaForm()->getHTML());
380  }
static get(string $a_glyph, string $a_text="")
static prepareFormOutput($a_str, bool $a_strip=false)
form( $class_path, string $cmd, string $submit_caption="")
initStandardSearchForm(int $a_mode)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ storeRoot()

ilSearchGUI::storeRoot ( )
protected

Store new root node.

Definition at line 269 of file class.ilSearchGUI.php.

References ilSearchBaseGUI\$form, ilPropertyFormGUI\getItemByPostVar(), ilSearchBaseGUI\getSearchAreaForm(), performSearch(), and ilSubItemListGUI\resetDetails().

269  : void
270  {
271  $form = $this->getSearchAreaForm();
272 
273  $this->root_node = $form->getItemByPostVar('area')->getValue();
274  $this->search_cache->setRoot($this->root_node);
275  $this->search_cache->save();
276  $this->search_cache->deleteCachedEntries();
278  $this->performSearch();
279  }
performSearch()
Perform search.
getItemByPostVar(string $a_post_var)
ilPropertyFormGUI $form
static resetDetails()
As long as static::resetDetails is not possible this method is final.
+ Here is the call graph for this function:

Field Documentation

◆ $combination

string ilSearchGUI::$combination

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

◆ $details

array ilSearchGUI::$details
private

Definition at line 37 of file class.ilSearchGUI.php.

◆ $help_gui

ilHelpGUI ilSearchGUI::$help_gui
protected

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

◆ $root_node

int ilSearchGUI::$root_node

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

◆ $string

string ilSearchGUI::$string

Definition at line 40 of file class.ilSearchGUI.php.

Referenced by getString().

◆ $tabs_gui

ilTabsGUI ilSearchGUI::$tabs_gui
protected

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

◆ $type

int ilSearchGUI::$type

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

Referenced by __construct().


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