diff --git a/code/site/components/com_pages/dispatcher/router/file.php b/code/site/components/com_pages/dispatcher/router/file.php index c71e767d3..e254905f4 100644 --- a/code/site/components/com_pages/dispatcher/router/file.php +++ b/code/site/components/com_pages/dispatcher/router/file.php @@ -12,6 +12,7 @@ class ComPagesDispatcherRouterFile extends ComPagesDispatcherRouterAbstract protected function _initialize(KObjectConfig $config) { $config->append([ + 'route' => 'file', 'routes' => [] ])->append([ 'resolvers' => [ @@ -25,15 +26,15 @@ protected function _initialize(KObjectConfig $config) public function resolve($route = null, array $parameters = array()) { $result = false; - if(count($this->getConfig()->routes)) + if (count($this->getConfig()->routes)) { - if(!$route) + if (!$route) { - $base = $this->getRequest()->getBasePath(); - $url = urldecode( $this->getRequest()->getUrl()->getPath()); + $base = $this->getRequest()->getBasePath(); + $url = urldecode($this->getRequest()->getUrl()->getPath()); $parameters = $this->getRequest()->getUrl()->getQuery(true); - $route = trim(str_replace(array($base, '/index.php'), '', $url), '/'); + $route = trim(str_replace(array($base, '/index.php'), '', $url), '/'); } $result = parent::resolve($route, $parameters); @@ -42,17 +43,16 @@ public function resolve($route = null, array $parameters = array()) return $result; } - public function qualify(ComPagesDispatcherRouterRouteInterface $route, $replace = false) + public function qualify(ComPagesDispatcherRouterRouteInterface $route, $replace = false) { $url = clone $route; - $path = $url->getPath(); - if(!is_file($path)) + if(!$url->isAbsolute()) { - //Qualify the path - $path = trim($path, '/'); - $base = $this->getRequest()->getBasePath(true); - $url->setPath($base.'/'.$path); + $base = $this->getRequest()->getBasePath(true); + $path = trim($url->getPath(), '/'); + + $url->setPath($base . '/' . $path); } return $url; diff --git a/code/site/components/com_pages/dispatcher/router/route/file.php b/code/site/components/com_pages/dispatcher/router/route/file.php new file mode 100644 index 000000000..a7ecb8cf5 --- /dev/null +++ b/code/site/components/com_pages/dispatcher/router/route/file.php @@ -0,0 +1,22 @@ + + * @link https://github.com/joomlatools/joomlatools-pages for the canonical source repository + */ + +/** + * Router File Route + * + * @author Johan Janssens + * @package Koowa\Library\Dispatcher\Router\Route + */ +class ComPagesDispatcherRouterRouteFile extends ComPagesDispatcherRouterRouteAbstract +{ + public function isAbsolute() + { + return file_exists($this->getPath()); + } +} \ No newline at end of file