ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
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 ()
 Add desktop item public. More...
 
 removeFromDeskObject ()
 Remove from desktop public. More...
 
 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\GlobalScreen\Provider\__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.
form( $class_path, string $cmd)
initStandardSearchForm(int $a_mode)
__construct(Container $dic, ilPlugin $plugin)
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 718 of file class.ilSearchGUI.php.

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

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

718  : array
719  {
720  if ($this->getType() != ilSearchBaseGUI::SEARCH_DETAILS) {
721  return [];
722  }
723 
724  $filter = [];
725  foreach ($this->getDetails() as $key => $detail_type) {
726  if (!$detail_type) {
727  continue;
728  }
729 
730  switch ($key) {
731  case 'lms':
732  $filter[] = 'lm';
733  $filter[] = 'dbk';
734  $filter[] = 'pg';
735  $filter[] = 'st';
736  $filter[] = 'sahs';
737  $filter[] = 'htlm';
738  break;
739 
740  case 'frm':
741  $filter[] = 'frm';
742  break;
743 
744  case 'glo':
745  $filter[] = 'glo';
746  break;
747 
748  case 'exc':
749  $filter[] = 'exc';
750  break;
751 
752  case 'mcst':
753  $filter[] = 'mcst';
754  break;
755 
756  case 'tst':
757  $filter[] = 'tst';
758  $filter[] = 'svy';
759  $filter[] = 'qpl';
760  $filter[] = 'spl';
761  break;
762 
763  case 'mep':
764  $filter[] = 'mep';
765  $filter[] = 'mob';
766  break;
767 
768  case 'fil':
769  $filter[] = 'file';
770  break;
771 
772  case 'wiki':
773  $filter[] = 'wpg';
774  break;
775 
776  default:
777  $filter[] = $key;
778  }
779  }
780  return $filter;
781  }
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 614 of file class.ilSearchGUI.php.

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

Referenced by performSearch().

615  {
616  $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->getString()));
617  $query_parser->setCombination($this->getCombination());
618  $query_parser->parse();
619 
620  if (!$query_parser->validate()) {
621  return $query_parser->getMessage();
622  }
623  return $query_parser;
624  }
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 523 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().

524  {
525  foreach ($this->getDetails() as $type => $enabled) {
526  if (!$enabled) {
527  continue;
528  }
529 
530  switch ($type) {
531  case 'crs':
532  $crs_search = ilObjectSearchFactory::_getObjectSearchInstance($query_parser);
533  $crs_search->setFilter(array('crs'));
534  $result->mergeEntries($crs_search->performSearch());
535  break;
536 
537  case 'grp':
538  $grp_search = ilObjectSearchFactory::_getObjectSearchInstance($query_parser);
539  $grp_search->setFilter(array('grp'));
540  $result->mergeEntries($grp_search->performSearch());
541  break;
542 
543  case 'lms':
544  $content_search = ilObjectSearchFactory::_getLMContentSearchInstance($query_parser);
545  $content_search->setFilter($this->__getFilter());
546  $result->mergeEntries($content_search->performSearch());
547  break;
548 
549  case 'frm':
550  $forum_search = ilObjectSearchFactory::_getForumSearchInstance($query_parser);
551  $forum_search->setFilter($this->__getFilter());
552  $result->mergeEntries($forum_search->performSearch());
553  break;
554 
555  case 'glo':
556  // Glossary term definition pages
557  $gdf_search = ilObjectSearchFactory::_getLMContentSearchInstance($query_parser);
558  $gdf_search->setFilter(array('gdf'));
559  $result->mergeEntries($gdf_search->performSearch());
560  // Glossary terms
561  $gdf_term_search = ilObjectSearchFactory::_getGlossaryDefinitionSearchInstance($query_parser);
562  $result->mergeEntries($gdf_term_search->performSearch());
563  break;
564 
565  case 'exc':
566  $exc_search = ilObjectSearchFactory::_getExerciseSearchInstance($query_parser);
567  $exc_search->setFilter($this->__getFilter());
568  $result->mergeEntries($exc_search->performSearch());
569  break;
570 
571  case 'mcst':
572  $mcst_search = ilObjectSearchFactory::_getMediacastSearchInstance($query_parser);
573  $result->mergeEntries($mcst_search->performSearch());
574  break;
575 
576  case 'tst':
577  $tst_search = ilObjectSearchFactory::_getTestSearchInstance($query_parser);
578  $tst_search->setFilter($this->__getFilter());
579  $result->mergeEntries($tst_search->performSearch());
580  break;
581 
582  case 'mep':
583  $mep_search = ilObjectSearchFactory::_getMediaPoolSearchInstance($query_parser);
584  $mep_search->setFilter($this->__getFilter());
585  $result->mergeEntries($mep_search->performSearch());
586 
587  // Mob keyword search
588  $mob_search = ilObjectSearchFactory::_getMediaPoolSearchInstance($query_parser);
589  $mob_search->setFilter($this->__getFilter());
590  $result->mergeEntries($mob_search->performKeywordSearch());
591 
592  break;
593 
594  case 'wiki':
595  $wiki_search = ilObjectSearchFactory::_getWikiContentSearchInstance($query_parser);
596  $wiki_search->setFilter($this->__getFilter());
597  $result->mergeEntries($wiki_search->performSearch());
598 
599  /*$result_meta =& $this->__searchMeta($query_parser,'title');
600  $result->mergeEntries($result_meta);
601  $result_meta =& $this->__searchMeta($query_parser,'description');
602  $result->mergeEntries($result_meta);*/
603  break;
604 
605  }
606  }
607  return $result;
608  }
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 689 of file class.ilSearchGUI.php.

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

