$params['min_width'], "max_width"=>$params['max_width'], "column_nb"=>$params['column_nb'], "gutter"=>$params['gutter']);
foreach ($test as $key => $value)
{
### test integers parameters
if (!is_array($value))
{
if (!preg_match('/[0-9]/',$value))
{
${'error_'.$key} = '
Error : Parameter "'.$key.'" must only use 0123456789.';
}
elseif (!is_int($value))// Is the parameter an integer ?
{
$params[$key] = (int)$value;
}
//reset value if error
if ($error_gutter)
{
$params['gutter'] = 20; //reset "gutter" to default value
$error_gutter .= "Parameter reset to default value : 20";
}
elseif (${'error_'.$key})
{
$params["$key"] = 960;
${'error_'.$key} .= "Parameter reset to default value : 960";
} // reset "min_width" or "max_width" parameter to default value
}
### test only "column_nb" parameter like an integer
if (is_array($value))
{
unset($column_id,$column_value);
foreach ($value as $column_id => $column_value)
{
if (!preg_match('/[0-9]/',$column_value))
{
${'error_'.$key} = '
Error : Parameter "'.$key.'" must be a STRING packaging INTEGER using 0123456789 separated with comma. Parameter reset to default value : 12"';
$params['column_nb'] = explode(',','12');
}
elseif (!is_int($column_nb))// Is the parameter an integer ?
{
$params[$key][$column_id] = (int)$column_value;
}
// check ratio for valid 960 GRID and "type"=fixed
if ( $params['type'] === 'fixed' && !is_int($params['max_width']/$column_value))
{
$error_ratio = 'Bad RATIO value : "max_width" divided by "column_nb" must be an integer. Reset defaults values : max_width=960 column_nb="12" ';
$params['column_nb'] = explode(',','12');
$params['max_width'] = 960;
}
}
unset($column_id,$column_value);
}
}
### Test strings values
unset($test,$key,$value);
$test = array ("type"=>$params['type'], "align"=>$params['align']);
foreach ($test as $key => $value)
{
switch ($key)
{
case "type" :
//default value : "fixed"
$unit = "px";
$container_width = $params['max_width'];
switch ($value)
{
case "fluid" :
$container_width = "92";
$params['gutter'] ="2";
$unit="%";
break;
case "fixed" :
$params['min_width'] = $params['max_width'];
break;
default : //keep default value
$params['type'] = 'fixed';
$params['min_width'] = $params['max_width'];
${'error_'.$key} = '
Error : Parameter "'.$key.'" must be a STRING and choose between "fluid" or "fixed". Default value "fixed" is used.';
};
break;
case "align" :
// default value "center"
$container_margin= "0 auto ;";
switch ($value)
{
case "left" :
$container_margin= "0 auto 0 0 ;";
break;
case "right" :
$container_margin= "0 0 0 auto ;";
break;
case "center" : //keep default value
break;
default : //keep default value
$params['align'] = 'center';
${'error_'.$key} = '
Error : Parameter "'.$key.'" must be a STRING and choose between "left" or "right" or "center". Default value "center" is used.';
break;
};
break;
}
}
unset($test,$key,$value);
### Display only values - don't generate & ouput CSS
if ($check)
{
echo <<
min_width = $min_width $error_min_width
max_width = $max_width $error_max_width
column_nb = "$column_check" $error_column_nb
gutter = $gutter $error_gutter
$error_ratio
Generate 960 GRID CSS
Just insert the tag into your stylesheet (template or page) like: {css_960_grid}
Three optionals parameters for only displaying some CSS part - usefull for multiples css stylesheet
use only single one of these options otherwise these options will be ignored.
-A good idea might be to choose a number of column in this list : 2, 3, 4, 5, 6, 8, 10, 12, 15, 16, 20, 24, 30, 32, 40, 48, 60, 64, 80, 96, 120, 160, 192, 240, 320 and 480
-This plugin generate a CSS based on 960 GRID SYSTEM and 960 is divisible by these values.
-This makes it a highly flexible base number to work with. get more infos here http://960.gs/
You aren't limited to only use 960 and you can use an other value define by "max_width" parameter,
but with parameter type="fixed" make sure that given parameters "max_width" divided by "column_nb" result is an integer.
example : type="fixed" max_widh=1000 column_nb="10" ratio result = 100 - correct value.
example : type="fixed" max_widh=1000 column_nb="11" ratio result = 90,909 - bad value -> defaults values overwrite yours
{css_960_grid type="fixed" align="center" max_width=960 min_width=960 column_nb="12" gutter=20}
or just {css_960_grid}
{css_960_grid type="fixed" align="center" max_width=960 min_width=960 column_nb="16" gutter=20}
or just {css_960_grid column="16"}
{css_960_grid type="fixed" align="center" max_width=960 min_width=960 column_nb="24" gutter=10}
or just {css_960_grid column="24" gutter=10}
{css_960_grid column="12,16"}
Author: Philippe THOMAS <devteam@aviapic.com>
plugin based on 960 GRID SYSTEM + Goran Ilic CSS: http://960.gs/
Version: 2.0.0
Change History:
1.0.0 - Initial version released.
1.1.0 - Add parameters : mobile, print, hack_css, hack_only.
next release will add parameters : mobile_only, print_only
2.0.0 - Check parameters and validation for outputed css
Display warnings if parameter check is true and errors exists
Add parameters : mobile_only, print_only