mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
Merge pull request #264 from kinglozzer/ss4-compat
SS4 namespaces compatibility
This commit is contained in:
commit
84551163a6
20
_config.php
20
_config.php
@ -1,5 +1,21 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\CMS\Controllers\ContentController;
|
||||
use SilverStripe\CMS\Controllers\CMSPageAddController;
|
||||
use SilverStripe\Admin\LeftAndMain;
|
||||
use SilverStripe\Security\Group;
|
||||
use SilverStripe\Assets\File;
|
||||
use SilverStripe\CMS\Model\ErrorPage;
|
||||
use SilverStripe\SiteConfig\SiteConfig;
|
||||
use SilverStripe\SiteConfig\SiteConfigLeftAndMain;
|
||||
use SilverStripe\Reports\Report;
|
||||
use SilverStripe\Admin\SecurityAdmin;
|
||||
use SilverStripe\CMS\Controllers\CMSMain;
|
||||
use SilverStripe\CMS\Controllers\CMSPagesController;
|
||||
use SilverStripe\CMS\Controllers\CMSPageSettingsController;
|
||||
use SilverStripe\AssetAdmin\Controller\AssetAdmin;
|
||||
|
||||
/**
|
||||
* The subsites module modifies the behaviour of the CMS - in the SiteTree and Group databases - to store information
|
||||
* about a number of sub-sites, rather than a single site.
|
||||
@ -16,7 +32,7 @@ File::add_extension('FileSubsites');
|
||||
ErrorPage::add_extension('ErrorPageSubsite');
|
||||
SiteConfig::add_extension('SiteConfigSubsites');
|
||||
|
||||
SS_Report::add_excluded_reports('SubsiteReportWrapper');
|
||||
Report::add_excluded_reports('SubsiteReportWrapper');
|
||||
|
||||
//Display in cms menu
|
||||
AssetAdmin::add_extension('SubsiteMenuExtension');
|
||||
@ -24,5 +40,5 @@ SecurityAdmin::add_extension('SubsiteMenuExtension');
|
||||
CMSMain::add_extension('SubsiteMenuExtension');
|
||||
CMSPagesController::add_extension('SubsiteMenuExtension');
|
||||
SubsiteAdmin::add_extension('SubsiteMenuExtension');
|
||||
CMSSettingsController::add_extension('SubsiteMenuExtension');
|
||||
SiteConfigLeftAndMain::add_extension('SubsiteMenuExtension');
|
||||
|
||||
|
@ -7,6 +7,6 @@ After:
|
||||
AssetAdmin:
|
||||
treats_subsite_0_as_global: true
|
||||
|
||||
Director:
|
||||
SilverStripe\Control\Director:
|
||||
rules:
|
||||
'SubsiteXHRController': 'SubsiteXHRController'
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Admin\ModelAdmin;
|
||||
/**
|
||||
* Admin interface to manage and create {@link Subsite} instances.
|
||||
*
|
||||
@ -23,7 +25,7 @@ class SubsiteAdmin extends ModelAdmin {
|
||||
|
||||
$grid=$form->Fields()->dataFieldByName('Subsite');
|
||||
if($grid) {
|
||||
$grid->getConfig()->removeComponentsByType('GridFieldDetailForm');
|
||||
$grid->getConfig()->removeComponentsByType('SilverStripe\\Forms\\GridField\\GridFieldDetailForm');
|
||||
$grid->getConfig()->addComponent(new GridFieldSubsiteDetailForm());
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,14 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Forms\TreeMultiselectField;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Reports\ReportWrapper;
|
||||
|
||||
/**
|
||||
* Creates a subsite-aware version of another report.
|
||||
* Pass another report (or its classname) into the constructor.
|
||||
*/
|
||||
class SubsiteReportWrapper extends SS_ReportWrapper {
|
||||
class SubsiteReportWrapper extends ReportWrapper {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Filtering
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Admin\LeftAndMain;
|
||||
|
||||
/**
|
||||
* Section-agnostic PJAX controller.
|
||||
*/
|
||||
@ -39,7 +41,7 @@ class SubsiteXHRController extends LeftAndMain {
|
||||
* Provide the list of available subsites as a cms-section-agnostic PJAX handler.
|
||||
*/
|
||||
public function SubsiteList() {
|
||||
return $this->renderWith('SubsiteList');
|
||||
return $this->renderWith('Includes/SubsiteList');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,17 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Forms\DropdownField;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Forms\LabelField;
|
||||
use SilverStripe\Forms\TextField;
|
||||
use SilverStripe\Forms\TextareaField;
|
||||
use SilverStripe\Control\Session;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\CMS\Model\VirtualPage;
|
||||
use SilverStripe\CMS\Model\VirtualPage_Controller;
|
||||
class SubsitesVirtualPage extends VirtualPage {
|
||||
|
||||
private static $description = 'Displays the content of a page on another subsite';
|
||||
@ -36,7 +49,7 @@ class SubsitesVirtualPage extends VirtualPage {
|
||||
$pageSelectionField = new SubsitesTreeDropdownField(
|
||||
"CopyContentFromID",
|
||||
_t('VirtualPage.CHOOSE', "Choose a page to link to"),
|
||||
"SiteTree",
|
||||
"SilverStripe\\CMS\\Model\\SiteTree",
|
||||
"ID",
|
||||
"MenuTitle"
|
||||
);
|
||||
@ -128,7 +141,7 @@ class SubsitesVirtualPage extends VirtualPage {
|
||||
public function syncLinkTracking() {
|
||||
$oldState = Subsite::$disable_subsite_filter;
|
||||
Subsite::$disable_subsite_filter = true;
|
||||
if ($this->CopyContentFromID) $this->HasBrokenLink = DataObject::get_by_id('SiteTree', $this->CopyContentFromID) ? false : true;
|
||||
if ($this->CopyContentFromID) $this->HasBrokenLink = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $this->CopyContentFromID) ? false : true;
|
||||
Subsite::$disable_subsite_filter = $oldState;
|
||||
}
|
||||
|
||||
@ -162,7 +175,7 @@ class SubsitesVirtualPage extends VirtualPage {
|
||||
$IDFilter = ($this->ID) ? "AND \"SiteTree\".\"ID\" <> $this->ID" : null;
|
||||
$parentFilter = null;
|
||||
|
||||
if(Config::inst()->get('SiteTree', 'nested_urls')) {
|
||||
if(Config::inst()->get('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls')) {
|
||||
if($this->ParentID) {
|
||||
$parentFilter = " AND \"SiteTree\".\"ParentID\" = $this->ParentID";
|
||||
} else {
|
||||
@ -173,13 +186,13 @@ class SubsitesVirtualPage extends VirtualPage {
|
||||
$origDisableSubsiteFilter = Subsite::$disable_subsite_filter;
|
||||
Subsite::$disable_subsite_filter = true;
|
||||
$existingPage = DataObject::get_one(
|
||||
'SiteTree',
|
||||
'SilverStripe\\CMS\\Model\\SiteTree',
|
||||
"\"URLSegment\" = '$this->URLSegment' $IDFilter $parentFilter",
|
||||
false // disable cache, it doesn't include subsite status in the key
|
||||
);
|
||||
Subsite::$disable_subsite_filter = $origDisableSubsiteFilter;
|
||||
$existingPageInSubsite = DataObject::get_one(
|
||||
'SiteTree',
|
||||
'SilverStripe\\CMS\\Model\\SiteTree',
|
||||
"\"URLSegment\" = '$this->URLSegment' $IDFilter $parentFilter",
|
||||
false // disable cache, it doesn't include subsite status in the key
|
||||
);
|
||||
@ -192,21 +205,3 @@ class SubsitesVirtualPage extends VirtualPage {
|
||||
return $isValid;
|
||||
}
|
||||
}
|
||||
|
||||
class SubsitesVirtualPage_Controller extends VirtualPage_Controller {
|
||||
|
||||
public function reloadContent() {
|
||||
$this->failover->copyFrom($this->failover->CopyContentFrom());
|
||||
$this->failover->write();
|
||||
return;
|
||||
}
|
||||
|
||||
public function init(){
|
||||
$origDisableSubsiteFilter = Subsite::$disable_subsite_filter;
|
||||
Subsite::$disable_subsite_filter = true;
|
||||
|
||||
parent::init();
|
||||
|
||||
Subsite::$disable_subsite_filter = $origDisableSubsiteFilter;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Forms\HiddenField;
|
||||
use SilverStripe\Core\Extension;
|
||||
class CMSPageAddControllerExtension extends Extension {
|
||||
|
||||
function updatePageOptions(&$fields) {
|
||||
|
@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\View\SSViewer;
|
||||
use SilverStripe\Core\Extension;
|
||||
/**
|
||||
* @package subsites
|
||||
*/
|
||||
|
@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
class ErrorPageSubsite extends DataExtension {
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,14 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Assets\Folder;
|
||||
use SilverStripe\Forms\DropdownField;
|
||||
use SilverStripe\Forms\LiteralField;
|
||||
use SilverStripe\ORM\Queries\SQLSelect;
|
||||
use SilverStripe\ORM\DataQuery;
|
||||
use SilverStripe\Control\Session;
|
||||
use SilverStripe\Security\Permission;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
/**
|
||||
* Extension for the File object to add subsites support
|
||||
*
|
||||
|
@ -1,4 +1,16 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Forms\OptionsetField;
|
||||
use SilverStripe\Forms\CheckboxSetField;
|
||||
use SilverStripe\Forms\ReadonlyField;
|
||||
use SilverStripe\ORM\Queries\SQLSelect;
|
||||
use SilverStripe\ORM\DataQuery;
|
||||
use SilverStripe\Control\Cookie;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\Security\PermissionProvider;
|
||||
/**
|
||||
* Extension for the Group object to add subsites support
|
||||
*
|
||||
|
@ -1,4 +1,19 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\View\Requirements;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Forms\HiddenField;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Security\Permission;
|
||||
use SilverStripe\Control\Session;
|
||||
use SilverStripe\Admin\CMSMenu;
|
||||
use SilverStripe\Security\Security;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Core\Extension;
|
||||
/**
|
||||
* Decorator designed to add subsites support to LeftAndMain
|
||||
*
|
||||
@ -46,7 +61,7 @@ class LeftAndMainSubsites extends Extension {
|
||||
// Rationalise member arguments
|
||||
if(!$member) $member = Member::currentUser();
|
||||
if(!$member) return new ArrayList();
|
||||
if(!is_object($member)) $member = DataObject::get_by_id('Member', $member);
|
||||
if(!is_object($member)) $member = DataObject::get_by_id('SilverStripe\\Security\\Member', $member);
|
||||
|
||||
// Collect permissions - honour the LeftAndMain::required_permission_codes, current model requires
|
||||
// us to check if the user satisfies ALL permissions. Code partly copied from LeftAndMain::canView.
|
||||
@ -295,7 +310,7 @@ class LeftAndMainSubsites extends Extension {
|
||||
}
|
||||
|
||||
function copytosubsite($data, $form) {
|
||||
$page = DataObject::get_by_id('SiteTree', $data['ID']);
|
||||
$page = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $data['ID']);
|
||||
$subsite = DataObject::get_by_id('Subsite', $data['CopyToSubsiteID']);
|
||||
$newPage = $page->duplicateToSubsite($subsite->ID, true);
|
||||
$response = $this->owner->getResponse();
|
||||
|
@ -1,5 +1,11 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\ORM\Queries\SQLSelect;
|
||||
use SilverStripe\ORM\DataQuery;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\HiddenField;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
|
||||
/**
|
||||
* Extension for the SiteConfig object to add subsites support
|
||||
*/
|
||||
|
@ -1,5 +1,20 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\ORM\Queries\SQLSelect;
|
||||
use SilverStripe\ORM\DataQuery;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\DropdownField;
|
||||
use SilverStripe\Forms\InlineFormAction;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\SiteConfig\SiteConfig;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Control\HTTP;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
|
||||
/**
|
||||
* Extension for the SiteTree object to add subsites support
|
||||
*/
|
||||
@ -10,7 +25,7 @@ class SiteTreeSubsites extends DataExtension {
|
||||
);
|
||||
|
||||
private static $many_many = array(
|
||||
'CrossSubsiteLinkTracking' => 'SiteTree' // Stored separately, as the logic for URL rewriting is different
|
||||
'CrossSubsiteLinkTracking' => 'SilverStripe\\CMS\\Model\\SiteTree' // Stored separately, as the logic for URL rewriting is different
|
||||
);
|
||||
|
||||
private static $many_many_extraFields = array(
|
||||
@ -58,7 +73,7 @@ class SiteTreeSubsites extends DataExtension {
|
||||
$subsites = Subsite::accessible_sites("CMS_ACCESS_CMSMain");
|
||||
$subsitesMap = array();
|
||||
if($subsites && $subsites->Count()) {
|
||||
$subsitesMap = $subsites->map('ID', 'Title');
|
||||
$subsitesMap = $subsites->map('ID', 'Title')->toArray();
|
||||
unset($subsitesMap[$this->owner->SubsiteID]);
|
||||
}
|
||||
|
||||
@ -81,12 +96,11 @@ class SiteTreeSubsites extends DataExtension {
|
||||
_t('SiteTreeSubsites.CopyAction', "Copy")
|
||||
)
|
||||
);
|
||||
$copyAction->includeDefaultJS(false);
|
||||
}
|
||||
|
||||
// replace readonly link prefix
|
||||
$subsite = $this->owner->Subsite();
|
||||
$nested_urls_enabled = Config::inst()->get('SiteTree', 'nested_urls');
|
||||
$nested_urls_enabled = Config::inst()->get('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls');
|
||||
if($subsite && $subsite->ID) {
|
||||
$baseUrl = Director::protocol() . $subsite->domain() . '/';
|
||||
$baseLink = Controller::join_links (
|
||||
@ -101,7 +115,7 @@ class SiteTreeSubsites extends DataExtension {
|
||||
|
||||
function alternateSiteConfig() {
|
||||
if(!$this->owner->SubsiteID) return false;
|
||||
$sc = DataObject::get_one('SiteConfig', '"SubsiteID" = ' . $this->owner->SubsiteID);
|
||||
$sc = DataObject::get_one('SilverStripe\\SiteConfig\\SiteConfig', '"SubsiteID" = ' . $this->owner->SubsiteID);
|
||||
if(!$sc) {
|
||||
$sc = new SiteConfig();
|
||||
$sc->SubsiteID = $this->owner->SubsiteID;
|
||||
@ -252,7 +266,7 @@ class SiteTreeSubsites extends DataExtension {
|
||||
$subsite = Subsite::currentSubsite();
|
||||
|
||||
if($subsite && $subsite->Theme){
|
||||
Config::inst()->update('SSViewer', 'theme', Subsite::currentSubsite()->Theme);
|
||||
Config::inst()->update('SilverStripe\\View\\SSViewer', 'theme', Subsite::currentSubsite()->Theme);
|
||||
}
|
||||
}
|
||||
|
||||
@ -306,7 +320,7 @@ class SiteTreeSubsites extends DataExtension {
|
||||
|
||||
$origDisableSubsiteFilter = Subsite::$disable_subsite_filter;
|
||||
Subsite::disable_subsite_filter(true);
|
||||
$candidatePage = DataObject::get_one("SiteTree", "\"URLSegment\" = '" . Convert::raw2sql(urldecode( $rest)) . "' AND \"SubsiteID\" = " . $subsiteID, false);
|
||||
$candidatePage = DataObject::get_one("SilverStripe\\CMS\\Model\\SiteTree", "\"URLSegment\" = '" . Convert::raw2sql(urldecode( $rest)) . "' AND \"SubsiteID\" = " . $subsiteID, false);
|
||||
Subsite::disable_subsite_filter($origDisableSubsiteFilter);
|
||||
|
||||
if($candidatePage) {
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Core\Extension;
|
||||
|
||||
/*
|
||||
* Simple extension to show admins in the menu of subsites.
|
||||
* If an admin area should be available to a subsite, you can attach
|
||||
|
@ -1,4 +1,8 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Forms\GridField\GridFieldDetailForm;
|
||||
use SilverStripe\Forms\DropdownField;
|
||||
use SilverStripe\Forms\GridField\GridFieldDetailForm_ItemRequest;
|
||||
class GridFieldSubsiteDetailForm extends GridFieldDetailForm {
|
||||
protected $itemRequestClass='GridFieldSubsiteDetailForm_ItemRequest';
|
||||
}
|
||||
|
@ -1,4 +1,9 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\View\Requirements;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\Session;
|
||||
use SilverStripe\Forms\TreeDropdownField;
|
||||
/**
|
||||
* Wraps around a TreedropdownField to add ability for temporary
|
||||
* switching of subsite sessions.
|
||||
@ -31,7 +36,7 @@ class SubsitesTreeDropdownField extends TreeDropdownField {
|
||||
return $this->subsiteID;
|
||||
}
|
||||
|
||||
function tree(SS_HTTPRequest $request) {
|
||||
function tree(HTTPRequest $request) {
|
||||
$oldSubsiteID = Session::get('SubsiteID');
|
||||
Session::set('SubsiteID', $this->subsiteID);
|
||||
|
||||
|
@ -1,4 +1,31 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\Control\Session;
|
||||
use SilverStripe\i18n\i18n;
|
||||
use SilverStripe\Security\Permission;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Admin\CMSMenu;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\Forms\GridField\GridFieldConfig_RecordEditor;
|
||||
use SilverStripe\Forms\GridField\GridField;
|
||||
use SilverStripe\Forms\LiteralField;
|
||||
use SilverStripe\Forms\DropdownField;
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\Forms\HeaderField;
|
||||
use SilverStripe\Forms\TextField;
|
||||
use SilverStripe\Forms\CheckboxField;
|
||||
use SilverStripe\Forms\CheckboxSetField;
|
||||
use SilverStripe\Forms\Tab;
|
||||
use SilverStripe\Forms\TabSet;
|
||||
use SilverStripe\Forms\HiddenField;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\ORM\ArrayLib;
|
||||
use SilverStripe\ORM\Versioning\Versioned;
|
||||
/**
|
||||
* A dynamically created subsite. SiteTree objects can now belong to a subsite.
|
||||
* You can simulate subsite access without setting up virtual hosts by appending ?SubsiteID=<ID> to the request.
|
||||
@ -270,7 +297,7 @@ class Subsite extends DataObject {
|
||||
// Rationalise member arguments
|
||||
if(!$member) $member = Member::currentUser();
|
||||
if(!$member) return new ArrayList();
|
||||
if(!is_object($member)) $member = DataObject::get_by_id('Member', $member);
|
||||
if(!is_object($member)) $member = DataObject::get_by_id('SilverStripe\\Security\\Member', $member);
|
||||
|
||||
$subsites = new ArrayList();
|
||||
|
||||
@ -308,7 +335,7 @@ class Subsite extends DataObject {
|
||||
// Rationalise member arguments
|
||||
if(!$member) $member = Member::currentUser();
|
||||
if(!$member) return new ArrayList();
|
||||
if(!is_object($member)) $member = DataObject::get_by_id('Member', $member);
|
||||
if(!is_object($member)) $member = DataObject::get_by_id('SilverStripe\\Security\\Member', $member);
|
||||
|
||||
// Rationalise permCode argument
|
||||
if(is_array($permCode)) $SQL_codes = "'" . implode("', '", Convert::raw2sql($permCode)) . "'";
|
||||
@ -486,7 +513,7 @@ class Subsite extends DataObject {
|
||||
* @var array
|
||||
*/
|
||||
private static $belongs_many_many = array(
|
||||
"Groups" => "Group",
|
||||
"Groups" => "SilverStripe\\Security\\Group",
|
||||
);
|
||||
|
||||
/**
|
||||
@ -559,10 +586,11 @@ class Subsite extends DataObject {
|
||||
new Tab(
|
||||
'Configuration',
|
||||
_t('Subsite.TabTitleConfig', 'Configuration'),
|
||||
new HeaderField($this->getClassName() . ' configuration', 2),
|
||||
new HeaderField('ConfigurationHeader', $this->getClassName() . ' configuration', 2),
|
||||
new TextField('Title', $this->fieldLabel('Title'), $this->Title),
|
||||
|
||||
new HeaderField(
|
||||
'DomainsHeader',
|
||||
_t('Subsite.DomainsHeadline', "Domains for this subsite")
|
||||
),
|
||||
$domainTable,
|
||||
@ -764,7 +792,7 @@ JS;
|
||||
$SQL_permissionCodes = join("','", $SQL_permissionCodes);
|
||||
|
||||
return DataObject::get(
|
||||
'Member',
|
||||
'SilverStripe\\Security\\Member',
|
||||
"\"Group\".\"SubsiteID\" = $this->ID AND \"Permission\".\"Code\" IN ('$SQL_permissionCodes')",
|
||||
'',
|
||||
"LEFT JOIN \"Group_Members\" ON \"Member\".\"ID\" = \"Group_Members\".\"MemberID\"
|
||||
|
@ -1,5 +1,11 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Forms\TextField;
|
||||
use SilverStripe\Forms\CheckboxField;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
|
||||
/**
|
||||
* @property text Domain domain name of this subsite. Do not include the URL scheme here
|
||||
* @property bool IsPrimary Is this the primary subdomain?
|
||||
|
@ -1,4 +1,8 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\Versioning\Versioned;
|
||||
use SilverStripe\Dev\BuildTask;
|
||||
/**
|
||||
* Handy alternative to copying pages when creating a subsite through the UI.
|
||||
* Can be used to batch-add new pages after subsite creation,
|
||||
@ -35,7 +39,7 @@ class SubsiteCopyPagesTask extends BuildTask {
|
||||
while(count($stack) > 0) {
|
||||
list($sourceParentID, $destParentID) = array_pop($stack);
|
||||
|
||||
$children = Versioned::get_by_stage('SiteTree', 'Live', "\"ParentID\" = $sourceParentID", '');
|
||||
$children = Versioned::get_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', "\"ParentID\" = $sourceParentID", '');
|
||||
|
||||
if($children) {
|
||||
foreach($children as $child) {
|
||||
|
@ -12,7 +12,8 @@
|
||||
"require":
|
||||
{
|
||||
"silverstripe/framework": "~4.0",
|
||||
"silverstripe/cms": "~4.0"
|
||||
"silverstripe/cms": "~4.0",
|
||||
"silverstripe/asset-admin": "~1.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/PHPUnit": "~3.7@stable"
|
||||
|
@ -25,12 +25,17 @@
|
||||
}
|
||||
|
||||
.cms-menu .cms-subsites{
|
||||
padding:3px 0px 15px;
|
||||
padding: 0 8px 12px;
|
||||
}
|
||||
.cms-menu .cms-subsites .field.dropdown{
|
||||
padding-bottom:0;
|
||||
margin-bottom:0;
|
||||
}
|
||||
|
||||
.cms-menu .cms-subsites .field.dropdown span {
|
||||
color: #4f5861;
|
||||
}
|
||||
|
||||
.cms-menu.collapsed .cms-subsites {
|
||||
display: none;
|
||||
}
|
||||
|
@ -1,45 +0,0 @@
|
||||
<div class="cms-menu cms-panel cms-panel-layout west" id="cms-menu" data-layout-type="border">
|
||||
<div class="cms-logo-header north">
|
||||
<div class="cms-logo">
|
||||
<a href="$ApplicationLink" target="_blank" title="$ApplicationName (Version - $CMSVersion)">
|
||||
$ApplicationName <% if $CMSVersion %><abbr class="version">$CMSVersion</abbr><% end_if %>
|
||||
</a>
|
||||
<span><% if $SiteConfig %>$SiteConfig.Title<% else %>$ApplicationName<% end_if %></span>
|
||||
</div>
|
||||
|
||||
<div class="cms-login-status">
|
||||
<a href="$LogoutURL" class="logout-link font-icon-logout" title="<%t LeftAndMain_Menu_ss.LOGOUT 'Log out' %>"></a>
|
||||
<% with $CurrentMember %>
|
||||
<span>
|
||||
<%t LeftAndMain_Menu_ss.Hello 'Hi' %>
|
||||
<a href="{$AbsoluteBaseURL}admin/myprofile" class="profile-link">
|
||||
<% if $FirstName && $Surname %>$FirstName $Surname<% else_if $FirstName %>$FirstName<% else %>$Email<% end_if %>
|
||||
</a>
|
||||
</span>
|
||||
<% end_with %>
|
||||
</div>
|
||||
<% if $ListSubsites %>
|
||||
<% include SubsiteList %>
|
||||
<% end_if %>
|
||||
</div>
|
||||
|
||||
<div class="cms-panel-content center">
|
||||
<ul class="cms-menu-list">
|
||||
<% loop $MainMenu %>
|
||||
<li class="$LinkingMode $FirstLast <% if $LinkingMode == 'link' %><% else %>opened<% end_if %>" id="Menu-$Code" title="$Title.ATT">
|
||||
<a href="$Link" <% if $Code == 'Help' %>target="_blank"<% end_if %>>
|
||||
<span class="icon icon-16 icon-{$Code.LowerCase}"> </span>
|
||||
<span class="text">$Title</span>
|
||||
</a>
|
||||
</li>
|
||||
<% end_loop %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="cms-panel-toggle south">
|
||||
<button class="sticky-toggle" type="button" title="Sticky nav">Sticky nav</button>
|
||||
<span class="sticky-status-indicator">auto</span>
|
||||
<a class="toggle-expand" href="#"><span>»</span></a>
|
||||
<a class="toggle-collapse" href="#"><span>«</span></a>
|
||||
</div>
|
||||
</div>
|
18
templates/SilverStripe/Admin/Includes/LeftAndMain_Menu.ss
Normal file
18
templates/SilverStripe/Admin/Includes/LeftAndMain_Menu.ss
Normal file
@ -0,0 +1,18 @@
|
||||
<div class="cms-menu cms-panel cms-panel-layout west" id="cms-menu" data-layout-type="border">
|
||||
<div class="cms-logo-header north">
|
||||
<% include SilverStripe\\Admin\\LeftAndMain_MenuLogo %>
|
||||
<% include SilverStripe\\Admin\\LeftAndMain_MenuStatus %>
|
||||
|
||||
<% if $ListSubsites %>
|
||||
<% include SubsiteList %>
|
||||
<% end_if %>
|
||||
</div>
|
||||
|
||||
<div class="panel panel--scrollable panel--triple-toolbar cms-panel-content">
|
||||
<% include SilverStripe\\Admin\\LeftAndMain_MenuList %>
|
||||
</div>
|
||||
|
||||
<div class="toolbar toolbar--south cms-panel-toggle">
|
||||
<% include SilverStripe\\Admin\\LeftAndMain_MenuToggle %>
|
||||
</div>
|
||||
</div>
|
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
class BaseSubsiteTest extends SapphireTest {
|
||||
|
||||
function setUp() {
|
||||
|
@ -1,5 +1,9 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Assets\File;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Assets\Folder;
|
||||
|
||||
class FileSubsitesTest extends BaseSubsiteTest {
|
||||
static $fixture_file = 'subsites/tests/SubsiteTest.yml';
|
||||
|
||||
@ -11,13 +15,13 @@ class FileSubsitesTest extends BaseSubsiteTest {
|
||||
$this->assertEquals(' * FileTitle', $file->alternateTreeTitle());
|
||||
$file->SubsiteID = $this->objFromFixture('Subsite', 'domaintest1')->ID;
|
||||
$this->assertEquals('FileTitle', $file->getTreeTitle());
|
||||
$this->assertTrue(singleton('Folder')->getCMSFields() instanceof FieldList);
|
||||
$this->assertTrue(singleton('SilverStripe\\Assets\\Folder')->getCMSFields() instanceof FieldList);
|
||||
Subsite::changeSubsite(1);
|
||||
$this->assertEquals($file->cacheKeyComponent(), 'subsite-1');
|
||||
}
|
||||
|
||||
function testWritingSubsiteID() {
|
||||
$this->objFromFixture('Member', 'admin')->logIn();
|
||||
$this->objFromFixture('SilverStripe\\Security\\Member', 'admin')->logIn();
|
||||
|
||||
$subsite = $this->objFromFixture('Subsite', 'domaintest1');
|
||||
FileSubsites::$default_root_folders_global = true;
|
||||
@ -55,7 +59,7 @@ class FileSubsitesTest extends BaseSubsiteTest {
|
||||
}
|
||||
|
||||
function testSubsitesFolderDropdown() {
|
||||
$this->objFromFixture('Member', 'admin')->logIn();
|
||||
$this->objFromFixture('SilverStripe\\Security\\Member', 'admin')->logIn();
|
||||
|
||||
$file = new Folder();
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Security\Group;
|
||||
|
||||
class GroupSubsitesTest extends BaseSubsiteTest {
|
||||
static $fixture_file = 'subsites/tests/SubsiteTest.yml';
|
||||
|
||||
@ -8,7 +11,7 @@ class GroupSubsitesTest extends BaseSubsiteTest {
|
||||
function testTrivialFeatures() {
|
||||
$this->assertTrue(is_array(singleton('GroupSubsites')->extraStatics()));
|
||||
$this->assertTrue(is_array(singleton('GroupSubsites')->providePermissions()));
|
||||
$this->assertTrue(singleton('Group')->getCMSFields() instanceof FieldList);
|
||||
$this->assertTrue(singleton('SilverStripe\\Security\\Group')->getCMSFields() instanceof FieldList);
|
||||
}
|
||||
|
||||
function testAlternateTreeTitle() {
|
||||
|
@ -1,5 +1,9 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Admin\LeftAndMain;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
|
||||
class LeftAndMainSubsitesTest extends FunctionalTest {
|
||||
|
||||
static $fixture_file = 'subsites/tests/SubsiteTest.yml';
|
||||
@ -16,9 +20,9 @@ class LeftAndMainSubsitesTest extends FunctionalTest {
|
||||
}
|
||||
|
||||
function testSectionSites() {
|
||||
$member = $this->objFromFixture('Member', 'subsite1member');
|
||||
$member = $this->objFromFixture('SilverStripe\\Security\\Member', 'subsite1member');
|
||||
|
||||
$cmsmain = singleton('CMSMain');
|
||||
$cmsmain = singleton('SilverStripe\\CMS\\Controllers\\CMSMain');
|
||||
$subsites = $cmsmain->sectionSites(true, "Main site", $member);
|
||||
$this->assertDOSEquals(array(
|
||||
array('Title' =>'Subsite1 Template')
|
||||
@ -28,9 +32,9 @@ class LeftAndMainSubsitesTest extends FunctionalTest {
|
||||
$subsites = $assetadmin->sectionSites(true, "Main site", $member);
|
||||
$this->assertDOSEquals(array(), $subsites, 'Does not list any sites for forbidden controller.');
|
||||
|
||||
$member = $this->objFromFixture('Member', 'editor');
|
||||
$member = $this->objFromFixture('SilverStripe\\Security\\Member', 'editor');
|
||||
|
||||
$cmsmain = singleton('CMSMain');
|
||||
$cmsmain = singleton('SilverStripe\\CMS\\Controllers\\CMSMain');
|
||||
$subsites = $cmsmain->sectionSites(true, "Main site", $member);
|
||||
$this->assertDOSContains(array(
|
||||
array('Title' =>'Main site')
|
||||
@ -38,7 +42,7 @@ class LeftAndMainSubsitesTest extends FunctionalTest {
|
||||
}
|
||||
|
||||
function testAccessChecksDontChangeCurrentSubsite() {
|
||||
$admin = $this->objFromFixture("Member","admin");
|
||||
$admin = $this->objFromFixture("SilverStripe\\Security\\Member","admin");
|
||||
$this->loginAs($admin);
|
||||
$ids = array();
|
||||
|
||||
@ -70,17 +74,17 @@ class LeftAndMainSubsitesTest extends FunctionalTest {
|
||||
$l = new LeftAndMain();
|
||||
Config::inst()->nest();
|
||||
|
||||
Config::inst()->update('CMSPageEditController', 'treats_subsite_0_as_global', false);
|
||||
$this->assertTrue($l->shouldChangeSubsite('CMSPageEditController', 0, 5));
|
||||
$this->assertFalse($l->shouldChangeSubsite('CMSPageEditController', 0, 0));
|
||||
$this->assertTrue($l->shouldChangeSubsite('CMSPageEditController', 1, 5));
|
||||
$this->assertFalse($l->shouldChangeSubsite('CMSPageEditController', 1, 1));
|
||||
Config::inst()->update('SilverStripe\\CMS\\Controllers\\CMSPageEditController', 'treats_subsite_0_as_global', false);
|
||||
$this->assertTrue($l->shouldChangeSubsite('SilverStripe\\CMS\\Controllers\\CMSPageEditController', 0, 5));
|
||||
$this->assertFalse($l->shouldChangeSubsite('SilverStripe\\CMS\\Controllers\\CMSPageEditController', 0, 0));
|
||||
$this->assertTrue($l->shouldChangeSubsite('SilverStripe\\CMS\\Controllers\\CMSPageEditController', 1, 5));
|
||||
$this->assertFalse($l->shouldChangeSubsite('SilverStripe\\CMS\\Controllers\\CMSPageEditController', 1, 1));
|
||||
|
||||
Config::inst()->update('CMSPageEditController', 'treats_subsite_0_as_global', true);
|
||||
$this->assertFalse($l->shouldChangeSubsite('CMSPageEditController', 0, 5));
|
||||
$this->assertFalse($l->shouldChangeSubsite('CMSPageEditController', 0, 0));
|
||||
$this->assertTrue($l->shouldChangeSubsite('CMSPageEditController', 1, 5));
|
||||
$this->assertFalse($l->shouldChangeSubsite('CMSPageEditController', 1, 1));
|
||||
Config::inst()->update('SilverStripe\\CMS\\Controllers\\CMSPageEditController', 'treats_subsite_0_as_global', true);
|
||||
$this->assertFalse($l->shouldChangeSubsite('SilverStripe\\CMS\\Controllers\\CMSPageEditController', 0, 5));
|
||||
$this->assertFalse($l->shouldChangeSubsite('SilverStripe\\CMS\\Controllers\\CMSPageEditController', 0, 0));
|
||||
$this->assertTrue($l->shouldChangeSubsite('SilverStripe\\CMS\\Controllers\\CMSPageEditController', 1, 5));
|
||||
$this->assertFalse($l->shouldChangeSubsite('SilverStripe\\CMS\\Controllers\\CMSPageEditController', 1, 1));
|
||||
|
||||
Config::inst()->unnest();
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\SiteConfig\SiteConfig;
|
||||
|
||||
class SiteConfigSubsitesTest extends BaseSubsiteTest {
|
||||
static $fixture_file = 'subsites/tests/SubsiteTest.yml';
|
||||
|
||||
|
@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\SiteConfig\SiteConfig;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Control\Session;
|
||||
use SilverStripe\CMS\Controllers\CMSMain;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\CMS\Model\ErrorPage;
|
||||
|
||||
class SiteTreeSubsitesTest extends BaseSubsiteTest {
|
||||
|
||||
static $fixture_file = 'subsites/tests/SubsiteTest.yml';
|
||||
@ -11,7 +20,7 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest {
|
||||
);
|
||||
|
||||
protected $illegalExtensions = array(
|
||||
'SiteTree' => array('Translatable')
|
||||
'SilverStripe\CMS\Model\SiteTree' => array('Translatable')
|
||||
);
|
||||
|
||||
function testPagesInDifferentSubsitesCanShareURLSegment() {
|
||||
@ -45,9 +54,9 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest {
|
||||
}
|
||||
|
||||
function testBasicSanity() {
|
||||
$this->assertTrue(singleton('SiteTree')->getSiteConfig() instanceof SiteConfig);
|
||||
$this->assertTrue(singleton('SilverStripe\\CMS\\Model\\SiteTree')->getSiteConfig() instanceof SiteConfig);
|
||||
// The following assert is breaking in Translatable.
|
||||
$this->assertTrue(singleton('SiteTree')->getCMSFields() instanceof FieldList);
|
||||
$this->assertTrue(singleton('SilverStripe\\CMS\\Model\\SiteTree')->getCMSFields() instanceof FieldList);
|
||||
$this->assertTrue(singleton('SubsitesVirtualPage')->getCMSFields() instanceof FieldList);
|
||||
$this->assertTrue(is_array(singleton('SiteTreeSubsites')->extraStatics()));
|
||||
}
|
||||
@ -63,9 +72,9 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest {
|
||||
}
|
||||
|
||||
function testCanEditSiteTree() {
|
||||
$admin = $this->objFromFixture('Member', 'admin');
|
||||
$subsite1member = $this->objFromFixture('Member', 'subsite1member');
|
||||
$subsite2member = $this->objFromFixture('Member', 'subsite2member');
|
||||
$admin = $this->objFromFixture('SilverStripe\\Security\\Member', 'admin');
|
||||
$subsite1member = $this->objFromFixture('SilverStripe\\Security\\Member', 'subsite1member');
|
||||
$subsite2member = $this->objFromFixture('SilverStripe\\Security\\Member', 'subsite2member');
|
||||
$mainpage = $this->objFromFixture('Page', 'home');
|
||||
$subsite1page = $this->objFromFixture('Page', 'subsite1_home');
|
||||
$subsite2page = $this->objFromFixture('Page', 'subsite2_home');
|
||||
@ -133,12 +142,12 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest {
|
||||
}
|
||||
|
||||
function testPageTypesBlacklistInClassDropdown() {
|
||||
$editor = $this->objFromFixture('Member', 'editor');
|
||||
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'editor');
|
||||
Session::set("loggedInAs", $editor->ID);
|
||||
|
||||
$s1 = $this->objFromFixture('Subsite','domaintest1');
|
||||
$s2 = $this->objFromFixture('Subsite','domaintest2');
|
||||
$page = singleton('SiteTree');
|
||||
$page = singleton('SilverStripe\\CMS\\Model\\SiteTree');
|
||||
|
||||
$s1->PageTypeBlacklist = 'SiteTreeSubsitesTest_ClassA,ErrorPage';
|
||||
$s1->write();
|
||||
@ -146,7 +155,7 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest {
|
||||
Subsite::changeSubsite($s1);
|
||||
$settingsFields = $page->getSettingsFields()->dataFieldByName('ClassName')->getSource();
|
||||
|
||||
$this->assertArrayNotHasKey('ErrorPage',
|
||||
$this->assertArrayNotHasKey('SilverStripe\\CMS\\Model\\ErrorPage',
|
||||
$settingsFields
|
||||
);
|
||||
$this->assertArrayNotHasKey('SiteTreeSubsitesTest_ClassA',
|
||||
@ -158,7 +167,7 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest {
|
||||
|
||||
Subsite::changeSubsite($s2);
|
||||
$settingsFields = $page->getSettingsFields()->dataFieldByName('ClassName')->getSource();
|
||||
$this->assertArrayHasKey('ErrorPage',
|
||||
$this->assertArrayHasKey('SilverStripe\\CMS\\Model\\ErrorPage',
|
||||
$settingsFields
|
||||
);
|
||||
$this->assertArrayHasKey('SiteTreeSubsitesTest_ClassA',
|
||||
@ -170,7 +179,7 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest {
|
||||
}
|
||||
|
||||
function testPageTypesBlacklistInCMSMain() {
|
||||
$editor = $this->objFromFixture('Member', 'editor');
|
||||
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'editor');
|
||||
Session::set("loggedInAs", $editor->ID);
|
||||
|
||||
$cmsmain = new CMSMain();
|
||||
@ -184,14 +193,14 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest {
|
||||
Subsite::changeSubsite($s1);
|
||||
$hints = Convert::json2array($cmsmain->SiteTreeHints());
|
||||
$classes = $hints['Root']['disallowedChildren'];
|
||||
$this->assertContains('ErrorPage', $classes);
|
||||
$this->assertContains('SilverStripe\\CMS\\Model\\ErrorPage', $classes);
|
||||
$this->assertContains('SiteTreeSubsitesTest_ClassA', $classes);
|
||||
$this->assertNotContains('SiteTreeSubsitesTest_ClassB', $classes);
|
||||
|
||||
Subsite::changeSubsite($s2);
|
||||
$hints = Convert::json2array($cmsmain->SiteTreeHints());
|
||||
$classes = $hints['Root']['disallowedChildren'];
|
||||
$this->assertNotContains('ErrorPage', $classes);
|
||||
$this->assertNotContains('SilverStripe\\CMS\\Model\\ErrorPage', $classes);
|
||||
$this->assertNotContains('SiteTreeSubsitesTest_ClassA', $classes);
|
||||
$this->assertNotContains('SiteTreeSubsitesTest_ClassB', $classes);
|
||||
}
|
||||
|
@ -1,5 +1,9 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Control\Session;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
|
||||
class SubsiteAdminFunctionalTest extends FunctionalTest {
|
||||
static $fixture_file = 'subsites/tests/SubsiteTest.yml';
|
||||
static $use_draft_site = true;
|
||||
@ -39,7 +43,7 @@ class SubsiteAdminFunctionalTest extends FunctionalTest {
|
||||
* Admin should be able to access all subsites and the main site
|
||||
*/
|
||||
function testAdminCanAccessAllSubsites() {
|
||||
$member = $this->objFromFixture('Member', 'admin');
|
||||
$member = $this->objFromFixture('SilverStripe\\Security\\Member', 'admin');
|
||||
Session::set("loggedInAs", $member->ID);
|
||||
|
||||
$this->getAndFollowAll('admin/pages/?SubsiteID=0');
|
||||
@ -57,7 +61,7 @@ class SubsiteAdminFunctionalTest extends FunctionalTest {
|
||||
}
|
||||
|
||||
function testAdminIsRedirectedToObjectsSubsite() {
|
||||
$member = $this->objFromFixture('Member', 'admin');
|
||||
$member = $this->objFromFixture('SilverStripe\\Security\\Member', 'admin');
|
||||
Session::set("loggedInAs", $member->ID);
|
||||
|
||||
$mainSubsitePage = $this->objFromFixture('Page', 'mainSubsitePage');
|
||||
@ -65,13 +69,13 @@ class SubsiteAdminFunctionalTest extends FunctionalTest {
|
||||
|
||||
Config::inst()->nest();
|
||||
|
||||
Config::inst()->update('CMSPageEditController', 'treats_subsite_0_as_global', false);
|
||||
Config::inst()->update('SilverStripe\\CMS\\Controllers\\CMSPageEditController', 'treats_subsite_0_as_global', false);
|
||||
Subsite::changeSubsite(0);
|
||||
$this->getAndFollowAll("admin/pages/edit/show/$subsite1Home->ID");
|
||||
$this->assertEquals(Subsite::currentSubsiteID(), $subsite1Home->SubsiteID, 'Loading an object switches the subsite');
|
||||
$this->assertRegExp("#^admin/pages.*#", $this->mainSession->lastUrl(), 'Lands on the correct section');
|
||||
|
||||
Config::inst()->update('CMSPageEditController', 'treats_subsite_0_as_global', true);
|
||||
Config::inst()->update('SilverStripe\\CMS\\Controllers\\CMSPageEditController', 'treats_subsite_0_as_global', true);
|
||||
Subsite::changeSubsite(0);
|
||||
$this->getAndFollowAll("admin/pages/edit/show/$subsite1Home->ID");
|
||||
$this->assertEquals(Subsite::currentSubsiteID(), $subsite1Home->SubsiteID, 'Loading a non-main-site object still switches the subsite if configured with treats_subsite_0_as_global');
|
||||
@ -89,7 +93,7 @@ class SubsiteAdminFunctionalTest extends FunctionalTest {
|
||||
* even though he does not have the ADMIN permission.
|
||||
*/
|
||||
function testEditorCanAccessAllSubsites() {
|
||||
$member = $this->objFromFixture('Member', 'editor');
|
||||
$member = $this->objFromFixture('SilverStripe\\Security\\Member', 'editor');
|
||||
Session::set("loggedInAs", $member->ID);
|
||||
|
||||
$this->getAndFollowAll('admin/pages/?SubsiteID=0');
|
||||
@ -110,7 +114,7 @@ class SubsiteAdminFunctionalTest extends FunctionalTest {
|
||||
* Test a member who only has access to one subsite (subsite1) and only some sections (pages and security).
|
||||
*/
|
||||
function testSubsiteAdmin() {
|
||||
$member = $this->objFromFixture('Member', 'subsite1member');
|
||||
$member = $this->objFromFixture('SilverStripe\\Security\\Member', 'subsite1member');
|
||||
Session::set("loggedInAs", $member->ID);
|
||||
|
||||
$subsite1 = $this->objFromFixture('Subsite', 'subsite1');
|
||||
|
@ -1,11 +1,15 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Control\Session;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\CMS\Controllers\CMSMain;
|
||||
|
||||
class SubsiteAdminTest extends BaseSubsiteTest {
|
||||
static $fixture_file = 'subsites/tests/SubsiteTest.yml';
|
||||
|
||||
function adminLoggedInSession() {
|
||||
return new Session(array(
|
||||
'loggedInAs' => $this->idFromFixture('Member', 'admin')
|
||||
'loggedInAs' => $this->idFromFixture('SilverStripe\\Security\\Member', 'admin')
|
||||
));
|
||||
}
|
||||
|
||||
@ -31,7 +35,7 @@ class SubsiteAdminTest extends BaseSubsiteTest {
|
||||
* of whether he is in a subsite-specific group or not.
|
||||
*/
|
||||
function testMainsiteAdminCanAccessAllSubsites() {
|
||||
$member = $this->objFromFixture('Member', 'admin');
|
||||
$member = $this->objFromFixture('SilverStripe\\Security\\Member', 'admin');
|
||||
Session::set("loggedInAs", $member->ID);
|
||||
|
||||
$cmsMain = new CMSMain();
|
||||
|
@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\Control\Director;
|
||||
|
||||
class SubsiteTest extends BaseSubsiteTest {
|
||||
|
||||
static $fixture_file = 'subsites/tests/SubsiteTest.yml';
|
||||
@ -32,7 +35,7 @@ class SubsiteTest extends BaseSubsiteTest {
|
||||
$tmplHome = DataObject::get_one('Page', "\"URLSegment\" = 'home'");
|
||||
|
||||
// Publish all the pages in the template, testing that DataObject::get only returns pages from the chosen subsite
|
||||
$pages = DataObject::get("SiteTree");
|
||||
$pages = DataObject::get("SilverStripe\\CMS\\Model\\SiteTree");
|
||||
$totalPages = $pages->Count();
|
||||
foreach($pages as $page) {
|
||||
$this->assertEquals($template->ID, $page->SubsiteID);
|
||||
@ -256,7 +259,7 @@ class SubsiteTest extends BaseSubsiteTest {
|
||||
}
|
||||
|
||||
function testAllAccessibleSites() {
|
||||
$member = $this->objFromFixture('Member', 'subsite1member');
|
||||
$member = $this->objFromFixture('SilverStripe\\Security\\Member', 'subsite1member');
|
||||
|
||||
$subsites = Subsite::all_accessible_sites(true, 'Main site', $member);
|
||||
$this->assertDOSEquals(array(
|
||||
@ -269,13 +272,13 @@ class SubsiteTest extends BaseSubsiteTest {
|
||||
*/
|
||||
function testAccessibleSites() {
|
||||
$member1Sites = Subsite::accessible_sites("CMS_ACCESS_CMSMain", false, null,
|
||||
$this->objFromFixture('Member', 'subsite1member'));
|
||||
$this->objFromFixture('SilverStripe\\Security\\Member', 'subsite1member'));
|
||||
$member1SiteTitles = $member1Sites->column("Title");
|
||||
sort($member1SiteTitles);
|
||||
$this->assertEquals('Subsite1 Template', $member1SiteTitles[0], 'Member can get to a subsite via a group');
|
||||
|
||||
$adminSites = Subsite::accessible_sites("CMS_ACCESS_CMSMain", false, null,
|
||||
$this->objFromFixture('Member', 'admin'));
|
||||
$this->objFromFixture('SilverStripe\\Security\\Member', 'admin'));
|
||||
$adminSiteTitles = $adminSites->column("Title");
|
||||
sort($adminSiteTitles);
|
||||
$this->assertEquals(array(
|
||||
@ -288,17 +291,17 @@ class SubsiteTest extends BaseSubsiteTest {
|
||||
), $adminSiteTitles);
|
||||
|
||||
$member2Sites = Subsite::accessible_sites("CMS_ACCESS_CMSMain", false, null,
|
||||
$this->objFromFixture('Member', 'subsite1member2'));
|
||||
$this->objFromFixture('SilverStripe\\Security\\Member', 'subsite1member2'));
|
||||
$member2SiteTitles = $member2Sites->column("Title");
|
||||
sort($member2SiteTitles);
|
||||
$this->assertEquals('Subsite1 Template', $member2SiteTitles[0], 'Member can get to subsite via a group role');
|
||||
}
|
||||
|
||||
function testhasMainSitePermission() {
|
||||
$admin = $this->objFromFixture('Member', 'admin');
|
||||
$subsite1member = $this->objFromFixture('Member', 'subsite1member');
|
||||
$subsite1admin = $this->objFromFixture('Member', 'subsite1admin');
|
||||
$allsubsitesauthor = $this->objFromFixture('Member', 'allsubsitesauthor');
|
||||
$admin = $this->objFromFixture('SilverStripe\\Security\\Member', 'admin');
|
||||
$subsite1member = $this->objFromFixture('SilverStripe\\Security\\Member', 'subsite1member');
|
||||
$subsite1admin = $this->objFromFixture('SilverStripe\\Security\\Member', 'subsite1admin');
|
||||
$allsubsitesauthor = $this->objFromFixture('SilverStripe\\Security\\Member', 'allsubsitesauthor');
|
||||
|
||||
$this->assertTrue(
|
||||
Subsite::hasMainSitePermission($admin),
|
||||
|
@ -75,14 +75,14 @@ Page:
|
||||
Title: 'Contact Us (Subsite 2)'
|
||||
SubsiteID: =>Subsite.subsite2
|
||||
|
||||
PermissionRoleCode:
|
||||
SilverStripe\Security\PermissionRoleCode:
|
||||
roleCode1:
|
||||
Code: CMS_ACCESS_CMSMain
|
||||
PermissionRole:
|
||||
SilverStripe\Security\PermissionRole:
|
||||
role1:
|
||||
Title: role1
|
||||
Codes: =>PermissionRoleCode.roleCode1
|
||||
Group:
|
||||
Codes: =>SilverStripe\Security\PermissionRoleCode.roleCode1
|
||||
SilverStripe\Security\Group:
|
||||
admin:
|
||||
Title: Admin
|
||||
Code: admin
|
||||
@ -114,71 +114,71 @@ Group:
|
||||
Title: subsite1_group_via_role
|
||||
Code: subsite1_group_via_role
|
||||
AccessAllSubsites: 1
|
||||
Roles: =>PermissionRole.role1
|
||||
Permission:
|
||||
Roles: =>SilverStripe\Security\PermissionRole.role1
|
||||
SilverStripe\Security\Permission:
|
||||
admin:
|
||||
Code: ADMIN
|
||||
GroupID: =>Group.admin
|
||||
GroupID: =>SilverStripe\Security\Group.admin
|
||||
editor1:
|
||||
Code: CMS_ACCESS_CMSMain
|
||||
GroupID: =>Group.editor
|
||||
GroupID: =>SilverStripe\Security\Group.editor
|
||||
editor2:
|
||||
Code: SITETREE_VIEW_ALL
|
||||
GroupID: =>Group.editor
|
||||
GroupID: =>SilverStripe\Security\Group.editor
|
||||
editor3:
|
||||
Code: VIEW_DRAFT_CONTENT
|
||||
GroupID: =>Group.editor
|
||||
GroupID: =>SilverStripe\Security\Group.editor
|
||||
accesscmsmain1:
|
||||
Code: CMS_ACCESS_CMSMain
|
||||
GroupID: =>Group.subsite1_group
|
||||
GroupID: =>SilverStripe\Security\Group.subsite1_group
|
||||
accesscmsmain2:
|
||||
Code: CMS_ACCESS_CMSMain
|
||||
GroupID: =>Group.subsite2_group
|
||||
GroupID: =>SilverStripe\Security\Group.subsite2_group
|
||||
accesscmsmain3:
|
||||
Code: CMS_ACCESS_CMSMain
|
||||
GroupID: =>Group.subsite1admins
|
||||
GroupID: =>SilverStripe\Security\Group.subsite1admins
|
||||
accesscmsmain4:
|
||||
Code: CMS_ACCESS_CMSMain
|
||||
GroupID: =>Group.allsubsitesauthors
|
||||
GroupID: =>SilverStripe\Security\Group.allsubsitesauthors
|
||||
securityaccess1:
|
||||
Code: CMS_ACCESS_SecurityAdmin
|
||||
GroupID: =>Group.subsite1_group
|
||||
GroupID: =>SilverStripe\Security\Group.subsite1_group
|
||||
securityaccess2:
|
||||
Code: CMS_ACCESS_SecurityAdmin
|
||||
GroupID: =>Group.subsite2_group
|
||||
GroupID: =>SilverStripe\Security\Group.subsite2_group
|
||||
adminsubsite1:
|
||||
Code: ADMIN
|
||||
GroupID: =>Group.subsite1admins
|
||||
GroupID: =>SilverStripe\Security\Group.subsite1admins
|
||||
|
||||
Member:
|
||||
SilverStripe\Security\Member:
|
||||
admin:
|
||||
FirstName: Admin
|
||||
Surname: User
|
||||
Email: admin@test.com
|
||||
Password: rangi
|
||||
Groups: =>Group.admin
|
||||
Groups: =>SilverStripe\Security\Group.admin
|
||||
editor:
|
||||
FirstName: Editor
|
||||
Surname: User
|
||||
Email: editor@test.com
|
||||
Password: rangi
|
||||
Groups: =>Group.editor
|
||||
Groups: =>SilverStripe\Security\Group.editor
|
||||
subsite1member:
|
||||
Email: subsite1member@test.com
|
||||
Groups: =>Group.subsite1_group
|
||||
Groups: =>SilverStripe\Security\Group.subsite1_group
|
||||
subsite2member:
|
||||
Email: subsite2member@test.com
|
||||
Groups: =>Group.subsite2_group
|
||||
Groups: =>SilverStripe\Security\Group.subsite2_group
|
||||
subsite1admin:
|
||||
Email: subsite1admin@test.com
|
||||
Groups: =>Group.subsite1admins
|
||||
Groups: =>SilverStripe\Security\Group.subsite1admins
|
||||
allsubsitesauthor:
|
||||
Email: allsubsitesauthor@test.com
|
||||
Groups: =>Group.allsubsitesauthors
|
||||
Groups: =>SilverStripe\Security\Group.allsubsitesauthors
|
||||
subsite1member2:
|
||||
Email: subsite1member2@test.com
|
||||
Groups: =>Group.subsite1_group_via_role
|
||||
Groups: =>SilverStripe\Security\Group.subsite1_group_via_role
|
||||
|
||||
SiteConfig:
|
||||
SilverStripe\SiteConfig\SiteConfig:
|
||||
config:
|
||||
CanCreateTopLevelType: LoggedInUsers
|
||||
|
@ -1,5 +1,10 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Assets\Filesystem;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\ORM\Versioning\Versioned;
|
||||
|
||||
class SubsitesVirtualPageTest extends BaseSubsiteTest {
|
||||
static $fixture_file = array(
|
||||
'subsites/tests/SubsiteTest.yml',
|
||||
@ -13,8 +18,8 @@ class SubsitesVirtualPageTest extends BaseSubsiteTest {
|
||||
AssetStoreTest_SpyStore::activate('SubsitesVirtualPageTest');
|
||||
|
||||
// Create a test files for each of the fixture references
|
||||
$file = $this->objFromFixture('File', 'file1');
|
||||
$page = $this->objFromFixture('SiteTree', 'page1');
|
||||
$file = $this->objFromFixture('SilverStripe\\Assets\\File', 'file1');
|
||||
$page = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'page1');
|
||||
$fromPath = __DIR__ . '/testscript-test-file.pdf';
|
||||
$destPath = AssetStoreTest_SpyStore::getLocalPath($file);
|
||||
Filesystem::makeFolder(dirname($destPath));
|
||||
@ -57,7 +62,7 @@ class SubsitesVirtualPageTest extends BaseSubsiteTest {
|
||||
$this->logInWithPermission('ADMIN');
|
||||
|
||||
// Publish the source page
|
||||
$page = $this->objFromFixture('SiteTree', 'page1');
|
||||
$page = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'page1');
|
||||
$this->assertTrue($page->doPublish());
|
||||
|
||||
// Create a virtual page from it, and publish that
|
||||
@ -67,7 +72,7 @@ class SubsitesVirtualPageTest extends BaseSubsiteTest {
|
||||
$svp->doPublish();
|
||||
|
||||
// Rename the file
|
||||
$file = $this->objFromFixture('File', 'file1');
|
||||
$file = $this->objFromFixture('SilverStripe\\Assets\\File', 'file1');
|
||||
$file->Name = 'renamed-test-file.pdf';
|
||||
$file->write();
|
||||
|
||||
@ -261,8 +266,8 @@ class SubsitesVirtualPageTest extends BaseSubsiteTest {
|
||||
function fixVersionNumberCache($page) {
|
||||
$pages = func_get_args();
|
||||
foreach($pages as $p) {
|
||||
Versioned::prepopulate_versionnumber_cache('SiteTree', 'Stage', array($p->ID));
|
||||
Versioned::prepopulate_versionnumber_cache('SiteTree', 'Live', array($p->ID));
|
||||
Versioned::prepopulate_versionnumber_cache('SilverStripe\\CMS\\Model\\SiteTree', 'Stage', array($p->ID));
|
||||
Versioned::prepopulate_versionnumber_cache('SilverStripe\\CMS\\Model\\SiteTree', 'Live', array($p->ID));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
# These need to come first so that SiteTree has the link meta-data written.
|
||||
File:
|
||||
SilverStripe\Assets\File:
|
||||
file1:
|
||||
FileFilename: testscript-test-file.pdf
|
||||
FileHash: 464dedb70af0dc7f8f3360e7f3ae43cbbf1cdf4e
|
||||
Name: testscript-test-file.pdf
|
||||
|
||||
SiteTree:
|
||||
SilverStripe\CMS\Model\SiteTree:
|
||||
page1:
|
||||
Title: page1
|
||||
URLSegment: page1
|
||||
|
@ -11,6 +11,9 @@ use SilverStripe\BehatExtension\Context\SilverStripeContext,
|
||||
SilverStripe\Framework\Test\Behaviour\CmsFormsContext,
|
||||
SilverStripe\Framework\Test\Behaviour\CmsUiContext,
|
||||
SilverStripe\Cms\Test\Behaviour;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
|
||||
|
||||
// PHPUnit
|
||||
require_once 'PHPUnit/Autoload.php';
|
||||
@ -49,15 +52,15 @@ class FeatureContext extends SilverStripeContext {
|
||||
|
||||
// Use blueprints to set user name from identifier
|
||||
$factory = $fixtureContext->getFixtureFactory();
|
||||
$blueprint = \Injector::inst()->create('FixtureBlueprint', 'Member');
|
||||
$blueprint = Injector::inst()->create('SilverStripe\\Dev\\FixtureBlueprint', 'SilverStripe\\Security\\Member');
|
||||
$blueprint->addCallback('beforeCreate', function($identifier, &$data, &$fixtures) {
|
||||
if(!isset($data['FirstName'])) $data['FirstName'] = $identifier;
|
||||
});
|
||||
$factory->define('Member', $blueprint);
|
||||
$factory->define('SilverStripe\\Security\\Member', $blueprint);
|
||||
|
||||
// Auto-publish pages
|
||||
foreach(\ClassInfo::subclassesFor('SiteTree') as $id => $class) {
|
||||
$blueprint = \Injector::inst()->create('FixtureBlueprint', $class);
|
||||
foreach(ClassInfo::subclassesFor('SilverStripe\\CMS\\Model\\SiteTree') as $id => $class) {
|
||||
$blueprint = Injector::inst()->create('SilverStripe\\Dev\\FixtureBlueprint', $class);
|
||||
$blueprint->addCallback('afterCreate', function($obj, $identifier, &$data, &$fixtures) {
|
||||
$obj->publish('Stage', 'Live');
|
||||
});
|
||||
@ -78,7 +81,7 @@ class FeatureContext extends SilverStripeContext {
|
||||
*/
|
||||
public function getFixtureFactory() {
|
||||
if(!$this->fixtureFactory) {
|
||||
$this->fixtureFactory = \Injector::inst()->create('BehatFixtureFactory');
|
||||
$this->fixtureFactory = Injector::inst()->create('SilverStripe\\Dev\\BehatFixtureFactory');
|
||||
}
|
||||
|
||||
return $this->fixtureFactory;
|
||||
|
Loading…
Reference in New Issue
Block a user