ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
LSControlBuilder Class Reference
+ Inheritance diagram for LSControlBuilder:
+ Collaboration diagram for LSControlBuilder:

Public Member Functions

 __construct (Factory $ui_factory, LSURLBuilder $url_builder, ilLanguage $language, LSGlobalSettings $global_settings, LSURLBuilder $lp_url_builder)
 
 getToggles ()
 
 getModeControls ()
 
 getControls ()
 
 getExitControl ()
 
 getPreviousControl ()
 
 getNextControl ()
 
 getDoneControl ()
 
 getToc ()
 
 getLocator ()
 
 exit (string $command)
 An exit control allows the user to gracefully leave the object providing the kiosk mode. More...
 
 next (string $command, ?int $parameter=null)
 A next control allows the user to progress to the next item in the object. More...
 
 previous (string $command, ?int $parameter=null)
 A previous control allows the user to go back to the previous item in the object. More...
 
 done (string $command, ?int $parameter=null)
 A done control allows the user to mark the object as done. More...
 
 generic (string $label, string $command, ?int $parameter=null)
 A generic control needs to have a label that tells what it does. More...
 
 genericWithSignal (string $label, Signal $signal)
 
 toggle (string $label, string $on_command, string $off_command)
 A toggle can be used to switch some behaviour in the view on or of. More...
 
 mode (string $command, array $labels)
 A mode control can be used to switch between different modes in the view. More...
 
 locator (string $command)
 A locator allows the user to see the path leading to her current location and jump back to previous items on that path. More...
 
 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 object. More...
 
 start (string $label, string $url, int $obj_id)
 Add a "start"-button as primary. More...
 
 getStartControl ()
 
 getAdditionalJS ()
 
- Public Member Functions inherited from ILIAS\KioskMode\ControlBuilder
 genericWithSignal (string $label, UI\Component\Signal $signal)
 A genericWithSignal will trigger the Signal rather than refreshing the View. More...
 

Data Fields

const CMD_START_OBJECT = 'start_legacy_obj'
 
const CMD_CHECK_CURRENT_ITEM_LP = 'ccilp'
 

Protected Member Functions

 setListenerJS (string $check_lp_url, string $on_lp_change_url)
 

Protected Attributes

array $controls = []
 
array $toggles = []
 
array $mode_controls = []
 
Component $exit_control = null
 
Component $previous_control = null
 
Component $next_control = null
 
Component $done_control = null
 
TOCBuilder $toc = null
 
LocatorBuilder $loc = null
 
JavaScriptBindable $start = null
 
string $additional_js = null
 
Factory $ui_factory
 
LSURLBuilder $url_builder
 
ilLanguage $lng
 
LSGlobalSettings $global_settings
 
LSURLBuilder $lp_url_builder
 

Detailed Description

Definition at line 29 of file LSControlBuilder.php.

Constructor & Destructor Documentation

◆ __construct()

LSControlBuilder::__construct ( Factory  $ui_factory,
LSURLBuilder  $url_builder,
ilLanguage  $language,
LSGlobalSettings  $global_settings,
LSURLBuilder  $lp_url_builder 
)

Definition at line 63 of file LSControlBuilder.php.

References $global_settings, $lp_url_builder, $ui_factory, $url_builder, and ILIAS\Repository\lng().

69  {
70  $this->ui_factory = $ui_factory;
71  $this->url_builder = $url_builder;
72  $this->lng = $language;
73  $this->global_settings = $global_settings;
74  $this->lp_url_builder = $lp_url_builder;
75  }
LSURLBuilder $lp_url_builder
LSGlobalSettings $global_settings
LSURLBuilder $url_builder
+ Here is the call graph for this function:

Member Function Documentation

◆ done()

LSControlBuilder::done ( string  $command,
?int  $parameter = null 
)

A done control allows the user to mark the object as done.

The $parameter can be used to pass additional information to View::updateGet if required, e.g. about a chapter in the content.

Exceptions

Implements ILIAS\KioskMode\ControlBuilder.

