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

CDN selection for Bootstrap Frontend.

This commit is contained in:
Cameron 2016-11-05 13:59:09 -07:00
parent c7fc923736
commit 5cb8a8d215
2 changed files with 78 additions and 13 deletions

View File

@ -13,18 +13,67 @@ define('VIEWPORT', "width=device-width, initial-scale=1.0");
// Warning: Some bootstrap CDNs are not compiled with popup.js
// use https if e107 is using https.
e107::js("url", "https://cdn.jsdelivr.net/bootstrap/3.3.6/js/bootstrap.min.js", 'jquery', 2);
/*
* jsdelivr
https://cdn.jsdelivr.net/bootstrap/3.3.7/js/bootstrap.min.js
https://cdn.jsdelivr.net/bootstrap/3.3.7/css/bootstrap-theme.min.css
https://cdn.jsdelivr.net/bootstrap/3.3.7/css/bootstrap.min.css
https://cdn.jsdelivr.net/fontawesome/4.7.0/css/font-awesome.min.css
https://cdn.jsdelivr.net/fontawesome/4.7.0/css/font-awesome.css
https://cdn.jsdelivr.net/bootswatch/3.3.7/cerulean/bootstrap.min.css
cdnjs
https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js
https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap-theme.css
https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap-theme.min.css
https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css
https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css
*/
$cndPref = e107::pref('theme', 'cdn','cdnjs');
$bootswatch = e107::pref('theme', 'bootswatch',false);
switch($cndPref)
{
case "jsdelivr":
e107::js("url", "https://cdn.jsdelivr.net/bootstrap/3.3.6/js/bootstrap.min.js", 'jquery', 2);
if($bootswatch)
{
e107::css('url', 'https://cdn.jsdelivr.net/bootswatch/3.3.7/'.$bootswatch.'/bootstrap.min.css');
}
else
{
e107::css('url', 'https://cdn.jsdelivr.net/bootstrap/3.3.7/css/bootstrap.min.css');
}
e107::css('url', 'https://cdn.jsdelivr.net/fontawesome/4.7.0/css/font-awesome.min.css');
break;
case "cdnjs":
default:
e107::js("url", "https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js", 'jquery', 2);
if($bootswatch)
{
e107::css('url', 'https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/'.$bootswatch.'/bootstrap.min.css');
}
else
{
e107::css('url', 'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css');
}
e107::css('url', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css');
}
if($bootswatch = e107::pref('theme', 'bootswatch',false))
{
e107::css('url', 'https://maxcdn.bootstrapcdn.com/bootswatch/3.3.6/'.$bootswatch.'/bootstrap.min.css');
}
else
{
e107::css('url', 'https://cdn.jsdelivr.net/bootstrap/3.3.6/css/bootstrap.min.css');
}
e107::css('url', 'https://cdn.jsdelivr.net/fontawesome/4.5.0/css/font-awesome.min.css');

View File

@ -16,14 +16,16 @@ class theme_bootstrap3 implements e_theme_config
$theme_pref['usernav_placement'] = $_POST['usernav_placement'];
$theme_pref['branding'] = $_POST['branding'];
$theme_pref['bootswatch'] = $_POST['bootswatch'];
$theme_pref['cdn'] = $_POST['cdn'];
$pref->set('sitetheme_pref', $theme_pref);
return $pref->dataHasChanged();
}
function config()
function config($type='front')
{
$frm = e107::getForm();
$frm = e107::getForm();
$brandingOpts = array('sitename'=>LAN_THEMEPREF_04, 'logo' => LAN_THEMEPREF_05, 'sitenamelogo'=>LAN_THEMEPREF_06);
@ -60,6 +62,13 @@ class theme_bootstrap3 implements e_theme_config
"yeti"=> 'Yeti',
);
$cdnFront = array(
'cdnjs' => "CDNJS (Cloudflare)",
'jsdelivr' => "jsDelivr"
// google ? No fontawesome support?
);
$previewLink = " <a class='btn btn-default e-modal' data-modal-caption=\"Use the 'Themes' menu to view the selection.\" href='http://bootswatch.com/default/'>".LAN_PREVIEW."</a>";
@ -67,15 +76,22 @@ class theme_bootstrap3 implements e_theme_config
$var[3]['html'] = "<div class='form-inline'>".$frm->select('bootswatch', $bootswatch, e107::pref('theme', 'bootswatch', ''),null,LAN_DEFAULT ).$previewLink."</div>";
$var[3]['help'] = "";
$var[4]['caption'] = "CDN";
$var[4]['html'] = $frm->select('cdn', $cdnFront, e107::pref('theme', 'cdn', '') );
$var[4]['help'] = "";
// $var[1]['caption'] = "Sample configuration field 2";
// $var[1]['html'] = $frm->text('_blank_example2', e107::pref('theme', 'example2', 'default'));
return $var;
}
function help()
{
return '';