3declare(strict_types=1);
99 $this->lng = $language;
153 if ($this->exit_control) {
154 throw new \LogicException(
"Only one exit-control per view...", 1);
156 $cmd = $this->url_builder->getHref($command);
158 $label =
'lso_player_suspend';
160 $label =
'lso_player_finish';
163 $exit_button = $this->ui_factory->button()->bulky(
164 $this->ui_factory->symbol()->glyph()->close(),
165 $this->lng->txt($label),
169 $this->exit_control = $exit_button;
178 if ($this->next_control) {
179 throw new \LogicException(
"Only one next-control per view...", 1);
181 $label = $this->lng->txt(
'lso_player_next');
182 $cmd = $this->url_builder->getHref($command, $parameter);
183 $btn = $this->ui_factory->button()->standard($label, $cmd);
184 if ($command ===
'') {
185 $btn = $btn->withUnavailableAction();
187 $this->next_control = $btn;
196 if ($this->previous_control) {
197 throw new \LogicException(
"Only one previous-control per view...", 1);
199 $label = $this->lng->txt(
'lso_player_previous');
200 $cmd = $this->url_builder->getHref($command, $parameter);
201 $btn = $this->ui_factory->button()->standard($label, $cmd);
202 if ($command ===
'') {
203 $btn = $btn->withUnavailableAction();
205 $this->previous_control = $btn;
214 if ($this->done_control) {
215 throw new \LogicException(
"Only one done-control per view...", 1);
217 $label = $this->lng->txt(
'lso_player_done');
218 $cmd = $this->url_builder->getHref($command, $parameter);
219 $btn = $this->ui_factory->button()->primary($label, $cmd);
220 $this->done_control = $btn;
227 public function generic(
string $label,
string $command,
int $parameter =
null) :
ControlBuilder
229 $cmd = $this->url_builder->getHref($command, $parameter);
230 $this->controls[] = $this->ui_factory->button()->standard($label, $cmd);
236 $this->controls[] = $this->ui_factory->button()->standard($label,
'')
237 ->withOnClick($signal);
246 throw new \Exception(
"NYI: Toggles", 1);
248 $cmd_on = $this->url_builder->getHref($on_command, 0);
249 $cmd_off = $this->url_builder->getHref($off_command, 0);
260 foreach ($labels as $parameter => $label) {
261 $actions[$label] = $this->url_builder->getHref($command, $parameter);
263 $this->mode_controls[] = $this->ui_factory->viewControl()->
mode($actions,
'');
273 throw new \LogicException(
"Only one locator per view...", 1);
285 int $parameter =
null,
289 throw new \LogicException(
"Only one ToC per view...", 1);
291 $this->toc =
new LSTOCBuilder($this, $command, $label, $parameter, $state);
305 throw new \LogicException(
"Only one start-control per view...", 1);
307 $this_cmd = $this->url_builder->getHref(self::CMD_START_OBJECT, $parameter);
308 $lp_cmd = str_replace(
310 '&cmd=' . self::CMD_CHECK_CURRENT_ITEM_LP .
'&',
314 $this->setListenerJS($lp_cmd, $this_cmd);
315 $this->start = $this->ui_factory->button()
316 ->primary($label,
'')
317 ->withOnLoadCode(
function ($id) use (
$url) {
318 $interval = $this->global_settings->getPollingIntervalMilliseconds();
319 return "$('#{$id}').on('click', function(ev) {
320 var il_ls_win = window.open('$url');
321 window._lso_current_item_lp = -1;
322 window.setInterval(lso_checkLPOfObject, $interval);
336 return $this->additional_js;
340 string $check_lp_url,
341 string $on_lp_change_url
343 $this->additional_js =
345function lso_checkLPOfObject()
347 if(! il.UICore.isPageVisible()) {
352 url:
"$check_lp_url",
353 }).done(
function(data) {
354 if(window._lso_current_item_lp === -1) {
355 window._lso_current_item_lp = data;
357 if (window._lso_current_item_lp !== data) {
358 location.replace(
'$on_lp_change_url');
An exception for terminatinating execution or to throw for unit testing.
__construct(Factory $ui_factory, LSURLBuilder $url_builder, ilLanguage $language, LSGlobalSettings $global_settings)
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...
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 addition...
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 b...
exit(string $command)
An exit control allows the user to gracefully leave the object providing the kiosk mode....
const CMD_CHECK_CURRENT_ITEM_LP
mode(string $command, array $labels)
A mode control can be used to switch between different modes in the view.Uses the indizes of the labe...
locator(string $command)
A locator allows the user to see the path leading to her current location and jump back to previous i...
start(string $label, string $url, int $parameter=null)
Add a "start"-button as primary.
setListenerJS(string $check_lp_url, string $on_lp_change_url)
genericWithSignal(string $label, Signal $signal)
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 ...
toggle(string $label, string $on_command, string $off_command)
A toggle can be used to switch some behaviour in the view on or of.
Global Settings of the Learning Sequence.
if(!file_exists(getcwd() . '/ilias.ini.php'))
registration confirmation script for ilias
Build controls for the view.
mode(string $command, array $labels)
A mode control can be used to switch between different modes in the view.
Build a locator for the view.
Build a nested table of contents for the view.
The URLBuilder allows views to get links that are used somewhere inline in the content.
This is how the factory for UI elements looks.