mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2026-05-07 18:15:56 +02:00
Fix issue when adding folders to subfolders. Also fix when ordering is < 10, and fix when there's no other folder
This commit is contained in:
@@ -1066,8 +1066,14 @@ class AdminController
|
||||
}
|
||||
|
||||
$data = $this->post;
|
||||
$pages_dir = $this->grav['locator']->findResource('page://');
|
||||
$files = Folder::all($pages_dir . $data['route'], ['recursive' => false]);
|
||||
|
||||
if ($data['route'] == '/') {
|
||||
$path = $this->grav['locator']->findResource('page://');
|
||||
} else {
|
||||
$path = $page = $this->grav['page']->find($data['route'])->path();
|
||||
}
|
||||
|
||||
$files = Folder::all($path, ['recursive' => false]);
|
||||
|
||||
$highestOrder = 0;
|
||||
foreach ($files as $file) {
|
||||
@@ -1075,6 +1081,8 @@ class AdminController
|
||||
|
||||
if (isset($order[0])) {
|
||||
$theOrder = intval(trim($order[0], '.'));
|
||||
} else {
|
||||
$theOrder = 0;
|
||||
}
|
||||
|
||||
if ($theOrder >= $highestOrder) {
|
||||
@@ -1084,7 +1092,11 @@ class AdminController
|
||||
|
||||
$orderOfNewFolder = $highestOrder + 1;
|
||||
|
||||
Folder::mkdir($pages_dir . $data['route'] . '/' . $orderOfNewFolder . '.' . $data['folder']);
|
||||
if ($orderOfNewFolder < 10) {
|
||||
$orderOfNewFolder = '0' . $orderOfNewFolder;
|
||||
}
|
||||
|
||||
Folder::mkdir($path . '/' . $orderOfNewFolder . '.' . $data['folder']);
|
||||
|
||||
$this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.SUCCESSFULLY_SAVED'), 'info');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user