Permalink
Browse files

BUGFIX Fixed "add page" action when invoked through tree context menu…

… (and removed URL hardcoding in JS) (fixes #7155)
  • Loading branch information...
1 parent 8c1651e commit 98a0331a48fb59fdb51386081e6e05a9adcba506 @chillu chillu committed Apr 30, 2012
@@ -157,12 +157,11 @@ public function LinkGalleryView() {
return $this->LinkWithSearch(singleton('CMSMain')->Link('galleryview'));
}
- public function LinkPageEdit() {
- if($id = $this->currentPageID()) {
- return $this->LinkWithSearch(
- Controller::join_links(singleton('CMSPageEditController')->Link('show'), $id)
- );
- }
+ public function LinkPageEdit($id = null) {
+ if(!$id) $id = $this->currentPageID();
+ return $this->LinkWithSearch(
+ Controller::join_links(singleton('CMSPageEditController')->Link('show'), $id)
+ );
}
public function LinkPageSettings() {
@@ -16,18 +16,6 @@ class CMSPageAddController extends CMSPageEditController {
* @return Form
*/
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();
$pageTypes = array();
View
@@ -3,8 +3,7 @@
$.entwine('ss', function($){
$('.cms-tree').entwine({
getTreeConfig: function() {
- var config = this._super();
- var hints = this.getHints();
+ var self = this, config = this._super(), hints = this.getHints();
config.plugins.push('contextmenu');
config.contextmenu = {
'items': function(node) {
@@ -19,8 +18,9 @@
'label': '<span class="jstree-pageicon"></span>' + val.ssname,
'_class': 'class-' + val.ssclass,
'action': function(obj) {
- // TODO Fix hardcoding of link
- $('.cms-container').loadPanel('admin/pages/add/?ParentID=' + id + '&Type=' + val.ssclass);
+ $('.cms-container').loadPanel(ss.i18n.sprintf(
+ self.data('urlAddpage'), id, val.ssclass
+ ));
}
};
}
@@ -30,8 +30,9 @@
'edit': {
'label': ss.i18n._t('Tree.EditPage'),
'action': function(obj) {
- // TODO Fix hardcoding of link
- $('.cms-container').loadPanel('admin/pages/add/show/' + obj.data('id'));
+ $('.cms-container').loadPanel(ss.i18n.sprintf(
+ self.data('urlEditpage'), obj.data('id')
+ ));
}
}
};
@@ -40,8 +41,9 @@
menuitems['addsubpage'] = {
'label': ss.i18n._t('Tree.AddSubPage'),
'action': function(obj) {
- // TODO Fix hardcoding of link
- $('.cms-container').loadPanel('admin/pages/add/?ParentID=' + obj.data('id'));
+ $('.cms-container').loadPanel(ss.i18n.sprintf(
+ self.data('urlAddpage'), id, 'Page'
+ ));
},
'submenu': allowedChildren
};
@@ -20,7 +20,7 @@
</div>
<% 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&amp;ParentID=%s&amp;PageType=%s&amp;SecurityID=$SecurityID" data-url-editpage="$LinkPageEdit('%s')" data-hints="$SiteTreeHints">
$SiteTreeAsUL
</div>
</div>

0 comments on commit 98a0331

Please sign in to comment.