From 36f2c396398c1f8c717849b2ca83f6ea365fafab Mon Sep 17 00:00:00 2001 From: Nils Haagen Date: Thu, 13 Jul 2023 13:10:37 +0200 Subject: [PATCH] ModeInfo/UI Demo: fix example for modeinfo --- .../Component/Layout/Page/Renderer.php | 3 - .../MainControls/ModeInfo/modeinfo.php | 87 ++++++++++--------- 2 files changed, 44 insertions(+), 46 deletions(-) diff --git a/src/UI/Implementation/Component/Layout/Page/Renderer.php b/src/UI/Implementation/Component/Layout/Page/Renderer.php index 7065c47cb57e..1e741e2be218 100644 --- a/src/UI/Implementation/Component/Layout/Page/Renderer.php +++ b/src/UI/Implementation/Component/Layout/Page/Renderer.php @@ -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', diff --git a/src/UI/examples/MainControls/ModeInfo/modeinfo.php b/src/UI/examples/MainControls/ModeInfo/modeinfo.php index 0e9f59aace2c..a3d69bd46555 100644 --- a/src/UI/examples/MainControls/ModeInfo/modeinfo.php +++ b/src/UI/examples/MainControls/ModeInfo/modeinfo.php @@ -11,12 +11,17 @@ 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('

press the link above to init a page with Mode Info


'), + $f->divider()->horizontal() ]); } @@ -24,49 +29,22 @@ function modeinfo(): string 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 @@ -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(); }