Use new Utils::getPagePathFromToken() method

This commit is contained in:
Andy Miller
2017-05-20 22:21:34 -06:00
parent c237bff1e3
commit 3e92bbed73
3 changed files with 3 additions and 41 deletions

View File

@@ -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));
}
/**