Convert FQCNs to html safe strings

Convert namespaced class names to html safe strings in `LeftAndMain.php` `CMSMenu.php` and `LeftAndMain.Main.js` by replacing backslashes (\) with dashes (\) and removing special characters with `Convert::raw2htmlname()`
This commit is contained in:
Tom Densham 2015-07-15 15:33:00 +01:00
parent 2549fa8a93
commit b17b186e93
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();
foreach($cmsClasses as $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) {
$icon = Config::inst()->get($class, 'menu_icon', Config::FIRST_SET);
if (!empty($icon)) {
$class = strtolower($class);
$class = strtolower(Convert::raw2htmlname(str_replace('\\', '-', $class)));
return ".icon.icon-16.icon-{$class} { background: url('{$icon}'); } ";
}
return '';

View File

@ -92,7 +92,7 @@
updateMenuFromResponse: function(xhr) {
var controller = xhr.getResponseHeader('X-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();
}
this.updateItems();