ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLegacyKioskModeView.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27
29{
30 public const GET_VIEW_CMD_FROM_LIST_GUI_FOR = ['sahs'];
31
32 protected ilObject $object;
33 protected ilLanguage $lng;
34 protected ilAccess $access;
35 protected LOMServices $lom_services;
36
37 public function __construct(
41 LOMServices $lom_services
42 ) {
43 $this->object = $object;
44 $this->lng = $lng;
45 $this->access = $access;
46 $this->lom_services = $lom_services;
47 }
48
49 protected function getObjectTitle(): string
50 {
51 return $this->object->getTitle();
52 }
53
54 protected function setObject(\ilObject $object): void
55 {
56 $this->object = $object;
57 }
58
59 protected function hasPermissionToAccessKioskMode(): bool
60 {
61 return true;
62 }
63
67 public function buildInitialState(State $empty_state): State
68 {
69 return $empty_state;
70 }
71
75 public function buildControls(State $state, ControlBuilder $builder): ControlBuilder
76 {
77 if (!$builder instanceof LSControlBuilder) {
78 throw new LogicException("The Legacy Mode in the Learning Sequence requires an LSControlBuilder explicitely.", 1);
79 }
80
81 $ref_id = $this->object->getRefId();
82 $type = $this->object->getType();
83
84 $label = sprintf(
85 $this->lng->txt('lso_start_item'),
86 $this->getTitleByType($type)
87 );
88
90 $ref_id,
91 $type
92 );
93
94 $obj_id = $this->object->getId();
95 if (in_array($type, self::GET_VIEW_CMD_FROM_LIST_GUI_FOR)) {
96 $item_list_gui = \ilObjectListGUIFactory::_getListGUIByType($type);
97 $item_list_gui->initItem($ref_id, $obj_id, $type);
98 $view_link = $item_list_gui->getCommandLink('view');
99 $view_link = str_replace('&amp;', '&', $view_link);
100 $view_link = ILIAS_HTTP_PATH . '/' . $view_link;
101 $url = $view_link;
102 }
103
104 $builder->start($label, $url, $obj_id);
105
106 return $builder;
107 }
108
112 public function updateGet(State $state, string $command, ?int $parameter = null): State
113 {
114 return $state;
115 }
116
120 public function updatePost(State $state, string $command, array $post): State
121 {
122 return $state;
123 }
124
128 public function render(
129 State $state,
130 Factory $factory,
131 URLBuilder $url_builder,
132 ?array $post = null
133 ): Component {
134 $obj_type = $this->object->getType();
135 $obj_type_txt = $this->lng->txt('obj_' . $obj_type);
136 $icon = $factory->symbol()->icon()->standard($obj_type, $obj_type_txt, 'large');
137
138 $props = array_merge(
139 [$this->lng->txt('obj_type') => $obj_type_txt],
140 $this->getMetadata($this->object->getId(), $obj_type)
141 );
142
143 return $factory->panel()->standard(
144 $this->object->getTitle(),
145 [
146 $factory->messageBox()->info($this->lng->txt('lso_legacy_info')),
147 $factory->item()->standard($this->object->getTitle())
148 ->withLeadIcon($icon)
149 ->withDescription($this->object->getDescription())
150 ->withProperties($props)
151 ]
152 );
153 }
154
155 //TODO: enhance metadata
159 private function getMetadata(int $obj_id, string $type): array
160 {
161 $paths = $this->lom_services->paths();
162 $data_helper = $this->lom_services->dataHelper();
163 $reader = $this->lom_services->read(
164 $obj_id,
165 0,
166 $type,
167 $paths->custom()->withNextStep('general')->get()
168 );
169
170 $meta_data = [];
171
172 $languages = $data_helper->makePresentableAsList(
173 ', ',
174 ...$reader->allData($paths->languages())
175 );
176 if ($languages !== '') {
177 $meta_data[$this->lng->txt('language')] = $languages;
178 }
179
180 $keywords = $data_helper->makePresentableAsList(
181 ', ',
182 ...$reader->allData($paths->keywords())
183 );
184 if ($keywords !== '') {
185 $meta_data[$this->lng->txt('keywords')] = $keywords;
186 }
187
188 return $meta_data;
189 }
190
191 private function getTitleByType(string $type): string
192 {
193 return $this->lng->txt("obj_" . $type);
194 }
195}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Keeps the state of a view in a simple stringly type key-value store.
Definition: State.php:27
Class ilAccessHandler Checks access for ILIAS objects.
language handling
buildInitialState(State $empty_state)
@inheritDoc
updateGet(State $state, string $command, ?int $parameter=null)
@inheritDoc
__construct(ilObject $object, ilLanguage $lng, ilAccess $access, LOMServices $lom_services)
updatePost(State $state, string $command, array $post)
@inheritDoc
buildControls(State $state, ControlBuilder $builder)
@inheritDoc
render(State $state, Factory $factory, URLBuilder $url_builder, ?array $post=null)
@inheritDoc
getMetadata(int $obj_id, string $type)
static _getListGUIByType(string $type, int $context=ilObjectListGUI::CONTEXT_REPOSITORY)
Class ilObject Basic functions for all objects.
Build controls for the view.
The URLBuilder allows views to get links that are used somewhere inline in the content.
Definition: URLBuilder.php:30
A kiosk mode view on a certain object.
Definition: View.php:31
A component is the most general form of an entity in the UI.
Definition: Component.php:28
This is how the factory for UI elements looks.
Definition: Factory.php:38
$ref_id
Definition: ltiauth.php:66
$post
Definition: ltitoken.php:46
$url
Definition: shib_logout.php:68