ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
Request.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
26 
30 final class Request
31 {
32  use URLSerializer;
33 
34  public const MODE_AS_DATA_TABLE = 1;
35  public const MODE_AS_PRESENTATION_TABLE = 2;
36  public const MODE_AS_ITEMS = 3;
37  public const MODE_AS_DECK = 4;
38  public const P_PAGE = 'page';
39  public const P_SORTATION = 'sort';
40  public const BY_CREATION_DATE_DESC = 'by_creation_date_desc';
41  public const BY_CREATION_DATE_ASC = 'by_creation_date_asc';
42  public const BY_TITLE_DESC = 'by_title_desc';
43  public const BY_TITLE_ASC = 'by_title_asc';
44  public const BY_SIZE_DESC = 'by_size_desc';
45  public const BY_SIZE_ASC = 'by_size_asc';
46  public const BY_TYPE_DESC = 'by_type_desc';
47  public const BY_TYPE_ASC = 'by_type_asc';
48  public const P_MODE = 'mode';
49  public const P_PATH = 'path';
50  private const BASE = './';
51  private Mode $mode;
52  private int $page;
53  private string $sortation;
54  private \ILIAS\UI\Factory $ui_factory;
55  private array $actions = [];
56  private \ilLanguage $language;
57  private \ILIAS\Refinery\Factory $refinery;
58  private int $items_per_page = 20;
59  private string $path = self::BASE;
61 
62  public function __construct(
63  private \ilCtrlInterface $ctrl,
64  private \ILIAS\HTTP\Wrapper\ArrayBasedRequestWrapper $query,
65  private Configuration $view_configuration,
66  ) {
67  global $DIC;
68  $irss = $DIC->resourceStorage();
69  $this->ctrl = $DIC->ctrl();
70  $this->refinery = $DIC->refinery();
71 
72  $this->mode = $this->determineMode();
73  $this->page = $this->determinePage();
74  $this->path = $this->determinePath();
75  $this->sortation = $this->determineSortation();
76  $this->items_per_page = $this->view_configuration->getItemsPerPage();
77 
78  $this->wrapper = new ContainerWrapper(
79  $view_configuration->getContainer()->getIdentification(),
81  );
82  }
83 
84  public function init(
85  \ilContainerResourceGUI $container_resource_gui
86  ): void {
87  $this->ctrl->saveParameter($container_resource_gui, self::P_SORTATION);
88  $this->ctrl->saveParameter($container_resource_gui, self::P_PAGE);
89  $this->ctrl->saveParameter($container_resource_gui, self::P_MODE);
90  $this->ctrl->saveParameter($container_resource_gui, self::P_PATH);
91  }
92 
93  public function buildURI(string $cmd)
94  {
95  }
96 
97  public function handleViewTitle(): bool
98  {
99  return false;
100  }
101 
102  private function determinePage(): int
103  {
104  return $this->query->has(self::P_PAGE)
105  ? $this->query->retrieve(self::P_PAGE, $this->refinery->kindlyTo()->int())
106  : 0;
107  }
108 
109  private function determinePath(): string
110  {
111  return $this->query->has(self::P_PATH)
112  ? $this->unhash($this->query->retrieve(self::P_PATH, $this->refinery->kindlyTo()->string()))
113  : self::BASE;
114  }
115 
116  public function setPage(int $page): void
117  {
118  $this->page = $page;
119  }
120 
121  public function getItemsPerPage(): int
122  {
123  return $this->items_per_page;
124  }
125 
126  public function getPath(): string
127  {
128  return $this->path;
129  }
130 
131  public function setItemsPerPage(int $items_per_page): void
132  {
133  $this->items_per_page = $items_per_page;
134  }
135 
136  public function getTitle(): ?string
137  {
138  return $this->view_configuration->getTitle();
139  }
140 
141  public function getDescription(): ?string
142  {
143  return $this->view_configuration->getDescription();
144  }
145 
146  private function determineSortation(): string
147  {
148  return $this->query->has(self::P_SORTATION)
149  ? $this->query->retrieve(self::P_SORTATION, $this->refinery->kindlyTo()->string())
150  : self::BY_TITLE_ASC;
151  }
152 
153  public function setSortation(string $sortation): void
154  {
155  $this->sortation = $sortation;
156  }
157 
158  public function getWrapper(): ContainerWrapper
159  {
160  return $this->wrapper;
161  }
162 
163  private function determineMode(): Mode
164  {
165  return $this->query->has(self::P_MODE)
166  ? Mode::from($this->query->retrieve(self::P_MODE, $this->refinery->kindlyTo()->int()))
167  : $this->view_configuration->getMode();
168  }
169 
170  public function getMode(): Mode
171  {
172  return $this->mode;
173  }
174 
175  public function getPage(): int
176  {
177  return $this->page;
178  }
179 
180  public function getSortation(): string
181  {
182  return $this->sortation;
183  }
184 
185  public function canUserUplaod(): bool
186  {
187  return $this->view_configuration->canUserUpload();
188  }
189 
190  public function canUserAdministrate(): bool
191  {
192  return $this->view_configuration->canUserAdministrate();
193  }
194 }
__construct(private \ilCtrlInterface $ctrl, private \ILIAS\HTTP\Wrapper\ArrayBasedRequestWrapper $query, private Configuration $view_configuration,)
Definition: Request.php:62
Interface Observer Contains several chained tasks and infos about them.
global $DIC
Definition: shib_login.php:25
init(\ilContainerResourceGUI $container_resource_gui)
Definition: Request.php:84
sortation()
expected output: > ILIAS shows the rendered Component.
Definition: sortation.php:13