mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 06:05:56 +00:00
Merge branch '3.6' into 3
This commit is contained in:
commit
799ee08251
@ -196,8 +196,8 @@ class SilverStripeNavigatorItem extends ViewableData {
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function isArchived() {
|
public function isArchived() {
|
||||||
if(!$this->record->hasExtension('Versioned')) return false;
|
if(!Object::has_extension($this->record->ClassName, 'Versioned')) return false;
|
||||||
|
|
||||||
if(!isset($this->record->_cached_isArchived)) {
|
if(!isset($this->record->_cached_isArchived)) {
|
||||||
$baseTable = ClassInfo::baseDataClass($this->record->class);
|
$baseTable = ClassInfo::baseDataClass($this->record->class);
|
||||||
$currentDraft = Versioned::get_one_by_stage($baseTable, 'Stage', array(
|
$currentDraft = Versioned::get_one_by_stage($baseTable, 'Stage', array(
|
||||||
@ -294,7 +294,7 @@ class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem {
|
|||||||
|
|
||||||
public function canView($member = null) {
|
public function canView($member = null) {
|
||||||
return (
|
return (
|
||||||
$this->record->hasExtension('Versioned')
|
Object::has_extension($this->record->ClassName, 'Versioned')
|
||||||
&& $this->getDraftPage()
|
&& $this->getDraftPage()
|
||||||
// Don't follow redirects in preview, they break the CMS editing form
|
// Don't follow redirects in preview, they break the CMS editing form
|
||||||
&& !($this->record instanceof RedirectorPage)
|
&& !($this->record instanceof RedirectorPage)
|
||||||
@ -351,7 +351,7 @@ class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem {
|
|||||||
|
|
||||||
public function canView($member = null) {
|
public function canView($member = null) {
|
||||||
return (
|
return (
|
||||||
$this->record->hasExtension('Versioned')
|
Object::has_extension($this->record->ClassName, 'Versioned')
|
||||||
&& $this->getLivePage()
|
&& $this->getLivePage()
|
||||||
// Don't follow redirects in preview, they break the CMS editing form
|
// Don't follow redirects in preview, they break the CMS editing form
|
||||||
&& !($this->record instanceof RedirectorPage)
|
&& !($this->record instanceof RedirectorPage)
|
||||||
@ -418,7 +418,7 @@ class SilverStripeNavigatorItem_ArchiveLink extends SilverStripeNavigatorItem {
|
|||||||
|
|
||||||
public function canView($member = null) {
|
public function canView($member = null) {
|
||||||
return (
|
return (
|
||||||
$this->record->hasExtension('Versioned')
|
Object::has_extension($this->record->ClassName, 'Versioned')
|
||||||
&& $this->isArchived()
|
&& $this->isArchived()
|
||||||
// Don't follow redirects in preview, they break the CMS editing form
|
// Don't follow redirects in preview, they break the CMS editing form
|
||||||
&& !($this->record instanceof RedirectorPage)
|
&& !($this->record instanceof RedirectorPage)
|
||||||
|
@ -419,7 +419,7 @@ class VirtualPage extends Page {
|
|||||||
return $this->CopyContentFrom()->$field;
|
return $this->CopyContentFrom()->$field;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow attributes on the master page to pass
|
* Allow attributes on the master page to pass
|
||||||
@ -514,10 +514,8 @@ class VirtualPage_Controller extends Page_Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getViewer($action) {
|
public function getViewer($action) {
|
||||||
$originalClass = get_class($this->CopyContentFrom());
|
$object = $this->CopyContentFrom();
|
||||||
if ($originalClass == 'SiteTree') $name = 'Page_Controller';
|
$controller = ModelAsController::controller_for($object, $action);
|
||||||
else $name = $originalClass."_Controller";
|
|
||||||
$controller = new $name();
|
|
||||||
return $controller->getViewer($action);
|
return $controller->getViewer($action);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -556,11 +554,8 @@ class VirtualPage_Controller extends Page_Controller {
|
|||||||
*/
|
*/
|
||||||
public function hasMethod($method) {
|
public function hasMethod($method) {
|
||||||
$haveIt = parent::hasMethod($method);
|
$haveIt = parent::hasMethod($method);
|
||||||
if (!$haveIt) {
|
if (!$haveIt) {
|
||||||
$originalClass = get_class($this->CopyContentFrom());
|
$controller = ModelAsController::controller_for($this->CopyContentFrom());
|
||||||
if ($originalClass == 'SiteTree') $name = 'ContentController';
|
|
||||||
else $name = $originalClass."_Controller";
|
|
||||||
$controller = new $name($this->dataRecord->CopyContentFrom());
|
|
||||||
$haveIt = $controller->hasMethod($method);
|
$haveIt = $controller->hasMethod($method);
|
||||||
}
|
}
|
||||||
return $haveIt;
|
return $haveIt;
|
||||||
|
@ -9,7 +9,7 @@ class VirtualPageTest extends FunctionalTest {
|
|||||||
'VirtualPageTest_ClassA',
|
'VirtualPageTest_ClassA',
|
||||||
'VirtualPageTest_ClassB',
|
'VirtualPageTest_ClassB',
|
||||||
'VirtualPageTest_VirtualPageSub',
|
'VirtualPageTest_VirtualPageSub',
|
||||||
'VirtualPageTest_PageWithAllowedChildren'
|
'VirtualPageTest_PageWithAllowedChildren',
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $illegalExtensions = array(
|
protected $illegalExtensions = array(
|
||||||
@ -667,6 +667,27 @@ class VirtualPageTest extends FunctionalTest {
|
|||||||
$this->assertEquals(301, $response->getStatusCode());
|
$this->assertEquals(301, $response->getStatusCode());
|
||||||
$this->assertEquals('http://google.com', $response->getHeader('Location'));
|
$this->assertEquals('http://google.com', $response->getHeader('Location'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testVirtualPageRendersCorrectTemplate() {
|
||||||
|
$self = $this;
|
||||||
|
$this->useDraftSite(true);
|
||||||
|
$this->useTestTheme(dirname(__FILE__), 'virtualpagetest', function() use ($self) {
|
||||||
|
$page = new VirtualPageTest_ClassA();
|
||||||
|
$page->Title = 'Test Page';
|
||||||
|
$page->Content = 'NotThisContent';
|
||||||
|
$page->MyInitiallyCopiedField = 'TestContent';
|
||||||
|
$page->write();
|
||||||
|
|
||||||
|
$vp = new VirtualPage();
|
||||||
|
$vp->CopyContentFromID = $page->ID;
|
||||||
|
$vp->write();
|
||||||
|
|
||||||
|
$response = $self->get($vp->Link());
|
||||||
|
$self->assertEquals(200, $response->getStatusCode());
|
||||||
|
$self->assertContains('TestContent', $response->getBody());
|
||||||
|
$self->assertNotContains('NotThisContent', $response->getBody());
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class VirtualPageTest_ClassA extends Page implements TestOnly {
|
class VirtualPageTest_ClassA extends Page implements TestOnly {
|
||||||
|
1
tests/model/themes/virtualpagetest/Page.ss
Normal file
1
tests/model/themes/virtualpagetest/Page.ss
Normal file
@ -0,0 +1 @@
|
|||||||
|
<div>$Content</div>
|
@ -0,0 +1 @@
|
|||||||
|
<div>$MyInitiallyCopiedField</div>
|
Loading…
x
Reference in New Issue
Block a user