diff --git a/e107_core/templates/header_default.php b/e107_core/templates/header_default.php index c89d247a2..14afe3d04 100644 --- a/e107_core/templates/header_default.php +++ b/e107_core/templates/header_default.php @@ -301,9 +301,13 @@ if(defined("PREVIEWTHEME")) } else { - $css_default = "all"; // TODO - default should be defined by the theme - // theme-css.php auto-detection TODO - convert it to constant or anything different from GLOBAL - if (isset($theme_css_php) && $theme_css_php) + $css_default = "all"; + + if(method_exists('theme', 'css')) // new v2.3.2 theme styles load override. + { + e107::callMethod('theme', 'css'); + } + elseif (isset($theme_css_php) && $theme_css_php) { //echo "\n"; $e_js->themeCSS('theme-css.php', $css_default); @@ -352,16 +356,10 @@ $e_js->renderLinks(); // Other CSS - from unknown location, different from core/theme/plugin location or backward compatibility; NOTE - could be removed in the future!!! -//TODO Additional options for 'bootstrap' and 'style' (ie. THEME_STYLE loaded above). Requires changes to js_manager.php - - - - - $CSSORDER = deftrue('CSSORDER') ? explode(",",CSSORDER) : array('library', 'other','core','plugin','theme','inline'); /** Experimental - Subject to removal at any time. Use at own risk */ -if(method_exists('theme', 'css')) +if(method_exists('theme', 'cssFilter')) { $e_js->set('_theme_css_processor', true); } diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index c87801068..c56da6f20 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -2652,7 +2652,7 @@ class e107 $jshandler = self::getJs(); $jshandler->setDependency($dep); - if(strpos($data,'http')===0) + if(strpos($data,'http')===0 && ($type !== 'theme')) { $type = 'url'; } @@ -2670,7 +2670,7 @@ class e107 break; case 'theme': - // data is path relative to current theme + // data is path relative to current theme or URL to load in the 'theme' zone. $jshandler->themeCSS($data, $media, $preComment, $postComment); break; diff --git a/e107_handlers/js_manager.php b/e107_handlers/js_manager.php index cc991baeb..591b7a22d 100644 --- a/e107_handlers/js_manager.php +++ b/e107_handlers/js_manager.php @@ -1083,7 +1083,7 @@ class e_jsmanager break; case 'theme_css': - $file_path = $runtime_location.$this->_sep.'{e_THEME}'.$this->getCurrentTheme().'/'.trim($file_path, '/').$this->_sep.$pre.$this->_sep.$post; + $file_path = $runtime_location.$this->_sep.(strpos($file_path, 'http') !== 0 && strpos($file_path, '//') !== 0 ?'{e_THEME}'.$this->getCurrentTheme().'/'.trim($file_path, '/') : $file_path).$this->_sep.$pre.$this->_sep.$post; if(!isset($this->_e_css['theme'])) $this->_e_css['theme'] = array(); $registry = &$this->_e_css['theme']; $runtime = true; @@ -1291,8 +1291,8 @@ class e_jsmanager case 'core_css': //e_jslib if($this->_theme_css_processor) { - $this->_e_css['core'] = e107::callMethod('theme', 'css', $this->_e_css['core'], 'core'); - e107::getMessage()->addDebug('Theme css() method is experimental and is subject to removal at any time. Use at own risk'); + $this->_e_css['core'] = e107::callMethod('theme', 'cssFilter', $this->_e_css['core'], 'core'); + e107::getMessage()->addDebug('Theme cssFilter() method is experimental and is subject to removal at any time. Use at own risk'); } $this->renderFile(varset($this->_e_css['core'], array()), $external, 'Core CSS', $mod, false); unset($this->_e_css['core']); @@ -1301,7 +1301,7 @@ class e_jsmanager case 'plugin_css': //e_jslib if($this->_theme_css_processor) { - $this->_e_css['plugin'] = e107::callMethod('theme', 'css', $this->_e_css['plugin'], 'plugin'); + $this->_e_css['plugin'] = e107::callMethod('theme', 'cssFilter', $this->_e_css['plugin'], 'plugin'); } $this->renderFile(varset($this->_e_css['plugin'], array()), $external, 'Plugin CSS', $mod, false); unset($this->_e_css['plugin']); @@ -1315,7 +1315,7 @@ class e_jsmanager case 'other_css': if($this->_theme_css_processor) { - $this->_e_css['other'] = e107::callMethod('theme', 'css', $this->_e_css['other'], 'other'); + $this->_e_css['other'] = e107::callMethod('theme', 'cssFilter', $this->_e_css['other'], 'other'); } $this->renderFile(varset($this->_e_css['other'], array()), $external, 'Other CSS', $mod, false); unset($this->_e_css['other']); diff --git a/e107_handlers/theme_handler.php b/e107_handlers/theme_handler.php index c80583bed..181efe805 100644 --- a/e107_handlers/theme_handler.php +++ b/e107_handlers/theme_handler.php @@ -166,7 +166,7 @@ class e_theme /** * Return an array of theme library or stylesheet values (as defined in theme.xml) that match the desired scope. * @note New in v2.3.1+ - * @param string $type library | stylesheet + * @param string $type library | css * @param string $scope front | admin | all | auto (as defined in theme.xml) * @return array */ @@ -287,8 +287,7 @@ class e_theme /** * Load library dependencies. * - * @param string $scope - * front | admin | all | auto + * @param string $scope front | admin | all | auto */ public function loadLibrary($scope = 'auto') { @@ -302,6 +301,8 @@ class e_theme $loaded = []; + $excludeCSS = (string) $this->cssAttribute('auto', 'exclude'); // current theme style + foreach($libraries as $name => $library) { @@ -310,6 +311,11 @@ class e_theme continue; } + if($name === $excludeCSS) + { + $library['files'] = 'js'; // load only JS, but not CSS since the style excluded it. + } + if($name === 'bootstrap' && !empty($library['version'])) { if((int) $library['version'] > 3) // quick fix. @@ -884,7 +890,7 @@ class e_theme if(!empty($themeArray[$file]['css']) && count($themeArray[$file]['css']) > 1) { $themeArray[$file]['multipleStylesheets'] = true; - } + } @@ -1348,7 +1354,7 @@ class e_theme define('THEME_STYLE', $pref['admincss']); self::initThemeLayout(); // the equivalent for frontend is in header_default.php } - elseif(!empty($pref['themecss']) && file_exists(THEME.$pref['themecss'])) + elseif(!empty($pref['themecss']) && (file_exists(THEME.$pref['themecss']) || strpos($pref['themecss'],'https') === 0)) { define('THEME_STYLE', $pref['themecss']); } @@ -2831,38 +2837,12 @@ class themeHandler $text .= varset($itext); - - // Render skin previews. - if(self::RENDER_ADMINPREFS === $mode) + if($skinText = self::renderSkin($theme, $mode, $pref)) { - $parms = []; - $parms['path'] = e_THEME.$theme['path'].'/'; - $parms['block-class'] = 'admin-css-selector col-md-3'; - - foreach($theme['css'] as $val) - { - $kid = $val['name']; - // $val['description']; - $parms['optArray'][$kid] = array( - 'thumbnail' => $val['thumbnail'], - 'label' => $val['info']."
".$val['description']."", - ); - } - - $text .= "".TPVLAN_95.": - - "; - $text .= e107::getForm()->radioImage('admincss', vartrue($pref['admincss']), $parms); - $text .= ""; - - + $text .= $skinText; } - - - - - if(array_key_exists("multipleStylesheets", $theme) && $mode && !empty($theme['css']) && self::RENDER_SITEPREFS === $mode) + elseif(!empty($theme['multipleStylesheets']) && $mode && !empty($theme['css']) && self::RENDER_SITEPREFS === $mode) { $pLabel = TPVLAN_22; @@ -3461,8 +3441,48 @@ class themeHandler } */ + /** + * @param array $theme + * @param string $mode + * @param mixed $value + * @return array + */ + private static function renderSkin($theme, $mode, $pref) + { + $parms = []; + $parms['path'] = e_THEME . $theme['path'] . '/'; + $parms['block-class'] = 'admin-css-selector col-md-3'; + foreach($theme['css'] as $val) + { + if(empty($val['thumbnail'])) + { + continue; + } + + $kid = $val['name']; + // $val['description']; + $parms['optArray'][$kid] = array( + 'thumbnail' => $val['thumbnail'], + 'label' => $val['info'] . "
" . $val['description'] . "", + ); + } + + if(empty($parms['optArray'])) + { + return ''; + } + + $text = "" . TPVLAN_95 . ": + + "; + $css = ($mode === self::RENDER_ADMINPREFS) ? 'admincss' : 'themecss'; + $text .= e107::getForm()->radioImage($css, vartrue($pref[$css]), $parms); + $text .= ""; + + return $text; + } } diff --git a/e107_plugins/hero/templates/hero_template.php b/e107_plugins/hero/templates/hero_template.php index 0ebcca822..3eb6a069a 100644 --- a/e107_plugins/hero/templates/hero_template.php +++ b/e107_plugins/hero/templates/hero_template.php @@ -30,7 +30,7 @@ $HERO_TEMPLATE['default']['footer'] = ''; -$HERO_TEMPLATE['default']['start'] = '