mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge branch 'master' into new-orm
This commit is contained in:
commit
15d01a3472
@ -33,3 +33,5 @@ Object::add_extension('File', 'SiteTreeFileExtension');
|
||||
// TODO Remove once we can configure CMSMenu through static, nested configuration files
|
||||
CMSMenu::remove_menu_item('CMSPageEditController');
|
||||
CMSMenu::remove_menu_item('CMSPageSettingsController');
|
||||
CMSMenu::remove_menu_item('CMSPageHistoryController');
|
||||
CMSMenu::remove_menu_item('CMSPageReportsController');
|
@ -139,7 +139,6 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
* Return the entire site tree as a nested set of ULs
|
||||
*/
|
||||
public function SiteTreeAsUL() {
|
||||
$this->generateDataTreeHints();
|
||||
$this->generateTreeStylingJS();
|
||||
|
||||
// Pre-cache sitetree version numbers for querying efficiency
|
||||
@ -172,8 +171,10 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
|
||||
$fields = new FieldSet(
|
||||
new TextField('Term', _t('CMSSearch.FILTERLABELTEXT', 'Content')),
|
||||
$dateGroup = new FieldGroup(
|
||||
$dateFrom = new DateField('LastEditedFrom', _t('CMSSearch.FilterDateFrom', 'from')),
|
||||
$dateTo = new DateField('LastEditedTo', _t('CMSSearch.FilterDateFrom', 'to')),
|
||||
$dateTo = new DateField('LastEditedTo', _t('CMSSearch.FilterDateFrom', 'to'))
|
||||
),
|
||||
new DropdownField(
|
||||
'FilterClass',
|
||||
_t('CMSMain.SearchTreeFormPagesDropdown', 'Pages'),
|
||||
@ -189,6 +190,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
)
|
||||
// new TextField('MetaTags', _t('CMSMain.SearchMetaTags', 'Meta tags'))
|
||||
);
|
||||
$dateGroup->subfieldParam = 'FieldHolder';
|
||||
$dateFrom->setConfig('showcalendar', true);
|
||||
$dateTo->setConfig('showcalendar', true);
|
||||
|
||||
@ -210,27 +212,43 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
return $this->getsubtree($this->request);
|
||||
}
|
||||
|
||||
public function generateDataTreeHints() {
|
||||
/**
|
||||
* Create serialized JSON string with site tree hints data to be injected into
|
||||
* 'data-hints' attribute of root node of jsTree.
|
||||
*
|
||||
* @return String Serialized JSON
|
||||
*/
|
||||
public function SiteTreeHints() {
|
||||
$classes = ClassInfo::subclassesFor( $this->stat('tree_class') );
|
||||
|
||||
$def['Root'] = array();
|
||||
$def['Root']['disallowedChildren'] = array();
|
||||
$def['Root']['disallowedParents'] = array();
|
||||
|
||||
foreach($classes as $class) {
|
||||
$obj = singleton($class);
|
||||
if($obj instanceof HiddenClass) continue;
|
||||
|
||||
$allowedChildren = $obj->allowedChildren();
|
||||
if($allowedChildren != "none") $def[$class]['allowedChildren'] = $allowedChildren;
|
||||
$def[$class]['defaultChild'] = $obj->defaultChild();
|
||||
$def[$class]['defaultParent'] = isset(SiteTree::get_by_link($obj->defaultParent())->ID) ? SiteTree::get_by_link($obj->defaultParent())->ID : null;
|
||||
//SiteTree::allowedChildren() returns null rather than an empty array if SiteTree::allowed_chldren == 'none'
|
||||
if ($allowedChildren == null) $allowedChildren = array();
|
||||
$def[$class]['disallowedChildren'] = array_keys(array_diff($classes, $allowedChildren));
|
||||
|
||||
if($obj->stat('can_be_root')) {
|
||||
$def['Root']['allowedChildren'][] = $class;
|
||||
}
|
||||
$defaultChild = $obj->defaultChild();
|
||||
if ($defaultChild != 'Page' && $defaultChild != null) $def[$class]['defaultChild'] = $defaultChild;
|
||||
|
||||
$defaultParent = isset(SiteTree::get_by_link($obj->defaultParent())->ID) ? SiteTree::get_by_link($obj->defaultParent())->ID : null;
|
||||
if ($defaultParent != 1 && $defaultParent != null) $def[$class]['defaultParent'] = $defaultParent;
|
||||
|
||||
if(is_array($def[$class]['disallowedChildren'])) foreach($def[$class]['disallowedChildren'] as $disallowedChild) {
|
||||
$def[$disallowedChild]['disallowedParents'][] = $class;
|
||||
}
|
||||
|
||||
// Put data hints into a script tag at the top
|
||||
Requirements::customScript("siteTreeHints = " . Convert::raw2json($def) . ";");
|
||||
//Are any classes allowed to be parents of root?
|
||||
$def['Root']['disallowedParents'][] = $class;
|
||||
}
|
||||
|
||||
return Convert::raw2xml(Convert::raw2json($def));
|
||||
}
|
||||
|
||||
public function generateTreeStylingJS() {
|
||||
@ -1279,6 +1297,8 @@ JS;
|
||||
|
||||
$fields = new FieldSet(
|
||||
// new HiddenField("ParentID", false, ($this->parentRecord) ? $this->parentRecord->ID : null),
|
||||
// TODO Should be part of the form attribute, but not possible in current form API
|
||||
$hintsField = new LiteralField('Hints', sprintf('<span class="hints" data-hints="%s"></span>', $this->SiteTreeHints())),
|
||||
$parentField = new TreeDropdownField("ParentID", _t('CMSMain.AddFormParentLabel', 'Parent page'), 'SiteTree'),
|
||||
new OptionsetField("PageType", "", $pageTypes, 'Page')
|
||||
);
|
||||
@ -1294,6 +1314,7 @@ JS;
|
||||
$this->extend('updatePageOptions', $fields);
|
||||
|
||||
$form = new Form($this, "AddForm", $fields, $actions);
|
||||
$form->addExtraClass('cms-add-form');
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
@ -7,7 +7,15 @@ class CMSPageEditController extends CMSMain {
|
||||
|
||||
function getEditForm($id = null, $fields = null) {
|
||||
$record = $this->getRecord($id ? $id : $this->currentPageID());
|
||||
return parent::getEditForm($record, ($record) ? $record->getCMSFields() : null);
|
||||
$form = parent::getEditForm($record, ($record) ? $record->getCMSFields() : null);
|
||||
|
||||
// TODO Replace with preview button
|
||||
$form->Fields()->addFieldToTab(
|
||||
'Root.Main',
|
||||
new LiteralField('SwitchView', sprintf('<div class="cms-switch-view field"><label>Preview:</label><div class="middleColumn">%s</div></div>', $this->SwitchView()))
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
12
code/controller/CMSPageHistoryController.php
Normal file
12
code/controller/CMSPageHistoryController.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
class CMSPageHistoryController extends CMSMain {
|
||||
|
||||
static $url_segment = 'page/history';
|
||||
static $url_rule = '/$Action/$ID/$OtherID';
|
||||
static $url_priority = 42;
|
||||
|
||||
function getEditForm($id = null, $fields = null) {
|
||||
return "Not implemented yet";
|
||||
}
|
||||
|
||||
}
|
12
code/controller/CMSPageReportsController.php
Normal file
12
code/controller/CMSPageReportsController.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
class CMSPageReportsController extends CMSMain {
|
||||
|
||||
static $url_segment = 'page/reports';
|
||||
static $url_rule = '/$Action/$ID/$OtherID';
|
||||
static $url_priority = 42;
|
||||
|
||||
function getEditForm($id = null, $fields = null) {
|
||||
return "Not implemented yet";
|
||||
}
|
||||
|
||||
}
|
@ -7,10 +7,11 @@
|
||||
abstract class SiteTreeDecorator extends SiteTreeExtension {
|
||||
|
||||
public function __construct() {
|
||||
user_error(
|
||||
'SiteTreeDecorator is deprecated, please use SiteTreeExtension instead.',
|
||||
E_USER_NOTICE
|
||||
);
|
||||
// TODO Re-enable before we release 3.0 beta, for now it "breaks" too many modules
|
||||
// user_error(
|
||||
// 'SiteTreeDecorator is deprecated, please use SiteTreeExtension instead.',
|
||||
// E_USER_NOTICE
|
||||
// );
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,57 @@
|
||||
this._super();
|
||||
},
|
||||
onclick: function() {
|
||||
this.parents('li:first').addClass('selected').siblings().removeClass('selected');
|
||||
var el = this.parents('li:first');
|
||||
el.setSelected(true);
|
||||
el.siblings().setSelected(false);
|
||||
}
|
||||
});
|
||||
|
||||
$(".cms-add-form").entwine({
|
||||
onmatch: function() {
|
||||
var self = this;
|
||||
this.find('#ParentID .TreeDropdownField').bind('change', function() {
|
||||
self.updateTypeList();
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Limit page type selection based on parent class.
|
||||
* Similar implementation to LeftAndMain.Tree.js.
|
||||
*/
|
||||
updateTypeList: function() {
|
||||
var hints = this.find('.hints').data('hints'),
|
||||
metadata = this.find('#ParentID .TreeDropdownField').data('metadata'),
|
||||
id = this.find('#ParentID .TreeDropdownField').getValue(),
|
||||
newClassName = metadata[0].ClassName,
|
||||
disallowedChildren = hints[newClassName ? newClassName : 'Root'].disallowedChildren || [],
|
||||
defaultChildClass = hints[newClassName ? newClassName : 'Root'].defaultChild || null;
|
||||
|
||||
// Limit selection
|
||||
this.find('#PageType li').each(function() {
|
||||
var className = $(this).find('input').val(), isAllowed = ($.inArray(className, disallowedChildren) == -1);
|
||||
$(this).setEnabled(isAllowed);
|
||||
});
|
||||
|
||||
// Set default child selection, or fall back to first available option
|
||||
if(defaultChildClass) {
|
||||
var selectedEl = this.find('#PageType li input[value=' + defaultChildClass + ']').parents('li:first');
|
||||
} else {
|
||||
var selectedEl = this.find('#PageType li:not(.disabled):first');
|
||||
}
|
||||
selectedEl.setSelected(true);
|
||||
selectedEl.siblings().setSelected(false);
|
||||
}
|
||||
});
|
||||
|
||||
$(".cms-add-form #PageType li").entwine({
|
||||
setSelected: function(bool) {
|
||||
this.toggleClass('selected', bool);
|
||||
this.find('input').attr('checked', bool ? 'checked' : null);
|
||||
},
|
||||
setEnabled: function(bool) {
|
||||
$(this).toggleClass('disabled', bool);
|
||||
$(this).find('input').attr('disabled', bool ? '' : 'disabled');
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -173,21 +173,22 @@
|
||||
* Toggle display of group dropdown in "access" tab,
|
||||
* based on selection of radiobuttons.
|
||||
*/
|
||||
$('.cms-edit-form #CanViewType, .cms-edit-form #CanEditType').entwine({
|
||||
$('.cms-edit-form #CanViewType, .cms-edit-form #CanEditType, .cms-edit-form #CanCreateTopLevelType').entwine({
|
||||
// Constructor: onmatch
|
||||
onmatch: function() {
|
||||
// TODO Decouple
|
||||
var dropdown;
|
||||
if(this.attr('id') == 'CanViewType') dropdown = $('#ViewerGroups');
|
||||
else if(this.attr('id') == 'CanEditType') dropdown = $('#EditorGroups');
|
||||
else if(this.attr('id') == 'CanCreateTopLevelType') dropdown = $('#CreateTopLevelGroups');
|
||||
|
||||
this.find('.optionset :input').bind('change', function(e) {
|
||||
dropdown.toggle(e.target.value == 'OnlyTheseUsers');
|
||||
dropdown[e.target.value == 'OnlyTheseUsers' ? 'show' : 'hide']();
|
||||
});
|
||||
|
||||
// initial state
|
||||
var currentVal = this.find('input[name=' + this.attr('id') + ']:checked').val();
|
||||
dropdown.toggle(currentVal == 'OnlyTheseUsers');
|
||||
dropdown[currentVal == 'OnlyTheseUsers' ? 'show' : 'hide']();
|
||||
|
||||
this._super();
|
||||
}
|
||||
|
@ -35,10 +35,10 @@
|
||||
$EditForm
|
||||
</div>
|
||||
<div id="cms-content-treeview">
|
||||
...
|
||||
<i>Not implemented yet</i>
|
||||
</div>
|
||||
<div id="cms-content-galleryview">
|
||||
...
|
||||
<i>Not implemented yet</i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
3
templates/Includes/CMSPageHistoryController_Content.ss
Normal file
3
templates/Includes/CMSPageHistoryController_Content.ss
Normal file
@ -0,0 +1,3 @@
|
||||
<div class="cms-content center">
|
||||
<i>Not implemented yet</i>
|
||||
</div>
|
3
templates/Includes/CMSPageReportsController_Content.ss
Normal file
3
templates/Includes/CMSPageReportsController_Content.ss
Normal file
@ -0,0 +1,3 @@
|
||||
<div class="cms-content center">
|
||||
<i>Not implemented yet</i>
|
||||
</div>
|
@ -34,14 +34,10 @@
|
||||
<% include CMSPagesController_ContentToolbar %>
|
||||
</div>
|
||||
|
||||
<div class="cms-tree" data-url-tree="$Link(getsubtree)" data-url-savetreenode="$Link(savetreenode)">
|
||||
<div class="cms-tree" data-url-tree="$Link(getsubtree)" data-url-savetreenode="$Link(savetreenode)" data-hints="$SiteTreeHints">
|
||||
$SiteTreeAsUL
|
||||
</div>
|
||||
|
||||
<div class="cms-content-toolbar">
|
||||
<% include CMSPagesController_ContentToolbar %>
|
||||
</div>
|
||||
|
||||
<div class="ss-dialog cms-page-add-form-dialog" id="cms-page-add-form" title="<% _t('CMSMain.ChoosePageType', 'Choose a page type') %>">
|
||||
$AddForm
|
||||
</div>
|
||||
@ -49,11 +45,11 @@
|
||||
</div>
|
||||
|
||||
<div id="cms-content-listview">
|
||||
...
|
||||
<i>Not implemented yet</i>
|
||||
</div>
|
||||
|
||||
<div id="cms-content-galleryview">
|
||||
...
|
||||
<i>Not implemented yet</i>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user