ILIAS  release_8 Revision v8.24
class.ilLegacyKioskModeView.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
26
28{
29 public const GET_VIEW_CMD_FROM_LIST_GUI_FOR = ['sahs'];
30
31 protected ilObject $object;
32 protected ilLanguage $lng;
33 protected ilAccess $access;
34
35 public function __construct(
39 ) {
40 $this->object = $object;
41 $this->lng = $lng;
42 $this->access = $access;
43 }
44
45 protected function getObjectTitle(): string
46 {
47 return $this->object->getTitle();
48 }
49
50 protected function setObject(\ilObject $object): void
51 {
52 $this->object = $object;
53 }
54
55 protected function hasPermissionToAccessKioskMode(): bool
56 {
57 return true;
58 }
59
63 public function buildInitialState(State $empty_state): State
64 {
65 return $empty_state;
66 }
67
71 public function buildControls(State $state, ControlBuilder $builder): ControlBuilder
72 {
73 if (!$builder instanceof LSControlBuilder) {
74 throw new LogicException("The Legacy Mode in the Learning Sequence requires an LSControlBuilder explicitely.", 1);
75 }
76
77 $ref_id = $this->object->getRefId();
78 $type = $this->object->getType();
79
80 $label = sprintf(
81 $this->lng->txt('lso_start_item'),
82 $this->getTitleByType($type)
83 );
84
86 $ref_id,
87 $type
88 );
89
90 $obj_id = $this->object->getId();
91 if (in_array($type, self::GET_VIEW_CMD_FROM_LIST_GUI_FOR)) {
93 $item_list_gui->initItem($ref_id, $obj_id, $type);
94 $view_link = $item_list_gui->getCommandLink('view');
95 $view_link = str_replace('&amp;', '&', $view_link);
96 $view_link = ILIAS_HTTP_PATH . '/' . $view_link;
97 $url = $view_link;
98 }
99
100 $builder->start($label, $url, $obj_id);
101
102 return $builder;
103 }
104
108 public function updateGet(State $state, string $command, int $parameter = null): State
109 {
110 return $state;
111 }
112
116 public function updatePost(State $state, string $command, array $post): State
117 {
118 return $state;
119 }
120
124 public function render(
125 State $state,
127 URLBuilder $url_builder,
128 array $post = null
129 ): Component {
130 $obj_type = $this->object->getType();
131 $obj_type_txt = $this->lng->txt('obj_' . $obj_type);
132 $icon = $factory->symbol()->icon()->standard($obj_type, $obj_type_txt, 'large');
133
134 $props = array_merge(
135 [$this->lng->txt('obj_type') => $obj_type_txt],
136 $this->getMetadata($this->object->getId(), $obj_type)
137 );
138
139 return $factory->item()->standard($this->object->getTitle())
140 ->withLeadIcon($icon)
141 ->withDescription($this->object->getDescription())
142 ->withProperties($props);
143 }
144
145 //TODO: enhance metadata
149 private function getMetadata(int $obj_id, string $type): array
150 {
151 $md = new ilMD($obj_id, 0, $type);
152 $meta_data = [];
153
154 $section = $md->getGeneral();
155 if (!$section) {
156 return [];
157 }
158
159 $meta_data['language'] = [];
160 foreach ($section->getLanguageIds() as $id) {
161 $meta_data['language'][] = $section->getLanguage($id)->getLanguageCode();
162 }
163 $meta_data['keywords'] = [];
164 foreach ($section->getKeywordIds() as $id) {
165 $meta_data['keywords'][] = $section->getKeyword($id)->getKeyword();
166 }
167
168 $md_flat = [];
169 foreach ($meta_data as $md_label => $values) {
170 if ($values !== []) {
171 $md_flat[$this->lng->txt($md_label)] = implode(', ', $values);
172 }
173 }
174 return $md_flat;
175 }
176
177 private function getTitleByType(string $type): string
178 {
179 return $this->lng->txt("obj_" . $type);
180 }
181}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Keeps the state of a view in a simple stringly type key-value store.
Definition: State.php:13
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
language handling
__construct(ilObject $object, ilLanguage $lng, ilAccess $access)
buildInitialState(State $empty_state)
@inheritDoc
render(State $state, Factory $factory, URLBuilder $url_builder, array $post=null)
@inheritDoc
updatePost(State $state, string $command, array $post)
@inheritDoc
buildControls(State $state, ControlBuilder $builder)
@inheritDoc
updateGet(State $state, string $command, int $parameter=null)
@inheritDoc
getMetadata(int $obj_id, string $type)
static _getListGUIByType(string $type, int $context=ilObjectListGUI::CONTEXT_REPOSITORY)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Build controls for the view.
The URLBuilder allows views to get links that are used somewhere inline in the content.
Definition: URLBuilder.php:16
A kiosk mode view on a certain object.
Definition: View.php:17
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:67
$post
Definition: ltitoken.php:49
$factory
Definition: metadata.php:75
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$type
$url