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;
14 
28 function large()
29 {
30  global $DIC;
31 
35  $f = $DIC['ui.factory'];
36 
40  $r = $DIC['ui.renderer'];
41 
45  $refinery = $DIC['refinery'];
46  $df = new \ILIAS\Data\Factory();
47  $request = $DIC->http()->request();
48  $request_wrapper = $DIC->http()->wrapper()->query();
49 
50  $columns = [
51  'entry' => $f->table()->column()->text("some entry")
52  ];
53 
54  $url_builder = new URLBuilder($df->uri($request->getUri()->__toString()));
55  $query_params_namespace = ['datatable', 'example', 'large'];
56  list($url_builder, $action_parameter_token, $row_id_token) = $url_builder->acquireParameters(
57  $query_params_namespace,
58  "table_action",
59  "a_quiet_longish_parameter_name_to_quickly_exceed_url_limits"
60  );
61 
62  $actions = [
63  $f->table()->action()->standard(
64  'some action',
65  $url_builder->withParameter($action_parameter_token, "edit"),
66  $row_id_token
67  )
68  ];
69 
70  $data_retrieval = new class ($f, $r) implements I\DataRetrieval {
71  protected array $records;
72 
73  public function __construct(
74  protected \ILIAS\UI\Factory $ui_factory,
75  protected \ILIAS\UI\Renderer $ui_renderer
76  ) {
77  $this->records = $this->initRecords();
78  }
79 
80  public function getRows(
81  I\DataRowBuilder $row_builder,
82  array $visible_column_ids,
83  Range $range,
84  Order $order,
85  ?array $filter_data,
86  ?array $additional_parameters
87  ): \Generator {
88  $records = array_values($this->records);
89  foreach ($this->records as $record) {
90  $row_id = (string) $record['id'];
91  yield $row_builder->buildDataRow($row_id, $record);
92  }
93  }
94 
95  public function getTotalRowCount(
96  ?array $filter_data,
97  ?array $additional_parameters
98  ): ?int {
99  return count($this->records);
100  }
101 
102  protected function initRecords(): array
103  {
104  $records = [];
105  foreach (array_map('strval', range(0, 9)) as $r) {
106  $id = str_repeat($r, 1000);
107  $records[$id] = [
108  'id' => $id,
109  'entry' => substr($id, 0, 50),
110  ];
111  }
112  return $records;
113  }
114  };
115 
116  $target = (new URI((string) $request->getUri()))->withParameter('ordering_example', 4);
117  $table = $f->table()->data($data_retrieval, 'large ids data table', $columns)
118  ->withActions($actions)
119  ->withRequest($request);
120 
121  return $r->render($table);
122 }
Interface Observer Contains several chained tasks and infos about them.
__construct()
Constructor setup ILIAS global object public.
Definition: class.ilias.php:76
global $DIC
Definition: shib_login.php:26
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$r