ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
RatingCategoryOrderingTable.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Rating;
22
23use Generator;
24use ilLanguage;
31use ILIAS\Data\Factory as DataFactory;
33use Psr\Http\Message\ServerRequestInterface;
36
38{
39 private ?array $records = null;
40
41 public function __construct(
42 private readonly int $parent_obj_id,
43 private readonly Factory $ui_factory,
44 private readonly ilLanguage $lng,
45 private readonly ilCtrlInterface $ctrl,
46 private readonly DataFactory $data_factory,
47 private readonly ServerRequestInterface $httpRequest,
48 ) {
49 }
50
51 public function getComponent(): Ordering
52 {
53 $query_params_namespace = ['rating', 'category', 'ordering'];
54 $uri = $this->data_factory->uri(
55 ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTargetByClass(ilRatingCategoryGUI::class, 'handleTableActions')
56 );
57 $url_builder = new URLBuilder($uri);
58 [$url_builder, $action_parameter_token, $row_id_token] = $url_builder->acquireParameters(
59 $query_params_namespace,
60 'table_action',
61 'rating_ids'
62 );
63
64 return $this->ui_factory
65 ->table()
66 ->ordering(
67 $this,
68 $uri->withParameter('cmd', 'updateOrder'),
69 $this->lng->txt('rating_categories'),
70 $this->getColumns(),
71 )
72 ->withId(
73 'rating_category_ordering_table'
74 )
75 ->withRequest($this->httpRequest)
76 ->withActions(
77 $this->getActions(
78 $url_builder,
79 $action_parameter_token,
80 $row_id_token
81 )
82 );
83 }
84
85 public function getActions(
86 URLBuilder $url_builder,
87 URLBuilderToken $action_parameter_token,
88 URLBuilderToken $row_id_token
89 ): array {
90 return [
91 'edit' => $this->ui_factory->table()->action()->single(
92 $this->lng->txt('edit'),
93 $url_builder->withParameter($action_parameter_token, 'edit'),
94 $row_id_token
95 ),
96 'delete' => $this->ui_factory->table()->action()->single(
97 $this->lng->txt('delete'),
98 $url_builder->withParameter($action_parameter_token, 'confirmDelete'),
99 $row_id_token
100 )
101 ];
102 }
103
104 public function getRows(
105 OrderingRowBuilder $row_builder,
106 array $visible_column_ids,
107 ): Generator {
108 $this->initRecords();
109 foreach ($this->records as $record) {
110 yield $row_builder->buildOrderingRow((string) $record['id'], $record);
111 }
112 }
113
114 public function initRecords(): void
115 {
116 if (!$this->records) {
117 $this->records = ilRatingCategory::getAllForObject($this->parent_obj_id);
118 }
119 }
120
127 private function getColumns(): array
128 {
129 return [
130 'title' => $this->ui_factory->table()->column()->text($this->lng->txt('title')),
131 'description' => $this->ui_factory->table()->column()->text($this->lng->txt('description'))
132 ];
133 }
134
135 public function getTotalRowCount(?array $filter_data, ?array $additional_parameters): ?int
136 {
137 $this->initRecords();
138
139 return count($this->records);
140 }
141}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Builds data types.
Definition: Factory.php:36
getActions(URLBuilder $url_builder, URLBuilderToken $action_parameter_token, URLBuilderToken $row_id_token)
__construct(private readonly int $parent_obj_id, private readonly Factory $ui_factory, private readonly ilLanguage $lng, private readonly ilCtrlInterface $ctrl, private readonly DataFactory $data_factory, private readonly ServerRequestInterface $httpRequest,)
getTotalRowCount(?array $filter_data, ?array $additional_parameters)
getRows(OrderingRowBuilder $row_builder, array $visible_column_ids,)
This is called by the (ordering-)table to retrieve rows; map data-records to rows using the $row_buil...
language handling
Class ilRatingCategoryGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getAllForObject(int $a_parent_obj_id)
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
buildOrderingRow(string $id, array $record)
This describes a Table to specify the order of its data (rows).
Definition: Ordering.php:29
This is how the factory for UI elements looks.
Definition: Factory.php:38
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $lng
Definition: privfeed.php:31