ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilLegacyKioskModeView.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
10
15{
17
18 protected $object;
19
20 public function __construct(
23 ilAccess $access
24 ) {
25 $this->object = $object;
26 $this->lng = $lng;
27 $this->access = $access;
28 }
29
30 protected function getObjectTitle() : string
31 {
32 return $this->object->getTitle();
33 }
34
35 protected function getType() : string
36 {
37 return $this->object->getType();
38 }
39
43 protected function setObject(\ilObject $object)
44 {
45 $this->object = $object;
46 }
47
51 protected function hasPermissionToAccessKioskMode() : bool
52 {
53 return true;
54 //return $this->access->checkAccess('read', '', $this->contentPageObject->getRefId());
55 }
56
60 public function buildInitialState(State $empty_state) : State
61 {
62 return $empty_state;
63 }
64
69 {
70 if (!$builder instanceof LSControlBuilder) {
71 throw new LogicException("The Legacy Mode in the Learning Sequence requires an LSControlBuilder explicitely.", 1);
72 }
73
74 $label = $this->lng->txt('lso_start_item') . ' ' . $this->getTitleByType($this->getType());
75
76 $ref_id = $this->object->getRefId();
77 $obj_id = (int) $this->object->getId();
78 $type = $this->object->getType();
79
81 $ref_id,
82 $type,
83 true,
84 false
85 );
86
87 if (in_array($type, self::GET_VIEW_CMD_FROM_LIST_GUI_FOR)) {
89 $item_list_gui->initItem($ref_id, $obj_id);
90 $view_link = $item_list_gui->getCommandLink('view');
91 $view_link = str_replace('&amp;', '&', $view_link);
92 $view_link = ILIAS_HTTP_PATH . '/' . $view_link;
93 $url = $view_link;
94 }
95
96 $builder->start($label, $url, $obj_id);
97 //return $this->debugBuildAllControls($builder);
98 return $builder;
99 }
100
104 public function updateGet(State $state, string $command, int $param = null) : State
105 {
106 return $state;
107 }
108
112 public function updatePost(State $state, string $command, array $post) : State
113 {
114 return $state;
115 }
116
120 public function render(
123 URLBuilder $url_builder,
124 array $post = null
125 ) : Component {
126 $obj_type = $this->object->getType();
127 $obj_type_txt = $this->lng->txt('obj_' . $obj_type);
128 $icon = $factory->icon()->standard($obj_type, $obj_type_txt, 'large');
129 $md = $this->getMetadata((int) $this->object->getId(), $obj_type);
130 $props = array_merge(
131 [$this->lng->txt('obj_type') => $obj_type_txt],
132 $this->getMetadata((int) $this->object->getId(), $obj_type)
133 );
134
135 $info = $factory->item()->standard($this->object->getTitle())
136 ->withLeadIcon($icon)
137 ->withDescription($this->object->getDescription())
138 ->withProperties($props);
139
140 return $info;
141 }
142
143 //TODO: enhance metadata
144 private function getMetadata(int $obj_id, string $type) : array
145 {
146 $md = new ilMD($obj_id, 0, $type);
147 $meta_data = [];
148
149 $section = $md->getGeneral();
150 if (!$section) {
151 return [];
152 }
153
154 $meta_data['language'] = [];
155 foreach ($section->getLanguageIds() as $id) {
156 $meta_data['language'][] = $section->getLanguage($id)->getLanguageCode();
157 }
158 $meta_data['keywords'] = [];
159 foreach ($section->getKeywordIds() as $id) {
160 $meta_data['keywords'][] = $section->getKeyword($id)->getKeyword();
161 }
162
163 $md_flat = [];
164 foreach ($meta_data as $md_label => $values) {
165 if (count($values) > 0) {
166 $md_flat[$this->lng->txt($md_label)] = implode(', ', $values);
167 }
168 }
169 return $md_flat;
170 }
171
173 {
175
176 ->tableOfContent($this->getObjectTitle(), 'kommando', 666)
177 ->node('node1')
178 ->item('item1.1', 1)
179 ->item('item1.2', 11)
180 ->end()
181 ->item('item2', 111)
182 ->node('node3', 1111)
183 ->item('item3.1', 2)
184 ->node('node3.2')
185 ->item('item3.2.1', 122)
186 ->end()
187 ->end()
188 ->end()
189
190 ->locator('locator_cmd')
191 ->item('item 1', 1)
192 ->item('item 2', 2)
193 ->item('item 3', 3)
194 ->end()
195
196 ->done('cmd', 1)
197 ->next('cmd', 1)
198 ->previous('', 1)
199 //->exit('cmd', 1)
200 ->generic('cmd 1', 'x', 1)
201 ->generic('cmd 2', 'x', 2)
202 //->toggle('toggle', 'cmd_on', 'cmd_off')
203 ->mode('modecmd', ['m1', 'm2', 'm3'])
204 ;
205
206 return $builder;
207 }
208
209 private function getTitleByType(string $type) : string
210 {
211 return $this->lng->txt("obj_" . $type);
212 }
213}
$factory
Definition: metadata.php:43
$section
Definition: Utf8Test.php:83
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
Definition: linkback.php:10
An exception for terminatinating execution or to throw for unit testing.
Keeps the state of a view in a simple stringly type key-value store.
Definition: State.php:10
Class LSControlBuilder.
Class ilAccessHandler.
language handling
Class ilLegacyKioskModeView.
updateGet(State $state, string $command, int $param=null)
@inheritDoc
debugBuildAllControls(ControlBuilder $builder)
__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
setObject(\ilObject $object)
@inheritDoc
getMetadata(int $obj_id, string $type)
static _getListGUIByType($a_type, $a_context=ilObjectListGUI::CONTEXT_REPOSITORY)
Class ilObject Basic functions for all objects.
if(!array_key_exists('StateId', $_REQUEST)) $id
Build controls for the view.
The URLBuilder allows views to get links that are used somewhere inline in the content.
Definition: URLBuilder.php:13
A kiosk mode view on a certain object.
Definition: View.php:14
A component is the most general form of an entity in the UI.
Definition: Component.php:14
This is how the factory for UI elements looks.
Definition: Factory.php:16
$info
Definition: index.php:5
$builder
Definition: parser.php:5
$post
Definition: post.php:34
$type
$url
$lng
$values