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

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

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

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

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

	$info = _CP_SA_LINK_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=link&operation=save\" method='post'>
	<table width=\"65%\" cellpadding=\"5\" cellspacing=\"5\" border=\"1\">
	<tr>
		<td colspan=\"3\" align=\"center\">
			<input type=\"submit\" value=\""._CMN_SAVE_."\" />
		</td>
	</tr>

	<tr>
		<td align=\"left\" width=\"45%\">"._CP_SA_LINK_COLOR_."</td>
		<td colspan=\"2\" width=\"55%\">
			<input type=\"text\" size=\"10\" maxlength=\"7\" name=\"al\" value=\"$al\" readonly>
			<input type=\"button\" value=\""._CP_SA_COLOR_CATALOG_."\" onclick=\"showColorPicker(this,document.forms[0].al)\">
		</td>
		<input type=\"hidden\" name=\"styleid\" value=\"$styleid\" />
	</tr>

	<tr>
		<td colspan=\"3\" align=\"center\">
			<input type=\"submit\" value=\""._CMN_SAVE_."\" />
		</td>
	</tr>
	</table>
	</form>
	</div>
	</center>";

	return $content;
}

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

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

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

	$styleid = $request['styleid'];
	$al = $request['al'];
	$smfcol = $request['smfcol'];

	/* Find the other colors! */
	$red=substr($al,1,2);
	$green=substr($al,3,2);
	$blue=substr($al,5,2);
	
	$red=hexdec($red);
	$green=hexdec($green);
	$blue=hexdec($blue);
	
	$vred=round($red*0.7);
	$vgreen=round($green*0.7);
	$vblue=round($blue*0.7);
	
	if ($vred<=15) $vred="0".dechex($vred); else $vred=dechex($vred);
	if ($vgreen<=15) $vgreen="0".dechex($vgreen); else $vgreen=dechex($vgreen);
	if ($vblue<=15) $vblue="0".dechex($vblue); else $vblue=dechex($vblue);
	
	$av="#$vred$vgreen$vblue";
	
	
	$hred=round((255*0.3) + ($red*0.7));
	$hgreen=round((255*0.3)+($green*0.7));
	$hblue=round((255*0.3)+($blue*0.7));
	
	if ($hred<=15) $hred="0".dechex($hred); else $hred=dechex($hred);
	if ($hgreen<=15) $hgreen="0".dechex($hgreen); else $hgreen=dechex($hgreen);
	if ($hblue<=15) $hblue="0".dechex($hblue); else $hblue=dechex($hblue);
	
	$ah="#$hred$hgreen$hblue";
	
	/* Update the DB */
	$obj_style = $obj_styleengine->GetStyle($styleid);
	$obj_style->al = $al;
	$obj_style->av = $av;
	$obj_style->ah = $ah;
	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=link&operation=view");

	return $content;
}

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

	$operation = $request['operation'];

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

	return $content;
}

?>
Return current item: ChiCoMaS - Chilek CMS