1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-09 16:17:14 +02:00

reformat a bit

This commit is contained in:
marj
2009-10-28 23:45:46 +00:00
parent 724b0e6805
commit bc7669ed4c

View File

@@ -9,12 +9,15 @@
* e107 Admin Theme Handler
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/theme_handler.php,v $
* $Revision: 1.55 $
* $Date: 2009-10-24 07:53:25 $
* $Author: e107coders $
* $Revision: 1.56 $
* $Date: 2009-10-28 23:45:46 $
* $Author: marj_nl_fr $
*/
if (!defined('e107_INIT')) { exit; }
if(!defined('e107_INIT'))
{
exit;
}
/**
* Base e107 Admin Theme Handler
@@ -25,7 +28,8 @@ if (!defined('e107_INIT')) { exit; }
* @author Cameron
* @copyright Copyright (c) 2009, e107 Inc.
*/
class themeHandler{
class themeHandler
{
var $themeArray;
var $action;
@@ -34,8 +38,7 @@ class themeHandler{
var $fl;
var $themeConfigObj = null;
var $noLog = FALSE;
public $allowedCategories = array(
'generic',
public $allowedCategories = array('generic',
'adult',
'blog',
'clan',
@@ -47,12 +50,12 @@ class themeHandler{
'news',
'social',
'video',
'multimedia'
);
'multimedia');
/* constructor */
function themeHandler() {
function themeHandler()
{
global $emessage,$e107cache,$pref;
@@ -188,21 +191,28 @@ class themeHandler{
closedir($handle);
/*
echo "<pre>";
print_r($themeArray);
echo "</pre>";*/
return $themeArray;
}
function getThemeInfo($file)
{
$STYLESHEET = FALSE;
$reject = array('$.','$..','/','CVS','thumbs.db','*._$', 'index', 'null*','e_*');
$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)
{
@@ -223,12 +233,15 @@ class themeHandler{
if($fp = fopen(e_THEME.$file."/".$file2, "r"))
{
// FIXME: use info from theme.xml alternateStyleSheet instead
$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);
$themeArray[$file]['css'][] = array("name"=>$file2,
"info"=>$match[1],
"nonadmin"=>$nonadmin);
if($STYLESHEET)
{
$themeArray[$file]['multipleStylesheets'] = TRUE;
@@ -241,9 +254,6 @@ class themeHandler{
}
} // end while..
@@ -261,8 +271,6 @@ class themeHandler{
}
return $themeArray[$file];
@@ -300,11 +308,10 @@ class themeHandler{
}
function themeUpload()
{
if (!$_POST['ac'] == md5(ADMINPWCHANGE)) {
if(!$_POST['ac'] == md5(ADMINPWCHANGE))
{
exit;
}
global $ns,$emessage;
@@ -322,29 +329,39 @@ class themeHandler{
$fileSize = $file_userfile['size'][0];
$fileType = $file_userfile['type'][0];
if(strstr($file_userfile['type'][0], "gzip")) {
if(strstr($file_userfile['type'][0], "gzip"))
{
$fileType = "tar";
} else if (strstr($file_userfile['type'][0], "zip")) {
}
else
if(strstr($file_userfile['type'][0], "zip"))
{
$fileType = "zip";
} else {
}
else
{
$emessage->add(TPVLAN_17, E_MESSAGE_ERROR);
// $ns->tablerender(TPVLAN_16, TPVLAN_17);
// require_once("footer.php");
return FALSE;
}
if ($fileSize) {
if($fileSize)
{
$uploaded = file_upload(e_THEME);
$archiveName = $uploaded[0]['name'];
if($fileType == "zip") {
if($fileType == "zip")
{
require_once (e_HANDLER."pclzip.lib.php");
$archive = new PclZip(e_THEME.$archiveName);
$unarc = ($fileList = $archive->extract(PCLZIP_OPT_PATH, e_THEME, PCLZIP_OPT_SET_CHMOD, 0666));
} else {
}
else
{
require_once (e_HANDLER."pcltar.lib.php");
$unarc = ($fileList = PclTarExtract($archiveName, e_THEME));
}
@@ -444,7 +461,8 @@ class themeHandler{
{
global $sql,$ns,$emessage;
if(!is_writable(e_THEME)) {
if(!is_writable(e_THEME))
{
$ns->tablerender(TPVLAN_16, TPVLAN_15);
$text = "";
}
@@ -488,10 +506,6 @@ class themeHandler{
}
function renderThemeInfo($theme)
{
@@ -595,7 +609,6 @@ class themeHandler{
}
function renderThemeConfig() // process custom theme configuration - TODO.
{
global $frm;
@@ -624,7 +637,6 @@ class themeHandler{
}
function setThemeConfig()
{
$this->loadThemeConfig();
@@ -646,7 +658,6 @@ class themeHandler{
global $ns,$pref,$frm;
$author = ($theme['email'] ? "<a href='mailto:".$theme['email']."' title='".$theme['email']."'>".$theme['author']."</a>" : $theme['author']);
$website = ($theme['website'] ? "<a href='".$theme['website']."' rel='external'>".$theme['website']."</a>" : "");
$preview = "<a href='".e_BASE."news.php?themepreview.".$theme['id']."' title='".TPVLAN_9."' >".($theme['preview'] ? "<img src='".$theme['preview']."' style='border: 1px solid #000;width:200px' alt='' />" : "<img src='".e_IMAGE_ABS."admin_images/nopreview.png' title='".TPVLAN_12."' alt='' />")."</a>";
@@ -751,7 +762,6 @@ class themeHandler{
}
if($mode == 1) // New in 0.8 ---- site theme.
{
@@ -821,7 +831,8 @@ class themeHandler{
$itext .= "</td>
<td style='vertical-align:top'>";
$itext .= ($pref['sitetheme_deflayout'] != $key) ? $custompage_diz."<div class='e-hideme' id='element-to-be-shown'><textarea style='width:97%' rows='6' cols='20' name='custompages[".$key."]' >".(isset($pref['sitetheme_custompages'][$key]) ? implode("\n",$pref['sitetheme_custompages'][$key]) : "")."</textarea></div>\n" : TPVLAN_55; // Default
$itext .= ($pref['sitetheme_deflayout'] != $key) ? $custompage_diz."<div class='e-hideme' id='element-to-be-shown'><textarea style='width:97%' rows='6' cols='20' name='custompages[".$key."]' >".(isset($pref['sitetheme_custompages'][$key]) ? implode("\n",
$pref['sitetheme_custompages'][$key]) : "")."</textarea></div>\n" : TPVLAN_55; // Default
$itext .= "</td>";
@@ -865,22 +876,19 @@ class themeHandler{
}
$text .= $itext;
if(array_key_exists("multipleStylesheets", $theme) && $mode)
{
$text .= "
<tr><td style='vertical-align:top;'><b>".TPVLAN_22.":</b></td><td colspan='2' style='vertical-align:top'>
<tr><td style='vertical-align:top;'><b>".TPVLAN_22.":</b></td>
<td colspan='2' style='vertical-align:top'>
<table class='adminlist' style='width:100%' >
<tr>
<td class='center' style='width:10%'>".TPVLAN_55."</td>
<td style='width:20%'>".TPVLAN_52."</td>
<td class='left'>".TPVLAN_7."</td>
</tr>\n";
</tr>";
foreach ($theme['css'] as $css)
@@ -894,7 +902,8 @@ class themeHandler{
if($mode == 2)
{
if (!$css['nonadmin']) {
if(!$css['nonadmin'])
{
$text2 = "
<td class='center'>
<input type='radio' name='admincss' value='".$css['name']."' ".($pref['admincss'] == $css['name'] || (!$pref['admincss'] && $css['name'] == "style.css") ? " checked='checked'" : "")." />
@@ -925,10 +934,6 @@ class themeHandler{
}
if($mode == 1)
{
$text .= $this->renderThemeConfig();
@@ -1130,9 +1135,8 @@ class themeHandler{
{
global $pref,$e107cache,$ns,$sql,$emessage;
//TODO adminlog
e107::getConfig()->setPosted('themecss', $_POST['themecss'])
->setPosted('image_preload', $_POST['image_preload'])
->setPosted('sitetheme_deflayout', $_POST['layout_default']);
e107::getConfig()->setPosted('themecss', $_POST['themecss'])->setPosted('image_preload', $_POST['image_preload'])->setPosted('sitetheme_deflayout',
$_POST['layout_default']);
$msg = $this->setThemeConfig();
if($msg)
@@ -1148,8 +1152,6 @@ class themeHandler{
global $pref,$e107cache,$ns,$emessage;
/*$pref['admincss'] = $_POST['admincss'];
$pref['adminstyle'] = $_POST['adminstyle'];
$e107cache->clear_sys();
if(save_prefs())
{
@@ -1160,16 +1162,20 @@ class themeHandler{
{
$emessage->add(TPVLAN_43, E_MESSAGE_ERROR);
}*/
//TODO adminlog
e107::getConfig()->setPosted('admincss', $_POST['admincss'])
->setPosted('adminstyle', $_POST['adminstyle']);
e107::getConfig()->setPosted('admincss', $_POST['admincss'])->setPosted('adminstyle', $_POST['adminstyle']);
return (e107::getConfig()->dataHasChangedFor('admincss') || e107::getConfig()->dataHasChangedFor('adminstyle'));
}
function SetCustomPages($array)
{
if(!is_array($array)){ return; }
if(!is_array($array))
{
return;
}
//global $pref;
$key = key($array);
@@ -1241,7 +1247,11 @@ class themeHandler{
}
$lays['legacyDefault']['@attributes'] = array('title'=>'Default','preview'=>'','previewFull'=>'','plugins'=>'', 'default'=>'true');
$lays['legacyDefault']['@attributes'] = array('title'=>'Default',
'preview'=>'',
'previewFull'=>'',
'plugins'=>'',
'default'=>'true');
if(!file_exists(e_THEME.$path."theme.xml")) // load custompages from theme.php only when theme.xml doesn't exist.
{
@@ -1262,7 +1272,10 @@ class themeHandler{
elseif($CUSTOMPAGES)
{
$themeArray['custompages']['legacyCustom'] = explode(" ", $CUSTOMPAGES);
$lays['legacyCustom']['@attributes'] = array('title'=>'Custom','preview'=>'','previewFull'=>'','plugins'=>'');
$lays['legacyCustom']['@attributes'] = array('title'=>'Custom',
'preview'=>'',
'previewFull'=>'',
'plugins'=>'');
}
}
@@ -1302,7 +1315,6 @@ class themeHandler{
// Compile layout information into a more usable format.
$custom = array();
foreach ($vars['layouts'] as $layout)