ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilContentPageKioskModeView.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3
12
17{
18 const CMD_LP_TO_COMPLETED = 'lp_completed';
19 const CMD_LP_TO_INCOMPLETE = 'lp_incomplete';
20
23
25 protected $user;
26
28 protected $uiFactory;
29
31 protected $uiRenderer;
32
34 protected $ctrl;
35
37 protected $mainTemplate;
38
40 protected $httpRequest;
41
43 protected $tabs;
44
46 protected $messages = [];
47
51 protected function getObjectClass() : string
52 {
53 return \ilObjContentPage::class;
54 }
55
59 protected function setObject(\ilObject $object)
60 {
61 global $DIC;
62
63 $this->contentPageObject = $object;
64
65 $this->ctrl = $DIC->ctrl();
66 $this->mainTemplate = $DIC->ui()->mainTemplate();
67 $this->uiFactory = $DIC->ui()->factory();
68 $this->uiRenderer = $DIC->ui()->renderer();
69 $this->httpRequest = $DIC->http()->request();
70 $this->tabs = $DIC->tabs();
71 $this->user = $DIC->user();
72 }
73
77 protected function hasPermissionToAccessKioskMode() : bool
78 {
79 return $this->access->checkAccess('read', '', $this->contentPageObject->getRefId());
80 }
81
85 public function buildInitialState(State $empty_state) : State
86 {
87 return $empty_state;
88 }
89
94 {
96 }
97
102 {
103 $learningProgress = \ilObjectLP::getInstance($this->contentPageObject->getId());
104 if ($learningProgress->getCurrentMode() == \ilLPObjSettings::LP_MODE_MANUAL) {
105 $isCompleted = \ilLPMarks::_hasCompleted($this->user->getId(), $this->contentPageObject->getId());
106
107 $this->lng->loadLanguageModule('copa');
108 $learningProgressToggleCtrlLabel = $this->lng->txt('copa_btn_lp_toggle_state_completed');
110 if (!$isCompleted) {
111 $learningProgressToggleCtrlLabel = $this->lng->txt('copa_btn_lp_toggle_state_not_completed');
113 }
114
115 $builder->generic(
116 $learningProgressToggleCtrlLabel,
117 $cmd,
118 1
119 );
120 }
121 }
122
126 public function updateGet(State $state, string $command, int $param = null) : State
127 {
128 $this->toggleLearningProgress($command);
129
130 return $state;
131 }
132
136 protected function toggleLearningProgress(string $command)
137 {
138 if (in_array($command, [
139 self::CMD_LP_TO_COMPLETED,
140 self::CMD_LP_TO_INCOMPLETE
141 ])) {
142 $learningProgress = ilObjectLP::getInstance($this->contentPageObject->getId());
143 if ($learningProgress->getCurrentMode() == ilLPObjSettings::LP_MODE_MANUAL) {
144 $marks = new ilLPMarks($this->contentPageObject->getId(), $this->user->getId());
145
146 $old_state = $marks->getCompleted();
147 $new_state = ($command === self::CMD_LP_TO_COMPLETED);
148 $marks->setCompleted($new_state);
149 $marks->update();
150 ilLPStatusWrapper::_updateStatus($this->contentPageObject->getId(), $this->user->getId());
151
152 if ($old_state != $new_state) {
153 $this->lng->loadLanguageModule('trac');
154 $this->messages[] = $this->uiFactory->messageBox()->success(
155 $this->lng->txt('trac_updated_status')
156 );
157 }
158 }
159 }
160 }
161
165 public function updatePost(State $state, string $command, array $post) : State
166 {
167 return $state;
168 }
169
173 public function render(
176 URLBuilder $url_builder,
177 array $post = null
178 ) : Component {
179 \ilLearningProgress::_tracProgress(
180 $this->user->getId(),
181 $this->contentPageObject->getId(),
182 $this->contentPageObject->getRefId(),
183 $this->contentPageObject->getType()
184 );
185
186 $this->renderContentStyle();
187
188 $forwarder = new \ilContentPagePageCommandForwarder(
189 $this->httpRequest,
190 $this->ctrl,
191 $this->tabs,
192 $this->lng,
193 $this->contentPageObject
194 );
196
197 $this->ctrl->setParameterByClass(\ilContentPagePageGUI::class, 'ref_id', $this->contentPageObject->getRefId());
198
199 return $factory->legacy(implode('', [
200 $this->uiRenderer->render($this->messages),
201 $forwarder->forward($this->ctrl->getLinkTargetByClass([
202 \ilRepositoryGUI::class, \ilObjContentPageGUI::class, \ilContentPagePageGUI::class
203 ]))
204 ]));
205 }
206
210 protected function renderContentStyle()
211 {
212 $this->mainTemplate->addCss(\ilObjStyleSheet::getSyntaxStylePath());
213 $this->mainTemplate->addCss(
215 $this->contentPageObject->getStyleSheetId()
216 )
217 );
218 }
219}
user()
Definition: user.php:4
$factory
Definition: metadata.php:43
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 ilContentPageKioskModeView.
setObject(\ilObject $object)
@inheritDoc
buildInitialState(State $empty_state)
@inheritDoc
buildControls(State $state, ControlBuilder $builder)
@inheritDoc
updatePost(State $state, string $command, array $post)
@inheritDoc
builtLearningProgressToggleControl(ControlBuilder $builder)
renderContentStyle()
Renders the content style of a ContentPage object into main template.
updateGet(State $state, string $command, int $param=null)
@inheritDoc
render(State $state, Factory $factory, URLBuilder $url_builder, array $post=null)
@inheritDoc
const PRESENTATION_MODE_EMBEDDED_PRESENTATION
presentation mode for embedded presentation, e.g.
Base class to be implemented and put in class-directory of module with the name il$MODULEKioskModeVie...
static _hasCompleted($a_usr_id, $a_obj_id)
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
static getSyntaxStylePath()
get syntax style path
static getContentStylePath($a_style_id, $add_random=true)
get content style path
static getInstance($a_obj_id)
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:13
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
An entity that renders components to a string output.
Definition: Renderer.php:15
Representation of an incoming, server-side HTTP request.
$builder
Definition: parser.php:5
$post
Definition: post.php:34
global $DIC
Definition: saml.php:7