Definition at line 183 of file LSControlBuilder.php.

References ILIAS\Repository\lng().

Referenced by setListenerJS().

184  {
185  if ($this->done_control) {
186  throw new \LogicException("Only one done-control per view...", 1);
187  }
188  $label = $this->lng->txt('lso_player_done');
189  $cmd = $this->url_builder->getHref($command, $parameter);
190  $btn = $this->ui_factory->button()->primary($label, $cmd);
191  $this->done_control = $btn;
192  return $this;
193  }
Build controls for the view.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exit()

LSControlBuilder::exit ( string  $command)

An exit control allows the user to gracefully leave the object providing the kiosk mode.

Exceptions

Implements ILIAS\KioskMode\ControlBuilder.

Definition at line 131 of file LSControlBuilder.php.

References ILIAS\Repository\lng(), and ilLSPlayer\LSO_CMD_FINISH.

Referenced by ilLSPlayer\buildDefaultControls().

132  {
133  if ($this->exit_control) {
134  throw new \LogicException("Only one exit-control per view...", 1);
135  }
136  $cmd = $this->url_builder->getHref($command);
137 
138  $label = 'lso_player_suspend';
139  if ($command === ilLSPlayer::LSO_CMD_FINISH) {
140  $label = 'lso_player_finish';
141  }
142 
143  $exit_button = $this->ui_factory->button()->bulky(
144  $this->ui_factory->symbol()->glyph()->close(),
145  $this->lng->txt($label),
146  $cmd
147  );
148 
149  $this->exit_control = $exit_button;
150  return $this;
151  }
const LSO_CMD_FINISH
Build controls for the view.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generic()

LSControlBuilder::generic ( string  $label,
string  $command,
?int  $parameter = null 
)

A generic control needs to have a label that tells what it does.

The $parameter can be used to pass additional information to View::updateGet if required, e.g. about a chapter in the content.

Implements ILIAS\KioskMode\ControlBuilder.

Definition at line 195 of file LSControlBuilder.php.

196  {
197  $cmd = $this->url_builder->getHref($command, $parameter);
198  $this->controls[] = $this->ui_factory->button()->standard($label, $cmd);
199  return $this;
200  }
Build controls for the view.

◆ genericWithSignal()

LSControlBuilder::genericWithSignal ( string  $label,
Signal  $signal 
)

Definition at line 202 of file LSControlBuilder.php.

203  {
204  $this->controls[] = $this->ui_factory->button()->standard($label, '')
205  ->withOnClick($signal);
206  return $this;
207  }
Build controls for the view.

◆ getAdditionalJS()

LSControlBuilder::getAdditionalJS ( )

Definition at line 283 of file LSControlBuilder.php.

References $additional_js.

Referenced by ilKioskPageRenderer\render().

283  : ?string
284  {
285  return $this->additional_js;
286  }
+ Here is the caller graph for this function:

◆ getControls()

LSControlBuilder::getControls ( )
Returns
[]

Definition at line 96 of file LSControlBuilder.php.

References $controls.

Referenced by ilKioskPageRenderer\render().

96  : array
97  {
98  return $this->controls;
99  }
+ Here is the caller graph for this function:

◆ getDoneControl()

LSControlBuilder::getDoneControl ( )

Definition at line 116 of file LSControlBuilder.php.

References $done_control.

Referenced by ilKioskPageRenderer\render().

116  : ?Component
117  {
118  return $this->done_control;
119  }
+ Here is the caller graph for this function:

◆ getExitControl()

LSControlBuilder::getExitControl ( )

Definition at line 101 of file LSControlBuilder.php.

References $exit_control.

Referenced by ilLSPlayer\buildDefaultControls().

101  : ?Component
102  {
103  return $this->exit_control;
104  }
+ Here is the caller graph for this function:

◆ getLocator()

LSControlBuilder::getLocator ( )

Definition at line 126 of file LSControlBuilder.php.

References $loc.

Referenced by ilKioskPageRenderer\render().

