mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-06-30 08:29:34 +02:00
Merge remote-tracking branch 'origin/3.1'
This commit is contained in:
commit
c62f992dc3
|
@ -41,7 +41,8 @@ class CMSSettingsController extends LeftAndMain {
|
||||||
$this, 'EditForm', $fields, $actions
|
$this, 'EditForm', $fields, $actions
|
||||||
)->setHTMLID('Form_EditForm');
|
)->setHTMLID('Form_EditForm');
|
||||||
$form->setResponseNegotiator($this->getResponseNegotiator());
|
$form->setResponseNegotiator($this->getResponseNegotiator());
|
||||||
$form->addExtraClass('cms-add-form cms-content center cms-edit-form');
|
$form->addExtraClass('root-form');
|
||||||
|
$form->addExtraClass('cms-edit-form cms-panel-padded center');
|
||||||
// don't add data-pjax-fragment=CurrentForm, its added in the content template instead
|
// don't add data-pjax-fragment=CurrentForm, its added in the content template instead
|
||||||
|
|
||||||
if($form->Fields()->hasTabset()) $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
|
if($form->Fields()->hasTabset()) $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
|
||||||
|
|
|
@ -103,10 +103,25 @@ class ContentController extends Controller {
|
||||||
|
|
||||||
// Check page permissions
|
// Check page permissions
|
||||||
if($this->dataRecord && $this->URLSegment != 'Security' && !$this->dataRecord->canView()) {
|
if($this->dataRecord && $this->URLSegment != 'Security' && !$this->dataRecord->canView()) {
|
||||||
$permissionMessage = null;
|
return Security::permissionFailure($this);
|
||||||
|
}
|
||||||
|
|
||||||
// Check if we could view the live version, offer redirect if so
|
// Draft/Archive security check - only CMS users should be able to look at stage/archived content
|
||||||
if($this->canViewStage('Live')) {
|
if(
|
||||||
|
$this->URLSegment != 'Security'
|
||||||
|
&& !Session::get('unsecuredDraftSite')
|
||||||
|
&& (
|
||||||
|
Versioned::current_archived_date()
|
||||||
|
|| (Versioned::current_stage() && Versioned::current_stage() != 'Live')
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
if(!$this->dataRecord->canViewStage(Versioned::current_archived_date() ? 'Stage' : Versioned::current_stage())) {
|
||||||
|
$link = $this->Link();
|
||||||
|
$message = _t(
|
||||||
|
"ContentController.DRAFT_SITE_ACCESS_RESTRICTION",
|
||||||
|
'You must log in with your CMS password in order to view the draft or archived content. ' .
|
||||||
|
'<a href="%s">Click here to go back to the published site.</a>'
|
||||||
|
);
|
||||||
Session::clear('currentStage');
|
Session::clear('currentStage');
|
||||||
Session::clear('archiveDate');
|
Session::clear('archiveDate');
|
||||||
|
|
||||||
|
@ -118,9 +133,10 @@ class ContentController extends Controller {
|
||||||
),
|
),
|
||||||
Controller::join_links($this->Link(), "?stage=Live")
|
Controller::join_links($this->Link(), "?stage=Live")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return Security::permissionFailure($this, $permissionMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Security::permissionFailure($this, $permissionMessage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use theme from the site config
|
// Use theme from the site config
|
||||||
|
@ -215,7 +231,7 @@ class ContentController extends Controller {
|
||||||
$response = $this->request->isMedia() ? null : ErrorPage::response_for($code);
|
$response = $this->request->isMedia() ? null : ErrorPage::response_for($code);
|
||||||
// Failover to $message if the HTML response is unavailable / inappropriate
|
// Failover to $message if the HTML response is unavailable / inappropriate
|
||||||
parent::httpError($code, $response ? $response : $message);
|
parent::httpError($code, $response ? $response : $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the project name
|
* Get the project name
|
||||||
|
|
|
@ -841,8 +841,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$fromLive
|
if(!$fromLive
|
||||||
&& !Session::get('unsecuredDraftSite')
|
&& !Session::get('unsecuredDraftSite')
|
||||||
&& !Permission::checkMember($member, array('CMS_ACCESS_CMSMain', 'VIEW_DRAFT_CONTENT'))) {
|
&& !Permission::checkMember($member, array('CMS_ACCESS_CMSMain', 'VIEW_DRAFT_CONTENT'))) {
|
||||||
// If we weren't definitely loaded from live, and we can't view non-live content, we need to
|
// If we weren't definitely loaded from live, and we can't view non-live content, we need to
|
||||||
// check to make sure this version is the live version and so can be viewed
|
// check to make sure this version is the live version and so can be viewed
|
||||||
if (Versioned::get_versionnumber_by_stage($this->class, 'Live', $this->ID) != $this->Version) return false;
|
if (Versioned::get_versionnumber_by_stage($this->class, 'Live', $this->ID) != $this->Version) return false;
|
||||||
|
@ -1607,7 +1607,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||||
);
|
);
|
||||||
|
|
||||||
return !($existingPage);
|
return !($existingPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a URL segment based on the title provided.
|
* Generate a URL segment based on the title provided.
|
||||||
|
@ -1712,7 +1712,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||||
foreach($contentLinks as $item) {
|
foreach($contentLinks as $item) {
|
||||||
$item->DependentLinkType = 'Content link';
|
$item->DependentLinkType = 'Content link';
|
||||||
$linkList->push($item);
|
$linkList->push($item);
|
||||||
}
|
}
|
||||||
$items->merge($linkList);
|
$items->merge($linkList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1724,9 +1724,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||||
foreach($virtuals as $item) {
|
foreach($virtuals as $item) {
|
||||||
$item->DependentLinkType = 'Virtual page';
|
$item->DependentLinkType = 'Virtual page';
|
||||||
$virtualList->push($item);
|
$virtualList->push($item);
|
||||||
}
|
|
||||||
$items->merge($virtualList);
|
|
||||||
}
|
}
|
||||||
|
$items->merge($virtualList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redirector pages
|
// Redirector pages
|
||||||
|
@ -1736,7 +1736,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||||
foreach($redirectors as $item) {
|
foreach($redirectors as $item) {
|
||||||
$item->DependentLinkType = 'Redirector page';
|
$item->DependentLinkType = 'Redirector page';
|
||||||
$redirectorList->push($item);
|
$redirectorList->push($item);
|
||||||
}
|
}
|
||||||
$items->merge($redirectorList);
|
$items->merge($redirectorList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1999,9 +1999,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||||
->setAttribute(
|
->setAttribute(
|
||||||
'data-placeholder',
|
'data-placeholder',
|
||||||
_t('SiteTree.GroupPlaceholder', 'Click to select group')
|
_t('SiteTree.GroupPlaceholder', 'Click to select group')
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$visibility->setTitle($this->fieldLabel('Visibility'));
|
$visibility->setTitle($this->fieldLabel('Visibility'));
|
||||||
|
@ -2226,7 +2226,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||||
// Set up the initial state of the button to reflect the state of the underlying SiteTree object.
|
// Set up the initial state of the button to reflect the state of the underlying SiteTree object.
|
||||||
if($this->stagesDiffer('Stage', 'Live')) {
|
if($this->stagesDiffer('Stage', 'Live')) {
|
||||||
$publish->addExtraClass('ss-ui-alternate');
|
$publish->addExtraClass('ss-ui-alternate');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$actions = new FieldList(array($majorActions, $rootTabSet));
|
$actions = new FieldList(array($majorActions, $rootTabSet));
|
||||||
|
@ -2666,7 +2666,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||||
|
|
||||||
if(!$this->canEdit() && !$this->canAddChildren()) {
|
if(!$this->canEdit() && !$this->canAddChildren()) {
|
||||||
if (!$this->canView()) {
|
if (!$this->canView()) {
|
||||||
$classes .= " disabled";
|
$classes .= " disabled";
|
||||||
} else {
|
} else {
|
||||||
$classes .= " edit-disabled";
|
$classes .= " edit-disabled";
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,37 @@
|
||||||
|
|
||||||
$.entwine('ss.tree', function($){
|
$.entwine('ss.tree', function($){
|
||||||
$('.cms-tree').entwine({
|
$('.cms-tree').entwine({
|
||||||
|
fromDocument: {
|
||||||
|
'oncontext_show.vakata': function(e){
|
||||||
|
this.adjustContextClass();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/*
|
||||||
|
* Add and remove classes from context menus to allow for
|
||||||
|
* adjusting the display
|
||||||
|
*/
|
||||||
|
adjustContextClass: function(){
|
||||||
|
var menus = $('#vakata-contextmenu').find("ul ul");
|
||||||
|
|
||||||
|
menus.each(function(i){
|
||||||
|
var col = "1",
|
||||||
|
count = $(menus[i]).find('li').length;
|
||||||
|
|
||||||
|
//Assign columns to menus over 10 items long
|
||||||
|
if(count > 20){
|
||||||
|
col = "3";
|
||||||
|
}else if(count > 10){
|
||||||
|
col = "2";
|
||||||
|
}
|
||||||
|
|
||||||
|
$(menus[i]).addClass('col-' + col).removeClass('right');
|
||||||
|
|
||||||
|
//Remove "right" class that jstree adds on mouseenter
|
||||||
|
$(menus[i]).find('li').on("mouseenter", function (e) {
|
||||||
|
$(this).parent('ul').removeClass("right");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
getTreeConfig: function() {
|
getTreeConfig: function() {
|
||||||
var self = this, config = this._super(), hints = this.getHints();
|
var self = this, config = this._super(), hints = this.getHints();
|
||||||
config.plugins.push('contextmenu');
|
config.plugins.push('contextmenu');
|
||||||
|
@ -110,6 +141,18 @@
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Scroll tree down to context of the current page
|
||||||
|
$('.cms-tree a.jstree-clicked').entwine({
|
||||||
|
onmatch: function(){
|
||||||
|
var self = this,
|
||||||
|
panel = self.parents('.cms-panel-content');
|
||||||
|
|
||||||
|
panel.animate({
|
||||||
|
scrollTop: self.offset().top - (panel.height() / 2)
|
||||||
|
}, 'slow');
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}(jQuery));
|
}(jQuery));
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<div id="settings-controller-cms-content" class="cms-content cms-edit-form center cms-tabset $BaseCSSClasses" data-layout-type="border" data-pjax-fragment="Content CurrentForm">
|
<div id="settings-controller-cms-content" class="cms-content center cms-tabset $BaseCSSClasses" data-layout-type="border" data-pjax-fragment="Content CurrentForm">
|
||||||
|
|
||||||
<div class="cms-content-header north">
|
<div class="cms-content-header north">
|
||||||
<% with $EditForm %>
|
<% with $EditForm %>
|
||||||
|
@ -7,10 +7,9 @@
|
||||||
<% include CMSBreadcrumbs %>
|
<% include CMSBreadcrumbs %>
|
||||||
<% end_with %>
|
<% end_with %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% if $Fields.hasTabset %>
|
<% if $Fields.hasTabset %>
|
||||||
<% with $Fields.fieldByName('Root') %>
|
<% with $Fields.fieldByName('Root') %>
|
||||||
<div class="cms-content-header-tabs cms-tabset-nav-primary ss-ui-tabs-nav">
|
<div class="cms-content-header-tabs">
|
||||||
<ul class="cms-tabset-nav-primary">
|
<ul class="cms-tabset-nav-primary">
|
||||||
<% loop $Tabs %>
|
<% loop $Tabs %>
|
||||||
<li<% if $extraClass %> class="$extraClass"<% end_if %>><a href="#$id">$Title</a></li>
|
<li<% if $extraClass %> class="$extraClass"<% end_if %>><a href="#$id">$Title</a></li>
|
||||||
|
|
|
@ -1,33 +1,29 @@
|
||||||
<form $FormAttributes data-layout-type="border">
|
<form $FormAttributes>
|
||||||
|
|
||||||
<div class="cms-content-fields center">
|
<% if $Message %>
|
||||||
<% if $Message %>
|
<p id="{$FormName}_error" class="message $MessageType">$Message</p>
|
||||||
<p id="{$FormName}_error" class="message $MessageType">$Message</p>
|
<% else %>
|
||||||
<% else %>
|
<p id="{$FormName}_error" class="message $MessageType" style="display: none"></p>
|
||||||
<p id="{$FormName}_error" class="message $MessageType" style="display: none"></p>
|
<% end_if %>
|
||||||
<% end_if %>
|
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<% if $Legend %><legend>$Legend</legend><% end_if %>
|
<% if $Legend %><legend>$Legend</legend><% end_if %>
|
||||||
<% loop $Fields %>
|
<% loop $Fields %>
|
||||||
$FieldHolder
|
$FieldHolder
|
||||||
<% end_loop %>
|
<% end_loop %>
|
||||||
<div class="clear"><!-- --></div>
|
<div class="clear"><!-- --></div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="cms-content-actions cms-content-controls south">
|
<% if $Actions %>
|
||||||
<% if $Actions %>
|
<div class="Actions">
|
||||||
<div class="Actions">
|
<% loop $Actions %>
|
||||||
<% loop $Actions %>
|
$Field
|
||||||
$Field
|
<% end_loop %>
|
||||||
<% end_loop %>
|
<% if $Controller.LinkPreview %>
|
||||||
<% if $Controller.LinkPreview %>
|
<a href="$Controller.LinkPreview" class="cms-preview-toggle-link ss-ui-button" data-icon="preview">
|
||||||
<a href="$Controller.LinkPreview" class="cms-preview-toggle-link ss-ui-button" data-icon="preview">
|
<% _t('LeftAndMain.PreviewButton', 'Preview') %> »
|
||||||
<% _t('LeftAndMain.PreviewButton', 'Preview') %> »
|
</a>
|
||||||
</a>
|
|
||||||
<% end_if %>
|
|
||||||
</div>
|
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
</div>
|
</div>
|
||||||
|
<% end_if %>
|
||||||
</form>
|
</form>
|
|
@ -109,7 +109,6 @@ class ZZZSearchFormTest extends FunctionalTest {
|
||||||
|
|
||||||
$page = $this->objFromFixture('SiteTree', 'restrictedViewLoggedInUsers');
|
$page = $this->objFromFixture('SiteTree', 'restrictedViewLoggedInUsers');
|
||||||
$page->publish('Stage', 'Live');
|
$page->publish('Stage', 'Live');
|
||||||
|
|
||||||
$results = $sf->getResults(null, array('Search'=>'restrictedViewLoggedInUsers'));
|
$results = $sf->getResults(null, array('Search'=>'restrictedViewLoggedInUsers'));
|
||||||
$this->assertNotContains(
|
$this->assertNotContains(
|
||||||
$page->ID,
|
$page->ID,
|
||||||
|
@ -135,7 +134,6 @@ class ZZZSearchFormTest extends FunctionalTest {
|
||||||
|
|
||||||
$page = $this->objFromFixture('SiteTree', 'restrictedViewOnlyWebsiteUsers');
|
$page = $this->objFromFixture('SiteTree', 'restrictedViewOnlyWebsiteUsers');
|
||||||
$page->publish('Stage', 'Live');
|
$page->publish('Stage', 'Live');
|
||||||
|
|
||||||
$results = $sf->getResults(null, array('Search'=>'restrictedViewOnlyWebsiteUsers'));
|
$results = $sf->getResults(null, array('Search'=>'restrictedViewOnlyWebsiteUsers'));
|
||||||
$this->assertNotContains(
|
$this->assertNotContains(
|
||||||
$page->ID,
|
$page->ID,
|
||||||
|
@ -165,8 +163,6 @@ class ZZZSearchFormTest extends FunctionalTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInheritedRestrictedPagesNotIncluded() {
|
public function testInheritedRestrictedPagesNotIncluded() {
|
||||||
if(!$this->checkFulltextSupport()) return;
|
|
||||||
|
|
||||||
$sf = new SearchForm($this->mockController, 'SearchForm');
|
$sf = new SearchForm($this->mockController, 'SearchForm');
|
||||||
|
|
||||||
$parent = $this->objFromFixture('SiteTree', 'restrictedViewLoggedInUsers');
|
$parent = $this->objFromFixture('SiteTree', 'restrictedViewLoggedInUsers');
|
||||||
|
@ -174,7 +170,6 @@ class ZZZSearchFormTest extends FunctionalTest {
|
||||||
|
|
||||||
$page = $this->objFromFixture('SiteTree', 'inheritRestrictedView');
|
$page = $this->objFromFixture('SiteTree', 'inheritRestrictedView');
|
||||||
$page->publish('Stage', 'Live');
|
$page->publish('Stage', 'Live');
|
||||||
|
|
||||||
$results = $sf->getResults(null, array('Search'=>'inheritRestrictedView'));
|
$results = $sf->getResults(null, array('Search'=>'inheritRestrictedView'));
|
||||||
$this->assertNotContains(
|
$this->assertNotContains(
|
||||||
$page->ID,
|
$page->ID,
|
||||||
|
@ -232,6 +227,10 @@ class ZZZSearchFormTest extends FunctionalTest {
|
||||||
public function testSearchTitleAndContentWithSpecialCharacters() {
|
public function testSearchTitleAndContentWithSpecialCharacters() {
|
||||||
if(!$this->checkFulltextSupport()) return;
|
if(!$this->checkFulltextSupport()) return;
|
||||||
|
|
||||||
|
if(class_exists('PostgreSQLDatabase') && DB::getConn() instanceof PostgreSQLDatabase) {
|
||||||
|
$this->markTestSkipped("PostgreSQLDatabase doesn't support entity-encoded searches");
|
||||||
|
}
|
||||||
|
|
||||||
$sf = new SearchForm($this->mockController, 'SearchForm');
|
$sf = new SearchForm($this->mockController, 'SearchForm');
|
||||||
|
|
||||||
$pageWithSpecialChars = $this->objFromFixture('SiteTree', 'pageWithSpecialChars');
|
$pageWithSpecialChars = $this->objFromFixture('SiteTree', 'pageWithSpecialChars');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user