ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
large.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26
40function large()
41{
42 global $DIC;
43
47 $f = $DIC['ui.factory'];
48
52 $r = $DIC['ui.renderer'];
53
57 $refinery = $DIC['refinery'];
58 $df = new \ILIAS\Data\Factory();
59 $request = $DIC->http()->request();
60 $request_wrapper = $DIC->http()->wrapper()->query();
61
65 $columns = [
66 'entry' => $f->table()->column()->text("some entry")
67 ];
68
74 $url_builder = new URLBuilder($df->uri($request->getUri()->__toString()));
75 $query_params_namespace = ['orderingtable', 'example', 'large'];
76 list($url_builder, $action_parameter_token, $row_id_token) = $url_builder->acquireParameters(
77 $query_params_namespace,
78 "table_action",
79 "a_quiet_longish_parameter_name_to_quickly_exceed_url_limits"
80 );
81 $actions = [
82 $f->table()->action()->standard(
83 'some action',
84 $url_builder->withParameter($action_parameter_token, "edit"),
85 $row_id_token
86 )
87 ];
88
89
93 $data_retrieval = new class ($f, $r) implements I\OrderingRetrieval {
94 protected array $records;
95
96 public function __construct(
97 protected \ILIAS\UI\Factory $ui_factory,
98 protected \ILIAS\UI\Renderer $ui_renderer
99 ) {
100 $this->records = $this->initRecords();
101 }
102
103 public function getRows(
104 I\OrderingRowBuilder $row_builder,
105 array $visible_column_ids
106 ): \Generator {
107 $records = array_values($this->records);
108 foreach ($this->records as $position_index => $record) {
109 $row_id = (string) $record['id'];
110 yield $row_builder->buildOrderingRow($row_id, $record);
111 }
112 }
113
114 protected function initRecords(): array
115 {
116 $records = [];
117 foreach (array_map('strval', range(0, 9)) as $r) {
118 $id = str_repeat($r, 1000);
119 $records[$id] = [
120 'id' => $id,
121 'entry' => substr($id, 0, 50),
122 ];
123 }
124 return $records;
125 }
126
130 public function setOrder(array $ordered): void
131 {
132 $r = [];
133 foreach ($ordered as $id) {
134 $r[(string) $id] = $this->records[(string) $id];
135 }
136 $this->records = $r;
137 }
138
139 };
140
141 $target = (new URI((string) $request->getUri()))->withParameter('ordering_example', 4);
142 $table = $f->table()->ordering($data_retrieval, $target, 'large ids ordering table', $columns)
143 ->withActions($actions)
144 ->withRequest($request);
145
146 $out = [];
147 if ($request->getMethod() == "POST"
148 && $request_wrapper->has('ordering_example')
149 && $request_wrapper->retrieve('ordering_example', $refinery->kindlyTo()->int()) === 4
150 ) {
151 if ($data = $table->getData()) {
152 $out[] = $f->legacy()->content('<pre>' . print_r($data, true) . '</pre>');
153 }
154 $data_retrieval->setOrder($data);
155 }
156
157 $out[] = $table;
158 return $r->render($out);
159}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$out
Definition: buildRTE.php:24
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
__construct()
Constructor setup ILIAS global object @access public.
Definition: class.ilias.php:76
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
global $DIC
Definition: shib_login.php:26