126  : ?LocatorBuilder
127  {
128  return $this->loc;
129  }
Build a locator for the view.
LocatorBuilder $loc
+ Here is the caller graph for this function:

◆ getModeControls()

LSControlBuilder::getModeControls ( )
Returns
[]

Definition at line 88 of file LSControlBuilder.php.

References $mode_controls.

Referenced by ilKioskPageRenderer\render().

88  : array
89  {
90  return $this->mode_controls;
91  }
+ Here is the caller graph for this function:

◆ getNextControl()

LSControlBuilder::getNextControl ( )

Definition at line 111 of file LSControlBuilder.php.

References $next_control.

Referenced by ilLSPlayer\buildDefaultControls(), and ilKioskPageRenderer\render().

111  : ?Component
112  {
113  return $this->next_control;
114  }
+ Here is the caller graph for this function:

◆ getPreviousControl()

LSControlBuilder::getPreviousControl ( )

Definition at line 106 of file LSControlBuilder.php.

References $previous_control.

Referenced by ilLSPlayer\buildDefaultControls(), and ilKioskPageRenderer\render().

106  : ?Component
107  {
109  }
Component $previous_control
+ Here is the caller graph for this function:

◆ getStartControl()

LSControlBuilder::getStartControl ( )

Definition at line 278 of file LSControlBuilder.php.

References $start.

Referenced by ilKioskPageRenderer\render().

279  {
280  return $this->start;
281  }
JavaScriptBindable $start
+ Here is the caller graph for this function:

◆ getToc()

LSControlBuilder::getToc ( )

Definition at line 121 of file LSControlBuilder.php.

References $toc.

121  : ?TOCBuilder
122  {
123  return $this->toc;
124  }
Build a nested table of contents for the view.
Definition: TOCBuilder.php:28

◆ getToggles()

LSControlBuilder::getToggles ( )
Returns
[]

Definition at line 80 of file LSControlBuilder.php.

References $toggles.

80  : array
81  {
82  return $this->toggles;
83  }

◆ locator()

LSControlBuilder::locator ( string  $command)

A locator allows the user to see the path leading to her current location and jump back to previous items on that path.

The command will be enhanced with a parameter defined in the locator builder.

Exceptions

Implements ILIAS\KioskMode\ControlBuilder.

Definition at line 224 of file LSControlBuilder.php.

References $loc.

225  {
226  if ($this->loc) {
227  throw new \LogicException("Only one locator per view...", 1);
228  }
229  $this->loc = new LSLocatorBuilder($command, $this);
230  return $this->loc;
231  }
Build a locator for the view.
LocatorBuilder $loc

◆ mode()

LSControlBuilder::mode ( string  $command,
array  $labels 
)

A mode control can be used to switch between different modes in the view.

Uses the indizes of the labels in the array as parameter for the command.

Implements ILIAS\KioskMode\ControlBuilder.

Definition at line 214 of file LSControlBuilder.php.

References ILIAS\KioskMode\ControlBuilder\mode().

215  {
216  $actions = [];
217  foreach ($labels as $parameter => $label) {
218  $actions[$label] = $this->url_builder->getHref($command, $parameter);
219  }
220  $this->mode_controls[] = $this->ui_factory->viewControl()->mode($actions, '');
221  return $this;
222  }
mode(string $command, array $labels)
A mode control can be used to switch between different modes in the view.
Build controls for the view.
+ Here is the call graph for this function:

◆ next()

LSControlBuilder::next ( string  $command,
?int  $parameter = null 
)

A next control allows the user to progress to the next item in the object.

The $parameter can be used to pass additional information to View::updateGet if required, e.g. about a chapter in the content.

Exceptions

Implements ILIAS\KioskMode\ControlBuilder.

Definition at line 153 of file LSControlBuilder.php.

References ILIAS\Repository\lng().

Referenced by ilLSPlayer\buildDefaultControls().

