@@ -24,6 +24,6 @@ |
||
| 24 | 24 | ) |
| 25 | 25 | ); |
| 26 | 26 | parent::__construct($input_settings); |
| 27 | - $this->set_html_class($this->html_class() . ' email'); |
|
| 27 | + $this->set_html_class($this->html_class().' email'); |
|
| 28 | 28 | } |
| 29 | 29 | } |
@@ -9,21 +9,21 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | class EE_Email_Input extends EE_Form_Input_Base |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * @param array $input_settings |
|
| 14 | - */ |
|
| 15 | - public function __construct($input_settings = array()) |
|
| 16 | - { |
|
| 17 | - $this->_set_display_strategy(new EE_Text_Input_Display_Strategy('email')); |
|
| 18 | - $this->_set_normalization_strategy(new EE_Text_Normalization()); |
|
| 19 | - $this->_add_validation_strategy( |
|
| 20 | - new EE_Email_Validation_Strategy( |
|
| 21 | - isset($input_settings['validation_error_message']) |
|
| 22 | - ? $input_settings['validation_error_message'] |
|
| 23 | - : null |
|
| 24 | - ) |
|
| 25 | - ); |
|
| 26 | - parent::__construct($input_settings); |
|
| 27 | - $this->set_html_class($this->html_class() . ' email'); |
|
| 28 | - } |
|
| 12 | + /** |
|
| 13 | + * @param array $input_settings |
|
| 14 | + */ |
|
| 15 | + public function __construct($input_settings = array()) |
|
| 16 | + { |
|
| 17 | + $this->_set_display_strategy(new EE_Text_Input_Display_Strategy('email')); |
|
| 18 | + $this->_set_normalization_strategy(new EE_Text_Normalization()); |
|
| 19 | + $this->_add_validation_strategy( |
|
| 20 | + new EE_Email_Validation_Strategy( |
|
| 21 | + isset($input_settings['validation_error_message']) |
|
| 22 | + ? $input_settings['validation_error_message'] |
|
| 23 | + : null |
|
| 24 | + ) |
|
| 25 | + ); |
|
| 26 | + parent::__construct($input_settings); |
|
| 27 | + $this->set_html_class($this->html_class() . ' email'); |
|
| 28 | + } |
|
| 29 | 29 | } |
@@ -29,8 +29,8 @@ |
||
| 29 | 29 | 'type' => 'submit', |
| 30 | 30 | 'value' => $default_value, |
| 31 | 31 | // overwrite the standard id with the backwards compatible one |
| 32 | - 'id' => $this->_input->html_id() . '-submit', |
|
| 33 | - 'class' => $this->_input->html_class() . ' ' . $this->_input->button_css_attributes() |
|
| 32 | + 'id' => $this->_input->html_id().'-submit', |
|
| 33 | + 'class' => $this->_input->html_class().' '.$this->_input->button_css_attributes() |
|
| 34 | 34 | ) |
| 35 | 35 | ) |
| 36 | 36 | ); |
@@ -9,29 +9,29 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | class EE_Submit_Input_Display_Strategy extends EE_Display_Strategy_Base |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * @return string of html to display the input |
|
| 14 | - */ |
|
| 15 | - public function display() |
|
| 16 | - { |
|
| 17 | - $default_value = $this->_input->get_default(); |
|
| 18 | - if ($this->_input->get_normalization_strategy() instanceof EE_Normalization_Strategy_Base) { |
|
| 19 | - $default_value = $this->_input->get_normalization_strategy()->unnormalize($default_value); |
|
| 20 | - } |
|
| 21 | - $html = $this->_opening_tag('input'); |
|
| 22 | - $html .= $this->_attributes_string( |
|
| 23 | - array_merge( |
|
| 24 | - $this->_standard_attributes_array(), |
|
| 25 | - array( |
|
| 26 | - 'type' => 'submit', |
|
| 27 | - 'value' => $default_value, |
|
| 28 | - // overwrite the standard id with the backwards compatible one |
|
| 29 | - 'id' => $this->_input->html_id() . '-submit', |
|
| 30 | - 'class' => $this->_input->html_class() . ' ' . $this->_input->button_css_attributes() |
|
| 31 | - ) |
|
| 32 | - ) |
|
| 33 | - ); |
|
| 34 | - $html .= $this->_close_tag(); |
|
| 35 | - return $html; |
|
| 36 | - } |
|
| 12 | + /** |
|
| 13 | + * @return string of html to display the input |
|
| 14 | + */ |
|
| 15 | + public function display() |
|
| 16 | + { |
|
| 17 | + $default_value = $this->_input->get_default(); |
|
| 18 | + if ($this->_input->get_normalization_strategy() instanceof EE_Normalization_Strategy_Base) { |
|
| 19 | + $default_value = $this->_input->get_normalization_strategy()->unnormalize($default_value); |
|
| 20 | + } |
|
| 21 | + $html = $this->_opening_tag('input'); |
|
| 22 | + $html .= $this->_attributes_string( |
|
| 23 | + array_merge( |
|
| 24 | + $this->_standard_attributes_array(), |
|
| 25 | + array( |
|
| 26 | + 'type' => 'submit', |
|
| 27 | + 'value' => $default_value, |
|
| 28 | + // overwrite the standard id with the backwards compatible one |
|
| 29 | + 'id' => $this->_input->html_id() . '-submit', |
|
| 30 | + 'class' => $this->_input->html_class() . ' ' . $this->_input->button_css_attributes() |
|
| 31 | + ) |
|
| 32 | + ) |
|
| 33 | + ); |
|
| 34 | + $html .= $this->_close_tag(); |
|
| 35 | + return $html; |
|
| 36 | + } |
|
| 37 | 37 | } |
@@ -11,13 +11,13 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class EE_Hidden_Display_Strategy extends EE_Display_Strategy_Base |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * |
|
| 16 | - * @return string of html to display the HIDDEN field |
|
| 17 | - */ |
|
| 18 | - public function display() |
|
| 19 | - { |
|
| 20 | - $input = $this->_input; |
|
| 21 | - return "<input type='hidden' id='{$input->html_id()}' name='{$input->html_name()}' class='{$input->html_class()}' style='{$input->html_style()}' value='{$input->raw_value_in_form()}' {$input->other_html_attributes()}/>"; |
|
| 22 | - } |
|
| 14 | + /** |
|
| 15 | + * |
|
| 16 | + * @return string of html to display the HIDDEN field |
|
| 17 | + */ |
|
| 18 | + public function display() |
|
| 19 | + { |
|
| 20 | + $input = $this->_input; |
|
| 21 | + return "<input type='hidden' id='{$input->html_id()}' name='{$input->html_name()}' class='{$input->html_class()}' style='{$input->html_style()}' value='{$input->raw_value_in_form()}' {$input->other_html_attributes()}/>"; |
|
| 22 | + } |
|
| 23 | 23 | } |
@@ -56,7 +56,7 @@ |
||
| 56 | 56 | */ |
| 57 | 57 | protected function _append_chars($string = '', $chars = '-') |
| 58 | 58 | { |
| 59 | - return $this->_remove_chars($string, $chars) . $chars; |
|
| 59 | + return $this->_remove_chars($string, $chars).$chars; |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | |
@@ -10,236 +10,236 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | abstract class EE_Display_Strategy_Base extends EE_Form_Input_Strategy_Base |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * @var string $_tag |
|
| 15 | - */ |
|
| 16 | - protected $_tag = ''; |
|
| 13 | + /** |
|
| 14 | + * @var string $_tag |
|
| 15 | + */ |
|
| 16 | + protected $_tag = ''; |
|
| 17 | 17 | |
| 18 | 18 | |
| 19 | 19 | |
| 20 | - |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * returns HTML and javascript related to the displaying of this input |
|
| 24 | - * |
|
| 25 | - * @return string |
|
| 26 | - */ |
|
| 27 | - abstract public function display(); |
|
| 20 | + |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * returns HTML and javascript related to the displaying of this input |
|
| 24 | + * |
|
| 25 | + * @return string |
|
| 26 | + */ |
|
| 27 | + abstract public function display(); |
|
| 28 | 28 | |
| 29 | 29 | |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * _remove_chars - takes an incoming string, and removes the string $chars from the end of it, but only if $chars |
|
| 33 | - * is already there |
|
| 34 | - * |
|
| 35 | - * @param string $string - the string being processed |
|
| 36 | - * @param string $chars - exact string of characters to remove |
|
| 37 | - * @return string |
|
| 38 | - */ |
|
| 39 | - protected function _remove_chars($string = '', $chars = '-') |
|
| 40 | - { |
|
| 41 | - $char_length = strlen($chars) * -1; |
|
| 42 | - // if last three characters of string is " - ", then remove it |
|
| 43 | - return substr($string, $char_length) === $chars ? substr($string, 0, $char_length) : $string; |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * _append_chars - takes an incoming string, and adds the string $chars to the end of it, but only if $chars is not |
|
| 50 | - * already there |
|
| 51 | - * |
|
| 52 | - * @param string $string - the string being processed |
|
| 53 | - * @param string $chars - exact string of characters to be added to end of string |
|
| 54 | - * @return string |
|
| 55 | - */ |
|
| 56 | - protected function _append_chars($string = '', $chars = '-') |
|
| 57 | - { |
|
| 58 | - return $this->_remove_chars($string, $chars) . $chars; |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Gets the HTML IDs of all the inputs |
|
| 65 | - * |
|
| 66 | - * @param bool $add_pound_sign |
|
| 67 | - * @return array |
|
| 68 | - */ |
|
| 69 | - public function get_html_input_ids($add_pound_sign = false) |
|
| 70 | - { |
|
| 71 | - return array($this->get_input()->html_id($add_pound_sign)); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * Adds js variables for localization to the $other_js_data. These should be put |
|
| 78 | - * in each form's "other_data" javascript object. |
|
| 79 | - * |
|
| 80 | - * @param array $other_js_data |
|
| 81 | - * @return array |
|
| 82 | - */ |
|
| 83 | - public function get_other_js_data($other_js_data = array()) |
|
| 84 | - { |
|
| 85 | - return $other_js_data; |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * Opportunity for this display strategy to call wp_enqueue_script and wp_enqueue_style. |
|
| 92 | - * This should be called during wp_enqueue_scripts |
|
| 93 | - */ |
|
| 94 | - public function enqueue_js() |
|
| 95 | - { |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * returns string like: '<tag' |
|
| 102 | - * |
|
| 103 | - * @param string $tag |
|
| 104 | - * @return string |
|
| 105 | - */ |
|
| 106 | - protected function _opening_tag($tag) |
|
| 107 | - { |
|
| 108 | - $this->_tag = $tag; |
|
| 109 | - return "<{$this->_tag}"; |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * returns string like: '</tag> |
|
| 116 | - * |
|
| 117 | - * @return string |
|
| 118 | - */ |
|
| 119 | - protected function _closing_tag() |
|
| 120 | - { |
|
| 121 | - return "</{$this->_tag}>"; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * returns string like: '/>' |
|
| 128 | - * |
|
| 129 | - * @return string |
|
| 130 | - */ |
|
| 131 | - protected function _close_tag() |
|
| 132 | - { |
|
| 133 | - return '/>'; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * returns an array of standard HTML attributes that get added to nearly all inputs, |
|
| 140 | - * where string keys represent named attributes like id, class, etc |
|
| 141 | - * and numeric keys represent single attributes like 'required'. |
|
| 142 | - * Note: this does not include "value" because many inputs (like dropdowns, textareas, and checkboxes) don't use |
|
| 143 | - * it. |
|
| 144 | - * |
|
| 145 | - * @return array |
|
| 146 | - */ |
|
| 147 | - protected function _standard_attributes_array() |
|
| 148 | - { |
|
| 149 | - return array( |
|
| 150 | - 'name' => $this->_input->html_name(), |
|
| 151 | - 'id' => $this->_input->html_id(), |
|
| 152 | - 'class' => $this->_input->html_class(true), |
|
| 153 | - 0 => array('required', $this->_input->required()), |
|
| 154 | - 1 => $this->_input->other_html_attributes(), |
|
| 155 | - 'style' => $this->_input->html_style(), |
|
| 156 | - ); |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - |
|
| 160 | - |
|
| 161 | - /** |
|
| 162 | - * sets the attributes using the incoming array |
|
| 163 | - * and returns a string of all attributes rendered as valid HTML |
|
| 164 | - * |
|
| 165 | - * @param array $attributes |
|
| 166 | - * @return string |
|
| 167 | - */ |
|
| 168 | - protected function _attributes_string($attributes = array()) |
|
| 169 | - { |
|
| 170 | - $attributes = apply_filters( |
|
| 171 | - 'FHEE__EE_Display_Strategy_Base__attributes_string__attributes', |
|
| 172 | - $attributes, |
|
| 173 | - $this, |
|
| 174 | - $this->_input |
|
| 175 | - ); |
|
| 176 | - $attributes_string = ''; |
|
| 177 | - foreach ($attributes as $attribute => $value) { |
|
| 178 | - if (is_numeric($attribute)) { |
|
| 179 | - $add = true; |
|
| 180 | - if (is_array($value)) { |
|
| 181 | - $attribute = isset($value[0]) ? $value[0] : ''; |
|
| 182 | - $add = isset($value[1]) ? $value[1] : false; |
|
| 183 | - } else { |
|
| 184 | - $attribute = $value; |
|
| 185 | - } |
|
| 186 | - $attributes_string .= $this->_single_attribute($attribute, $add); |
|
| 187 | - } else { |
|
| 188 | - $attributes_string .= $this->_attribute($attribute, $value); |
|
| 189 | - } |
|
| 190 | - } |
|
| 191 | - return $attributes_string; |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * returns string like: ' attribute="value"' |
|
| 198 | - * returns an empty string if $value is null |
|
| 199 | - * |
|
| 200 | - * @param string $attribute |
|
| 201 | - * @param string $value |
|
| 202 | - * @return string |
|
| 203 | - */ |
|
| 204 | - protected function _attribute($attribute, $value = '') |
|
| 205 | - { |
|
| 206 | - if ($value === null) { |
|
| 207 | - return ''; |
|
| 208 | - } |
|
| 209 | - $value = esc_attr($value); |
|
| 210 | - return " {$attribute}=\"{$value}\""; |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * returns string like: ' data-attribute="value"' |
|
| 217 | - * returns an empty string if $value is null |
|
| 218 | - * |
|
| 219 | - * @param string $attribute |
|
| 220 | - * @param string $value |
|
| 221 | - * @return string |
|
| 222 | - */ |
|
| 223 | - protected function _data_attribute($attribute, $value = '') |
|
| 224 | - { |
|
| 225 | - if ($value === null) { |
|
| 226 | - return ''; |
|
| 227 | - } |
|
| 228 | - $value = esc_attr($value); |
|
| 229 | - return " data-{$attribute}=\"{$value}\""; |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - |
|
| 233 | - |
|
| 234 | - /** |
|
| 235 | - * returns string like: ' attribute' if $add is true |
|
| 236 | - * |
|
| 237 | - * @param string $attribute |
|
| 238 | - * @param boolean $add |
|
| 239 | - * @return string |
|
| 240 | - */ |
|
| 241 | - protected function _single_attribute($attribute, $add = true) |
|
| 242 | - { |
|
| 243 | - return $add ? " {$attribute}" : ''; |
|
| 244 | - } |
|
| 31 | + /** |
|
| 32 | + * _remove_chars - takes an incoming string, and removes the string $chars from the end of it, but only if $chars |
|
| 33 | + * is already there |
|
| 34 | + * |
|
| 35 | + * @param string $string - the string being processed |
|
| 36 | + * @param string $chars - exact string of characters to remove |
|
| 37 | + * @return string |
|
| 38 | + */ |
|
| 39 | + protected function _remove_chars($string = '', $chars = '-') |
|
| 40 | + { |
|
| 41 | + $char_length = strlen($chars) * -1; |
|
| 42 | + // if last three characters of string is " - ", then remove it |
|
| 43 | + return substr($string, $char_length) === $chars ? substr($string, 0, $char_length) : $string; |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * _append_chars - takes an incoming string, and adds the string $chars to the end of it, but only if $chars is not |
|
| 50 | + * already there |
|
| 51 | + * |
|
| 52 | + * @param string $string - the string being processed |
|
| 53 | + * @param string $chars - exact string of characters to be added to end of string |
|
| 54 | + * @return string |
|
| 55 | + */ |
|
| 56 | + protected function _append_chars($string = '', $chars = '-') |
|
| 57 | + { |
|
| 58 | + return $this->_remove_chars($string, $chars) . $chars; |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Gets the HTML IDs of all the inputs |
|
| 65 | + * |
|
| 66 | + * @param bool $add_pound_sign |
|
| 67 | + * @return array |
|
| 68 | + */ |
|
| 69 | + public function get_html_input_ids($add_pound_sign = false) |
|
| 70 | + { |
|
| 71 | + return array($this->get_input()->html_id($add_pound_sign)); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * Adds js variables for localization to the $other_js_data. These should be put |
|
| 78 | + * in each form's "other_data" javascript object. |
|
| 79 | + * |
|
| 80 | + * @param array $other_js_data |
|
| 81 | + * @return array |
|
| 82 | + */ |
|
| 83 | + public function get_other_js_data($other_js_data = array()) |
|
| 84 | + { |
|
| 85 | + return $other_js_data; |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * Opportunity for this display strategy to call wp_enqueue_script and wp_enqueue_style. |
|
| 92 | + * This should be called during wp_enqueue_scripts |
|
| 93 | + */ |
|
| 94 | + public function enqueue_js() |
|
| 95 | + { |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * returns string like: '<tag' |
|
| 102 | + * |
|
| 103 | + * @param string $tag |
|
| 104 | + * @return string |
|
| 105 | + */ |
|
| 106 | + protected function _opening_tag($tag) |
|
| 107 | + { |
|
| 108 | + $this->_tag = $tag; |
|
| 109 | + return "<{$this->_tag}"; |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * returns string like: '</tag> |
|
| 116 | + * |
|
| 117 | + * @return string |
|
| 118 | + */ |
|
| 119 | + protected function _closing_tag() |
|
| 120 | + { |
|
| 121 | + return "</{$this->_tag}>"; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * returns string like: '/>' |
|
| 128 | + * |
|
| 129 | + * @return string |
|
| 130 | + */ |
|
| 131 | + protected function _close_tag() |
|
| 132 | + { |
|
| 133 | + return '/>'; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * returns an array of standard HTML attributes that get added to nearly all inputs, |
|
| 140 | + * where string keys represent named attributes like id, class, etc |
|
| 141 | + * and numeric keys represent single attributes like 'required'. |
|
| 142 | + * Note: this does not include "value" because many inputs (like dropdowns, textareas, and checkboxes) don't use |
|
| 143 | + * it. |
|
| 144 | + * |
|
| 145 | + * @return array |
|
| 146 | + */ |
|
| 147 | + protected function _standard_attributes_array() |
|
| 148 | + { |
|
| 149 | + return array( |
|
| 150 | + 'name' => $this->_input->html_name(), |
|
| 151 | + 'id' => $this->_input->html_id(), |
|
| 152 | + 'class' => $this->_input->html_class(true), |
|
| 153 | + 0 => array('required', $this->_input->required()), |
|
| 154 | + 1 => $this->_input->other_html_attributes(), |
|
| 155 | + 'style' => $this->_input->html_style(), |
|
| 156 | + ); |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + |
|
| 160 | + |
|
| 161 | + /** |
|
| 162 | + * sets the attributes using the incoming array |
|
| 163 | + * and returns a string of all attributes rendered as valid HTML |
|
| 164 | + * |
|
| 165 | + * @param array $attributes |
|
| 166 | + * @return string |
|
| 167 | + */ |
|
| 168 | + protected function _attributes_string($attributes = array()) |
|
| 169 | + { |
|
| 170 | + $attributes = apply_filters( |
|
| 171 | + 'FHEE__EE_Display_Strategy_Base__attributes_string__attributes', |
|
| 172 | + $attributes, |
|
| 173 | + $this, |
|
| 174 | + $this->_input |
|
| 175 | + ); |
|
| 176 | + $attributes_string = ''; |
|
| 177 | + foreach ($attributes as $attribute => $value) { |
|
| 178 | + if (is_numeric($attribute)) { |
|
| 179 | + $add = true; |
|
| 180 | + if (is_array($value)) { |
|
| 181 | + $attribute = isset($value[0]) ? $value[0] : ''; |
|
| 182 | + $add = isset($value[1]) ? $value[1] : false; |
|
| 183 | + } else { |
|
| 184 | + $attribute = $value; |
|
| 185 | + } |
|
| 186 | + $attributes_string .= $this->_single_attribute($attribute, $add); |
|
| 187 | + } else { |
|
| 188 | + $attributes_string .= $this->_attribute($attribute, $value); |
|
| 189 | + } |
|
| 190 | + } |
|
| 191 | + return $attributes_string; |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + |
|
| 195 | + |
|
| 196 | + /** |
|
| 197 | + * returns string like: ' attribute="value"' |
|
| 198 | + * returns an empty string if $value is null |
|
| 199 | + * |
|
| 200 | + * @param string $attribute |
|
| 201 | + * @param string $value |
|
| 202 | + * @return string |
|
| 203 | + */ |
|
| 204 | + protected function _attribute($attribute, $value = '') |
|
| 205 | + { |
|
| 206 | + if ($value === null) { |
|
| 207 | + return ''; |
|
| 208 | + } |
|
| 209 | + $value = esc_attr($value); |
|
| 210 | + return " {$attribute}=\"{$value}\""; |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * returns string like: ' data-attribute="value"' |
|
| 217 | + * returns an empty string if $value is null |
|
| 218 | + * |
|
| 219 | + * @param string $attribute |
|
| 220 | + * @param string $value |
|
| 221 | + * @return string |
|
| 222 | + */ |
|
| 223 | + protected function _data_attribute($attribute, $value = '') |
|
| 224 | + { |
|
| 225 | + if ($value === null) { |
|
| 226 | + return ''; |
|
| 227 | + } |
|
| 228 | + $value = esc_attr($value); |
|
| 229 | + return " data-{$attribute}=\"{$value}\""; |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + |
|
| 233 | + |
|
| 234 | + /** |
|
| 235 | + * returns string like: ' attribute' if $add is true |
|
| 236 | + * |
|
| 237 | + * @param string $attribute |
|
| 238 | + * @param boolean $add |
|
| 239 | + * @return string |
|
| 240 | + */ |
|
| 241 | + protected function _single_attribute($attribute, $add = true) |
|
| 242 | + { |
|
| 243 | + return $add ? " {$attribute}" : ''; |
|
| 244 | + } |
|
| 245 | 245 | } |
@@ -20,12 +20,12 @@ |
||
| 20 | 20 | $cols = 20; |
| 21 | 21 | } |
| 22 | 22 | $html = '<textarea'; |
| 23 | - $html .= ' id="' . $input->html_id() . '"'; |
|
| 24 | - $html .= ' name="' . $input->html_name() . '"'; |
|
| 25 | - $html .= ' class="' . $input->html_class() . '"' ; |
|
| 26 | - $html .= ' style="' . $input->html_style() . '"'; |
|
| 23 | + $html .= ' id="'.$input->html_id().'"'; |
|
| 24 | + $html .= ' name="'.$input->html_name().'"'; |
|
| 25 | + $html .= ' class="'.$input->html_class().'"'; |
|
| 26 | + $html .= ' style="'.$input->html_style().'"'; |
|
| 27 | 27 | $html .= $input->other_html_attributes(); |
| 28 | - $html .= ' rows= "' . $rows . '" cols="' . $cols . '">'; |
|
| 28 | + $html .= ' rows= "'.$rows.'" cols="'.$cols.'">'; |
|
| 29 | 29 | $html .= esc_textarea($raw_value); |
| 30 | 30 | $html .= '</textarea>'; |
| 31 | 31 | foreach ($this->_input->get_validation_strategies() as $validation_strategy) { |
@@ -2,43 +2,43 @@ |
||
| 2 | 2 | |
| 3 | 3 | class EE_Text_Area_Display_Strategy extends EE_Display_Strategy_Base |
| 4 | 4 | { |
| 5 | - /** |
|
| 6 | - * |
|
| 7 | - * @return string of html to display the field |
|
| 8 | - */ |
|
| 9 | - public function display() |
|
| 10 | - { |
|
| 11 | - $input = $this->_input; |
|
| 12 | - $raw_value = maybe_serialize($input->raw_value()); |
|
| 13 | - if ($input instanceof EE_Text_Area_Input) { |
|
| 14 | - $rows = $input->get_rows(); |
|
| 15 | - $cols = $input->get_cols(); |
|
| 16 | - } else { |
|
| 17 | - $rows = 4; |
|
| 18 | - $cols = 20; |
|
| 19 | - } |
|
| 20 | - $html = '<textarea'; |
|
| 21 | - $html .= ' id="' . $input->html_id() . '"'; |
|
| 22 | - $html .= ' name="' . $input->html_name() . '"'; |
|
| 23 | - $html .= ' class="' . $input->html_class() . '"' ; |
|
| 24 | - $html .= ' style="' . $input->html_style() . '"'; |
|
| 25 | - $html .= $input->other_html_attributes(); |
|
| 26 | - $html .= ' rows= "' . $rows . '" cols="' . $cols . '">'; |
|
| 27 | - $html .= esc_textarea($raw_value); |
|
| 28 | - $html .= '</textarea>'; |
|
| 29 | - foreach ($this->_input->get_validation_strategies() as $validation_strategy) { |
|
| 30 | - if ( |
|
| 31 | - $validation_strategy instanceof EE_Simple_HTML_Validation_Strategy |
|
| 32 | - || $validation_strategy instanceof EE_Full_HTML_Validation_Strategy |
|
| 33 | - ) { |
|
| 34 | - $html .= sprintf( |
|
| 35 | - esc_html__('%1$s(allowed tags: %2$s)%3$s', 'event_espresso'), |
|
| 36 | - '<p class="ee-question-desc">', |
|
| 37 | - $validation_strategy->get_list_of_allowed_tags(), |
|
| 38 | - '</p>' |
|
| 39 | - ); |
|
| 40 | - } |
|
| 41 | - } |
|
| 42 | - return $html; |
|
| 43 | - } |
|
| 5 | + /** |
|
| 6 | + * |
|
| 7 | + * @return string of html to display the field |
|
| 8 | + */ |
|
| 9 | + public function display() |
|
| 10 | + { |
|
| 11 | + $input = $this->_input; |
|
| 12 | + $raw_value = maybe_serialize($input->raw_value()); |
|
| 13 | + if ($input instanceof EE_Text_Area_Input) { |
|
| 14 | + $rows = $input->get_rows(); |
|
| 15 | + $cols = $input->get_cols(); |
|
| 16 | + } else { |
|
| 17 | + $rows = 4; |
|
| 18 | + $cols = 20; |
|
| 19 | + } |
|
| 20 | + $html = '<textarea'; |
|
| 21 | + $html .= ' id="' . $input->html_id() . '"'; |
|
| 22 | + $html .= ' name="' . $input->html_name() . '"'; |
|
| 23 | + $html .= ' class="' . $input->html_class() . '"' ; |
|
| 24 | + $html .= ' style="' . $input->html_style() . '"'; |
|
| 25 | + $html .= $input->other_html_attributes(); |
|
| 26 | + $html .= ' rows= "' . $rows . '" cols="' . $cols . '">'; |
|
| 27 | + $html .= esc_textarea($raw_value); |
|
| 28 | + $html .= '</textarea>'; |
|
| 29 | + foreach ($this->_input->get_validation_strategies() as $validation_strategy) { |
|
| 30 | + if ( |
|
| 31 | + $validation_strategy instanceof EE_Simple_HTML_Validation_Strategy |
|
| 32 | + || $validation_strategy instanceof EE_Full_HTML_Validation_Strategy |
|
| 33 | + ) { |
|
| 34 | + $html .= sprintf( |
|
| 35 | + esc_html__('%1$s(allowed tags: %2$s)%3$s', 'event_espresso'), |
|
| 36 | + '<p class="ee-question-desc">', |
|
| 37 | + $validation_strategy->get_list_of_allowed_tags(), |
|
| 38 | + '</p>' |
|
| 39 | + ); |
|
| 40 | + } |
|
| 41 | + } |
|
| 42 | + return $html; |
|
| 43 | + } |
|
| 44 | 44 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | } |
| 44 | 44 | $normalized_array_value = array(); |
| 45 | 45 | foreach ($items_to_normalize as $key => $individual_item) { |
| 46 | - $normalized_array_value[ $key ] = $this->normalize_one($individual_item); |
|
| 46 | + $normalized_array_value[$key] = $this->normalize_one($individual_item); |
|
| 47 | 47 | } |
| 48 | 48 | return $normalized_array_value; |
| 49 | 49 | } |
@@ -74,12 +74,12 @@ discard block |
||
| 74 | 74 | if ($normalized_values === null) { |
| 75 | 75 | $normalized_values = array(); |
| 76 | 76 | } |
| 77 | - if (! is_array($normalized_values)) { |
|
| 77 | + if ( ! is_array($normalized_values)) { |
|
| 78 | 78 | $normalized_values = array($normalized_values); |
| 79 | 79 | } |
| 80 | 80 | $non_normal_values = array(); |
| 81 | 81 | foreach ($normalized_values as $key => $value) { |
| 82 | - $non_normal_values[ $key ] = $this->unnormalize_one($value); |
|
| 82 | + $non_normal_values[$key] = $this->unnormalize_one($value); |
|
| 83 | 83 | } |
| 84 | 84 | return $non_normal_values; |
| 85 | 85 | } |
@@ -9,90 +9,90 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | class EE_Many_Valued_Normalization extends EE_Normalization_Strategy_Base |
| 11 | 11 | { |
| 12 | - protected $_individual_item_normalization_strategy = array(); |
|
| 13 | - |
|
| 14 | - |
|
| 15 | - |
|
| 16 | - /** |
|
| 17 | - * @param EE_Normalization_Strategy_Base $individual_item_normalization_strategy |
|
| 18 | - */ |
|
| 19 | - public function __construct($individual_item_normalization_strategy) |
|
| 20 | - { |
|
| 21 | - $this->_individual_item_normalization_strategy = $individual_item_normalization_strategy; |
|
| 22 | - parent::__construct(); |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * Normalizes the input into an array, and normalizes each item according to its |
|
| 29 | - * individual item normalization strategy |
|
| 30 | - * |
|
| 31 | - * @param array | string $value_to_normalize |
|
| 32 | - * @return array |
|
| 33 | - */ |
|
| 34 | - public function normalize($value_to_normalize) |
|
| 35 | - { |
|
| 36 | - if (is_array($value_to_normalize)) { |
|
| 37 | - $items_to_normalize = $value_to_normalize; |
|
| 38 | - } elseif ($value_to_normalize !== null) { |
|
| 39 | - $items_to_normalize = array($value_to_normalize); |
|
| 40 | - } else { |
|
| 41 | - $items_to_normalize = array(); |
|
| 42 | - } |
|
| 43 | - $normalized_array_value = array(); |
|
| 44 | - foreach ($items_to_normalize as $key => $individual_item) { |
|
| 45 | - $normalized_array_value[ $key ] = $this->normalize_one($individual_item); |
|
| 46 | - } |
|
| 47 | - return $normalized_array_value; |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * Normalized the one item (called for each array item in EE_Many_values_Normalization::normalize()) |
|
| 54 | - * |
|
| 55 | - * @param string $individual_value_to_normalize but definitely NOT an array |
|
| 56 | - * @return mixed |
|
| 57 | - */ |
|
| 58 | - public function normalize_one($individual_value_to_normalize) |
|
| 59 | - { |
|
| 60 | - return $this->_individual_item_normalization_strategy->normalize($individual_value_to_normalize); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * Converts the array of normalized things to an array of raw html values. |
|
| 67 | - * |
|
| 68 | - * @param array $normalized_values |
|
| 69 | - * @return string[] |
|
| 70 | - */ |
|
| 71 | - public function unnormalize($normalized_values) |
|
| 72 | - { |
|
| 73 | - if ($normalized_values === null) { |
|
| 74 | - $normalized_values = array(); |
|
| 75 | - } |
|
| 76 | - if (! is_array($normalized_values)) { |
|
| 77 | - $normalized_values = array($normalized_values); |
|
| 78 | - } |
|
| 79 | - $non_normal_values = array(); |
|
| 80 | - foreach ($normalized_values as $key => $value) { |
|
| 81 | - $non_normal_values[ $key ] = $this->unnormalize_one($value); |
|
| 82 | - } |
|
| 83 | - return $non_normal_values; |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * Unnormalizes an individual item in the array of values |
|
| 90 | - * |
|
| 91 | - * @param mixed $individual_value_to_unnormalize but certainly NOT an array |
|
| 92 | - * @return string |
|
| 93 | - */ |
|
| 94 | - public function unnormalize_one($individual_value_to_unnormalize) |
|
| 95 | - { |
|
| 96 | - return $this->_individual_item_normalization_strategy->unnormalize($individual_value_to_unnormalize); |
|
| 97 | - } |
|
| 12 | + protected $_individual_item_normalization_strategy = array(); |
|
| 13 | + |
|
| 14 | + |
|
| 15 | + |
|
| 16 | + /** |
|
| 17 | + * @param EE_Normalization_Strategy_Base $individual_item_normalization_strategy |
|
| 18 | + */ |
|
| 19 | + public function __construct($individual_item_normalization_strategy) |
|
| 20 | + { |
|
| 21 | + $this->_individual_item_normalization_strategy = $individual_item_normalization_strategy; |
|
| 22 | + parent::__construct(); |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * Normalizes the input into an array, and normalizes each item according to its |
|
| 29 | + * individual item normalization strategy |
|
| 30 | + * |
|
| 31 | + * @param array | string $value_to_normalize |
|
| 32 | + * @return array |
|
| 33 | + */ |
|
| 34 | + public function normalize($value_to_normalize) |
|
| 35 | + { |
|
| 36 | + if (is_array($value_to_normalize)) { |
|
| 37 | + $items_to_normalize = $value_to_normalize; |
|
| 38 | + } elseif ($value_to_normalize !== null) { |
|
| 39 | + $items_to_normalize = array($value_to_normalize); |
|
| 40 | + } else { |
|
| 41 | + $items_to_normalize = array(); |
|
| 42 | + } |
|
| 43 | + $normalized_array_value = array(); |
|
| 44 | + foreach ($items_to_normalize as $key => $individual_item) { |
|
| 45 | + $normalized_array_value[ $key ] = $this->normalize_one($individual_item); |
|
| 46 | + } |
|
| 47 | + return $normalized_array_value; |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * Normalized the one item (called for each array item in EE_Many_values_Normalization::normalize()) |
|
| 54 | + * |
|
| 55 | + * @param string $individual_value_to_normalize but definitely NOT an array |
|
| 56 | + * @return mixed |
|
| 57 | + */ |
|
| 58 | + public function normalize_one($individual_value_to_normalize) |
|
| 59 | + { |
|
| 60 | + return $this->_individual_item_normalization_strategy->normalize($individual_value_to_normalize); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * Converts the array of normalized things to an array of raw html values. |
|
| 67 | + * |
|
| 68 | + * @param array $normalized_values |
|
| 69 | + * @return string[] |
|
| 70 | + */ |
|
| 71 | + public function unnormalize($normalized_values) |
|
| 72 | + { |
|
| 73 | + if ($normalized_values === null) { |
|
| 74 | + $normalized_values = array(); |
|
| 75 | + } |
|
| 76 | + if (! is_array($normalized_values)) { |
|
| 77 | + $normalized_values = array($normalized_values); |
|
| 78 | + } |
|
| 79 | + $non_normal_values = array(); |
|
| 80 | + foreach ($normalized_values as $key => $value) { |
|
| 81 | + $non_normal_values[ $key ] = $this->unnormalize_one($value); |
|
| 82 | + } |
|
| 83 | + return $non_normal_values; |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * Unnormalizes an individual item in the array of values |
|
| 90 | + * |
|
| 91 | + * @param mixed $individual_value_to_unnormalize but certainly NOT an array |
|
| 92 | + * @return string |
|
| 93 | + */ |
|
| 94 | + public function unnormalize_one($individual_value_to_unnormalize) |
|
| 95 | + { |
|
| 96 | + return $this->_individual_item_normalization_strategy->unnormalize($individual_value_to_unnormalize); |
|
| 97 | + } |
|
| 98 | 98 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | // loop through incoming options |
| 53 | 53 | foreach ($template_options as $key => $value) { |
| 54 | 54 | // add underscore to $key to match property names |
| 55 | - $_key = '_' . $key; |
|
| 55 | + $_key = '_'.$key; |
|
| 56 | 56 | if (property_exists($this, $_key)) { |
| 57 | 57 | $this->{$_key} = $value; |
| 58 | 58 | } |
@@ -182,9 +182,9 @@ discard block |
||
| 182 | 182 | $subsection_name = self::prep_form_subsection_key_name($subsection_name); |
| 183 | 183 | if (strpos($subsection_name, '[') !== false) { |
| 184 | 184 | $sub_name = explode('[', $subsection_name); |
| 185 | - $this->_template_args[ $sub_name[0] ][ rtrim($sub_name[1], ']') ] = $this->layout_subsection($subsection); |
|
| 185 | + $this->_template_args[$sub_name[0]][rtrim($sub_name[1], ']')] = $this->layout_subsection($subsection); |
|
| 186 | 186 | } else { |
| 187 | - $this->_template_args[ $subsection_name ] = $this->layout_subsection($subsection); |
|
| 187 | + $this->_template_args[$subsection_name] = $this->layout_subsection($subsection); |
|
| 188 | 188 | } |
| 189 | 189 | } |
| 190 | 190 | // d( $this->_template_args ); |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | public static function prep_form_subsection_key_name($subsection_name = '') |
| 204 | 204 | { |
| 205 | 205 | $subsection_name = str_replace(array('-', ' '), array('', '_'), $subsection_name); |
| 206 | - return is_numeric(substr($subsection_name, 0, 1)) ? 'form_' . $subsection_name : $subsection_name; |
|
| 206 | + return is_numeric(substr($subsection_name, 0, 1)) ? 'form_'.$subsection_name : $subsection_name; |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | |
@@ -22,200 +22,200 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class EE_Template_Layout extends EE_Div_Per_Section_Layout |
| 24 | 24 | { |
| 25 | - protected $_layout_template_file = null; |
|
| 26 | - |
|
| 27 | - protected $_layout_begin_template_file = null; |
|
| 28 | - |
|
| 29 | - protected $_input_template_file = null; |
|
| 30 | - |
|
| 31 | - protected $_subsection_template_file = null; |
|
| 32 | - |
|
| 33 | - protected $_layout_end_template_file = null; |
|
| 34 | - |
|
| 35 | - protected $_template_args = array(); |
|
| 36 | - |
|
| 37 | - |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * @param array $template_options { |
|
| 41 | - * @type string $_layout_template_file |
|
| 42 | - * @type string $_begin_template_file |
|
| 43 | - * @type string $_input_template_file |
|
| 44 | - * @type string $_subsection_template_file |
|
| 45 | - * @type string $_end_template_file |
|
| 46 | - * @type array $_template_args |
|
| 47 | - * } |
|
| 48 | - */ |
|
| 49 | - public function __construct($template_options = array()) |
|
| 50 | - { |
|
| 51 | - // loop through incoming options |
|
| 52 | - foreach ($template_options as $key => $value) { |
|
| 53 | - // add underscore to $key to match property names |
|
| 54 | - $_key = '_' . $key; |
|
| 55 | - if (property_exists($this, $_key)) { |
|
| 56 | - $this->{$_key} = $value; |
|
| 57 | - } |
|
| 58 | - } |
|
| 59 | - parent::__construct(); |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * Also has the side effect of enqueuing any needed JS and CSS for |
|
| 66 | - * this form. |
|
| 67 | - * Creates all the HTML necessary for displaying this form, its inputs, and |
|
| 68 | - * proper subsections. |
|
| 69 | - * Returns the HTML |
|
| 70 | - * |
|
| 71 | - * @return string |
|
| 72 | - */ |
|
| 73 | - public function layout_form() |
|
| 74 | - { |
|
| 75 | - if ($this->_layout_template_file) { |
|
| 76 | - return EEH_Template::locate_template($this->_layout_template_file, $this->template_args(), true, true); |
|
| 77 | - } else { |
|
| 78 | - return parent::layout_form(); |
|
| 79 | - } |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * opening div tag for a form |
|
| 86 | - * |
|
| 87 | - * @return string |
|
| 88 | - */ |
|
| 89 | - public function layout_form_begin() |
|
| 90 | - { |
|
| 91 | - if ($this->_layout_begin_template_file) { |
|
| 92 | - return EEH_Template::locate_template( |
|
| 93 | - $this->_layout_begin_template_file, |
|
| 94 | - $this->template_args(), |
|
| 95 | - true, |
|
| 96 | - true |
|
| 97 | - ); |
|
| 98 | - } else { |
|
| 99 | - return parent::layout_form_begin(); |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * If an input_template_file was provided upon construction, uses that to layout the input. Otherwise uses parent. |
|
| 107 | - * |
|
| 108 | - * @see EE_DIv_Per_Section_Layout::layout_input() for documentation |
|
| 109 | - * @param EE_Form_Input_Base $input |
|
| 110 | - * @return string |
|
| 111 | - */ |
|
| 112 | - public function layout_input($input) |
|
| 113 | - { |
|
| 114 | - if ($this->_input_template_file) { |
|
| 115 | - return EEH_Template::locate_template($this->_input_template_file, array('input' => $input), true, true); |
|
| 116 | - } |
|
| 117 | - return parent::layout_input($input); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * If a subsection_template_file was provided upon construction, uses that to layout the subsection. Otherwise uses parent. |
|
| 124 | - * |
|
| 125 | - * @see EE_Div_Per_Section_Layout::layout_subsection() for documentation |
|
| 126 | - * @param EE_Form_Section_Proper $form_section |
|
| 127 | - * @return string |
|
| 128 | - */ |
|
| 129 | - public function layout_subsection($form_section) |
|
| 130 | - { |
|
| 131 | - if ($this->_subsection_template_file) { |
|
| 132 | - return EEH_Template::locate_template($this->_subsection_template_file, $this->template_args(), true, true); |
|
| 133 | - } |
|
| 134 | - return parent::layout_subsection($form_section); |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * closing div tag for a form |
|
| 141 | - * |
|
| 142 | - * @return string |
|
| 143 | - */ |
|
| 144 | - public function layout_form_end() |
|
| 145 | - { |
|
| 146 | - if ($this->_layout_end_template_file) { |
|
| 147 | - return EEH_Template::locate_template($this->_layout_end_template_file, $this->template_args(), true, true); |
|
| 148 | - } else { |
|
| 149 | - return parent::layout_form_end(); |
|
| 150 | - } |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * @param array $template_args |
|
| 157 | - */ |
|
| 158 | - public function set_template_args($template_args = array()) |
|
| 159 | - { |
|
| 160 | - $this->_template_args = $template_args; |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - |
|
| 164 | - |
|
| 165 | - /** |
|
| 166 | - * @param array $template_args |
|
| 167 | - */ |
|
| 168 | - public function add_template_args($template_args = array()) |
|
| 169 | - { |
|
| 170 | - $this->_template_args = array_merge_recursive($this->_template_args, $template_args); |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * @return array |
|
| 177 | - */ |
|
| 178 | - public function template_args() |
|
| 179 | - { |
|
| 180 | - foreach ($this->form_section()->subsections() as $subsection_name => $subsection) { |
|
| 181 | - $subsection_name = self::prep_form_subsection_key_name($subsection_name); |
|
| 182 | - if (strpos($subsection_name, '[') !== false) { |
|
| 183 | - $sub_name = explode('[', $subsection_name); |
|
| 184 | - $this->_template_args[ $sub_name[0] ][ rtrim($sub_name[1], ']') ] = $this->layout_subsection($subsection); |
|
| 185 | - } else { |
|
| 186 | - $this->_template_args[ $subsection_name ] = $this->layout_subsection($subsection); |
|
| 187 | - } |
|
| 188 | - } |
|
| 189 | - // d( $this->_template_args ); |
|
| 190 | - return $this->_template_args; |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * prep_form_section_key_name |
|
| 197 | - * |
|
| 198 | - * @access public |
|
| 199 | - * @param string $subsection_name |
|
| 200 | - * @return string |
|
| 201 | - */ |
|
| 202 | - public static function prep_form_subsection_key_name($subsection_name = '') |
|
| 203 | - { |
|
| 204 | - $subsection_name = str_replace(array('-', ' '), array('', '_'), $subsection_name); |
|
| 205 | - return is_numeric(substr($subsection_name, 0, 1)) ? 'form_' . $subsection_name : $subsection_name; |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - |
|
| 209 | - |
|
| 210 | - /** |
|
| 211 | - * get_subform - just a wrapper for the above method |
|
| 212 | - * |
|
| 213 | - * @access public |
|
| 214 | - * @param string $subsection_name |
|
| 215 | - * @return string |
|
| 216 | - */ |
|
| 217 | - public static function get_subform_name($subsection_name = '') |
|
| 218 | - { |
|
| 219 | - return EE_Template_Layout::prep_form_subsection_key_name($subsection_name); |
|
| 220 | - } |
|
| 25 | + protected $_layout_template_file = null; |
|
| 26 | + |
|
| 27 | + protected $_layout_begin_template_file = null; |
|
| 28 | + |
|
| 29 | + protected $_input_template_file = null; |
|
| 30 | + |
|
| 31 | + protected $_subsection_template_file = null; |
|
| 32 | + |
|
| 33 | + protected $_layout_end_template_file = null; |
|
| 34 | + |
|
| 35 | + protected $_template_args = array(); |
|
| 36 | + |
|
| 37 | + |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * @param array $template_options { |
|
| 41 | + * @type string $_layout_template_file |
|
| 42 | + * @type string $_begin_template_file |
|
| 43 | + * @type string $_input_template_file |
|
| 44 | + * @type string $_subsection_template_file |
|
| 45 | + * @type string $_end_template_file |
|
| 46 | + * @type array $_template_args |
|
| 47 | + * } |
|
| 48 | + */ |
|
| 49 | + public function __construct($template_options = array()) |
|
| 50 | + { |
|
| 51 | + // loop through incoming options |
|
| 52 | + foreach ($template_options as $key => $value) { |
|
| 53 | + // add underscore to $key to match property names |
|
| 54 | + $_key = '_' . $key; |
|
| 55 | + if (property_exists($this, $_key)) { |
|
| 56 | + $this->{$_key} = $value; |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | + parent::__construct(); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * Also has the side effect of enqueuing any needed JS and CSS for |
|
| 66 | + * this form. |
|
| 67 | + * Creates all the HTML necessary for displaying this form, its inputs, and |
|
| 68 | + * proper subsections. |
|
| 69 | + * Returns the HTML |
|
| 70 | + * |
|
| 71 | + * @return string |
|
| 72 | + */ |
|
| 73 | + public function layout_form() |
|
| 74 | + { |
|
| 75 | + if ($this->_layout_template_file) { |
|
| 76 | + return EEH_Template::locate_template($this->_layout_template_file, $this->template_args(), true, true); |
|
| 77 | + } else { |
|
| 78 | + return parent::layout_form(); |
|
| 79 | + } |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * opening div tag for a form |
|
| 86 | + * |
|
| 87 | + * @return string |
|
| 88 | + */ |
|
| 89 | + public function layout_form_begin() |
|
| 90 | + { |
|
| 91 | + if ($this->_layout_begin_template_file) { |
|
| 92 | + return EEH_Template::locate_template( |
|
| 93 | + $this->_layout_begin_template_file, |
|
| 94 | + $this->template_args(), |
|
| 95 | + true, |
|
| 96 | + true |
|
| 97 | + ); |
|
| 98 | + } else { |
|
| 99 | + return parent::layout_form_begin(); |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * If an input_template_file was provided upon construction, uses that to layout the input. Otherwise uses parent. |
|
| 107 | + * |
|
| 108 | + * @see EE_DIv_Per_Section_Layout::layout_input() for documentation |
|
| 109 | + * @param EE_Form_Input_Base $input |
|
| 110 | + * @return string |
|
| 111 | + */ |
|
| 112 | + public function layout_input($input) |
|
| 113 | + { |
|
| 114 | + if ($this->_input_template_file) { |
|
| 115 | + return EEH_Template::locate_template($this->_input_template_file, array('input' => $input), true, true); |
|
| 116 | + } |
|
| 117 | + return parent::layout_input($input); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * If a subsection_template_file was provided upon construction, uses that to layout the subsection. Otherwise uses parent. |
|
| 124 | + * |
|
| 125 | + * @see EE_Div_Per_Section_Layout::layout_subsection() for documentation |
|
| 126 | + * @param EE_Form_Section_Proper $form_section |
|
| 127 | + * @return string |
|
| 128 | + */ |
|
| 129 | + public function layout_subsection($form_section) |
|
| 130 | + { |
|
| 131 | + if ($this->_subsection_template_file) { |
|
| 132 | + return EEH_Template::locate_template($this->_subsection_template_file, $this->template_args(), true, true); |
|
| 133 | + } |
|
| 134 | + return parent::layout_subsection($form_section); |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * closing div tag for a form |
|
| 141 | + * |
|
| 142 | + * @return string |
|
| 143 | + */ |
|
| 144 | + public function layout_form_end() |
|
| 145 | + { |
|
| 146 | + if ($this->_layout_end_template_file) { |
|
| 147 | + return EEH_Template::locate_template($this->_layout_end_template_file, $this->template_args(), true, true); |
|
| 148 | + } else { |
|
| 149 | + return parent::layout_form_end(); |
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * @param array $template_args |
|
| 157 | + */ |
|
| 158 | + public function set_template_args($template_args = array()) |
|
| 159 | + { |
|
| 160 | + $this->_template_args = $template_args; |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + |
|
| 164 | + |
|
| 165 | + /** |
|
| 166 | + * @param array $template_args |
|
| 167 | + */ |
|
| 168 | + public function add_template_args($template_args = array()) |
|
| 169 | + { |
|
| 170 | + $this->_template_args = array_merge_recursive($this->_template_args, $template_args); |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * @return array |
|
| 177 | + */ |
|
| 178 | + public function template_args() |
|
| 179 | + { |
|
| 180 | + foreach ($this->form_section()->subsections() as $subsection_name => $subsection) { |
|
| 181 | + $subsection_name = self::prep_form_subsection_key_name($subsection_name); |
|
| 182 | + if (strpos($subsection_name, '[') !== false) { |
|
| 183 | + $sub_name = explode('[', $subsection_name); |
|
| 184 | + $this->_template_args[ $sub_name[0] ][ rtrim($sub_name[1], ']') ] = $this->layout_subsection($subsection); |
|
| 185 | + } else { |
|
| 186 | + $this->_template_args[ $subsection_name ] = $this->layout_subsection($subsection); |
|
| 187 | + } |
|
| 188 | + } |
|
| 189 | + // d( $this->_template_args ); |
|
| 190 | + return $this->_template_args; |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * prep_form_section_key_name |
|
| 197 | + * |
|
| 198 | + * @access public |
|
| 199 | + * @param string $subsection_name |
|
| 200 | + * @return string |
|
| 201 | + */ |
|
| 202 | + public static function prep_form_subsection_key_name($subsection_name = '') |
|
| 203 | + { |
|
| 204 | + $subsection_name = str_replace(array('-', ' '), array('', '_'), $subsection_name); |
|
| 205 | + return is_numeric(substr($subsection_name, 0, 1)) ? 'form_' . $subsection_name : $subsection_name; |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + |
|
| 209 | + |
|
| 210 | + /** |
|
| 211 | + * get_subform - just a wrapper for the above method |
|
| 212 | + * |
|
| 213 | + * @access public |
|
| 214 | + * @param string $subsection_name |
|
| 215 | + * @return string |
|
| 216 | + */ |
|
| 217 | + public static function get_subform_name($subsection_name = '') |
|
| 218 | + { |
|
| 219 | + return EE_Template_Layout::prep_form_subsection_key_name($subsection_name); |
|
| 220 | + } |
|
| 221 | 221 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | public function __construct($options = array()) |
| 37 | 37 | { |
| 38 | 38 | foreach ($options as $key => $value) { |
| 39 | - $key = '_' . $key; |
|
| 39 | + $key = '_'.$key; |
|
| 40 | 40 | if (property_exists($this, $key)) { |
| 41 | 41 | $this->{$key} = $value; |
| 42 | 42 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | . '" style="' |
| 61 | 61 | . $this->_form_section->html_style() |
| 62 | 62 | . '">'; |
| 63 | - $html .= '<legend class="' . $this->legend_class() . '">' . $this->legend_text() . '</legend>'; |
|
| 63 | + $html .= '<legend class="'.$this->legend_class().'">'.$this->legend_text().'</legend>'; |
|
| 64 | 64 | return $html; |
| 65 | 65 | } |
| 66 | 66 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public function layout_form_end() |
| 75 | 75 | { |
| 76 | - return EEH_HTML::nl(-1) . '</fieldset>'; |
|
| 76 | + return EEH_HTML::nl(-1).'</fieldset>'; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | |
@@ -11,107 +11,107 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class EE_Fieldset_Section_Layout extends EE_Div_Per_Section_Layout |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * legend_class |
|
| 16 | - * |
|
| 17 | - * @var string |
|
| 18 | - */ |
|
| 19 | - protected $_legend_class; |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * legend_text |
|
| 23 | - * |
|
| 24 | - * @var string |
|
| 25 | - */ |
|
| 26 | - protected $_legend_text; |
|
| 27 | - |
|
| 28 | - |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * construct |
|
| 32 | - * |
|
| 33 | - * @param array $options |
|
| 34 | - */ |
|
| 35 | - public function __construct($options = array()) |
|
| 36 | - { |
|
| 37 | - foreach ($options as $key => $value) { |
|
| 38 | - $key = '_' . $key; |
|
| 39 | - if (property_exists($this, $key)) { |
|
| 40 | - $this->{$key} = $value; |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * opening div tag for a form |
|
| 49 | - * |
|
| 50 | - * @return string |
|
| 51 | - */ |
|
| 52 | - public function layout_form_begin() |
|
| 53 | - { |
|
| 54 | - $html = EEH_HTML::nl(1) |
|
| 55 | - . '<fieldset id="' |
|
| 56 | - . $this->_form_section->html_id() |
|
| 57 | - . '" class="' |
|
| 58 | - . $this->_form_section->html_class() |
|
| 59 | - . '" style="' |
|
| 60 | - . $this->_form_section->html_style() |
|
| 61 | - . '">'; |
|
| 62 | - $html .= '<legend class="' . $this->legend_class() . '">' . $this->legend_text() . '</legend>'; |
|
| 63 | - return $html; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * closing div tag for a form |
|
| 70 | - * |
|
| 71 | - * @return string |
|
| 72 | - */ |
|
| 73 | - public function layout_form_end() |
|
| 74 | - { |
|
| 75 | - return EEH_HTML::nl(-1) . '</fieldset>'; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * @param string $legend_class |
|
| 82 | - */ |
|
| 83 | - public function set_legend_class($legend_class) |
|
| 84 | - { |
|
| 85 | - $this->_legend_class = $legend_class; |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * @return string |
|
| 92 | - */ |
|
| 93 | - public function legend_class() |
|
| 94 | - { |
|
| 95 | - return $this->_legend_class; |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * @param string $legend_text |
|
| 102 | - */ |
|
| 103 | - public function set_legend_text($legend_text) |
|
| 104 | - { |
|
| 105 | - $this->_legend_text = $legend_text; |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * @return string |
|
| 112 | - */ |
|
| 113 | - public function legend_text() |
|
| 114 | - { |
|
| 115 | - return $this->_legend_text; |
|
| 116 | - } |
|
| 14 | + /** |
|
| 15 | + * legend_class |
|
| 16 | + * |
|
| 17 | + * @var string |
|
| 18 | + */ |
|
| 19 | + protected $_legend_class; |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * legend_text |
|
| 23 | + * |
|
| 24 | + * @var string |
|
| 25 | + */ |
|
| 26 | + protected $_legend_text; |
|
| 27 | + |
|
| 28 | + |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * construct |
|
| 32 | + * |
|
| 33 | + * @param array $options |
|
| 34 | + */ |
|
| 35 | + public function __construct($options = array()) |
|
| 36 | + { |
|
| 37 | + foreach ($options as $key => $value) { |
|
| 38 | + $key = '_' . $key; |
|
| 39 | + if (property_exists($this, $key)) { |
|
| 40 | + $this->{$key} = $value; |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * opening div tag for a form |
|
| 49 | + * |
|
| 50 | + * @return string |
|
| 51 | + */ |
|
| 52 | + public function layout_form_begin() |
|
| 53 | + { |
|
| 54 | + $html = EEH_HTML::nl(1) |
|
| 55 | + . '<fieldset id="' |
|
| 56 | + . $this->_form_section->html_id() |
|
| 57 | + . '" class="' |
|
| 58 | + . $this->_form_section->html_class() |
|
| 59 | + . '" style="' |
|
| 60 | + . $this->_form_section->html_style() |
|
| 61 | + . '">'; |
|
| 62 | + $html .= '<legend class="' . $this->legend_class() . '">' . $this->legend_text() . '</legend>'; |
|
| 63 | + return $html; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * closing div tag for a form |
|
| 70 | + * |
|
| 71 | + * @return string |
|
| 72 | + */ |
|
| 73 | + public function layout_form_end() |
|
| 74 | + { |
|
| 75 | + return EEH_HTML::nl(-1) . '</fieldset>'; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * @param string $legend_class |
|
| 82 | + */ |
|
| 83 | + public function set_legend_class($legend_class) |
|
| 84 | + { |
|
| 85 | + $this->_legend_class = $legend_class; |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * @return string |
|
| 92 | + */ |
|
| 93 | + public function legend_class() |
|
| 94 | + { |
|
| 95 | + return $this->_legend_class; |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * @param string $legend_text |
|
| 102 | + */ |
|
| 103 | + public function set_legend_text($legend_text) |
|
| 104 | + { |
|
| 105 | + $this->_legend_text = $legend_text; |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * @return string |
|
| 112 | + */ |
|
| 113 | + public function legend_text() |
|
| 114 | + { |
|
| 115 | + return $this->_legend_text; |
|
| 116 | + } |
|
| 117 | 117 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | public function layout_form_begin($additional_args = array()) |
| 17 | 17 | { |
| 18 | - $this->_form_section->set_html_class($this->_form_section->html_class() . ' form-table'); |
|
| 18 | + $this->_form_section->set_html_class($this->_form_section->html_class().' form-table'); |
|
| 19 | 19 | return parent::layout_form_begin($additional_args); |
| 20 | 20 | } |
| 21 | 21 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | || $input->get_display_strategy() instanceof EE_Text_Input_Display_Strategy |
| 53 | 53 | || $input->get_display_strategy() instanceof EE_Admin_File_Uploader_Display_Strategy |
| 54 | 54 | ) { |
| 55 | - $input->set_html_class($input->html_class() . ' large-text'); |
|
| 55 | + $input->set_html_class($input->html_class().' large-text'); |
|
| 56 | 56 | } |
| 57 | 57 | if ($input instanceof EE_Text_Area_Input) { |
| 58 | 58 | $input->set_rows(4); |
@@ -61,10 +61,10 @@ discard block |
||
| 61 | 61 | $input_html = $input->get_html_for_input(); |
| 62 | 62 | // maybe add errors and help text ? |
| 63 | 63 | $input_html .= $input->get_html_for_errors() !== '' |
| 64 | - ? EEH_HTML::nl() . $input->get_html_for_errors() |
|
| 64 | + ? EEH_HTML::nl().$input->get_html_for_errors() |
|
| 65 | 65 | : ''; |
| 66 | 66 | $input_html .= $input->get_html_for_help() !== '' |
| 67 | - ? EEH_HTML::nl() . $input->get_html_for_help() |
|
| 67 | + ? EEH_HTML::nl().$input->get_html_for_help() |
|
| 68 | 68 | : ''; |
| 69 | 69 | // overriding parent to add wp admin specific things. |
| 70 | 70 | $html = ''; |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | '', |
| 79 | 79 | '', |
| 80 | 80 | 'scope="row"' |
| 81 | - ) . EEH_HTML::td($input_html) |
|
| 81 | + ).EEH_HTML::td($input_html) |
|
| 82 | 82 | ); |
| 83 | 83 | } |
| 84 | 84 | return $html; |
@@ -6,63 +6,63 @@ |
||
| 6 | 6 | */ |
| 7 | 7 | class EE_Admin_Two_Column_Layout extends EE_Two_Column_Layout |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Overriding the parent table layout to include <tbody> tags |
|
| 11 | - * |
|
| 12 | - * @param array $additional_args |
|
| 13 | - * @return string |
|
| 14 | - */ |
|
| 15 | - public function layout_form_begin($additional_args = array()) |
|
| 16 | - { |
|
| 17 | - $this->_form_section->set_html_class($this->_form_section->html_class() . ' form-table'); |
|
| 18 | - return parent::layout_form_begin($additional_args); |
|
| 19 | - } |
|
| 9 | + /** |
|
| 10 | + * Overriding the parent table layout to include <tbody> tags |
|
| 11 | + * |
|
| 12 | + * @param array $additional_args |
|
| 13 | + * @return string |
|
| 14 | + */ |
|
| 15 | + public function layout_form_begin($additional_args = array()) |
|
| 16 | + { |
|
| 17 | + $this->_form_section->set_html_class($this->_form_section->html_class() . ' form-table'); |
|
| 18 | + return parent::layout_form_begin($additional_args); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | 21 | |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Lays out the row for the input, including label and errors |
|
| 25 | - * |
|
| 26 | - * @param EE_Form_Input_Base $input |
|
| 27 | - * @return string |
|
| 28 | - * @throws EE_Error |
|
| 29 | - */ |
|
| 30 | - public function layout_input($input) |
|
| 31 | - { |
|
| 32 | - if ( |
|
| 33 | - $input->get_display_strategy() instanceof EE_Text_Area_Display_Strategy |
|
| 34 | - || $input->get_display_strategy() instanceof EE_Text_Input_Display_Strategy |
|
| 35 | - || $input->get_display_strategy() instanceof EE_Admin_File_Uploader_Display_Strategy |
|
| 36 | - ) { |
|
| 37 | - $input->set_html_class($input->html_class() . ' large-text'); |
|
| 38 | - } |
|
| 39 | - if ($input instanceof EE_Text_Area_Input) { |
|
| 40 | - $input->set_rows(4); |
|
| 41 | - $input->set_cols(60); |
|
| 42 | - } |
|
| 43 | - $input_html = $input->get_html_for_input(); |
|
| 44 | - // maybe add errors and help text ? |
|
| 45 | - $input_html .= $input->get_html_for_errors() !== '' |
|
| 46 | - ? EEH_HTML::nl() . $input->get_html_for_errors() |
|
| 47 | - : ''; |
|
| 48 | - $input_html .= $input->get_html_for_help() !== '' |
|
| 49 | - ? EEH_HTML::nl() . $input->get_html_for_help() |
|
| 50 | - : ''; |
|
| 51 | - // overriding parent to add wp admin specific things. |
|
| 52 | - $html = ''; |
|
| 53 | - if ($input instanceof EE_Hidden_Input) { |
|
| 54 | - $html .= EEH_HTML::no_row($input->get_html_for_input()); |
|
| 55 | - } else { |
|
| 56 | - $html .= EEH_HTML::tr( |
|
| 57 | - EEH_HTML::th( |
|
| 58 | - $input->get_html_for_label(), |
|
| 59 | - '', |
|
| 60 | - '', |
|
| 61 | - '', |
|
| 62 | - 'scope="row"' |
|
| 63 | - ) . EEH_HTML::td($input_html) |
|
| 64 | - ); |
|
| 65 | - } |
|
| 66 | - return $html; |
|
| 67 | - } |
|
| 23 | + /** |
|
| 24 | + * Lays out the row for the input, including label and errors |
|
| 25 | + * |
|
| 26 | + * @param EE_Form_Input_Base $input |
|
| 27 | + * @return string |
|
| 28 | + * @throws EE_Error |
|
| 29 | + */ |
|
| 30 | + public function layout_input($input) |
|
| 31 | + { |
|
| 32 | + if ( |
|
| 33 | + $input->get_display_strategy() instanceof EE_Text_Area_Display_Strategy |
|
| 34 | + || $input->get_display_strategy() instanceof EE_Text_Input_Display_Strategy |
|
| 35 | + || $input->get_display_strategy() instanceof EE_Admin_File_Uploader_Display_Strategy |
|
| 36 | + ) { |
|
| 37 | + $input->set_html_class($input->html_class() . ' large-text'); |
|
| 38 | + } |
|
| 39 | + if ($input instanceof EE_Text_Area_Input) { |
|
| 40 | + $input->set_rows(4); |
|
| 41 | + $input->set_cols(60); |
|
| 42 | + } |
|
| 43 | + $input_html = $input->get_html_for_input(); |
|
| 44 | + // maybe add errors and help text ? |
|
| 45 | + $input_html .= $input->get_html_for_errors() !== '' |
|
| 46 | + ? EEH_HTML::nl() . $input->get_html_for_errors() |
|
| 47 | + : ''; |
|
| 48 | + $input_html .= $input->get_html_for_help() !== '' |
|
| 49 | + ? EEH_HTML::nl() . $input->get_html_for_help() |
|
| 50 | + : ''; |
|
| 51 | + // overriding parent to add wp admin specific things. |
|
| 52 | + $html = ''; |
|
| 53 | + if ($input instanceof EE_Hidden_Input) { |
|
| 54 | + $html .= EEH_HTML::no_row($input->get_html_for_input()); |
|
| 55 | + } else { |
|
| 56 | + $html .= EEH_HTML::tr( |
|
| 57 | + EEH_HTML::th( |
|
| 58 | + $input->get_html_for_label(), |
|
| 59 | + '', |
|
| 60 | + '', |
|
| 61 | + '', |
|
| 62 | + 'scope="row"' |
|
| 63 | + ) . EEH_HTML::td($input_html) |
|
| 64 | + ); |
|
| 65 | + } |
|
| 66 | + return $html; |
|
| 67 | + } |
|
| 68 | 68 | } |