mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
FIX Page type blacklist not matching classes correctly (Fixes 297)
Tidied up the UI, removed custom javascript in favour of core Toggle field.
This commit is contained in:
parent
32385e580d
commit
188b02df6b
@ -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($) {
|
||||||
@ -90,26 +89,6 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
|
||||||
* 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) {
|
||||||
var form = this.closest('form');
|
var form = this.closest('form');
|
||||||
|
@ -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…
Reference in New Issue
Block a user