154  {
155  if ($this->next_control) {
156  throw new \LogicException("Only one next-control per view...", 1);
157  }
158  $label = $this->lng->txt('lso_player_next');
159  $cmd = $this->url_builder->getHref($command, $parameter);
160  $btn = $this->ui_factory->button()->standard($label, $cmd);
161  if ($command === '') {
162  $btn = $btn->withUnavailableAction();
163  }
164  $this->next_control = $btn;
165  return $this;
166  }
Build controls for the view.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ previous()

LSControlBuilder::previous ( string  $command,
?int  $parameter = null 
)

A previous control allows the user to go back to the previous item in the object.

The $parameter can be used to pass additional information to View::updateGet if required, e.g. about a chapter in the content.

Exceptions

Implements ILIAS\KioskMode\ControlBuilder.

Definition at line 168 of file LSControlBuilder.php.

References ILIAS\Repository\lng().

Referenced by ilLSPlayer\buildDefaultControls().

169  {
170  if ($this->previous_control) {
171  throw new \LogicException("Only one previous-control per view...", 1);
172  }
173  $label = $this->lng->txt('lso_player_previous');
174  $cmd = $this->url_builder->getHref($command, $parameter);
175  $btn = $this->ui_factory->button()->standard($label, $cmd);
176  if ($command === '') {
177  $btn = $btn->withUnavailableAction();
178  }
179  $this->previous_control = $btn;
180  return $this;
181  }
Build controls for the view.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setListenerJS()

LSControlBuilder::setListenerJS ( string  $check_lp_url,
string  $on_lp_change_url 
)
protected

Definition at line 288 of file LSControlBuilder.php.

References done(), and if.

Referenced by start().

291  : void {
292  $this->additional_js =
293 <<<JS
294 function lso_checkLPOfObject()
295 {
296  if(! il.UICore.isPageVisible()) {
297  return;
298  }
299 
300  $.ajax({
301  url: "$check_lp_url",
302  }).done(function(data) {
303  if(window._lso_current_item_lp === -1) {
304  window._lso_current_item_lp = data;
305  }
306  if (window._lso_current_item_lp !== data) {
307  location.replace('$on_lp_change_url');
308  }
309  });
310 }
311 JS;
312  }
if(!file_exists('../ilias.ini.php'))
done(string $command, ?int $parameter=null)
A done control allows the user to mark the object as done.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ start()

LSControlBuilder::start ( string  $label,
string  $url,
int  $obj_id 
)

Add a "start"-button as primary.

This is NOT regular behavior, but a special feature for the LegacyView of LearningSequence's sub-objects that do not implement a KioskModeView.

The start-control is exclusively used to open an ILIAS-Object in a new windwow/tab.

Definition at line 253 of file LSControlBuilder.php.

References $id, and setListenerJS().

254  {
255  if ($this->start) {
256  throw new \LogicException("Only one start-control per view...", 1);
257  }
258 
259  $this_cmd = $this->url_builder->getHref(self::CMD_START_OBJECT, 0);
260  $lp_cmd = $this->lp_url_builder->getHref(self::CMD_CHECK_CURRENT_ITEM_LP, $obj_id);
261 
262  $this->setListenerJS($lp_cmd, $this_cmd);
263  $this->start = $this->ui_factory->button()
264  ->primary($label, '')
265  ->withOnLoadCode(function ($id) use ($url) {
266  $interval = $this->global_settings->getPollingIntervalMilliseconds();
267  return "$('#$id').on('click', function(ev) {
268  var _lso_win = window.open('$url');
269  });
270  window._lso_current_item_lp = -1;
271  window.setInterval(lso_checkLPOfObject, $interval);
272  ";
273  });
274 
275  return $this;
276  }
$url
Definition: shib_logout.php:66
setListenerJS(string $check_lp_url, string $on_lp_change_url)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
start(string $label, string $url, int $obj_id)
Add a "start"-button as primary.
Build controls for the view.
+ Here is the call graph for this function:

◆ tableOfContent()

LSControlBuilder::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 object.

The command will be enhanced with a parameter defined here on in the locator builder.

