Subversion Repositories Applications.papyrus

Rev

Rev 1087 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
320 jpm 1
<?php
2
/* vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +----------------------------------------------------------------------+
4
// | PHP version 4.0                                                      |
5
// +----------------------------------------------------------------------+
6
// | Copyright (c) 1997-2003 The PHP Group                                |
7
// +----------------------------------------------------------------------+
8
// | This source file is subject to version 2.0 of the PHP license,       |
9
// | that is bundled with this package in the file LICENSE, and is        |
10
// | available at through the world-wide-web at                           |
11
// | http://www.php.net/license/2_02.txt.                                 |
12
// | If you did not receive a copy of the PHP license and are unable to   |
13
// | obtain it through the world-wide-web, please send a note to          |
14
// | license@php.net so we can mail you a copy immediately.               |
15
// +----------------------------------------------------------------------+
16
// | Authors: Adam Daniel <adaniel1@eesus.jnj.com>                        |
17
// |          Bertrand Mansion <bmansion@mamasam.com>                     |
18
// +----------------------------------------------------------------------+
19
//
443 ddelon 20
// $Id: static.php,v 1.2 2005-09-20 17:01:22 ddelon Exp $
320 jpm 21
 
22
require_once("HTML/QuickForm/element.php");
23
 
24
/**
25
 * HTML class for static data
26
 *
27
 * @author       Wojciech Gdela <eltehaem@poczta.onet.pl>
28
 * @access       public
29
 */
30
class HTML_QuickForm_static extends HTML_QuickForm_element {
31
 
32
    // {{{ properties
33
 
34
    /**
35
     * Display text
36
     * @var       string
37
     * @access    private
38
     */
39
    var $_text = null;
40
 
41
    // }}}
42
    // {{{ constructor
43
 
44
    /**
45
     * Class constructor
46
     *
47
     * @param     string    $elementLabel   (optional)Label
48
     * @param     string    $text           (optional)Display text
49
     * @access    public
50
     * @return    void
51
     */
52
    function HTML_QuickForm_static($elementName=null, $elementLabel=null, $text=null)
53
    {
54
        HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel);
55
        $this->_persistantFreeze = false;
56
        $this->_type = 'static';
57
        $this->_text = $text;
58
    } //end constructor
59
 
60
    // }}}
61
    // {{{ setName()
62
 
63
    /**
64
     * Sets the element name
65
     *
66
     * @param     string    $name   Element name
67
     * @access    public
68
     * @return    void
69
     */
70
    function setName($name)
71
    {
72
        $this->updateAttributes(array('name'=>$name));
73
    } //end func setName
74
 
75
    // }}}
76
    // {{{ getName()
77
 
78
    /**
79
     * Returns the element name
80
     *
81
     * @access    public
82
     * @return    string
83
     */
84
    function getName()
85
    {
86
        return $this->getAttribute('name');
87
    } //end func getName
88
 
89
    // }}}
90
    // {{{ setText()
91
 
92
    /**
93
     * Sets the text
94
     *
95
     * @param     string    $text
96
     * @access    public
97
     * @return    void
98
     */
99
    function setText($text)
100
    {
101
        $this->_text = $text;
102
    } // end func setText
103
 
104
    // }}}
105
    // {{{ setValue()
106
 
107
    /**
108
     * Sets the text (uses the standard setValue call to emulate a form element.
109
     *
110
     * @param     string    $text
111
     * @access    public
112
     * @return    void
113
     */
114
    function setValue($text)
115
    {
116
        $this->setText($text);
117
    } // end func setValue
118
 
119
    // }}}
120
    // {{{ toHtml()
121
 
122
    /**
123
     * Returns the static text element in HTML
124
     *
125
     * @access    public
126
     * @return    string
127
     */
128
    function toHtml()
129
    {
130
        return $this->_getTabs() . $this->_text;
131
    } //end func toHtml
132
 
133
    // }}}
134
    // {{{ getFrozenHtml()
135
 
136
    /**
137
     * Returns the value of field without HTML tags
138
     *
139
     * @access    public
140
     * @return    string
141
     */
142
    function getFrozenHtml()
143
    {
144
        return $this->toHtml();
145
    } //end func getFrozenHtml
146
 
147
    // }}}
148
    // {{{ onQuickFormEvent()
149
 
150
    /**
151
     * Called by HTML_QuickForm whenever form event is made on this element
152
     *
153
     * @param     string    $event  Name of event
154
     * @param     mixed     $arg    event arguments
155
     * @param     object    $caller calling object
156
     * @since     1.0
157
     * @access    public
158
     * @return    void
159
     * @throws
160
     */
161
    function onQuickFormEvent($event, $arg, &$caller)
162
    {
163
        switch ($event) {
164
            case 'updateValue':
165
                // do NOT use submitted values for static elements
166
                $value = $this->_findValue($caller->_constantValues);
167
                if (null === $value) {
168
                    $value = $this->_findValue($caller->_defaultValues);
169
                }
170
                if (null !== $value) {
171
                    $this->setValue($value);
172
                }
173
                break;
174
            default:
175
                parent::onQuickFormEvent($event, $arg, $caller);
176
        }
177
        return true;
178
    } // end func onQuickFormEvent
179
 
180
    // }}}
181
    // {{{ exportValue()
182
 
183
   /**
184
    * We override this here because we don't want any values from static elements
185
    */
186
    function exportValue(&$submitValues, $assoc = false)
187
    {
188
        return null;
189
    }
190
 
191
    // }}}
192
} //end class HTML_QuickForm_static
193
?>