Location: PHPKode > projects > ChiCoMaS - Chilek CMS > chicomas/modules/style/submenu_operation.php
<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 SubMenuView($request){
	$content = null;

	$obj_style = new CStyle();
	$obj_stylearray = new CStyleArray();
	$obj_styleengine = new CStyleEngine();

	if (!isset($f)) $f="style";
	if (!isset($sf)) $sf="smenu";
	
	$styleid = $request['styleid'];
	$smbgcol = $request['smbgcol'];
	$smborstyle = $request['smborstyle'];
	$smborw = $request['smborw'];
	$smborcol = $request['smborcol'];
	$smfcol = $request['smfcol'];
	$smhcol = $request['smhcol'];

	/* Read the db values */
	if (!isset($smbgcol)){
		$obj_style = $obj_styleengine->GetActiveStyle();
		$styleid = $obj_style->style_id;
		$smbgcol = $obj_style->smbgcol;
		$smborstyle = $obj_style->smborstyle;
		$smborw = $obj_style->smborw;
		$smborcol = $obj_style->smborcol;
		$smfcol = $obj_style->smfcol;
		$smhcol = $obj_style->smhcol;
	}

	$header = _CONTROL_PANEL_."<br>";
	$header .= _CP_STYLE_ADMINISTRATION_._CMN_DASH_._CP_SA_SUBMENU_;

	$info = _CP_SA_SUBMENU_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=smenu&operation=save\";
		}
		else
			if(document.pressed == '"._CMN_PREVIEW_."'){
				document.headform.action =\"".basename($PHP_SELF)."?f=style&sf=smenu&operation=preview\";
		}
	return true;
	}
	</SCRIPT>

	<center><h3>".$header."</h3></center>
	<i><ul>".$info."</ul></i>

	<center>
	<form name=\"headform\" onsubmit=\"return OnSubmitForm();\" method='post'>
	<table>
	<tr>
		<td width=\"500\">
			<div id=\"formular\">
			<table width=\"100%\" 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_BACKGROUND_."</b>
				</td>
				<input type=\"hidden\" name=\"styleid\" value=\"$styleid\" />
			</tr>
			<tr>
				<td align=\"left\" width=\"45%\">"._CP_SA_BACKGROUND_COLOR_."</td>
				<td colspan=\"2\" width=\"55%\">
					<input type=\"text\" size=\"10\" maxlength=\"7\" name=\"smbgcol\" value=\"$smbgcol\" readonly>
					<input type=\"button\" value=\""._CP_SA_COLOR_CATALOG_."\" onclick=\"showColorPicker(this,document.forms[0].smbgcol)\">
				</td>
			</tr>

			<tr>
				<td colspan=\"3\" align=\"left\">
					<b>"._CP_SA_BORDER_."</b>
				</td>
			</tr>
			<tr>
				<td>"._CP_SA_BORDER_STYLE_."</td>
				<td colspan=\"2\">
					<select name=\"smborstyle\">";
					if ($smborstyle=="solid")
						$content .= "<option selected=\"selected\" value=\"solid\">"._CP_SA_BORDER_TYPE_OPTION_1_."</option>";
					else
						$content .= "<option value=\"solid\">"._CP_SA_BORDER_TYPE_OPTION_1_."</option>";
		
					if ($smborstyle=="dashed")
						$content .= "<option selected=\"selected\" value=\"dashed\">"._CP_SA_BORDER_TYPE_OPTION_2_."</option>";
					else
						$content .= "<option value=\"dashed\">"._CP_SA_BORDER_TYPE_OPTION_2_."</option>";
		
					if ($smborstyle=="dotted")
						$content .= "<option selected=\"selected\" value=\"dotted\">"._CP_SA_BORDER_TYPE_OPTION_3_."</option>";
					else
						$content .= "<option value=\"dotted\">"._CP_SA_BORDER_TYPE_OPTION_3_."</option>";
		
					$content .= "
					</select>
				</td>
			</tr>

			<tr>
				<td align=\"left\">"._CP_SA_BORDER_WIDTH_."</td>
				<td colspan=\"2\" align=\"left\">
					<input type=\"text\" size=\"4\" name=\"smborw\" value=\"$smborw\" />
				</td>
			</tr>

			<tr>
				<td align=\"left\">"._CP_SA_BORDER_COLOR_."</td>
				<td align=\"left\" colspan=\"2\">
					<input type=\"text\" size=\"10\" maxlength=\"7\" name=\"smborcol\" value=\"$smborcol\" readonly>
					<input type=\"button\" value=\""._CP_SA_COLOR_CATALOG_."\" onclick=\"showColorPicker(this,document.forms[0].smborcol)\">
				</td>
			</tr>
		</td>
	</tr>

	<tr>
		<td colspan=\"3\" align=\"left\">
			<b>"._CP_SA_FONT_."</b>
		</td>
	</tr>
	<tr>
		<td align=\"left\">"._CP_SA_FONT_COLOR_."</td>
		<td align=\"left\" colspan=\"2\">
			<input type=\"text\" size=\"10\" maxlength=\"7\" name=\"smfcol\" value=\"$smfcol\" readonly>
			<input type=\"button\" value=\""._CP_SA_COLOR_CATALOG_."\" onclick=\"showColorPicker(this,document.forms[0].smfcol)\">
		</td>
	</tr>

	<tr>
		<td colspan=\"3\" align=\"left\">
			<b>"._CP_SA_OTHER_."</b>
		</td>
	</tr>
	<tr>
		<td align=\"left\">"._CP_SA_MENU_COLOR_ON_ACTIVED_."</td>
		<td align=\"left\" colspan=\"2\">
			<input type=\"text\" size=\"10\" maxlength=\"7\" name=\"smhcol\" value=\"$smhcol\" readonly>
			<input type=\"button\" value=\""._CP_SA_COLOR_CATALOG_."\" onclick=\"showColorPicker(this,document.forms[0].smhcol)\">
		</td>
	</tr>

	</td>
	</tr>

	<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>
	</div>
