Skip to content

Commit

Permalink
ModeInfo/UI Demo: fix example for modeinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
nhaagen committed Jul 13, 2023
1 parent c5fe95c commit 36f2c39
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 46 deletions.
3 changes: 0 additions & 3 deletions src/UI/Implementation/Component/Layout/Page/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,6 @@ protected function setHeaderVars(Template $tpl, bool $for_ui_demo = false): Temp
}

if ($for_ui_demo) {
$base_url = '../../../../../../';
$tpl->setVariable("BASE", $base_url);

$additional_js_files = [
iljQueryUtil::getLocaljQueryPath(),
'./Services/JavaScript/js/Basic.js',
Expand Down
87 changes: 44 additions & 43 deletions src/UI/examples/MainControls/ModeInfo/modeinfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,62 +11,40 @@ function modeinfo(): string
global $DIC;
$f = $DIC->ui()->factory();
$renderer = $DIC->ui()->renderer();
$request_wrapper = $DIC->http()->wrapper()->query();

$icon = $f->symbol()->icon()->standard('root', '')->withSize('large');
$target = new \ILIAS\Data\URI(
$DIC->http()->request()->getUri()->__toString() . '&new_mode_info=' . MODE_INFO_ACTIVE
);
return $renderer->render([
$f->link()->standard(
'See UI in fullscreen-mode',
'src/UI/examples/MainControls/ModeInfo/modeinfo.php?new_mode_info='.MODE_INFO_INACTIVE
)
$f->divider()->horizontal(),
$f->link()->bulky($icon, 'See UI in fullscreen-mode', $target),
$f->legacy('<p><b>press the link above to init a page with Mode Info</b></p><p><br/></p>'),
$f->divider()->horizontal()
]);
}

global $DIC;
const MODE_INFO_ACTIVE = 2;
const MODE_INFO_INACTIVE = 1;

//Render Mode Info example in Fullscreen mode
if (basename($_SERVER["SCRIPT_FILENAME"]) == "modeinfo.php") {
chdir('../../../../../');
require_once("libs/composer/vendor/autoload.php");
\ilInitialisation::initILIAS();
$refinery = $DIC->refinery();
$request_wrapper = $DIC->http()->wrapper()->query();
}


if (isset($request_wrapper) && isset($refinery) && $request_wrapper->has('new_mode_info')) {
echo renderModeInfoPage($DIC, $request_wrapper->retrieve('new_mode_info', $refinery->kindlyTo()->int()));
}

function renderModeInfoPage(Container $dic, int $mode): string
{
if ((int)@$_GET['new_mode_info'] === MODE_INFO_ACTIVE) {
\ilInitialisation::initILIAS();
$dic = $DIC;
$f = $dic->ui()->factory();
$data_factory = new \ILIAS\Data\Factory();
$renderer = $dic->ui()->renderer();

if ($mode == MODE_INFO_INACTIVE) {
$url = 'src/UI/examples/MainControls/ModeInfo/modeinfo.php?new_mode_info='.MODE_INFO_ACTIVE;
$label = "Activate Mode Info";
$panel_content = $f->button()->standard($label, $url);
$slate = $f->mainControls()->slate()->legacy(
"Mode Info Inactive",
$f->symbol()->glyph()->settings(),
$f->legacy("Just regular Mainbar stuff")
);
} else {
$components[] = $f->mainControls()->modeInfo(
"Active Mode Info",
$data_factory->uri($dic->http()->request()->getUri()->withQuery('new_mode_info='.MODE_INFO_INACTIVE)->__toString())
);
$panel_content = $f->legacy("Mode Info is Active");
$slate = $f->mainControls()->slate()->legacy(
"Mode Info Active",
$f->symbol()->glyph()->notification(),
$f->legacy("Things todo when special Mode is active")
);
}
$panel_content = $f->legacy("Mode Info is Active");
$slate = $f->mainControls()->slate()->legacy(
"Mode Info Active",
$f->symbol()->glyph()->notification(),
$f->legacy("Things todo when special Mode is active")
);

$components[] = $f->layout()->page()->standard(
$page = $f->layout()->page()->standard(
[$f->panel()->standard(
'Mode Info Example',
$panel_content
Expand All @@ -85,7 +63,30 @@ function renderModeInfoPage(Container $dic, int $mode): string
'UI PAGE MODE INFO DEMO', //page title
'ILIAS', //short title
'Mode Info Demo' //view title
)->withUIDemo(true);
)
->withHeaders(true)
->withUIDemo(true);


/**
* a Mode Info needs to know what happens when you exit the mode
*/
$back = str_replace(
'new_mode_info=' . MODE_INFO_ACTIVE,
'new_mode_info=' . MODE_INFO_INACTIVE,
$dic->http()->request()->getUri()->getQuery()
);

$mode_info = $f->mainControls()->modeInfo(
"Active Mode Info",
$data_factory->uri($dic->http()->request()->getUri()->withQuery($back)->__toString())
);

/**
* the Mode Info is attached to the page
*/
$page = $page->withModeInfo($mode_info);

return $renderer->render($components);
echo $renderer->render($page);
exit();
}

0 comments on commit 36f2c39

Please sign in to comment.