ILIAS  trunk Revision v12.0_alpha-33-ge186251a14d
AbstractSearchStateHandlerImpl.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27use ilSession;
30
32{
33 public function __construct(
34 protected HTTP $http,
35 protected Refinery $refinery
36 ) {
37 }
38
39 public function fetchMaxPage(): int
40 {
41 return (int) (ilSession::get(Param::MAX_PAGE->value) ?? 1);
42 }
43
44 public function resetMaxPage(): void
45 {
46 ilSession::clear(Param::MAX_PAGE->value);
47 }
48
49 public function updateMaxPage(int $max_page): void
50 {
51 ilSession::set(Param::MAX_PAGE->value, $max_page > 0 ? (string) $max_page : '1');
52 }
53
54 public function fetchRequestedPage(): int
55 {
56 if ($this->http->wrapper()->query()->has(Param::PAGE_NUMBER->value)) {
57 // pages in the view control are 0-indexed, in search 1-indexed
58 return $this->http->wrapper()->query()->retrieve(
59 Param::PAGE_NUMBER->value,
60 $this->refinery->kindlyTo()->int()
61 ) + 1;
62 }
63 return 1;
64 }
65
66 public function fetchSortation(): Sortation
67 {
68 $sortation_string = '';
69 if ($this->http->wrapper()->query()->has(Param::SORTATION->value)) {
70 $sortation_string = $this->http->wrapper()->query()->retrieve(
71 Param::SORTATION->value,
72 $this->refinery->kindlyTo()->string()
73 );
74 }
75 return Sortation::tryFrom($sortation_string) ?? Sortation::RELEVANCE_DESC;
76 }
77
82 public function fetchRequestedSearchTerm(): string
83 {
84 if ($this->http->wrapper()->post()->has('term')) {
85 return $this->http->wrapper()->post()->retrieve(
86 'term',
87 $this->refinery->kindlyTo()->string()
88 );
89 }
90 return '';
91 }
92
97 abstract public function fetchRequestedRemoteSearchTerm(): string;
98
103 public function fetchRequestedAutoCompleteSearchTerm(): string
104 {
105 if ($this->http->wrapper()->post()->has('term')) {
106 return $this->http->wrapper()->post()->retrieve(
107 'term',
108 $this->refinery->kindlyTo()->string()
109 );
110 }
111 return '';
112 }
113
119 {
120 if ($this->http->wrapper()->post()->has('root_id')) {
121 return $this->http->wrapper()->post()->retrieve(
122 'root_id',
123 $this->refinery->kindlyTo()->int()
124 );
125 }
126 return ROOT_FOLDER_ID;
127 }
128
129 abstract public function fetchCache(int $usr_id): ilUserSearchCache;
130
131 abstract public function fetchFilter(URI $action): ilSearchFilterGUI;
132
133 abstract public function loadFilterToCache(ilSearchFilterGUI $filter, ilUserSearchCache $cache): void;
134}
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
fetchRequestedSearchTerm()
propably needs to be replaced with a completely different mechanism when switching to KS
loadFilterToCache(ilSearchFilterGUI $filter, ilUserSearchCache $cache)
fetchRequestedAutoCompleteSearchTerm()
propably needs to be replaced with a completely different mechanism when switching to KS
fetchRequestedRemoteSearchTerm()
propably needs to be replaced with a completely different mechanism when switching to KS
__construct(protected HTTP $http, protected Refinery $refinery)
fetchRequestedRemoteScope()
propably needs to be replaced with a completely different mechanism when switching to KS
static get(string $a_var)
static clear(string $a_var)
static set(string $a_var, $a_val)
Set a value.
Class for storing search result.
const ROOT_FOLDER_ID
Definition: constants.php:32
$http
Definition: deliver.php:30
static http()
Fetches the global http state from ILIAS.