<?php
// db
include("../db.php");
switch ($mode)
{
case "global":
saveGlobalConfig();
break;
case "layout":
saveLayoutConfig();
break;
case "tooltip":
saveTooltipConfig();
break;
default:
exit("<br /><b>Could not stave the data!</b><br />");
}
/* // // // START CONTENT FUNCTIONS \\ \\ \\ */
function saveGlobalConfig()
{
updateRadioList("startCircle",array("inner","outher"));
updateRadioList("minimun",array("1", "2","3", "4", "5"));
updateTxtFields(array("siteTitle","metaTags"));
}
function saveLayoutConfig()
{
updateRadioList("align", array("left","center","right"));
updateRadioList("valign", array("top","middle","bottom"));
updateColorFields(array("linkHoverCol","linkActiveCol","linkVisitedCol"));
foreach(array("title","location","city","url","telephone","email","fax") as $groupeName)
{
foreach(array("Bold","Cursive","Underlined") as $attribute)
{
updateCheckBoxes(array($groupeName.$attribute)); // attributes
}
updateColorFields(array($groupeName."Color")); // color
updateData($groupeName."Font", $_REQUEST[$groupeName."Font"]); // font
updateData($groupeName."Size", $_REQUEST[$groupeName."Size"]); // size
}
}
function saveTooltipConfig()
{
updateRadioList("ttFontSize", array("10", "11","12", "13", "14"));
updateRadioList("ttTextAlign", array("left","center","right"));
updateTxtFields(array("ttDelay","ttDuration","ttFadeIn","ttFadeOut","ttBorerWidth","ttShadowWidth","ttWidth","ttOffsetX","ttOffsetY","ttOpacity","ttPadding"));
updateColorFields(array("ttBgColor","ttBorderColor","ttFontColor","ttShadowColor"));
updateCheckBoxes(array("ttShadow","ttFontWeight","ttCenterMouse","ttFollowMouse"));
}
/* \\ \\ \\ END CONTENT FUNCTIONS // // // */
/* // // // START UPDATE FUNCTIONS \\ \\ \\ */
function updateData($field, $data = "", $compareTable = "config_field", $dataTable = "config_data", $compareVal = "", $tableName = "config")
{
if ($data == "") {$data = $_REQUEST[$field];}
if ($compareVal == "") {$compareVal = $field;}
// echo "<br />UPDATE `$tableName` SET `$dataTable` = '$data' WHERE `$compareTable` = '$compareVal'";
mysql_query("UPDATE `$tableName` SET `$dataTable` = '$data' WHERE `$compareTable` = '$compareVal'");
}
function updateTxtFields($fields)
{
foreach($fields as $field)
{
if (strlen($_REQUEST[$field]) > 0)
{
updateData($field);
}
}
}
function updateColorFields($fields)
{
foreach($fields as $field)
{
updateData($field, str_pad($_REQUEST[$field], 6, "0", STR_PAD_LEFT));
}
}
function updateRadioList($field, $dbValues, $indx = "")
{
if ($indx == "") {$indx = $_REQUEST[$field];}
updateData($field, $dbValues[$indx]);
}
function updateCheckBoxes($boxes)
{
foreach($boxes as $box)
{
updateData($box, 0 + $_REQUEST[$box]);
}
}
/* \\ \\ \\ END UPDATE FUNCTIONS // // // */
?>