ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Ordering.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27use ILIAS\UI\Component\Input\Container\ViewControl as ViewControlContainer;
28
29class 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(
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 ) {
52 $view_control_container_factory,
54 $title,
56 );
57 $this->initViewControlFieldSelection($columns);
58 }
59
61 {
62 return $this->row_builder
63 ->withMultiActionsPresent($this->hasMultiActions())
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}
Builds data types.
Definition: Factory.php:36
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
bool()
Get a kind transformation to a bool.
Definition: Group.php:159
applyValuesToViewcontrols(ViewControlContainer $view_controls, ServerRequestInterface $request)
Definition: Sequence.php:193
__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
clone(int $target_parent_obj_id)
readonly SignalGenerator $signal_generator
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Factory.php:21