mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR Fixed controller contexts in LeftAndMain->SiteTreeAsUL() - needs different context for edit links and determining "current page" (not applicable for CMSPagesController)
This commit is contained in:
parent
761bae3418
commit
473d3a66b8
@ -624,19 +624,22 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// getChildrenAsUL is a flexible and complex way of traversing the tree
|
// getChildrenAsUL is a flexible and complex way of traversing the tree
|
||||||
$titleEval = '
|
$controller = $this;
|
||||||
"<li id=\"record-$child->ID\" data-id=\"$child->ID\" data-ssclass=\"$child->ClassName\" class=\"" . $child->CMSTreeClasses($extraArg) . "\">" .
|
$recordController = ($this->stat('tree_class') == 'SiteTree') ? singleton('CMSPageEditController') : $this;
|
||||||
"<ins class=\"jstree-icon\"> </ins>" .
|
$titleFn = function(&$child) use(&$controller, &$recordController) {
|
||||||
"<a href=\"" . Controller::join_links($extraArg->Link("show"), $child->ID) . "\" title=\"'
|
$classes = $child->CMSTreeClasses();
|
||||||
. _t('LeftAndMain.PAGETYPE','Page type: ')
|
if($controller->isCurrentPage($child)) $classes .= " current";
|
||||||
. '".$child->class."\" ><ins class=\"jstree-icon\"> </ins><span class=\"text\">" . ($child->TreeTitle) .
|
return "<li id=\"record-$child->ID\" data-id=\"$child->ID\" data-ssclass=\"$child->ClassName\" class=\"" . $classes . "\">" .
|
||||||
"</span></a>"
|
"<ins class=\"jstree-icon\"> </ins>" .
|
||||||
';
|
"<a href=\"" . Controller::join_links($recordController->Link("show"), $child->ID) . "\" title=\"'
|
||||||
|
. _t('LeftAndMain.PAGETYPE','Page type: ')
|
||||||
|
. '".$child->class."\" ><ins class=\"jstree-icon\"> </ins><span class=\"text\">" . ($child->TreeTitle) .
|
||||||
|
"</span></a>";
|
||||||
|
};
|
||||||
$html = $obj->getChildrenAsUL(
|
$html = $obj->getChildrenAsUL(
|
||||||
"",
|
"",
|
||||||
$titleEval,
|
$titleFn,
|
||||||
singleton('CMSPageEditController'),
|
singleton('CMSPagesController'),
|
||||||
true,
|
true,
|
||||||
$childrenMethod,
|
$childrenMethod,
|
||||||
$numChildrenMethod,
|
$numChildrenMethod,
|
||||||
|
@ -263,8 +263,8 @@ body.cms { overflow: hidden; }
|
|||||||
.cms-content-header h2 { padding: 8px 8px 0 8px; font-size: 14px; line-height: 24px; font-weight: bold; text-shadow: #bfcad2 1px 1px 0; margin: 0; display: table-cell; vertical-align: top; width: 100%; }
|
.cms-content-header h2 { padding: 8px 8px 0 8px; font-size: 14px; line-height: 24px; font-weight: bold; text-shadow: #bfcad2 1px 1px 0; margin: 0; display: table-cell; vertical-align: top; width: 100%; }
|
||||||
.cms-content-header h2 .breadcrumbs-wrapper { display: table-row; }
|
.cms-content-header h2 .breadcrumbs-wrapper { display: table-row; }
|
||||||
.cms-content-header h2 .breadcrumbs-wrapper .crumb { display: table-cell; line-height: 26px; }
|
.cms-content-header h2 .breadcrumbs-wrapper .crumb { display: table-cell; line-height: 26px; }
|
||||||
.cms-content-header div { display: table-row; }
|
.cms-content-header > div { display: table; }
|
||||||
.cms-content-header div .cms_backlink { display: table-cell; vertical-align: middle; width: auto; }
|
.cms-content-header > div .cms_backlink { display: table-cell; vertical-align: middle; width: auto; }
|
||||||
.cms-content-header .cms-content-header-tabs { display: table-cell; white-space: nowrap; width: 100%; }
|
.cms-content-header .cms-content-header-tabs { display: table-cell; white-space: nowrap; width: 100%; }
|
||||||
.cms-content-header .cms-content-header-tabs .ui-tabs-nav { float: right; margin-right: 32px; }
|
.cms-content-header .cms-content-header-tabs .ui-tabs-nav { float: right; margin-right: 32px; }
|
||||||
.cms-content-header .cms-content-header-tabs .ui-tabs-nav li a { font-weight: bold; line-height: 16px; padding: 12px 20px 12px; }
|
.cms-content-header .cms-content-header-tabs .ui-tabs-nav li a { font-weight: bold; line-height: 16px; padding: 12px 20px 12px; }
|
||||||
|
@ -222,21 +222,20 @@
|
|||||||
var url = $(node).find('a:first').attr('href');
|
var url = $(node).find('a:first').attr('href');
|
||||||
if(url && url != '#') {
|
if(url && url != '#') {
|
||||||
|
|
||||||
|
// Ensure URL is absolute (important for IE)
|
||||||
if($.path.isExternal($(node).find('a:first'))) url = url = $.path.makeUrlAbsolute(url, $('base').attr('href'));
|
if($.path.isExternal($(node).find('a:first'))) url = url = $.path.makeUrlAbsolute(url, $('base').attr('href'));
|
||||||
// Reload only edit form if it exists (side-by-side view of tree and edit view), otherwise reload whole panel
|
// Retain search parameters
|
||||||
if(container.find('.cms-edit-form').length) {
|
if(document.location.search) url = $.path.addSearchParams(url, document.location.search.replace(/^\?/, ''));
|
||||||
container.entwine('ss').loadPanel(url, null, {selector: '.cms-edit-form', pjax: 'CurrentForm'});
|
// Load new page
|
||||||
} else {
|
container.entwine('ss').loadPanel(url);
|
||||||
container.entwine('ss').loadPanel(url);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
self.removeForm();
|
self.removeForm();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.cms-content.loading,.cms-edit-form.loading').entwine({
|
$('.cms-content.loading,.cms-edit-form.loading,.cms-content-fields.loading,.cms-content-view.loading').entwine({
|
||||||
onmatch: function() {
|
onmatch: function() {
|
||||||
this.append('<div class="cms-content-loading-overlay ui-widget-overlay-light"></div><div class="cms-content-loading-spinner"></div>');
|
this.append('<div class="cms-content-loading-overlay ui-widget-overlay-light"></div><div class="cms-content-loading-spinner"></div>');
|
||||||
},
|
},
|
||||||
|
@ -610,6 +610,55 @@ jQuery.noConflict();
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lightweight wrapper around jQuery UI tabs.
|
||||||
|
* Ensures that anchor links are set properly,
|
||||||
|
* and any nested tabs are scrolled if they have
|
||||||
|
* their height explicitly set. This is important
|
||||||
|
* for forms inside the CMS layout.
|
||||||
|
*/
|
||||||
|
$('.cms-tabset').entwine({
|
||||||
|
onmatch: function() {
|
||||||
|
// Can't name redraw() as it clashes with other CMS entwine classes
|
||||||
|
this.redrawTabs();
|
||||||
|
this._super();
|
||||||
|
},
|
||||||
|
|
||||||
|
redrawTabs: function() {
|
||||||
|
this.rewriteHashlinks();
|
||||||
|
|
||||||
|
var id = this.attr('id'), cookieId = 'ui-tabs-' + id,
|
||||||
|
selectedTab = this.find('ul:first .ui-state-selected');
|
||||||
|
|
||||||
|
// Fix for wrong cookie storage of deselected tabs
|
||||||
|
if($.cookie && id && $.cookie(cookieId) == -1) $.cookie(cookieId, 0);
|
||||||
|
this.tabs({
|
||||||
|
cookie: ($.cookie && id) ? { expires: 30, path: '/', name: cookieId } : false,
|
||||||
|
ajaxOptions: {
|
||||||
|
// Overwrite ajax loading to use CMS logic instead
|
||||||
|
beforeSend: function(xhr, settings) {
|
||||||
|
$('.cms-container').entwine('ss').loadPanel(settings.url);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
selected: (selectedTab.index() != -1) ? selectedTab.index() : 0
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace prefixes for all hashlinks in tabs.
|
||||||
|
* SSViewer rewrites them from "#Root_MyTab" to
|
||||||
|
* e.g. "/admin/#Root_MyTab" which makes them
|
||||||
|
* unusable for jQuery UI.
|
||||||
|
*/
|
||||||
|
rewriteHashlinks: function() {
|
||||||
|
$(this).find('ul a').each(function() {
|
||||||
|
var href = $(this).attr('href').replace(/.*(#.*)/, '$1');
|
||||||
|
if(href) $(this).attr('href', href);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}(jQuery));
|
}(jQuery));
|
||||||
|
|
||||||
|
@ -126,9 +126,9 @@ body.cms {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
& div {
|
& > div {
|
||||||
display:table-row;
|
display:table;
|
||||||
& .cms_backlink {
|
.cms_backlink {
|
||||||
display:table-cell;
|
display:table-cell;
|
||||||
vertical-align:middle;
|
vertical-align:middle;
|
||||||
width:auto;
|
width:auto;
|
||||||
|
@ -39,7 +39,6 @@
|
|||||||
|
|
||||||
.ui-tabs-panel {
|
.ui-tabs-panel {
|
||||||
background: transparent; // default it's white
|
background: transparent; // default it's white
|
||||||
padding: 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,15 +433,12 @@ class Folder extends File {
|
|||||||
/**
|
/**
|
||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
function CMSTreeClasses($controller) {
|
function CMSTreeClasses() {
|
||||||
$classes = sprintf('class-%s', $this->class);
|
$classes = sprintf('class-%s', $this->class);
|
||||||
|
|
||||||
if(!$this->canDelete())
|
if(!$this->canDelete())
|
||||||
$classes .= " nodelete";
|
$classes .= " nodelete";
|
||||||
|
|
||||||
if($controller->isCurrentPage($this))
|
|
||||||
$classes .= " current";
|
|
||||||
|
|
||||||
if(!$this->canEdit())
|
if(!$this->canEdit())
|
||||||
$classes .= " disabled";
|
$classes .= " disabled";
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user