mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-03 11:55:52 +01:00
Use new Utils::getPagePathFromToken() method
This commit is contained in:
@@ -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)
|
* 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
|
* 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
|
* Filepicker field now renders thumbnail previews of the selected value on load
|
||||||
|
* Use new `Utils::getPagePathFromToken()` method
|
||||||
1. [](#bugfix)
|
1. [](#bugfix)
|
||||||
* Fix for undefined `include_metadata` error
|
* Fix for undefined `include_metadata` error
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ docs: https://github.com/getgrav/grav-plugin-admin/blob/develop/README.md
|
|||||||
license: MIT
|
license: MIT
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
- { name: grav, version: '>1.2.4' }
|
- { name: grav, version: '>1.3.0-rc.2' }
|
||||||
- { name: form, version: '>=2.4.0' }
|
- { name: form, version: '>=2.4.0' }
|
||||||
- { name: email, version: '~2.0' }
|
- { name: email, version: '~2.0' }
|
||||||
- { name: login, version: '~2.0' }
|
- { name: login, version: '~2.0' }
|
||||||
|
|||||||
@@ -1225,46 +1225,7 @@ class Admin
|
|||||||
|
|
||||||
public function getPagePathFromToken($path)
|
public function getPagePathFromToken($path)
|
||||||
{
|
{
|
||||||
$path_parts = pathinfo($path);
|
return Utils::getPagePathFromToken($path, $this->page(true));
|
||||||
$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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user