19declare(strict_types=1);
31use Psr\Http\Message\ServerRequestInterface;
33use Psr\Http\Message\RequestInterface;
46 private readonly ServerRequestInterface|RequestInterface
$request;
53 public function __construct(
protected bool $has_write =
false)
56 $this->
lng = $DIC->language();
57 $this->tpl =
$DIC->ui()->mainTemplate();
58 $this->
factory = $DIC->ui()->factory();
59 $this->
renderer = $DIC->ui()->renderer();
61 $this->request =
$DIC->http()->request();
62 $this->
http = $DIC->http();
70 if ($this->cached_records !==
null) {
79 $title = $template->getTitle();
81 $image_src = $template->getImageFromResourceId();
82 if ($image_src !==
'') {
83 $image_component = $this->
factory->image()->responsive(
87 $image_html = $this->
renderer->render($image_component);
89 $image_src_large = $template->getImageFromResourceId(
92 $large_image_component = $this->
factory->image()->responsive(
97 $modal = $modal_container->constructModal($large_image_component, $template->getTitle());
99 $image = implode(
'', [
100 $modal_container->renderShyButton($image_html, $modal),
101 $modal_container->renderModal($modal)
103 $title = $modal_container->renderShyButton($template->getTitle(), $modal);
107 'id' => $template->getId(),
110 'title_sortable' => $template->getTitle()
114 $this->cached_records = $rows;
121 array $visible_column_ids,
124 mixed $additional_viewcontrol_data,
126 mixed $additional_parameters
131 [$order_field, $order_direction] = $order->
join(
133 fn($ret, $key, $value) => [$key, $value]
136 usort($records,
static function (array $left, array $right) use ($order_field):
int {
137 if ($order_field ===
'title') {
138 return \ilStr::strCmp(
139 $left[$order_field .
'_sortable'],
140 $right[$order_field .
'_sortable']
144 return $left[$order_field] <=> $right[$order_field];
148 $records = array_reverse($records);
156 foreach ($records as $record) {
157 yield $row_builder->
buildDataRow((
string) $record[
'id'], $record);
162 mixed $additional_viewcontrol_data,
164 mixed $additional_parameters
166 return \count($this->getRecords());
175 'image' => $this->
factory->table()->column()->text($this->
lng->txt(
'image'))->withIsSortable(
false),
176 'title' => $this->
factory->table()->column()->text($this->
lng->txt(
'title'))
188 return $this->has_write ? [
189 'badge_image_template_edit' => $this->
factory->table()->action()->single(
190 $this->
lng->txt(
'edit'),
191 $url_builder->withParameter($action_parameter_token,
'badge_image_template_editImageTemplate'),
194 'badge_image_template_delete' =>
196 $this->
lng->txt(
'delete'),
197 $url_builder->withParameter($action_parameter_token,
'badge_image_template_delete'),
205 $df = new \ILIAS\Data\Factory();
207 $table_uri = $df->uri(
$url);
209 $query_params_namespace = [
'tid'];
211 [$url_builder, $action_parameter_token, $row_id_token] = $url_builder->acquireParameters(
212 $query_params_namespace,
219 ->data($this, $this->
lng->txt(
'badge_image_templates'), $this->getColumns())
220 ->withId(self::class)
221 ->withOrder(
new Order(
'title', Order::ASC))
222 ->withActions($this->getActions($url_builder, $action_parameter_token, $row_id_token))
223 ->withRequest($this->request);
226 $query = $this->
http->wrapper()->query();
227 if ($query->has(
'tid')) {
228 $query_values = $query->retrieve(
230 $this->
refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->string())
234 if ($query_values === [
'ALL_OBJECTS']) {
236 if ($template->getId() !==
null) {
237 $items[] = $this->
factory->modal()->interruptiveItem()->keyValue(
238 (
string) $template->getId(),
239 (
string) $template->getId(),
240 $template->getTitle()
244 } elseif (\is_array($query_values)) {
245 foreach ($query_values as
$id) {
247 $items[] = $this->
factory->modal()->interruptiveItem()->keyValue(
249 (
string) $badge->getId(),
255 $items[] = $this->
factory->modal()->interruptiveItem()->keyValue(
256 (
string) $badge->getId(),
257 (
string) $badge->getId(),
261 if ($query->has($action_parameter_token->getName())) {
262 $action = $query->retrieve($action_parameter_token->getName(), $this->refinery->kindlyTo()->string());
263 if ($action ===
'badge_image_template_delete') {
264 $this->
http->saveResponse(
268 Streams::ofString($this->
renderer->renderAsync([
269 $this->factory->modal()->interruptive(
270 $this->lng->txt(
'badge_deletion'),
271 $this->lng->txt(
'badge_deletion_confirmation'),
273 )->withAffectedItems($items)
277 $this->
http->sendResponse();
278 $this->
http->close();
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
readonly ILIAS Refinery Factory $refinery
readonly Factory $factory
getTotalRowCount(mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
Mainly for the purpose of pagination-support, it is important to know about the total number of recor...
readonly Renderer $renderer
readonly ServerRequestInterface RequestInterface $request
getRows(DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
This is called by the table to retrieve rows; map data-records to rows using the $row_builder e....
getActions(URLBuilder $url_builder, URLBuilderToken $action_parameter_token, URLBuilderToken $row_id_token)
__construct(protected bool $has_write=false)
readonly ilGlobalTemplateInterface $tpl
Builds a Color from either hex- or rgb values.
Both the subject and the direction need to be specified when expressing an order.
join($init, callable $fn)
A simple class to express a naive range of whole positive numbers.
Stream factory which enables the user to create streams without the knowledge of the concrete class.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
A Column describes the form of presentation for a certain aspect of data, i.e.
buildDataRow(string $id, array $record)
This is how the factory for UI elements looks.
An entity that renders components to a string output.
static http()
Fetches the global http state from ILIAS.