/[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.1 - (show annotations)
Sat Feb 22 21:07:48 2003 UTC (21 years, 6 months ago) by jonen
Branch: MAIN
+ updated whole lib to version 2.2.1 (new FormProcessing since 2.2.0!)

1 <?php
2 /**
3 * This file contains the base FECheckBox class.
4 *
5 * $Id: FECheckBox.inc,v 1.9 2003/02/18 23:02:00 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 * @param mixed - the value to look up
58 * @return string - the text associated
59 */
60 function get_value_text($value) {
61 return $this->_text;
62 }
63
64 /**
65 * This function builds and returns the
66 * form element object
67 *
68 * @return object
69 */
70 function get_element() {
71
72 $c = form_active_checkbox($this->get_element_name(),
73 $this->_text,
74 $this->get_value(),
75 "form_element");
76
77 return $c;
78 }
79 }
80
81 /**
82 * This is the CheckBoxList FormElement which builds a
83 * list of checkboxes inside a scrollable DIV.
84 * It has no validation method.
85 *
86 *
87 * @author Walter A. Boring IV <waboring@buildabetterweb.com>
88 * @author Suren Markossian <suren@bcsweb.com>
89 * @package phpHtmlLib
90 * @subpackage FormProcessing
91 *
92 * @copyright LGPL - See LICENCE
93 */
94 class FECheckBoxList extends FEMultiListBox {
95
96 /**
97 * This function builds and returns the
98 * form element object
99 *
100 * @return object
101 */
102 function get_element() {
103
104 if ($this->_height || $this->_width) {
105 $this->set_style_attribute("overflow", "auto");
106 $this->set_style_attribute("border", "1px inset");
107 $this->set_style_attribute("background-color", "white");
108 }
109
110 $attributes = $this->_build_element_attributes();
111 $c = new DIVtag($attributes);
112
113 $element_name = $this->get_element_name();
114 $selected_values = $this->get_value();
115
116 $x=0;
117 foreach ($this->_data_list as $text=>$value) {
118 $name = str_replace("[]", "[$x]", $element_name);
119 $x++;
120 $attributes = array("type"=>"checkbox",
121 "name"=>$name,
122 "value"=>$value);
123
124 if (is_array($selected_values) && in_array($value, $selected_values))
125 $attributes[] = "checked";
126
127
128 $checkbox = new INPUTtag($attributes);
129
130 $js_action = "javascript:elements['" . $name . "'].checked=!elements['".$name."'].checked;";
131 $a_attributes = array("href" => "#",
132 "onClick" => $js_action);
133 $a = new Atag($a_attributes, $text, FALSE);
134
135 $check = container( $checkbox, $a );
136 $check->set_collapse();
137
138 $c->push($check, html_br());
139 }
140
141 return $c;
142 }
143 }
144 ?>

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