From b0a48418d82c1424c24f6ac33a95ead6ae1217f1 Mon Sep 17 00:00:00 2001 From: lonalore Date: Fri, 27 Jan 2017 11:51:28 +0100 Subject: [PATCH] Auto-prepend "cdn." (when available and CDN is On). Autoload "unminified" version (if available) when debug mode is On. --- e107_admin/prefs.php | 4 +- e107_handlers/e107_class.php | 46 +- e107_handlers/js_manager.php | 84 +- e107_handlers/library_manager.php | 1065 +++++++++++----------- e107_themes/bootstrap3/admin_theme.php | 42 +- e107_themes/bootstrap3/theme.php | 30 +- e107_themes/bootstrap3/theme_library.php | 17 +- 7 files changed, 652 insertions(+), 636 deletions(-) diff --git a/e107_admin/prefs.php b/e107_admin/prefs.php index 8e67d9a7f..e44c20edd 100644 --- a/e107_admin/prefs.php +++ b/e107_admin/prefs.php @@ -1677,13 +1677,14 @@ $text .= " "; +$text .= "
"; + if(E107_DEBUG_LEVEL > 0) { // TODO - remove these old JS settings completely! // Javascript Control $text .= " -
" . PRFLAN_242 . " @@ -1786,7 +1787,6 @@ $CDNproviders = array( ); $text .= ' -

' . LAN_LIBRARY_MANAGER_30 . '

diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index d5dd14655..6e4be92d1 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -1853,13 +1853,57 @@ class e107 { $libraryHandler = e107::getLibrary(); - switch ($action) + switch($action) { case 'detect': return $libraryHandler->detect($library); break; case 'load': + $cdn = (bool) e107::getPref('e_jslib_cdn', true); + $debug = (bool) deftrue('e_DEBUG'); + + // Try to detect and load CDN version. + if($cdn && substr($library, 0, 4) != 'cdn.') + { + $lib = $libraryHandler->detect('cdn.' . $library); + + // If CDN version is available. + if($lib && !empty($lib['installed'])) + { + // If a variant is specified, we need to check if it's installed. + if(!empty($variant) && !empty($lib['variants'][$variant]['installed'])) + { + // Load CDN version with the variant. + return $libraryHandler->load('cdn.' . $library, $variant); + } + + // If CDN version is available, but no variant is specified, + // and debug mode is on, try to load 'debug' variant. + if(empty($variant) && $debug && !empty($lib['variants']['dev']['installed'])) + { + // Load CDN version with 'debug' variant. + return $libraryHandler->load('cdn.' . $library, 'dev'); + } + + // Load CDN version without variant. + return $libraryHandler->load('cdn.' . $library, $variant); + } + } + + // If no variant is specified, and CDN version is not available, and debug mode is on. + if(empty($variant) && $debug) + { + $lib = $libraryHandler->detect($library); + + // If 'debug' variant is available. + if($lib && !empty($lib['variants']['dev']['installed'])) + { + // Load library with 'debug' variant. + return $libraryHandler->load($library, 'dev'); + } + } + return $libraryHandler->load($library, $variant); break; diff --git a/e107_handlers/js_manager.php b/e107_handlers/js_manager.php index fc96c720c..c7ebdbfbc 100644 --- a/e107_handlers/js_manager.php +++ b/e107_handlers/js_manager.php @@ -3,14 +3,13 @@ /** * e107 website system * - * Copyright (C) 2008-2012 e107 Inc (e107.org) + * Copyright (C) 2008-2017 e107 Inc (e107.org) * Released under the terms and conditions of the - * GNU General Public License (http://gnu.org). + * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * - * $URL$ - * $Id$ - * -*/ + * @file + * JS Manager. + */ /** @@ -191,8 +190,6 @@ class e_jsmanager * * Use {@link getInstance()}, direct instantiating * is not possible for signleton objects - * - * @return void */ protected function __construct() { @@ -231,43 +228,24 @@ class e_jsmanager // Try to auto-detect runtime location $this->setInAdmin(defset('e_ADMIN_AREA', false)); - $minified = deftrue('e_DEBUG') == true ? null : 'minified'; - $cdn = e107::getPref('e_jslib_cdn', true); + if($this->isInAdmin()) // Admin Area. + { + e107::library('load', 'jquery'); + // jQuery Once is used in e107.behaviors. + e107::library('load', 'jquery.once'); + e107::library('load', 'jquery.ui'); + } + else // Front-End. + { + e107::library('load', 'jquery'); + // jQuery Once is used in e107.behaviors. + e107::library('load', 'jquery.once'); + } + + // TODO + // jQuery is the only JS framework, and it is always loaded. So remove + // unnecessary code here below. - // Use local files. - if(isset($_SERVER['E_DEV_LOCALJS']) && $_SERVER['E_DEV_LOCALJS'] === 'true' || !deftrue('e_CDN', $cdn)) - { - if($this->isInAdmin()) // Admin Area. - { - e107::library('load', 'jquery', $minified); - // jQuery Once is used in e107.behaviors. - e107::library('load', 'jquery.once', $minified); - e107::library('load', 'jquery.ui', $minified); - } - else // Front-End. - { - e107::library('load', 'jquery', $minified); - // jQuery Once is used in e107.behaviors. - e107::library('load', 'jquery.once', $minified); - } - } - else // Use CDN files. - { - if($this->isInAdmin()) // Admin Area. - { - e107::library('load', 'cdn.jquery', $minified); - // jQuery Once is used in e107.behaviors. - e107::library('load', 'cdn.jquery.once', $minified); - e107::library('load', 'cdn.jquery.ui', $minified); - } - else // Front-End. - { - e107::library('load', 'cdn.jquery', $minified); - // jQuery Once is used in e107.behaviors. - e107::library('load', 'cdn.jquery.once', $minified); - } - } - $customJqueryUrls = e107::getPref('library-jquery-urls'); $this->_cache_enabled = e107::getPref('jscsscachestatus',false); @@ -277,12 +255,9 @@ class e_jsmanager } // Try to load browser cache id from core preferences - //$this->setCacheId(deftrue('e_NOCACHE') ? time() : e107::getPref('e_jslib_browser_cache')); - $this->setCacheId(e107::getPref('e_jslib_browser_cache'), 0); + $this->setCacheId(e107::getPref('e_jslib_browser_cache', 0)); - // 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'); + // Load stored in preferences core lib paths ASAP $this->_core_prefs = e107::getPref('e_jslib_core'); $core = array(); @@ -294,13 +269,11 @@ class e_jsmanager if(!$this->libDisabled($id,$vis)) { - //echo "

FRAMEWORK Loaded: ".$id." :: ".$vis."

"; if(vartrue($this->_libraries[$id])) { foreach($this->_libraries[$id] as $path) { - //echo "

Loaded: ".$path." :: ".$vis."

"; - $core[$path] = $vis; + $core[$path] = $vis; } } @@ -314,7 +287,6 @@ class e_jsmanager { $this->checkLibDependence(null, $core); } - // Load stored in preferences plugin lib paths ASAP $plug_libs = e107::getPref('e_jslib_plugin'); @@ -336,12 +308,6 @@ class e_jsmanager $theme_libs = array(); } $this->themeLib($theme_libs); - - // TEST VALUES - // $this->_e_jslib_plugin[] = '{e_PLUGIN}myplug/test.js'; - // $this->_e_jslib_plugin[] = 'http://somesite/myplug/test.js'; - // $this->_e_jslib_theme[] = '{THEME}js/test.js'; - // $this->_e_jslib_theme[] = 'http://somesite/js/test.js'; } /** diff --git a/e107_handlers/library_manager.php b/e107_handlers/library_manager.php index 58d22b1e8..3a7a076bd 100644 --- a/e107_handlers/library_manager.php +++ b/e107_handlers/library_manager.php @@ -1,8 +1,14 @@ 'jQuery (CDN)', + 'vendor_url' => 'https://jquery.com/', + 'version_arguments' => array( + 'file' => 'jquery.min.js', + 'pattern' => '/jQuery\s+v(\d\.\d\.\d+)/', + 'lines' => 5, + ), + 'files' => array( + 'js' => array( + 'jquery.min.js' => array( + 'zone' => 1, + 'type' => 'url', + ), + ), + ), + 'variants' => array( + // 'unminified' version for debugging. + 'dev' => array( + 'files' => array( + 'js' => array( + 'jquery.js' => array( + 'zone' => 1, + 'type' => 'url', + ), + ), + ), + ), + ), + // Override library path to CDN. + 'library_path' => 'https://cdn.jsdelivr.net/jquery/2.2.4/', + ); + + // jQuery (local). + $libraries['jquery'] = array( + 'name' => 'jQuery (local)', + 'vendor_url' => 'https://jquery.com/', + 'version_arguments' => array( + 'file' => 'dist/jquery.min.js', + 'pattern' => '/v(\d\.\d\.\d+)/', + 'lines' => 5, + ), + 'files' => array( + 'js' => array( + 'dist/jquery.min.js' => array( + 'zone' => 1, + 'type' => 'url', + ), + ), + ), + 'variants' => array( + // 'unminified' version for debugging. + 'dev' => array( + 'files' => array( + 'js' => array( + 'dist/jquery.js' => array( + 'zone' => 1, + 'type' => 'url', + ), + ), + ), + ), + ), + ); + + // jQuery Once (CDN). + $libraries['cdn.jquery.once'] = array( + 'name' => 'jQuery Once (CDN)', + 'vendor_url' => 'https://plugins.jquery.com/once/', + 'version_arguments' => array( + 'file' => 'jquery.once.min.js', + 'pattern' => '/jQuery\sOnce\s+v(\d\.\d\.\d+)/', + 'lines' => 5, + ), + 'files' => array( + 'js' => array( + 'jquery.once.min.js' => array( + 'zone' => 2, + 'type' => 'footer', + ), + ), + ), + 'variants' => array( + // 'unminified' version for debugging. + 'dev' => array( + 'files' => array( + 'js' => array( + // There is no non-minified version. + 'jquery.once.min.js' => array( + 'zone' => 2, + 'type' => 'footer', + ), + ), + ), + ), + ), + // Override library path to CDN. + 'library_path' => 'https://cdn.jsdelivr.net/jquery.once/2.1.2/', + ); + + // jQuery Once (local). + $libraries['jquery.once'] = array( + 'name' => 'jQuery Once (local)', + 'vendor_url' => 'https://plugins.jquery.com/once/', + 'version_arguments' => array( + 'file' => 'jquery.once.min.js', + 'pattern' => '/jQuery\sOnce\s+v(\d\.\d\.\d+)/', + 'lines' => 5, + ), + 'files' => array( + 'js' => array( + 'jquery.once.min.js' => array( + 'zone' => 2, + 'type' => 'footer', + ), + ), + ), + 'variants' => array( + // 'unminified' version for debugging. + 'dev' => array( + 'files' => array( + 'js' => array( + // There is no non-minified version. + 'jquery.once.min.js' => array( + 'zone' => 2, + 'type' => 'footer', + ), + ), + ), + ), + ), + // Override library path. + 'library_path' => '{e_WEB}lib/jquery-once/', + ); + + // jQuery UI (CDN). + $libraries['cdn.jquery.ui'] = array( + 'name' => 'jQuery UI (CDN)', + 'vendor_url' => 'https://jqueryui.com/', + 'version_arguments' => array( + 'file' => 'jquery-ui.min.js', + 'pattern' => '/v(\d\.\d+\.\d+)/', + 'lines' => 5, + ), + 'files' => array( + 'js' => array( + 'jquery-ui.min.js' => array( + 'zone' => 2, + 'type' => 'footer', + ), + ), + 'css' => array( + 'jquery-ui.min.css' => array( + 'zone' => 2, + ), + ), + ), + 'variants' => array( + // 'unminified' version for debugging. + 'dev' => array( + 'files' => array( + 'js' => array( + // There is no non-minified version. + 'jquery-ui.min.js' => array( + 'zone' => 2, + 'type' => 'footer', + ), + ), + 'css' => array( + // There is no non-minified version. + 'jquery-ui.min.css' => array( + 'zone' => 2, + ), + ), + ), + ), + ), + // Override library path to CDN. + 'library_path' => 'https://cdn.jsdelivr.net/jquery.ui/1.11.4/', + ); + + // jQuery UI (local). + $libraries['jquery.ui'] = array( + 'name' => 'jQuery UI (local)', + 'vendor_url' => 'https://jqueryui.com/', + 'version_arguments' => array( + 'file' => 'jquery-ui.js', + 'pattern' => '/v(\d\.\d+\.\d+)/', + 'lines' => 5, + ), + 'files' => array( + 'js' => array( + 'jquery-ui.min.js' => array( + 'zone' => 2, + 'type' => 'footer', + ), + ), + 'css' => array( + 'jquery-ui.min.css' => array( + 'zone' => 2, + ), + ), + ), + 'variants' => array( + // 'unminified' version for debugging. + 'dev' => array( + 'files' => array( + 'js' => array( + 'jquery-ui.js' => array( + 'zone' => 2, + 'type' => 'footer', + ), + ), + 'css' => array( + 'jquery-ui.css' => array( + 'zone' => 2, + ), + ), + ), + ), + ), + // Override library path. + 'library_path' => '{e_WEB}lib/jquery-ui/', + ); + + // Bootstrap (CDN). + $libraries['cdn.bootstrap'] = array( + 'name' => 'Bootstrap (CDN)', + 'vendor_url' => 'http://getbootstrap.com/', + 'version_arguments' => array( + 'file' => 'js/bootstrap.min.js', + 'pattern' => '/Bootstrap\s+v(\d\.\d\.\d+)/', + 'lines' => 5, + ), + 'files' => array( + 'js' => array( + 'js/bootstrap.min.js' => array( + 'zone' => 2, + 'type' => 'footer', + ), + ), + 'css' => array( + 'css/bootstrap.min.css' => array( + 'zone' => 2, + ), + ), + ), + 'variants' => array( + // 'unminified' version for debugging. + 'dev' => array( + 'files' => array( + 'js' => array( + 'js/bootstrap.js' => array( + 'zone' => 2, + 'type' => 'footer', + ), + ), + 'css' => array( + 'css/bootstrap.css' => array( + 'zone' => 2, + ), + ), + ), + ), + ), + // Override library path to CDN. + 'library_path' => 'https://cdn.jsdelivr.net/bootstrap/3.3.7/', + ); + + // Bootstrap (local). + $libraries['bootstrap'] = array( + 'name' => 'Bootstrap (local)', + 'vendor_url' => 'http://getbootstrap.com/', + 'version_arguments' => array( + 'file' => 'dist/js/bootstrap.min.js', + 'pattern' => '/Bootstrap\s+v(\d\.\d\.\d+)/', + 'lines' => 5, + ), + 'files' => array( + 'js' => array( + 'dist/js/bootstrap.min.js' => array( + 'zone' => 2, + 'type' => 'footer', + ), + ), + 'css' => array( + 'dist/css/bootstrap.min.css' => array( + 'zone' => 2, + ), + ), + ), + 'variants' => array( + // 'unminified' version for debugging. + 'dev' => array( + 'files' => array( + 'js' => array( + 'dist/js/bootstrap.js' => array( + 'zone' => 2, + 'type' => 'footer', + ), + ), + 'css' => array( + 'dist/css/bootstrap.css' => array( + 'zone' => 2, + ), + ), + ), + ), + ), + // Override library path. + 'library_path' => '{e_WEB}lib/bootstrap/3.3.7/', + ); + + // Bootstrap Editable (CDN). + $libraries['cdn.bootstrap.editable'] = array( + 'name' => 'Bootstrap Editable (CDN)', + 'vendor_url' => 'https://vitalets.github.io/bootstrap-editable/', + 'version_arguments' => array( + 'file' => 'js/bootstrap-editable.min.js', + 'pattern' => '/v(\d\.\d\.\d+)/', + 'lines' => 5, + ), + 'files' => array( + 'js' => array( + 'js/bootstrap-editable.min.js' => array( + 'zone' => 2, + 'type' => 'footer', + ), + ), + 'css' => array( + 'css/bootstrap-editable.min.css' => array( + 'zone' => 2, + ), + ), + ), + 'variants' => array( + // 'unminified' version for debugging. + 'dev' => array( + 'files' => array( + 'js' => array( + 'js/bootstrap-editable.js' => array( + 'zone' => 2, + 'type' => 'footer', + ), + ), + 'css' => array( + 'css/bootstrap-editable.css' => array( + 'zone' => 2, + ), + ), + ), + ), + ), + // Override library path to CDN. + 'library_path' => 'https://cdn.jsdelivr.net/bootstrap.editable/1.5.1/', + ); + + // Bootstrap Editable (local). + $libraries['bootstrap.editable'] = array( + 'name' => 'Bootstrap Editable (Local)', + 'vendor_url' => 'https://vitalets.github.io/bootstrap-editable/', + 'version_arguments' => array( + 'file' => 'js/bootstrap-editable.min.js', + 'pattern' => '/v(\d\.\d\.\d+)/', + 'lines' => 5, + ), + 'files' => array( + 'js' => array( + 'js/bootstrap-editable.min.js' => array( + 'zone' => 2, + 'type' => 'footer', + ), + ), + 'css' => array( + 'css/bootstrap-editable.min.css' => array( + 'zone' => 2, + ), + ), + ), + 'variants' => array( + // 'unminified' version for debugging. + 'dev' => array( + 'files' => array( + 'js' => array( + 'js/bootstrap-editable.js' => array( + 'zone' => 2, + 'type' => 'footer', + ), + ), + 'css' => array( + 'css/bootstrap-editable.css' => array( + 'zone' => 2, + ), + ), + ), + ), + ), + // Override library path. + 'library_path' => '{e_WEB}js/bootstrap3-editable/', + ); + + // Font-Awesome (CDN). + $libraries['cdn.fontawesome'] = array( + 'name' => 'Font-Awesome (CDN)', + 'vendor_url' => 'http://fontawesome.io/', + 'version_arguments' => array( + 'file' => 'css/font-awesome.min.css', + 'pattern' => '/(\d\.\d\.\d+)/', + 'lines' => 10, + ), + 'files' => array( + 'css' => array( + 'css/font-awesome.min.css' => array( + 'zone' => 2, + ), + ), + ), + 'variants' => array( + // 'unminified' version for debugging. + 'dev' => array( + 'files' => array( + 'css' => array( + 'css/font-awesome.css' => array( + 'zone' => 2, + ), + ), + ), + ), + ), + // Override library path to CDN. + 'library_path' => 'https://cdn.jsdelivr.net/fontawesome/4.7.0/', + ); + + // Font-Awesome (local). + $libraries['fontawesome'] = array( + 'name' => 'Font-Awesome (local)', + 'vendor_url' => 'http://fontawesome.io/', + 'version_arguments' => array( + 'file' => 'css/font-awesome.min.css', + 'pattern' => '/(\d\.\d\.\d+)/', + 'lines' => 10, + ), + 'files' => array( + 'css' => array( + 'css/font-awesome.min.css' => array( + 'zone' => 2, + ), + ), + ), + 'variants' => array( + // 'unminified' version for debugging. + 'dev' => array( + 'files' => array( + 'css' => array( + 'css/font-awesome.css' => array( + 'zone' => 2, + ), + ), + ), + ), + ), + // Override library path. + 'library_path' => '{e_WEB}lib/font-awesome/', + ); + + return $libraries; + } + + /** + * Alters library information before detection and caching takes place. + */ + function config_alter(&$libraries) + { + $pref = e107::pref('core'); + $cdnProvider = varset($pref['e_jslib_cdn_provider'], 'jsdelivr'); + + // If CDNJS is the selected provider, we alter core CDN libraries to use it + // instead of jsDelivr. + if($cdnProvider == 'cdnjs') + { + $libraries['cdn.jquery']['library_path'] = str_replace('https://cdn.jsdelivr.net/jquery/', 'https://cdnjs.cloudflare.com/ajax/libs/jquery/', $libraries['cdn.jquery']['library_path']); + $libraries['cdn.jquery.once']['library_path'] = str_replace('https://cdn.jsdelivr.net/jquery.once/', 'https://cdnjs.cloudflare.com/ajax/libs/jquery-once/', $libraries['cdn.jquery.once']['library_path']); + $libraries['cdn.jquery.ui']['library_path'] = str_replace('https://cdn.jsdelivr.net/jquery.ui/', 'https://cdnjs.cloudflare.com/ajax/libs/jqueryui/', $libraries['cdn.jquery.ui']['library_path']); + $libraries['cdn.bootstrap']['library_path'] = str_replace('https://cdn.jsdelivr.net/bootstrap/', 'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/', $libraries['cdn.bootstrap']['library_path']); + + if (preg_match('/(\d\.\d\.\d+)/', $libraries['cdn.bootstrap.editable']['library_path'], $matches)) { + $version = $matches[0]; + $old = 'https://cdn.jsdelivr.net/bootstrap.editable/' . $version . '/'; + $new = 'https://cdnjs.cloudflare.com/ajax/libs/x-editable/' . $version . '/bootstrap-editable/'; + $libraries['cdn.bootstrap.editable']['library_path'] = str_replace($old, $new, $libraries['cdn.bootstrap.editable']['library_path']); + } + + $libraries['cdn.fontawesome']['library_path'] = str_replace('https://cdn.jsdelivr.net/fontawesome/', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/', $libraries['cdn.fontawesome']['library_path']); + } + } + +} + + /** * Class e_library_manager. */ @@ -1173,540 +1707,17 @@ class e_library_manager switch($library['machine_name']) { - // Force to use default CSS files on Admin UI. + // Force to use default (original) files on Admin UI. case 'cdn.jquery.ui': case 'jquery.ui': case 'cdn.bootstrap': case 'bootstrap': $coreLib = $coreLibs[$library['machine_name']]; - $library['files']['css'] = $coreLib['files']['css']; - $library['variants']['minified']['files']['css'] = $coreLib['variants']['minified']['files']['css']; + $library['files'] = $coreLib['files']; + $library['variants'] = $coreLib['variants']; break; } } } } - - -/** - * Class core_library. - */ -class core_library -{ - - /** - * Provides information about external libraries. - * - * Provides information about: - * - jQuery (CDN). - * - jQuery (local). - * - jQuery Once (CDN) - * - jQuery Once (local) - * - jQuery UI (CDN) - * - jQuery UI (local) - * - Bootstrap (CDN) - * - Bootstrap (local) - * - Bootstrap Editable (CDN) - * - Bootstrap Editable (local) - * - Font-Awesome (CDN) - * - Font-Awesome (local) - */ - public function config() - { - $libraries = array(); - - // jQuery (CDN). - $libraries['cdn.jquery'] = array( - 'name' => 'jQuery (CDN)', - 'vendor_url' => 'https://jquery.com/', - 'version_arguments' => array( - 'file' => 'jquery.min.js', - 'pattern' => '/jQuery\s+v(\d\.\d\.\d+)/', - 'lines' => 5, - ), - 'files' => array( - 'js' => array( - 'jquery.js' => array( - 'zone' => 1, - 'type' => 'url', - ), - ), - ), - 'variants' => array( - // All properties defined for 'minified' override top-level properties. - 'minified' => array( - 'files' => array( - 'js' => array( - 'jquery.min.js' => array( - 'zone' => 1, - 'type' => 'url', - ), - ), - ), - ), - ), - // Override library path to CDN. - 'library_path' => 'https://cdn.jsdelivr.net/jquery/2.2.4/', - ); - - // jQuery (local). - $libraries['jquery'] = array( - 'name' => 'jQuery (local)', - 'vendor_url' => 'https://jquery.com/', - 'version_arguments' => array( - 'file' => 'dist/jquery.min.js', - 'pattern' => '/v(\d\.\d\.\d+)/', - 'lines' => 5, - ), - 'files' => array( - 'js' => array( - 'dist/jquery.js' => array( - 'zone' => 1, - 'type' => 'url', - ), - ), - ), - 'variants' => array( - // All properties defined for 'minified' override top-level properties. - 'minified' => array( - 'files' => array( - 'js' => array( - 'dist/jquery.min.js' => array( - 'zone' => 1, - 'type' => 'url', - ), - ), - ), - ), - ), - ); - - // jQuery Once (CDN). - $libraries['cdn.jquery.once'] = array( - 'name' => 'jQuery Once (CDN)', - 'vendor_url' => 'https://plugins.jquery.com/once/', - 'version_arguments' => array( - 'file' => 'jquery.once.min.js', - 'pattern' => '/jQuery\sOnce\s+v(\d\.\d\.\d+)/', - 'lines' => 5, - ), - 'files' => array( - 'js' => array( - 'jquery.once.min.js' => array( // There is no non-minified version. - 'zone' => 2, - 'type' => 'url', - ), - ), - ), - 'variants' => array( - // All properties defined for 'minified' override top-level properties. - 'minified' => array( - 'files' => array( - 'js' => array( - 'jquery.once.min.js' => array( - 'zone' => 2, - 'type' => 'url', - ), - ), - ), - ), - ), - // Override library path to CDN. - 'library_path' => 'https://cdn.jsdelivr.net/jquery.once/2.1.2/', - ); - - // jQuery Once (local). - $libraries['jquery.once'] = array( - 'name' => 'jQuery Once (local)', - 'vendor_url' => 'https://plugins.jquery.com/once/', - 'version_arguments' => array( - 'file' => 'jquery.once.min.js', - 'pattern' => '/jQuery\sOnce\s+v(\d\.\d\.\d+)/', - 'lines' => 5, - ), - 'files' => array( - 'js' => array( - 'jquery.once.min.js' => array( // There is no non-minified version. - 'zone' => 2, - 'type' => 'url', - ), - ), - ), - 'variants' => array( - // All properties defined for 'minified' override top-level properties. - 'minified' => array( - 'files' => array( - 'js' => array( - 'jquery.once.min.js' => array( - 'zone' => 2, - 'type' => 'url', - ), - ), - ), - ), - ), - // Override library path. - 'library_path' => '{e_WEB}lib/jquery-once/', - ); - - // jQuery UI (CDN). - $libraries['cdn.jquery.ui'] = array( - 'name' => 'jQuery UI (CDN)', - 'vendor_url' => 'https://jqueryui.com/', - 'version_arguments' => array( - 'file' => 'jquery-ui.min.js', - 'pattern' => '/v(\d\.\d+\.\d+)/', - 'lines' => 5, - ), - 'files' => array( - 'js' => array( - 'jquery-ui.min.js' => array( // There is no non-minified version. - 'zone' => 2, - 'type' => 'url', - ), - ), - 'css' => array( - 'jquery-ui.min.css' => array( // There is no non-minified version. - 'zone' => 2, - ), - ), - ), - 'variants' => array( - // All properties defined for 'minified' override top-level properties. - 'minified' => array( - 'files' => array( - 'js' => array( - 'jquery-ui.min.js' => array( - 'zone' => 2, - 'type' => 'url', - ), - ), - 'css' => array( - 'jquery-ui.min.css' => array( - 'zone' => 2, - ), - ), - ), - ), - ), - // Override library path to CDN. - 'library_path' => 'https://cdn.jsdelivr.net/jquery.ui/1.11.4/', - ); - - // jQuery UI (local). - $libraries['jquery.ui'] = array( - 'name' => 'jQuery UI (local)', - 'vendor_url' => 'https://jqueryui.com/', - 'version_arguments' => array( - 'file' => 'jquery-ui.js', - 'pattern' => '/v(\d\.\d+\.\d+)/', - 'lines' => 5, - ), - 'files' => array( - 'js' => array( - 'jquery-ui.js' => array( - 'zone' => 2, - 'type' => 'url', - ), - ), - 'css' => array( - 'jquery-ui.css' => array( - 'zone' => 2, - ), - ), - ), - 'variants' => array( - // All properties defined for 'minified' override top-level properties. - 'minified' => array( - 'files' => array( - 'js' => array( - 'jquery-ui.min.js' => array( - 'zone' => 2, - 'type' => 'url', - ), - ), - 'css' => array( - 'jquery-ui.min.css' => array( - 'zone' => 2, - ), - ), - ), - ), - ), - // Override library path. - 'library_path' => '{e_WEB}lib/jquery-ui/', - ); - - // Bootstrap (CDN). - $libraries['cdn.bootstrap'] = array( - 'name' => 'Bootstrap (CDN)', - 'vendor_url' => 'http://getbootstrap.com/', - 'version_arguments' => array( - 'file' => 'js/bootstrap.min.js', - 'pattern' => '/Bootstrap\s+v(\d\.\d\.\d+)/', - 'lines' => 5, - ), - 'files' => array( - 'js' => array( - 'js/bootstrap.js' => array( - 'zone' => 2, - 'type' => 'url', - ), - ), - 'css' => array( - 'css/bootstrap.css' => array( - 'zone' => 2, - ), - ), - ), - 'variants' => array( - // All properties defined for 'minified' override top-level properties. - 'minified' => array( - 'files' => array( - 'js' => array( - 'js/bootstrap.min.js' => array( - 'zone' => 2, - 'type' => 'url', - ), - ), - 'css' => array( - 'css/bootstrap.min.css' => array( - 'zone' => 2, - ), - ), - ), - ), - ), - // Override library path to CDN. - 'library_path' => 'https://cdn.jsdelivr.net/bootstrap/3.3.7/', - ); - - // Bootstrap (local). - $libraries['bootstrap'] = array( - 'name' => 'Bootstrap (local)', - 'vendor_url' => 'http://getbootstrap.com/', - 'version_arguments' => array( - 'file' => 'dist/js/bootstrap.min.js', - 'pattern' => '/Bootstrap\s+v(\d\.\d\.\d+)/', - 'lines' => 5, - ), - 'files' => array( - 'js' => array( - 'dist/js/bootstrap.js' => array( - 'zone' => 2, - 'type' => 'url', - ), - ), - 'css' => array( - 'dist/css/bootstrap.css' => array( - 'zone' => 2, - ), - ), - ), - 'variants' => array( - // All properties defined for 'minified' override top-level properties. - 'minified' => array( - 'files' => array( - 'js' => array( - 'dist/js/bootstrap.min.js' => array( - 'zone' => 2, - 'type' => 'url', - ), - ), - 'css' => array( - 'dist/css/bootstrap.min.css' => array( - 'zone' => 2, - ), - ), - ), - ), - ), - // Override library path. - 'library_path' => '{e_WEB}lib/bootstrap/3.3.7/', - ); - - // Bootstrap Editable (CDN). - $libraries['cdn.bootstrap.editable'] = array( - 'name' => 'Bootstrap Editable (CDN)', - 'vendor_url' => 'https://vitalets.github.io/bootstrap-editable/', - 'version_arguments' => array( - 'file' => 'js/bootstrap-editable.min.js', - 'pattern' => '/v(\d\.\d\.\d+)/', - 'lines' => 5, - ), - 'files' => array( - 'js' => array( - 'js/bootstrap-editable.js' => array( - 'zone' => 2, - 'type' => 'url', - ), - ), - 'css' => array( - 'css/bootstrap-editable.css' => array( - 'zone' => 2, - ), - ), - ), - 'variants' => array( - // All properties defined for 'minified' override top-level properties. - 'minified' => array( - 'files' => array( - 'js' => array( - 'js/bootstrap-editable.min.js' => array( - 'zone' => 2, - 'type' => 'url', - ), - ), - 'css' => array( - 'css/bootstrap-editable.min.css' => array( - 'zone' => 2, - ), - ), - ), - ), - ), - // Override library path to CDN. - 'library_path' => 'https://cdn.jsdelivr.net/bootstrap.editable/1.5.1/', - ); - - // Bootstrap Editable (local). - $libraries['bootstrap.editable'] = array( - 'name' => 'Bootstrap Editable (Local)', - 'vendor_url' => 'https://vitalets.github.io/bootstrap-editable/', - 'version_arguments' => array( - 'file' => 'js/bootstrap-editable.min.js', - 'pattern' => '/v(\d\.\d\.\d+)/', - 'lines' => 5, - ), - 'files' => array( - 'js' => array( - 'js/bootstrap-editable.js' => array( - 'zone' => 2, - 'type' => 'url', - ), - ), - 'css' => array( - 'css/bootstrap-editable.css' => array( - 'zone' => 2, - ), - ), - ), - 'variants' => array( - // All properties defined for 'minified' override top-level properties. - 'minified' => array( - 'files' => array( - 'js' => array( - 'js/bootstrap-editable.min.js' => array( - 'zone' => 2, - 'type' => 'url', - ), - ), - 'css' => array( - 'css/bootstrap-editable.min.css' => array( - 'zone' => 2, - ), - ), - ), - ), - ), - // Override library path. - 'library_path' => '{e_WEB}js/bootstrap3-editable/', - ); - - // Font-Awesome (CDN). - $libraries['cdn.fontawesome'] = array( - 'name' => 'Font-Awesome (CDN)', - 'vendor_url' => 'http://fontawesome.io/', - 'version_arguments' => array( - 'file' => 'css/font-awesome.min.css', - 'pattern' => '/(\d\.\d\.\d+)/', - 'lines' => 10, - ), - 'files' => array( - 'css' => array( - 'css/font-awesome.css' => array( - 'zone' => 2, - ), - ), - ), - 'variants' => array( - // All properties defined for 'minified' override top-level properties. - 'minified' => array( - 'files' => array( - 'css' => array( - 'css/font-awesome.min.css' => array( - 'zone' => 2, - ), - ), - ), - ), - ), - // Override library path to CDN. - 'library_path' => 'https://cdn.jsdelivr.net/fontawesome/4.7.0/', - ); - - // Font-Awesome (local). - $libraries['fontawesome'] = array( - 'name' => 'Font-Awesome (local)', - 'vendor_url' => 'http://fontawesome.io/', - 'version_arguments' => array( - 'file' => 'css/font-awesome.min.css', - 'pattern' => '/(\d\.\d\.\d+)/', - 'lines' => 10, - ), - 'files' => array( - 'css' => array( - 'css/font-awesome.css' => array( - 'zone' => 2, - ), - ), - ), - 'variants' => array( - // All properties defined for 'minified' override top-level properties. - 'minified' => array( - 'files' => array( - 'css' => array( - 'css/font-awesome.min.css' => array( - 'zone' => 2, - ), - ), - ), - ), - ), - // Override library path. - 'library_path' => '{e_WEB}lib/font-awesome/', - ); - - return $libraries; - } - - /** - * Implements config_alter(). - */ - function config_alter(&$libraries) - { - $pref = e107::pref('core'); - $cdnProvider = varset($pref['e_jslib_cdn_provider'], 'jsdelivr'); - - // If CDNJS is the selected provider, we alter core CDN libraries to use it - // instead of jsDelivr. - if($cdnProvider == 'cdnjs') - { - $libraries['cdn.jquery']['library_path'] = str_replace('https://cdn.jsdelivr.net/jquery/', 'https://cdnjs.cloudflare.com/ajax/libs/jquery/', $libraries['cdn.jquery']['library_path']); - $libraries['cdn.jquery.once']['library_path'] = str_replace('https://cdn.jsdelivr.net/jquery.once/', 'https://cdnjs.cloudflare.com/ajax/libs/jquery-once/', $libraries['cdn.jquery.once']['library_path']); - $libraries['cdn.jquery.ui']['library_path'] = str_replace('https://cdn.jsdelivr.net/jquery.ui/', 'https://cdnjs.cloudflare.com/ajax/libs/jqueryui/', $libraries['cdn.jquery.ui']['library_path']); - $libraries['cdn.bootstrap']['library_path'] = str_replace('https://cdn.jsdelivr.net/bootstrap/', 'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/', $libraries['cdn.bootstrap']['library_path']); - - if (preg_match('/(\d\.\d\.\d+)/', $libraries['cdn.bootstrap.editable']['library_path'], $matches)) { - $version = $matches[0]; - $old = 'https://cdn.jsdelivr.net/bootstrap.editable/' . $version . '/'; - $new = 'https://cdnjs.cloudflare.com/ajax/libs/x-editable/' . $version . '/bootstrap-editable/'; - $libraries['cdn.bootstrap.editable']['library_path'] = str_replace($old, $new, $libraries['cdn.bootstrap.editable']['library_path']); - } - - $libraries['cdn.fontawesome']['library_path'] = str_replace('https://cdn.jsdelivr.net/fontawesome/', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/', $libraries['cdn.fontawesome']['library_path']); - } - } - -} diff --git a/e107_themes/bootstrap3/admin_theme.php b/e107_themes/bootstrap3/admin_theme.php index 9d43c2b8f..66bb696a8 100644 --- a/e107_themes/bootstrap3/admin_theme.php +++ b/e107_themes/bootstrap3/admin_theme.php @@ -1,29 +1,33 @@ "); -define("BOOTSTRAP", 3); -define('FONTAWESOME', 4); +/** + * e107 website system + * + * Copyright (C) 2008-2017 e107 Inc (e107.org) + * Released under the terms and conditions of the + * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) + * + * @file + * Bootstrap 3 Theme for e107 v2.x admin area. + */ -$minified = deftrue('e_DEBUG') == true ? null : 'minified'; -$cdn = e107::getPref('e_jslib_cdn', true); - -if($cdn) { - e107::library('load', 'cdn.bootstrap', $minified); - e107::library('load', 'cdn.fontawesome', $minified); -} -else +if(!defined('e107_INIT')) { - e107::library('load', 'bootstrap', $minified); - e107::library('load', 'fontawesome', $minified); + exit(); } -e107::library('load', 'bootstrap.editable', $minified); +define("SEP", " "); +define("BOOTSTRAP", 3); +define('FONTAWESOME', 4); -e107::css('theme','css/bootstrap-dark.min.css'); -e107::css('theme','admin_style.css'); -e107::css('theme','admin_dark.css'); -e107::css('theme','ie_all.css',null,'all',""); +e107::library('load', 'bootstrap'); +e107::library('load', 'fontawesome'); +e107::library('load', 'bootstrap.editable'); + +e107::css('theme', 'css/bootstrap-dark.min.css'); +e107::css('theme', 'admin_style.css'); +e107::css('theme', 'admin_dark.css'); +e107::css('theme', 'ie_all.css', null, 'all', ""); e107::css('inline', " .mce-menubar .mce-caret { border-top-color: #C6C6C6!important } diff --git a/e107_themes/bootstrap3/theme.php b/e107_themes/bootstrap3/theme.php index 5b3fda90b..0112961d5 100644 --- a/e107_themes/bootstrap3/theme.php +++ b/e107_themes/bootstrap3/theme.php @@ -1,6 +1,12 @@ 'prefetch', 'href'=>THEME.'images/browsers.png')); - - e107::js("footer-inline", "$('.e-tip').tooltip({container: 'body'})"); // activate bootstrap tooltips. // Legacy Stuff. diff --git a/e107_themes/bootstrap3/theme_library.php b/e107_themes/bootstrap3/theme_library.php index 680422453..00e2031eb 100644 --- a/e107_themes/bootstrap3/theme_library.php +++ b/e107_themes/bootstrap3/theme_library.php @@ -1,6 +1,12 @@