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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Thu Aug 11 14:09:58 2005 UTC (18 years, 11 months ago) by jonen
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +5 -5 lines
+ updated to version 2.5.3

1 <?php
2 /**
3 * This file contains the FEButton, FESubmitButton classes
4 *
5 * $Id: FEButton.inc,v 1.5.2.1 2005/05/12 01:24:02 hemna Exp $
6 *
7 * @author Walter A. Boring IV <waboring@newsblob.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 button FormElement which builds a
18 * input field of type="button". It has no validation method.
19 *
20 *
21 * @author Walter A. Boring IV <waboring@newsblob.com>
22 * @author Suren Markossian <suren@bcsweb.com>
23 * @package phpHtmlLib
24 * @subpackage FormProcessing
25 *
26 * @copyright LGPL - See LICENCE
27 */
28 class FEButton extends FEBoxElement {
29
30 /**
31 * Holds the button action
32 *
33 *
34 */
35 var $_action = NULL;
36
37 /**
38 * The constructor
39 *
40 * @param label string - text label for the element
41 * @param string value - button text
42 * @param string action - action to perform
43 * @param int required - element width in pixels (px), percentage (%) or elements (em)
44 * @param int required - element height in pixels (px), percentage (%) or elements (em)
45 */
46 function FEButton($label, $value, $action = NULL, $width = NULL, $height = NULL) {
47 $this->FEBoxElement($label, false);
48
49 $this->set_value($value);
50
51 $this->_action = $action;
52 }
53
54 /**
55 * This function return the javaScript code for
56 * an onClick event
57 *
58 * @return string - javascript code
59 */
60 function onClick() {
61 if ($this->_action != NULL) {
62 return "javascript:" . str_replace("javascript:", "", $this->_action);
63 }
64 else {
65 return NULL;
66 }
67 }
68
69 /**
70 * This function builds and returns the
71 * form element object
72 *
73 * @return object
74 */
75 function get_element() {
76
77 $attributes = $this->_build_element_attributes();
78 $attributes["type"] = "button";
79
80 $attributes["value"] = $this->get_value();
81
82 $tag = new INPUTtag($attributes);
83
84 return $tag;
85 }
86
87 }
88
89 /**
90 * This is the SubmitButton FormElement which builds a
91 * input field of type="submit". It has no validation method.
92 *
93 *
94 * @author Walter A. Boring IV <waboring@newsblob.com>
95 * @author Suren Markossian <suren@bcsweb.com>
96 * @package phpHtmlLib
97 * @subpackage FormProcessing
98 *
99 * @copyright LGPL - See LICENCE
100 */
101 class FESubmitButton extends FEButton {
102
103 /**
104 * The constructor
105 *
106 * @param label string - text label for the element
107 * @param string value - button text
108 * @param int required - element width in pixels (px), percentage (%) or elements (em)
109 * @param int required - element height in pixels (px), percentage (%) or elements (em)
110 */
111 function FESubmitButton($label, $value, $width = NULL, $height = NULL) {
112 $this->FEButton($label, $value, 'submit()');
113 }
114
115 /**
116 * This function return the javaScript code for
117 * an onSubmit event
118 *
119 * @return string - javascript code
120 */
121 function onClick() {
122 return $this->get_element_name() . ".disabled=true;";
123 }
124
125 /**
126 * This function builds and returns the
127 * form element object
128 *
129 * @return object
130 */
131 function get_element() {
132
133 $attributes = $this->_build_element_attributes();
134 $attributes["type"] = "submit";
135
136 $attributes["value"] = $this->get_value();
137
138 $tag = new INPUTtag($attributes);
139
140 return $tag;
141 }
142 }
143
144
145 /**
146 * This builds a button that will do a JS popup
147 * question, asking for yes/no. if yes, it submits
148 * the form.
149 *
150 * @author Walter A. Boring IV <waboring@newsblob.com>
151 * @author Suren Markossian <suren@bcsweb.com>
152 * @package phpHtmlLib
153 * @subpackage FormProcessing
154 *
155 * @copyright LGPL - See LICENCE
156 */
157 class FEConfirmActionButton extends FEButton {
158
159 function FEConfirmActionButton($label, $value, $message = NULL, $width = NULL, $height = NULL) {
160 $action = "if (confirm('".$message."')) {this.form.".FORM_ACTION.".value='".$value."'; submit();}";
161 $this->FEButton($label, $value, $action, $width, $height);
162 }
163 }
164 ?>

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