From: Vincent Vanwaelscappel Date: Fri, 12 Jul 2019 18:32:09 +0000 (+0200) Subject: #2757 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=bbb4d1c72315e49e09c082a3fad20c93ae5e2d63;p=cubist_cms-back.git #2757 --- diff --git a/src/app/Http/Controllers/CubistPageController.php b/src/app/Http/Controllers/CubistPageController.php index 6d48186..9626756 100644 --- a/src/app/Http/Controllers/CubistPageController.php +++ b/src/app/Http/Controllers/CubistPageController.php @@ -4,6 +4,7 @@ namespace Cubist\Backpack\app\Http\Controllers; use Cubist\Backpack\app\Magic\Menu\Menu; use Cubist\Backpack\app\Magic\Models\CMSPage; +use Illuminate\Http\Request; use Illuminate\Support\Str; class CubistPageController extends CubistFrontController @@ -29,21 +30,31 @@ class CubistPageController extends CubistFrontController return view('pages.' . $page->getAttributeValue('template'), $this->data); } - public function catchall($main = '', $subs = '') + public function catchall(Request $request, $main = '', $subs = '') { - - $path = trim($main . '/' . $subs, '/'); - if (!$path) { - $path = 'home'; - } - $nav = Menu::getNavigation(); - $item = $nav->findItemWithURL($path); - if (null === $item) { - $this->_404(); + if ($main == 'ajax') { + $e = explode('/', trim($subs, '/')); + $c = ['controller' => 'AjaxController']; + $c['action'] = array_shift($e); + $c['params'] = ['request' => $request]; + if (count($e)) { + $c['params']['path'] = implode('/', $e); + } + } else { + + $path = trim($main . '/' . $subs, '/'); + if (!$path) { + $path = 'home'; + } + $nav = Menu::getNavigation(); + $item = $nav->findItemWithURL($path); + if (null === $item) { + $this->_404(); + } + + $c = $item->getController(); } - $c = $item->getController(); - return call_user_func_array([app('App\\Http\\Controllers\\' . $c['controller']), $c['action']], $c['params']); } }