<link rel="stylesheet" href="./modules/style/js_color_picker_v2.css" media="screen">
<script src="./modules/style/color_functions.js"></script>
<script type="text/javascript" src="./modules/style/js_color_picker_v2.js"></script>
<?
function HeaderView($request){
$content = null;
global $logoname;
global $textlogo;
//print_r($request);
$obj_style = new CStyle();
$obj_stylearray = new CStyleArray();
$obj_styleengine = new CStyleEngine();
$styleid = $request['styleid'];
$hbgcol = $request['hbgcol'];
$hsize = $request['hsize'];
$hcol = $request['hcol'];
$hbgim = $request['hbgim'];
$newlogofile = $request['newlogofile'];
$newbgfile = $request['newbgfile'];
$ext_logo = $request['ext_logo'];
$ext_bg = $request['ext_bg'];
$new_textlogo = $request['new_textlogo'];
$hbgrep = $request['hbgrep'];
$hbgpos = $request['hbgpos'];
$replace_bg = $request['replace_bg'];
$replace = $request['replace'];
if (!isset($f)) $f="style";
if (!isset($sf)) $sf="header";
if (!isset($new_textlogo)) $new_textlogo=$textlogo;
if (!isset($newlogofile)) $newlogofile="";
if (!isset($ext_logo)) $ext_logo="";
if (!isset($newbgfile)) $newbgfile="";
if (!isset($ext_bg)) $ext_bg="";
/* Read the values */
if (!isset($hbgcol)){
$obj_style = $obj_styleengine->GetActiveStyle();
$styleid = $obj_style->style_id;
$hsize = $obj_style->hsize;
$hcol = $obj_style->hcol;
$hbgcol = $obj_style->hbgcol;
$hbgrep = $obj_style->hbgrep;
$hbgpos = $obj_style->hbgpos;
$hbgim = $obj_style->hbgim;
}
/* $hcol=str_replace("#","#",$hcol); */
/* $hbgcol=str_replace("#","#",$hbgcol); */
$logoimage=$_FILES['new_logo']['tmp_name'];
$logoimage_name=$_FILES['new_logo']['name'];
if ($logoimage_name!=""){
$extension=explode(".",$logoimage_name);
$num_els=count($extension);
$ext_logo=$extension[$num_els - 1];
$newlogofile="./siteimages/temp_logoimage";
if (file_exists($newlogofile)){
unlink($newlogofile);
move_uploaded_file ($logoimage,$newlogofile);
}
else{
move_uploaded_file ($logoimage,$newlogofile);
}
}
$bgimage=$_FILES['new_hbgim']['tmp_name'];
$bgimage_name=$_FILES['new_hbgim']['name'];
if ($bgimage_name!=""){
$extension=explode(".",$bgimage_name);
$num_els=count($extension);
$ext_bg=$extension[$num_els - 1];
$newbgfile="./siteimages/temp_bgimage";
/* if (file_exists($newbgfile)) unlink($newbgfile); */
move_uploaded_file ($bgimage,$newbgfile);
}
$header = _CONTROL_PANEL_."<br>";
$header .= _CP_STYLE_ADMINISTRATION_._CMN_DASH_._CP_SA_HEADER_;
$info = _CP_SA_HEADER_MSG_;
$content = "
<!-- Dynamically switch the action of the form between delete/rename -->
<script language=\"JavaScript\" type=\"text/javascript\">
function OnSubmitForm(){
if(document.pressed == '"._CMN_SAVE_."'){
document.headform.action =\"".basename($PHP_SELF)."?f=style&sf=header&operation=save\";
}
else
if(document.pressed == '"._CMN_PREVIEW_."'){
document.headform.action =\"".basename($PHP_SELF)."?f=style&sf=header&operation=preview\";
}
return true;
}
</SCRIPT>
<center><h3>".$header."</h3></center>
<i><ul>".$info."</ul></i>
<center>
<div id=\"formular\">
<form enctype=\"multipart/form-data\" name=\"headform\" onsubmit=\"return OnSubmitForm();\" method='post'>
<table width=\"95%\" cellpadding=\"5\" cellspacing=\"5\" border=\"1\">
<tr>
<td colspan=\"3\" align=\"center\">
<input type=\"submit\" value=\""._CMN_PREVIEW_."\" name=\"preview\" onclick=\"document.pressed=this.value\" /> "._CMN_OR_."
<input type=\"submit\" value=\""._CMN_SAVE_."\" name=\"save\" onclick=\"document.pressed=this.value\" />
</td>
</tr>
<tr>
<td colspan=\"3\" align=\"left\">
<b>"._CP_SA_HEADER_LOGO_."</b>
</td>
</tr>
<tr>
<td width=\"50%\">"._CP_SA_HP_HEADER_LOGO_MSG_."</td>
<td align=\"left\" width=\"50%\" colspan=\"2\">
<input type=\"hidden\" name=\"textlogo\" value=\"$textlogo\" />
<input type=\"hidden\" name=\"newlogofile\" value=\"$newlogofile\" />
<input type=\"hidden\" name=\"newbgfile\" value=\"$newbgfile\" />
<input type=\"hidden\" name=\"ext_logo\" value=\"$ext_logo\" />
<input type=\"hidden\" name=\"ext_bg\" value=\"$ext_bg\" />
<input type=\"hidden\" name=\"hbgim\" value=\"$hbgim\" />
<input type=\"hidden\" name=\"styleid\" value=\"$styleid\" />
<input type=\"text\" name=\"new_textlogo\" value=\"$new_textlogo\" />
</td>
</tr>
<tr>
<td width=\"50%\">"._CP_SA_HP_HEADER_FONT_SIZE_."</td>
<td align=\"left\" width=\"50%\">
<input type=\"text\" name=\"hsize\" value=\"$hsize\" /> %
</td>
</tr>
<tr>
<td width=\"50%\">"._CP_SA_HP_HEADER_FONT_COLOR_."</td>
<td align=\"left\">
<input type=\"text\" size=\"10\" maxlength=\"7\" name=\"hcol\" value=\"$hcol\" readonly>
<input type=\"button\" value=\""._CP_SA_COLOR_CATALOG_."\" onclick=\"showColorPicker(this,document.forms[0].hcol)\">
</td>
</tr>
<tr>
<td width=\"50%\">"._CP_SA_HP_HEADER_LOGO_."</td>
<td align=\"left\" colspan=\"2\">
<input type=\"file\" name=\"new_logo\" />
</td>
</tr>";
if ($logoname!="" || $newlogofile!=""){
$content .= "
<tr>
<td width=\"50%\">"._CP_SA_HP_HEADER_CHANGE_LOGO_."</td>
<td align=\"left\" colspan=\"2\">
<input type=\"checkbox\" name=\"replace\" ";
if (!isset($replace))
$content .= "unchecked=\"unchecked\" />";
else
$content .= "checked=\"checked\" />";
$content .= "
</td>
</tr>";
}
$content .= "
<tr>
<td colspan=\"3\" align=\"left\">
<b>"._CP_SA_BACKGROUND_."</b>
</td>
</tr>
<tr>
<td width=\"50%\">"._CP_SA_BACKGROUND_COLOR_."</td>
<td colspan=\"2\">
<input type=\"text\" size=\"10\" maxlength=\"7\" name=\"hbgcol\" value=\"$hbgcol\" readonly>
<input type=\"button\" value=\""._CP_SA_COLOR_CATALOG_."\" onclick=\"showColorPicker(this,document.forms[0].hbgcol)\">
</td>
</tr>
<tr>
<td width=\"50%\">"._CP_SA_BACKGROUND_PICTURE_."</td>
<td align=\"left\" colspan=\"2\">
<input type=\"file\" name=\"new_hbgim\" />
</td>
</tr>
<tr>
<td width=\"50%\">"._CP_SA_REPEAT_BACKGROUND_PICTURE_."</td>
<td align=\"left\">
<select name=\"hbgrep\">";
if ($hbgrep=="no-repeat")
$content .= "<option value=\"no-repeat\" selected=\"selected\">"._CP_SA_RBP_OPTION_1_."</option>";
else
$content .= "<option value=\"no-repeat\">"._CP_SA_RBP_OPTION_1_."</option>";
if ($hbgrep=="repeat-x")
$content .= "<option value=\"repeat-x\" selected=\"selected\">"._CP_SA_RBP_OPTION_2_."</option>";
else
$content .= "<option value=\"repeat-x\">"._CP_SA_RBP_OPTION_2_."</option>";
if ($hbgrep=="repeat-y")
$content .= "<option value=\"repeat-y\" selected=\"selected\">"._CP_SA_RBP_OPTION_3_."</option>";
else
$content .= "<option value=\"repeat-y\">"._CP_SA_RBP_OPTION_3_."</option>";
if ($hbgrep=="repeat")
$content .= "<option value=\"repeat\" selected=\"selected\">"._CP_SA_RBP_OPTION_4_."</option>";
else
$content .= "<option value=\"repeat\">"._CP_SA_RBP_OPTION_4_."</option>";
$content .= "
</select>
</td>
</tr>
<tr>
<td width=\"50%\">"._CP_SA_BACKGROUND_PICTURE_POSITION_."</td>
<td align=\"left\">
<select name=\"hbgpos\">";
if ($hbgpos=="0% 0%")
$content .= "<option value=\"0% 0%\" selected=\"selected\">"._CP_SA_UPPER_LEFT_."</option>";
else
$content .= "<option value=\"0% 0%\">"._CP_SA_UPPER_LEFT_."</option>";
if ($hbgpos=="0% 50%")
$content .= "<option value=\"0% 50%\" selected=\"selected\">"._CP_SA_MIDDLE_LEFT_."</option>";
else
$content .= "<option value=\"0% 50%\">"._CP_SA_MIDDLE_LEFT_."</option>";
if ($hbgpos=="0% 100%")
$content .= "<option value=\"0% 100%\" selected=\"selected\">"._CP_SA_LOWER_LEFT_."</option>";
else
$content .= "<option value=\"0% 100%\">"._CP_SA_LOWER_LEFT_."</option>";
if ($hbgpos=="50% 0%")
$content .= "<option value=\"50% 0%\" selected=\"selected\">"._CP_SA_UPPER_MIDDLE_."</option>";
else
$content .= "<option value=\"50% 0%\">"._CP_SA_UPPER_MIDDLE_."</option>";
if ($hbgpos=="50% 50%")
$content .= "<option value=\"50% 50%\" selected=\"selected\">"._CP_SA_MIDDLE_MIDDLE_."</option>";
else
$content .= "<option value=\"50% 50%\">"._CP_SA_MIDDLE_MIDDLE_."</option>";
if ($hbgpos=="50% 100%")
$content .= "<option value=\"50% 100%\" selected=\"selected\">"._CP_SA_LOWER_MIDDLE_."</option>";
else
$content .= "<option value=\"50% 100%\">"._CP_SA_LOWER_MIDDLE_."</option>";
if ($hbgpos=="100% 0%")
$content .= "<option value=\"100% 0%\" selected=\"selected\">"._CP_SA_UPPER_RIGHT_."</option>";
else
$content .= "<option value=\"100% 0%\">"._CP_SA_UPPER_RIGHT_."</option>";
if ($hbgpos=="100% 50%")
$content .= "<option value=\"100% 50%\" selected=\"selected\">"._CP_SA_MIDDLE_RIGHT_."</option>";
else
$content .= "<option value=\"100% 50%\">"._CP_SA_MIDDLE_RIGHT_."</option>";
if ($hbgpos=="100% 100%")
$content .= "<option value=\"100% 100%\" selected=\"selected\">"._CP_SA_LOWER_RIGHT_."</option>";
else
$content .= "<option value=\"100% 100%\">"._CP_SA_LOWER_RIGHT_."</option>";
$content .= "
</select>
</td>
</tr>";
if ($newbgfile!="" || $hbgim!=""){
$content .= "
<tr>
<td>"._CP_SA_CHANGE_BACKGROUND_PICTURE_."</td>
<td align=\"left\" colspan=\"2\">
<input type=\"checkbox\" name=\"replace_bg\" ";
if (!isset($replace_bg))
$content .= "unchecked=\"unchecked\" />";
else
$content .= "checked=\"checked\" />";
}
$content .= "
<tr>
<td colspan=\"3\" align=\"center\">
<input type=\"submit\" value=\""._CMN_PREVIEW_."\" name=\"preview\" onclick=\"document.pressed=this.value\" /> "._CMN_OR_."
<input type=\"submit\" value=\""._CMN_SAVE_."\" name=\"save\" onclick=\"document.pressed=this.value\" />
</td>
</tr>
</table>
</form>
</div>
</center>
</td>
</tr>
</table>
<table width=\"100%\">
<tr>
<td>
<center>
<b>"._CP_SA_PREVIEW_."</b><br />";
$content .= "
<div style=\"font-size:$hsize%; color:$hcol; background-color: $hbgcol;";
if ($newbgfile!="" && !isset($replace_bg)){
$content .= "background-image:url('$newbgfile'); background-repeat:$hbgrep; background-position: $hbgpos;";
}
elseif ($hbgim!="" && !isset($replace_bg)){
$hbgim=str_replace("./","./",$hbgim);
$content .= "background-image:url('$hbgim'); background-repeat:$hbgrep; background-position: $hbgpos;";
}
$content .= "
\">
<table width=\"100%\">
<tr>
<td align=\"left\" valign=\"middle\" style=\"border:solid 1px black\">
<a href=\"index.php\" title=\"".$new_textlogo."\">";
if ($newlogofile!="" && !isset($replace))
$content .= "<img src=\"$newlogofile\" border=\"0\" alt=\"Home page\" />";
elseif ($logoname!="" && !isset($replace))
$content .= "<img src=\"./siteimages/$logoname\" border=\"0\" alt=\"".$new_textlogo."\" />";
else
$content .= "
<br />
<font style=\"color:$hcol\">$new_textlogo</font>
<br /><br />";
$content .= "
</a>
</td>
</tr>
</table>
</div>
</center>";
return $content;
}
function HeaderSave($request){
$content = null;
global $logoname;
global $textlogo;
$obj_style = new CStyle();
$obj_stylearray = new CStyleArray();
$obj_styleengine = new CStyleEngine();
// print_r($request);
$styleid = $request['styleid'];
$hbgcol = $request['hbgcol'];
$hsize = $request['hsize'];
$hcol = $request['hcol'];
$hbgim = $request['hbgim'];
$newlogofile = $request['newlogofile'];
$newbgfile = $request['newbgfile'];
$ext_logo = $request['ext_logo'];
$ext_bg = $request['ext_bg'];
$new_textlogo = $request['new_textlogo'];
$hbgrep = $request['hbgrep'];
$hbgpos = $request['hbgpos'];
$replace_bg = $request['replace_bg'];
$replace = $request['replace'];
if (!isset($f)) $f="style";
if (!isset($sf)) $sf="header";
/* Manage the files */
$logoimage=$_FILES['new_logo']['tmp_name'];
$logoimage_name=$_FILES['new_logo']['name'];
if ($logoimage_name!=""){
$extension=explode(".",$logoimage_name);
$num_els=count($extension);
$ext_logo=$extension[$num_els - 1];
$newlogofile="./siteimages/temp_logoimage";
if (file_exists($newlogofile)){
unlink($newlogofile);
move_uploaded_file ($logoimage,$newlogofile);
}
else{
move_uploaded_file ($logoimage,$newlogofile);
}
}
$bgimage=$_FILES['new_hbgim']['tmp_name'];
$bgimage_name=$_FILES['new_hbgim']['name'];
if ($bgimage_name!=""){
$extension=explode(".",$bgimage_name);
$num_els=count($extension);
$ext_bg=$extension[$num_els - 1];
$newbgfile="./siteimages/temp_bgimage";
/* if (file_exists($newbgfile)) unlink($newbgfile); */
move_uploaded_file ($bgimage,$newbgfile);
}
/* Set the background values */
if ($newbgfile!="" && !isset($replace_bg)){
if (file_exists("./siteimages/hbgimage.$ext_bg"))
unlink ("./siteimages/hbgimage.$ext_bg");
rename("./siteimages/temp_bgimage","./siteimages/hbgimage.$ext_bg");
$hbgim="./siteimages/hbgimage.$ext_bg";
}
elseif ($hbgim!="" && !isset($replace_bg)){
if (file_exists("./siteimages/temp_bgimage"))
unlink("./siteimages/temp_bgimage");
}
else{
if (file_exists("./siteimages/temp_bgimage"))
unlink("./siteimages/temp_bgimage");
$hbgim="";
}
/* Update the DB */
$obj_style = $obj_styleengine->GetStyle($styleid);
$obj_style->hsize = $hsize;
$obj_style->hcol = $hcol;
$obj_style->hbgcol = $hbgcol;
$obj_style->hbgim = $hbgim;
$obj_style->hbgrep = $hbgrep;
$obj_style->hbgpos = $hbgpos;
if (!$obj_styleengine->UpdateStyle($obj_style))
echo "Update error on Style Engine<br>";
if ($newlogofile!="" && !isset($replace)){
if (file_exists("./siteimages/logo.$ext_logo"))
unlink("./siteimages/logo.$ext_logo");
rename("./siteimages/temp_logoimage","./siteimages/logo.$ext_logo");
$new_logoname="logo.$ext_logo";
}
elseif ($logoname!="" && !isset($replace)){
if (file_exists("./siteimages/temp_logoimage"))
unlink ("./siteimages/temp_logoimage");
$new_logoname=$logoname;
}
else{
if (file_exists("./siteimages/temp_logoimage"))
unlink ("./siteimages/temp_logoimage");
}
/* Update the config.inc file */
$conf = new ConfigTool();
$conf->setConfigFromFile( CONFIGFILE );
//********************
// logoname
//********************
if ($conf->isDefined('logoname'))
$conf->updateKeyValue( "logoname", "'".$new_logoname."'" );
else{
$logoname = "";
$conf->addKeyValue( "logoname", "''" );
}
//********************
// textlogo
//********************
if ($conf->isDefined('textlogo'))
$conf->updateKeyValue( "textlogo", "'".$new_textlogo."'" );
else{
$textlogo = "http://www.chicomas.com/";
$conf->addKeyValue( "textlogo", "'http://www.chicomas.com/'" );
}
//********************
// Save Config File
//********************
$conf->setFileName( CONFIGFILE );
$conf->saveToFile();
/* Create a new css file! */
$obj_style = $obj_styleengine->GetStyle($styleid);
CreateCSSFile($obj_style);
ReDirection(basename($PHP_SELF)."?f=style&sf=header&operation=view");
return $content;
}
function Header_Operation($request){
$content = null;
$operation = $request['operation'];
switch ($operation){
default:
case 'view':
case 'preview':
$content = HeaderView($request);
break;
case 'save':
$content = HeaderSave($request);
break;
}
return $content;
}
?>