root/trunk/patForms/AttributeFilter/Test.php

Revision 349, 1.9 kB (checked in by gerd, 3 years ago)

Draft of new feature: attribute filter

  • Property svn:keywords set to "Id"
Line 
1 <?php
2 /**
3  * patForms test attribute filter
4  *
5  * $Id$
6  *
7  * @package     patForms
8  * @subpackage  AttributeFilter
9  */
10
11 /**
12  * patForms test attribute filter
13  *
14  *
15  * @package     patForms
16  * @subpackage  AttributeFilter
17  * @author      gERD Schaufelberger <gerd@php-tools.net>
18  * @license     LGPL, see license.txt for details
19  * @link        http://www.php-tools.net
20  * @version     1.0
21  */
22 class patForms_AttributeFilter_Test extends patForms_AttributeFilter
23 {
24    /**
25     * attribute list
26     *
27     * list of attributes to handle
28     * @access   private
29     */
30     var $_attributes = array( 'label', 'title', 'description' );
31
32    /**
33     * define the attibute names to be handled
34     *
35     * @access   public
36     * @param array list of attributes to handle
37     * @return boolean true on success
38     */
39     function setAttributes($attributes)
40     {
41         $this->_attributes   =   $attributes;
42         return true;
43     }
44
45    /**
46     * Filter attribute value on "set"-event
47     *
48     * @access   public
49     * @param    string  element's type
50     * @param    string  attribute's names
51     * @param    mixed   attribute's value
52     * @return   mixed   true on success, patError-object on error
53     */
54     function onSet($type, $attribute, &$value)
55     {
56         if( !in_array( $attribute, $this->_attributes ) ) {
57             return true;
58         }
59
60         $value  =   '[TEST:SET] ' . $value . ' [/TEST:SET]';
61         return true;
62     }
63
64    /**
65     * Filter attribute value on "apply"-event
66     *
67     * @access   public
68     * @param    string  element's type
69     * @param    string  attribute's names
70     * @param    mixed   attribute's value
71     * @return   mixed   true on success, patError-object on error
72     */
73     function onApply($type, $attribute, &$value)
74     {
75         if( !in_array( $attribute, $this->_attributes ) ) {
76             return true;
77         }
78
79         $value  =    '[TEST:APPLY] ' . $value . ' [/TEST:APPLY]';
80         return true;
81     }
82 }
83 ?>
Note: See TracBrowser for help on using the browser.