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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations)
Thu May 6 16:27:26 2004 UTC (20 years, 3 months ago) by jonen
Branch: MAIN
Changes since 1.2: +16 -9 lines
 updated all to v2.4.1 - Apr 01, 2004

1 <?php
2 /**
3 * This file contains the base FECheckBox class.
4 *
5 * $Id: FECheckBox.inc,v 1.14 2004/03/25 21:02:57 hemna Exp $
6 *
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 * @return string - the text associated
58 */
59 function get_value_text() {
60 $value = $this->get_value();
61 if ($value != NULL) {
62 return $this->_text;
63 } else {
64 return NULL;
65 }
66 }
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
102 /**
103 * This function builds and returns the
104 * form element object
105 *
106 * @return object
107 */
108 function get_element() {
109
110 if ($this->_height || $this->_width) {
111 $this->set_style_attribute("overflow", "auto");
112 $this->set_style_attribute("border", "1px inset");
113 $this->set_style_attribute("background-color", "white");
114 }
115
116 $attributes = $this->_build_element_attributes();
117 unset( $attributes["name"] );
118 $c = new DIVtag($attributes);
119
120 $element_name = $this->get_element_name();
121 $selected_values = $this->get_value();
122
123 $x=0;
124 foreach ($this->_data_list as $text=>$value) {
125 $name = str_replace("[]", "[$x]", $element_name);
126 $x++;
127 $attributes = array("type"=>"checkbox",
128 "name"=>$name,
129 "value"=>$value);
130
131 if (is_array($selected_values) && in_array($value, $selected_values))
132 $attributes[] = "checked";
133
134 $checkbox = new INPUTtag($attributes);
135
136 if (isset($this->_disabled_items[$text])) {
137 $checkbox->set_tag_attribute("disabled");
138 $a = $text;
139 } else {
140 $js_action = "javascript:elements['" . $name . "'].checked=!elements['".$name."'].checked;";
141 $a_attributes = array("href" => "javascript:void(0)",
142 "onClick" => $js_action);
143 $a = new Atag($a_attributes, htmlspecialchars($text), FALSE);
144 }
145
146 $check = container( $checkbox, $a );
147 $check->set_collapse();
148
149 $c->push($check, html_br());
150 }
151
152 return $c;
153 }
154
155 }
156 ?>

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