ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilLegacyKioskModeView.php
Go to the documentation of this file.
1 <?php
2 
19 declare(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;
36 
37  public function __construct(
38  ilObject $object,
39  ilLanguage $lng,
40  ilAccess $access,
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 }
panel()
description: purpose: > Panels are used to group titled content.
symbol()
description: purpose: > Symbols are graphical representations of concepts or contexts quickly compre...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$url
Definition: shib_logout.php:66
updatePost(State $state, string $command, array $post)
Keeps the state of a view in a simple stringly type key-value store.
Definition: State.php:26
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
render(State $state, Factory $factory, URLBuilder $url_builder, ?array $post=null)
$ref_id
Definition: ltiauth.php:65
buildControls(State $state, ControlBuilder $builder)
This is how the factory for UI elements looks.
Definition: Factory.php:37
static _getListGUIByType(string $type, int $context=ilObjectListGUI::CONTEXT_REPOSITORY)
updateGet(State $state, string $command, ?int $parameter=null)
item()
description: purpose: > An item displays a unique entity within the system.
__construct(ilObject $object, ilLanguage $lng, ilAccess $access, LOMServices $lom_services)
messageBox()
description: purpose: > Message Boxes inform the user about the state of the system or an ongoing us...
buildInitialState(State $empty_state)
The URLBuilder allows views to get links that are used somewhere inline in the content.
Definition: URLBuilder.php:29
getMetadata(int $obj_id, string $type)
Build controls for the view.
$post
Definition: ltitoken.php:46