diff --git a/code/Controllers/ContentController.php b/code/Controllers/ContentController.php index 3989609d..60e94abe 100644 --- a/code/Controllers/ContentController.php +++ b/code/Controllers/ContentController.php @@ -62,6 +62,10 @@ class ContentController extends Controller 'LoginForm', ]; + private static $casting = [ + 'SilverStripeNavigator' => 'HTMLFragment', + ]; + /** * The ContentController will take the URLSegment parameter from the URL and use that to look * up a SiteTree record. @@ -137,7 +141,7 @@ class ContentController extends Controller // If we've accessed the homepage as /home/, then we should redirect to /. if ($this->dataRecord instanceof SiteTree && RootURLController::should_be_on_root($this->dataRecord) - && (!isset($this->urlParams['Action']) || !$this->urlParams['Action'] ) + && (!isset($this->urlParams['Action']) || !$this->urlParams['Action']) && !$_POST && !$_FILES && !$this->redirectedTo() ) { $getVars = $_GET; @@ -180,7 +184,7 @@ class ContentController extends Controller public function handleRequest(HTTPRequest $request) { /** @var SiteTree $child */ - $child = null; + $child = null; $action = $request->param('Action'); // If nested URLs are enabled, and there is no action handler for the current request then attempt to pass @@ -192,10 +196,10 @@ class ContentController extends Controller Translatable::disable_locale_filter(); } // look for a page with this URLSegment - $child = SiteTree::get()->filter(array( + $child = SiteTree::get()->filter([ 'ParentID' => $this->ID, - 'URLSegment' => rawurlencode($action) - ))->first(); + 'URLSegment' => rawurlencode($action), + ])->first(); if (class_exists('Translatable')) { Translatable::enable_locale_filter(); } @@ -273,13 +277,13 @@ class ContentController extends Controller public function getMenu($level = 1) { if ($level == 1) { - $result = SiteTree::get()->filter(array( + $result = SiteTree::get()->filter([ "ShowInMenus" => 1, - "ParentID" => 0 - )); + "ParentID" => 0, + ]); } else { $parent = $this->data(); - $stack = array($parent); + $stack = [$parent]; if ($parent) { while (($parent = $parent->Parent()) && $parent->exists()) { @@ -287,12 +291,12 @@ class ContentController extends Controller } } - if (isset($stack[$level-2])) { - $result = $stack[$level-2]->Children(); + if (isset($stack[$level - 2])) { + $result = $stack[$level - 2]->Children(); } } - $visible = array(); + $visible = []; // Remove all entries the can not be viewed by the current user // We might need to create a show in menu permission @@ -345,18 +349,18 @@ class ContentController extends Controller if ($member) { $firstname = Convert::raw2xml($member->FirstName); $surname = Convert::raw2xml($member->Surname); - $logInMessage = _t(__CLASS__ . '.LOGGEDINAS', 'Logged in as') ." {$firstname} {$surname} - ". _t(__CLASS__ . '.LOGOUT', 'Log out'). ""; + $logInMessage = _t(__CLASS__ . '.LOGGEDINAS', 'Logged in as') . " {$firstname} {$surname} - " . _t(__CLASS__ . '.LOGOUT', 'Log out') . ""; } else { $logInMessage = sprintf( '%s - %s', _t(__CLASS__ . '.NOTLOGGEDIN', 'Not logged in'), Security::config()->login_url, - _t(__CLASS__ . '.LOGIN', 'Login') ."" + _t(__CLASS__ . '.LOGIN', 'Login') . "" ); } $viewPageIn = _t(__CLASS__ . '.VIEWPAGEIN', 'View Page in:'); - $navigator = <<