ILIAS  trunk Revision v12.0_alpha-16-g3e876e53c80
Builder.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27use ILIAS\Data\Factory as DataFactory;
28use DateTimeImmutable;
29use ILIAS\UI\Component\Listing\Unordered as UnorderedListing;
30use DateTimeZone;
33
35{
36 public function __construct(
37 protected InternalDomainService $domain,
38 protected InternalGUIService $gui,
39 protected DataFactory $data_factory,
40 protected SubObjectRetrieval $sub_object_retrieval,
41 object $parent_gui,
42 string $parent_cmd
43 ) {
44 parent::__construct($parent_gui, $parent_cmd, true);
45 }
46
47 protected function getId(): string
48 {
49 return 'mob_overview';
50 }
51
52 protected function getTitle(): string
53 {
54 return $this->domain->lng()->txt('mob_media_objects_overview');
55 }
56
57 protected function getRetrieval(): RetrievalInterface
58 {
59 return new Retrieval(
60 $this->sub_object_retrieval,
61 $this->domain,
62 $this->data_factory
63 );
64 }
65
66 protected function transformRow(array $data_row): array
67 {
68 $data = [
69 'id' => $data_row['id'],
70 'title' => $data_row['title'] ?? '',
71 'last_update' => (new DateTimeImmutable('@' . ($data_row['last_update'] ?? 0)))
72 ->setTimezone(new DateTimeZone($this->domain->user()->getTimeZone())),
73 'internal_usages' => $this->buildLinkListingFromData($data_row['internal_usages'] ?? []),
74 'mep_usages' => $this->buildLinkListingFromData($data_row['mep_usages'] ?? []),
75 'external_usages' => $this->buildLinkListingFromData($data_row['external_usages'] ?? [])
76 ];
77 if (($data_row['copyright_identifier'] ?? '') !== '') {
78 $preset = $this->domain->learningObjectMetadata()->copyrightHelper()->getCopyrightPreset($data_row['copyright_identifier']);
79 if ($image = $preset->presentAsImageOnly()) {
80 $data['copyright_icon'] = $image;
81 }
82 if ($link = $preset->presentAsLinkOnly()) {
83 $data['copyright'] = $link;
84 }
85 } elseif (($data_row['copyright'] ?? '') !== '') {
86 $data['copyright'] = $this->gui->ui()->factory()->link()->standard(
87 $data_row['copyright'],
88 ''
89 )->withDisabled();
90 }
91 return $data;
92 }
93
94 protected function buildLinkListingFromData(array $usage_data): UnorderedListing
95 {
96 $ui_factory = $this->gui->ui()->factory();
97
98 $links = [];
99 foreach ($usage_data as $usage) {
100 $title = $usage['title'] ?? '';
101 $link_string = $usage['link'] ?? '';
102 if ($title === '') {
103 continue;
104 }
105 $link = $ui_factory->link()->standard($title, $link_string);
106 if ($link_string === '') {
107 $link = $link->withDisabled();
108 }
109 $links[] = $link;
110 }
111 return $ui_factory->listing()->unordered($links);
112 }
113
115 {
116 $lng = $this->domain->lng();
117 $lom = $this->domain->learningObjectMetadata();
118
119 $table = $table
120 ->textColumn('title', $lng->txt('mob'), true)
121 ->dateColumn('last_update', $lng->txt('mob_last_update'), true);
122 if ($lom->copyrightHelper()->isCopyrightSelectionActive()) {
123 $table = $table
124 ->iconColumn('copyright_icon', $lng->txt('mob_copyright_icon'), false)
125 ->linkColumn('copyright', $lng->txt('mob_copyright'), true);
126 }
127 return $table
128 ->linkListingColumn('internal_usages', $lng->txt('mob_internal_usages_in_object'))
129 ->linkListingColumn('mep_usages', $lng->txt('mob_usages_in_media_pools'))
130 ->linkListingColumn('external_usages', $lng->txt('mob_usages_in_other_objects'));
131 }
132}
Builds data types.
Definition: Factory.php:36
transformRow(array $data_row)
transform raw data array to table row data array
Definition: Builder.php:66
__construct(protected InternalDomainService $domain, protected InternalGUIService $gui, protected DataFactory $data_factory, protected SubObjectRetrieval $sub_object_retrieval, object $parent_gui, string $parent_cmd)
Definition: Builder.php:36
textColumn(string $key, string $title, bool $sortable=false)
linkListingColumn(string $key, string $title, bool $sortable=false)
iconColumn(string $key, string $title, bool $sortable=false)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $lng
Definition: privfeed.php:31