Skip to content

Commit

Permalink
Improvement for Layout Developer
Browse files Browse the repository at this point in the history
  • Loading branch information
taufik-nurrohman committed Jun 21, 2020
1 parent 223aaba commit dc2f0fc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ GUI Extension for Mecha
Release Notes
-------------

### master
### 2.4.0

- Removed `$lot` hook parameter and store the form data to `$_['form']` property, for easy form data manipulation during CRUD process.
- Fixed bug where creating a new page does not populate the `time` data automatically.
- Changed `#blob:{code}` language string into a more readable language string as the default language string for every blob response code.
- Updated [Tag Picker](https://github.com/taufik-nurrohman/tag-picker) to version 3.0.12.
- Moved `type` and `x` state data to a separated file, stored in `.\lot\x\panel\state` folder.
- Added ability to set custom panel definition through `.\lot\layout\index\panel.php` file.

### 2.3.2

Expand Down
6 changes: 6 additions & 0 deletions panel/engine/r/route.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,18 @@ function route() {
// Update data
$_ = $GLOBALS['_'];
}
// Load panel definition from a file stored in `.\lot\x\*\index\panel.php`
foreach ($GLOBALS['X'][1] as $v) {
\is_file($v = \Path::F($v) . \DS . 'panel.php') && (function($v) {
extract($GLOBALS, \EXTR_SKIP);
require $v;
})($v);
}
// Load panel definition from a file stored in `.\lot\layout\index\panel.php`
\is_file($v = \LOT . \DS . 'layout' . \DS . 'index' . \DS . 'panel.php') && (function($v) {
extract($GLOBALS, \EXTR_SKIP);
require $v;
})($v);
// Update data
$_ = $GLOBALS['_'];
// Define lot with no filter
Expand Down
16 changes: 8 additions & 8 deletions panel/engine/r/task/g.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ function page($_) {
unset($_['form']['page']['name'], $_['form']['page']['x']);
$page = [];
$p = (array) ($state->x->page->page ?? []);
// Remove array item(s) with `null` value
$nully = function($v) use(&$nully) {
// Remove array item(s) with empty value
$drop = function($v) use(&$drop) {
foreach ($v as $kk => $vv) {
if (\is_array($vv) && !empty($vv)) {
if ($vv = $nully($vv)) {
if ($vv = $drop($vv)) {
$v[$kk] = $vv;
} else {
unset($v[$kk]);
Expand All @@ -194,7 +194,7 @@ function page($_) {
continue;
}
if (\is_array($v)) {
if ($v = $nully(\array_replace_recursive($page[$k] ?? [], $v))) {
if ($v = $drop(\array_replace_recursive($page[$k] ?? [], $v))) {
$page[$k] = $v;
}
} else {
Expand Down Expand Up @@ -253,11 +253,11 @@ function state($_) {
'token' => false,
'trash' => false
]) . $url->hash;
// Remove array item(s) with `null` value
$nully = function($v) use(&$nully) {
// Remove array item(s) with empty value
$drop = function($v) use(&$drop) {
foreach ($v as $kk => $vv) {
if (\is_array($vv) && !empty($vv)) {
if ($vv = $nully($vv)) {
if ($vv = $drop($vv)) {
$v[$kk] = $vv;
} else {
unset($v[$kk]);
Expand All @@ -276,7 +276,7 @@ function state($_) {
if (\is_file($f = \LOT . \DS . \trim(\strtr($_['form']['path'] ?? $_['path'], '/', \DS), \DS))) {
$_['f'] = $f = \realpath($f);
$v = \array_replace_recursive((array) require $f, $_['form']['state'] ?? []);
$v = $nully($v);
$v = $drop($v);
$_['form']['file']['content'] = $_POST['file']['content'] = '<?php return ' . \z($v) . ';';
$_ = file($_); // Move to `file`
}
Expand Down
8 changes: 4 additions & 4 deletions panel/engine/r/task/s.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,11 @@ function page($_) {
unset($_['form']['page']['name'], $_['form']['page']['x']);
$page = [];
$p = (array) ($state->x->page->page ?? []);
// Remove array item(s) with `null` value
$nully = function($v) use(&$nully) {
// Remove array item(s) with empty value
$drop = function($v) use(&$drop) {
foreach ($v as $kk => $vv) {
if (\is_array($vv) && !empty($vv)) {
if ($vv = $nully($vv)) {
if ($vv = $drop($vv)) {
$v[$kk] = $vv;
} else {
unset($v[$kk]);
Expand All @@ -246,7 +246,7 @@ function page($_) {
continue;
}
if (\is_array($v)) {
if ($v = $nully(\array_replace_recursive($page[$k] ?? [], $v))) {
if ($v = $drop(\array_replace_recursive($page[$k] ?? [], $v))) {
$page[$k] = $v;
}
} else {
Expand Down

0 comments on commit dc2f0fc

Please sign in to comment.