Referenced by performSearch().

690  {
691  $meta_search = ilObjectSearchFactory::_getMetaDataSearchInstance($query_parser);
692  if ($this->getType() == ilSearchBaseGUI::SEARCH_DETAILS) {
693  $meta_search->setFilter($this->__getFilter());
694  }
695  switch ($a_type) {
696  case 'keyword':
697  $meta_search->setMode('keyword');
698  break;
699 
700  case 'contribute':
701  $meta_search->setMode('contribute');
702  break;
703 
704  case 'title':
705  $meta_search->setMode('title');
706  break;
707 
708  case 'description':
709  $meta_search->setMode('description');
710  break;
711  }
712  return $meta_search->performSearch();
713  }
__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 628 of file class.ilSearchGUI.php.

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

Referenced by performSearch().

629  {
630  $obj_search = ilObjectSearchFactory::_getObjectSearchInstance($query_parser);
631  if ($this->getType() == ilSearchBaseGUI::SEARCH_DETAILS) {
632  $obj_search->setFilter($this->__getFilter());
633  }
634  $this->parseCreationFilter($obj_search);
635  return $obj_search->performSearch();
636  }
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 $query, $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 {
332  echo $list;
333  exit;
334  }
335  }
$res
Definition: ltiservices.php:69
exit
Definition: login.php:28
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.
$query
+ 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 638 of file class.ilSearchGUI.php.

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

Referenced by __searchObjects().

638  : bool
639  {
640  $date = $this->parseDateFromCreationFilter();
641  $operator = $this->parseOperatorFromCreationFilter();
642 
643  if (is_null($date) || is_null($operator)) {
644  return true;
645  }
646 
647  $search->setCreationDateFilterDate($date);
648  $search->setCreationDateFilterOperator($operator);
649  return true;
650  }
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 652 of file class.ilSearchGUI.php.

References ilSearchBaseGUI\getSearchCache(), and IL_CAL_UNIX.

Referenced by parseCreationFilter(), and performSearch().

652  : ?ilDate
653  {
654  $options = $this->getSearchCache()->getCreationFilter();
655  if (!($options['enabled'] ?? false)) {
656  return null;
657  }
658  return new ilDate($options['date'] ?? 0, IL_CAL_UNIX);
659  }
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 661 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().

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

◆ performSearch()

ilSearchGUI::performSearch ( )

Perform search.

Definition at line 413 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().

