From e26efc242f6b5e46b5970762b45007029a12ef3a Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 18 Jul 2015 13:16:11 -0700 Subject: [PATCH] Theme manager: stylesheet detection improved. --- e107_handlers/theme_handler.php | 193 ++++++++++++++++++++----------- e107_themes/bootstrap3/theme.xml | 1 + 2 files changed, 128 insertions(+), 66 deletions(-) diff --git a/e107_handlers/theme_handler.php b/e107_handlers/theme_handler.php index 5684fcb97..ca4905b8f 100644 --- a/e107_handlers/theme_handler.php +++ b/e107_handlers/theme_handler.php @@ -264,7 +264,10 @@ class themeHandler $nonadmin = preg_match('/\* Non-Admin(.*?)\*\//', $cssContents) ? true : false; preg_match('/\* info:(.*?)\*\//', $cssContents, $match); $match[1] = varset($match[1], ''); - $themeArray[$file]['css'][] = array("name"=>$file2, "info"=>$match[1], "nonadmin"=>$nonadmin); + $scope = ($nonadmin == true) ? 'front' : ''; + + + $themeArray[$file]['css'][] = array("name"=>$file2, "info"=>$match[1], "scope"=>$scope, "nonadmin"=>$nonadmin); } else @@ -292,6 +295,8 @@ class themeHandler $themeArray[$file]['multipleStylesheets'] = TRUE; } + + return $themeArray[$file]; @@ -1065,7 +1070,7 @@ class themeHandler $previewPath = e_BASE."index.php?themepreview.".$theme['id']; } - $thumbnail = ""; + $thumbnail = ""; if($_GET['mode'] == 'online') @@ -1375,41 +1380,11 @@ class themeHandler $text .= $itext; - $wildcard = false; - $curCss = array(); - - - foreach($theme['css'] as $k=>$vl) - { - if($vl['name'] == '*') - { - unset($theme['css'][$k]); - $wildcard = true; - } - else - { - $curCss[] = $vl['name']; - } - } - - - if($wildcard == true) - { - foreach($theme['files'] as $val) - { - if(substr($val,-4) == '.css' && substr($val,0,5) != 'admin_' && !in_array($val, $curCss)) - { - $theme['css'][] = array('name'=>$val, 'info'=>'User-added Stylesheet', 'nonadmin'=>1); - } - } - - } - - + $theme['css'] = $this->filterStylesheets($mode, $theme); - if(array_key_exists("multipleStylesheets", $theme) && $mode) + if(array_key_exists("multipleStylesheets", $theme) && $mode && !empty($theme['css'])) { $text .= " ".TPVLAN_22.": @@ -1426,44 +1401,34 @@ class themeHandler { $text2 = ""; - - - - if($mode == 2) // ADMIN MODE + + switch($mode) { - if($css['name'] == "style.css" || !vartrue($css['info'])) // Hide the admin css unless it has a header. eg. /* info: Default stylesheet */ - { - continue; - } - - if(!$css['nonadmin']) - { + case 2: // admin mode. + $for = $frm->name2id("admincss-".$css['name']); $text2 = " ". $frm->radio('admincss', $css['name'], vartrue($pref['admincss'])== $css['name'])." "; - + $text2 .= "".($css['info'] ? $css['info'] : ($css['name'] == "admin_style.css" ? TPVLAN_23 : TPVLAN_24))."\n"; - } - } - - if($mode == 1) // SITE-THEME Mode - { - if(substr($css['name'], 0, 6) == "admin_") - { - continue; - } - - $text2 = " + + break; + + case 1: // front 'sitetheme' mode. + + $text2 = "