From 6ddb47ba8e3d9c390ed6824f765ad25f4819934d Mon Sep 17 00:00:00 2001 From: CaMer0n Date: Sat, 5 May 2012 02:18:11 +0000 Subject: [PATCH] Javascript CDN framework options added to admin -> prefs. (mostly for testing) --- e107_admin/prefs.php | 34 ++++++++++++++++++++++++++-------- e107_handlers/js_manager.php | 27 +++++++++++++++++++++++++-- 2 files changed, 51 insertions(+), 10 deletions(-) diff --git a/e107_admin/prefs.php b/e107_admin/prefs.php index 4fc6ac3ae..4eed81808 100644 --- a/e107_admin/prefs.php +++ b/e107_admin/prefs.php @@ -1102,7 +1102,7 @@ $text .= " "; -// Javascripts +// Javascript Control //TODO LANS $text .= "
@@ -1114,20 +1114,38 @@ $text .= " "; - $js_options = array('admin'=>'Admin Area','front'=>'Front-End','all'=>"Both"); + $js_options = array('admin'=>'Admin Area','front'=>'Front-End','all'=>"Both", 'none'=> 'Disabled'); + + //TODO FIXME - remove JS framework dependency from front-end and backend. + // ie. no JS errors when prototype.js is completely disabled. + // no JS error with only 'e107 Core Minimum' is enabled. + // e107 Core Minimum should function independently of framework. + // ie. e107 Core Minimum: JS similar to e107 v1.0 should be loaded "e_js.php" (no framwork dependency) + // with basic functions like SyncWithServerTime() and expandit(), externalLinks() etc. + + //TODO Move paths into js_manager and store only keys like 'prototype-local', 'core-minimum' in prefs. $js_types = array( - 'prototype/prototype.js' , - 'scriptaculous/scriptaculous.js', - 'scriptaculous/effects.js', - 'e107.js.php' + array('name'=> 'Prototype (local)', 'path'=> 'prototype/prototype.js') , + array('name'=> 'Scriptaculous (local)', 'path'=> 'scriptaculous/scriptaculous.js'), + array('name'=> 'Scriptaculous-effects (local)', 'path'=> 'scriptaculous/effects.js'), + array('name'=> 'Prototype (CDN)', 'path'=> 'https://ajax.googleapis.com/ajax/libs/prototype/1.7.0.0/prototype.js'), + array('name'=> 'Scriptaculous + Effects (CDN)', 'path'=> 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/scriptaculous.js?load=effects'), + array('name'=> 'jQuery (CDN)', 'path'=> 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'), + array('name'=> 'jQuery UI (CDN)', 'path'=> 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js'), + array('name'=> 'e107 Core Minimum', 'path'=> 'e107.js.php'), + array('name'=> 'e107 Plugin Scripts (TO-DO)', 'path'=> ''), // all js that has been added by Plugins. + array('name'=> 'e107 Theme Scripts (TO-DO)', 'path'=> ''), // all js that has been added by Themes. ); + - foreach($js_types as $k) + foreach($js_types as $arr) { + $k = $arr['path']; + $name = $arr['name']; $text .= " - ".$k." + ".$name." ".$frm->radio_multi("e_jslib_core[{$k}]",$js_options,$pref['e_jslib_core'][$k])." "; } diff --git a/e107_handlers/js_manager.php b/e107_handlers/js_manager.php index 37fea46e8..6876080e7 100644 --- a/e107_handlers/js_manager.php +++ b/e107_handlers/js_manager.php @@ -175,7 +175,11 @@ class e_jsmanager $this->setCacheId(deftrue('e_NOCACHE') ? time() : e107::getPref('e_jslib_browser_cache')); // Load stored in preferences core lib paths ASAP - FIXME - find better way to store libs - array structure and separate table row + $core_libs = e107::getPref('e_jslib_core'); + + + if(!$core_libs) { $core_libs = array(); @@ -516,16 +520,35 @@ class e_jsmanager * @see footerInline() * @param string $type core|plugin - jslib.php, header|footer|header_inline|footer_inline|core_css|plugin_css|theme_css|other_css|inline_css - runtime * @param string|array $file_path - * @param string|integer $runtime_location admin|front|all (jslib), 0-5 (runtime inclusion), 'media' attribute (CSS) + * @param string|integer $runtime_location admin|front|all|none (jslib), 0-5 (runtime inclusion), 'media' attribute (CSS) * @return object $this */ protected function addJs($type, $file_path, $runtime_location = '', $pre = '', $post = '') { + // TODO FIXME - remove JS framework dependency from front-end and backend. + // ie. no JS errors when prototype.js is completely disabled. + // no JS error with only 'e107 Core Minimum' is enabled. + // e107 Core Minimum should function independently of framework. + // ie. e107 Core Minimum: JS similar to e107 v1.0 should be loaded "e_js.php" (no framwork dependency) + // with basic functions like SyncWithServerTime() and expandit(), externalLinks() etc. + + if(empty($file_path)) { return $this; } - + + if($type == 'core' && ($runtime_location == 'none')) // disabled core js library + { + return $this; + } + + if($type == 'core' && substr($file_path,0,4)=='http' ) // Core using CDN. + { + $type = 'header'; + $runtime_location = 1; + } + // FIXME - this could break something after CSS support was added, move it to separate method(s), recursion by type! if(is_array($file_path)) {