From 7c5e0c754449f792cc6c8d0c978f8b04b252dd13 Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 3 Jan 2017 11:02:09 -0800 Subject: [PATCH] Option to prevent loading of js/css --- e107_admin/menus.php | 7 ++++- e107_handlers/e107_class.php | 44 ++++++++++++++++++++++++++++- e107_handlers/menumanager_class.php | 2 +- 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/e107_admin/menus.php b/e107_admin/menus.php index 70f019443..82e437a7d 100644 --- a/e107_admin/menus.php +++ b/e107_admin/menus.php @@ -792,8 +792,13 @@ class e_menu_layout return false; } + e107::set('css_enabled',false); + e107::set('js_enabled',false); + require($file); + e107::set('css_enabled',true); + e107::set('js_enabled',true); $head = array(); $foot = array(); @@ -988,7 +993,7 @@ class e_menu_layout foreach ($areas as $menu_act) { - $text .= "
  • \n"; + $text .= "
  • \n"; } $text .= ''; diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index 2feac3f1d..14fe307e3 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -127,6 +127,22 @@ class e107 */ protected static $_theme_config_arr = array(); + + + /** + * e107 e107::css() on/off flag. + * + * @var bool + */ + protected static $_css_enabled = true; + + /** + * e107 e107::js() on/off flag. + * + * @var bool + */ + protected static $_js_enabled = true; + /** * Core handlers array * For new/missing handler add @@ -1844,7 +1860,23 @@ class e107 } return e_jsmanager::getInstance(); } - + + + public static function set($type=null, $val=true) + { + if($type === 'js_enabled') + { + self::$_js_enabled = (bool) $val; + } + + if($type === 'css_enabled') + { + self::$_css_enabled = (bool) $val; + } + } + + + /** * JS Common Public Function. Prefered is shortcode script path * @param string $type core|theme|footer|inline|footer-inline|url or any existing plugin_name @@ -1854,6 +1886,11 @@ class e107 */ public static function js($type, $data, $dep = null, $zone = null, $pre = '', $post = '') { + if(self::$_js_enabled === false) + { + return null; + } + $jshandler = e107::getJs(); $jshandler->setDependency($dep); @@ -1946,6 +1983,11 @@ class e107 { define("BOOTSTRAP", true); } + + if(self::$_css_enabled === false) + { + return null; + } $jshandler = e107::getJs(); $jshandler->setDependency($dep); diff --git a/e107_handlers/menumanager_class.php b/e107_handlers/menumanager_class.php index d44bc696f..d1428a91c 100644 --- a/e107_handlers/menumanager_class.php +++ b/e107_handlers/menumanager_class.php @@ -206,7 +206,7 @@ class e_menuManager { // $cnt = $sql->select("menus", "*", "menu_location > 0 AND menu_layout = '$curLayout' ORDER BY menu_name "); // calculate height to remove vertical scroll-bar. // $text = ""; - $text = ""; + $text = ""; return $text; }