Merge pull request #4167 from nedmas/namespace-safe-cmsmenu

Fix CMSMenuItem CSS references for namespaced controllers
This commit is contained in:
Daniel Hensby 2015-07-15 17:28:03 +01:00
commit bd316b9002
3 changed files with 3 additions and 3 deletions

View File

@ -142,7 +142,7 @@ class CMSMenu extends Object implements IteratorAggregate, i18nEntityProvider {
$cmsClasses = self::get_cms_classes(); $cmsClasses = self::get_cms_classes();
foreach($cmsClasses as $cmsClass) { foreach($cmsClasses as $cmsClass) {
$menuItem = self::menuitem_for_controller($cmsClass); $menuItem = self::menuitem_for_controller($cmsClass);
if($menuItem) $menuItems[$cmsClass] = $menuItem; if($menuItem) $menuItems[Convert::raw2htmlname(str_replace('\\', '-', $cmsClass))] = $menuItem;
} }
} }

View File

@ -556,7 +556,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
public static function menu_icon_for_class($class) { public static function menu_icon_for_class($class) {
$icon = Config::inst()->get($class, 'menu_icon', Config::FIRST_SET); $icon = Config::inst()->get($class, 'menu_icon', Config::FIRST_SET);
if (!empty($icon)) { if (!empty($icon)) {
$class = strtolower($class); $class = strtolower(Convert::raw2htmlname(str_replace('\\', '-', $class)));
return ".icon.icon-16.icon-{$class} { background: url('{$icon}'); } "; return ".icon.icon-16.icon-{$class} { background: url('{$icon}'); } ";
} }
return ''; return '';

View File

@ -92,7 +92,7 @@
updateMenuFromResponse: function(xhr) { updateMenuFromResponse: function(xhr) {
var controller = xhr.getResponseHeader('X-Controller'); var controller = xhr.getResponseHeader('X-Controller');
if(controller) { if(controller) {
var item = this.find('li#Menu-' + controller); var item = this.find('li#Menu-' + controller.replace(/\\/g, '-').replace(/[^a-zA-Z0-9\-_:.]+/, ''));
if(!item.hasClass('current')) item.select(); if(!item.hasClass('current')) item.select();
} }
this.updateItems(); this.updateItems();