Skip to content

Commit

Permalink
Bug Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
taufik-nurrohman committed Feb 6, 2021
1 parent ea8b1dd commit 9b8252f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 23 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion panel/about.page
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 21 additions & 1 deletion panel/engine/r/asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 .= '<svg xmlns="http://www.w3.org/2000/svg" display="none">';
foreach ($SVG as $k => $v) {
$icons .= '<symbol id="i:' . $k . '" viewBox="0 0 24 24">';
$icons .= 0 === strpos($v, '<') ? $v : '<path d="' . $v . '"></path>';
$icons .= '</symbol>';
}
$icons .= '</svg>';
}
// Put icon(s) before content. Why? Because HTML5!
$GLOBALS['panel'] = $icons . $content;
if (isset($_['f'])) {
$_['f'] = To::URL($_['f']);
}
Expand All @@ -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);
20 changes: 1 addition & 19 deletions panel/engine/r/layout/200.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,6 @@
<link href="<?= $url; ?>/favicon.ico" rel="icon">
</head>
<body spellcheck="false">
<?php

$svg = "";
$panel = _\lot\x\panel\type\lot(['lot' => $_['lot']], 0); // Load layout first, to queue the icon data

// Build icon(s)
if (!empty($GLOBALS['SVG'])) {
$svg .= '<svg xmlns="http://www.w3.org/2000/svg" display="none">';
foreach ($GLOBALS['SVG'] as $k => $v) {
$svg .= '<symbol id="i:' . $k . '" viewBox="0 0 24 24">';
$svg .= 0 === strpos($v, '<') ? $v : '<path d="' . $v . '"></path>';
$svg .= '</symbol>';
}
$svg .= '</svg>';
}

echo $svg . $panel; // Put icon(s) before layout. Why? Because HTML5!

?>
<?= $panel; ?>
</body>
</html>
2 changes: 0 additions & 2 deletions panel/engine/r/route.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9b8252f

Please sign in to comment.