@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 2 | - exit('No direct script access allowed'); |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | |
| 5 | 5 | |
@@ -16,237 +16,237 @@ discard block |
||
| 16 | 16 | { |
| 17 | 17 | |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * @var string $_tag |
|
| 21 | - */ |
|
| 22 | - protected $_tag = ''; |
|
| 19 | + /** |
|
| 20 | + * @var string $_tag |
|
| 21 | + */ |
|
| 22 | + protected $_tag = ''; |
|
| 23 | 23 | |
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * returns HTML and javascript related to the displaying of this input |
|
| 30 | - * |
|
| 31 | - * @return string |
|
| 32 | - */ |
|
| 33 | - abstract public function display(); |
|
| 28 | + /** |
|
| 29 | + * returns HTML and javascript related to the displaying of this input |
|
| 30 | + * |
|
| 31 | + * @return string |
|
| 32 | + */ |
|
| 33 | + abstract public function display(); |
|
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * _remove_chars - takes an incoming string, and removes the string $chars from the end of it, but only if $chars |
|
| 39 | - * is already there |
|
| 40 | - * |
|
| 41 | - * @param string $string - the string being processed |
|
| 42 | - * @param string $chars - exact string of characters to remove |
|
| 43 | - * @return string |
|
| 44 | - */ |
|
| 45 | - protected function _remove_chars($string = '', $chars = '-') |
|
| 46 | - { |
|
| 47 | - $char_length = strlen($chars) * -1; |
|
| 48 | - // if last three characters of string is " - ", then remove it |
|
| 49 | - return substr($string, $char_length) === $chars ? substr($string, 0, $char_length) : $string; |
|
| 50 | - } |
|
| 37 | + /** |
|
| 38 | + * _remove_chars - takes an incoming string, and removes the string $chars from the end of it, but only if $chars |
|
| 39 | + * is already there |
|
| 40 | + * |
|
| 41 | + * @param string $string - the string being processed |
|
| 42 | + * @param string $chars - exact string of characters to remove |
|
| 43 | + * @return string |
|
| 44 | + */ |
|
| 45 | + protected function _remove_chars($string = '', $chars = '-') |
|
| 46 | + { |
|
| 47 | + $char_length = strlen($chars) * -1; |
|
| 48 | + // if last three characters of string is " - ", then remove it |
|
| 49 | + return substr($string, $char_length) === $chars ? substr($string, 0, $char_length) : $string; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | 52 | |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * _append_chars - takes an incoming string, and adds the string $chars to the end of it, but only if $chars is not |
|
| 56 | - * already there |
|
| 57 | - * |
|
| 58 | - * @param string $string - the string being processed |
|
| 59 | - * @param string $chars - exact string of characters to be added to end of string |
|
| 60 | - * @return string |
|
| 61 | - */ |
|
| 62 | - protected function _append_chars($string = '', $chars = '-') |
|
| 63 | - { |
|
| 64 | - return $this->_remove_chars($string, $chars) . $chars; |
|
| 65 | - } |
|
| 54 | + /** |
|
| 55 | + * _append_chars - takes an incoming string, and adds the string $chars to the end of it, but only if $chars is not |
|
| 56 | + * already there |
|
| 57 | + * |
|
| 58 | + * @param string $string - the string being processed |
|
| 59 | + * @param string $chars - exact string of characters to be added to end of string |
|
| 60 | + * @return string |
|
| 61 | + */ |
|
| 62 | + protected function _append_chars($string = '', $chars = '-') |
|
| 63 | + { |
|
| 64 | + return $this->_remove_chars($string, $chars) . $chars; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | 67 | |
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * Gets the HTML IDs of all the inputs |
|
| 71 | - * |
|
| 72 | - * @param bool $add_pound_sign |
|
| 73 | - * @return array |
|
| 74 | - */ |
|
| 75 | - public function get_html_input_ids($add_pound_sign = false) |
|
| 76 | - { |
|
| 77 | - return array($this->get_input()->html_id($add_pound_sign)); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * Adds js variables for localization to the $other_js_data. These should be put |
|
| 84 | - * in each form's "other_data" javascript object. |
|
| 85 | - * |
|
| 86 | - * @param array $other_js_data |
|
| 87 | - * @return array |
|
| 88 | - */ |
|
| 89 | - public function get_other_js_data($other_js_data = array()) |
|
| 90 | - { |
|
| 91 | - return $other_js_data; |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * Opportunity for this display strategy to call wp_enqueue_script and wp_enqueue_style. |
|
| 98 | - * This should be called during wp_enqueue_scripts |
|
| 99 | - */ |
|
| 100 | - public function enqueue_js() |
|
| 101 | - { |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * returns string like: '<tag' |
|
| 108 | - * |
|
| 109 | - * @param string $tag |
|
| 110 | - * @return string |
|
| 111 | - */ |
|
| 112 | - protected function _opening_tag($tag) |
|
| 113 | - { |
|
| 114 | - $this->_tag = $tag; |
|
| 115 | - return "<{$this->_tag}"; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * returns string like: '</tag> |
|
| 122 | - * |
|
| 123 | - * @return string |
|
| 124 | - */ |
|
| 125 | - protected function _closing_tag() |
|
| 126 | - { |
|
| 127 | - return "</{$this->_tag}>"; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * returns string like: '/>' |
|
| 134 | - * |
|
| 135 | - * @return string |
|
| 136 | - */ |
|
| 137 | - protected function _close_tag() |
|
| 138 | - { |
|
| 139 | - return '/>'; |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * returns an array of standard HTML attributes that get added to nearly all inputs, |
|
| 146 | - * where string keys represent named attributes like id, class, etc |
|
| 147 | - * and numeric keys represent single attributes like 'required'. |
|
| 148 | - * Note: this does not include "value" because many inputs (like dropdowns, textareas, and checkboxes) don't use |
|
| 149 | - * it. |
|
| 150 | - * |
|
| 151 | - * @return array |
|
| 152 | - */ |
|
| 153 | - protected function _standard_attributes_array() |
|
| 154 | - { |
|
| 155 | - return array( |
|
| 156 | - 'name' => $this->_input->html_name(), |
|
| 157 | - 'id' => $this->_input->html_id(), |
|
| 158 | - 'class' => $this->_input->html_class(true), |
|
| 159 | - 0 => array('required', $this->_input->required()), |
|
| 160 | - 1 => $this->_input->other_html_attributes(), |
|
| 161 | - 'style' => $this->_input->html_style(), |
|
| 162 | - ); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * sets the attributes using the incoming array |
|
| 169 | - * and returns a string of all attributes rendered as valid HTML |
|
| 170 | - * |
|
| 171 | - * @param array $attributes |
|
| 172 | - * @return string |
|
| 173 | - */ |
|
| 174 | - protected function _attributes_string($attributes = array()) |
|
| 175 | - { |
|
| 176 | - $attributes = apply_filters( |
|
| 177 | - 'FHEE__EE_Display_Strategy_Base__attributes_string__attributes', |
|
| 178 | - $attributes, |
|
| 179 | - $this, |
|
| 180 | - $this->_input |
|
| 181 | - ); |
|
| 182 | - $attributes_string = ''; |
|
| 183 | - foreach ($attributes as $attribute => $value) { |
|
| 184 | - if (is_numeric($attribute)) { |
|
| 185 | - $add = true; |
|
| 186 | - if (is_array($value)) { |
|
| 187 | - $attribute = isset($value[0]) ? $value[0] : ''; |
|
| 188 | - $add = isset($value[1]) ? $value[1] : false; |
|
| 189 | - } else { |
|
| 190 | - $attribute = $value; |
|
| 191 | - } |
|
| 192 | - $attributes_string .= $this->_single_attribute($attribute, $add); |
|
| 193 | - } else { |
|
| 194 | - $attributes_string .= $this->_attribute($attribute, $value); |
|
| 195 | - } |
|
| 196 | - } |
|
| 197 | - return $attributes_string; |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - |
|
| 201 | - |
|
| 202 | - /** |
|
| 203 | - * returns string like: ' attribute="value"' |
|
| 204 | - * returns an empty string if $value is null |
|
| 205 | - * |
|
| 206 | - * @param string $attribute |
|
| 207 | - * @param string $value |
|
| 208 | - * @return string |
|
| 209 | - */ |
|
| 210 | - protected function _attribute($attribute, $value = '') |
|
| 211 | - { |
|
| 212 | - if( $value === null) { |
|
| 213 | - return ''; |
|
| 214 | - } |
|
| 215 | - $value = esc_attr($value); |
|
| 216 | - return " {$attribute}=\"{$value}\""; |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - |
|
| 220 | - |
|
| 221 | - /** |
|
| 222 | - * returns string like: ' data-attribute="value"' |
|
| 223 | - * returns an empty string if $value is null |
|
| 224 | - * |
|
| 225 | - * @param string $attribute |
|
| 226 | - * @param string $value |
|
| 227 | - * @return string |
|
| 228 | - */ |
|
| 229 | - protected function _data_attribute($attribute, $value = '') |
|
| 230 | - { |
|
| 231 | - if( $value === null) { |
|
| 232 | - return ''; |
|
| 233 | - } |
|
| 234 | - $value = esc_attr($value); |
|
| 235 | - return " data-{$attribute}=\"{$value}\""; |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - |
|
| 239 | - |
|
| 240 | - /** |
|
| 241 | - * returns string like: ' attribute' if $add is true |
|
| 242 | - * |
|
| 243 | - * @param string $attribute |
|
| 244 | - * @param boolean $add |
|
| 245 | - * @return string |
|
| 246 | - */ |
|
| 247 | - protected function _single_attribute($attribute, $add = true) |
|
| 248 | - { |
|
| 249 | - return $add ? " {$attribute}" : ''; |
|
| 250 | - } |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * Gets the HTML IDs of all the inputs |
|
| 71 | + * |
|
| 72 | + * @param bool $add_pound_sign |
|
| 73 | + * @return array |
|
| 74 | + */ |
|
| 75 | + public function get_html_input_ids($add_pound_sign = false) |
|
| 76 | + { |
|
| 77 | + return array($this->get_input()->html_id($add_pound_sign)); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * Adds js variables for localization to the $other_js_data. These should be put |
|
| 84 | + * in each form's "other_data" javascript object. |
|
| 85 | + * |
|
| 86 | + * @param array $other_js_data |
|
| 87 | + * @return array |
|
| 88 | + */ |
|
| 89 | + public function get_other_js_data($other_js_data = array()) |
|
| 90 | + { |
|
| 91 | + return $other_js_data; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * Opportunity for this display strategy to call wp_enqueue_script and wp_enqueue_style. |
|
| 98 | + * This should be called during wp_enqueue_scripts |
|
| 99 | + */ |
|
| 100 | + public function enqueue_js() |
|
| 101 | + { |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * returns string like: '<tag' |
|
| 108 | + * |
|
| 109 | + * @param string $tag |
|
| 110 | + * @return string |
|
| 111 | + */ |
|
| 112 | + protected function _opening_tag($tag) |
|
| 113 | + { |
|
| 114 | + $this->_tag = $tag; |
|
| 115 | + return "<{$this->_tag}"; |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * returns string like: '</tag> |
|
| 122 | + * |
|
| 123 | + * @return string |
|
| 124 | + */ |
|
| 125 | + protected function _closing_tag() |
|
| 126 | + { |
|
| 127 | + return "</{$this->_tag}>"; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * returns string like: '/>' |
|
| 134 | + * |
|
| 135 | + * @return string |
|
| 136 | + */ |
|
| 137 | + protected function _close_tag() |
|
| 138 | + { |
|
| 139 | + return '/>'; |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * returns an array of standard HTML attributes that get added to nearly all inputs, |
|
| 146 | + * where string keys represent named attributes like id, class, etc |
|
| 147 | + * and numeric keys represent single attributes like 'required'. |
|
| 148 | + * Note: this does not include "value" because many inputs (like dropdowns, textareas, and checkboxes) don't use |
|
| 149 | + * it. |
|
| 150 | + * |
|
| 151 | + * @return array |
|
| 152 | + */ |
|
| 153 | + protected function _standard_attributes_array() |
|
| 154 | + { |
|
| 155 | + return array( |
|
| 156 | + 'name' => $this->_input->html_name(), |
|
| 157 | + 'id' => $this->_input->html_id(), |
|
| 158 | + 'class' => $this->_input->html_class(true), |
|
| 159 | + 0 => array('required', $this->_input->required()), |
|
| 160 | + 1 => $this->_input->other_html_attributes(), |
|
| 161 | + 'style' => $this->_input->html_style(), |
|
| 162 | + ); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * sets the attributes using the incoming array |
|
| 169 | + * and returns a string of all attributes rendered as valid HTML |
|
| 170 | + * |
|
| 171 | + * @param array $attributes |
|
| 172 | + * @return string |
|
| 173 | + */ |
|
| 174 | + protected function _attributes_string($attributes = array()) |
|
| 175 | + { |
|
| 176 | + $attributes = apply_filters( |
|
| 177 | + 'FHEE__EE_Display_Strategy_Base__attributes_string__attributes', |
|
| 178 | + $attributes, |
|
| 179 | + $this, |
|
| 180 | + $this->_input |
|
| 181 | + ); |
|
| 182 | + $attributes_string = ''; |
|
| 183 | + foreach ($attributes as $attribute => $value) { |
|
| 184 | + if (is_numeric($attribute)) { |
|
| 185 | + $add = true; |
|
| 186 | + if (is_array($value)) { |
|
| 187 | + $attribute = isset($value[0]) ? $value[0] : ''; |
|
| 188 | + $add = isset($value[1]) ? $value[1] : false; |
|
| 189 | + } else { |
|
| 190 | + $attribute = $value; |
|
| 191 | + } |
|
| 192 | + $attributes_string .= $this->_single_attribute($attribute, $add); |
|
| 193 | + } else { |
|
| 194 | + $attributes_string .= $this->_attribute($attribute, $value); |
|
| 195 | + } |
|
| 196 | + } |
|
| 197 | + return $attributes_string; |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + |
|
| 201 | + |
|
| 202 | + /** |
|
| 203 | + * returns string like: ' attribute="value"' |
|
| 204 | + * returns an empty string if $value is null |
|
| 205 | + * |
|
| 206 | + * @param string $attribute |
|
| 207 | + * @param string $value |
|
| 208 | + * @return string |
|
| 209 | + */ |
|
| 210 | + protected function _attribute($attribute, $value = '') |
|
| 211 | + { |
|
| 212 | + if( $value === null) { |
|
| 213 | + return ''; |
|
| 214 | + } |
|
| 215 | + $value = esc_attr($value); |
|
| 216 | + return " {$attribute}=\"{$value}\""; |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + |
|
| 220 | + |
|
| 221 | + /** |
|
| 222 | + * returns string like: ' data-attribute="value"' |
|
| 223 | + * returns an empty string if $value is null |
|
| 224 | + * |
|
| 225 | + * @param string $attribute |
|
| 226 | + * @param string $value |
|
| 227 | + * @return string |
|
| 228 | + */ |
|
| 229 | + protected function _data_attribute($attribute, $value = '') |
|
| 230 | + { |
|
| 231 | + if( $value === null) { |
|
| 232 | + return ''; |
|
| 233 | + } |
|
| 234 | + $value = esc_attr($value); |
|
| 235 | + return " data-{$attribute}=\"{$value}\""; |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + |
|
| 239 | + |
|
| 240 | + /** |
|
| 241 | + * returns string like: ' attribute' if $add is true |
|
| 242 | + * |
|
| 243 | + * @param string $attribute |
|
| 244 | + * @param boolean $add |
|
| 245 | + * @return string |
|
| 246 | + */ |
|
| 247 | + protected function _single_attribute($attribute, $add = true) |
|
| 248 | + { |
|
| 249 | + return $add ? " {$attribute}" : ''; |
|
| 250 | + } |
|
| 251 | 251 | |
| 252 | 252 | } |
| 253 | 253 | \ No newline at end of file |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | 2 | exit('No direct script access allowed'); |
| 3 | 3 | } |
| 4 | 4 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | protected function _append_chars($string = '', $chars = '-') |
| 63 | 63 | { |
| 64 | - return $this->_remove_chars($string, $chars) . $chars; |
|
| 64 | + return $this->_remove_chars($string, $chars).$chars; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | */ |
| 210 | 210 | protected function _attribute($attribute, $value = '') |
| 211 | 211 | { |
| 212 | - if( $value === null) { |
|
| 212 | + if ($value === null) { |
|
| 213 | 213 | return ''; |
| 214 | 214 | } |
| 215 | 215 | $value = esc_attr($value); |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | */ |
| 229 | 229 | protected function _data_attribute($attribute, $value = '') |
| 230 | 230 | { |
| 231 | - if( $value === null) { |
|
| 231 | + if ($value === null) { |
|
| 232 | 232 | return ''; |
| 233 | 233 | } |
| 234 | 234 | $value = esc_attr($value); |
@@ -12,32 +12,32 @@ |
||
| 12 | 12 | class EE_Button_Display_Strategy extends EE_Display_Strategy_Base |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @return string of html to display the input |
|
| 17 | - */ |
|
| 18 | - public function display() |
|
| 19 | - { |
|
| 20 | - $default_value = $this->_input->get_default(); |
|
| 21 | - if ($this->_input->get_normalization_strategy() instanceof EE_Normalization_Strategy_Base) { |
|
| 22 | - $default_value = $this->_input->get_normalization_strategy()->unnormalize($default_value); |
|
| 23 | - } |
|
| 24 | - $html = $this->_opening_tag('button'); |
|
| 25 | - $html .= $this->_attributes_string( |
|
| 26 | - array_merge( |
|
| 27 | - $this->_standard_attributes_array(), |
|
| 28 | - array( |
|
| 29 | - 'value' => $default_value, |
|
| 30 | - ) |
|
| 31 | - ) |
|
| 32 | - ); |
|
| 33 | - if ($this->_input instanceof EE_Button_Input) { |
|
| 34 | - $button_content = $this->_input->button_content(); |
|
| 35 | - } else { |
|
| 36 | - $button_content = $this->_input->get_default(); |
|
| 37 | - } |
|
| 38 | - $html .= '>'; |
|
| 39 | - $html .= $button_content; |
|
| 40 | - $html .= $this->_closing_tag(); |
|
| 41 | - return $html; |
|
| 42 | - } |
|
| 15 | + /** |
|
| 16 | + * @return string of html to display the input |
|
| 17 | + */ |
|
| 18 | + public function display() |
|
| 19 | + { |
|
| 20 | + $default_value = $this->_input->get_default(); |
|
| 21 | + if ($this->_input->get_normalization_strategy() instanceof EE_Normalization_Strategy_Base) { |
|
| 22 | + $default_value = $this->_input->get_normalization_strategy()->unnormalize($default_value); |
|
| 23 | + } |
|
| 24 | + $html = $this->_opening_tag('button'); |
|
| 25 | + $html .= $this->_attributes_string( |
|
| 26 | + array_merge( |
|
| 27 | + $this->_standard_attributes_array(), |
|
| 28 | + array( |
|
| 29 | + 'value' => $default_value, |
|
| 30 | + ) |
|
| 31 | + ) |
|
| 32 | + ); |
|
| 33 | + if ($this->_input instanceof EE_Button_Input) { |
|
| 34 | + $button_content = $this->_input->button_content(); |
|
| 35 | + } else { |
|
| 36 | + $button_content = $this->_input->get_default(); |
|
| 37 | + } |
|
| 38 | + $html .= '>'; |
|
| 39 | + $html .= $button_content; |
|
| 40 | + $html .= $this->_closing_tag(); |
|
| 41 | + return $html; |
|
| 42 | + } |
|
| 43 | 43 | } |
@@ -12,26 +12,26 @@ |
||
| 12 | 12 | class EE_Submit_Input_Display_Strategy extends EE_Display_Strategy_Base |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @return string of html to display the input |
|
| 17 | - */ |
|
| 18 | - public function display() |
|
| 19 | - { |
|
| 20 | - $default_value = $this->_input->get_default(); |
|
| 21 | - if ($this->_input->get_normalization_strategy() instanceof EE_Normalization_Strategy_Base) { |
|
| 22 | - $default_value = $this->_input->get_normalization_strategy()->unnormalize($default_value); |
|
| 23 | - } |
|
| 24 | - $html = $this->_opening_tag('input'); |
|
| 25 | - $html .= $this->_attributes_string( |
|
| 26 | - array_merge( |
|
| 27 | - $this->_standard_attributes_array(), |
|
| 28 | - array( |
|
| 29 | - 'type' => 'submit', |
|
| 30 | - 'value' => $default_value, |
|
| 31 | - ) |
|
| 32 | - ) |
|
| 33 | - ); |
|
| 34 | - $html .= $this->_close_tag(); |
|
| 35 | - return $html; |
|
| 15 | + /** |
|
| 16 | + * @return string of html to display the input |
|
| 17 | + */ |
|
| 18 | + public function display() |
|
| 19 | + { |
|
| 20 | + $default_value = $this->_input->get_default(); |
|
| 21 | + if ($this->_input->get_normalization_strategy() instanceof EE_Normalization_Strategy_Base) { |
|
| 22 | + $default_value = $this->_input->get_normalization_strategy()->unnormalize($default_value); |
|
| 23 | + } |
|
| 24 | + $html = $this->_opening_tag('input'); |
|
| 25 | + $html .= $this->_attributes_string( |
|
| 26 | + array_merge( |
|
| 27 | + $this->_standard_attributes_array(), |
|
| 28 | + array( |
|
| 29 | + 'type' => 'submit', |
|
| 30 | + 'value' => $default_value, |
|
| 31 | + ) |
|
| 32 | + ) |
|
| 33 | + ); |
|
| 34 | + $html .= $this->_close_tag(); |
|
| 35 | + return $html; |
|
| 36 | 36 | } |
| 37 | 37 | } |
@@ -10,17 +10,17 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | class EE_Button_Input extends EE_Form_Input_Base{ |
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * @var string of HTML to put between the button tags |
|
| 15 | - */ |
|
| 16 | - protected $_button_content; |
|
| 13 | + /** |
|
| 14 | + * @var string of HTML to put between the button tags |
|
| 15 | + */ |
|
| 16 | + protected $_button_content; |
|
| 17 | 17 | /** |
| 18 | 18 | * @param array $options |
| 19 | 19 | */ |
| 20 | 20 | public function __construct($options = array()){ |
| 21 | - if( empty($options['button_content'])) { |
|
| 22 | - $options['button_content'] = esc_html__('Button', 'event_espresso'); |
|
| 23 | - } |
|
| 21 | + if( empty($options['button_content'])) { |
|
| 22 | + $options['button_content'] = esc_html__('Button', 'event_espresso'); |
|
| 23 | + } |
|
| 24 | 24 | $this->_set_display_strategy(new EE_Button_Display_Strategy()); |
| 25 | 25 | $this->_set_normalization_strategy(new EE_Text_Normalization()); |
| 26 | 26 | $this->_add_validation_strategy( new EE_Plaintext_Validation_Strategy() ); |
@@ -29,22 +29,22 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Sets the button content |
|
| 34 | - * @see EE_Button_Input::$_button_content |
|
| 35 | - * @param string $new_content |
|
| 36 | - */ |
|
| 32 | + /** |
|
| 33 | + * Sets the button content |
|
| 34 | + * @see EE_Button_Input::$_button_content |
|
| 35 | + * @param string $new_content |
|
| 36 | + */ |
|
| 37 | 37 | public function set_button_content($new_content) |
| 38 | - { |
|
| 39 | - $this->_button_content = $new_content; |
|
| 40 | - } |
|
| 38 | + { |
|
| 39 | + $this->_button_content = $new_content; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Gets the button content |
|
| 44 | - * @return string |
|
| 45 | - */ |
|
| 42 | + /** |
|
| 43 | + * Gets the button content |
|
| 44 | + * @return string |
|
| 45 | + */ |
|
| 46 | 46 | public function button_content() |
| 47 | - { |
|
| 48 | - return $this->_button_content; |
|
| 49 | - } |
|
| 47 | + { |
|
| 48 | + return $this->_button_content; |
|
| 49 | + } |
|
| 50 | 50 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | * @author Mike Nelson |
| 9 | 9 | * |
| 10 | 10 | */ |
| 11 | -class EE_Button_Input extends EE_Form_Input_Base{ |
|
| 11 | +class EE_Button_Input extends EE_Form_Input_Base { |
|
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * @var string of HTML to put between the button tags |
@@ -17,13 +17,13 @@ discard block |
||
| 17 | 17 | /** |
| 18 | 18 | * @param array $options |
| 19 | 19 | */ |
| 20 | - public function __construct($options = array()){ |
|
| 21 | - if( empty($options['button_content'])) { |
|
| 20 | + public function __construct($options = array()) { |
|
| 21 | + if (empty($options['button_content'])) { |
|
| 22 | 22 | $options['button_content'] = esc_html__('Button', 'event_espresso'); |
| 23 | 23 | } |
| 24 | 24 | $this->_set_display_strategy(new EE_Button_Display_Strategy()); |
| 25 | 25 | $this->_set_normalization_strategy(new EE_Text_Normalization()); |
| 26 | - $this->_add_validation_strategy( new EE_Plaintext_Validation_Strategy() ); |
|
| 26 | + $this->_add_validation_strategy(new EE_Plaintext_Validation_Strategy()); |
|
| 27 | 27 | parent::__construct($options); |
| 28 | 28 | } |
| 29 | 29 | |