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
|
||||
*/
|
||||
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)) {
|
||||
$baseTable = ClassInfo::baseDataClass($this->record->class);
|
||||
$currentDraft = Versioned::get_one_by_stage($baseTable, 'Stage', array(
|
||||
@ -294,7 +294,7 @@ class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem {
|
||||
|
||||
public function canView($member = null) {
|
||||
return (
|
||||
$this->record->hasExtension('Versioned')
|
||||
Object::has_extension($this->record->ClassName, 'Versioned')
|
||||
&& $this->getDraftPage()
|
||||
// Don't follow redirects in preview, they break the CMS editing form
|
||||
&& !($this->record instanceof RedirectorPage)
|
||||
@ -351,7 +351,7 @@ class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem {
|
||||
|
||||
public function canView($member = null) {
|
||||
return (
|
||||
$this->record->hasExtension('Versioned')
|
||||
Object::has_extension($this->record->ClassName, 'Versioned')
|
||||
&& $this->getLivePage()
|
||||
// Don't follow redirects in preview, they break the CMS editing form
|
||||
&& !($this->record instanceof RedirectorPage)
|
||||
@ -418,7 +418,7 @@ class SilverStripeNavigatorItem_ArchiveLink extends SilverStripeNavigatorItem {
|
||||
|
||||
public function canView($member = null) {
|
||||
return (
|
||||
$this->record->hasExtension('Versioned')
|
||||
Object::has_extension($this->record->ClassName, 'Versioned')
|
||||
&& $this->isArchived()
|
||||
// Don't follow redirects in preview, they break the CMS editing form
|
||||
&& !($this->record instanceof RedirectorPage)
|
||||
|
@ -419,7 +419,7 @@ class VirtualPage extends Page {
|
||||
return $this->CopyContentFrom()->$field;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Allow attributes on the master page to pass
|
||||
@ -514,10 +514,8 @@ class VirtualPage_Controller extends Page_Controller {
|
||||
}
|
||||
|
||||
public function getViewer($action) {
|
||||
$originalClass = get_class($this->CopyContentFrom());
|
||||
if ($originalClass == 'SiteTree') $name = 'Page_Controller';
|
||||
else $name = $originalClass."_Controller";
|
||||
$controller = new $name();
|
||||
$object = $this->CopyContentFrom();
|
||||
$controller = ModelAsController::controller_for($object, $action);
|
||||
return $controller->getViewer($action);
|
||||
}
|
||||
|
||||
@ -556,11 +554,8 @@ class VirtualPage_Controller extends Page_Controller {
|
||||
*/
|
||||
public function hasMethod($method) {
|
||||
$haveIt = parent::hasMethod($method);
|
||||
if (!$haveIt) {
|
||||
$originalClass = get_class($this->CopyContentFrom());
|
||||
if ($originalClass == 'SiteTree') $name = 'ContentController';
|
||||
else $name = $originalClass."_Controller";
|
||||
$controller = new $name($this->dataRecord->CopyContentFrom());
|
||||
if (!$haveIt) {
|
||||
$controller = ModelAsController::controller_for($this->CopyContentFrom());
|
||||
$haveIt = $controller->hasMethod($method);
|
||||
}
|
||||
return $haveIt;
|
||||
|
@ -9,7 +9,7 @@ class VirtualPageTest extends FunctionalTest {
|
||||
'VirtualPageTest_ClassA',
|
||||
'VirtualPageTest_ClassB',
|
||||
'VirtualPageTest_VirtualPageSub',
|
||||
'VirtualPageTest_PageWithAllowedChildren'
|
||||
'VirtualPageTest_PageWithAllowedChildren',
|
||||
);
|
||||
|
||||
protected $illegalExtensions = array(
|
||||
@ -667,6 +667,27 @@ class VirtualPageTest extends FunctionalTest {
|
||||
$this->assertEquals(301, $response->getStatusCode());
|
||||
$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 {
|
||||
|
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