ILIAS  trunk Revision v12.0_alpha-16-g3e876e53c80
SearchStateHandlerImpl.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27use ILIAS\HTTP\Services as HTTP;
28use ILIAS\Refinery\Factory as Refinery;
31
33{
34 public function __construct(
35 protected ilSearchSettings $settings,
36 protected LOMServices $lom_services,
37 HTTP $http,
39 ) {
41 }
42
43 public function fetchRequestedRemoteSearchTerm(): string
44 {
45 if ($this->http->wrapper()->post()->has('queryString')) {
46 return $this->http->wrapper()->post()->retrieve(
47 'queryString',
48 $this->refinery->kindlyTo()->string()
49 );
50 }
51 return '';
52 }
53
54 public function fetchFilter(URI $action): ilSearchFilterGUI
55 {
56 return new ilSearchFilterGUI($action, false);
57 }
58
59 public function fetchCache(int $usr_id): ilUserSearchCache
60 {
61 return ilUserSearchCache::_getInstance($usr_id);
62 }
63
64 public function loadFilterToCache(ilSearchFilterGUI $filter, ilUserSearchCache $cache): void
65 {
66 $search_filter_data = $filter->getData();
67
68 $cache->setRoot((int) ($search_filter_data['search_scope'] ?? ROOT_FOLDER_ID));
69
70 $creation_filter = [];
71 if (
72 $this->settings->isDateFilterEnabled() &&
73 isset($search_filter_data['search_date'])
74 ) {
75 $creation_filter['date_start'] = $search_filter_data['search_date'][0];
76 $creation_filter['date_end'] = $search_filter_data['search_date'][1];
77 }
78 $cache->setCreationFilter($creation_filter);
79
80 $types_from_filter = (array) ($search_filter_data['search_type'] ?? []);
81 $enabled_types = [];
82 foreach ($this->settings->getEnabledLuceneItemFilterDefinitions() as $type => $data) {
83 if (in_array($type, $types_from_filter)) {
84 $enabled_types[$type] = 1;
85 }
86 }
87 $cache->setItemFilter($enabled_types);
88
89 $copyright_filter = [];
90 if (
91 $this->lom_services->copyrightHelper()->isCopyrightSelectionActive() &&
92 isset($search_filter_data['search_copyright'])
93 ) {
94 $copyright_filter = $search_filter_data['search_copyright'];
95 }
96 $cache->setCopyrightFilter(...$copyright_filter);
97 }
98}
Builds data types.
Definition: Factory.php:36
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
Class Services.
Definition: Services.php:38
__construct(protected ilSearchSettings $settings, protected LOMServices $lom_services, HTTP $http, Refinery $refinery)
loadFilterToCache(ilSearchFilterGUI $filter, ilUserSearchCache $cache)
fetchRequestedRemoteSearchTerm()
propably needs to be replaced with a completely different mechanism when switching to KS
Class for storing search result.
setCreationFilter(array $a_filter)
setItemFilter(array $a_filter)
setRoot(int $a_root)
set root node of search
static _getInstance(int $a_usr_id)
setCopyrightFilter(string ... $copyright_identifiers)
const ROOT_FOLDER_ID
Definition: constants.php:32
$http
Definition: deliver.php:30
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc