diff --git a/classes/admincontroller.php b/classes/admincontroller.php index 29cfa4e6..cbadc5b6 100644 --- a/classes/admincontroller.php +++ b/classes/admincontroller.php @@ -1333,6 +1333,40 @@ class AdminController extends AdminBaseController return true; } + protected function taskGetChildTypes() + { + if (!$this->authorizeTask('get childtypes', ['admin.pages', 'admin.super'])) { + return; + } + + $data = $this->post; + + $rawroute = !empty($data['rawroute']) ? $data['rawroute'] : null; + + if ($rawroute) { + $page = $this->grav['pages']->dispatch($rawroute); + + if ($page) { + $child_type = $page->childType(); + + if (isset($child_type)) { + $this->admin->json_response = [ + 'status' => 'success', + 'child_type' => $child_type + ]; + return true; + } + } + } + + $this->admin->json_response = [ + 'status' => 'error', + 'message' => $this->admin->translate('PLUGIN_ADMIN.NO_CHILD_TYPE') + ]; + + return true; + } + /** * Handles filtering the page by modular/visible/routable in the pages list. */ diff --git a/languages/en.yaml b/languages/en.yaml index 89328e17..50e622cb 100644 --- a/languages/en.yaml +++ b/languages/en.yaml @@ -654,4 +654,5 @@ PLUGIN_ADMIN: CANNOT_OVERWRITE_SYMLINKS: "Cannot overwrite symlinks" ZIP_PACKAGE_NOT_FOUND: "ZIP package could not be found" GPM_OFFICIAL_ONLY: "Official GPM Only" - GPM_OFFICIAL_ONLY_HELP: "Only allow direct installs from the official GPM repository only." \ No newline at end of file + GPM_OFFICIAL_ONLY_HELP: "Only allow direct installs from the official GPM repository only." + NO_CHILD_TYPE: "No child type for this rawroute" \ No newline at end of file