ILIAS  trunk Revision v11.0_alpha-1846-g895b5f47236
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 
26 
30 final class Request
31 {
35  public const MODE_AS_DATA_TABLE = 1;
39  public const MODE_AS_PRESENTATION_TABLE = 2;
43  public const MODE_AS_ITEMS = 3;
47  public const MODE_AS_DECK = 4;
51  public const P_PAGE = 'page';
55  public const P_SORTATION = 'sort';
59  public const BY_CREATION_DATE_DESC = 'by_creation_date_desc';
63  public const BY_CREATION_DATE_ASC = 'by_creation_date_asc';
67  public const BY_TITLE_DESC = 'by_title_desc';
71  public const BY_TITLE_ASC = 'by_title_asc';
75  public const BY_SIZE_DESC = 'by_size_desc';
79  public const BY_SIZE_ASC = 'by_size_asc';
83  public const P_MODE = 'mode';
84  private Mode $mode;
85  private int $page;
86  private string $sortation;
88  private array $actions = [];
89  private \ilLanguage $language;
90  private \ILIAS\Refinery\Factory $refinery;
91  private int $items_per_page = 20;
92 
93  public function __construct(
94  private \ilCtrlInterface $ctrl,
95  private ArrayBasedRequestWrapper $query,
96  private Configuration $view_configuration,
97  ) {
98  global $DIC;
99  $this->ctrl = $DIC->ctrl();
100  $this->refinery = $DIC->refinery();
101 
102  $this->mode = $this->determineMode();
103  $this->page = $this->determinePage();
104  $this->sortation = $this->determineSortation();
105  $this->items_per_page = $this->view_configuration->getItemsPerPage();
106  }
107 
108  public function init(
109  \ilResourceCollectionGUI $collection_gui
110  ): void {
111  $this->ctrl->saveParameter($collection_gui, self::P_SORTATION);
112  $this->ctrl->saveParameter($collection_gui, self::P_PAGE);
113  $this->ctrl->saveParameter($collection_gui, self::P_MODE);
114  $this->ctrl->saveParameter($collection_gui, 'tsort_f');
115  $this->ctrl->saveParameter($collection_gui, 'tsort_d');
116  }
117 
118  public function handleViewTitle(): bool
119  {
120  return false;
121  }
122 
123  private function determinePage(): int
124  {
125  return $this->query->has(self::P_PAGE)
126  ? $this->query->retrieve(self::P_PAGE, $this->refinery->kindlyTo()->int())
127  : 0;
128  }
129 
130  public function setPage(int $page): void
131  {
132  $this->page = $page;
133  }
134 
135  public function getItemsPerPage(): int
136  {
137  return $this->items_per_page;
138  }
139 
140  public function setItemsPerPage(int $items_per_page): void
141  {
142  $this->items_per_page = $items_per_page;
143  }
144 
145  public function getTitle(): ?string
146  {
147  return $this->view_configuration->getTitle();
148  }
149 
150  public function getDescription(): ?string
151  {
152  return $this->view_configuration->getDescription();
153  }
154 
155  private function determineSortation(): string
156  {
157  return $this->query->has(self::P_SORTATION)
158  ? $this->query->retrieve(self::P_SORTATION, $this->refinery->kindlyTo()->string())
159  : self::BY_TITLE_ASC;
160  }
161 
162  public function setSortation(string $sortation): void
163  {
164  $this->sortation = $sortation;
165  }
166 
168  {
169  return $this->view_configuration->getCollection();
170  }
171 
172  private function determineMode(): Mode
173  {
174  return $this->query->has(self::P_MODE)
175  ? Mode::from($this->query->retrieve(self::P_MODE, $this->refinery->kindlyTo()->int()))
176  : $this->view_configuration->getMode();
177  }
178 
179  public function getMode(): Mode
180  {
181  return $this->mode;
182  }
183 
184  public function getPage(): int
185  {
186  return $this->page;
187  }
188 
189  public function getSortation(): string
190  {
191  return $this->sortation;
192  }
193 
194  public function canUserUplaod(): bool
195  {
196  return $this->view_configuration->canUserUpload();
197  }
198 
199  public function canUserAdministrate(): bool
200  {
201  return $this->view_configuration->canUserAdministrate();
202  }
203 }
init(\ilResourceCollectionGUI $collection_gui)
Definition: Request.php:108
This is how the factory for UI elements looks.
Definition: Factory.php:37
global $DIC
Definition: shib_login.php:22
__construct(private \ilCtrlInterface $ctrl, private ArrayBasedRequestWrapper $query, private Configuration $view_configuration,)
Definition: Request.php:93
sortation()
expected output: > ILIAS shows the rendered Component.
Definition: sortation.php:29