mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-02 19:36:08 +01:00
Use new Utils::getPagePathFromToken() method
This commit is contained in:
@@ -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