diff --git a/admin/code/CMSMenu.php b/admin/code/CMSMenu.php index af67468d5..f791d64f8 100644 --- a/admin/code/CMSMenu.php +++ b/admin/code/CMSMenu.php @@ -1,16 +1,21 @@ setAttributes($attributes); + } + self::$menu_item_changes[] = array( 'type' => 'add', 'code' => $code, - 'item' => new CMSMenuItem($menuTitle, $url, $controllerClass, $priority), + 'item' => $item, ); } /** - * Add a previously built menuitem object to the menu + * Add a previously built menu item object to the menu */ protected static function add_menu_item_obj($code, $cmsMenuItem) { self::$menu_item_changes[] = array( diff --git a/admin/code/CMSMenuItem.php b/admin/code/CMSMenuItem.php index 97cd75778..5239df26c 100644 --- a/admin/code/CMSMenuItem.php +++ b/admin/code/CMSMenuItem.php @@ -1,12 +1,18 @@ url = $url; $this->controller = $controller; $this->priority = $priority; + parent::__construct(); } - + + /** + * @param array $attributes + */ + public function setAttributes($attributes) { + $this->attributes = $attributes; + } + + /** + * @param array + * + * @return HTML + */ + public function getAttributesHTML($attrs = null) { + $exclude = (is_string($attrs)) ? func_get_args() : null; + + if(!$attrs || is_string($attrs)) { + $attrs = $this->attributes; + } + + // Remove empty + $attrs = array_filter((array)$attrs, function($v) { + return ($v || $v === 0 || $v === '0'); + }); + + // Create markkup + $parts = array(); + + foreach($attrs as $name => $value) { + $parts[] = ($value === true) ? "{$name}=\"{$name}\"" : "{$name}=\"" . Convert::raw2att($value) . "\""; + } + + return implode(' ', $parts); + } } diff --git a/admin/code/LeftAndMain.php b/admin/code/LeftAndMain.php index 4b563c93d..ca92f69b0 100644 --- a/admin/code/LeftAndMain.php +++ b/admin/code/LeftAndMain.php @@ -219,7 +219,10 @@ class LeftAndMain extends Controller implements PermissionProvider { 'Help', _t('LeftAndMain.HELP', 'Help', 'Menu title'), $this->config()->help_link, - -2 + -2, + array( + 'target' => '_blank' + ) ); // Allow customisation of the access check by a extension @@ -616,6 +619,7 @@ class LeftAndMain extends Controller implements PermissionProvider { if($menuItems) { foreach($menuItems as $code => $menuItem) { // alternate permission checks (in addition to LeftAndMain->canView()) + if( isset($menuItem->controller) && $this->hasMethod('alternateMenuDisplayCheck') @@ -661,9 +665,10 @@ class LeftAndMain extends Controller implements PermissionProvider { $menuIcon = LeftAndMain::menu_icon_for_class($menuItem->controller); if (!empty($menuIcon)) $menuIconStyling .= $menuIcon; } - + $menu->push(new ArrayData(array( "MenuItem" => $menuItem, + "AttributesHTML" => $menuItem->getAttributesHTML(), "Title" => Convert::raw2xml($title), "Code" => DBField::create_field('Text', $code), "Link" => $menuItem->url, diff --git a/admin/css/screen.css b/admin/css/screen.css index 6731edb81..f2d397725 100644 --- a/admin/css/screen.css +++ b/admin/css/screen.css @@ -747,6 +747,7 @@ form.import-form label.left { width: 250px; } .cms .jstree li.jstree-open > ul, .TreeDropdownField .treedropdownfield-panel .jstree li.jstree-open > ul { display: block; } .cms .jstree li.jstree-closed > ul, .TreeDropdownField .treedropdownfield-panel .jstree li.jstree-closed > ul { display: none; } .cms .jstree li.disabled > a, .TreeDropdownField .treedropdownfield-panel .jstree li.disabled > a { color: #aaaaaa; } +.cms .jstree li.disabled > a:hover, .TreeDropdownField .treedropdownfield-panel .jstree li.disabled > a:hover { background: transparent; cursor: default; } .cms .jstree li.edit-disabled > a, .TreeDropdownField .treedropdownfield-panel .jstree li.edit-disabled > a { color: #aaaaaa; } .cms .jstree li > .jstree-icon, .TreeDropdownField .treedropdownfield-panel .jstree li > .jstree-icon { cursor: pointer; } .cms .jstree ins, .TreeDropdownField .treedropdownfield-panel .jstree ins { display: inline-block; text-decoration: none; width: 18px; height: 18px; margin: 0 0 0 0; padding: 0; float: left; } @@ -817,6 +818,7 @@ form.import-form label.left { width: 250px; } .tree-holder.jstree-apple li.Root > a .jstree-icon, .cms-tree.jstree-apple li.Root > a .jstree-icon { background-position: -56px -36px; } .tree-holder.jstree-apple li.status-deletedonlive .text, .cms-tree.jstree-apple li.status-deletedonlive .text { text-decoration: line-through; } .tree-holder.jstree-apple li.jstree-checked > a, .tree-holder.jstree-apple li.jstree-checked > a:link, .cms-tree.jstree-apple li.jstree-checked > a, .cms-tree.jstree-apple li.jstree-checked > a:link { background-color: #efe999; } +.tree-holder.jstree-apple li.disabled > a > .jstree-checkbox, .cms-tree.jstree-apple li.disabled > a > .jstree-checkbox { background-position: -57px -54px; } .tree-holder.jstree-apple li.readonly, .cms-tree.jstree-apple li.readonly { color: #aaaaaa; padding-left: 18px; } .tree-holder.jstree-apple li.readonly a, .tree-holder.jstree-apple li.readonly a:link, .cms-tree.jstree-apple li.readonly a, .cms-tree.jstree-apple li.readonly a:link { margin: 0; padding: 0; } .tree-holder.jstree-apple li.readonly .jstree-icon, .cms-tree.jstree-apple li.readonly .jstree-icon { display: none; } diff --git a/admin/images/sitetree_ss_default_icons.png b/admin/images/sitetree_ss_default_icons.png index 101351db9..783fd2268 100644 Binary files a/admin/images/sitetree_ss_default_icons.png and b/admin/images/sitetree_ss_default_icons.png differ diff --git a/admin/javascript/LeftAndMain.Menu.js b/admin/javascript/LeftAndMain.Menu.js index 549e53aa9..0f4c02e42 100644 --- a/admin/javascript/LeftAndMain.Menu.js +++ b/admin/javascript/LeftAndMain.Menu.js @@ -230,6 +230,13 @@ // Ignore external links, fallback to standard link behaviour var isExternal = $.path.isExternal(this.attr('href')); if(e.which > 1 || isExternal) return; + + // if the developer has this to open in a new window, handle + // that + if(this.attr('target') == "_blank") { + return; + } + e.preventDefault(); var item = this.getMenuItem(); diff --git a/admin/scss/_tree.scss b/admin/scss/_tree.scss index df8098c14..1be4b67f7 100644 --- a/admin/scss/_tree.scss +++ b/admin/scss/_tree.scss @@ -32,6 +32,10 @@ } &.disabled > a { color: #aaaaaa; + &:hover { + background: transparent; + cursor: default; + } } &.edit-disabled > a { color: #aaaaaa; @@ -438,7 +442,12 @@ > a, > a:link{ background-color: $color-cms-batchactions-menu-selected-background; } - } + } + &.disabled { + > a > .jstree-checkbox { + background-position: -57px -54px; + } + } &.readonly { color: $color-text-disabled; padding-left: 18px; diff --git a/admin/templates/Includes/LeftAndMain_Menu.ss b/admin/templates/Includes/LeftAndMain_Menu.ss index 899cfae67..e65330b1c 100644 --- a/admin/templates/Includes/LeftAndMain_Menu.ss +++ b/admin/templates/Includes/LeftAndMain_Menu.ss @@ -24,7 +24,7 @@