/[cvs]/nfo/php/libs/com.newsblob.phphtmllib/form/form_elements/FECheckBox.inc
ViewVC logotype

Annotation of /nfo/php/libs/com.newsblob.phphtmllib/form/form_elements/FECheckBox.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Sat Sep 20 00:20:15 2003 UTC (20 years, 11 months ago) by jonen
Branch: MAIN
Changes since 1.1: +9 -4 lines
+ updated whole phphtmllib to v2.3.0

1 jonen 1.1 <?php
2     /**
3     * This file contains the base FECheckBox class.
4     *
5 jonen 1.2 * $Id: FECheckBox.inc,v 1.12 2003/07/18 17:59:21 hemna Exp $
6 jonen 1.1 *
7     * @author Walter A. Boring IV <waboring@buildabetterweb.com>
8     * @author Suren Markosyan <suren@bcsweb.com>
9     * @package phpHtmlLib
10     * @subpackage FormProcessing
11     *
12     * @copyright LGPL - See LICENCE
13     *
14     */
15    
16     /**
17     * This is the CheckBox FormElement which builds a
18     * input field of type="checkbox". It has no validation method.
19     *
20     *
21     * @author Walter A. Boring IV <waboring@buildabetterweb.com>
22     * @author Suren Markossian <suren@bcsweb.com>
23     * @package phpHtmlLib
24     * @subpackage FormProcessing
25     *
26     * @copyright LGPL - See LICENCE
27     */
28     class FECheckBox extends FormElement {
29    
30     /**
31     * Holds the checkbox text
32     *
33     */
34     var $_text = NULL;
35    
36     /**
37     * The constructor
38     *
39     * @param label string - text label for the element
40     * @param string text - checkbox text to be displayed
41     */
42     function FECheckBox($label, $text) {
43     $this->FormElement($label, false);
44     $this->_text = $text;
45     }
46    
47     /**
48     * This provides a method
49     * for the FormContent
50     * to get access to the
51     * text associated with a
52     * field. This is only available
53     * on FormElements that have text
54     * associated with a field.
55     * It is used during Confirmation
56     *
57     * @param mixed - the value to look up
58     * @return string - the text associated
59     */
60     function get_value_text($value) {
61 jonen 1.2 if ($value != NULL) {
62     return $this->_text;
63     } else {
64     return NULL;
65     }
66 jonen 1.1 }
67    
68     /**
69     * This function builds and returns the
70     * form element object
71     *
72     * @return object
73     */
74     function get_element() {
75    
76     $c = form_active_checkbox($this->get_element_name(),
77     $this->_text,
78     $this->get_value(),
79     "form_element");
80    
81     return $c;
82     }
83     }
84    
85     /**
86     * This is the CheckBoxList FormElement which builds a
87     * list of checkboxes inside a scrollable DIV.
88     * It has no validation method.
89     *
90     *
91     * @author Walter A. Boring IV <waboring@buildabetterweb.com>
92     * @author Suren Markossian <suren@bcsweb.com>
93     * @package phpHtmlLib
94     * @subpackage FormProcessing
95     *
96     * @copyright LGPL - See LICENCE
97     */
98     class FECheckBoxList extends FEMultiListBox {
99    
100     /**
101     * This function builds and returns the
102     * form element object
103     *
104     * @return object
105     */
106     function get_element() {
107    
108     if ($this->_height || $this->_width) {
109     $this->set_style_attribute("overflow", "auto");
110     $this->set_style_attribute("border", "1px inset");
111     $this->set_style_attribute("background-color", "white");
112     }
113    
114     $attributes = $this->_build_element_attributes();
115 jonen 1.2 unset( $attributes["name"] );
116 jonen 1.1 $c = new DIVtag($attributes);
117    
118     $element_name = $this->get_element_name();
119     $selected_values = $this->get_value();
120    
121     $x=0;
122     foreach ($this->_data_list as $text=>$value) {
123     $name = str_replace("[]", "[$x]", $element_name);
124     $x++;
125     $attributes = array("type"=>"checkbox",
126     "name"=>$name,
127     "value"=>$value);
128    
129     if (is_array($selected_values) && in_array($value, $selected_values))
130     $attributes[] = "checked";
131    
132    
133     $checkbox = new INPUTtag($attributes);
134    
135     $js_action = "javascript:elements['" . $name . "'].checked=!elements['".$name."'].checked;";
136 jonen 1.2 $a_attributes = array("href" => "javascript:void(0)",
137 jonen 1.1 "onClick" => $js_action);
138 jonen 1.2 $a = new Atag($a_attributes, htmlspecialchars($text), FALSE);
139 jonen 1.1
140     $check = container( $checkbox, $a );
141     $check->set_collapse();
142    
143     $c->push($check, html_br());
144     }
145    
146     return $c;
147     }
148     }
149     ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed