BUG: Coding convention fixes

BUG: more coding convention fixing
This commit is contained in:
Kirk Mayo 2012-07-16 11:14:13 +12:00
parent ef4d539a12
commit c345f6fcc5
8 changed files with 93 additions and 92 deletions

View File

@ -229,13 +229,13 @@ 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(); $oldSubsite=Subsite::currentSubsiteID();
if($subsiteID) { if($subsiteID) {
Subsite::changeSubsite($subsiteID); Subsite::changeSubsite($subsiteID);
}else { }else {
$subsiteID=$oldSubsite; $subsiteID=$oldSubsite;
} }
$page = $this->owner->duplicate(false); $page = $this->owner->duplicate(false);
$page->CheckedPublicationDifferences = $page->AddedToStage = true; $page->CheckedPublicationDifferences = $page->AddedToStage = true;
@ -245,9 +245,9 @@ class SiteTreeSubsites extends DataExtension {
if($isTemplate) $page->MasterPageID = $this->owner->ID; if($isTemplate) $page->MasterPageID = $this->owner->ID;
$page->write(); $page->write();
Subsite::changeSubsite($oldSubsite); Subsite::changeSubsite($oldSubsite);
return $page; return $page;
} }
@ -331,4 +331,4 @@ class SiteTreeSubsites extends DataExtension {
if(in_array($this->owner->class, $blacklisted)) return false; if(in_array($this->owner->class, $blacklisted)) return false;
} }
} }
} }

View File

@ -87,4 +87,4 @@ class RelatedPageLink extends DataObject {
} }
} }
?> ?>

View File

@ -661,17 +661,18 @@ 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 //Change to destination subsite
self::changeSubsite($intranet->ID); self::changeSubsite($intranet->ID);
$newTemplate = parent::duplicate($doWrite);
$childClone = $child->duplicateToSubsite($newTemplate, false);
$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 //Change Back to this subsite
self::changeSubsite($this->ID); self::changeSubsite($this->ID);
array_push($stack, array($child->ID, $childClone->ID)); array_push($stack, array($child->ID, $childClone->ID));
} }
} }
@ -682,4 +683,4 @@ class Subsite_Template extends Subsite {
return $intranet; return $intranet;
} }
} }
?> ?>

View File

@ -25,7 +25,7 @@
} }
.cms-login-status.subsites { .cms-login-status.subsites {
padding-bottom: 7px; padding-bottom: 7px;
} }
#SubsitesSelect, #SubsitesSelect,
@ -33,7 +33,7 @@
font-size: 12px; font-size: 12px;
} }
#SubsitesSelect { #SubsitesSelect {
width: 171px; width: 171px;
padding: 3px; padding: 3px;
} }
@ -58,5 +58,5 @@ body.SubsiteAdmin .right form #URL .fieldgroup * {
} }
.cms-add-form #PageType li .class-SubsitesVirtualPage, .class-SubsitesVirtualPage a .jstree-pageicon { .cms-add-form #PageType li .class-SubsitesVirtualPage, .class-SubsitesVirtualPage a .jstree-pageicon {
background-position: 0 -32px !important; background-position: 0 -32px !important;
} }

View File

@ -18,10 +18,10 @@
</span> </span>
<% end_control %> <% end_control %>
</div> </div>
<div class="cms-login-status subsites"> <div class="cms-login-status subsites">
$SubsiteList $SubsiteList
</div> </div>
</div> </div>
<div class="cms-panel-content center"> <div class="cms-panel-content center">
@ -56,4 +56,4 @@
<a class="toggle-expand" href="#"><span>&raquo;</span></a> <a class="toggle-expand" href="#"><span>&raquo;</span></a>
<a class="toggle-collapse" href="#"><span>&laquo;</span></a> <a class="toggle-collapse" href="#"><span>&laquo;</span></a>
</div> </div>
</div> </div>

View File

@ -3,27 +3,27 @@
class SubsiteAdminTest extends SapphireTest { class SubsiteAdminTest extends SapphireTest {
static $fixture_file = 'subsites/tests/SubsiteTest.yml'; static $fixture_file = 'subsites/tests/SubsiteTest.yml';
function adminLoggedInSession() { function adminLoggedInSession() {
return new Session(array( return new Session(array(
'loggedInAs' => $this->idFromFixture('Member', 'admin') 'loggedInAs' => $this->idFromFixture('Member', 'admin')
)); ));
} }
/** /**
* Test generation of the view * Test generation of the view
*/ */
function testBasicView() { function testBasicView() {
Subsite::$write_hostmap = false; Subsite::$write_hostmap = false;
$subsite1ID = $this->objFromFixture('Subsite','domaintest1')->ID; $subsite1ID = $this->objFromFixture('Subsite','domaintest1')->ID;
// Open the admin area logged in as admin // Open the admin area logged in as admin
$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/EditForm/field/Subsite/item/$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_ItemEditForm_ID"') !== false, "Testing Form_ItemEditForm_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");
} }
/** /**
* Test searching for an intranet * Test searching for an intranet
@ -31,7 +31,7 @@ class SubsiteAdminTest extends SapphireTest {
function XXtestIntranetSearch() { function XXtestIntranetSearch() {
$cont = new SubsiteAdmin(); $cont = new SubsiteAdmin();
$cont->pushCurrent(); $cont->pushCurrent();
$cont->setSession($this->adminLoggedInSession()); $cont->setSession($this->adminLoggedInSession());
// Check that the logged-in member has the correct permissions // Check that the logged-in member has the correct permissions
$this->assertTrue(Permission::check('ADMIN') ? true : false); $this->assertTrue(Permission::check('ADMIN') ? true : false);
@ -44,49 +44,49 @@ class SubsiteAdminTest extends SapphireTest {
foreach($searches as $search) { foreach($searches as $search) {
$response = $form->testAjaxSubmission('getResults', $search); $response = $form->testAjaxSubmission('getResults', $search);
$links = $response->getLinks(); $links = $response->getLinks();
foreach($links as $link) { foreach($links as $link) {
$this->assertTrue(preg_match('/^admin\/subsites\/show\/[0-9]+$/', $link['href']) == 1, "Search result links bad."); $this->assertTrue(preg_match('/^admin\/subsites\/show\/[0-9]+$/', $link['href']) == 1, "Search result links bad.");
} }
} }
$cont->popCurrent(); $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', * Test the intranet creation form.
'Domain' => 'test.example.com', */
'TemplateID' => 1, function XXtestIntranetCreation() {
'AdminEmail' => '', $cont = new SubsiteAdmin();
'AdminName' => '', $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"); $form = $cont->AddSubsiteForm();
$source = $form->dataFieldByName('TemplateID')->getSource();
$newIntranet = DataObject::get_by_id("Subsite", $matches[1]);
$this->assertEquals('Test Intranet', $newIntranet->Title, "New intranet not created properly."); $templateIDs = $this->allFixtureIDs('Subsite_Template');
foreach($templateIDs as $templateID) {
$cont->popCurrent(); $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 {
} }
?> ?>

View File

@ -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->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, $this->assertEquals($subsite->ID, $siteHome->SubsiteID,
'createInstance() copies existing pages retaining the same URLSegment' 'createInstance() copies existing pages retaining the same URLSegment'
); );
@ -342,4 +342,4 @@ class SubsiteTest extends SapphireTest {
$subsite2->activate(); $subsite2->activate();
$this->assertEquals('MyNewAwesomePage', DataObject::get_by_id('Page', $page2->ID)->Title); $this->assertEquals('MyNewAwesomePage', DataObject::get_by_id('Page', $page2->ID)->Title);
} }
} }

View File

@ -232,9 +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 //Change to subsite 2
Subsite::changeSubsite($subsite2->ID); 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();
@ -256,4 +256,4 @@ class SubsitesVirtualPageTest extends SapphireTest {
} }
} }
} }