1
0
mirror of https://github.com/e107inc/e107.git synced 2025-06-02 00:45:03 +02:00

Auto-prepend "cdn." (when available and CDN is On). Autoload "unminified" version (if available) when debug mode is On.

This commit is contained in:
lonalore 2017-01-27 11:51:28 +01:00
parent b8a1bde497
commit b0a48418d8
7 changed files with 652 additions and 636 deletions

View File

@ -1677,13 +1677,14 @@ $text .= "
</fieldset>";
$text .= "<fieldset class='e-hideme' id='core-prefs-javascript'>";
if(E107_DEBUG_LEVEL > 0)
{
// TODO - remove these old JS settings completely!
// Javascript Control
$text .= "
<fieldset class='e-hideme' id='core-prefs-javascript'>
<legend>" . PRFLAN_242 . "</legend>
<table class='table adminform'>
<colgroup>
@ -1786,7 +1787,6 @@ $CDNproviders = array(
);
$text .= '
<fieldset class="e-hideme" id="core-prefs-javascript">
<h4 class="caption">' . LAN_LIBRARY_MANAGER_30 . '</h4>
<table class="table adminform">
<colgroup>

View File

@ -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;

View File

@ -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 "<h2>FRAMEWORK Loaded: ".$id." :: ".$vis."</h2>";
if(vartrue($this->_libraries[$id]))
{
foreach($this->_libraries[$id] as $path)
{
//echo "<h4>Loaded: ".$path." :: ".$vis."</h4>";
$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';
}
/**

File diff suppressed because it is too large Load Diff

View File

@ -1,29 +1,33 @@
<?php
if ( ! defined('e107_INIT')) { exit(); }
define("SEP"," <span class='fa fa-play e-breadcrumb'></span> ");
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", " <span class='fa fa-play e-breadcrumb'></span> ");
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',"<!--[if IE]>","<![endif]-->");
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', "<!--[if IE]>", "<![endif]-->");
e107::css('inline', "
.mce-menubar .mce-caret { border-top-color: #C6C6C6!important }

View File

@ -1,6 +1,12 @@
<?php
/**
* 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.
*/
@ -14,19 +20,8 @@ define("BOOTSTRAP", 3);
define("FONTAWESOME", 4);
define('VIEWPORT', "width=device-width, initial-scale=1.0");
$min = deftrue('e_DEBUG') == true ? null : 'minified';
$cdn = e107::getPref('e_jslib_cdn', true);
if($cdn)
{
e107::library('load', 'cdn.bootstrap', $min);
e107::library('load', 'cdn.fontawesome', $min);
}
else
{
e107::library('load', 'bootstrap', $min);
e107::library('load', 'fontawesome', $min);
}
e107::library('load', 'bootstrap');
e107::library('load', 'fontawesome');
// CDN provider for Bootswatch.
$cndPref = e107::pref('theme', 'cdn', 'cdnjs');
@ -50,18 +45,9 @@ switch($cndPref)
break;
}
/* @example prefetch */
//e107::link(array('rel'=>'prefetch', 'href'=>THEME.'images/browsers.png'));
e107::js("footer-inline", "$('.e-tip').tooltip({container: 'body'})"); // activate bootstrap tooltips.
// Legacy Stuff.

View File

@ -1,6 +1,12 @@
<?php
/**
* 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
* Provides information about external libraries.
*/
@ -17,13 +23,12 @@ class bootstrap3_library
*/
function config()
{
$libraries = array();
return $libraries;
// TODO - bootswatch...
return array();
}
/**
* Alter the library information before detection and caching takes place.
* Alters library information before detection and caching takes place.
*/
function config_alter(&$libraries)
{
@ -33,9 +38,9 @@ class bootstrap3_library
{
// Disable Bootstrap CSS.
unset($libraries['cdn.bootstrap']['files']['css']);
unset($libraries['cdn.bootstrap']['variants']['minified']['files']['css']);
unset($libraries['cdn.bootstrap']['variants']['dev']['files']['css']);
unset($libraries['bootstrap']['files']['css']);
unset($libraries['bootstrap']['variants']['minified']['files']['css']);
unset($libraries['bootstrap']['variants']['dev']['files']['css']);
}
}