mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-03 11:55:52 +01:00
finishing the visibility updates
This commit is contained in:
@@ -538,7 +538,7 @@ class Admin
|
|||||||
$header = ['title' => $data['title']];
|
$header = ['title' => $data['title']];
|
||||||
|
|
||||||
if (isset($data['visible'])) {
|
if (isset($data['visible'])) {
|
||||||
if ($data['visible'] == '') {
|
if ($data['visible'] == '' || $data['visible']) {
|
||||||
// if auto (ie '')
|
// if auto (ie '')
|
||||||
$children = $page->parent()->children();
|
$children = $page->parent()->children();
|
||||||
foreach ($children as $child) {
|
foreach ($children as $child) {
|
||||||
@@ -548,9 +548,6 @@ class Admin
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// else visible explicitly set
|
|
||||||
$header['visible'] = (bool) $data['visible'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -576,25 +573,6 @@ class Admin
|
|||||||
return $page;
|
return $page;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Guess the intended visibility status based on other sibling folders
|
|
||||||
*
|
|
||||||
* @param \Grav\Common\Page\Page $page
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function guessVisibility(Page $page)
|
|
||||||
{
|
|
||||||
$children = $page->parent()->children();
|
|
||||||
foreach ($children as $child) {
|
|
||||||
if ($child->order()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Static helper method to return current route.
|
* Static helper method to return current route.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -829,6 +829,8 @@ class AdminController
|
|||||||
$original_slug = $obj->slug();
|
$original_slug = $obj->slug();
|
||||||
$original_order = intval(trim($obj->order(), '.'));
|
$original_order = intval(trim($obj->order(), '.'));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Change parent if needed and initialize move (might be needed also on ordering/folder change).
|
// Change parent if needed and initialize move (might be needed also on ordering/folder change).
|
||||||
$obj = $obj->move($parent);
|
$obj = $obj->move($parent);
|
||||||
$this->preparePage($obj);
|
$this->preparePage($obj);
|
||||||
@@ -845,6 +847,16 @@ class AdminController
|
|||||||
$obj->order($original_order + 1);
|
$obj->order($original_order + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add or remove numeric prefix based on ordering value
|
||||||
|
if (isset($data['ordering'])) {
|
||||||
|
if ($data['ordering'] && !$obj->order()) {
|
||||||
|
$obj->order(1001);
|
||||||
|
} elseif (!$data['ordering'] && $obj->order()) {
|
||||||
|
$obj->folder($obj->slug());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Handle standard data types.
|
// Handle standard data types.
|
||||||
$obj = $this->prepareData();
|
$obj = $this->prepareData();
|
||||||
@@ -1134,11 +1146,18 @@ class AdminController
|
|||||||
{
|
{
|
||||||
$input = $this->post;
|
$input = $this->post;
|
||||||
|
|
||||||
|
if (isset($input['order'])) {
|
||||||
$order = max(0, (int) isset($input['order']) ? $input['order'] : $page->value('order'));
|
$order = max(0, (int) isset($input['order']) ? $input['order'] : $page->value('order'));
|
||||||
$ordering = $order ? sprintf('%02d.', $order) : '';
|
$ordering = $order ? sprintf('%02d.', $order) : '';
|
||||||
$slug = empty($input['folder']) ? $page->value('folder') : (string) $input['folder'];
|
$slug = empty($input['folder']) ? $page->value('folder') : (string) $input['folder'];
|
||||||
$page->folder($ordering . $slug);
|
$page->folder($ordering . $slug);
|
||||||
|
|
||||||
|
if (isset($input['header']['visible']) && $input['header']['visible'] == true) {
|
||||||
|
unset($input['header']['visible']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (isset($input['type']) && !empty($input['type'])) {
|
if (isset($input['type']) && !empty($input['type'])) {
|
||||||
$type = (string) strtolower($input['type']);
|
$type = (string) strtolower($input['type']);
|
||||||
@@ -1147,7 +1166,6 @@ class AdminController
|
|||||||
$page->template($type);
|
$page->template($type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Special case for Expert mode: build the raw, unset content
|
// Special case for Expert mode: build the raw, unset content
|
||||||
if (isset($input['frontmatter']) && isset($input['content'])) {
|
if (isset($input['frontmatter']) && isset($input['content'])) {
|
||||||
$page->raw("---\n" . (string) $input['frontmatter'] . "\n---\n" . (string) $input['content']);
|
$page->raw("---\n" . (string) $input['frontmatter'] . "\n---\n" . (string) $input['content']);
|
||||||
@@ -1166,7 +1184,7 @@ class AdminController
|
|||||||
}
|
}
|
||||||
} elseif ($key == 'taxonomy') {
|
} elseif ($key == 'taxonomy') {
|
||||||
foreach ($header[$key] as $taxkey => $taxonomy) {
|
foreach ($header[$key] as $taxkey => $taxonomy) {
|
||||||
if (is_array($taxonomy) && count($taxonomy) == 1 && $taxonomy[0] == '') {
|
if (is_array($taxonomy) && count($taxonomy) == 1 && trim($taxonomy[0]) == '') {
|
||||||
unset($header[$key][$taxkey]);
|
unset($header[$key][$taxkey]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user