mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
BUGFIX Fixed "add page" action when invoked through tree context menu (and removed URL hardcoding in JS) (fixes #7155)
This commit is contained in:
parent
8c1651ec59
commit
98a0331a48
@ -157,12 +157,11 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
return $this->LinkWithSearch(singleton('CMSMain')->Link('galleryview'));
|
return $this->LinkWithSearch(singleton('CMSMain')->Link('galleryview'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function LinkPageEdit() {
|
public function LinkPageEdit($id = null) {
|
||||||
if($id = $this->currentPageID()) {
|
if(!$id) $id = $this->currentPageID();
|
||||||
return $this->LinkWithSearch(
|
return $this->LinkWithSearch(
|
||||||
Controller::join_links(singleton('CMSPageEditController')->Link('show'), $id)
|
Controller::join_links(singleton('CMSPageEditController')->Link('show'), $id)
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function LinkPageSettings() {
|
public function LinkPageSettings() {
|
||||||
|
@ -16,18 +16,6 @@ class CMSPageAddController extends CMSPageEditController {
|
|||||||
* @return Form
|
* @return Form
|
||||||
*/
|
*/
|
||||||
function AddForm() {
|
function AddForm() {
|
||||||
// If request send from rightclick-submenu, directly add Page
|
|
||||||
if(($pageType = $this->request->getVar('Type')) && ($parentID = $this->request->getVar('ParentID'))) {
|
|
||||||
$data = array(
|
|
||||||
"PageType" => (string)$pageType,
|
|
||||||
"ParentID" => $parentID,
|
|
||||||
"ParentModeField" => "child"
|
|
||||||
);
|
|
||||||
$this->doAdd($data, null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$record = $this->currentPage();
|
$record = $this->currentPage();
|
||||||
|
|
||||||
$pageTypes = array();
|
$pageTypes = array();
|
||||||
|
@ -3,8 +3,7 @@
|
|||||||
$.entwine('ss', function($){
|
$.entwine('ss', function($){
|
||||||
$('.cms-tree').entwine({
|
$('.cms-tree').entwine({
|
||||||
getTreeConfig: function() {
|
getTreeConfig: function() {
|
||||||
var config = this._super();
|
var self = this, config = this._super(), hints = this.getHints();
|
||||||
var hints = this.getHints();
|
|
||||||
config.plugins.push('contextmenu');
|
config.plugins.push('contextmenu');
|
||||||
config.contextmenu = {
|
config.contextmenu = {
|
||||||
'items': function(node) {
|
'items': function(node) {
|
||||||
@ -19,8 +18,9 @@
|
|||||||
'label': '<span class="jstree-pageicon"></span>' + val.ssname,
|
'label': '<span class="jstree-pageicon"></span>' + val.ssname,
|
||||||
'_class': 'class-' + val.ssclass,
|
'_class': 'class-' + val.ssclass,
|
||||||
'action': function(obj) {
|
'action': function(obj) {
|
||||||
// TODO Fix hardcoding of link
|
$('.cms-container').loadPanel(ss.i18n.sprintf(
|
||||||
$('.cms-container').loadPanel('admin/pages/add/?ParentID=' + id + '&Type=' + val.ssclass);
|
self.data('urlAddpage'), id, val.ssclass
|
||||||
|
));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -30,8 +30,9 @@
|
|||||||
'edit': {
|
'edit': {
|
||||||
'label': ss.i18n._t('Tree.EditPage'),
|
'label': ss.i18n._t('Tree.EditPage'),
|
||||||
'action': function(obj) {
|
'action': function(obj) {
|
||||||
// TODO Fix hardcoding of link
|
$('.cms-container').loadPanel(ss.i18n.sprintf(
|
||||||
$('.cms-container').loadPanel('admin/pages/add/show/' + obj.data('id'));
|
self.data('urlEditpage'), obj.data('id')
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -40,8 +41,9 @@
|
|||||||
menuitems['addsubpage'] = {
|
menuitems['addsubpage'] = {
|
||||||
'label': ss.i18n._t('Tree.AddSubPage'),
|
'label': ss.i18n._t('Tree.AddSubPage'),
|
||||||
'action': function(obj) {
|
'action': function(obj) {
|
||||||
// TODO Fix hardcoding of link
|
$('.cms-container').loadPanel(ss.i18n.sprintf(
|
||||||
$('.cms-container').loadPanel('admin/pages/add/?ParentID=' + obj.data('id'));
|
self.data('urlAddpage'), id, 'Page'
|
||||||
|
));
|
||||||
},
|
},
|
||||||
'submenu': allowedChildren
|
'submenu': allowedChildren
|
||||||
};
|
};
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
|
|
||||||
<div class="cms-tree" data-url-tree="$Link(getsubtree)" data-url-savetreenode="$Link(savetreenode)" data-hints="$SiteTreeHints">
|
<div class="cms-tree" data-url-tree="$Link(getsubtree)" data-url-savetreenode="$Link(savetreenode)" data-url-addpage="{$LinkPageAdd}AddForm/?action_doAdd=1&ParentID=%s&PageType=%s&SecurityID=$SecurityID" data-url-editpage="$LinkPageEdit('%s')" data-hints="$SiteTreeHints">
|
||||||
$SiteTreeAsUL
|
$SiteTreeAsUL
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user