mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 03:40:37 +02:00
Theme manager: stylesheet detection improved.
This commit is contained in:
@@ -264,7 +264,10 @@ class themeHandler
|
|||||||
$nonadmin = preg_match('/\* Non-Admin(.*?)\*\//', $cssContents) ? true : false;
|
$nonadmin = preg_match('/\* Non-Admin(.*?)\*\//', $cssContents) ? true : false;
|
||||||
preg_match('/\* info:(.*?)\*\//', $cssContents, $match);
|
preg_match('/\* info:(.*?)\*\//', $cssContents, $match);
|
||||||
$match[1] = varset($match[1], '');
|
$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
|
else
|
||||||
@@ -292,6 +295,8 @@ class themeHandler
|
|||||||
$themeArray[$file]['multipleStylesheets'] = TRUE;
|
$themeArray[$file]['multipleStylesheets'] = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return $themeArray[$file];
|
return $themeArray[$file];
|
||||||
|
|
||||||
|
|
||||||
@@ -1065,7 +1070,7 @@ class themeHandler
|
|||||||
$previewPath = e_BASE."index.php?themepreview.".$theme['id'];
|
$previewPath = e_BASE."index.php?themepreview.".$theme['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$thumbnail = "<img src='".$thumbPath."' style='width:100%; height:130px;' alt='' />";
|
$thumbnail = "<img src='".$thumbPath."' style='width:100%; max-height:200px;' alt='' />";
|
||||||
|
|
||||||
|
|
||||||
if($_GET['mode'] == 'online')
|
if($_GET['mode'] == 'online')
|
||||||
@@ -1375,41 +1380,11 @@ class themeHandler
|
|||||||
|
|
||||||
$text .= $itext;
|
$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 .= "
|
$text .= "
|
||||||
<tr><td style='vertical-align:top;'><b>".TPVLAN_22.":</b></td>
|
<tr><td style='vertical-align:top;'><b>".TPVLAN_22.":</b></td>
|
||||||
@@ -1426,44 +1401,34 @@ class themeHandler
|
|||||||
{
|
{
|
||||||
|
|
||||||
$text2 = "";
|
$text2 = "";
|
||||||
|
|
||||||
|
switch($mode)
|
||||||
|
|
||||||
if($mode == 2) // ADMIN MODE
|
|
||||||
{
|
{
|
||||||
if($css['name'] == "style.css" || !vartrue($css['info'])) // Hide the admin css unless it has a header. eg. /* info: Default stylesheet */
|
case 2: // admin mode.
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!$css['nonadmin'])
|
|
||||||
{
|
|
||||||
$for = $frm->name2id("admincss-".$css['name']);
|
$for = $frm->name2id("admincss-".$css['name']);
|
||||||
$text2 = "
|
$text2 = "
|
||||||
<td class='center'>".
|
<td class='center'>".
|
||||||
$frm->radio('admincss', $css['name'], vartrue($pref['admincss'])== $css['name'])."
|
$frm->radio('admincss', $css['name'], vartrue($pref['admincss'])== $css['name'])."
|
||||||
</td>
|
</td>
|
||||||
<td><label for='".$for."'>".$css['info']."</label></td>";
|
<td><label for='".$for."'>".$css['info']."</label></td>";
|
||||||
|
|
||||||
$text2 .= "<td>".($css['info'] ? $css['info'] : ($css['name'] == "admin_style.css" ? TPVLAN_23 : TPVLAN_24))."</td>\n";
|
$text2 .= "<td>".($css['info'] ? $css['info'] : ($css['name'] == "admin_style.css" ? TPVLAN_23 : TPVLAN_24))."</td>\n";
|
||||||
}
|
|
||||||
}
|
break;
|
||||||
|
|
||||||
if($mode == 1) // SITE-THEME Mode
|
case 1: // front 'sitetheme' mode.
|
||||||
{
|
|
||||||
if(substr($css['name'], 0, 6) == "admin_")
|
$text2 = "
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$text2 = "
|
|
||||||
<td class='center'>
|
<td class='center'>
|
||||||
<input id='".$frm->name2id($css['name'])."' type='radio' name='themecss' value='".$css['name']."' ".($pref['themecss'] == $css['name'] || (!$pref['themecss'] && $css['name'] == "style.css") ? " checked='checked'" : "")." />
|
<input id='".$frm->name2id($css['name'])."' type='radio' name='themecss' value='".$css['name']."' ".($pref['themecss'] == $css['name'] || (!$pref['themecss'] && $css['name'] == "style.css") ? " checked='checked'" : "")." />
|
||||||
</td>
|
</td>
|
||||||
<td><label for='".$frm->name2id($css['name'])."' >".$css['name']."</lable></td>
|
<td><label for='".$frm->name2id($css['name'])."' >".$css['name']."</lable></td>
|
||||||
<td>".($css['info'] ? $css['info'] : ($css['name'] == "style.css" ? TPVLAN_23 : TPVLAN_24))."</td>\n";
|
<td>".($css['info'] ? $css['info'] : ($css['name'] == "style.css" ? TPVLAN_23 : TPVLAN_24))."</td>\n";
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$text .= ($text2) ? "<tr>".$text2."</tr>" : "";
|
$text .= ($text2) ? "<tr>".$text2."</tr>" : "";
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1471,13 +1436,7 @@ class themeHandler
|
|||||||
$text .= "</table></td></tr>";
|
$text .= "</table></td></tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
if($mode == 1)
|
|
||||||
{
|
|
||||||
$text .= $this->renderThemeConfig();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
$text .= "</table>
|
$text .= "</table>
|
||||||
|
|
||||||
|
|
||||||
@@ -1544,6 +1503,108 @@ class themeHandler
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private function filterStylesheets($mode, $theme)
|
||||||
|
{
|
||||||
|
|
||||||
|
$remove = array();
|
||||||
|
$detected = array();
|
||||||
|
|
||||||
|
if($mode == 1)
|
||||||
|
{
|
||||||
|
foreach($theme['css'] as $k=>$v) // check if wildcard is present.
|
||||||
|
{
|
||||||
|
if($v['name'] == '*')
|
||||||
|
{
|
||||||
|
foreach($theme['files'] as $val) // get wildcard list of css files.
|
||||||
|
{
|
||||||
|
if(substr($val,-4) == '.css' && substr($val, 0, 6) != "admin_")
|
||||||
|
{
|
||||||
|
$detected[$val] = array('name'=>$val, 'info'=>'User-added Stylesheet', 'nonadmin'=>1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
foreach($theme['css'] as $k=>$vl) // as defined.
|
||||||
|
{
|
||||||
|
if(!empty($detected[$vl['name']])) // remove any detected files which are listed
|
||||||
|
{
|
||||||
|
unset($detected[$vl['name']]);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch($mode)
|
||||||
|
{
|
||||||
|
case 1: // frontend
|
||||||
|
|
||||||
|
if(substr($vl['name'], 0, 6) == "admin_")
|
||||||
|
{
|
||||||
|
$remove[$k] = $vl['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if($vl['scope'] == 'admin')
|
||||||
|
{
|
||||||
|
$remove[$k] = $vl['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if($vl['name'] == '*' )
|
||||||
|
{
|
||||||
|
$remove[$k] = $vl['name'];
|
||||||
|
|
||||||
|
$wildcard = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2: // admin
|
||||||
|
|
||||||
|
if($vl['name'] == "style.css" || empty($vl['info'])) // Hide the admin css unless it has a header. eg. /* info: Default stylesheet */
|
||||||
|
{
|
||||||
|
$remove[$k] = $vl['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if($vl['name'] == '*' )
|
||||||
|
{
|
||||||
|
$remove[$k] = $vl['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if($vl['scope'] == 'front')
|
||||||
|
{
|
||||||
|
$remove[$k] = $vl['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!empty($vl['nonadmin']))
|
||||||
|
{
|
||||||
|
$remove[$k] = $vl['name'];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($remove as $k=>$file)
|
||||||
|
{
|
||||||
|
unset($theme['css'][$k]);
|
||||||
|
// unset($detected[$file]);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($detected as $k=>$v)
|
||||||
|
{
|
||||||
|
$theme['css'][] = $v;
|
||||||
|
}
|
||||||
|
|
||||||
|
// print_a($detected);
|
||||||
|
// print_a($remove);
|
||||||
|
|
||||||
|
return $theme['css'];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function renderPresets($key)
|
function renderPresets($key)
|
||||||
{
|
{
|
||||||
@@ -2162,7 +2223,7 @@ class themeHandler
|
|||||||
{
|
{
|
||||||
$notadmin = vartrue($val['@attributes']['admin']) ? false : true;
|
$notadmin = vartrue($val['@attributes']['admin']) ? false : true;
|
||||||
|
|
||||||
$vars['css'][] = array("name" => $val['@attributes']['file'], "info"=> $val['@attributes']['name'], "nonadmin"=>$notadmin);
|
$vars['css'][] = array("name" => $val['@attributes']['file'], "info"=> $val['@attributes']['name'], "nonadmin"=>$notadmin, 'scope'=>$val['@attributes']['scope']);
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($vars['stylesheets']);
|
unset($vars['stylesheets']);
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
</screenshots>
|
</screenshots>
|
||||||
<stylesheets>
|
<stylesheets>
|
||||||
<css file="style.css" name="Default" />
|
<css file="style.css" name="Default" />
|
||||||
|
<css file="css/bootstrap-dark.min.css" name="Bootstrap3 Dark Admin" scope='admin' />
|
||||||
<css file="*" name="*" />
|
<css file="*" name="*" />
|
||||||
</stylesheets>
|
</stylesheets>
|
||||||
<layouts>
|
<layouts>
|
||||||
|
Reference in New Issue
Block a user