<<-introduction->>in zephyr beta 2 a new feature has been added which is called "filter". a filter is a special class which executes just before an action get control and just after the content of "view" is rendered and ready to display. you will get full control over input data before they reach to action using these actions and can modify the rendered output before it display. In zephyr beta 2.00, there are two types of filter - input filters to use filter, you need to specify them in package.xml. lets create one sample input filter and output filter. every filter must have a "process()" function with two parameter. these parameters are different for input and output filters. lets take a look at the definition -input filter -output filters <<-input filters->>to use input filters, you need to specify them in package.xml using <input_filter></input_filter> tag block. you can as many filters as you want. they will be executed in same order as you include in package.xml <input_filter>sample_input</input_filter> zephyr controller will invoke this action from "filters" folder . you must save this file as "sample_input.class.php" inside "filters" folder inside your package. lets take a look at our sample_input filter code. this filter will simply escape all input data.
//sample_input.class.php
<?
class sample_input
{
public function process($params, $action)
{
$data = unserialize($params);
foreach ($data as &$dt)
{
if (!get_magic_quotes_gpc())
$dt = addslashes($dt);
}
$data = serialize($data);
return $data;
}
}
?>
<<-output filters->>to use output filters, you need to specify them in package.xml using <output_filter></output_filter> tag block. you can as many filters as you want. they will be executed in same order as you include in package.xml <output_filter>sample_output</output_filter> zephyr controller will invoke this action from "filters" folder . you must save this file as "sample_output.class.php" inside "filters" folder inside your package. lets take a look at our sample_output filter code.
//sample_output.class.php
<?
class sample_output
{
public function process($rendered_output, $action)
{
return strtoupper($rendered_output);
}
}
?>
|