ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Ordering.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
25 use ILIAS\Data\URI;
28 
29 class Ordering extends AbstractTable implements T\Ordering
30 {
32 
33  public const STORAGE_ID_PREFIX = self::class . '_';
34  public const VIEWCONTROL_KEY_FIELDSELECTION = 'selected_optional';
35 
36  protected bool $ordering_disabled = false;
37 
38  public function __construct(
39  SignalGeneratorInterface $signal_generator,
40  ViewControl\Factory $view_control_factory,
41  ViewControlContainer\Factory $view_control_container_factory,
42  protected OrderingRowBuilder $row_builder,
43  string $title,
44  array $columns,
45  protected T\OrderingRetrieval $binding,
46  protected URI $target_url,
47  \ArrayAccess $storage
48  ) {
50  $signal_generator,
51  $view_control_factory,
52  $view_control_container_factory,
53  $storage,
54  $title,
55  $columns
56  );
57  $this->initViewControlFieldSelection($columns);
58  }
59 
60  public function getRowBuilder(): OrderingRowBuilder
61  {
62  return $this->row_builder
64  ->withSingleActions($this->getSingleActions())
65  ->withVisibleColumns($this->getVisibleColumns());
66  }
67 
68  public function getDataBinding(): T\OrderingRetrieval
69  {
70  return $this->binding;
71  }
72 
73  public function withOrderingDisabled(bool $flag): self
74  {
75  $clone = clone $this;
76  $clone->ordering_disabled = $flag;
77  return $clone;
78  }
79 
80  public function isOrderingDisabled(): bool
81  {
83  }
84 
85  public function getTargetURL(): ?URI
86  {
87  return $this->target_url;
88  }
89 
90  public function getData(): array
91  {
92  if (!$request = $this->getRequest()) {
93  return null;
94  }
95  $ordered = $request->getParsedBody();
96  asort($ordered, SORT_NUMERIC);
97  return array_keys($ordered);
98  }
99 
103  public function applyViewControls(): array
104  {
105  $table = $this;
106  $view_controls = $this->getViewControls();
107 
108  if ($request = $this->getRequest()) {
109  $view_controls = $this->applyValuesToViewcontrols($view_controls, $request);
110  $data = $view_controls->getData();
111  $table = $table
112  ->withSelectedOptionalColumns($data[self::VIEWCONTROL_KEY_FIELDSELECTION] ?? null);
113  }
114 
115  return [
116  $table,
117  $view_controls
118  ];
119  }
120 
121  protected function getViewControls(): ViewControlContainer\ViewControl
122  {
123  $view_controls = [
124  self::VIEWCONTROL_KEY_FIELDSELECTION => $this->getViewControlFieldSelection(),
125  ];
126  $view_controls = array_filter($view_controls);
127  return $this->view_control_container_factory->standard($view_controls);
128  }
129 }
__construct(SignalGeneratorInterface $signal_generator, ViewControl\Factory $view_control_factory, ViewControlContainer\Factory $view_control_container_factory, protected OrderingRowBuilder $row_builder, string $title, array $columns, protected T\OrderingRetrieval $binding, protected URI $target_url, \ArrayAccess $storage)
Definition: Ordering.php:38
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Builds data types.
Definition: Factory.php:35
applyValuesToViewcontrols(ViewControlContainer\ViewControl $view_controls, ServerRequestInterface $request)
__construct(Container $dic, ilPlugin $plugin)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Factory.php:21
withOrderingDisabled(bool $flag)
Turns ordering capabilites off/on.
Definition: Ordering.php:73