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

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

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

	$styleid = $request['styleid'];
	$mmbgcol = $request['mmbgcol'];
	$mmborstyle = $request['mmborstyle'];
	$mmborw = $request['mmborw'];
	$mmborcol = $request['mmborcol'];
	$mmfcol = $request['mmfcol'];
	$mmhcol = $request['mmhcol'];

	/* Read the db values */
	
	if (!isset($mmbgcol)){
		$obj_style = $obj_styleengine->GetActiveStyle();
		$styleid = $obj_style->style_id;
		$mmbgcol = $obj_style->mmbgcol;
		$mmborstyle = $obj_style->mmborstyle;
		$mmborw = $obj_style->mmborw;
		$mmborcol = $obj_style->mmborcol;
		$mmfcol = $obj_style->mmfcol;
		$mmhcol = $obj_style->mmhcol;
	}

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

	$info = _CP_SA_MAINMENU_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=mmenu&operation=save\";
		}
		else
			if(document.pressed == '"._CMN_PREVIEW_."'){
				document.headform.action =\"".basename($PHP_SELF)."?f=style&sf=mmenu&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=\"mmbgcol\" value=\"$mmbgcol\" readonly>
					<input type=\"button\" value=\""._CP_SA_COLOR_CATALOG_."\" onclick=\"showColorPicker(this,document.forms[0].mmbgcol)\">
				</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=\"mmborstyle\">";
					if ($mmborstyle=="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 ($mmborstyle=="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 ($mmborstyle=="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=\"mmborw\" value=\"$mmborw\" />
				</td>
			</tr>

			<tr>
				<td align=\"left\">"._CP_SA_BORDER_COLOR_."</td>
				<td align=\"left\" colspan=\"2\">
					<input type=\"text\" size=\"10\" maxlength=\"7\" name=\"mmborcol\" value=\"$mmborcol\" readonly>
					<input type=\"button\" value=\""._CP_SA_COLOR_CATALOG_."\" onclick=\"showColorPicker(this,document.forms[0].mmborcol)\">
				</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=\"mmfcol\" value=\"$mmfcol\" readonly>
					<input type=\"button\" value=\""._CP_SA_COLOR_CATALOG_."\" onclick=\"showColorPicker(this,document.forms[0].mmfcol)\">
				</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=\"mmhcol\" value=\"$mmhcol\" readonly>
					<input type=\"button\" value=\""._CP_SA_COLOR_CATALOG_."\" onclick=\"showColorPicker(this,document.forms[0].mmhcol)\">
				</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:$mmbgcol; border: $mmborstyle $mmborw $mmborcol; color:$mmfcol\">"._CP_SA_MMP_ELEMENT_1_."</td>
		</tr>
		<tr>
			<td style=\"background-color:$mmbgcol; border: $mmborstyle $mmborw $mmborcol; color:$mmfcol\"><b>"._CP_SA_MMP_ELEMENT_2_."</b></td>
		</tr>
		<tr>
			<td  style=\"background-color:$mmhcol; border: $mmborstyle $mmborw $mmborcol; color:$mmfcol\"><u>"._CP_SA_MMP_ELEMENT_3_."</u></td>
		</tr>
		</table>
	</td>
	</tr>
	</table>
	</form>
	</center>";

	return $content;
}


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

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

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

	$styleid = $request['styleid'];
	$mmbgcol = $request['mmbgcol'];
	$mmborstyle = $request['mmborstyle'];
	$mmborw = $request['mmborw'];
	$mmborcol = $request['mmborcol'];
	$mmfcol = $request['mmfcol'];
	$mmhcol = $request['mmhcol'];

	/* Update the DB */
	$obj_style = $obj_styleengine->GetStyle($styleid);
	$obj_style->mmbgcol = $mmbgcol;
	$obj_style->mmborstyle = $mmborstyle;
	$obj_style->mmborw = $mmborw;
	$obj_style->mmborcol = $mmborcol;
	$obj_style->mmfcol = $mmfcol;
	$obj_style->mmhcol = $mmhcol;
	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=mmenu&operation=view");

	return $content;
}

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

	$operation = $request['operation'];

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

	return $content;
}
?>
Return current item: ChiCoMaS - Chilek CMS