</td>

<td width=\"150\" valign=\"top\" align=\"center\">"._CP_SA_PREVIEW_."
	<table width=\"90%\">
	<tr>
		<td style=\"background-color:$smbgcol; border: $smborstyle $smborw $smborcol; color:$smfcol\">"._CP_SA_MMP_ELEMENT_1_."</td>
	</tr>
	<tr>
		<td style=\"background-color:$smbgcol; border: $smborstyle $smborw $smborcol; color:$smfcol\"><b>"._CP_SA_MMP_ELEMENT_2_."</b></td>
	</tr>
	<tr>
		<td style=\"background-color:$smhcol; border: $smborstyle $smborw $smborcol; color:$smfcol\"><u>"._CP_SA_MMP_ELEMENT_3_."</u></td>
	</tr>
	</table>
</td>
</tr>
</table>
</form>
</center>";

	return $content;
}

function SubMenuSave($request){
	$content = null;

	$obj_style = new CStyle();
	$obj_stylearray = new CStyleArray();
	$obj_styleengine = new CStyleEngine();

	if (!isset($f)) $f="style";
	if (!isset($sf)) $sf="smenu";

	$styleid = $request['styleid'];
	$smbgcol = $request['smbgcol'];
	$smborstyle = $request['smborstyle'];
	$smborw = $request['smborw'];
	$smborcol = $request['smborcol'];
	$smfcol = $request['smfcol'];
	$smhcol = $request['smhcol'];

	/* Update the DB */
	$obj_style = $obj_styleengine->GetStyle($styleid);
	$obj_style->smbgcol = $smbgcol;
	$obj_style->smborstyle = $smborstyle;
	$obj_style->smborw = $smborw;
	$obj_style->smborcol = $smborcol;
	$obj_style->smfcol = $smfcol;
	$obj_style->smhcol = $smhcol;

	if (!$obj_styleengine->UpdateStyle($obj_style))
		echo "Update error on Style Engine<br>";
	
	/* Create a new css file! */
	$obj_style = $obj_styleengine->GetStyle($styleid);
	CreateCSSFile($obj_style);
	
	/* Create a new styleedit file - for edition in the Content Management */
	CreateCSSEditFile($obj_style);
	
	ReDirection(basename($PHP_SELF)."?f=style&sf=smenu&operation=view");

	return $content;
}

function SubMenu_Operation($request){
	$content = null;

	$operation = $request['operation'];

	switch ($operation){
	default:
	case 'view':
	case 'preview':
		$content = SubMenuView($request);
	break;
	case 'save':
		$content = SubMenuSave($request);
	break;
	}

	return $content;
}

?>
Return current item: ChiCoMaS - Chilek CMS