diff --git a/CHANGELOG.md b/CHANGELOG.md index ec3dc997..cb352536 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * Remove save button and save location notification on Config Info tab [#1116](https://github.com/getgrav/grav-plugin-admin/pull/1116) * Allow taxonomy field to just list one or more specific taxonomies if the `taxonomies` field is filled in the blueprint * Filepicker field now renders thumbnail previews of the selected value on load + * Use new `Utils::getPagePathFromToken()` method 1. [](#bugfix) * Fix for undefined `include_metadata` error diff --git a/blueprints.yaml b/blueprints.yaml index 5fadb0ca..aed822f4 100644 --- a/blueprints.yaml +++ b/blueprints.yaml @@ -13,7 +13,7 @@ docs: https://github.com/getgrav/grav-plugin-admin/blob/develop/README.md license: MIT dependencies: - - { name: grav, version: '>1.2.4' } + - { name: grav, version: '>1.3.0-rc.2' } - { name: form, version: '>=2.4.0' } - { name: email, version: '~2.0' } - { name: login, version: '~2.0' } diff --git a/classes/admin.php b/classes/admin.php index 4e550e0e..fb1a4dc3 100644 --- a/classes/admin.php +++ b/classes/admin.php @@ -1225,46 +1225,7 @@ class Admin public function getPagePathFromToken($path) { - $path_parts = pathinfo($path); - $page = null; - - $basename = ''; - if (isset($path_parts['extension'])) { - $basename = '/' . $path_parts['basename']; - $path = $path_parts['dirname']; - } - - $regex = '/(@self|self@)|((?:@page|page@):(?:.*))|((?:@theme|theme@):(?:.*))/'; - preg_match($regex, $path, $matches); - - if ($matches) { - if ($matches[1]) { - // self@ - $page = $this->page(true); - } elseif ($matches[2]) { - // page@ - $parts = explode(':', $path); - $route = $parts[1]; - $page = $this->grav['page']->find($route); - } elseif ($matches[3]) { - // theme@ - $parts = explode(':', $path); - $route = $parts[1]; - $theme = str_replace(ROOT_DIR, '', $this->grav['locator']->findResource("theme://")); - - return $theme . $route . $basename; - } - } else { - return $path . $basename; - } - - if (!$page) { - throw new \RuntimeException('Page route not found: ' . $path); - } - - $path = str_replace($matches[0], rtrim($page->relativePagePath(), '/'), $path); - - return $path . $basename; + return Utils::getPagePathFromToken($path, $this->page(true)); } /**