root/trunk/patForms/Filter/Multiplier.php

Revision 2, 1.6 kB (checked in by schst, 5 years ago)

initial import on new server

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 <?php
2 /**
3  * patForms multiplier filter
4  *
5  * Will multiply values returned by patForms
6  * and divide them while setting values
7  *
8  * $Id$
9  *
10  * @package        patForms
11  * @subpackage    Filter
12  */
13
14 /**
15  * patForms multiplier filter
16  *
17  * Will multiply values returned by patForms
18  * and divide them while setting values
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_Multiplier extends patForms_Filter
28 {
29    /**
30     * type of the filter
31     *
32     * @access    private
33     */
34     var $_type    =    PATFORMS_FILTER_TYPE_PHP;
35
36    /**
37     * multiplier
38     *
39     * @access    private
40     * @var        integer
41     */
42     var $_multiplier    =    1;
43
44    /**
45     * change the multiplier value
46     *
47     * @access    public
48     * @param    integer        new multiplier value
49     */
50     function setMultiplier( $multi )
51     {
52         $this->_multiplier    =    $multi;
53     }
54     
55    /**
56     * Filter value that is returned by patForms
57     *
58     * This method is applied when patForms_Element::getValue()
59     * or patForms::getValues() is called.
60     *
61     * @abstract
62     * @access    public
63     * @param    string    value
64     * @return    float    filtered value
65     */
66     function out( $value )
67     {
68         $value    =    (float)$value * $this->_multiplier;
69         return $value;
70     }
71
72    /**
73     * Filter value that is passed to patForms
74     *
75     * This method is applied when patForms_Element::setValue()
76     * or patForms::setValues() is called.
77     *
78     * @abstract
79     * @access    public
80     * @param    mixed    value
81     * @return    mixed    filtered value
82     */
83     function in( $value )
84     {
85         $value    =    (string)( $value / $this->_multiplier );
86         return $value;
87     }
88 }
89 ?>
Note: See TracBrowser for help on using the browser.