mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2026-02-21 05:57:56 +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)
|
||||
* 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
|
||||
|
||||
|
||||
@@ -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' }
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user