If a parameter is defined here, the view provides an overview-page.

Exceptions

Implements ILIAS\KioskMode\ControlBuilder.

Definition at line 233 of file LSControlBuilder.php.

References $toc.

238  : TOCBuilder {
239  if ($this->toc) {
240  throw new \LogicException("Only one ToC per view...", 1);
241  }
242  $this->toc = new LSTOCBuilder($this, $command, $label, $parameter, $state);
243  return $this->toc;
244  }
Build a nested table of contents for the view.
Definition: TOCBuilder.php:28
Class LSTOCBuilder.

◆ toggle()

LSControlBuilder::toggle ( string  $label,
string  $on_command,
string  $off_command 
)

A toggle can be used to switch some behaviour in the view on or of.

Implements ILIAS\KioskMode\ControlBuilder.

Definition at line 209 of file LSControlBuilder.php.

210  {
211  throw new \Exception("NYI: Toggles", 1);
212  }
Build controls for the view.

Field Documentation

◆ $additional_js

string LSControlBuilder::$additional_js = null
protected

Definition at line 56 of file LSControlBuilder.php.

Referenced by getAdditionalJS().

◆ $controls

array LSControlBuilder::$controls = []
protected

Definition at line 37 of file LSControlBuilder.php.

Referenced by getControls().

◆ $done_control

Component LSControlBuilder::$done_control = null
protected

Definition at line 52 of file LSControlBuilder.php.

Referenced by getDoneControl().

◆ $exit_control

Component LSControlBuilder::$exit_control = null
protected

Definition at line 49 of file LSControlBuilder.php.

Referenced by getExitControl().

◆ $global_settings

LSGlobalSettings LSControlBuilder::$global_settings
protected

Definition at line 60 of file LSControlBuilder.php.

Referenced by __construct().

◆ $lng

ilLanguage LSControlBuilder::$lng
protected

Definition at line 59 of file LSControlBuilder.php.

◆ $loc

LocatorBuilder LSControlBuilder::$loc = null
protected

Definition at line 54 of file LSControlBuilder.php.

Referenced by getLocator(), and locator().

◆ $lp_url_builder

LSURLBuilder LSControlBuilder::$lp_url_builder
protected

Definition at line 61 of file LSControlBuilder.php.

Referenced by __construct().

◆ $mode_controls

array LSControlBuilder::$mode_controls = []
protected

Definition at line 47 of file LSControlBuilder.php.

Referenced by getModeControls().

◆ $next_control

Component LSControlBuilder::$next_control = null
protected

Definition at line 51 of file LSControlBuilder.php.

Referenced by getNextControl().

◆ $previous_control

Component LSControlBuilder::$previous_control = null
protected

Definition at line 50 of file LSControlBuilder.php.

Referenced by getPreviousControl().

◆ $start

JavaScriptBindable LSControlBuilder::$start = null
protected

Definition at line 55 of file LSControlBuilder.php.

Referenced by getStartControl().

◆ $toc

TOCBuilder LSControlBuilder::$toc = null
protected

Definition at line 53 of file LSControlBuilder.php.

Referenced by getToc(), and tableOfContent().

◆ $toggles

array LSControlBuilder::$toggles = []
protected

Definition at line 42 of file LSControlBuilder.php.

Referenced by getToggles().

◆ $ui_factory

Factory LSControlBuilder::$ui_factory
protected

Definition at line 57 of file LSControlBuilder.php.

Referenced by __construct().

◆ $url_builder

LSURLBuilder LSControlBuilder::$url_builder
protected

Definition at line 58 of file LSControlBuilder.php.

Referenced by __construct().

◆ CMD_CHECK_CURRENT_ITEM_LP

const LSControlBuilder::CMD_CHECK_CURRENT_ITEM_LP = 'ccilp'

◆ CMD_START_OBJECT

const LSControlBuilder::CMD_START_OBJECT = 'start_legacy_obj'

Definition at line 31 of file LSControlBuilder.php.


The documentation for this class was generated from the following file: