From 9b8252f77ca4096061344d97e75f123b94a90f7b Mon Sep 17 00:00:00 2001 From: Taufik Nurrohman Date: Sun, 7 Feb 2021 02:25:47 +0700 Subject: [PATCH] Bug Fix --- README.md | 4 ++++ panel/about.page | 2 +- panel/engine/r/asset.php | 22 +++++++++++++++++++++- panel/engine/r/layout/200.php | 20 +------------------- panel/engine/r/route.php | 2 -- 5 files changed, 27 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index ac4e3fd2..760d6bc2 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,10 @@ GUI Extension for Mecha Release Notes ------------- +### 2.5.1 + + - Bug fixes. + ### 2.5.0 - Added `$_['asset']` property to easily load/unload assets in the control panel (#18) diff --git a/panel/about.page b/panel/about.page index d57c819c..594f54ca 100644 --- a/panel/about.page +++ b/panel/about.page @@ -3,7 +3,7 @@ title: Panel description: GUI extension for Mecha. author: Taufik Nurrohman type: Markdown -version: 2.5.0 +version: 2.5.1 use: '.\lot\x\layout': 1 diff --git a/panel/engine/r/asset.php b/panel/engine/r/asset.php index 9e91fe8f..e19a158f 100644 --- a/panel/engine/r/asset.php +++ b/panel/engine/r/asset.php @@ -47,7 +47,26 @@ }, 20); Hook::set('layout', function() { - extract($GLOBALS); + // Load content first to queue the icon data + if (isset($GLOBALS['_']['content'])) { + $content = _\lot\x\panel\type\lot(['content' => $GLOBALS['_']['content'] ?? []], 0); + } else if (isset($GLOBALS['_']['lot'])) { + $content = _\lot\x\panel\type\lot(['lot' => $GLOBALS['_']['lot'] ?? []], 0); + } + extract($GLOBALS, EXTR_SKIP); + // Build icon(s) + $icons = ""; + if (!empty($SVG)) { + $icons .= ''; + foreach ($SVG as $k => $v) { + $icons .= ''; + $icons .= 0 === strpos($v, '<') ? $v : ''; + $icons .= ''; + } + $icons .= ''; + } + // Put icon(s) before content. Why? Because HTML5! + $GLOBALS['panel'] = $icons . $content; if (isset($_['f'])) { $_['f'] = To::URL($_['f']); } @@ -57,4 +76,5 @@ // Remove sensitive data unset($_['asset'], $_['lot'], $_['user']); Asset::script('window._=Object.assign(window._||{},' . json_encode($_) . ');', 0); + _\lot\x\panel\_set_asset(); }, 20); diff --git a/panel/engine/r/layout/200.php b/panel/engine/r/layout/200.php index 58fc8af4..be8073ce 100644 --- a/panel/engine/r/layout/200.php +++ b/panel/engine/r/layout/200.php @@ -8,24 +8,6 @@ - $_['lot']], 0); // Load layout first, to queue the icon data - -// Build icon(s) -if (!empty($GLOBALS['SVG'])) { - $svg .= ''; - foreach ($GLOBALS['SVG'] as $k => $v) { - $svg .= ''; - $svg .= 0 === strpos($v, '<') ? $v : ''; - $svg .= ''; - } - $svg .= ''; -} - -echo $svg . $panel; // Put icon(s) before layout. Why? Because HTML5! - - ?> + diff --git a/panel/engine/r/route.php b/panel/engine/r/route.php index 294583d2..c9901c24 100644 --- a/panel/engine/r/route.php +++ b/panel/engine/r/route.php @@ -25,13 +25,11 @@ function route() { if ('get' === $_['form']['type']) { if (!$route && !empty($_['is']['error'])) { $_ = \_\lot\x\panel\_set(); - $_ = \_\lot\x\panel\_set_asset(); $_ = \_\lot\x\panel\_set_state(); $this->layout($_['layout'] ?? $_['is']['error'] . '/panel'); } } $_ = \_\lot\x\panel\_set(); - $_ = \_\lot\x\panel\_set_asset(); $_ = \_\lot\x\panel\_set_state(); if (!isset($_['type'])) { // Auto-detect layout type