413  : bool
414  {
415  $page_number = $this->initPageNumberFromQuery();
416  if (!$page_number and $this->search_mode != 'in_results') {
417  ilSession::clear('max_page');
418  $this->search_cache->deleteCachedEntries();
419  }
420 
421  $this->search_cache->setResultPageNumber($page_number);
422 
423  if ($this->getType() == ilSearchBaseGUI::SEARCH_DETAILS and !$this->getDetails()) {
424  $this->tpl->setOnScreenMessage('info', $this->lng->txt('search_choose_object_type'));
425  $this->showSearch();
426  return false;
427  }
428 
429  // Step 1: parse query string
430  if (!is_object($query_parser = $this->__parseQueryString())) {
431  $this->tpl->setOnScreenMessage('info', $query_parser);
432  $this->showSearch();
433 
434  return false;
435  }
436  // Step 2: perform object search. Get an ObjectSearch object via factory. Depends on fulltext or like search type.
437  $result = $this->__searchObjects($query_parser);
438 
439  // Step 3: perform meta keyword search. Get an MetaDataSearch object.
440  $result_meta = $this->__searchMeta($query_parser, 'keyword');
441  $result->mergeEntries($result_meta);
442 
443  $result_meta = $this->__searchMeta($query_parser, 'contribute');
444  $result->mergeEntries($result_meta);
445 
446  $result_meta = $this->__searchMeta($query_parser, 'title');
447  $result->mergeEntries($result_meta);
448 
449  $result_meta = $this->__searchMeta($query_parser, 'description');
450  $result->mergeEntries($result_meta);
451 
452  // Perform details search in object specific tables
453  if ($this->getType() == ilSearchBaseGUI::SEARCH_DETAILS) {
454  $result = $this->__performDetailsSearch($query_parser, $result);
455  }
456  // Step 5: Search in results
457  if ($this->search_mode == 'in_results') {
458  $old_result_obj = new ilSearchResult($this->user->getId());
459  $old_result_obj->read();
460 
461  $result->diffEntriesFromResult();
462  }
463 
464 
465  // Step 4: merge and validate results
466  $result->filter(
467  $this->getRootNode(),
471  );
472  $result->save();
473  $this->showSearch();
474 
475  if (!count($result->getResults())) {
476  $this->tpl->setOnScreenMessage('info', $this->lng->txt('search_no_match'));
477  }
478 
479  if ($result->isLimitReached()) {
480  #$message = sprintf($this->lng->txt('search_limit_reached'),$this->settings->getMaxHits());
481  #ilUtil::sendInfo($message);
482  }
483 
484  // Step 6: show results
485  $this->addPager($result, 'max_page');
486 
488  $presentation->setResults($result->getResultsForPresentation());
489  $presentation->setSubitemIds($result->getSubitemIds());
490  $presentation->setPreviousNext($this->prev_link, $this->next_link);
491 
492  if ($presentation->render()) {
493  $this->tpl->setVariable('RESULTS_TABLE', $presentation->getHTML());
494  }
495  return true;
496  }
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 500 of file class.ilSearchGUI.php.

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

Referenced by executeCommand().

500  : void
501  {
502  parent::prepareOutput();
503 
504  $this->help_gui->setScreenIdComponent("src");
505 
506  $this->tabs_gui->addTab(
507  "search",
508  $this->lng->txt("search"),
509  $this->ctrl->getLinkTarget($this)
510  );
511 
512  if (!$this->settings->getHideAdvancedSearch()) {
513  $this->tabs_gui->addTab(
514  "adv_search",
515  $this->lng->txt("search_advanced"),
516  $this->ctrl->getLinkTargetByClass('iladvancedsearchgui')
517  );
518  }
519 
520  $this->tabs_gui->activateTab("search");
521  }
+ 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 
385  // Read old result sets
386 
387  $result_obj = new ilSearchResult($this->user->getId());
388  $result_obj->read();
389  $result_obj->filterResults($this->getRootNode());
390 
391  $this->showSearch();
392 
393  // Show them
394  if (count($result_obj->getResults())) {
395  $this->addPager($result_obj, 'max_page');
396 
398  $presentation->setResults($result_obj->getResultsForPresentation());
399  $presentation->setSubitemIds($result_obj->getSubitemIds());
400  $presentation->setPreviousNext($this->prev_link, $this->next_link);
401  #$presentation->setSearcher($searcher);
402 
403  if ($presentation->render()) {
404  // $this->tpl->setVariable('SEARCH_RESULTS',$presentation->getHTML());
405  $this->tpl->setVariable('RESULTS_TABLE', $presentation->getHTML());
406  }
407  }
408  }
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)
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: