mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
BUG: Coding convention fixes
BUG: more coding convention fixing
This commit is contained in:
parent
ef4d539a12
commit
c345f6fcc5
@ -229,13 +229,13 @@ class SiteTreeSubsites extends DataExtension {
|
||||
$subsiteID = $subsite->ID;
|
||||
} else $subsite = DataObject::get_by_id('Subsite', $subsiteID);
|
||||
|
||||
$oldSubsite=Subsite::currentSubsiteID();
|
||||
if($subsiteID) {
|
||||
Subsite::changeSubsite($subsiteID);
|
||||
}else {
|
||||
$subsiteID=$oldSubsite;
|
||||
}
|
||||
|
||||
$oldSubsite=Subsite::currentSubsiteID();
|
||||
if($subsiteID) {
|
||||
Subsite::changeSubsite($subsiteID);
|
||||
}else {
|
||||
$subsiteID=$oldSubsite;
|
||||
}
|
||||
|
||||
$page = $this->owner->duplicate(false);
|
||||
|
||||
$page->CheckedPublicationDifferences = $page->AddedToStage = true;
|
||||
@ -245,9 +245,9 @@ class SiteTreeSubsites extends DataExtension {
|
||||
if($isTemplate) $page->MasterPageID = $this->owner->ID;
|
||||
|
||||
$page->write();
|
||||
|
||||
Subsite::changeSubsite($oldSubsite);
|
||||
|
||||
|
||||
Subsite::changeSubsite($oldSubsite);
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
||||
@ -331,4 +331,4 @@ class SiteTreeSubsites extends DataExtension {
|
||||
if(in_array($this->owner->class, $blacklisted)) return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -87,4 +87,4 @@ class RelatedPageLink extends DataObject {
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
@ -661,17 +661,18 @@ class Subsite_Template extends Subsite {
|
||||
if($children) {
|
||||
foreach($children as $child) {
|
||||
$childClone = $child->duplicateToSubsite($intranet);
|
||||
|
||||
//Change to destination subsite
|
||||
self::changeSubsite($intranet->ID);
|
||||
|
||||
|
||||
//Change to destination subsite
|
||||
self::changeSubsite($intranet->ID);
|
||||
$newTemplate = parent::duplicate($doWrite);
|
||||
$childClone = $child->duplicateToSubsite($newTemplate, false);
|
||||
|
||||
$childClone->ParentID = $destParentID;
|
||||
$childClone->writeToStage('Stage');
|
||||
$childClone->publish('Stage', 'Live');
|
||||
|
||||
//Change Back to this subsite
|
||||
self::changeSubsite($this->ID);
|
||||
|
||||
|
||||
//Change Back to this subsite
|
||||
self::changeSubsite($this->ID);
|
||||
array_push($stack, array($child->ID, $childClone->ID));
|
||||
}
|
||||
}
|
||||
@ -682,4 +683,4 @@ class Subsite_Template extends Subsite {
|
||||
return $intranet;
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
@ -25,7 +25,7 @@
|
||||
}
|
||||
|
||||
.cms-login-status.subsites {
|
||||
padding-bottom: 7px;
|
||||
padding-bottom: 7px;
|
||||
}
|
||||
|
||||
#SubsitesSelect,
|
||||
@ -33,7 +33,7 @@
|
||||
font-size: 12px;
|
||||
}
|
||||
#SubsitesSelect {
|
||||
width: 171px;
|
||||
width: 171px;
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
@ -58,5 +58,5 @@ body.SubsiteAdmin .right form #URL .fieldgroup * {
|
||||
}
|
||||
|
||||
.cms-add-form #PageType li .class-SubsitesVirtualPage, .class-SubsitesVirtualPage a .jstree-pageicon {
|
||||
background-position: 0 -32px !important;
|
||||
}
|
||||
background-position: 0 -32px !important;
|
||||
}
|
||||
|
@ -18,10 +18,10 @@
|
||||
</span>
|
||||
<% end_control %>
|
||||
</div>
|
||||
|
||||
<div class="cms-login-status subsites">
|
||||
$SubsiteList
|
||||
</div>
|
||||
|
||||
<div class="cms-login-status subsites">
|
||||
$SubsiteList
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="cms-panel-content center">
|
||||
@ -56,4 +56,4 @@
|
||||
<a class="toggle-expand" href="#"><span>»</span></a>
|
||||
<a class="toggle-collapse" href="#"><span>«</span></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -3,27 +3,27 @@
|
||||
class SubsiteAdminTest extends SapphireTest {
|
||||
static $fixture_file = 'subsites/tests/SubsiteTest.yml';
|
||||
|
||||
function adminLoggedInSession() {
|
||||
return new Session(array(
|
||||
'loggedInAs' => $this->idFromFixture('Member', 'admin')
|
||||
));
|
||||
}
|
||||
function adminLoggedInSession() {
|
||||
return new Session(array(
|
||||
'loggedInAs' => $this->idFromFixture('Member', 'admin')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test generation of the view
|
||||
*/
|
||||
function testBasicView() {
|
||||
/**
|
||||
* Test generation of the view
|
||||
*/
|
||||
function testBasicView() {
|
||||
Subsite::$write_hostmap = false;
|
||||
$subsite1ID = $this->objFromFixture('Subsite','domaintest1')->ID;
|
||||
|
||||
// Open the admin area logged in as admin
|
||||
$response1 = Director::test('admin/subsites/', null, $this->adminLoggedInSession());
|
||||
|
||||
// Confirm that this URL gets you the entire page, with the edit form loaded
|
||||
$response2 = Director::test("admin/subsites/Subsite/EditForm/field/Subsite/item/$subsite1ID/edit", null, $this->adminLoggedInSession());
|
||||
$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");
|
||||
}
|
||||
// Open the admin area logged in as admin
|
||||
$response1 = Director::test('admin/subsites/', null, $this->adminLoggedInSession());
|
||||
|
||||
// Confirm that this URL gets you the entire page, with the edit form loaded
|
||||
$response2 = Director::test("admin/subsites/Subsite/EditForm/field/Subsite/item/$subsite1ID/edit", null, $this->adminLoggedInSession());
|
||||
$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");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test searching for an intranet
|
||||
@ -31,7 +31,7 @@ class SubsiteAdminTest extends SapphireTest {
|
||||
function XXtestIntranetSearch() {
|
||||
$cont = new SubsiteAdmin();
|
||||
$cont->pushCurrent();
|
||||
$cont->setSession($this->adminLoggedInSession());
|
||||
$cont->setSession($this->adminLoggedInSession());
|
||||
|
||||
// Check that the logged-in member has the correct permissions
|
||||
$this->assertTrue(Permission::check('ADMIN') ? true : false);
|
||||
@ -44,49 +44,49 @@ class SubsiteAdminTest extends SapphireTest {
|
||||
|
||||
foreach($searches as $search) {
|
||||
$response = $form->testAjaxSubmission('getResults', $search);
|
||||
$links = $response->getLinks();
|
||||
foreach($links as $link) {
|
||||
$this->assertTrue(preg_match('/^admin\/subsites\/show\/[0-9]+$/', $link['href']) == 1, "Search result links bad.");
|
||||
}
|
||||
$links = $response->getLinks();
|
||||
foreach($links as $link) {
|
||||
$this->assertTrue(preg_match('/^admin\/subsites\/show\/[0-9]+$/', $link['href']) == 1, "Search result links bad.");
|
||||
}
|
||||
}
|
||||
|
||||
$cont->popCurrent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the intranet creation form.
|
||||
*/
|
||||
function XXtestIntranetCreation() {
|
||||
$cont = new SubsiteAdmin();
|
||||
$cont->pushCurrent();
|
||||
$cont->setSession($this->adminLoggedInSession());
|
||||
|
||||
$form = $cont->AddSubsiteForm();
|
||||
$source = $form->dataFieldByName('TemplateID')->getSource();
|
||||
|
||||
$templateIDs = $this->allFixtureIDs('Subsite_Template');
|
||||
foreach($templateIDs as $templateID) {
|
||||
$this->assertArrayHasKey($templateID, $source);
|
||||
}
|
||||
|
||||
$templateObj = $this->objFromFixture('Subsite_Template','main');
|
||||
$this->assertEquals($templateObj->Title, $source[$templateObj->ID], "Template dropdown isn't listing Title values");
|
||||
|
||||
$response = $form->testSubmission('addintranet', array(
|
||||
'Name' => 'Test Intranet',
|
||||
'Domain' => 'test.example.com',
|
||||
'TemplateID' => 1,
|
||||
'AdminEmail' => '',
|
||||
'AdminName' => '',
|
||||
));
|
||||
/**
|
||||
* Test the intranet creation form.
|
||||
*/
|
||||
function XXtestIntranetCreation() {
|
||||
$cont = new SubsiteAdmin();
|
||||
$cont->pushCurrent();
|
||||
$cont->setSession($this->adminLoggedInSession());
|
||||
|
||||
$this->assertTrue(true == preg_match('/admin\/subsites\/show\/([0-9]+)/i', $response->getHeader('Location'), $matches), "Intranet creation dowsn't redirect to new view");
|
||||
|
||||
$newIntranet = DataObject::get_by_id("Subsite", $matches[1]);
|
||||
$this->assertEquals('Test Intranet', $newIntranet->Title, "New intranet not created properly.");
|
||||
|
||||
$cont->popCurrent();
|
||||
}
|
||||
$form = $cont->AddSubsiteForm();
|
||||
$source = $form->dataFieldByName('TemplateID')->getSource();
|
||||
|
||||
$templateIDs = $this->allFixtureIDs('Subsite_Template');
|
||||
foreach($templateIDs as $templateID) {
|
||||
$this->assertArrayHasKey($templateID, $source);
|
||||
}
|
||||
|
||||
$templateObj = $this->objFromFixture('Subsite_Template','main');
|
||||
$this->assertEquals($templateObj->Title, $source[$templateObj->ID], "Template dropdown isn't listing Title values");
|
||||
|
||||
$response = $form->testSubmission('addintranet', array(
|
||||
'Name' => 'Test Intranet',
|
||||
'Domain' => 'test.example.com',
|
||||
'TemplateID' => 1,
|
||||
'AdminEmail' => '',
|
||||
'AdminName' => '',
|
||||
));
|
||||
|
||||
$this->assertTrue(true == preg_match('/admin\/subsites\/show\/([0-9]+)/i', $response->getHeader('Location'), $matches), "Intranet creation dowsn't redirect to new view");
|
||||
|
||||
$newIntranet = DataObject::get_by_id("Subsite", $matches[1]);
|
||||
$this->assertEquals('Test Intranet', $newIntranet->Title, "New intranet not created properly.");
|
||||
|
||||
$cont->popCurrent();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -112,4 +112,4 @@ class SubsiteAdminTest extends SapphireTest {
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
@ -52,7 +52,7 @@ class SubsiteTest extends SapphireTest {
|
||||
$subsite->activate();
|
||||
|
||||
$siteHome = DataObject::get_one('SiteTree', "\"URLSegment\" = 'home'");
|
||||
$this->assertNotEquals($siteHome, false, 'Home Page for subsite not found');
|
||||
$this->assertNotEquals($siteHome, false, 'Home Page for subsite not found');
|
||||
$this->assertEquals($subsite->ID, $siteHome->SubsiteID,
|
||||
'createInstance() copies existing pages retaining the same URLSegment'
|
||||
);
|
||||
@ -342,4 +342,4 @@ class SubsiteTest extends SapphireTest {
|
||||
$subsite2->activate();
|
||||
$this->assertEquals('MyNewAwesomePage', DataObject::get_by_id('Page', $page2->ID)->Title);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -232,9 +232,9 @@ class SubsitesVirtualPageTest extends SapphireTest {
|
||||
"Doesn't allow explicit URLSegment overrides when already existing in same subsite"
|
||||
);
|
||||
|
||||
//Change to subsite 2
|
||||
Subsite::changeSubsite($subsite2->ID);
|
||||
|
||||
//Change to subsite 2
|
||||
Subsite::changeSubsite($subsite2->ID);
|
||||
|
||||
// saving in subsite2 (which already has a page with URLSegment 'contact-us'),
|
||||
// but linking to a page in subsite1
|
||||
$subsite2Vp = new SubsitesVirtualPage();
|
||||
@ -256,4 +256,4 @@ class SubsitesVirtualPageTest extends SapphireTest {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user