diff --git a/code/admin/SubsiteAdmin.php b/code/admin/SubsiteAdmin.php index 77b8841e..e921031f 100644 --- a/code/admin/SubsiteAdmin.php +++ b/code/admin/SubsiteAdmin.php @@ -15,14 +15,13 @@ */ class SubsiteAdmin extends ModelAdmin { - private static $managed_models = [Subsite::class]; private static $url_segment = 'subsites'; private static $menu_title = 'Subsites'; - private static $menu_icon = 'subsites/images/subsites.png'; + private static $menu_icon_class = 'font-icon-tree'; public $showImportForm = false; @@ -40,5 +39,4 @@ public function getEditForm($id = null, $fields = null) return $form; } - } diff --git a/code/extensions/LeftAndMainSubsites.php b/code/extensions/LeftAndMainSubsites.php index 51887bf5..78d315d1 100644 --- a/code/extensions/LeftAndMainSubsites.php +++ b/code/extensions/LeftAndMainSubsites.php @@ -257,13 +257,15 @@ public function onBeforeInit() // We are accessing the CMS, so we need to let Subsites know we will be using the session. Subsite::$use_session_subsiteid = true; + $session = Controller::curr()->getRequest()->getSession(); + // FIRST, check if we need to change subsites due to the URL. // Catch forced subsite changes that need to cause CMS reloads. if (isset($_GET['SubsiteID'])) { // Clear current page when subsite changes (or is set for the first time) - if (!Session::get('SubsiteID') || $_GET['SubsiteID'] != Session::get('SubsiteID')) { - Session::clear("{$this->owner->class}.currentPage"); + if (!$session->get('SubsiteID') || $_GET['SubsiteID'] != $session->get('SubsiteID')) { + $session->clear("{$this->owner->class}.currentPage"); } // Update current subsite in session diff --git a/code/model/Subsite.php b/code/model/Subsite.php index 18c3f7c1..63fcc2b5 100644 --- a/code/model/Subsite.php +++ b/code/model/Subsite.php @@ -4,6 +4,7 @@ use SilverStripe\Admin\CMSMenu; use SilverStripe\CMS\Model\SiteTree; +use SilverStripe\Control\Controller; use SilverStripe\Control\Director; use SilverStripe\Control\Session; use SilverStripe\Core\Convert; @@ -154,7 +155,7 @@ public static function currentSubsiteID() if (isset($_GET['SubsiteID'])) { $id = (int)$_GET['SubsiteID']; } elseif (Subsite::$use_session_subsiteid) { - $id = Session::get('SubsiteID'); + $id = Controller::curr()->getRequest()->getSession()->get('SubsiteID'); } if ($id === null) { @@ -184,7 +185,7 @@ public static function changeSubsite($subsite) $subsiteID = $subsite; } - Session::set('SubsiteID', (int)$subsiteID); + Controller::curr()->getRequest()->getSession()->set('SubsiteID', (int)$subsiteID); // Set locale if (is_object($subsite) && $subsite->Language !== '') { @@ -677,7 +678,7 @@ public function getCMSFields() new Tab( 'Configuration', _t('Subsite.TabTitleConfig', 'Configuration'), - new HeaderField('ConfigForSubsiteHeaderField', $this->getClassName() . ' configuration'), + new HeaderField('ConfigForSubsiteHeaderField', 'Subsite Configuration'), new TextField('Title', $this->fieldLabel('Title'), $this->Title), new HeaderField( @@ -783,7 +784,7 @@ public function validate() { $result = parent::validate(); if (!$this->Title) { - $result->error(_t('Subsite.ValidateTitle', 'Please add a "Title"')); + $result->addError(_t('Subsite.ValidateTitle', 'Please add a "Title"')); } return $result; } @@ -855,14 +856,6 @@ public function absoluteBaseURL() return Director::absoluteBaseURL(); } - /** - * @todo getClassName is redundant, already stored as a database field? - */ - public function getClassName() - { - return $this->class; - } - /** * Javascript admin action to duplicate this subsite * diff --git a/templates/SilverStripe/Admin/LeftAndMain_Menu.ss b/templates/SilverStripe/Admin/LeftAndMain_Menu.ss index d6f32668..86ad94ed 100644 --- a/templates/SilverStripe/Admin/LeftAndMain_Menu.ss +++ b/templates/SilverStripe/Admin/LeftAndMain_Menu.ss @@ -1,5 +1,7 @@ -
-
+
+ + + +