@@ -9,14 +9,14 @@ |
||
9 | 9 | class EE_Credit_Card_Normalization extends EE_Text_Normalization |
10 | 10 | { |
11 | 11 | |
12 | - /** |
|
13 | - * @param string $value_to_normalize |
|
14 | - * @return mixed |
|
15 | - */ |
|
16 | - public function normalize($value_to_normalize) |
|
17 | - { |
|
18 | - $normalized_by_parent = parent::normalize($value_to_normalize); |
|
19 | - // we want to make it consistent, so remove whitespace from cc number |
|
20 | - return preg_replace('/\s+/', '', $normalized_by_parent); |
|
21 | - } |
|
12 | + /** |
|
13 | + * @param string $value_to_normalize |
|
14 | + * @return mixed |
|
15 | + */ |
|
16 | + public function normalize($value_to_normalize) |
|
17 | + { |
|
18 | + $normalized_by_parent = parent::normalize($value_to_normalize); |
|
19 | + // we want to make it consistent, so remove whitespace from cc number |
|
20 | + return preg_replace('/\s+/', '', $normalized_by_parent); |
|
21 | + } |
|
22 | 22 | } |
@@ -10,38 +10,38 @@ |
||
10 | 10 | class EE_Text_Normalization extends EE_Normalization_Strategy_Base |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * @param string $value_to_normalize |
|
15 | - * @return array|mixed|string |
|
16 | - */ |
|
17 | - public function normalize($value_to_normalize) |
|
18 | - { |
|
19 | - if (is_array($value_to_normalize)) { |
|
20 | - return (string) array_shift($value_to_normalize); |
|
21 | - } |
|
22 | - // consider `"null"` values to be equivalent to null. |
|
23 | - if ($value_to_normalize === '' || $value_to_normalize === null) { |
|
24 | - return null; |
|
25 | - } |
|
26 | - return (string) $value_to_normalize; |
|
27 | - } |
|
13 | + /** |
|
14 | + * @param string $value_to_normalize |
|
15 | + * @return array|mixed|string |
|
16 | + */ |
|
17 | + public function normalize($value_to_normalize) |
|
18 | + { |
|
19 | + if (is_array($value_to_normalize)) { |
|
20 | + return (string) array_shift($value_to_normalize); |
|
21 | + } |
|
22 | + // consider `"null"` values to be equivalent to null. |
|
23 | + if ($value_to_normalize === '' || $value_to_normalize === null) { |
|
24 | + return null; |
|
25 | + } |
|
26 | + return (string) $value_to_normalize; |
|
27 | + } |
|
28 | 28 | |
29 | 29 | |
30 | 30 | |
31 | - /** |
|
32 | - * IF its a string in PHP, it will be a string in the HTML form. easy |
|
33 | - * |
|
34 | - * @param string $normalized_value |
|
35 | - * @return string |
|
36 | - */ |
|
37 | - public function unnormalize($normalized_value) |
|
38 | - { |
|
39 | - // account for default "select here" option values |
|
40 | - if ($normalized_value === null) { |
|
41 | - return ''; |
|
42 | - } |
|
43 | - // double-check it's a string. It's possible this value was a question option that happened to be a numeric |
|
44 | - // string, in which case PHP has automatically converted it to an integer! |
|
45 | - return (string) $normalized_value; |
|
46 | - } |
|
31 | + /** |
|
32 | + * IF its a string in PHP, it will be a string in the HTML form. easy |
|
33 | + * |
|
34 | + * @param string $normalized_value |
|
35 | + * @return string |
|
36 | + */ |
|
37 | + public function unnormalize($normalized_value) |
|
38 | + { |
|
39 | + // account for default "select here" option values |
|
40 | + if ($normalized_value === null) { |
|
41 | + return ''; |
|
42 | + } |
|
43 | + // double-check it's a string. It's possible this value was a question option that happened to be a numeric |
|
44 | + // string, in which case PHP has automatically converted it to an integer! |
|
45 | + return (string) $normalized_value; |
|
46 | + } |
|
47 | 47 | } |
@@ -23,200 +23,200 @@ |
||
23 | 23 | class EE_Template_Layout extends EE_Div_Per_Section_Layout |
24 | 24 | { |
25 | 25 | |
26 | - protected $_layout_template_file = null; |
|
27 | - |
|
28 | - protected $_layout_begin_template_file = null; |
|
29 | - |
|
30 | - protected $_input_template_file = null; |
|
31 | - |
|
32 | - protected $_subsection_template_file = null; |
|
33 | - |
|
34 | - protected $_layout_end_template_file = null; |
|
35 | - |
|
36 | - protected $_template_args = array(); |
|
37 | - |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * @param array $template_options { |
|
42 | - * @type string $_layout_template_file |
|
43 | - * @type string $_begin_template_file |
|
44 | - * @type string $_input_template_file |
|
45 | - * @type string $_subsection_template_file |
|
46 | - * @type string $_end_template_file |
|
47 | - * @type array $_template_args |
|
48 | - * } |
|
49 | - */ |
|
50 | - public function __construct($template_options = array()) |
|
51 | - { |
|
52 | - // loop through incoming options |
|
53 | - foreach ($template_options as $key => $value) { |
|
54 | - // add underscore to $key to match property names |
|
55 | - $_key = '_' . $key; |
|
56 | - if (property_exists($this, $_key)) { |
|
57 | - $this->{$_key} = $value; |
|
58 | - } |
|
59 | - } |
|
60 | - parent::__construct(); |
|
61 | - } |
|
62 | - |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * Also has the side effect of enqueuing any needed JS and CSS for |
|
67 | - * this form. |
|
68 | - * Creates all the HTML necessary for displaying this form, its inputs, and |
|
69 | - * proper subsections. |
|
70 | - * Returns the HTML |
|
71 | - * |
|
72 | - * @return string |
|
73 | - */ |
|
74 | - public function layout_form() |
|
75 | - { |
|
76 | - if ($this->_layout_template_file) { |
|
77 | - return EEH_Template::locate_template($this->_layout_template_file, $this->template_args(), true, true); |
|
78 | - } else { |
|
79 | - return parent::layout_form(); |
|
80 | - } |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - |
|
85 | - /** |
|
86 | - * opening div tag for a form |
|
87 | - * |
|
88 | - * @return string |
|
89 | - */ |
|
90 | - public function layout_form_begin() |
|
91 | - { |
|
92 | - if ($this->_layout_begin_template_file) { |
|
93 | - return EEH_Template::locate_template( |
|
94 | - $this->_layout_begin_template_file, |
|
95 | - $this->template_args(), |
|
96 | - true, |
|
97 | - true |
|
98 | - ); |
|
99 | - } else { |
|
100 | - return parent::layout_form_begin(); |
|
101 | - } |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - |
|
106 | - /** |
|
107 | - * If an input_template_file was provided upon construction, uses that to layout the input. Otherwise uses parent. |
|
108 | - * |
|
109 | - * @see EE_DIv_Per_Section_Layout::layout_input() for documentation |
|
110 | - * @param EE_Form_Input_Base $input |
|
111 | - * @return string |
|
112 | - */ |
|
113 | - public function layout_input($input) |
|
114 | - { |
|
115 | - if ($this->_input_template_file) { |
|
116 | - return EEH_Template::locate_template($this->_input_template_file, array('input' => $input), true, true); |
|
117 | - } |
|
118 | - return parent::layout_input($input); |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - |
|
123 | - /** |
|
124 | - * If a subsection_template_file was provided upon construction, uses that to layout the subsection. Otherwise uses parent. |
|
125 | - * |
|
126 | - * @see EE_Div_Per_Section_Layout::layout_subsection() for documentation |
|
127 | - * @param EE_Form_Section_Proper $form_section |
|
128 | - * @return string |
|
129 | - */ |
|
130 | - public function layout_subsection($form_section) |
|
131 | - { |
|
132 | - if ($this->_subsection_template_file) { |
|
133 | - return EEH_Template::locate_template($this->_subsection_template_file, $this->template_args(), true, true); |
|
134 | - } |
|
135 | - return parent::layout_subsection($form_section); |
|
136 | - } |
|
137 | - |
|
138 | - |
|
139 | - |
|
140 | - /** |
|
141 | - * closing div tag for a form |
|
142 | - * |
|
143 | - * @return string |
|
144 | - */ |
|
145 | - public function layout_form_end() |
|
146 | - { |
|
147 | - if ($this->_layout_end_template_file) { |
|
148 | - return EEH_Template::locate_template($this->_layout_end_template_file, $this->template_args(), true, true); |
|
149 | - } else { |
|
150 | - return parent::layout_form_end(); |
|
151 | - } |
|
152 | - } |
|
153 | - |
|
154 | - |
|
155 | - |
|
156 | - /** |
|
157 | - * @param array $template_args |
|
158 | - */ |
|
159 | - public function set_template_args($template_args = array()) |
|
160 | - { |
|
161 | - $this->_template_args = $template_args; |
|
162 | - } |
|
163 | - |
|
164 | - |
|
165 | - |
|
166 | - /** |
|
167 | - * @param array $template_args |
|
168 | - */ |
|
169 | - public function add_template_args($template_args = array()) |
|
170 | - { |
|
171 | - $this->_template_args = array_merge_recursive($this->_template_args, $template_args); |
|
172 | - } |
|
173 | - |
|
174 | - |
|
175 | - |
|
176 | - /** |
|
177 | - * @return array |
|
178 | - */ |
|
179 | - public function template_args() |
|
180 | - { |
|
181 | - foreach ($this->form_section()->subsections() as $subsection_name => $subsection) { |
|
182 | - $subsection_name = self::prep_form_subsection_key_name($subsection_name); |
|
183 | - if (strpos($subsection_name, '[') !== false) { |
|
184 | - $sub_name = explode('[', $subsection_name); |
|
185 | - $this->_template_args[ $sub_name[0] ][ rtrim($sub_name[1], ']') ] = $this->layout_subsection($subsection); |
|
186 | - } else { |
|
187 | - $this->_template_args[ $subsection_name ] = $this->layout_subsection($subsection); |
|
188 | - } |
|
189 | - } |
|
190 | - // d( $this->_template_args ); |
|
191 | - return $this->_template_args; |
|
192 | - } |
|
193 | - |
|
194 | - |
|
195 | - |
|
196 | - /** |
|
197 | - * prep_form_section_key_name |
|
198 | - * |
|
199 | - * @access public |
|
200 | - * @param string $subsection_name |
|
201 | - * @return string |
|
202 | - */ |
|
203 | - public static function prep_form_subsection_key_name($subsection_name = '') |
|
204 | - { |
|
205 | - $subsection_name = str_replace(array('-', ' '), array('', '_'), $subsection_name); |
|
206 | - return is_numeric(substr($subsection_name, 0, 1)) ? 'form_' . $subsection_name : $subsection_name; |
|
207 | - } |
|
208 | - |
|
209 | - |
|
210 | - |
|
211 | - /** |
|
212 | - * get_subform - just a wrapper for the above method |
|
213 | - * |
|
214 | - * @access public |
|
215 | - * @param string $subsection_name |
|
216 | - * @return string |
|
217 | - */ |
|
218 | - public static function get_subform_name($subsection_name = '') |
|
219 | - { |
|
220 | - return EE_Template_Layout::prep_form_subsection_key_name($subsection_name); |
|
221 | - } |
|
26 | + protected $_layout_template_file = null; |
|
27 | + |
|
28 | + protected $_layout_begin_template_file = null; |
|
29 | + |
|
30 | + protected $_input_template_file = null; |
|
31 | + |
|
32 | + protected $_subsection_template_file = null; |
|
33 | + |
|
34 | + protected $_layout_end_template_file = null; |
|
35 | + |
|
36 | + protected $_template_args = array(); |
|
37 | + |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * @param array $template_options { |
|
42 | + * @type string $_layout_template_file |
|
43 | + * @type string $_begin_template_file |
|
44 | + * @type string $_input_template_file |
|
45 | + * @type string $_subsection_template_file |
|
46 | + * @type string $_end_template_file |
|
47 | + * @type array $_template_args |
|
48 | + * } |
|
49 | + */ |
|
50 | + public function __construct($template_options = array()) |
|
51 | + { |
|
52 | + // loop through incoming options |
|
53 | + foreach ($template_options as $key => $value) { |
|
54 | + // add underscore to $key to match property names |
|
55 | + $_key = '_' . $key; |
|
56 | + if (property_exists($this, $_key)) { |
|
57 | + $this->{$_key} = $value; |
|
58 | + } |
|
59 | + } |
|
60 | + parent::__construct(); |
|
61 | + } |
|
62 | + |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * Also has the side effect of enqueuing any needed JS and CSS for |
|
67 | + * this form. |
|
68 | + * Creates all the HTML necessary for displaying this form, its inputs, and |
|
69 | + * proper subsections. |
|
70 | + * Returns the HTML |
|
71 | + * |
|
72 | + * @return string |
|
73 | + */ |
|
74 | + public function layout_form() |
|
75 | + { |
|
76 | + if ($this->_layout_template_file) { |
|
77 | + return EEH_Template::locate_template($this->_layout_template_file, $this->template_args(), true, true); |
|
78 | + } else { |
|
79 | + return parent::layout_form(); |
|
80 | + } |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + |
|
85 | + /** |
|
86 | + * opening div tag for a form |
|
87 | + * |
|
88 | + * @return string |
|
89 | + */ |
|
90 | + public function layout_form_begin() |
|
91 | + { |
|
92 | + if ($this->_layout_begin_template_file) { |
|
93 | + return EEH_Template::locate_template( |
|
94 | + $this->_layout_begin_template_file, |
|
95 | + $this->template_args(), |
|
96 | + true, |
|
97 | + true |
|
98 | + ); |
|
99 | + } else { |
|
100 | + return parent::layout_form_begin(); |
|
101 | + } |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + |
|
106 | + /** |
|
107 | + * If an input_template_file was provided upon construction, uses that to layout the input. Otherwise uses parent. |
|
108 | + * |
|
109 | + * @see EE_DIv_Per_Section_Layout::layout_input() for documentation |
|
110 | + * @param EE_Form_Input_Base $input |
|
111 | + * @return string |
|
112 | + */ |
|
113 | + public function layout_input($input) |
|
114 | + { |
|
115 | + if ($this->_input_template_file) { |
|
116 | + return EEH_Template::locate_template($this->_input_template_file, array('input' => $input), true, true); |
|
117 | + } |
|
118 | + return parent::layout_input($input); |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + |
|
123 | + /** |
|
124 | + * If a subsection_template_file was provided upon construction, uses that to layout the subsection. Otherwise uses parent. |
|
125 | + * |
|
126 | + * @see EE_Div_Per_Section_Layout::layout_subsection() for documentation |
|
127 | + * @param EE_Form_Section_Proper $form_section |
|
128 | + * @return string |
|
129 | + */ |
|
130 | + public function layout_subsection($form_section) |
|
131 | + { |
|
132 | + if ($this->_subsection_template_file) { |
|
133 | + return EEH_Template::locate_template($this->_subsection_template_file, $this->template_args(), true, true); |
|
134 | + } |
|
135 | + return parent::layout_subsection($form_section); |
|
136 | + } |
|
137 | + |
|
138 | + |
|
139 | + |
|
140 | + /** |
|
141 | + * closing div tag for a form |
|
142 | + * |
|
143 | + * @return string |
|
144 | + */ |
|
145 | + public function layout_form_end() |
|
146 | + { |
|
147 | + if ($this->_layout_end_template_file) { |
|
148 | + return EEH_Template::locate_template($this->_layout_end_template_file, $this->template_args(), true, true); |
|
149 | + } else { |
|
150 | + return parent::layout_form_end(); |
|
151 | + } |
|
152 | + } |
|
153 | + |
|
154 | + |
|
155 | + |
|
156 | + /** |
|
157 | + * @param array $template_args |
|
158 | + */ |
|
159 | + public function set_template_args($template_args = array()) |
|
160 | + { |
|
161 | + $this->_template_args = $template_args; |
|
162 | + } |
|
163 | + |
|
164 | + |
|
165 | + |
|
166 | + /** |
|
167 | + * @param array $template_args |
|
168 | + */ |
|
169 | + public function add_template_args($template_args = array()) |
|
170 | + { |
|
171 | + $this->_template_args = array_merge_recursive($this->_template_args, $template_args); |
|
172 | + } |
|
173 | + |
|
174 | + |
|
175 | + |
|
176 | + /** |
|
177 | + * @return array |
|
178 | + */ |
|
179 | + public function template_args() |
|
180 | + { |
|
181 | + foreach ($this->form_section()->subsections() as $subsection_name => $subsection) { |
|
182 | + $subsection_name = self::prep_form_subsection_key_name($subsection_name); |
|
183 | + if (strpos($subsection_name, '[') !== false) { |
|
184 | + $sub_name = explode('[', $subsection_name); |
|
185 | + $this->_template_args[ $sub_name[0] ][ rtrim($sub_name[1], ']') ] = $this->layout_subsection($subsection); |
|
186 | + } else { |
|
187 | + $this->_template_args[ $subsection_name ] = $this->layout_subsection($subsection); |
|
188 | + } |
|
189 | + } |
|
190 | + // d( $this->_template_args ); |
|
191 | + return $this->_template_args; |
|
192 | + } |
|
193 | + |
|
194 | + |
|
195 | + |
|
196 | + /** |
|
197 | + * prep_form_section_key_name |
|
198 | + * |
|
199 | + * @access public |
|
200 | + * @param string $subsection_name |
|
201 | + * @return string |
|
202 | + */ |
|
203 | + public static function prep_form_subsection_key_name($subsection_name = '') |
|
204 | + { |
|
205 | + $subsection_name = str_replace(array('-', ' '), array('', '_'), $subsection_name); |
|
206 | + return is_numeric(substr($subsection_name, 0, 1)) ? 'form_' . $subsection_name : $subsection_name; |
|
207 | + } |
|
208 | + |
|
209 | + |
|
210 | + |
|
211 | + /** |
|
212 | + * get_subform - just a wrapper for the above method |
|
213 | + * |
|
214 | + * @access public |
|
215 | + * @param string $subsection_name |
|
216 | + * @return string |
|
217 | + */ |
|
218 | + public static function get_subform_name($subsection_name = '') |
|
219 | + { |
|
220 | + return EE_Template_Layout::prep_form_subsection_key_name($subsection_name); |
|
221 | + } |
|
222 | 222 | } |
@@ -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 |
@@ -12,107 +12,107 @@ |
||
12 | 12 | class EE_Fieldset_Section_Layout extends EE_Div_Per_Section_Layout |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * legend_class |
|
17 | - * |
|
18 | - * @var string |
|
19 | - */ |
|
20 | - protected $_legend_class; |
|
21 | - |
|
22 | - /** |
|
23 | - * legend_text |
|
24 | - * |
|
25 | - * @var string |
|
26 | - */ |
|
27 | - protected $_legend_text; |
|
28 | - |
|
29 | - |
|
30 | - |
|
31 | - /** |
|
32 | - * construct |
|
33 | - * |
|
34 | - * @param array $options |
|
35 | - */ |
|
36 | - public function __construct($options = array()) |
|
37 | - { |
|
38 | - foreach ($options as $key => $value) { |
|
39 | - $key = '_' . $key; |
|
40 | - if (property_exists($this, $key)) { |
|
41 | - $this->{$key} = $value; |
|
42 | - } |
|
43 | - } |
|
44 | - } |
|
45 | - |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * opening div tag for a form |
|
50 | - * |
|
51 | - * @return string |
|
52 | - */ |
|
53 | - public function layout_form_begin() |
|
54 | - { |
|
55 | - $html = EEH_HTML::nl(1) |
|
56 | - . '<fieldset id="' |
|
57 | - . $this->_form_section->html_id() |
|
58 | - . '" class="' |
|
59 | - . $this->_form_section->html_class() |
|
60 | - . '" style="' |
|
61 | - . $this->_form_section->html_style() |
|
62 | - . '">'; |
|
63 | - $html .= '<legend class="' . $this->legend_class() . '">' . $this->legend_text() . '</legend>'; |
|
64 | - return $html; |
|
65 | - } |
|
66 | - |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * closing div tag for a form |
|
71 | - * |
|
72 | - * @return string |
|
73 | - */ |
|
74 | - public function layout_form_end() |
|
75 | - { |
|
76 | - return EEH_HTML::nl(-1) . '</fieldset>'; |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * @param string $legend_class |
|
83 | - */ |
|
84 | - public function set_legend_class($legend_class) |
|
85 | - { |
|
86 | - $this->_legend_class = $legend_class; |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * @return string |
|
93 | - */ |
|
94 | - public function legend_class() |
|
95 | - { |
|
96 | - return $this->_legend_class; |
|
97 | - } |
|
98 | - |
|
99 | - |
|
100 | - |
|
101 | - /** |
|
102 | - * @param string $legend_text |
|
103 | - */ |
|
104 | - public function set_legend_text($legend_text) |
|
105 | - { |
|
106 | - $this->_legend_text = $legend_text; |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - |
|
111 | - /** |
|
112 | - * @return string |
|
113 | - */ |
|
114 | - public function legend_text() |
|
115 | - { |
|
116 | - return $this->_legend_text; |
|
117 | - } |
|
15 | + /** |
|
16 | + * legend_class |
|
17 | + * |
|
18 | + * @var string |
|
19 | + */ |
|
20 | + protected $_legend_class; |
|
21 | + |
|
22 | + /** |
|
23 | + * legend_text |
|
24 | + * |
|
25 | + * @var string |
|
26 | + */ |
|
27 | + protected $_legend_text; |
|
28 | + |
|
29 | + |
|
30 | + |
|
31 | + /** |
|
32 | + * construct |
|
33 | + * |
|
34 | + * @param array $options |
|
35 | + */ |
|
36 | + public function __construct($options = array()) |
|
37 | + { |
|
38 | + foreach ($options as $key => $value) { |
|
39 | + $key = '_' . $key; |
|
40 | + if (property_exists($this, $key)) { |
|
41 | + $this->{$key} = $value; |
|
42 | + } |
|
43 | + } |
|
44 | + } |
|
45 | + |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * opening div tag for a form |
|
50 | + * |
|
51 | + * @return string |
|
52 | + */ |
|
53 | + public function layout_form_begin() |
|
54 | + { |
|
55 | + $html = EEH_HTML::nl(1) |
|
56 | + . '<fieldset id="' |
|
57 | + . $this->_form_section->html_id() |
|
58 | + . '" class="' |
|
59 | + . $this->_form_section->html_class() |
|
60 | + . '" style="' |
|
61 | + . $this->_form_section->html_style() |
|
62 | + . '">'; |
|
63 | + $html .= '<legend class="' . $this->legend_class() . '">' . $this->legend_text() . '</legend>'; |
|
64 | + return $html; |
|
65 | + } |
|
66 | + |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * closing div tag for a form |
|
71 | + * |
|
72 | + * @return string |
|
73 | + */ |
|
74 | + public function layout_form_end() |
|
75 | + { |
|
76 | + return EEH_HTML::nl(-1) . '</fieldset>'; |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * @param string $legend_class |
|
83 | + */ |
|
84 | + public function set_legend_class($legend_class) |
|
85 | + { |
|
86 | + $this->_legend_class = $legend_class; |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * @return string |
|
93 | + */ |
|
94 | + public function legend_class() |
|
95 | + { |
|
96 | + return $this->_legend_class; |
|
97 | + } |
|
98 | + |
|
99 | + |
|
100 | + |
|
101 | + /** |
|
102 | + * @param string $legend_text |
|
103 | + */ |
|
104 | + public function set_legend_text($legend_text) |
|
105 | + { |
|
106 | + $this->_legend_text = $legend_text; |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + |
|
111 | + /** |
|
112 | + * @return string |
|
113 | + */ |
|
114 | + public function legend_text() |
|
115 | + { |
|
116 | + return $this->_legend_text; |
|
117 | + } |
|
118 | 118 | } |
@@ -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 |
@@ -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; |
@@ -7,63 +7,63 @@ |
||
7 | 7 | class EE_Admin_Two_Column_Layout extends EE_Two_Column_Layout |
8 | 8 | { |
9 | 9 | |
10 | - /** |
|
11 | - * Overriding the parent table layout to include <tbody> tags |
|
12 | - * |
|
13 | - * @param array $additional_args |
|
14 | - * @return string |
|
15 | - */ |
|
16 | - public function layout_form_begin($additional_args = array()) |
|
17 | - { |
|
18 | - $this->_form_section->set_html_class($this->_form_section->html_class() . ' form-table'); |
|
19 | - return parent::layout_form_begin($additional_args); |
|
20 | - } |
|
10 | + /** |
|
11 | + * Overriding the parent table layout to include <tbody> tags |
|
12 | + * |
|
13 | + * @param array $additional_args |
|
14 | + * @return string |
|
15 | + */ |
|
16 | + public function layout_form_begin($additional_args = array()) |
|
17 | + { |
|
18 | + $this->_form_section->set_html_class($this->_form_section->html_class() . ' form-table'); |
|
19 | + return parent::layout_form_begin($additional_args); |
|
20 | + } |
|
21 | 21 | |
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * Lays out the row for the input, including label and errors |
|
26 | - * |
|
27 | - * @param EE_Form_Input_Base $input |
|
28 | - * @return string |
|
29 | - * @throws EE_Error |
|
30 | - */ |
|
31 | - public function layout_input($input) |
|
32 | - { |
|
33 | - if ( |
|
34 | - $input->get_display_strategy() instanceof EE_Text_Area_Display_Strategy |
|
35 | - || $input->get_display_strategy() instanceof EE_Text_Input_Display_Strategy |
|
36 | - || $input->get_display_strategy() instanceof EE_Admin_File_Uploader_Display_Strategy |
|
37 | - ) { |
|
38 | - $input->set_html_class($input->html_class() . ' large-text'); |
|
39 | - } |
|
40 | - if ($input instanceof EE_Text_Area_Input) { |
|
41 | - $input->set_rows(4); |
|
42 | - $input->set_cols(60); |
|
43 | - } |
|
44 | - $input_html = $input->get_html_for_input(); |
|
45 | - // maybe add errors and help text ? |
|
46 | - $input_html .= $input->get_html_for_errors() !== '' |
|
47 | - ? EEH_HTML::nl() . $input->get_html_for_errors() |
|
48 | - : ''; |
|
49 | - $input_html .= $input->get_html_for_help() !== '' |
|
50 | - ? EEH_HTML::nl() . $input->get_html_for_help() |
|
51 | - : ''; |
|
52 | - // overriding parent to add wp admin specific things. |
|
53 | - $html = ''; |
|
54 | - if ($input instanceof EE_Hidden_Input) { |
|
55 | - $html .= EEH_HTML::no_row($input->get_html_for_input()); |
|
56 | - } else { |
|
57 | - $html .= EEH_HTML::tr( |
|
58 | - EEH_HTML::th( |
|
59 | - $input->get_html_for_label(), |
|
60 | - '', |
|
61 | - '', |
|
62 | - '', |
|
63 | - 'scope="row"' |
|
64 | - ) . EEH_HTML::td($input_html) |
|
65 | - ); |
|
66 | - } |
|
67 | - return $html; |
|
68 | - } |
|
24 | + /** |
|
25 | + * Lays out the row for the input, including label and errors |
|
26 | + * |
|
27 | + * @param EE_Form_Input_Base $input |
|
28 | + * @return string |
|
29 | + * @throws EE_Error |
|
30 | + */ |
|
31 | + public function layout_input($input) |
|
32 | + { |
|
33 | + if ( |
|
34 | + $input->get_display_strategy() instanceof EE_Text_Area_Display_Strategy |
|
35 | + || $input->get_display_strategy() instanceof EE_Text_Input_Display_Strategy |
|
36 | + || $input->get_display_strategy() instanceof EE_Admin_File_Uploader_Display_Strategy |
|
37 | + ) { |
|
38 | + $input->set_html_class($input->html_class() . ' large-text'); |
|
39 | + } |
|
40 | + if ($input instanceof EE_Text_Area_Input) { |
|
41 | + $input->set_rows(4); |
|
42 | + $input->set_cols(60); |
|
43 | + } |
|
44 | + $input_html = $input->get_html_for_input(); |
|
45 | + // maybe add errors and help text ? |
|
46 | + $input_html .= $input->get_html_for_errors() !== '' |
|
47 | + ? EEH_HTML::nl() . $input->get_html_for_errors() |
|
48 | + : ''; |
|
49 | + $input_html .= $input->get_html_for_help() !== '' |
|
50 | + ? EEH_HTML::nl() . $input->get_html_for_help() |
|
51 | + : ''; |
|
52 | + // overriding parent to add wp admin specific things. |
|
53 | + $html = ''; |
|
54 | + if ($input instanceof EE_Hidden_Input) { |
|
55 | + $html .= EEH_HTML::no_row($input->get_html_for_input()); |
|
56 | + } else { |
|
57 | + $html .= EEH_HTML::tr( |
|
58 | + EEH_HTML::th( |
|
59 | + $input->get_html_for_label(), |
|
60 | + '', |
|
61 | + '', |
|
62 | + '', |
|
63 | + 'scope="row"' |
|
64 | + ) . EEH_HTML::td($input_html) |
|
65 | + ); |
|
66 | + } |
|
67 | + return $html; |
|
68 | + } |
|
69 | 69 | } |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | return EEH_HTML::table( |
15 | 15 | '', |
16 | 16 | $this->_form_section->html_id(), |
17 | - $this->_form_section->html_class() . ' form-table', |
|
17 | + $this->_form_section->html_class().' form-table', |
|
18 | 18 | $this->_form_section->html_style() |
19 | - ) . EEH_HTML::tbody(); |
|
19 | + ).EEH_HTML::tbody(); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function layout_form_end($additional_args = array()) |
30 | 30 | { |
31 | - return EEH_HTML::tbodyx() . EEH_HTML::tablex($this->_form_section->html_id()); |
|
31 | + return EEH_HTML::tbodyx().EEH_HTML::tablex($this->_form_section->html_id()); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
@@ -45,15 +45,15 @@ discard block |
||
45 | 45 | || $input->get_display_strategy() instanceof EE_Text_Input_Display_Strategy |
46 | 46 | || $input->get_display_strategy() instanceof EE_Admin_File_Uploader_Display_Strategy |
47 | 47 | ) { |
48 | - $input->set_html_class($input->html_class() . ' large-text'); |
|
48 | + $input->set_html_class($input->html_class().' large-text'); |
|
49 | 49 | } |
50 | 50 | $input_html = $input->get_html_for_input(); |
51 | 51 | // maybe add errors and help text ? |
52 | 52 | $input_html .= $input->get_html_for_errors() !== '' |
53 | - ? EEH_HTML::nl() . $input->get_html_for_errors() |
|
53 | + ? EEH_HTML::nl().$input->get_html_for_errors() |
|
54 | 54 | : ''; |
55 | 55 | $input_html .= $input->get_html_for_help() !== '' |
56 | - ? EEH_HTML::nl() . $input->get_html_for_help() |
|
56 | + ? EEH_HTML::nl().$input->get_html_for_help() |
|
57 | 57 | : ''; |
58 | 58 | // overriding parent to add wp admin specific things. |
59 | 59 | $html = ''; |
@@ -3,90 +3,90 @@ |
||
3 | 3 | class EE_Admin_One_Column_Layout extends EE_Form_Section_Layout_Base |
4 | 4 | { |
5 | 5 | |
6 | - /** |
|
7 | - * Starts the form section |
|
8 | - * |
|
9 | - * @param array $additional_args |
|
10 | - * @return string |
|
11 | - */ |
|
12 | - public function layout_form_begin($additional_args = array()) |
|
13 | - { |
|
14 | - return EEH_HTML::table( |
|
15 | - '', |
|
16 | - $this->_form_section->html_id(), |
|
17 | - $this->_form_section->html_class() . ' form-table', |
|
18 | - $this->_form_section->html_style() |
|
19 | - ) . EEH_HTML::tbody(); |
|
20 | - } |
|
6 | + /** |
|
7 | + * Starts the form section |
|
8 | + * |
|
9 | + * @param array $additional_args |
|
10 | + * @return string |
|
11 | + */ |
|
12 | + public function layout_form_begin($additional_args = array()) |
|
13 | + { |
|
14 | + return EEH_HTML::table( |
|
15 | + '', |
|
16 | + $this->_form_section->html_id(), |
|
17 | + $this->_form_section->html_class() . ' form-table', |
|
18 | + $this->_form_section->html_style() |
|
19 | + ) . EEH_HTML::tbody(); |
|
20 | + } |
|
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * Ends the form section |
|
25 | - * |
|
26 | - * @param array $additional_args |
|
27 | - * @return string |
|
28 | - */ |
|
29 | - public function layout_form_end($additional_args = array()) |
|
30 | - { |
|
31 | - return EEH_HTML::tbodyx() . EEH_HTML::tablex($this->_form_section->html_id()); |
|
32 | - } |
|
23 | + /** |
|
24 | + * Ends the form section |
|
25 | + * |
|
26 | + * @param array $additional_args |
|
27 | + * @return string |
|
28 | + */ |
|
29 | + public function layout_form_end($additional_args = array()) |
|
30 | + { |
|
31 | + return EEH_HTML::tbodyx() . EEH_HTML::tablex($this->_form_section->html_id()); |
|
32 | + } |
|
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * Lays out the row for the input, including label and errors |
|
37 | - * |
|
38 | - * @param EE_Form_Input_Base $input |
|
39 | - * @return string |
|
40 | - * @throws EE_Error |
|
41 | - */ |
|
42 | - public function layout_input($input) |
|
43 | - { |
|
44 | - if ( |
|
45 | - $input->get_display_strategy() instanceof EE_Text_Area_Display_Strategy |
|
46 | - || $input->get_display_strategy() instanceof EE_Text_Input_Display_Strategy |
|
47 | - || $input->get_display_strategy() instanceof EE_Admin_File_Uploader_Display_Strategy |
|
48 | - ) { |
|
49 | - $input->set_html_class($input->html_class() . ' large-text'); |
|
50 | - } |
|
51 | - $input_html = $input->get_html_for_input(); |
|
52 | - // maybe add errors and help text ? |
|
53 | - $input_html .= $input->get_html_for_errors() !== '' |
|
54 | - ? EEH_HTML::nl() . $input->get_html_for_errors() |
|
55 | - : ''; |
|
56 | - $input_html .= $input->get_html_for_help() !== '' |
|
57 | - ? EEH_HTML::nl() . $input->get_html_for_help() |
|
58 | - : ''; |
|
59 | - // overriding parent to add wp admin specific things. |
|
60 | - $html = ''; |
|
61 | - if ($input instanceof EE_Hidden_Input) { |
|
62 | - $html .= EEH_HTML::no_row($input->get_html_for_input()); |
|
63 | - } else { |
|
64 | - $html .= EEH_HTML::tr( |
|
65 | - EEH_HTML::td( |
|
66 | - $input->get_html_for_label() |
|
67 | - . EEH_HTML::nl() |
|
68 | - . $input_html |
|
69 | - ) |
|
70 | - ); |
|
71 | - } |
|
72 | - return $html; |
|
73 | - } |
|
35 | + /** |
|
36 | + * Lays out the row for the input, including label and errors |
|
37 | + * |
|
38 | + * @param EE_Form_Input_Base $input |
|
39 | + * @return string |
|
40 | + * @throws EE_Error |
|
41 | + */ |
|
42 | + public function layout_input($input) |
|
43 | + { |
|
44 | + if ( |
|
45 | + $input->get_display_strategy() instanceof EE_Text_Area_Display_Strategy |
|
46 | + || $input->get_display_strategy() instanceof EE_Text_Input_Display_Strategy |
|
47 | + || $input->get_display_strategy() instanceof EE_Admin_File_Uploader_Display_Strategy |
|
48 | + ) { |
|
49 | + $input->set_html_class($input->html_class() . ' large-text'); |
|
50 | + } |
|
51 | + $input_html = $input->get_html_for_input(); |
|
52 | + // maybe add errors and help text ? |
|
53 | + $input_html .= $input->get_html_for_errors() !== '' |
|
54 | + ? EEH_HTML::nl() . $input->get_html_for_errors() |
|
55 | + : ''; |
|
56 | + $input_html .= $input->get_html_for_help() !== '' |
|
57 | + ? EEH_HTML::nl() . $input->get_html_for_help() |
|
58 | + : ''; |
|
59 | + // overriding parent to add wp admin specific things. |
|
60 | + $html = ''; |
|
61 | + if ($input instanceof EE_Hidden_Input) { |
|
62 | + $html .= EEH_HTML::no_row($input->get_html_for_input()); |
|
63 | + } else { |
|
64 | + $html .= EEH_HTML::tr( |
|
65 | + EEH_HTML::td( |
|
66 | + $input->get_html_for_label() |
|
67 | + . EEH_HTML::nl() |
|
68 | + . $input_html |
|
69 | + ) |
|
70 | + ); |
|
71 | + } |
|
72 | + return $html; |
|
73 | + } |
|
74 | 74 | |
75 | 75 | |
76 | - /** |
|
77 | - * Lays out a row for the subsection |
|
78 | - * |
|
79 | - * @param EE_Form_Section_Proper $form_section |
|
80 | - * @return string |
|
81 | - */ |
|
82 | - public function layout_subsection($form_section) |
|
83 | - { |
|
84 | - if ( |
|
85 | - $form_section instanceof EE_Form_Section_Proper |
|
86 | - || $form_section instanceof EE_Form_Section_HTML |
|
87 | - ) { |
|
88 | - return EEH_HTML::no_row($form_section->get_html()); |
|
89 | - } |
|
90 | - return ''; |
|
91 | - } |
|
76 | + /** |
|
77 | + * Lays out a row for the subsection |
|
78 | + * |
|
79 | + * @param EE_Form_Section_Proper $form_section |
|
80 | + * @return string |
|
81 | + */ |
|
82 | + public function layout_subsection($form_section) |
|
83 | + { |
|
84 | + if ( |
|
85 | + $form_section instanceof EE_Form_Section_Proper |
|
86 | + || $form_section instanceof EE_Form_Section_HTML |
|
87 | + ) { |
|
88 | + return EEH_HTML::no_row($form_section->get_html()); |
|
89 | + } |
|
90 | + return ''; |
|
91 | + } |
|
92 | 92 | } |
@@ -12,117 +12,117 @@ |
||
12 | 12 | { |
13 | 13 | |
14 | 14 | |
15 | - /** |
|
16 | - * This is a flag indicating whether to use '<br>' tags after each input in the layout |
|
17 | - * strategy. |
|
18 | - * |
|
19 | - * @var bool |
|
20 | - */ |
|
21 | - protected $_use_break_tags = true; |
|
22 | - |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * EE_No_Layout constructor. |
|
27 | - * |
|
28 | - * @param array $options Currently if this has a 'use_break_tags' key that is used to set the _use_break_tags |
|
29 | - * property on the class. |
|
30 | - */ |
|
31 | - public function __construct($options = array()) |
|
32 | - { |
|
33 | - $this->_use_break_tags = is_array($options) && isset($options['use_break_tags']) |
|
34 | - ? filter_var($options['use_break_tags'], FILTER_VALIDATE_BOOLEAN) |
|
35 | - : $this->_use_break_tags; |
|
36 | - parent::__construct(); |
|
37 | - } |
|
38 | - |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * Add line break at beginning of form |
|
43 | - * |
|
44 | - * @return string |
|
45 | - */ |
|
46 | - public function layout_form_begin() |
|
47 | - { |
|
48 | - return EEH_HTML::nl(1); |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * Lays out the row for the input, including label and errors |
|
55 | - * |
|
56 | - * @param EE_Form_Input_Base $input |
|
57 | - * @return string |
|
58 | - * @throws \EE_Error |
|
59 | - */ |
|
60 | - public function layout_input($input) |
|
61 | - { |
|
62 | - $html = ''; |
|
63 | - if ($input instanceof EE_Hidden_Input) { |
|
64 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
65 | - } elseif ($input instanceof EE_Submit_Input) { |
|
66 | - $html .= $this->br(); |
|
67 | - $html .= $input->get_html_for_input(); |
|
68 | - } elseif ($input instanceof EE_Select_Input) { |
|
69 | - $html .= $this->br(); |
|
70 | - $html .= EEH_HTML::nl(1) . $input->get_html_for_label(); |
|
71 | - $html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
|
72 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
73 | - $html .= EEH_HTML::nl() . $input->get_html_for_help(); |
|
74 | - $html .= $this->br(); |
|
75 | - } elseif ($input instanceof EE_Form_Input_With_Options_Base) { |
|
76 | - $html .= $this->br(); |
|
77 | - $html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
|
78 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
79 | - $html .= EEH_HTML::nl() . $input->get_html_for_help(); |
|
80 | - } else { |
|
81 | - $html .= $this->br(); |
|
82 | - $html .= EEH_HTML::nl(1) . $input->get_html_for_label(); |
|
83 | - $html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
|
84 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
85 | - $html .= EEH_HTML::nl() . $input->get_html_for_help(); |
|
86 | - } |
|
87 | - $html .= EEH_HTML::nl(-1); |
|
88 | - return $html; |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * Lays out a row for the subsection |
|
95 | - * |
|
96 | - * @param EE_Form_Section_Proper $form_section |
|
97 | - * @return string |
|
98 | - */ |
|
99 | - public function layout_subsection($form_section) |
|
100 | - { |
|
101 | - // d( $form_section ); |
|
102 | - return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1); |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * Add line break at end of form. |
|
109 | - * |
|
110 | - * @return string |
|
111 | - */ |
|
112 | - public function layout_form_end() |
|
113 | - { |
|
114 | - return EEH_HTML::nl(-1); |
|
115 | - } |
|
116 | - |
|
117 | - |
|
118 | - |
|
119 | - /** |
|
120 | - * This returns a break tag or an empty string depending on the value of the `_use_break_tags` property. |
|
121 | - * |
|
122 | - * @return string |
|
123 | - */ |
|
124 | - protected function br() |
|
125 | - { |
|
126 | - return $this->_use_break_tags ? EEH_HTML::br() : ''; |
|
127 | - } |
|
15 | + /** |
|
16 | + * This is a flag indicating whether to use '<br>' tags after each input in the layout |
|
17 | + * strategy. |
|
18 | + * |
|
19 | + * @var bool |
|
20 | + */ |
|
21 | + protected $_use_break_tags = true; |
|
22 | + |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * EE_No_Layout constructor. |
|
27 | + * |
|
28 | + * @param array $options Currently if this has a 'use_break_tags' key that is used to set the _use_break_tags |
|
29 | + * property on the class. |
|
30 | + */ |
|
31 | + public function __construct($options = array()) |
|
32 | + { |
|
33 | + $this->_use_break_tags = is_array($options) && isset($options['use_break_tags']) |
|
34 | + ? filter_var($options['use_break_tags'], FILTER_VALIDATE_BOOLEAN) |
|
35 | + : $this->_use_break_tags; |
|
36 | + parent::__construct(); |
|
37 | + } |
|
38 | + |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * Add line break at beginning of form |
|
43 | + * |
|
44 | + * @return string |
|
45 | + */ |
|
46 | + public function layout_form_begin() |
|
47 | + { |
|
48 | + return EEH_HTML::nl(1); |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * Lays out the row for the input, including label and errors |
|
55 | + * |
|
56 | + * @param EE_Form_Input_Base $input |
|
57 | + * @return string |
|
58 | + * @throws \EE_Error |
|
59 | + */ |
|
60 | + public function layout_input($input) |
|
61 | + { |
|
62 | + $html = ''; |
|
63 | + if ($input instanceof EE_Hidden_Input) { |
|
64 | + $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
65 | + } elseif ($input instanceof EE_Submit_Input) { |
|
66 | + $html .= $this->br(); |
|
67 | + $html .= $input->get_html_for_input(); |
|
68 | + } elseif ($input instanceof EE_Select_Input) { |
|
69 | + $html .= $this->br(); |
|
70 | + $html .= EEH_HTML::nl(1) . $input->get_html_for_label(); |
|
71 | + $html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
|
72 | + $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
73 | + $html .= EEH_HTML::nl() . $input->get_html_for_help(); |
|
74 | + $html .= $this->br(); |
|
75 | + } elseif ($input instanceof EE_Form_Input_With_Options_Base) { |
|
76 | + $html .= $this->br(); |
|
77 | + $html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
|
78 | + $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
79 | + $html .= EEH_HTML::nl() . $input->get_html_for_help(); |
|
80 | + } else { |
|
81 | + $html .= $this->br(); |
|
82 | + $html .= EEH_HTML::nl(1) . $input->get_html_for_label(); |
|
83 | + $html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
|
84 | + $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
85 | + $html .= EEH_HTML::nl() . $input->get_html_for_help(); |
|
86 | + } |
|
87 | + $html .= EEH_HTML::nl(-1); |
|
88 | + return $html; |
|
89 | + } |
|
90 | + |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * Lays out a row for the subsection |
|
95 | + * |
|
96 | + * @param EE_Form_Section_Proper $form_section |
|
97 | + * @return string |
|
98 | + */ |
|
99 | + public function layout_subsection($form_section) |
|
100 | + { |
|
101 | + // d( $form_section ); |
|
102 | + return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1); |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * Add line break at end of form. |
|
109 | + * |
|
110 | + * @return string |
|
111 | + */ |
|
112 | + public function layout_form_end() |
|
113 | + { |
|
114 | + return EEH_HTML::nl(-1); |
|
115 | + } |
|
116 | + |
|
117 | + |
|
118 | + |
|
119 | + /** |
|
120 | + * This returns a break tag or an empty string depending on the value of the `_use_break_tags` property. |
|
121 | + * |
|
122 | + * @return string |
|
123 | + */ |
|
124 | + protected function br() |
|
125 | + { |
|
126 | + return $this->_use_break_tags ? EEH_HTML::br() : ''; |
|
127 | + } |
|
128 | 128 | } |
@@ -61,28 +61,28 @@ discard block |
||
61 | 61 | { |
62 | 62 | $html = ''; |
63 | 63 | if ($input instanceof EE_Hidden_Input) { |
64 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
64 | + $html .= EEH_HTML::nl().$input->get_html_for_input(); |
|
65 | 65 | } elseif ($input instanceof EE_Submit_Input) { |
66 | 66 | $html .= $this->br(); |
67 | 67 | $html .= $input->get_html_for_input(); |
68 | 68 | } elseif ($input instanceof EE_Select_Input) { |
69 | 69 | $html .= $this->br(); |
70 | - $html .= EEH_HTML::nl(1) . $input->get_html_for_label(); |
|
71 | - $html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
|
72 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
73 | - $html .= EEH_HTML::nl() . $input->get_html_for_help(); |
|
70 | + $html .= EEH_HTML::nl(1).$input->get_html_for_label(); |
|
71 | + $html .= EEH_HTML::nl().$input->get_html_for_errors(); |
|
72 | + $html .= EEH_HTML::nl().$input->get_html_for_input(); |
|
73 | + $html .= EEH_HTML::nl().$input->get_html_for_help(); |
|
74 | 74 | $html .= $this->br(); |
75 | 75 | } elseif ($input instanceof EE_Form_Input_With_Options_Base) { |
76 | 76 | $html .= $this->br(); |
77 | - $html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
|
78 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
79 | - $html .= EEH_HTML::nl() . $input->get_html_for_help(); |
|
77 | + $html .= EEH_HTML::nl().$input->get_html_for_errors(); |
|
78 | + $html .= EEH_HTML::nl().$input->get_html_for_input(); |
|
79 | + $html .= EEH_HTML::nl().$input->get_html_for_help(); |
|
80 | 80 | } else { |
81 | 81 | $html .= $this->br(); |
82 | - $html .= EEH_HTML::nl(1) . $input->get_html_for_label(); |
|
83 | - $html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
|
84 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
85 | - $html .= EEH_HTML::nl() . $input->get_html_for_help(); |
|
82 | + $html .= EEH_HTML::nl(1).$input->get_html_for_label(); |
|
83 | + $html .= EEH_HTML::nl().$input->get_html_for_errors(); |
|
84 | + $html .= EEH_HTML::nl().$input->get_html_for_input(); |
|
85 | + $html .= EEH_HTML::nl().$input->get_html_for_help(); |
|
86 | 86 | } |
87 | 87 | $html .= EEH_HTML::nl(-1); |
88 | 88 | return $html; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | public function layout_subsection($form_section) |
100 | 100 | { |
101 | 101 | // d( $form_section ); |
102 | - return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1); |
|
102 | + return EEH_HTML::nl(1).$form_section->get_html().EEH_HTML::nl(-1); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 |
@@ -14,7 +14,7 @@ |
||
14 | 14 | */ |
15 | 15 | public function __construct($validation_error_message = null) |
16 | 16 | { |
17 | - if (! $validation_error_message) { |
|
17 | + if ( ! $validation_error_message) { |
|
18 | 18 | $validation_error_message = __("Only digits are allowed.", "event_espresso"); |
19 | 19 | } |
20 | 20 | parent::__construct($validation_error_message); |
@@ -10,41 +10,41 @@ |
||
10 | 10 | class EE_Int_Validation_Strategy extends EE_Validation_Strategy_Base |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * @param null $validation_error_message |
|
15 | - */ |
|
16 | - public function __construct($validation_error_message = null) |
|
17 | - { |
|
18 | - if (! $validation_error_message) { |
|
19 | - $validation_error_message = __("Only digits are allowed.", "event_espresso"); |
|
20 | - } |
|
21 | - parent::__construct($validation_error_message); |
|
22 | - } |
|
23 | - |
|
24 | - |
|
25 | - |
|
26 | - /** |
|
27 | - * @param $normalized_value |
|
28 | - */ |
|
29 | - public function validate($normalized_value) |
|
30 | - { |
|
31 | - // this should have already been detected by the normalization strategy |
|
32 | - } |
|
33 | - |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * @return array |
|
38 | - */ |
|
39 | - public function get_jquery_validation_rule_array() |
|
40 | - { |
|
41 | - return array( |
|
42 | - 'number' => true, |
|
43 | - 'step' => 1, |
|
44 | - 'messages' => array( |
|
45 | - 'number' => $this->get_validation_error_message(), |
|
46 | - 'step' => $this->get_validation_error_message() |
|
47 | - ) |
|
48 | - ); |
|
49 | - } |
|
13 | + /** |
|
14 | + * @param null $validation_error_message |
|
15 | + */ |
|
16 | + public function __construct($validation_error_message = null) |
|
17 | + { |
|
18 | + if (! $validation_error_message) { |
|
19 | + $validation_error_message = __("Only digits are allowed.", "event_espresso"); |
|
20 | + } |
|
21 | + parent::__construct($validation_error_message); |
|
22 | + } |
|
23 | + |
|
24 | + |
|
25 | + |
|
26 | + /** |
|
27 | + * @param $normalized_value |
|
28 | + */ |
|
29 | + public function validate($normalized_value) |
|
30 | + { |
|
31 | + // this should have already been detected by the normalization strategy |
|
32 | + } |
|
33 | + |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * @return array |
|
38 | + */ |
|
39 | + public function get_jquery_validation_rule_array() |
|
40 | + { |
|
41 | + return array( |
|
42 | + 'number' => true, |
|
43 | + 'step' => 1, |
|
44 | + 'messages' => array( |
|
45 | + 'number' => $this->get_validation_error_message(), |
|
46 | + 'step' => $this->get_validation_error_message() |
|
47 | + ) |
|
48 | + ); |
|
49 | + } |
|
50 | 50 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function __construct($validation_error_message = null, $requirement_conditions = array()) |
29 | 29 | { |
30 | - if (! $validation_error_message) { |
|
30 | + if ( ! $validation_error_message) { |
|
31 | 31 | $validation_error_message = __("This field is required.", "event_espresso"); |
32 | 32 | } |
33 | 33 | $this->set_requirement_conditions($requirement_conditions); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | { |
115 | 115 | $requirement_value = ''; |
116 | 116 | $conditions = $this->get_requirement_conditions(); |
117 | - if (! is_array($conditions)) { |
|
117 | + if ( ! is_array($conditions)) { |
|
118 | 118 | EE_Error::throw_exception_if_debugging( |
119 | 119 | sprintf( |
120 | 120 | __('Input requirement conditions must be an array. You provided %1$s', 'event_espresso'), |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | } |
140 | 140 | foreach ($conditions as $input_path => $op_and_value) { |
141 | 141 | $input = $this->_input->find_section_from_path($input_path); |
142 | - if (! $input instanceof EE_Form_Input_Base) { |
|
142 | + if ( ! $input instanceof EE_Form_Input_Base) { |
|
143 | 143 | EE_Error::throw_exception_if_debugging( |
144 | 144 | sprintf( |
145 | 145 | __('Error encountered while setting requirement condition for input %1$s. The path %2$s does not correspond to a valid input', 'event_espresso'), |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | ); |
153 | 153 | return false; |
154 | 154 | } |
155 | - list( $op, $value ) = $this->_validate_op_and_value($op_and_value); |
|
155 | + list($op, $value) = $this->_validate_op_and_value($op_and_value); |
|
156 | 156 | // ok now the jquery dependency expression depends on the input's display strategy. |
157 | - if (! $input->get_display_strategy() instanceof EE_Select_Display_Strategy) { |
|
157 | + if ( ! $input->get_display_strategy() instanceof EE_Select_Display_Strategy) { |
|
158 | 158 | EE_Error::throw_exception_if_debugging( |
159 | 159 | sprintf( |
160 | 160 | __('Required Validation Strategy can only depend on another input which uses the EE_Select_Display_Strategy, but you specified a field "%1$s" that uses display strategy "%2$s". If you need others, please add support for it! The related input is %3$s', 'event_espresso'), |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | __LINE__ |
168 | 168 | ); |
169 | 169 | } |
170 | - $requirement_value = $input->html_id(true) . ' option[value="' . $value . '"]:selected'; |
|
170 | + $requirement_value = $input->html_id(true).' option[value="'.$value.'"]:selected'; |
|
171 | 171 | } |
172 | 172 | return $requirement_value; |
173 | 173 | } |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | $conditions = $this->get_requirement_conditions(); |
189 | 189 | foreach ($conditions as $input_path => $op_and_value) { |
190 | 190 | $input = $this->_input->find_section_from_path($input_path); |
191 | - if (! $input instanceof EE_Form_Input_Base) { |
|
191 | + if ( ! $input instanceof EE_Form_Input_Base) { |
|
192 | 192 | EE_Error::throw_exception_if_debugging( |
193 | 193 | sprintf( |
194 | 194 | __('Error encountered while setting requirement condition for input %1$s. The path %2$s does not correspond to a valid input', 'event_espresso'), |
@@ -201,13 +201,13 @@ discard block |
||
201 | 201 | ); |
202 | 202 | return false; |
203 | 203 | } |
204 | - list( $op, $value ) = $this->_validate_op_and_value($op_and_value); |
|
204 | + list($op, $value) = $this->_validate_op_and_value($op_and_value); |
|
205 | 205 | switch ($op) { |
206 | 206 | case '=': |
207 | 207 | default: |
208 | 208 | $meets_all_requirements = $input->normalized_value() === $value; |
209 | 209 | } |
210 | - if (! $meets_all_requirements) { |
|
210 | + if ( ! $meets_all_requirements) { |
|
211 | 211 | break; |
212 | 212 | } |
213 | 213 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | */ |
227 | 227 | protected function _validate_op_and_value($op_and_value) |
228 | 228 | { |
229 | - if (! isset($op_and_value[0], $op_and_value[1])) { |
|
229 | + if ( ! isset($op_and_value[0], $op_and_value[1])) { |
|
230 | 230 | EE_Error::throw_exception_if_debugging( |
231 | 231 | sprintf( |
232 | 232 | __('Required Validation Strategy conditions array\'s value must be an array with two elements: an operator, and a value. It didn\'t. The related input is %1$s', 'event_espresso'), |
@@ -250,6 +250,6 @@ discard block |
||
250 | 250 | __LINE__ |
251 | 251 | ); |
252 | 252 | } |
253 | - return array( $operator, $value ); |
|
253 | + return array($operator, $value); |
|
254 | 254 | } |
255 | 255 | } |
@@ -12,246 +12,246 @@ |
||
12 | 12 | class EE_Conditionally_Required_Validation_Strategy extends EE_Validation_Strategy_Base |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * Array describing conditions necessary to make the input required. |
|
17 | - * This is used to derive a jquery dependency expression (see http://jqueryvalidation.org/required-method) |
|
18 | - * or jquery callback; and server-side logic to determine if the field is necessary. |
|
19 | - * @var array |
|
20 | - */ |
|
21 | - protected $requirement_conditions; |
|
15 | + /** |
|
16 | + * Array describing conditions necessary to make the input required. |
|
17 | + * This is used to derive a jquery dependency expression (see http://jqueryvalidation.org/required-method) |
|
18 | + * or jquery callback; and server-side logic to determine if the field is necessary. |
|
19 | + * @var array |
|
20 | + */ |
|
21 | + protected $requirement_conditions; |
|
22 | 22 | |
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * @param string $validation_error_message |
|
27 | - * @param array $requirement_conditions |
|
28 | - */ |
|
29 | - public function __construct($validation_error_message = null, $requirement_conditions = array()) |
|
30 | - { |
|
31 | - if (! $validation_error_message) { |
|
32 | - $validation_error_message = __("This field is required.", "event_espresso"); |
|
33 | - } |
|
34 | - $this->set_requirement_conditions($requirement_conditions); |
|
35 | - parent::__construct($validation_error_message); |
|
36 | - } |
|
25 | + /** |
|
26 | + * @param string $validation_error_message |
|
27 | + * @param array $requirement_conditions |
|
28 | + */ |
|
29 | + public function __construct($validation_error_message = null, $requirement_conditions = array()) |
|
30 | + { |
|
31 | + if (! $validation_error_message) { |
|
32 | + $validation_error_message = __("This field is required.", "event_espresso"); |
|
33 | + } |
|
34 | + $this->set_requirement_conditions($requirement_conditions); |
|
35 | + parent::__construct($validation_error_message); |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * just checks the field isn't blank, provided the requirement conditions |
|
42 | - * indicate this input is still required |
|
43 | - * |
|
44 | - * @param $normalized_value |
|
45 | - * @return bool |
|
46 | - * @throws \EE_Error |
|
47 | - * @throws \EE_Validation_Error |
|
48 | - */ |
|
49 | - public function validate($normalized_value) |
|
50 | - { |
|
51 | - if ( |
|
52 | - ( |
|
53 | - $normalized_value === '' |
|
54 | - || $normalized_value === null |
|
55 | - || $normalized_value === array() |
|
56 | - ) |
|
57 | - && $this->_input_is_required_server_side() |
|
58 | - ) { |
|
59 | - throw new EE_Validation_Error($this->get_validation_error_message(), 'required'); |
|
60 | - } else { |
|
61 | - return true; |
|
62 | - } |
|
63 | - } |
|
40 | + /** |
|
41 | + * just checks the field isn't blank, provided the requirement conditions |
|
42 | + * indicate this input is still required |
|
43 | + * |
|
44 | + * @param $normalized_value |
|
45 | + * @return bool |
|
46 | + * @throws \EE_Error |
|
47 | + * @throws \EE_Validation_Error |
|
48 | + */ |
|
49 | + public function validate($normalized_value) |
|
50 | + { |
|
51 | + if ( |
|
52 | + ( |
|
53 | + $normalized_value === '' |
|
54 | + || $normalized_value === null |
|
55 | + || $normalized_value === array() |
|
56 | + ) |
|
57 | + && $this->_input_is_required_server_side() |
|
58 | + ) { |
|
59 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'required'); |
|
60 | + } else { |
|
61 | + return true; |
|
62 | + } |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | 66 | |
67 | - /** |
|
68 | - * @return array |
|
69 | - * @throws \EE_Error |
|
70 | - */ |
|
71 | - public function get_jquery_validation_rule_array() |
|
72 | - { |
|
73 | - return array( |
|
74 | - 'required' => $this->_get_jquery_requirement_value(), |
|
75 | - 'messages' => array( |
|
76 | - 'required' => $this->get_validation_error_message() |
|
77 | - ) |
|
78 | - ); |
|
79 | - } |
|
67 | + /** |
|
68 | + * @return array |
|
69 | + * @throws \EE_Error |
|
70 | + */ |
|
71 | + public function get_jquery_validation_rule_array() |
|
72 | + { |
|
73 | + return array( |
|
74 | + 'required' => $this->_get_jquery_requirement_value(), |
|
75 | + 'messages' => array( |
|
76 | + 'required' => $this->get_validation_error_message() |
|
77 | + ) |
|
78 | + ); |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * Sets the "required conditions". This should be an array, its top-level key |
|
83 | - * is the name of a field, its value is an array. This 2nd level array has two items: |
|
84 | - * the first is the operator (for now only '=' is accepted), and teh 2nd argument is the |
|
85 | - * the value the field should be in order to make the field required. |
|
86 | - * Eg array( 'payment_type' => array( '=', 'credit_card' ). |
|
87 | - * |
|
88 | - * @param array $requirement_conditions |
|
89 | - */ |
|
90 | - public function set_requirement_conditions($requirement_conditions) |
|
91 | - { |
|
92 | - $this->requirement_conditions = (array) $requirement_conditions; |
|
93 | - } |
|
81 | + /** |
|
82 | + * Sets the "required conditions". This should be an array, its top-level key |
|
83 | + * is the name of a field, its value is an array. This 2nd level array has two items: |
|
84 | + * the first is the operator (for now only '=' is accepted), and teh 2nd argument is the |
|
85 | + * the value the field should be in order to make the field required. |
|
86 | + * Eg array( 'payment_type' => array( '=', 'credit_card' ). |
|
87 | + * |
|
88 | + * @param array $requirement_conditions |
|
89 | + */ |
|
90 | + public function set_requirement_conditions($requirement_conditions) |
|
91 | + { |
|
92 | + $this->requirement_conditions = (array) $requirement_conditions; |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * Gets the array that describes when the related input should be required. |
|
97 | - * see set_requirement_conditions for a description of how it should be formatted |
|
98 | - * @return array |
|
99 | - */ |
|
100 | - public function get_requirement_conditions() |
|
101 | - { |
|
102 | - return $this->requirement_conditions; |
|
103 | - } |
|
95 | + /** |
|
96 | + * Gets the array that describes when the related input should be required. |
|
97 | + * see set_requirement_conditions for a description of how it should be formatted |
|
98 | + * @return array |
|
99 | + */ |
|
100 | + public function get_requirement_conditions() |
|
101 | + { |
|
102 | + return $this->requirement_conditions; |
|
103 | + } |
|
104 | 104 | |
105 | 105 | |
106 | 106 | |
107 | - /** |
|
108 | - * gets jQuery dependency expression used for client-side validation |
|
109 | - * Its possible this could also return a javascript callback used for determining |
|
110 | - * if the input is required or not. That is not yet implemented, however. |
|
111 | - * |
|
112 | - * @return string see http://jqueryvalidation.org/required-method for format |
|
113 | - * @throws \EE_Error |
|
114 | - */ |
|
115 | - protected function _get_jquery_requirement_value() |
|
116 | - { |
|
117 | - $requirement_value = ''; |
|
118 | - $conditions = $this->get_requirement_conditions(); |
|
119 | - if (! is_array($conditions)) { |
|
120 | - EE_Error::throw_exception_if_debugging( |
|
121 | - sprintf( |
|
122 | - __('Input requirement conditions must be an array. You provided %1$s', 'event_espresso'), |
|
123 | - $this->_input->name() |
|
124 | - ), |
|
125 | - __FILE__, |
|
126 | - __FUNCTION__, |
|
127 | - __LINE__ |
|
128 | - ); |
|
129 | - return true; |
|
130 | - } |
|
131 | - if (count($conditions) > 1) { |
|
132 | - EE_Error::throw_exception_if_debugging( |
|
133 | - sprintf( |
|
134 | - __('Required Validation Strategy does not yet support multiple conditions. You should add it! The related input is %1$s', 'event_espresso'), |
|
135 | - $this->_input->name() |
|
136 | - ), |
|
137 | - __FILE__, |
|
138 | - __FUNCTION__, |
|
139 | - __LINE__ |
|
140 | - ); |
|
141 | - } |
|
142 | - foreach ($conditions as $input_path => $op_and_value) { |
|
143 | - $input = $this->_input->find_section_from_path($input_path); |
|
144 | - if (! $input instanceof EE_Form_Input_Base) { |
|
145 | - EE_Error::throw_exception_if_debugging( |
|
146 | - sprintf( |
|
147 | - __('Error encountered while setting requirement condition for input %1$s. The path %2$s does not correspond to a valid input', 'event_espresso'), |
|
148 | - $this->_input->name(), |
|
149 | - $input_path |
|
150 | - ), |
|
151 | - __FILE__, |
|
152 | - __FUNCTION__, |
|
153 | - __LINE__ |
|
154 | - ); |
|
155 | - return false; |
|
156 | - } |
|
157 | - list( $op, $value ) = $this->_validate_op_and_value($op_and_value); |
|
158 | - // ok now the jquery dependency expression depends on the input's display strategy. |
|
159 | - if (! $input->get_display_strategy() instanceof EE_Select_Display_Strategy) { |
|
160 | - EE_Error::throw_exception_if_debugging( |
|
161 | - sprintf( |
|
162 | - __('Required Validation Strategy can only depend on another input which uses the EE_Select_Display_Strategy, but you specified a field "%1$s" that uses display strategy "%2$s". If you need others, please add support for it! The related input is %3$s', 'event_espresso'), |
|
163 | - $input->name(), |
|
164 | - get_class($input->get_display_strategy()), |
|
165 | - $this->_input->name() |
|
166 | - ), |
|
167 | - __FILE__, |
|
168 | - __FUNCTION__, |
|
169 | - __LINE__ |
|
170 | - ); |
|
171 | - } |
|
172 | - $requirement_value = $input->html_id(true) . ' option[value="' . $value . '"]:selected'; |
|
173 | - } |
|
174 | - return $requirement_value; |
|
175 | - } |
|
107 | + /** |
|
108 | + * gets jQuery dependency expression used for client-side validation |
|
109 | + * Its possible this could also return a javascript callback used for determining |
|
110 | + * if the input is required or not. That is not yet implemented, however. |
|
111 | + * |
|
112 | + * @return string see http://jqueryvalidation.org/required-method for format |
|
113 | + * @throws \EE_Error |
|
114 | + */ |
|
115 | + protected function _get_jquery_requirement_value() |
|
116 | + { |
|
117 | + $requirement_value = ''; |
|
118 | + $conditions = $this->get_requirement_conditions(); |
|
119 | + if (! is_array($conditions)) { |
|
120 | + EE_Error::throw_exception_if_debugging( |
|
121 | + sprintf( |
|
122 | + __('Input requirement conditions must be an array. You provided %1$s', 'event_espresso'), |
|
123 | + $this->_input->name() |
|
124 | + ), |
|
125 | + __FILE__, |
|
126 | + __FUNCTION__, |
|
127 | + __LINE__ |
|
128 | + ); |
|
129 | + return true; |
|
130 | + } |
|
131 | + if (count($conditions) > 1) { |
|
132 | + EE_Error::throw_exception_if_debugging( |
|
133 | + sprintf( |
|
134 | + __('Required Validation Strategy does not yet support multiple conditions. You should add it! The related input is %1$s', 'event_espresso'), |
|
135 | + $this->_input->name() |
|
136 | + ), |
|
137 | + __FILE__, |
|
138 | + __FUNCTION__, |
|
139 | + __LINE__ |
|
140 | + ); |
|
141 | + } |
|
142 | + foreach ($conditions as $input_path => $op_and_value) { |
|
143 | + $input = $this->_input->find_section_from_path($input_path); |
|
144 | + if (! $input instanceof EE_Form_Input_Base) { |
|
145 | + EE_Error::throw_exception_if_debugging( |
|
146 | + sprintf( |
|
147 | + __('Error encountered while setting requirement condition for input %1$s. The path %2$s does not correspond to a valid input', 'event_espresso'), |
|
148 | + $this->_input->name(), |
|
149 | + $input_path |
|
150 | + ), |
|
151 | + __FILE__, |
|
152 | + __FUNCTION__, |
|
153 | + __LINE__ |
|
154 | + ); |
|
155 | + return false; |
|
156 | + } |
|
157 | + list( $op, $value ) = $this->_validate_op_and_value($op_and_value); |
|
158 | + // ok now the jquery dependency expression depends on the input's display strategy. |
|
159 | + if (! $input->get_display_strategy() instanceof EE_Select_Display_Strategy) { |
|
160 | + EE_Error::throw_exception_if_debugging( |
|
161 | + sprintf( |
|
162 | + __('Required Validation Strategy can only depend on another input which uses the EE_Select_Display_Strategy, but you specified a field "%1$s" that uses display strategy "%2$s". If you need others, please add support for it! The related input is %3$s', 'event_espresso'), |
|
163 | + $input->name(), |
|
164 | + get_class($input->get_display_strategy()), |
|
165 | + $this->_input->name() |
|
166 | + ), |
|
167 | + __FILE__, |
|
168 | + __FUNCTION__, |
|
169 | + __LINE__ |
|
170 | + ); |
|
171 | + } |
|
172 | + $requirement_value = $input->html_id(true) . ' option[value="' . $value . '"]:selected'; |
|
173 | + } |
|
174 | + return $requirement_value; |
|
175 | + } |
|
176 | 176 | |
177 | 177 | |
178 | 178 | |
179 | - /** |
|
180 | - * Returns whether or not this input is required based on the _requirement_conditions |
|
181 | - * (not whether or not the input passes validation. That's for the validate method |
|
182 | - * to decide) |
|
183 | - * |
|
184 | - * @return boolean |
|
185 | - * @throws \EE_Error |
|
186 | - */ |
|
187 | - protected function _input_is_required_server_side() |
|
188 | - { |
|
189 | - $meets_all_requirements = true; |
|
190 | - $conditions = $this->get_requirement_conditions(); |
|
191 | - foreach ($conditions as $input_path => $op_and_value) { |
|
192 | - $input = $this->_input->find_section_from_path($input_path); |
|
193 | - if (! $input instanceof EE_Form_Input_Base) { |
|
194 | - EE_Error::throw_exception_if_debugging( |
|
195 | - sprintf( |
|
196 | - __('Error encountered while setting requirement condition for input %1$s. The path %2$s does not correspond to a valid input', 'event_espresso'), |
|
197 | - $this->_input->name(), |
|
198 | - $input_path |
|
199 | - ), |
|
200 | - __FILE__, |
|
201 | - __FUNCTION__, |
|
202 | - __LINE__ |
|
203 | - ); |
|
204 | - return false; |
|
205 | - } |
|
206 | - list( $op, $value ) = $this->_validate_op_and_value($op_and_value); |
|
207 | - switch ($op) { |
|
208 | - case '=': |
|
209 | - default: |
|
210 | - $meets_all_requirements = $input->normalized_value() === $value; |
|
211 | - } |
|
212 | - if (! $meets_all_requirements) { |
|
213 | - break; |
|
214 | - } |
|
215 | - } |
|
216 | - return $meets_all_requirements; |
|
217 | - } |
|
179 | + /** |
|
180 | + * Returns whether or not this input is required based on the _requirement_conditions |
|
181 | + * (not whether or not the input passes validation. That's for the validate method |
|
182 | + * to decide) |
|
183 | + * |
|
184 | + * @return boolean |
|
185 | + * @throws \EE_Error |
|
186 | + */ |
|
187 | + protected function _input_is_required_server_side() |
|
188 | + { |
|
189 | + $meets_all_requirements = true; |
|
190 | + $conditions = $this->get_requirement_conditions(); |
|
191 | + foreach ($conditions as $input_path => $op_and_value) { |
|
192 | + $input = $this->_input->find_section_from_path($input_path); |
|
193 | + if (! $input instanceof EE_Form_Input_Base) { |
|
194 | + EE_Error::throw_exception_if_debugging( |
|
195 | + sprintf( |
|
196 | + __('Error encountered while setting requirement condition for input %1$s. The path %2$s does not correspond to a valid input', 'event_espresso'), |
|
197 | + $this->_input->name(), |
|
198 | + $input_path |
|
199 | + ), |
|
200 | + __FILE__, |
|
201 | + __FUNCTION__, |
|
202 | + __LINE__ |
|
203 | + ); |
|
204 | + return false; |
|
205 | + } |
|
206 | + list( $op, $value ) = $this->_validate_op_and_value($op_and_value); |
|
207 | + switch ($op) { |
|
208 | + case '=': |
|
209 | + default: |
|
210 | + $meets_all_requirements = $input->normalized_value() === $value; |
|
211 | + } |
|
212 | + if (! $meets_all_requirements) { |
|
213 | + break; |
|
214 | + } |
|
215 | + } |
|
216 | + return $meets_all_requirements; |
|
217 | + } |
|
218 | 218 | |
219 | 219 | |
220 | 220 | |
221 | - /** |
|
222 | - * Verifies this is an array with keys 0 and 1, where key 0 is a usable |
|
223 | - * operator (initially just '=') and key 1 is something that can be cast to a string |
|
224 | - * |
|
225 | - * @param array $op_and_value |
|
226 | - * @return array |
|
227 | - * @throws \EE_Error |
|
228 | - */ |
|
229 | - protected function _validate_op_and_value($op_and_value) |
|
230 | - { |
|
231 | - if (! isset($op_and_value[0], $op_and_value[1])) { |
|
232 | - EE_Error::throw_exception_if_debugging( |
|
233 | - sprintf( |
|
234 | - __('Required Validation Strategy conditions array\'s value must be an array with two elements: an operator, and a value. It didn\'t. The related input is %1$s', 'event_espresso'), |
|
235 | - $this->_input->name() |
|
236 | - ), |
|
237 | - __FILE__, |
|
238 | - __FUNCTION__, |
|
239 | - __LINE__ |
|
240 | - ); |
|
241 | - } |
|
242 | - $operator = $op_and_value[0]; |
|
243 | - $value = (string) $op_and_value[1]; |
|
244 | - if ($operator !== '=') { |
|
245 | - EE_Error::throw_exception_if_debugging( |
|
246 | - sprintf( |
|
247 | - __('Required Validation Strategy conditions can currently only use the equals operator. If you need others, please add support for it! The related input is %1$s', 'event_espresso'), |
|
248 | - $this->_input->name() |
|
249 | - ), |
|
250 | - __FILE__, |
|
251 | - __FUNCTION__, |
|
252 | - __LINE__ |
|
253 | - ); |
|
254 | - } |
|
255 | - return array( $operator, $value ); |
|
256 | - } |
|
221 | + /** |
|
222 | + * Verifies this is an array with keys 0 and 1, where key 0 is a usable |
|
223 | + * operator (initially just '=') and key 1 is something that can be cast to a string |
|
224 | + * |
|
225 | + * @param array $op_and_value |
|
226 | + * @return array |
|
227 | + * @throws \EE_Error |
|
228 | + */ |
|
229 | + protected function _validate_op_and_value($op_and_value) |
|
230 | + { |
|
231 | + if (! isset($op_and_value[0], $op_and_value[1])) { |
|
232 | + EE_Error::throw_exception_if_debugging( |
|
233 | + sprintf( |
|
234 | + __('Required Validation Strategy conditions array\'s value must be an array with two elements: an operator, and a value. It didn\'t. The related input is %1$s', 'event_espresso'), |
|
235 | + $this->_input->name() |
|
236 | + ), |
|
237 | + __FILE__, |
|
238 | + __FUNCTION__, |
|
239 | + __LINE__ |
|
240 | + ); |
|
241 | + } |
|
242 | + $operator = $op_and_value[0]; |
|
243 | + $value = (string) $op_and_value[1]; |
|
244 | + if ($operator !== '=') { |
|
245 | + EE_Error::throw_exception_if_debugging( |
|
246 | + sprintf( |
|
247 | + __('Required Validation Strategy conditions can currently only use the equals operator. If you need others, please add support for it! The related input is %1$s', 'event_espresso'), |
|
248 | + $this->_input->name() |
|
249 | + ), |
|
250 | + __FILE__, |
|
251 | + __FUNCTION__, |
|
252 | + __LINE__ |
|
253 | + ); |
|
254 | + } |
|
255 | + return array( $operator, $value ); |
|
256 | + } |
|
257 | 257 | } |