1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-30 19:30:25 +02:00

Some theme-manager fixes, theme-preview fixes etc. Had to move up theme-loading before menu loading in class2.php. Let's hope it doesn't break anything.

This commit is contained in:
CaMer0n
2009-07-12 14:44:57 +00:00
parent 28f2146f1e
commit 97286190ad
5 changed files with 191 additions and 125 deletions

View File

@@ -9,8 +9,8 @@
* General purpose file
*
* $Source: /cvs_backup/e107_0.8/class2.php,v $
* $Revision: 1.106 $
* $Date: 2009-07-11 01:48:40 $
* $Revision: 1.107 $
* $Date: 2009-07-12 14:44:56 $
* $Author: e107coders $
*
*/
@@ -696,6 +696,7 @@ $sql->db_Mark_Time('Start: Load Theme');
//########### Module redefinable functions ###############
if (!function_exists('checkvalidtheme'))
{
function checkvalidtheme($theme_check)
{
// arg1 = theme to check
@@ -704,8 +705,13 @@ if (!function_exists('checkvalidtheme'))
if (ADMIN && strpos(e_QUERY, 'themepreview') !== false)
{
list($action, $id) = explode('.', e_QUERY);
require_once(e_HANDLER.'theme_handler.php');
$themeArray = themeHandler :: getThemes('id');
$themeobj = new themeHandler;
$themeArray = $themeobj->getThemes('id');
$themeDef = $themeobj->findDefault($themeArray[$id]);
define('THEME_LAYOUT',$themeDef);
define('PREVIEWTHEME', e_THEME.$themeArray[$id].'/');
define('PREVIEWTHEMENAME', $themeArray[$id]);
@@ -926,6 +932,56 @@ if (isset($_COOKIE['e107_tzOffset']))
define('TIMEOFFSET', $e_deltaTime);
// ----------------------------------------------------------------------------
$sql->db_Mark_Time('(Start: Find/Load Theme)');
// Work out which theme to use
//----------------------------
// The following files are assumed to use admin theme:
// 1. Any file in the admin directory (check for non-plugin added to avoid mismatches)
// 2. any plugin file starting with 'admin_'
// 3. any plugin file in a folder called admin/
// 4. any file that specifies $eplug_admin = TRUE;
//
// e_SELF has the full HTML path
$inAdminDir = FALSE;
$isPluginDir = strpos(e_SELF,'/'.$PLUGINS_DIRECTORY) !== FALSE; // True if we're in a plugin
$e107Path = str_replace($e107->base_path, '', e_SELF); // Knock off the initial bits
if (
(!$isPluginDir && strpos($e107Path, $ADMIN_DIRECTORY) === 0 ) // Core admin directory
|| ($isPluginDir && (strpos(e_PAGE,'admin_') === 0 || strpos($e107Path, 'admin/') !== false)) // Plugin admin file or directory
|| (varsettrue($eplug_admin)) // Admin forced
)
{
$inAdminDir = true;
}
if(!defined('THEME'))
{
if ($inAdminDir && varsettrue($pref['admintheme'])&& (strpos(e_SELF.'?'.e_QUERY, 'menus.php?configure') === false))
{
/* if (strpos(e_SELF, "newspost.php") !== FALSE)
{
define("MAINTHEME", e_THEME.$pref['sitetheme']."/"); MAINTHEME no longer used in core distribution
} */
checkvalidtheme($pref['admintheme']);
}
elseif (USERTHEME !== false && USERTHEME != 'USERTHEME' && !$inAdminDir)
{
checkvalidtheme(USERTHEME);
}
else
{
checkvalidtheme($pref['sitetheme']);
}
}
$theme_pref = varset($pref['sitetheme_pref']);
// --------------------------------------------------------------
$sql->db_Mark_Time('(Start: Find/Load Theme-Layout)'); // needs to run after checkvalidtheme() (for theme previewing).
if(!defined("THEME_LAYOUT"))
{
@@ -934,6 +990,8 @@ if(!defined("THEME_LAYOUT"))
if(is_array($cusPagePref)) // check if we match a page in layout custompages.
{
// print_r($cusPagePref);
foreach($cusPagePref as $lyout=>$cusPageArray)
{
foreach($cusPageArray as $kpage)
@@ -1010,61 +1068,13 @@ if(!isset($_E107['no_menus']))
}
}
$sql->db_Mark_Time('(Start: Find/Load Theme)');
// Work out which theme to use
//----------------------------
// The following files are assumed to use admin theme:
// 1. Any file in the admin directory (check for non-plugin added to avoid mismatches)
// 2. any plugin file starting with 'admin_'
// 3. any plugin file in a folder called admin/
// 4. any file that specifies $eplug_admin = TRUE;
//
// e_SELF has the full HTML path
$inAdminDir = FALSE;
$isPluginDir = strpos(e_SELF,'/'.$PLUGINS_DIRECTORY) !== FALSE; // True if we're in a plugin
$e107Path = str_replace($e107->base_path, '', e_SELF); // Knock off the initial bits
if (
(!$isPluginDir && strpos($e107Path, $ADMIN_DIRECTORY) === 0 ) // Core admin directory
|| ($isPluginDir && (strpos(e_PAGE,'admin_') === 0 || strpos($e107Path, 'admin/') !== false)) // Plugin admin file or directory
|| (varsettrue($eplug_admin)) // Admin forced
)
{
$inAdminDir = true;
}
if(!defined('THEME'))
{
if ($inAdminDir && varsettrue($pref['admintheme'])&& (strpos(e_SELF.'?'.e_QUERY, 'menus.php?configure') === false))
{
/* if (strpos(e_SELF, "newspost.php") !== FALSE)
{
define("MAINTHEME", e_THEME.$pref['sitetheme']."/"); MAINTHEME no longer used in core distribution
} */
checkvalidtheme($pref['admintheme']);
}
elseif (USERTHEME !== false && USERTHEME != 'USERTHEME' && !$inAdminDir)
{
checkvalidtheme(USERTHEME);
}
else
{
checkvalidtheme($pref['sitetheme']);
}
}
$theme_pref = varset($pref['sitetheme_pref']);
// --------------------------------------------------------------
// here we USE the theme
if ($inAdminDir)
{
if (file_exists(THEME.'admin_theme.php') && (strpos(e_SELF.'?'.e_QUERY, $ADMIN_DIRECTORY. 'menus.php?configure')===FALSE)) // no admin theme when previewing.
if (file_exists(THEME.'admin_theme.php') && (strpos(e_SELF.'?'.e_QUERY, $ADMIN_DIRECTORY. 'menus.php?configure')===FALSE)) // no admin theme when previewing.
{
require_once(THEME.'admin_theme.php');
}

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/theme_handler.php,v $
| $Revision: 1.33 $
| $Date: 2009-07-12 10:11:35 $
| $Revision: 1.34 $
| $Date: 2009-07-12 14:44:56 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
@@ -25,6 +25,7 @@ class themeHandler{
var $action;
var $id;
var $frm;
var $fl;
/* constructor */
@@ -33,6 +34,8 @@ class themeHandler{
require_once(e_HANDLER."form_handler.php");
$this->frm = new e_form(); //enable inner tabindex counter
require_once(e_HANDLER."file_class.php");
$this->fl = new e_file;
if (isset($_POST['upload'])) {
@@ -92,6 +95,7 @@ class themeHandler{
$tloop = 1;
$handle = opendir(e_THEME);
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != ".." && $file != "CVS" && $file != "templates" && is_dir(e_THEME.$file) && is_readable(e_THEME.$file."/theme.php") )
@@ -102,45 +106,82 @@ class themeHandler{
}
else
{
$themeArray[$file] = $this->getThemeInfo($file);
$themeArray[$file]['id'] = $tloop;
}
$tloop++;
$STYLESHEET = FALSE;
if(!$mode)
{
$handle2 = opendir(e_THEME.$file."/");
while (false !== ($file2 = readdir($handle2))) // Read files in theme directory
{
if ($file2 != "." && $file2 != ".." && $file != "CVS" && !is_dir(e_THEME.$file."/".$file2))
{
}
}
closedir($handle);
/*
echo "<pre>";
print_r($themeArray);
echo "</pre>";*/
return $themeArray;
}
function getThemeInfo($file)
{
$STYLESHEET = FALSE;
$reject = array('$.','$..','/','CVS','thumbs.db','*._$', 'index', 'null*','e_*');
$handle2 = $this->fl->get_files(e_THEME.$file."/", ".php|.css|.xml|preview.jpg|preview.png",$reject,1);
foreach($handle2 as $fln)
{
$file2 = str_replace(e_THEME.$file."/","",$fln['path']).$fln['fname'];
// $handle2 = opendir(e_THEME.$file."/");
// while (false !== ($file2 = readdir($handle2))) // Read files in theme directory
// {
// echo $file." = ".$file2."<br />";
$themeArray[$file]['files'][] = $file2;
if(strstr($file2, "preview."))
{
$themeArray[$file]['preview'] = e_THEME.$file."/".$file2;
}
// ---------------- get information string for css file
if(strstr($file2, "css") && !strstr($file2, "menu.css") && strpos($file2, "e_") !== 0 && strpos($file2, "admin_") !== 0)
{
/* get information string for css file */
$fp=fopen(e_THEME.$file."/".$file2, "r");
$cssContents = fread ($fp, filesize(e_THEME.$file."/".$file2));
fclose($fp);
$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);
if($STYLESHEET)
if($fp=fopen(e_THEME.$file."/".$file2, "r"))
{
$themeArray[$file]['multipleStylesheets'] = TRUE;
}
else
{
$STYLESHEET = TRUE;
$cssContents = fread ($fp, filesize(e_THEME.$file."/".$file2));
fclose($fp);
$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);
if($STYLESHEET)
{
$themeArray[$file]['multipleStylesheets'] = TRUE;
}
else
{
$STYLESHEET = TRUE;
}
}
}
}
} // end while..
closedir($handle2);
} // end while..
// echo "<hr />";
// closedir($handle2);
// Load Theme information and merge with existing array. theme.xml (0.8 themes) is given priority over theme.php (0.7).
if(in_array("theme.xml",$themeArray[$file]['files']) )
@@ -151,25 +192,20 @@ class themeHandler{
{
$themeArray[$file] = array_merge($themeArray[$file], $this->parse_theme_php($file));
}
}
}
}
closedir($handle);
/*
echo "<table><tr><td>";
echo "<pre>";
print_r($themeArray['jayya']);
echo "</pre>";
echo "</td><td>";
echo "<pre>";
print_r($themeArray['e107v4a']);
echo "</pre>";
echo "</td></tr></table>";*/
return $themeArray;
return $themeArray[$file];
}
function themeUpload()
{
if (!$_POST['ac'] == md5(ADMINPWCHANGE)) {
@@ -604,7 +640,7 @@ class themeHandler{
if(count($theme['layouts'])>1 && $mode==1) // New in 0.8 ----
if($mode==1) // New in 0.8 ----
{
$itext .= "<tr>
@@ -630,7 +666,7 @@ class themeHandler{
{
$pref['sitetheme_deflayout'] = ($val['@attributes']['default']=='true') ? $key : "";
}
$itext .= "<td style='vertical-align:top width:auto;text-align:center'>\n";
$itext .= "<td class='center'>\n";
$itext .= "
<input type='radio' name='layout_default' value='{$key}' ".($pref['sitetheme_deflayout']==$key ? " checked='checked'" : "")." />
@@ -843,16 +879,26 @@ class themeHandler{
$l = $this->themeArray[$theme];
if(!$l)
{
$l = $this->getThemeInfo($theme);
}
if($l['layouts'])
{
foreach($l['layouts'] as $key=>$val)
{
if(isset($val['@attributes']['default']) && ($val['@attributes']['default'] == "true"))
{
return $key;
return $key;
}
}
}
else
{
return "";
}
}
function setAdminTheme()
@@ -897,8 +943,11 @@ class themeHandler{
function SetCustomPages($array)
{
if(!is_array($array)){ return; }
global $pref;
$key = key($array);
$pref['sitetheme_custompages'][$key] = array_filter(explode(" ",$array[$key]));
if($pref['sitetheme_deflayout'] == 'legacyCustom')
@@ -955,28 +1004,31 @@ class themeHandler{
{
unset($themeArray);
}
// echo " <hr>".$path."<hr>";
$lays['legacyDefault']['@attributes'] = array('title'=>'Default','preview'=>'','previewFull'=>'','plugins'=>'', 'default'=>'true');
foreach($themeContentsArray as $line)
if(!file_exists(e_THEME.$path."theme.xml")) // load custompages from theme.php only when theme.xml doesn't exist.
{
if(strstr($line,"CUSTOMPAGES"))
foreach($themeContentsArray as $line)
{
eval(str_replace("$","\$",$line));
if(strstr($line,"CUSTOMPAGES"))
{
eval(str_replace("$","\$",$line));
}
}
if(is_array($CUSTOMPAGES))
{
foreach($CUSTOMPAGES as $key=>$val)
{
$themeArray['custompages'][$key] = explode(" ",$val);
}
}
elseif($CUSTOMPAGES)
{
$themeArray['custompages']['legacyCustom'] = explode(" ",$CUSTOMPAGES);
$lays['legacyCustom']['@attributes'] = array('title'=>'Custom','preview'=>'','previewFull'=>'','plugins'=>'');
}
}
if(is_array($CUSTOMPAGES))
{
foreach($CUSTOMPAGES as $key=>$val)
{
$themeArray['custompages'][$key] = explode(" ",$val);
}
}
elseif($CUSTOMPAGES)
{
$themeArray['custompages']['legacyCustom'] = explode(" ",$CUSTOMPAGES);
$lays['legacyCustom']['@attributes'] = array('title'=>'Custom','preview'=>'','previewFull'=>'','plugins'=>'');
}
$themeArray['path'] = $path;
@@ -1024,6 +1076,7 @@ class themeHandler{
$name = $val['@attributes']['name'];
unset($val['@attributes']['name']);
$lays[$name] = $val;
if(isset($val['customPages']))
{

View File

@@ -4,14 +4,14 @@
| e107 website system - Language File.
|
| $Source: /cvs_backup/e107_0.8/e107_languages/English/admin/lan_theme.php,v $
| $Revision: 1.7 $
| $Date: 2009-07-09 08:31:38 $
| $Revision: 1.8 $
| $Date: 2009-07-12 14:44:57 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
define("TPVLAN_1", "You are looking at a preview of the <b>'".PREVIEWTHEMENAME."'</b> theme. It has not been set as the main theme for your site, it has been activated to provide a preview of how the theme looks.<br />To set this theme as your site theme, <a href='".e_ADMIN."theme.php'>return to your theme manager</a> and select 'Set As Site Theme'.<br />To preview more themes please <a href='".e_ADMIN."theme.php'>click here</a>");
define("TPVLAN_1", "You are looking at a preview of the <b>'".PREVIEWTHEMENAME."'</b> theme. It has not been set as the main theme for your site, it has been activated to provide a preview of how the theme looks.<br />To set this theme as your site theme, <a href='".e_ADMIN."theme.php?choose'>return to your theme manager</a> and select 'Set As Site Theme'.<br />To preview more themes please <a href='".e_ADMIN."theme.php'>click here</a>");
define("TPVLAN_2", "Theme Preview");
define("TPVLAN_3", "Main site theme set to");
define("TPVLAN_4", "Author");
@@ -73,7 +73,7 @@ define("TPVLAN_52", "Name");
define("TPVLAN_53", "Suggested Plugins");
define("TPVLAN_54", "Menu Presets");
define("TPVLAN_55", "Default");
define("TPVLAN_56", "Visibility Filter");
define("TPVLAN_56", "Visibility Filter");

View File

@@ -9,15 +9,15 @@
* Plugin Administration - Login menu
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/login_menu/config.php,v $
* $Revision: 1.5 $
* $Date: 2008-12-21 12:53:48 $
* $Author: e107steved $
* $Revision: 1.6 $
* $Date: 2009-07-12 14:44:57 $
* $Author: e107coders $
*
*/
$eplug_admin = TRUE;
require_once("../../class2.php");
require_once("../../class2.php");
if (!getperms("4"))
{
header("location:".e_BASE."index.php");

View File

@@ -6,8 +6,8 @@
| Released under the terms and conditions of the GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_themes/templates/header_default.php,v $
| $Revision: 1.33 $
| $Date: 2009-07-09 08:31:38 $
| $Revision: 1.34 $
| $Date: 2009-07-12 14:44:57 $
| $Author: e107coders $
+-----------------------------------------------------------------------------------------------+
*/
@@ -340,8 +340,10 @@ if(function_exists('theme_head')){
// FIXME H: Generate JS for image preloads
//
if ($pref['image_preload']) {
if ($pref['image_preload'] && is_dir(THEME.'images'))
{
$ejs_listpics = '';
$handle=opendir(THEME.'images');
while ($file = readdir($handle)) {
if(preg_match("#(jpg|jpeg|gif|bmp|png)$#i", $file)) {
@@ -452,8 +454,9 @@ if ($e107_popup != 1) {
// echo "DEF = ".$def."<br />";
if(($def == 'legacyCustom' || $def=='legacyDefault') && (isset($CUSTOMHEADER) || isset($CUSTOMFOOTER)) ) // 0.6 themes.
if($def == 'legacyCustom' || $def=='legacyDefault' ) // 0.6 themes.
{
// echo "MODE 0.6";
if($def == 'legacyCustom')
{
$HEADER = ($CUSTOMHEADER) ? $CUSTOMHEADER : $HEADER;