mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
BUG: Merged patch from kmayo how ever re-added some of the removed fields since they really should appear on the Main Content tab instead of the Metadata tab.
Fixed a few missed strict errors Applied patch from kmayo to fix issues with SubsiteAdminTest.php Fixed issue causing the url segments of subsites created from a template to add -2 to the end Fixed undefined method TotalItems() on datalist for the SubsiteTest Fixed failure on SubsiteTest because DataObject::get_one() now returns boolean false instead of null when no result is found Fixed failure on SubsitesVirtualPageTest caused by Versioned::get_one_by_stage() returning null instead of false Fixed failure caused by the contact-us page existing on subsite 2 Merged another patch from kmayo Force main site to be on, for some reason it gets hidden in some cases i.e. refreshing the cms while editing a page
This commit is contained in:
parent
598b0253f5
commit
ef4d539a12
@ -63,10 +63,10 @@ class SubsitesVirtualPage extends VirtualPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$fields->addFieldToTab('Root.Metadata', new TextField('CustomMetaTitle', 'Title (overrides inherited value from the source)'), 'MetaTitle');
|
$fields->addFieldToTab('Root.Main', new TextField('CustomMetaTitle', 'Title (overrides inherited value from the source)'), 'MetaTitle');
|
||||||
$fields->addFieldToTab('Root.Metadata', new TextareaField('CustomMetaKeywords', 'Keywords (overrides inherited value from the source)'), 'MetaKeywords');
|
$fields->addFieldToTab('Root.Main', new TextareaField('CustomMetaKeywords', 'Keywords (overrides inherited value from the source)'), 'MetaKeywords');
|
||||||
$fields->addFieldToTab('Root.Metadata', new TextareaField('CustomMetaDescription', 'Description (overrides inherited value from the source)'), 'MetaDescription');
|
$fields->addFieldToTab('Root.Main', new TextareaField('CustomMetaDescription', 'Description (overrides inherited value from the source)'), 'MetaDescription');
|
||||||
$fields->addFieldToTab('Root.Metadata', new TextField('CustomExtraMeta', 'Custom Meta Tags (overrides inherited value from the source)'), 'ExtraMeta');
|
$fields->addFieldToTab('Root.Main', new TextField('CustomExtraMeta', 'Custom Meta Tags (overrides inherited value from the source)'), 'ExtraMeta');
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
@ -30,8 +30,11 @@ class FileSubsites extends DataExtension {
|
|||||||
function updateCMSFields(FieldList $fields) {
|
function updateCMSFields(FieldList $fields) {
|
||||||
if($this->owner instanceof Folder) {
|
if($this->owner instanceof Folder) {
|
||||||
$sites = Subsite::accessible_sites('CMS_ACCESS_AssetAdmin');
|
$sites = Subsite::accessible_sites('CMS_ACCESS_AssetAdmin');
|
||||||
$dropdownValues = ($sites) ? $sites->map() : array();
|
$dropdownValues = array();
|
||||||
$dropdownValues[0] = 'All sites';
|
$dropdownValues[0] = 'All sites';
|
||||||
|
foreach ($sites as $site) {
|
||||||
|
$dropDownValues[$site->ID] = $site->Title;
|
||||||
|
}
|
||||||
ksort($dropdownValues);
|
ksort($dropdownValues);
|
||||||
if($sites)$fields->push(new DropdownField("SubsiteID", "Subsite", $dropdownValues));
|
if($sites)$fields->push(new DropdownField("SubsiteID", "Subsite", $dropdownValues));
|
||||||
}
|
}
|
||||||
@ -107,4 +110,3 @@ class FileSubsites extends DataExtension {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,7 +38,35 @@ class LeftAndMainSubsites extends Extension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function Subsites() {
|
public function Subsites() {
|
||||||
return Subsite::accessible_sites('ADMIN');
|
$accessPerm = 'CMS_ACCESS_'. $this->owner->class;
|
||||||
|
switch($this->owner->class) {
|
||||||
|
case "AssetAdmin":
|
||||||
|
$subsites = Subsite::accessible_sites($accessPerm, true, "Shared files & images");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "SecurityAdmin":
|
||||||
|
$subsites = Subsite::accessible_sites($accessPerm, true, "Groups accessing all sites");
|
||||||
|
if($subsites->find('ID',0)) {
|
||||||
|
$subsites->push(new ArrayData(array('Title' => 'All groups', 'ID' => -1)));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "CMSMain":
|
||||||
|
// If there's a default site then main site has no meaning
|
||||||
|
$showMainSite = !DataObject::get_one('Subsite',"\"DefaultSite\"=1 AND \"IsPublic\"=1");
|
||||||
|
$subsites = Subsite::accessible_sites($accessPerm, $showMainSite);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "SubsiteAdmin":
|
||||||
|
$subsites = Subsite::accessible_sites('ADMIN', true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
$subsites = Subsite::accessible_sites($accessPerm);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $subsites;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function SubsiteList() {
|
public function SubsiteList() {
|
||||||
|
@ -96,18 +96,15 @@ class SiteTreeSubsites extends DataExtension {
|
|||||||
$subsite = $this->owner->Subsite();
|
$subsite = $this->owner->Subsite();
|
||||||
if($subsite && $subsite->ID) {
|
if($subsite && $subsite->ID) {
|
||||||
$baseUrl = 'http://' . $subsite->domain() . '/';
|
$baseUrl = 'http://' . $subsite->domain() . '/';
|
||||||
$fields->removeByName('URLSegment');
|
|
||||||
|
|
||||||
$baseLink = Controller::join_links (
|
$baseLink = Controller::join_links (
|
||||||
$baseUrl,
|
$baseUrl,
|
||||||
(SiteTree::nested_urls() && $this->owner->ParentID ? $this->owner->Parent()->RelativeLink(true) : null)
|
(SiteTree::nested_urls() && $this->owner->ParentID ? $this->owner->Parent()->RelativeLink(true) : null)
|
||||||
);
|
);
|
||||||
|
|
||||||
$url = (strlen($baseLink) > 36) ? "..." .substr($baseLink, -32) : $baseLink;
|
$url = (strlen($baseLink) > 36 ? "..." .substr($baseLink, -32) : $baseLink);
|
||||||
$urlsegment = new SiteTreeURLSegmentField("URLSegment", $this->owner->fieldLabel('URLSegment'));
|
$urlsegment = $fields->dataFieldByName('URLSegment');
|
||||||
$urlsegment->setURLPrefix($url);
|
$urlsegment->setURLPrefix($url);
|
||||||
$urlsegment->setHelpText(SiteTree::nested_urls() && count($this->owner->Children()) ? $this->owner->fieldLabel('LinkChangeNote'): false);
|
|
||||||
$fields->addFieldToTab('Root.Metadata', $urlsegment, 'MetaTitle');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$relatedCount = 0;
|
$relatedCount = 0;
|
||||||
@ -119,7 +116,8 @@ class SiteTreeSubsites extends DataExtension {
|
|||||||
$tabName = $relatedCount ? 'Related (' . $relatedCount . ')' : 'Related';
|
$tabName = $relatedCount ? 'Related (' . $relatedCount . ')' : 'Related';
|
||||||
$tab = $fields->findOrMakeTab('Root.Related', $tabName);
|
$tab = $fields->findOrMakeTab('Root.Related', $tabName);
|
||||||
// Related pages
|
// Related pages
|
||||||
$tab->push(new LiteralField('RelatedNote', '<p>You can list pages here that are related to this page.<br />When this page is updated, you will get a reminder to check whether these related pages need to be updated as well.</p>'));
|
$tab->push(new LiteralField('RelatedNote',
|
||||||
|
'<p>You can list pages here that are related to this page.<br />When this page is updated, you will get a reminder to check whether these related pages need to be updated as well.</p>'));
|
||||||
$tab->push(
|
$tab->push(
|
||||||
$related=new GridField('RelatedPages', 'Related Pages', $this->owner->RelatedPages(), GridFieldConfig_Base::create())
|
$related=new GridField('RelatedPages', 'Related Pages', $this->owner->RelatedPages(), GridFieldConfig_Base::create())
|
||||||
);
|
);
|
||||||
@ -231,16 +229,25 @@ class SiteTreeSubsites extends DataExtension {
|
|||||||
$subsiteID = $subsite->ID;
|
$subsiteID = $subsite->ID;
|
||||||
} else $subsite = DataObject::get_by_id('Subsite', $subsiteID);
|
} else $subsite = DataObject::get_by_id('Subsite', $subsiteID);
|
||||||
|
|
||||||
|
$oldSubsite=Subsite::currentSubsiteID();
|
||||||
|
if($subsiteID) {
|
||||||
|
Subsite::changeSubsite($subsiteID);
|
||||||
|
}else {
|
||||||
|
$subsiteID=$oldSubsite;
|
||||||
|
}
|
||||||
|
|
||||||
$page = $this->owner->duplicate(false);
|
$page = $this->owner->duplicate(false);
|
||||||
|
|
||||||
$page->CheckedPublicationDifferences = $page->AddedToStage = true;
|
$page->CheckedPublicationDifferences = $page->AddedToStage = true;
|
||||||
$subsiteID = ($subsiteID ? $subsiteID : Subsite::currentSubsiteID());
|
$subsiteID = ($subsiteID ? $subsiteID : $oldSubsite);
|
||||||
$page->SubsiteID = $subsiteID;
|
$page->SubsiteID = $subsiteID;
|
||||||
|
|
||||||
if($isTemplate) $page->MasterPageID = $this->owner->ID;
|
if($isTemplate) $page->MasterPageID = $this->owner->ID;
|
||||||
|
|
||||||
$page->write();
|
$page->write();
|
||||||
|
|
||||||
|
Subsite::changeSubsite($oldSubsite);
|
||||||
|
|
||||||
return $page;
|
return $page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ class SubsitesTreeDropdownField extends TreeDropdownField {
|
|||||||
|
|
||||||
protected $extraClasses = array('SubsitesTreeDropdownField');
|
protected $extraClasses = array('SubsitesTreeDropdownField');
|
||||||
|
|
||||||
function Field() {
|
function Field($properties = array()) {
|
||||||
$html = parent::Field();
|
$html = parent::Field($properties);
|
||||||
|
|
||||||
Requirements::javascript('subsites/javascript/SubsitesTreeDropdownField.js');
|
Requirements::javascript('subsites/javascript/SubsitesTreeDropdownField.js');
|
||||||
|
|
||||||
|
@ -27,14 +27,14 @@ class RelatedPageLink extends DataObject {
|
|||||||
if(!$subsites) $subsites = new ArrayList();
|
if(!$subsites) $subsites = new ArrayList();
|
||||||
|
|
||||||
if(Subsite::hasMainSitePermission(null, array("CMS_ACCESS_CMSMain"))) {
|
if(Subsite::hasMainSitePermission(null, array("CMS_ACCESS_CMSMain"))) {
|
||||||
$subsites->push(new ArrayData(array('Title' => 'Main site', "\"ID\"" => 0)));
|
$subsites = Subsite::accessible_sites("CMS_ACCESS_CMSMain", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($subsites->Count()) {
|
if($subsites->Count()) {
|
||||||
$subsiteSelectionField = new DropdownField(
|
$subsiteSelectionField = new DropdownField(
|
||||||
"CopyContentFromID_SubsiteID",
|
"CopyContentFromID_SubsiteID",
|
||||||
"Subsite",
|
"Subsite",
|
||||||
$subsites->toDropdownMap('ID', 'Title'),
|
$subsites->map('ID', 'Title'),
|
||||||
($this->CopyContentFromID) ? $this->CopyContentFrom()->SubsiteID : Session::get('SubsiteID')
|
($this->CopyContentFromID) ? $this->CopyContentFrom()->SubsiteID : Session::get('SubsiteID')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -322,7 +322,7 @@ JS;
|
|||||||
/**
|
/**
|
||||||
* @todo Possible security issue, don't grant edit permissions to everybody.
|
* @todo Possible security issue, don't grant edit permissions to everybody.
|
||||||
*/
|
*/
|
||||||
function canEdit() {
|
function canEdit($member = false) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,7 +403,7 @@ JS;
|
|||||||
if(!is_array($permissionCodes))
|
if(!is_array($permissionCodes))
|
||||||
user_error('Permissions must be passed to Subsite::hasMainSitePermission as an array', E_USER_ERROR);
|
user_error('Permissions must be passed to Subsite::hasMainSitePermission as an array', E_USER_ERROR);
|
||||||
|
|
||||||
if(!$member && $member !== FALSE) $member = Member::currentMember();
|
if(!$member && $member !== FALSE) $member = Member::currentUser();
|
||||||
|
|
||||||
if(!$member) return false;
|
if(!$member) return false;
|
||||||
|
|
||||||
@ -429,8 +429,8 @@ JS;
|
|||||||
/**
|
/**
|
||||||
* Duplicate this subsite
|
* Duplicate this subsite
|
||||||
*/
|
*/
|
||||||
function duplicate() {
|
function duplicate($doWrite = true) {
|
||||||
$newTemplate = parent::duplicate();
|
$newTemplate = parent::duplicate($doWrite);
|
||||||
|
|
||||||
$oldSubsiteID = Session::get('SubsiteID');
|
$oldSubsiteID = Session::get('SubsiteID');
|
||||||
self::changeSubsite($this->ID);
|
self::changeSubsite($this->ID);
|
||||||
@ -476,7 +476,7 @@ JS;
|
|||||||
* @param $member
|
* @param $member
|
||||||
* @return DataList of {@link Subsite} instances
|
* @return DataList of {@link Subsite} instances
|
||||||
*/
|
*/
|
||||||
function accessible_sites($permCode, $includeMainSite = true, $mainSiteTitle = "Main site", $member = null) {
|
public static function accessible_sites($permCode, $includeMainSite = true, $mainSiteTitle = "Main site", $member = null) {
|
||||||
// Rationalise member arguments
|
// Rationalise member arguments
|
||||||
if(!$member) $member = Member::currentUser();
|
if(!$member) $member = Member::currentUser();
|
||||||
if(!$member) return new ArrayList();
|
if(!$member) return new ArrayList();
|
||||||
@ -661,9 +661,17 @@ class Subsite_Template extends Subsite {
|
|||||||
if($children) {
|
if($children) {
|
||||||
foreach($children as $child) {
|
foreach($children as $child) {
|
||||||
$childClone = $child->duplicateToSubsite($intranet);
|
$childClone = $child->duplicateToSubsite($intranet);
|
||||||
|
|
||||||
|
//Change to destination subsite
|
||||||
|
self::changeSubsite($intranet->ID);
|
||||||
|
|
||||||
$childClone->ParentID = $destParentID;
|
$childClone->ParentID = $destParentID;
|
||||||
$childClone->writeToStage('Stage');
|
$childClone->writeToStage('Stage');
|
||||||
$childClone->publish('Stage', 'Live');
|
$childClone->publish('Stage', 'Live');
|
||||||
|
|
||||||
|
//Change Back to this subsite
|
||||||
|
self::changeSubsite($this->ID);
|
||||||
|
|
||||||
array_push($stack, array($child->ID, $childClone->ID));
|
array_push($stack, array($child->ID, $childClone->ID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,6 @@
|
|||||||
//Bind listener
|
//Bind listener
|
||||||
$('a#PageTypeBlacklistToggle').click(function(e) {
|
$('a#PageTypeBlacklistToggle').click(function(e) {
|
||||||
jQuery('#PageTypeBlacklist').toggle();
|
jQuery('#PageTypeBlacklist').toggle();
|
||||||
|
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
@ -10,7 +10,7 @@ class FileSubsitesTest extends SapphireTest {
|
|||||||
$file->Title = 'FileTitle';
|
$file->Title = 'FileTitle';
|
||||||
$this->assertEquals(' * FileTitle', $file->alternateTreeTitle());
|
$this->assertEquals(' * FileTitle', $file->alternateTreeTitle());
|
||||||
$file->SubsiteID = $this->objFromFixture('Subsite', 'domaintest1')->ID;
|
$file->SubsiteID = $this->objFromFixture('Subsite', 'domaintest1')->ID;
|
||||||
$this->assertEquals('FileTitle', $file->TreeTitle());
|
$this->assertEquals('FileTitle', $file->getTreeTitle());
|
||||||
$this->assertTrue(singleton('Folder')->getCMSFields() instanceof FieldList);
|
$this->assertTrue(singleton('Folder')->getCMSFields() instanceof FieldList);
|
||||||
Subsite::changeSubsite(1);
|
Subsite::changeSubsite(1);
|
||||||
$this->assertEquals($file->cacheKeyComponent(), 'subsite-1');
|
$this->assertEquals($file->cacheKeyComponent(), 'subsite-1');
|
||||||
|
@ -15,11 +15,11 @@ class GroupSubsitesTest extends SapphireTest {
|
|||||||
$group = new Group();
|
$group = new Group();
|
||||||
$group->Title = 'The A Team';
|
$group->Title = 'The A Team';
|
||||||
$group->AccessAllSubsites = true;
|
$group->AccessAllSubsites = true;
|
||||||
$this->assertEquals($group->TreeTitle(), 'The A Team <i>(global group)</i>');
|
$this->assertEquals($group->getTreeTitle(), 'The A Team <i>(global group)</i>');
|
||||||
$group->AccessAllSubsites = false;
|
$group->AccessAllSubsites = false;
|
||||||
$group->write();
|
$group->write();
|
||||||
$group->Subsites()->add($this->objFromFixture('Subsite', 'domaintest1'));
|
$group->Subsites()->add($this->objFromFixture('Subsite', 'domaintest1'));
|
||||||
$group->Subsites()->add($this->objFromFixture('Subsite', 'domaintest2'));
|
$group->Subsites()->add($this->objFromFixture('Subsite', 'domaintest2'));
|
||||||
$this->assertEquals($group->TreeTitle(), 'The A Team <i>(Test 1, Test 2)</i>');
|
$this->assertEquals($group->getTreeTitle(), 'The A Team <i>(Test 1, Test 2)</i>');
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -164,25 +164,27 @@ class SiteTreeSubsitesTest extends SapphireTest {
|
|||||||
$s1->write();
|
$s1->write();
|
||||||
|
|
||||||
Subsite::changeSubsite($s1);
|
Subsite::changeSubsite($s1);
|
||||||
|
$settingsFields = $page->getSettingsFields()->dataFieldByName('ClassName')->getSource();
|
||||||
$this->assertArrayNotHasKey('ErrorPage',
|
$this->assertArrayNotHasKey('ErrorPage',
|
||||||
$page->getCMSFields()->dataFieldByName('ClassName')->getSource()
|
$settingsFields
|
||||||
);
|
);
|
||||||
$this->assertArrayNotHasKey('SiteTreeSubsitesTest_ClassA',
|
$this->assertArrayNotHasKey('SiteTreeSubsitesTest_ClassA',
|
||||||
$page->getCMSFields()->dataFieldByName('ClassName')->getSource()
|
$settingsFields
|
||||||
);
|
);
|
||||||
$this->assertArrayHasKey('SiteTreeSubsitesTest_ClassB',
|
$this->assertArrayHasKey('SiteTreeSubsitesTest_ClassB',
|
||||||
$page->getCMSFields()->dataFieldByName('ClassName')->getSource()
|
$settingsFields
|
||||||
);
|
);
|
||||||
|
|
||||||
Subsite::changeSubsite($s2);
|
Subsite::changeSubsite($s2);
|
||||||
|
$settingsFields = $page->getSettingsFields()->dataFieldByName('ClassName')->getSource();
|
||||||
$this->assertArrayHasKey('ErrorPage',
|
$this->assertArrayHasKey('ErrorPage',
|
||||||
$page->getCMSFields()->dataFieldByName('ClassName')->getSource()
|
$settingsFields
|
||||||
);
|
);
|
||||||
$this->assertArrayHasKey('SiteTreeSubsitesTest_ClassA',
|
$this->assertArrayHasKey('SiteTreeSubsitesTest_ClassA',
|
||||||
$page->getCMSFields()->dataFieldByName('ClassName')->getSource()
|
$settingsFields
|
||||||
);
|
);
|
||||||
$this->assertArrayHasKey('SiteTreeSubsitesTest_ClassB',
|
$this->assertArrayHasKey('SiteTreeSubsitesTest_ClassB',
|
||||||
$page->getCMSFields()->dataFieldByName('ClassName')->getSource()
|
$settingsFields
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,8 +20,8 @@ class SubsiteAdminTest extends SapphireTest {
|
|||||||
$response1 = Director::test('admin/subsites/', null, $this->adminLoggedInSession());
|
$response1 = Director::test('admin/subsites/', null, $this->adminLoggedInSession());
|
||||||
|
|
||||||
// Confirm that this URL gets you the entire page, with the edit form loaded
|
// Confirm that this URL gets you the entire page, with the edit form loaded
|
||||||
$response2 = Director::test("admin/subsites/Subsite/$subsite1ID/edit", null, $this->adminLoggedInSession());
|
$response2 = Director::test("admin/subsites/Subsite/EditForm/field/Subsite/item/$subsite1ID/edit", null, $this->adminLoggedInSession());
|
||||||
$this->assertTrue(strpos($response2->getBody(), 'id="Form_EditForm_ID"') !== false, "Testing Form_EditForm_ID exists");
|
$this->assertTrue(strpos($response2->getBody(), 'id="Form_ItemEditForm_ID"') !== false, "Testing Form_ItemEditForm_ID exists");
|
||||||
$this->assertTrue(strpos($response2->getBody(), '<head') !== false, "Testing <head> exists");
|
$this->assertTrue(strpos($response2->getBody(), '<head') !== false, "Testing <head> exists");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ class SubsiteAdminTest extends SapphireTest {
|
|||||||
$ids[$subsite->ID] = true;
|
$ids[$subsite->ID] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->assertTrue($subsite->adminSearchFields() instanceof FieldList);
|
$this->assertTrue(Subsite::adminSearchFields() instanceof FieldList);
|
||||||
$this->assertArrayHasKey(0, $ids, "Main site accessible");
|
$this->assertArrayHasKey(0, $ids, "Main site accessible");
|
||||||
$this->assertArrayHasKey($this->idFromFixture('Subsite_Template','main'), $ids, "Site with no groups inaccesible");
|
$this->assertArrayHasKey($this->idFromFixture('Subsite_Template','main'), $ids, "Site with no groups inaccesible");
|
||||||
$this->assertArrayHasKey($this->idFromFixture('Subsite_Template','subsite1'), $ids, "Subsite1 Template inaccessible");
|
$this->assertArrayHasKey($this->idFromFixture('Subsite_Template','subsite1'), $ids, "Subsite1 Template inaccessible");
|
||||||
|
@ -33,7 +33,7 @@ class SubsiteTest extends SapphireTest {
|
|||||||
|
|
||||||
// Publish all the pages in the template, testing that DataObject::get only returns pages from the chosen subsite
|
// 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("SiteTree");
|
||||||
$totalPages = $pages->TotalItems();
|
$totalPages = $pages->Count();
|
||||||
foreach($pages as $page) {
|
foreach($pages as $page) {
|
||||||
$this->assertEquals($template->ID, $page->SubsiteID);
|
$this->assertEquals($template->ID, $page->SubsiteID);
|
||||||
$page->publish('Stage', 'Live');
|
$page->publish('Stage', 'Live');
|
||||||
@ -52,7 +52,7 @@ class SubsiteTest extends SapphireTest {
|
|||||||
$subsite->activate();
|
$subsite->activate();
|
||||||
|
|
||||||
$siteHome = DataObject::get_one('SiteTree', "\"URLSegment\" = 'home'");
|
$siteHome = DataObject::get_one('SiteTree', "\"URLSegment\" = 'home'");
|
||||||
$this->assertNotNull($siteHome);
|
$this->assertNotEquals($siteHome, false, 'Home Page for subsite not found');
|
||||||
$this->assertEquals($subsite->ID, $siteHome->SubsiteID,
|
$this->assertEquals($subsite->ID, $siteHome->SubsiteID,
|
||||||
'createInstance() copies existing pages retaining the same URLSegment'
|
'createInstance() copies existing pages retaining the same URLSegment'
|
||||||
);
|
);
|
||||||
|
@ -60,16 +60,19 @@ SiteTree:
|
|||||||
Title: Important Page
|
Title: Important Page
|
||||||
SubsiteID: =>Subsite_Template.main
|
SubsiteID: =>Subsite_Template.main
|
||||||
subsite1_home:
|
subsite1_home:
|
||||||
Title: Home (Subsite 1)
|
Title: Home
|
||||||
SubsiteID: =>Subsite_Template.subsite1
|
SubsiteID: =>Subsite_Template.subsite1
|
||||||
subsite1_contactus:
|
subsite1_contactus:
|
||||||
Title: Contact Us (Subsite 1)
|
Title: Contact Us
|
||||||
|
SubsiteID: =>Subsite_Template.subsite1
|
||||||
|
subsite1_staff:
|
||||||
|
Title: Staff
|
||||||
SubsiteID: =>Subsite_Template.subsite1
|
SubsiteID: =>Subsite_Template.subsite1
|
||||||
subsite2_home:
|
subsite2_home:
|
||||||
Title: Home (Subsite 2)
|
Title: Home
|
||||||
SubsiteID: =>Subsite_Template.subsite2
|
SubsiteID: =>Subsite_Template.subsite2
|
||||||
subsite2_contactus:
|
subsite2_contactus:
|
||||||
Title: Contact Us (Subsite 2)
|
Title: Contact Us
|
||||||
SubsiteID: =>Subsite_Template.subsite2
|
SubsiteID: =>Subsite_Template.subsite2
|
||||||
|
|
||||||
Group:
|
Group:
|
||||||
|
@ -199,12 +199,12 @@ class SubsitesVirtualPageTest extends SapphireTest {
|
|||||||
|
|
||||||
Subsite::changeSubsite($vp1->SubsiteID);
|
Subsite::changeSubsite($vp1->SubsiteID);
|
||||||
$onLive = Versioned::get_one_by_stage('SubsitesVirtualPage', 'Live', "\"SiteTree_Live\".\"ID\" = ".$vp1->ID);
|
$onLive = Versioned::get_one_by_stage('SubsitesVirtualPage', 'Live', "\"SiteTree_Live\".\"ID\" = ".$vp1->ID);
|
||||||
$this->assertFalse($onLive, 'SVP has been removed from live');
|
$this->assertNull($onLive, 'SVP has been removed from live');
|
||||||
|
|
||||||
$subsite = $this->objFromFixture('Subsite_Template', 'subsite2');
|
$subsite = $this->objFromFixture('Subsite_Template', 'subsite2');
|
||||||
Subsite::changeSubsite($vp2->SubsiteID);
|
Subsite::changeSubsite($vp2->SubsiteID);
|
||||||
$onLive = Versioned::get_one_by_stage('SubsitesVirtualPage', 'Live', "\"SiteTree_Live\".\"ID\" = ".$vp2->ID);
|
$onLive = Versioned::get_one_by_stage('SubsitesVirtualPage', 'Live', "\"SiteTree_Live\".\"ID\" = ".$vp2->ID);
|
||||||
$this->assertFalse($onLive, 'SVP has been removed from live');
|
$this->assertNull($onLive, 'SVP has been removed from live');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -217,8 +217,8 @@ class SubsitesVirtualPageTest extends SapphireTest {
|
|||||||
$subsite2 = $this->objFromFixture('Subsite_Template', 'subsite2');
|
$subsite2 = $this->objFromFixture('Subsite_Template', 'subsite2');
|
||||||
Subsite::changeSubsite($subsite1->ID);
|
Subsite::changeSubsite($subsite1->ID);
|
||||||
|
|
||||||
$subsite1Page = $this->objFromFixture('SiteTree', 'subsite1_contactus');
|
$subsite1Page = $this->objFromFixture('SiteTree', 'subsite1_staff');
|
||||||
$subsite1Page->URLSegment = 'contact-us';
|
$subsite1Page->URLSegment = 'staff';
|
||||||
$subsite1Page->write();
|
$subsite1Page->write();
|
||||||
|
|
||||||
// saving on subsite1, and linking to subsite1
|
// saving on subsite1, and linking to subsite1
|
||||||
@ -232,6 +232,9 @@ class SubsitesVirtualPageTest extends SapphireTest {
|
|||||||
"Doesn't allow explicit URLSegment overrides when already existing in same subsite"
|
"Doesn't allow explicit URLSegment overrides when already existing in same subsite"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//Change to subsite 2
|
||||||
|
Subsite::changeSubsite($subsite2->ID);
|
||||||
|
|
||||||
// saving in subsite2 (which already has a page with URLSegment 'contact-us'),
|
// saving in subsite2 (which already has a page with URLSegment 'contact-us'),
|
||||||
// but linking to a page in subsite1
|
// but linking to a page in subsite1
|
||||||
$subsite2Vp = new SubsitesVirtualPage();
|
$subsite2Vp = new SubsitesVirtualPage();
|
||||||
|
Loading…
Reference in New Issue
Block a user