root/trunk/patForms/Filter/Trim.php

Revision 196, 1.1 kB (checked in by schst, 4 years ago)

fix bug #97 (Trim filter erases Array)
Thanks to Bj�rn Kraus for the fix

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 <?php
2 /**
3  * patForms trim filter
4  *
5  * Removes leading and trailing whitespace from
6  * user input
7  *
8  * $Id$
9  *
10  * @package        patForms
11  * @subpackage    Filter
12  */
13
14 /**
15  * patForms trim filter
16  *
17  * Removes leading and trailing whitespace from
18  * user input
19  *
20  * @package        patForms
21  * @subpackage    Filter
22  * @author        Stephan Schmidt <schst@php-tools.net>
23  * @license        LGPL, see license.txt for details
24  * @link        http://www.php-tools.net
25  * @version        1.0
26  */
27 class patForms_Filter_Trim extends patForms_Filter
28 {
29    /**
30     * type of the filter
31     *
32     * @access    private
33     */
34     var $_type    =    PATFORMS_FILTER_TYPE_HTTP;
35
36    /**
37     * Filter value that is returned by patForms
38     *
39     * This method is applied when patForms_Element::getValue()
40     * or patForms::getValues() is called.
41     *
42     * @abstract
43     * @access    public
44     * @param    string    value
45     * @return    float    filtered value
46     */
47     function out( $value )
48     {
49         return $value;
50     }
51
52    /**
53     * Filter value that is passed to patForms
54     *
55     * @abstract
56     * @access    public
57     * @param    mixed    value
58     * @return    mixed    filtered value
59     */
60     function in( $value )
61     {
62         if (is_string($value)) {
63             $value = trim( $value );
64         }
65         return $value;
66     }
67 }
68 ?>
Note: See TracBrowser for help on using the browser.