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

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

	if (!isset($f)) $f="style";
	if (!isset($sf)) $sf="font";
	
	/* Read the db values */
	
	if (!isset($font)){
		$obj_style = $obj_styleengine->GetActiveStyle();
		$styleid = $obj_style->style_id;
		$font = $obj_style->font;
		$fsize = $obj_style->fsize;
		$fcol = $obj_style->fcol;
	}

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

	$info = _CP_SA_FONT_MSG_;

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

	<center>
	<div id=\"formular\">
	<form name=\"headform\" action=\"".basename($PHP_SELF)."?f=style&sf=font&operation=save\" method='post'>
	<table width=\"95%\" cellpadding=\"5\" cellspacing=\"5\" border=\"1\">
	<tr>
		<td colspan=\"3\" align=\"center\">
			<input type=\"submit\" value=\""._CMN_SAVE_."\" />
		</td>
	</tr>

	<tr>
		<td colspan=\"3\" align=\"left\">
			<b>"._CP_SA_FONT_."</b>
		</td>
	</tr>

	<tr>
		<td align=\"left\" width=\"25%\">"._CP_SA_FP_FONT_FAMILY_."</td>
		<td align=\"left\" width=\"45%\">
			<select name=\"font\">";
			if ($font==_CP_SA_FP_FONT_FAMILY_OPTION_1_)
				$content .= "<option selected=\"selected\" value=\""._CP_SA_FP_FONT_FAMILY_OPTION_1_."\">"._CP_SA_FP_FONT_FAMILY_OPTION_1_."</option>";
			else
				$content .= "<option value=\""._CP_SA_FP_FONT_FAMILY_OPTION_1_."\">"._CP_SA_FP_FONT_FAMILY_OPTION_1_."</option>";

			if ($font==_CP_SA_FP_FONT_FAMILY_OPTION_2_)
				$content .= "<option selected=\"selected\" value=\""._CP_SA_FP_FONT_FAMILY_OPTION_2_."\">"._CP_SA_FP_FONT_FAMILY_OPTION_2_."</option>";
			else
				$content .= "<option value=\""._CP_SA_FP_FONT_FAMILY_OPTION_2_."\">"._CP_SA_FP_FONT_FAMILY_OPTION_2_."</option>";

			if ($font==_CP_SA_FP_FONT_FAMILY_OPTION_3_)
				$content .= "<option selected=\"selected\" value=\""._CP_SA_FP_FONT_FAMILY_OPTION_3_."\">"._CP_SA_FP_FONT_FAMILY_OPTION_3_."</option>";
			else
				$content .= "<option value=\""._CP_SA_FP_FONT_FAMILY_OPTION_3_."\">"._CP_SA_FP_FONT_FAMILY_OPTION_3_."</option>";

			if ($font==_CP_SA_FP_FONT_FAMILY_OPTION_4_)
				$content .= "<option selected=\"selected\" value=\""._CP_SA_FP_FONT_FAMILY_OPTION_4_."\">"._CP_SA_FP_FONT_FAMILY_OPTION_4_."</option>";
			else
				$content .= "<option value=\""._CP_SA_FP_FONT_FAMILY_OPTION_4_."\">"._CP_SA_FP_FONT_FAMILY_OPTION_4_."</option>";

			$content .= "
			</select>
		</td>
		<td align=\"left\">
			<ol>
			<li style=\"font-family:"._CP_SA_FP_FONT_FAMILY_OPTION_1_."\">"._CP_SA_FP_FONT_FAMILY_OPTION_1_."</li>
			<li style=\"font-family:"._CP_SA_FP_FONT_FAMILY_OPTION_2_."\">"._CP_SA_FP_FONT_FAMILY_OPTION_2_."</li>
			<li style=\"font-family:"._CP_SA_FP_FONT_FAMILY_OPTION_3_."\">"._CP_SA_FP_FONT_FAMILY_OPTION_3_."</li>
			<li style=\"font-family:"._CP_SA_FP_FONT_FAMILY_OPTION_4_."\">"._CP_SA_FP_FONT_FAMILY_OPTION_4_."</li>
			</ol>
			<input type=\"hidden\" name=\"styleid\" value=\"$styleid\" />
		</td>
	</tr>

	<tr>
		<td align=\"left\">"._CP_SA_FP_FONT_SIZE_."</td>
		<td align=\"left\">
			<select name=\"fsize\">";
			if ($fsize=="9")
				$content .= "<option selected=\"selected\" value=\"9\">9px</option>";
			else
				$content .= "<option value=\"9\">9px</option>";

			if ($fsize=="10")
				$content .= "<option selected=\"selected\" value=\"10\">10px</option>";
			else
				$content .= "<option value=\"10\">10px</option>";

			if ($fsize=="11")
				$content .= "<option selected=\"selected\" value=\"11\">11px</option>";
			else
				$content .= "<option value=\"11\">11px</option>";

			if ($fsize=="12")
				$content .= "<option selected=\"selected\" value=\"12\">12px</option>";
			else
				$content .= "<option value=\"12\">12px</option>";

			if ($fsize=="13")
				$content .= "<option selected=\"selected\" value=\"13\">13px</option>";
			else
				$content .= "<option value=\"13\">13px</option>";

			if ($fsize=="14")
				$content .= "<option selected=\"selected\" value=\"14\">14px</option>";
			else
				$content .= "<option value=\"14\">14px</option>";

			if ($fsize=="15")
				$content .= "<option selected=\"selected\" value=\"15\">15px</option>";
			else
				$content .= "<option value=\"15\">15px</option>";

			if ($fsize=="16")
				$content .= "<option selected=\"selected\" value=\"16\">16px</option>";
			else
				$content .= "<option value=\"16\">16px</option>";

			$content .= "<option disabled>---</option>";

			if ($fsize=="80")
				$content .= "<option selected=\"selected\" value=\"80\">80%</option>";
			else
				$content .= "<option value=\"80\">80%</option>";

			if ($fsize=="85")
				$content .= "<option selected=\"selected\" value=\"85\">85%</option>";
			else
				$content .= "<option value=\"85\">85%</option>";

			if ($fsize=="90")
				$content .= "<option selected=\"selected\" value=\"90\">90%</option>";
			else
				$content .= "<option value=\"90\">90%</option>";

			if ($fsize=="95")
				$content .= "<option selected=\"selected\" value=\"95\">95%</option>";
			else
				$content .= "<option value=\"95\">95%</option>";

			if ($fsize=="100")
				$content .= "<option selected=\"selected\" value=\"100\">100%</option>";
			else
				$content .= "<option value=\"100\">100%</option>";

			if ($fsize=="105")
				$content .= "<option selected=\"selected\" value=\"105\">105%</option>";
			else
				$content .= "<option value=\"105\">105%</option>";

			if ($fsize=="110")
				$content .= "<option selected=\"selected\" value=\"110\">110%</option>";
			else
				$content .= "<option value=\"110\">110%</option>";
			$content .= "
			</select>
		</td>
		<td style=\"font-size:100%\" align=\"left\">
			<table border=\"0\">
			<tr>
				<td style=\"font-size:100%\" align=\"left\">
					<ol>
					<li style=\"font-size:9\">9px</li>
					<li style=\"font-size:10\">10px</li>
					<li style=\"font-size:11\">11px</li>
					<li style=\"font-size:12\">12px</li>
					<li style=\"font-size:13\">13px</li>
					<li style=\"font-size:14\">14px</li>
					<li style=\"font-size:15\">15px</li>
					<li style=\"font-size:16\">16px</li>
					</ol>
				</td>
				<td style=\"font-size:100%\" align=\"left\">
					<ol>
					<li style=\"font-size:80%\">80%</li>
					<li style=\"font-size:85%\">85%</li>
					<li style=\"font-size:90%\">90%</li>
					<li style=\"font-size:95%\">95%</li>
					<li style=\"font-size:100%\">100%</li>
					<li style=\"font-size:105%\">105%</li>
					<li style=\"font-size:110%\">110%</li>
					</ol>
				</td>
			</tr>
			</table>
		</td>
	</tr>

	<tr>
		<td align=\"left\">"._CP_SA_FP_FONT_COLOR_."</td>
		<td colspan=\"2\">
			<input type=\"text\" size=\"10\" maxlength=\"7\" name=\"fcol\" value=\"$fcol\" readonly>
			<input type=\"button\" value=\""._CP_SA_COLOR_CATALOG_."\" onclick=\"showColorPicker(this,document.forms[0].fcol)\">
		</td>
	</tr>
	<tr>
		<td colspan=\"3\" align=\"center\">
			<input type=\"submit\" value=\""._CMN_SAVE_."\" />
		</td>
	</tr>	
	</table>
	</form>
	</div>
	</center>";

	return $content;
}


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

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

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

	$styleid = $request['styleid'];
	$font = $request['font'];
	$fsize = $request['fsize'];
	$fcol = $request['fcol'];

	/* Update the DB */
	$obj_style = $obj_styleengine->GetStyle($styleid);
	$obj_style->font = $font;
	$obj_style->fsize = $fsize;
	$obj_style->fcol = $fcol;
	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=font&operation=view");

	return $content;
}

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

	$operation = $request['operation'];

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

	return $content;
}

?>
Return current item: ChiCoMaS - Chilek CMS