mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
Merge 4f727869ac
into 393940195d
This commit is contained in:
commit
411e5d3635
@ -51,10 +51,6 @@ SilverStripe\CMS\Controllers\CMSMain:
|
|||||||
- SilverStripe\Subsites\Extensions\HintsCacheKeyExtension
|
- SilverStripe\Subsites\Extensions\HintsCacheKeyExtension
|
||||||
- SilverStripe\Subsites\Extensions\SubsiteMenuExtension
|
- SilverStripe\Subsites\Extensions\SubsiteMenuExtension
|
||||||
|
|
||||||
SilverStripe\CMS\Controllers\CMSPagesController:
|
|
||||||
extensions:
|
|
||||||
- SilverStripe\Subsites\Extensions\SubsiteMenuExtension
|
|
||||||
|
|
||||||
SilverStripe\Subsites\Admin\SubsiteAdmin:
|
SilverStripe\Subsites\Admin\SubsiteAdmin:
|
||||||
extensions:
|
extensions:
|
||||||
- SilverStripe\Subsites\Extensions\SubsiteMenuExtension
|
- SilverStripe\Subsites\Extensions\SubsiteMenuExtension
|
||||||
|
@ -6,7 +6,7 @@ use SilverStripe\Admin\AdminRootController;
|
|||||||
use SilverStripe\Admin\CMSMenu;
|
use SilverStripe\Admin\CMSMenu;
|
||||||
use SilverStripe\Admin\CMSProfileController;
|
use SilverStripe\Admin\CMSProfileController;
|
||||||
use SilverStripe\Admin\LeftAndMain;
|
use SilverStripe\Admin\LeftAndMain;
|
||||||
use SilverStripe\CMS\Controllers\CMSPagesController;
|
use SilverStripe\CMS\Controllers\CMSMain;
|
||||||
use SilverStripe\CMS\Model\SiteTree;
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
use SilverStripe\CMS\Controllers\CMSPageEditController;
|
use SilverStripe\CMS\Controllers\CMSPageEditController;
|
||||||
use SilverStripe\Control\Controller;
|
use SilverStripe\Control\Controller;
|
||||||
@ -280,7 +280,7 @@ class LeftAndMainSubsites extends Extension
|
|||||||
// sessionNamespace() is protected - see for info
|
// sessionNamespace() is protected - see for info
|
||||||
$override = $this->owner->config()->get('session_namespace');
|
$override = $this->owner->config()->get('session_namespace');
|
||||||
$sessionNamespace = $override ? $override : get_class($this->owner);
|
$sessionNamespace = $override ? $override : get_class($this->owner);
|
||||||
$session->clear($sessionNamespace . '.currentPage');
|
$session->clear($sessionNamespace . '.currentRecord');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Context: Subsite ID has already been set to the state via InitStateMiddleware
|
// Context: Subsite ID has already been set to the state via InitStateMiddleware
|
||||||
@ -293,13 +293,13 @@ class LeftAndMainSubsites extends Extension
|
|||||||
$currentController = Controller::curr();
|
$currentController = Controller::curr();
|
||||||
if ($currentController instanceof CMSPageEditController) {
|
if ($currentController instanceof CMSPageEditController) {
|
||||||
/** @var SiteTree $page */
|
/** @var SiteTree $page */
|
||||||
$page = $currentController->currentPage();
|
$page = $currentController->currentRecord();
|
||||||
|
|
||||||
// If the page exists but doesn't belong to the requested subsite, redirect to admin/pages which
|
// If the page exists but doesn't belong to the requested subsite, redirect to admin/pages which
|
||||||
// will show a list of the requested subsite's pages
|
// will show a list of the requested subsite's pages
|
||||||
$currentSubsiteId = $request->getVar('SubsiteID');
|
$currentSubsiteId = $request->getVar('SubsiteID');
|
||||||
if ($page && (int) $page->SubsiteID !== (int) $currentSubsiteId) {
|
if ($page && (int) $page->SubsiteID !== (int) $currentSubsiteId) {
|
||||||
return $this->owner->redirect(CMSPagesController::singleton()->Link());
|
return $this->owner->redirect(CMSMain::singleton()->Link());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Page does belong to the current subsite, so remove the query string parameter and refresh the page
|
// Page does belong to the current subsite, so remove the query string parameter and refresh the page
|
||||||
@ -314,7 +314,7 @@ class LeftAndMainSubsites extends Extension
|
|||||||
|
|
||||||
// Automatically redirect the session to appropriate subsite when requesting a record.
|
// Automatically redirect the session to appropriate subsite when requesting a record.
|
||||||
// This is needed to properly initialise the session in situations where someone opens the CMS via a link.
|
// This is needed to properly initialise the session in situations where someone opens the CMS via a link.
|
||||||
$record = $this->owner->currentPage();
|
$record = $this->owner->currentRecord();
|
||||||
if ($record
|
if ($record
|
||||||
&& isset($record->SubsiteID, $this->owner->urlParams['ID'])
|
&& isset($record->SubsiteID, $this->owner->urlParams['ID'])
|
||||||
&& is_numeric($record->SubsiteID)
|
&& is_numeric($record->SubsiteID)
|
||||||
@ -379,7 +379,7 @@ class LeftAndMainSubsites extends Extension
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function augmentNewSiteTreeItem(&$item)
|
protected function updateNewItem(&$item)
|
||||||
{
|
{
|
||||||
$request = Controller::curr()->getRequest();
|
$request = Controller::curr()->getRequest();
|
||||||
$item->SubsiteID = $request->postVar('SubsiteID') ?: SubsiteState::singleton()->getSubsiteId();
|
$item->SubsiteID = $request->postVar('SubsiteID') ?: SubsiteState::singleton()->getSubsiteId();
|
||||||
|
@ -287,7 +287,7 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest
|
|||||||
|
|
||||||
Subsite::changeSubsite($s1);
|
Subsite::changeSubsite($s1);
|
||||||
$cmsmain = CMSMain::create();
|
$cmsmain = CMSMain::create();
|
||||||
$hints = json_decode($cmsmain->SiteTreeHints() ?? '', true);
|
$hints = json_decode($cmsmain->TreeHints() ?? '', true);
|
||||||
$classes = $hints['Root']['disallowedChildren'];
|
$classes = $hints['Root']['disallowedChildren'];
|
||||||
$this->assertContains(ErrorPage::class, $classes);
|
$this->assertContains(ErrorPage::class, $classes);
|
||||||
$this->assertContains(TestClassA::class, $classes);
|
$this->assertContains(TestClassA::class, $classes);
|
||||||
@ -298,7 +298,7 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest
|
|||||||
if ($cmsmain->hasMethod('getHintsCache')) {
|
if ($cmsmain->hasMethod('getHintsCache')) {
|
||||||
$cmsmain->getHintsCache()->clear();
|
$cmsmain->getHintsCache()->clear();
|
||||||
}
|
}
|
||||||
$hints = json_decode($cmsmain->SiteTreeHints() ?? '', true);
|
$hints = json_decode($cmsmain->TreeHints() ?? '', true);
|
||||||
|
|
||||||
$classes = $hints['Root']['disallowedChildren'];
|
$classes = $hints['Root']['disallowedChildren'];
|
||||||
$this->assertNotContains(ErrorPage::class, $classes);
|
$this->assertNotContains(ErrorPage::class, $classes);
|
||||||
|
Loading…
Reference in New Issue
Block a user