mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 09:05:55 +00:00
Merge pull request #310 from wilr/pulls/4.0/fix-blacklist-toggle
FIX Page type blacklist not matching classes correctly (Fixes 297)
This commit is contained in:
commit
20e1c016f1
@ -1,6 +1,5 @@
|
|||||||
/*jslint browser: true, nomen: true*/
|
/*jslint browser: true, nomen: true*/
|
||||||
/*global $, window, jQuery*/
|
/*global $, window, jQuery*/
|
||||||
|
|
||||||
(function($) {
|
(function($) {
|
||||||
'use strict';
|
'use strict';
|
||||||
$.entwine('ss', function($) {
|
$.entwine('ss', function($) {
|
||||||
@ -13,8 +12,8 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reload subsites dropdown when links are processed
|
* Reload subsites dropdown when links are processed
|
||||||
*/
|
*/
|
||||||
$('.cms-container .cms-menu-list li a').entwine({
|
$('.cms-container .cms-menu-list li a').entwine({
|
||||||
onclick: function(e) {
|
onclick: function(e) {
|
||||||
@ -23,8 +22,8 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reload subsites dropdown when the admin area reloads (for deleting sites)
|
* Reload subsites dropdown when the admin area reloads (for deleting sites)
|
||||||
*/
|
*/
|
||||||
$('.cms-container .SubsiteAdmin .cms-edit-form fieldset.ss-gridfield').entwine({
|
$('.cms-container .SubsiteAdmin .cms-edit-form fieldset.ss-gridfield').entwine({
|
||||||
onreload: function(e) {
|
onreload: function(e) {
|
||||||
@ -35,8 +34,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reload subsites dropdown when subsites are added or names are modified
|
* Reload subsites dropdown when subsites are added or names are modified
|
||||||
*/
|
*/
|
||||||
$('.cms-container .cms-content-fields .subsite-model').entwine({
|
$('.cms-container .cms-content-fields .subsite-model').entwine({
|
||||||
@ -45,7 +44,7 @@
|
|||||||
this._super(e);
|
this._super(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Subsite tab of Group editor
|
// Subsite tab of Group editor
|
||||||
$('#Form_ItemEditForm_AccessAllSubsites').entwine({
|
$('#Form_ItemEditForm_AccessAllSubsites').entwine({
|
||||||
/**
|
/**
|
||||||
@ -53,18 +52,18 @@
|
|||||||
*/
|
*/
|
||||||
onmatch: function () {
|
onmatch: function () {
|
||||||
this.showHideSubsiteList();
|
this.showHideSubsiteList();
|
||||||
|
|
||||||
var ref=this;
|
var ref=this;
|
||||||
$('#Form_ItemEditForm_AccessAllSubsites input').change(function() {
|
$('#Form_ItemEditForm_AccessAllSubsites input').change(function() {
|
||||||
ref.showHideSubsiteList();
|
ref.showHideSubsiteList();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
showHideSubsiteList: function () {
|
showHideSubsiteList: function () {
|
||||||
$('#Form_ItemEditForm_Subsites').parent().parent().css('display', ($('#Form_ItemEditForm_AccessAllSubsites_1').is(':checked') ? 'none':''));
|
$('#Form_ItemEditForm_Subsites').parent().parent().css('display', ($('#Form_ItemEditForm_AccessAllSubsites_1').is(':checked') ? 'none':''));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.cms-edit-form').entwine({
|
$('.cms-edit-form').entwine({
|
||||||
/**
|
/**
|
||||||
* TODO: Fix with Entwine API extension. See https://github.com/silverstripe/silverstripe-subsites/pull/125
|
* TODO: Fix with Entwine API extension. See https://github.com/silverstripe/silverstripe-subsites/pull/125
|
||||||
@ -89,26 +88,6 @@
|
|||||||
return opts;
|
return opts;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
|
||||||
* Binding a visibility toggle anchor to a longer list of checkboxes.
|
|
||||||
* Hidden by default, unless either the toggle checkbox, or any of the
|
|
||||||
* actual value checkboxes are selected.
|
|
||||||
*/
|
|
||||||
$('#PageTypeBlacklist').entwine({
|
|
||||||
onmatch: function() {
|
|
||||||
var hasLimits=Boolean($('#PageTypeBlacklist').find('input:checked').length);
|
|
||||||
jQuery('#PageTypeBlacklist').toggle(hasLimits);
|
|
||||||
|
|
||||||
|
|
||||||
//Bind listener
|
|
||||||
$('a#PageTypeBlacklistToggle').click(function(e) {
|
|
||||||
jQuery('#PageTypeBlacklist').toggle();
|
|
||||||
e.stopPropagation();
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$('.cms-edit-form input[name=action_copytosubsite]').entwine({
|
$('.cms-edit-form input[name=action_copytosubsite]').entwine({
|
||||||
onclick: function(e) {
|
onclick: function(e) {
|
||||||
|
@ -475,9 +475,12 @@ class SiteTreeSubsites extends DataExtension
|
|||||||
{
|
{
|
||||||
// Typically called on a singleton, so we're not using the Subsite() relation
|
// Typically called on a singleton, so we're not using the Subsite() relation
|
||||||
$subsite = Subsite::currentSubsite();
|
$subsite = Subsite::currentSubsite();
|
||||||
|
|
||||||
if ($subsite && $subsite->exists() && $subsite->PageTypeBlacklist) {
|
if ($subsite && $subsite->exists() && $subsite->PageTypeBlacklist) {
|
||||||
$blacklisted = explode(',', $subsite->PageTypeBlacklist);
|
$blacklist = str_replace(['[', '"', ']'], '', $subsite->PageTypeBlacklist);
|
||||||
// All subclasses need to be listed explicitly
|
$blacklist = str_replace(['\\\\'], '\\', $blacklist);
|
||||||
|
$blacklisted = explode(',', $blacklist);
|
||||||
|
|
||||||
if (in_array(get_class($this->owner), $blacklisted)) {
|
if (in_array(get_class($this->owner), $blacklisted)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ use SilverStripe\Forms\LiteralField;
|
|||||||
use SilverStripe\Forms\Tab;
|
use SilverStripe\Forms\Tab;
|
||||||
use SilverStripe\Forms\TabSet;
|
use SilverStripe\Forms\TabSet;
|
||||||
use SilverStripe\Forms\TextField;
|
use SilverStripe\Forms\TextField;
|
||||||
|
use SilverStripe\Forms\ToggleCompositeField;
|
||||||
use SilverStripe\i18n\Data\Intl\IntlLocales;
|
use SilverStripe\i18n\Data\Intl\IntlLocales;
|
||||||
use SilverStripe\i18n\i18n;
|
use SilverStripe\i18n\i18n;
|
||||||
use SilverStripe\ORM\ArrayLib;
|
use SilverStripe\ORM\ArrayLib;
|
||||||
@ -34,6 +35,7 @@ use SilverStripe\Security\Permission;
|
|||||||
use SilverStripe\Security\Security;
|
use SilverStripe\Security\Security;
|
||||||
use SilverStripe\Subsites\State\SubsiteState;
|
use SilverStripe\Subsites\State\SubsiteState;
|
||||||
use SilverStripe\Versioned\Versioned;
|
use SilverStripe\Versioned\Versioned;
|
||||||
|
|
||||||
use UnexpectedValueException;
|
use UnexpectedValueException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -697,18 +699,12 @@ class Subsite extends DataObject
|
|||||||
// new TextField('RedirectURL', 'Redirect to URL', $this->RedirectURL),
|
// new TextField('RedirectURL', 'Redirect to URL', $this->RedirectURL),
|
||||||
CheckboxField::create('DefaultSite', $this->fieldLabel('DefaultSite'), $this->DefaultSite),
|
CheckboxField::create('DefaultSite', $this->fieldLabel('DefaultSite'), $this->DefaultSite),
|
||||||
CheckboxField::create('IsPublic', $this->fieldLabel('IsPublic'), $this->IsPublic),
|
CheckboxField::create('IsPublic', $this->fieldLabel('IsPublic'), $this->IsPublic),
|
||||||
LiteralField::create(
|
ToggleCompositeField::create(
|
||||||
'PageTypeBlacklistToggle',
|
'PageTypeBlacklistToggle',
|
||||||
sprintf(
|
_t(__CLASS__ . '.PageTypeBlacklistField', 'Disallow page types?'),
|
||||||
'<div class="field"><a href="#" id="PageTypeBlacklistToggle">%s</a></div>',
|
[CheckboxSetField::create('PageTypeBlacklist', '', $pageTypeMap)]
|
||||||
_t(__CLASS__ . '.PageTypeBlacklistField', 'Disallow page types?')
|
)->setHeadingLevel(4)
|
||||||
)
|
|
||||||
),
|
|
||||||
CheckboxSetField::create(
|
|
||||||
'PageTypeBlacklist',
|
|
||||||
false,
|
|
||||||
$pageTypeMap
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
HiddenField::create('ID', '', $this->ID),
|
HiddenField::create('ID', '', $this->ID),
|
||||||
@ -721,8 +717,7 @@ class Subsite extends DataObject
|
|||||||
$fields->addFieldToTab(
|
$fields->addFieldToTab(
|
||||||
'Root.Configuration',
|
'Root.Configuration',
|
||||||
DropdownField::create('Theme', $this->fieldLabel('Theme'), $this->allowedThemes(), $this->Theme)
|
DropdownField::create('Theme', $this->fieldLabel('Theme'), $this->allowedThemes(), $this->Theme)
|
||||||
->setEmptyString(_t(__CLASS__ . '.ThemeFieldEmptyString', '-')),
|
->setEmptyString(_t(__CLASS__ . '.ThemeFieldEmptyString', '-'))
|
||||||
'PageTypeBlacklistToggle'
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user