ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Request.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
27 
31 final class Request
32 {
33  use URLSerializer;
34 
38  public const MODE_AS_DATA_TABLE = 1;
42  public const MODE_AS_PRESENTATION_TABLE = 2;
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;
113 
114  public function __construct(
115  private \ilCtrlInterface $ctrl,
116  private ArrayBasedRequestWrapper $query,
117  private Configuration $view_configuration,
118  ) {
119  global $DIC;
120  $irss = $DIC->resourceStorage();
121  $this->ctrl = $DIC->ctrl();
122  $this->refinery = $DIC->refinery();
123 
124  $this->mode = $this->determineMode();
125  $this->page = $this->determinePage();
126  $this->path = $this->determinePath();
127  $this->sortation = $this->determineSortation();
128  $this->items_per_page = $this->view_configuration->getItemsPerPage();
129 
130  $this->wrapper = new ContainerWrapper(
131  $view_configuration->getContainer()->getIdentification(),
133  );
134  }
135 
136  public function init(
137  \ilContainerResourceGUI $container_resource_gui
138  ): void {
139  $this->ctrl->saveParameter($container_resource_gui, self::P_SORTATION);
140  $this->ctrl->saveParameter($container_resource_gui, self::P_PAGE);
141  $this->ctrl->saveParameter($container_resource_gui, self::P_MODE);
142  $this->ctrl->saveParameter($container_resource_gui, self::P_PATH);
143  }
144 
145  public function buildURI(string $cmd): void
146  {
147  }
148 
149  public function handleViewTitle(): bool
150  {
151  return false;
152  }
153 
154  private function determinePage(): int
155  {
156  return $this->query->has(self::P_PAGE)
157  ? $this->query->retrieve(self::P_PAGE, $this->refinery->kindlyTo()->int())
158  : 0;
159  }
160 
161  private function determinePath(): string
162  {
163  return $this->query->has(self::P_PATH)
164  ? $this->unhash($this->query->retrieve(self::P_PATH, $this->refinery->kindlyTo()->string()))
165  : self::BASE;
166  }
167 
168  public function setPage(int $page): void
169  {
170  $this->page = $page;
171  }
172 
173  public function getItemsPerPage(): int
174  {
175  return $this->items_per_page;
176  }
177 
178  public function getPath(): string
179  {
180  return $this->path;
181  }
182 
183  public function setItemsPerPage(int $items_per_page): void
184  {
185  $this->items_per_page = $items_per_page;
186  }
187 
188  public function getTitle(): ?string
189  {
190  return $this->view_configuration->getTitle();
191  }
192 
193  public function getDescription(): ?string
194  {
195  return $this->view_configuration->getDescription();
196  }
197 
198  private function determineSortation(): string
199  {
200  return $this->query->has(self::P_SORTATION)
201  ? $this->query->retrieve(self::P_SORTATION, $this->refinery->kindlyTo()->string())
202  : self::BY_TITLE_ASC;
203  }
204 
205  public function setSortation(string $sortation): void
206  {
207  $this->sortation = $sortation;
208  }
209 
210  public function getWrapper(): ContainerWrapper
211  {
212  return $this->wrapper;
213  }
214 
215  private function determineMode(): Mode
216  {
217  return $this->query->has(self::P_MODE)
218  ? Mode::from($this->query->retrieve(self::P_MODE, $this->refinery->kindlyTo()->int()))
219  : $this->view_configuration->getMode();
220  }
221 
222  public function getMode(): Mode
223  {
224  return $this->mode;
225  }
226 
227  public function getPage(): int
228  {
229  return $this->page;
230  }
231 
232  public function getSortation(): string
233  {
234  return $this->sortation;
235  }
236 
237  public function canUserUplaod(): bool
238  {
239  return $this->view_configuration->canUserUpload();
240  }
241 
242  public function canUserAdministrate(): bool
243  {
244  return $this->view_configuration->canUserAdministrate();
245  }
246 }
__construct(private \ilCtrlInterface $ctrl, private ArrayBasedRequestWrapper $query, private Configuration $view_configuration,)
Definition: Request.php:114
This is how the factory for UI elements looks.
Definition: Factory.php:37
global $DIC
Definition: shib_login.php:22
init(\ilContainerResourceGUI $container_resource_gui)
Definition: Request.php:136
sortation()
expected output: > ILIAS shows the rendered Component.
Definition: sortation.php:29