- Timestamp:
- 02/23/06 20:09:13 (6 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/trax/vendor/trax/action_view/helpers/form_tag_helper.php
r132 r138 1 1 <?php 2 # $Id$ 3 # 4 # Copyright (c) 2005 John Peterson 5 # 6 # Permission is hereby granted, free of charge, to any person obtaining 7 # a copy of this software and associated documentation files (the 8 # "Software"), to deal in the Software without restriction, including 9 # without limitation the rights to use, copy, modify, merge, publish, 10 # distribute, sublicense, and/or sell copies of the Software, and to 11 # permit persons to whom the Software is furnished to do so, subject to 12 # the following conditions: 13 # 14 # The above copyright notice and this permission notice shall be 15 # included in all copies or substantial portions of the Software. 16 # 17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 2 /** 3 * File containing the FormTagHelper class and support functions 4 * 5 * (PHP 5) 6 * 7 * @package PHPonTrax 8 * @version $Id$ 9 * @copyright (c) 2005 John Peterson 10 * 11 * Permission is hereby granted, free of charge, to any person obtaining 12 * a copy of this software and associated documentation files (the 13 * "Software"), to deal in the Software without restriction, including 14 * without limitation the rights to use, copy, modify, merge, publish, 15 * distribute, sublicense, and/or sell copies of the Software, and to 16 * permit persons to whom the Software is furnished to do so, subject to 17 * the following conditions: 18 * 19 * The above copyright notice and this permission notice shall be 20 * included in all copies or substantial portions of the Software. 21 * 22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 23 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 24 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 25 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 26 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 27 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 28 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 29 */ 30 31 /** 32 * 33 * @package PHPonTrax 34 */ 25 35 class FormTagHelper extends Helpers { 26 36 27 37 /** 38 * 39 */ 28 40 private function convert_options($options = array()) { 29 41 $arr = array('disabled', 'readonly', 'multiple'); … … 34 46 } 35 47 48 /** 49 * 50 */ 36 51 private function boolean_attribute(&$options, $attribute) { 37 52 if($options[$attribute]) { … … 42 57 } 43 58 59 /** 60 * 61 */ 44 62 function form_tag($url_for_options = array(), $options = array(), $parameters_for_url = array()) { 45 63 $html_options = array_merge(array("method" => "post"), $options); … … 54 72 } 55 73 74 /** 75 * 76 */ 56 77 function start_form_tag() { 57 78 $args = func_get_args(); … … 59 80 } 60 81 82 /** 83 * 84 */ 61 85 function select_tag($name, $option_tags = null, $options = array()) { 62 86 return $this->content_tag("select", $option_tags, array_merge(array("name" => $name, "id" => $name), $this->convert_options($options))); 63 87 } 64 88 89 /** 90 * 91 */ 65 92 function text_field_tag($name, $value = null, $options = array()) { 66 93 return $this->tag("input", array_merge(array("type" => "text", "name" => $name, "id" => $name, "value" => $value), $this->convert_options($options))); 67 94 } 68 95 96 /** 97 * 98 */ 69 99 function hidden_field_tag($name, $value = null, $options = array()) { 70 100 return $this->text_field_tag($name, $value, array_merge($options, array("type" => "hidden"))); 71 101 } 72 102 103 /** 104 * 105 */ 73 106 function file_field_tag($name, $options = array()) { 74 107 return $this->text_field_tag($name, null, array_merge($this->convert_options($options), array("type" => "file"))); 75 108 } 76 109 110 /** 111 * 112 */ 77 113 function password_field_tag($name = "password", $value = null, $options = array()) { 78 114 return $this->text_field_tag($name, $value, array_merge($this->convert_options($options), array("type" => "password"))); 79 115 } 80 116 117 /** 118 * 119 */ 81 120 function text_area_tag($name, $content = null, $options = array()) { 82 121 if ($options["size"]) { … … 90 129 } 91 130 131 /** 132 * 133 */ 92 134 function check_box_tag($name, $value = "1", $checked = false, $options = array()) { 93 135 $html_options = array_merge(array("type" => "checkbox", "name" => $name, "id" => $name, "value" => $value), $this->convert_options($options)); … … 96 138 } 97 139 140 /** 141 * 142 */ 98 143 function radio_button_tag($name, $value, $checked = false, $options = array()) { 99 144 $html_options = array_merge(array("type" => "radio", "name" => $name, "id" => $name, "value" => $value), $this->convert_options($options)); … … 102 147 } 103 148 149 /** 150 * 151 */ 104 152 function submit_tag($value = "Save changes", $options = array()) { 105 153 return $this->tag("input", array_merge(array("type" => "submit", "name" => "commit", "value" => $value), $this->convert_options($options))); 106 154 } 107 155 156 /** 157 * 158 */ 108 159 function image_submit_tag($source, $options = array()) { 109 160 return $this->tag("input", array_merge(array("type" => "image", "src" => image_path($source)), $this->convert_options($options))); … … 112 163 } 113 164 114 ################################################################################################ 115 ##Avialble functions for use in views116 ################################################################################################ 165 /** 166 * Avialble functions for use in views 167 */ 117 168 function form_tag() { 118 169 $form_tag_helper = new FormTagHelper(); … … 121 172 } 122 173 174 /** 175 * 176 */ 123 177 function start_form_tag() { 124 178 $args = func_get_args(); … … 126 180 } 127 181 182 /** 183 * 184 */ 128 185 function end_form_tag() { 129 186 return "</form>"; 130 187 } 131 188 189 /** 190 * 191 */ 132 192 function select_tag() { 133 193 $form_tag_helper = new FormTagHelper(); … … 136 196 } 137 197 198 /** 199 * 200 */ 138 201 function text_field_tag() { 139 202 $form_tag_helper = new FormTagHelper(); … … 142 205 } 143 206 207 /** 208 * 209 */ 144 210 function hidden_field_tag() { 145 211 $form_tag_helper = new FormTagHelper(); … … 148 214 } 149 215 216 /** 217 * 218 */ 150 219 function file_field_tag() { 151 220 $form_tag_helper = new FormTagHelper(); … … 154 223 } 155 224 225 /** 226 * 227 */ 156 228 function password_field_tag() { 157 229 $form_tag_helper = new FormTagHelper(); … … 160 232 } 161 233 234 /** 235 * 236 */ 162 237 function text_area_tag() { 163 238 $form_tag_helper = new FormTagHelper(); … … 166 241 } 167 242 243 /** 244 * 245 */ 168 246 function check_box_tag() { 169 247 $form_tag_helper = new FormTagHelper(); … … 172 250 } 173 251 252 /** 253 * 254 */ 174 255 function radio_button_tag() { 175 256 $form_tag_helper = new FormTagHelper(); … … 178 259 } 179 260 261 /** 262 * 263 */ 180 264 function submit_tag() { 181 265 $form_tag_helper = new FormTagHelper(); … … 184 268 } 185 269 270 /** 271 * 272 */ 186 273 function image_submit_tag() { 187 274 $form_tag_helper = new FormTagHelper();
