ENHANCEMENT Section icons in CMS (#7269)

This commit is contained in:
Ingo Schommer 2012-05-03 13:49:19 +02:00
parent 0d1e4cece5
commit 4029f96728
6 changed files with 83 additions and 68 deletions

View File

@ -437,9 +437,11 @@ class LeftAndMain extends Controller implements PermissionProvider {
* Returns the main menu of the CMS. This is also used by init() * Returns the main menu of the CMS. This is also used by init()
* to work out which sections the user has access to. * to work out which sections the user has access to.
* *
* @param Boolean
* @return SS_List * @return SS_List
*/ */
public function MainMenu() { public function MainMenu($cached = true) {
if(!isset($this->_cache_MainMenu) || !$cached) {
// Don't accidentally return a menu if you're not logged in - it's used to determine access. // Don't accidentally return a menu if you're not logged in - it's used to determine access.
if(!Member::currentUser()) return new ArrayList(); if(!Member::currentUser()) return new ArrayList();
@ -497,15 +499,25 @@ class LeftAndMain extends Controller implements PermissionProvider {
} }
} }
// if no current item is found, assume that first item is shown $this->_cache_MainMenu = $menu;
//if(!isset($foundCurrent)) }
return $menu;
return $this->_cache_MainMenu;
} }
public function Menu() { public function Menu() {
return $this->renderWith($this->getTemplatesWithSuffix('_Menu')); return $this->renderWith($this->getTemplatesWithSuffix('_Menu'));
} }
/**
* @todo Wrap in CMSMenu instance accessor
* @return ArrayData A single menu entry (see {@link MainMenu})
*/
public function MenuCurrentItem() {
$items = $this->MainMenu();
return $items->find('LinkingMode', 'current');
}
/** /**
* Return a list of appropriate templates for this class, with the given suffix * Return a list of appropriate templates for this class, with the given suffix
*/ */
@ -1244,10 +1256,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
function SectionTitle() { function SectionTitle() {
if($title = $this->stat('menu_title')) return $title; if($title = $this->stat('menu_title')) return $title;
// Get menu - use obj() to cache it in the same place as the template engine foreach($this->MainMenu() as $menuItem) {
$menu = $this->obj('MainMenu');
foreach($menu as $menuItem) {
if($menuItem->LinkingMode != 'link') return $menuItem->Title; if($menuItem->LinkingMode != 'link') return $menuItem->Title;
} }
} }

View File

@ -262,6 +262,8 @@ body.cms { overflow: hidden; }
.cms-content-header a { color: #1556b2; } .cms-content-header a { color: #1556b2; }
.cms-content-header .backlink span.btn-icon-back { height: 16px; } .cms-content-header .backlink span.btn-icon-back { height: 16px; }
.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: 60%; } .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: 60%; }
.cms-content-header h2 .section-icon { display: inline-block; vertical-align: middle; }
.cms-content-header h2 .breadcrumbs-wrapper { display: inline-block; vertical-align: middle; }
.cms-content-header h2 .breadcrumbs-wrapper .crumb { display: inline; line-height: 26px; padding: 0 5px; } .cms-content-header h2 .breadcrumbs-wrapper .crumb { display: inline; line-height: 26px; padding: 0 5px; }
.cms-content-header h2 .breadcrumbs-wrapper .crumb:first-child { padding-left: 0px; } .cms-content-header h2 .breadcrumbs-wrapper .crumb:first-child { padding-left: 0px; }
.cms-content-header h2 .breadcrumbs-wrapper .crumb:last-child { padding-right: 0px; } .cms-content-header h2 .breadcrumbs-wrapper .crumb:last-child { padding-right: 0px; }

View File

@ -117,10 +117,16 @@ body.cms {
display:table-cell; display:table-cell;
vertical-align:top; vertical-align:top;
width:60%; width:60%;
.section-icon {
display: inline-block;
vertical-align: middle;
}
.breadcrumbs-wrapper { .breadcrumbs-wrapper {
// display:table; display: inline-block;
vertical-align: middle;
.crumb { .crumb {
// display:table-cell;
display: inline; display: inline;
line-height:26px; line-height:26px;
padding:0 5px; padding:0 5px;

View File

@ -0,0 +1,7 @@
<% if ToplevelController %>
<span class="section-icon icon icon-16 icon-{$ToplevelController.MenuCurrentItem.Code.LowerCase}"></span>
<% else_if Controller %>
<span class="section-icon icon icon-16 icon-{$Controller.MenuCurrentItem.Code.LowerCase}"></span>
<% else %>
<span class="section-icon icon icon-16 icon-{$MenuCurrentItem.Code.LowerCase}"></span>
<% end_if %>

View File

@ -3,21 +3,11 @@
<% end_if %> <% end_if %>
<div class="cms-content-header north"> <div class="cms-content-header north">
<div> <div>
<% with Controller %>
<% if class=CMSFileAddController %>
<span class="section-icon icon icon-24 icon-assetadmin"></span>
<% else %>
<% with ToplevelController %>
<% if class=SecurityAdmin %>
<span class="section-icon icon icon-24 icon-securityadmin"></span>
<% end_if %>
<% end_with %>
<% end_if %>
<% end_with %>
<% include BackLink_Button %> <% include BackLink_Button %>
<h2 id="page-title-heading"> <h2 id="page-title-heading">
<% control Controller %> <% control Controller %>
<% include CMSSectionIcon %>
<% include CMSBreadcrumbs %> <% include CMSBreadcrumbs %>
<% end_control %> <% end_control %>
</h2> </h2>

View File

@ -3,6 +3,7 @@
<div class="cms-content-header north"> <div class="cms-content-header north">
<div> <div>
<h2> <h2>
<% include CMSSectionIcon %>
<% if SectionTitle %> <% if SectionTitle %>
$SectionTitle $SectionTitle
<% else %> <% else %>