mirror of
https://github.com/e107inc/e107.git
synced 2025-06-07 11:28:22 +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:
parent
b8a1bde497
commit
b0a48418d8
@ -1677,13 +1677,14 @@ $text .= "
|
|||||||
</fieldset>";
|
</fieldset>";
|
||||||
|
|
||||||
|
|
||||||
|
$text .= "<fieldset class='e-hideme' id='core-prefs-javascript'>";
|
||||||
|
|
||||||
if(E107_DEBUG_LEVEL > 0)
|
if(E107_DEBUG_LEVEL > 0)
|
||||||
{
|
{
|
||||||
// TODO - remove these old JS settings completely!
|
// TODO - remove these old JS settings completely!
|
||||||
|
|
||||||
// Javascript Control
|
// Javascript Control
|
||||||
$text .= "
|
$text .= "
|
||||||
<fieldset class='e-hideme' id='core-prefs-javascript'>
|
|
||||||
<legend>" . PRFLAN_242 . "</legend>
|
<legend>" . PRFLAN_242 . "</legend>
|
||||||
<table class='table adminform'>
|
<table class='table adminform'>
|
||||||
<colgroup>
|
<colgroup>
|
||||||
@ -1786,7 +1787,6 @@ $CDNproviders = array(
|
|||||||
);
|
);
|
||||||
|
|
||||||
$text .= '
|
$text .= '
|
||||||
<fieldset class="e-hideme" id="core-prefs-javascript">
|
|
||||||
<h4 class="caption">' . LAN_LIBRARY_MANAGER_30 . '</h4>
|
<h4 class="caption">' . LAN_LIBRARY_MANAGER_30 . '</h4>
|
||||||
<table class="table adminform">
|
<table class="table adminform">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
|
@ -1853,13 +1853,57 @@ class e107
|
|||||||
{
|
{
|
||||||
$libraryHandler = e107::getLibrary();
|
$libraryHandler = e107::getLibrary();
|
||||||
|
|
||||||
switch ($action)
|
switch($action)
|
||||||
{
|
{
|
||||||
case 'detect':
|
case 'detect':
|
||||||
return $libraryHandler->detect($library);
|
return $libraryHandler->detect($library);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'load':
|
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);
|
return $libraryHandler->load($library, $variant);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -3,14 +3,13 @@
|
|||||||
/**
|
/**
|
||||||
* e107 website system
|
* 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
|
* 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$
|
* @file
|
||||||
* $Id$
|
* JS Manager.
|
||||||
*
|
*/
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -191,8 +190,6 @@ class e_jsmanager
|
|||||||
*
|
*
|
||||||
* Use {@link getInstance()}, direct instantiating
|
* Use {@link getInstance()}, direct instantiating
|
||||||
* is not possible for signleton objects
|
* is not possible for signleton objects
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
protected function __construct()
|
protected function __construct()
|
||||||
{
|
{
|
||||||
@ -231,42 +228,23 @@ class e_jsmanager
|
|||||||
// Try to auto-detect runtime location
|
// Try to auto-detect runtime location
|
||||||
$this->setInAdmin(defset('e_ADMIN_AREA', false));
|
$this->setInAdmin(defset('e_ADMIN_AREA', false));
|
||||||
|
|
||||||
$minified = deftrue('e_DEBUG') == true ? null : 'minified';
|
if($this->isInAdmin()) // Admin Area.
|
||||||
$cdn = e107::getPref('e_jslib_cdn', true);
|
{
|
||||||
|
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');
|
||||||
|
}
|
||||||
|
|
||||||
// Use local files.
|
// TODO
|
||||||
if(isset($_SERVER['E_DEV_LOCALJS']) && $_SERVER['E_DEV_LOCALJS'] === 'true' || !deftrue('e_CDN', $cdn))
|
// jQuery is the only JS framework, and it is always loaded. So remove
|
||||||
{
|
// unnecessary code here below.
|
||||||
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');
|
$customJqueryUrls = e107::getPref('library-jquery-urls');
|
||||||
$this->_cache_enabled = e107::getPref('jscsscachestatus',false);
|
$this->_cache_enabled = e107::getPref('jscsscachestatus',false);
|
||||||
@ -277,12 +255,9 @@ class e_jsmanager
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try to load browser cache id from core preferences
|
// 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
|
// Load stored in preferences core lib paths ASAP
|
||||||
|
|
||||||
// $core_libs = e107::getPref('e_jslib_core');
|
|
||||||
$this->_core_prefs = e107::getPref('e_jslib_core');
|
$this->_core_prefs = e107::getPref('e_jslib_core');
|
||||||
$core = array();
|
$core = array();
|
||||||
|
|
||||||
@ -294,12 +269,10 @@ class e_jsmanager
|
|||||||
|
|
||||||
if(!$this->libDisabled($id,$vis))
|
if(!$this->libDisabled($id,$vis))
|
||||||
{
|
{
|
||||||
//echo "<h2>FRAMEWORK Loaded: ".$id." :: ".$vis."</h2>";
|
|
||||||
if(vartrue($this->_libraries[$id]))
|
if(vartrue($this->_libraries[$id]))
|
||||||
{
|
{
|
||||||
foreach($this->_libraries[$id] as $path)
|
foreach($this->_libraries[$id] as $path)
|
||||||
{
|
{
|
||||||
//echo "<h4>Loaded: ".$path." :: ".$vis."</h4>";
|
|
||||||
$core[$path] = $vis;
|
$core[$path] = $vis;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -315,7 +288,6 @@ class e_jsmanager
|
|||||||
$this->checkLibDependence(null, $core);
|
$this->checkLibDependence(null, $core);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Load stored in preferences plugin lib paths ASAP
|
// Load stored in preferences plugin lib paths ASAP
|
||||||
$plug_libs = e107::getPref('e_jslib_plugin');
|
$plug_libs = e107::getPref('e_jslib_plugin');
|
||||||
if(!$plug_libs)
|
if(!$plug_libs)
|
||||||
@ -336,12 +308,6 @@ class e_jsmanager
|
|||||||
$theme_libs = array();
|
$theme_libs = array();
|
||||||
}
|
}
|
||||||
$this->themeLib($theme_libs);
|
$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
@ -1,29 +1,33 @@
|
|||||||
<?php
|
<?php
|
||||||
if ( ! defined('e107_INIT')) { exit(); }
|
|
||||||
|
|
||||||
define("SEP"," <span class='fa fa-play e-breadcrumb'></span> ");
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if(!defined('e107_INIT'))
|
||||||
|
{
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
define("SEP", " <span class='fa fa-play e-breadcrumb'></span> ");
|
||||||
define("BOOTSTRAP", 3);
|
define("BOOTSTRAP", 3);
|
||||||
define('FONTAWESOME', 4);
|
define('FONTAWESOME', 4);
|
||||||
|
|
||||||
$minified = deftrue('e_DEBUG') == true ? null : 'minified';
|
e107::library('load', 'bootstrap');
|
||||||
$cdn = e107::getPref('e_jslib_cdn', true);
|
e107::library('load', 'fontawesome');
|
||||||
|
e107::library('load', 'bootstrap.editable');
|
||||||
|
|
||||||
if($cdn) {
|
e107::css('theme', 'css/bootstrap-dark.min.css');
|
||||||
e107::library('load', 'cdn.bootstrap', $minified);
|
e107::css('theme', 'admin_style.css');
|
||||||
e107::library('load', 'cdn.fontawesome', $minified);
|
e107::css('theme', 'admin_dark.css');
|
||||||
}
|
e107::css('theme', 'ie_all.css', null, 'all', "<!--[if IE]>", "<![endif]-->");
|
||||||
else
|
|
||||||
{
|
|
||||||
e107::library('load', 'bootstrap', $minified);
|
|
||||||
e107::library('load', 'fontawesome', $minified);
|
|
||||||
}
|
|
||||||
|
|
||||||
e107::library('load', 'bootstrap.editable', $minified);
|
|
||||||
|
|
||||||
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', "
|
e107::css('inline', "
|
||||||
.mce-menubar .mce-caret { border-top-color: #C6C6C6!important }
|
.mce-menubar .mce-caret { border-top-color: #C6C6C6!important }
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
<?php
|
<?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
|
* @file
|
||||||
* Bootstrap 3 Theme for e107 v2.x.
|
* Bootstrap 3 Theme for e107 v2.x.
|
||||||
*/
|
*/
|
||||||
@ -14,19 +20,8 @@ define("BOOTSTRAP", 3);
|
|||||||
define("FONTAWESOME", 4);
|
define("FONTAWESOME", 4);
|
||||||
define('VIEWPORT', "width=device-width, initial-scale=1.0");
|
define('VIEWPORT', "width=device-width, initial-scale=1.0");
|
||||||
|
|
||||||
$min = deftrue('e_DEBUG') == true ? null : 'minified';
|
e107::library('load', 'bootstrap');
|
||||||
$cdn = e107::getPref('e_jslib_cdn', true);
|
e107::library('load', 'fontawesome');
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// CDN provider for Bootswatch.
|
// CDN provider for Bootswatch.
|
||||||
$cndPref = e107::pref('theme', 'cdn', 'cdnjs');
|
$cndPref = e107::pref('theme', 'cdn', 'cdnjs');
|
||||||
@ -50,18 +45,9 @@ switch($cndPref)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* @example prefetch */
|
/* @example prefetch */
|
||||||
//e107::link(array('rel'=>'prefetch', 'href'=>THEME.'images/browsers.png'));
|
//e107::link(array('rel'=>'prefetch', 'href'=>THEME.'images/browsers.png'));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
e107::js("footer-inline", "$('.e-tip').tooltip({container: 'body'})"); // activate bootstrap tooltips.
|
e107::js("footer-inline", "$('.e-tip').tooltip({container: 'body'})"); // activate bootstrap tooltips.
|
||||||
|
|
||||||
// Legacy Stuff.
|
// Legacy Stuff.
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
<?php
|
<?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
|
* @file
|
||||||
* Provides information about external libraries.
|
* Provides information about external libraries.
|
||||||
*/
|
*/
|
||||||
@ -17,13 +23,12 @@ class bootstrap3_library
|
|||||||
*/
|
*/
|
||||||
function config()
|
function config()
|
||||||
{
|
{
|
||||||
$libraries = array();
|
// TODO - bootswatch...
|
||||||
|
return array();
|
||||||
return $libraries;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alter the library information before detection and caching takes place.
|
* Alters library information before detection and caching takes place.
|
||||||
*/
|
*/
|
||||||
function config_alter(&$libraries)
|
function config_alter(&$libraries)
|
||||||
{
|
{
|
||||||
@ -33,9 +38,9 @@ class bootstrap3_library
|
|||||||
{
|
{
|
||||||
// Disable Bootstrap CSS.
|
// Disable Bootstrap CSS.
|
||||||
unset($libraries['cdn.bootstrap']['files']['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']['files']['css']);
|
||||||
unset($libraries['bootstrap']['variants']['minified']['files']['css']);
|
unset($libraries['bootstrap']['variants']['dev']['files']['css']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user