ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilLegacyKioskModeView.php
Go to the documentation of this file.
1 <?php
2 
3 declare(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 
38  protected function setObject(\ilObject $object)
39  {
40  $this->object = $object;
41  }
42 
46  protected function hasPermissionToAccessKioskMode() : bool
47  {
48  return true;
49  //return $this->access->checkAccess('read', '', $this->contentPageObject->getRefId());
50  }
51 
55  public function buildInitialState(State $empty_state) : State
56  {
57  return $empty_state;
58  }
59 
64  {
65  if (!$builder instanceof LSControlBuilder) {
66  throw new LogicException("The Legacy Mode in the Learning Sequence requires an LSControlBuilder explicitely.", 1);
67  }
68 
69  $ref_id = $this->object->getRefId();
70  $type = $this->object->getType();
71 
72  $label = sprintf(
73  $this->lng->txt('lso_start_item'),
74  $this->getTitleByType($type)
75  );
76 
78  $ref_id,
79  $type,
80  true,
81  false
82  );
83 
84  if (in_array($type, self::GET_VIEW_CMD_FROM_LIST_GUI_FOR)) {
85  $obj_id = $this->object->getId();
87  $item_list_gui->initItem($ref_id, $obj_id, $type);
88  $view_link = $item_list_gui->getCommandLink('view');
89  $view_link = str_replace('&amp;', '&', $view_link);
90  $view_link = ILIAS_HTTP_PATH . '/' . $view_link;
91  $url = $view_link;
92  }
93 
94  $builder->start($label, $url, 0);
95 
96  // return $this->debugBuildAllControls($builder);
97  return $builder;
98  }
99 
103  public function updateGet(State $state, string $command, int $param = null) : State
104  {
105  return $state;
106  }
107 
111  public function updatePost(State $state, string $command, array $post) : State
112  {
113  return $state;
114  }
115 
119  public function render(
120  State $state,
122  URLBuilder $url_builder,
123  array $post = null
124  ) : Component {
125  $obj_type = $this->object->getType();
126  $obj_type_txt = $this->lng->txt('obj_' . $obj_type);
127  $icon = $factory->symbol()->icon()->standard($obj_type, $obj_type_txt, 'large');
128  $md = $this->getMetadata((int) $this->object->getId(), $obj_type);
129  $props = array_merge(
130  [$this->lng->txt('obj_type') => $obj_type_txt],
131  $this->getMetadata((int) $this->object->getId(), $obj_type)
132  );
133 
134  $info = $factory->item()->standard($this->object->getTitle())
135  ->withLeadIcon($icon)
136  ->withDescription($this->object->getDescription())
137  ->withProperties($props);
138 
139  return $info;
140  }
141 
142  //TODO: enhance metadata
143  private function getMetadata(int $obj_id, string $type) : array
144  {
145  $md = new ilMD($obj_id, 0, $type);
146  $meta_data = [];
147 
148  $section = $md->getGeneral();
149  if (!$section) {
150  return [];
151  }
152 
153  $meta_data['language'] = [];
154  foreach ($section->getLanguageIds() as $id) {
155  $meta_data['language'][] = $section->getLanguage($id)->getLanguageCode();
156  }
157  $meta_data['keywords'] = [];
158  foreach ($section->getKeywordIds() as $id) {
159  $meta_data['keywords'][] = $section->getKeyword($id)->getKeyword();
160  }
161 
162  $md_flat = [];
163  foreach ($meta_data as $md_label => $values) {
164  if (count($values) > 0) {
165  $md_flat[$this->lng->txt($md_label)] = implode(', ', $values);
166  }
167  }
168  return $md_flat;
169  }
170 
172  {
173  $builder
174 
175  ->tableOfContent($this->getObjectTitle(), 'kommando', 666)
176  ->node('node1')
177  ->item('item1.1', 1)
178  ->item('item1.2', 11)
179  ->end()
180  ->item('item2', 111)
181  ->node('node3', 1111)
182  ->item('item3.1', 2)
183  ->node('node3.2')
184  ->item('item3.2.1', 122)
185  ->end()
186  ->end()
187  ->end()
188 
189  ->locator('locator_cmd')
190  ->item('item 1', 1)
191  ->item('item 2', 2)
192  ->item('item 3', 3)
193  ->end()
194 
195  ->done('cmd', 1)
196  ->next('cmd', 1)
197  ->previous('', 1)
198  //->exit('cmd', 1)
199  ->generic('cmd 1', 'x', 1)
200  ->generic('cmd 2', 'x', 2)
201  //->toggle('toggle', 'cmd_on', 'cmd_off')
202  ->mode('modecmd', ['m1', 'm2', 'm3'])
203  ;
204 
205  return $builder;
206  }
207 
208  private function getTitleByType(string $type) : string
209  {
210  return $this->lng->txt("obj_" . $type);
211  }
212 }
Class ilLegacyKioskModeView.
$type
updateGet(State $state, string $command, int $param=null)
symbol()
description: purpose: > Symbols are graphical representations of concepts or contexts quickly compre...
tableOfContent(string $label, string $command, int $parameter=null, $state=null)
A table of content allows the user to get an overview over the generally available content in the obj...
updatePost(State $state, string $command, array $post)
Class ilAccessHandler.
__construct(ilObject $object, ilLanguage $lng, ilAccess $access)
Keeps the state of a view in a simple stringly type key-value store.
Definition: State.php:9
$section
Definition: Utf8Test.php:83
A kiosk mode view on a certain object.
Definition: View.php:13
buildControls(State $state, ControlBuilder $builder)
$lng
This is how the factory for UI elements looks.
Definition: Factory.php:17
debugBuildAllControls(ControlBuilder $builder)
$param
Definition: xapitoken.php:31
render(State $state, Factory $factory, URLBuilder $url_builder, array $post=null)
item()
description: purpose: > An item displays a unique entity within the system.
buildInitialState(State $empty_state)
The URLBuilder allows views to get links that are used somewhere inline in the content.
Definition: URLBuilder.php:12
static _getListGUIByType($a_type, $a_context=ilObjectListGUI::CONTEXT_REPOSITORY)
Class LSControlBuilder.
getMetadata(int $obj_id, string $type)
language handling
Build controls for the view.
$url
$builder
Definition: parser.php:5
$factory
Definition: metadata.php:58