ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
large.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
11 use ILIAS\Data\URI;
12 
26 function large()
27 {
28  global $DIC;
29 
33  $f = $DIC['ui.factory'];
34 
38  $r = $DIC['ui.renderer'];
39 
43  $refinery = $DIC['refinery'];
44  $df = new \ILIAS\Data\Factory();
45  $request = $DIC->http()->request();
46  $request_wrapper = $DIC->http()->wrapper()->query();
47 
51  $columns = [
52  'entry' => $f->table()->column()->text("some entry")
53  ];
54 
60  $url_builder = new URLBuilder($df->uri($request->getUri()->__toString()));
61  $query_params_namespace = ['orderingtable', 'example', 'large'];
62  list($url_builder, $action_parameter_token, $row_id_token) = $url_builder->acquireParameters(
63  $query_params_namespace,
64  "table_action",
65  "a_quiet_longish_parameter_name_to_quickly_exceed_url_limits"
66  );
67  $actions = [
68  $f->table()->action()->standard(
69  'some action',
70  $url_builder->withParameter($action_parameter_token, "edit"),
71  $row_id_token
72  )
73  ];
74 
75 
79  $data_retrieval = new class ($f, $r) implements I\OrderingRetrieval {
80  protected array $records;
81 
82  public function __construct(
83  protected \ILIAS\UI\Factory $ui_factory,
84  protected \ILIAS\UI\Renderer $ui_renderer
85  ) {
86  $this->records = $this->initRecords();
87  }
88 
89  public function getRows(
90  I\OrderingRowBuilder $row_builder,
91  array $visible_column_ids
92  ): \Generator {
93  $records = array_values($this->records);
94  foreach ($this->records as $position_index => $record) {
95  $row_id = (string) $record['id'];
96  yield $row_builder->buildOrderingRow($row_id, $record);
97  }
98  }
99 
100  protected function initRecords(): array
101  {
102  $records = [];
103  foreach (array_map('strval', range(0, 9)) as $r) {
104  $id = str_repeat($r, 1000);
105  $records[$id] = [
106  'id' => $id,
107  'entry' => substr($id, 0, 50),
108  ];
109  }
110  return $records;
111  }
112 
116  public function setOrder(array $ordered): void
117  {
118  $r = [];
119  foreach ($ordered as $id) {
120  $r[(string) $id] = $this->records[(string) $id];
121  }
122  $this->records = $r;
123  }
124 
125  };
126 
127  $target = (new URI((string) $request->getUri()))->withParameter('ordering_example', 4);
128  $table = $f->table()->ordering($data_retrieval, $target, 'large ids ordering table', $columns)
129  ->withActions($actions)
130  ->withRequest($request);
131 
132  $out = [];
133  if ($request->getMethod() == "POST"
134  && $request_wrapper->has('ordering_example')
135  && $request_wrapper->retrieve('ordering_example', $refinery->kindlyTo()->int()) === 4
136  ) {
137  if ($data = $table->getData()) {
138  $out[] = $f->legacy('<pre>' . print_r($data, true) . '</pre>');
139  }
140  $data_retrieval->setOrder($data);
141  }
142 
143  $out[] = $table;
144  return $r->render($out);
145 }
Interface Observer Contains several chained tasks and infos about them.
__construct()
Constructor setup ILIAS global object public.
Definition: class.ilias.php:76
$out
Definition: buildRTE.php:24
global $DIC
Definition: shib_login.php:26
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$r