ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
Request.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27
31final class Request
32{
33 use URLSerializer;
34
38 public const MODE_AS_DATA_TABLE = 1;
46 public const MODE_AS_ITEMS = 3;
50 public const MODE_AS_DECK = 4;
54 public const P_PAGE = 'page';
58 public const P_SORTATION = 'sort';
62 public const BY_CREATION_DATE_DESC = 'by_creation_date_desc';
66 public const BY_CREATION_DATE_ASC = 'by_creation_date_asc';
70 public const BY_TITLE_DESC = 'by_title_desc';
74 public const BY_TITLE_ASC = 'by_title_asc';
78 public const BY_SIZE_DESC = 'by_size_desc';
82 public const BY_SIZE_ASC = 'by_size_asc';
86 public const BY_TYPE_DESC = 'by_type_desc';
90 public const BY_TYPE_ASC = 'by_type_asc';
94 public const P_MODE = 'mode';
98 public const P_PATH = 'path';
102 private const BASE = './';
103 private Mode $mode;
104 private int $page;
105 private string $sortation;
107 private array $actions = [];
108 private \ilLanguage $language;
109 private \ILIAS\Refinery\Factory $refinery;
110 private int $items_per_page = 20;
111 private string $path = self::BASE;
114
115 public function __construct(
116 private \ilCtrlInterface $ctrl,
117 private ArrayBasedRequestWrapper $query,
118 private Configuration $view_configuration,
119 ) {
120 global $DIC;
121 $DIC->resourceStorage();
122 $this->ctrl = $DIC->ctrl();
123 $this->refinery = $DIC->refinery();
124
125 $this->mode = $this->determineMode();
126 $this->page = $this->determinePage();
127 $this->path = $this->determinePath();
128 $this->sortation = $this->determineSortation();
129 $this->items_per_page = $this->view_configuration->getItemsPerPage();
130
131 $this->wrapper = new ContainerWrapper(
132 $view_configuration->getContainer()->getIdentification(),
133 $this->path
134 );
135 $this->path_status_info = $view_configuration->getPathStatusInfo();
136 }
137
138 public function init(
139 \ilContainerResourceGUI $container_resource_gui
140 ): void {
141 $this->ctrl->saveParameter($container_resource_gui, self::P_SORTATION);
142 $this->ctrl->saveParameter($container_resource_gui, self::P_PAGE);
143 $this->ctrl->saveParameter($container_resource_gui, self::P_MODE);
144 $this->ctrl->saveParameter($container_resource_gui, self::P_PATH);
145 }
146
147 public function buildURI(): void
148 {
149 }
150
151 public function handleViewTitle(): bool
152 {
153 return false;
154 }
155
156 private function determinePage(): int
157 {
158 return $this->query->has(self::P_PAGE)
159 ? $this->query->retrieve(self::P_PAGE, $this->refinery->kindlyTo()->int())
160 : 0;
161 }
162
163 private function determinePath(): string
164 {
165 return $this->query->has(self::P_PATH)
166 ? $this->unhash($this->query->retrieve(self::P_PATH, $this->refinery->kindlyTo()->string()))
167 : self::BASE;
168 }
169
170 public function setPage(int $page): void
171 {
172 $this->page = $page;
173 }
174
175 public function getItemsPerPage(): int
176 {
177 return $this->items_per_page;
178 }
179
180 public function getPath(): string
181 {
182 return $this->path;
183 }
184
185 public function setItemsPerPage(int $items_per_page): void
186 {
187 $this->items_per_page = $items_per_page;
188 }
189
190 public function getTitle(): string
191 {
192 return $this->view_configuration->getTitle();
193 }
194
195 public function getDescription(): ?string
196 {
197 return $this->view_configuration->getDescription();
198 }
199
200 private function determineSortation(): string
201 {
202 return $this->query->has(self::P_SORTATION)
203 ? $this->query->retrieve(self::P_SORTATION, $this->refinery->kindlyTo()->string())
204 : self::BY_TITLE_ASC;
205 }
206
207 public function setSortation(string $sortation): void
208 {
209 $this->sortation = $sortation;
210 }
211
212 public function getWrapper(): ContainerWrapper
213 {
214 return $this->wrapper;
215 }
216
217 private function determineMode(): Mode
218 {
219 return $this->query->has(self::P_MODE)
220 ? Mode::from($this->query->retrieve(self::P_MODE, $this->refinery->kindlyTo()->int()))
221 : $this->view_configuration->getMode();
222 }
223
224 public function getMode(): Mode
225 {
226 return $this->mode;
227 }
228
229 public function getPage(): int
230 {
231 return $this->page;
232 }
233
234 public function getSortation(): string
235 {
236 return $this->sortation;
237 }
238
239 public function canUserUplaod(): bool
240 {
241 return $this->view_configuration->canUserUpload();
242 }
243
244 public function canUserAdministrate(): bool
245 {
246 return $this->view_configuration->canUserAdministrate();
247 }
248
250 {
251 return $this->path_status_info;
252 }
253}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
init(\ilContainerResourceGUI $container_resource_gui)
Definition: Request.php:138
__construct(private \ilCtrlInterface $ctrl, private ArrayBasedRequestWrapper $query, private Configuration $view_configuration,)
Definition: Request.php:115
This is how the factory for UI elements looks.
Definition: Factory.php:38
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$path
Definition: ltiservices.php:30
global $DIC
Definition: shib_login.php:26