@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | |
394 | 394 | /** |
395 | 395 | * generate_question_groups_html |
396 | - * |
|
396 | + * |
|
397 | 397 | * @param string $question_groups |
398 | 398 | * @return string HTML |
399 | 399 | */ |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | |
538 | 538 | /** |
539 | 539 | * generate_form_input |
540 | - * |
|
540 | + * |
|
541 | 541 | * @param EE_Question_Form_Input $QFI |
542 | 542 | * @return string HTML |
543 | 543 | */ |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | |
613 | 613 | /** |
614 | 614 | * generates HTML for a form text input |
615 | - * |
|
615 | + * |
|
616 | 616 | * @param string $question label content |
617 | 617 | * @param string $answer form input value attribute |
618 | 618 | * @param string $name form input name attribute |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | |
658 | 658 | /** |
659 | 659 | * generates HTML for a form textarea |
660 | - * |
|
660 | + * |
|
661 | 661 | * @param string $question label content |
662 | 662 | * @param string $answer form input value attribute |
663 | 663 | * @param string $name form input name attribute |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | |
709 | 709 | /** |
710 | 710 | * generates HTML for a form select input |
711 | - * |
|
711 | + * |
|
712 | 712 | * @param string $question label content |
713 | 713 | * @param string $answer form input value attribute |
714 | 714 | * @param array $options array of answer options where array key = option value and array value = option display text |
@@ -885,7 +885,7 @@ discard block |
||
885 | 885 | |
886 | 886 | /** |
887 | 887 | * generates HTML for form checkbox inputs |
888 | - * |
|
888 | + * |
|
889 | 889 | * @param string $question label content |
890 | 890 | * @param string $answer form input value attribute |
891 | 891 | * @param array $options array of options where array key = option value and array value = option display text |
@@ -966,7 +966,7 @@ discard block |
||
966 | 966 | |
967 | 967 | /** |
968 | 968 | * generates HTML for a form datepicker input |
969 | - * |
|
969 | + * |
|
970 | 970 | * @param string $question label content |
971 | 971 | * @param string $answer form input value attribute |
972 | 972 | * @param string $name form input name attribute |
@@ -366,14 +366,16 @@ discard block |
||
366 | 366 | $field = '<select id="' . EEH_Formatter::ee_tep_output_string($name) . '" name="' . EEH_Formatter::ee_tep_output_string($name) . '"'; |
367 | 367 | //Debug |
368 | 368 | //EEH_Debug_Tools::printr( $values, '$values <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
369 | - if ( EEH_Formatter::ee_tep_not_null($parameters)) |
|
370 | - $field .= ' ' . $parameters; |
|
369 | + if ( EEH_Formatter::ee_tep_not_null($parameters)) { |
|
370 | + $field .= ' ' . $parameters; |
|
371 | + } |
|
371 | 372 | if ($autosize) { |
372 | 373 | $size = 'med'; |
373 | 374 | for ($ii = 0, $ni = sizeof($values); $ii < $ni; $ii++) { |
374 | 375 | if ($values[$ii]['text']) { |
375 | - if (strlen($values[$ii]['text']) > 5) |
|
376 | - $size = 'wide'; |
|
376 | + if (strlen($values[$ii]['text']) > 5) { |
|
377 | + $size = 'wide'; |
|
378 | + } |
|
377 | 379 | } |
378 | 380 | } |
379 | 381 | } else { |
@@ -382,8 +384,9 @@ discard block |
||
382 | 384 | |
383 | 385 | $field .= ' class="' . $class . ' ' . $size . '">'; |
384 | 386 | |
385 | - if (empty($default) && isset($GLOBALS[$name])) |
|
386 | - $default = stripslashes($GLOBALS[$name]); |
|
387 | + if (empty($default) && isset($GLOBALS[$name])) { |
|
388 | + $default = stripslashes($GLOBALS[$name]); |
|
389 | + } |
|
387 | 390 | |
388 | 391 | |
389 | 392 | for ($i = 0, $n = sizeof($values); $i < $n; $i++) { |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | * @return string |
70 | 70 | * @todo: at some point we can break this down into other static methods to abstract it a bit better. |
71 | 71 | */ |
72 | - static public function get_form_fields( $input_vars = array(), $id = FALSE ) { |
|
72 | + static public function get_form_fields($input_vars = array(), $id = FALSE) { |
|
73 | 73 | |
74 | - if ( empty($input_vars) ) { |
|
75 | - EE_Error::add_error( __('missing required variables for the form field generator', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
74 | + if (empty($input_vars)) { |
|
75 | + EE_Error::add_error(__('missing required variables for the form field generator', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
76 | 76 | return FALSE; |
77 | 77 | } |
78 | 78 | |
@@ -98,25 +98,25 @@ discard block |
||
98 | 98 | 'append_content' => '' |
99 | 99 | ); |
100 | 100 | |
101 | - $input_value = wp_parse_args( $input_value, $defaults ); |
|
101 | + $input_value = wp_parse_args($input_value, $defaults); |
|
102 | 102 | |
103 | 103 | // required fields get a * |
104 | 104 | $required = isset($input_value['required']) && $input_value['required'] ? ' <span>*</span>: ' : ': '; |
105 | 105 | // and the css class "required" |
106 | - $css_class = isset( $input_value['css_class'] ) ? $input_value['css_class'] : ''; |
|
107 | - $styles = $input_value['required'] ? 'required ' . $css_class : $css_class; |
|
106 | + $css_class = isset($input_value['css_class']) ? $input_value['css_class'] : ''; |
|
107 | + $styles = $input_value['required'] ? 'required '.$css_class : $css_class; |
|
108 | 108 | |
109 | - $field_id = ($id) ? $id . '-' . $input_key : $input_key; |
|
110 | - $tabindex = !empty($input_value['tabindex']) ? ' tabindex="' . $input_value['tabindex'] . '"' : ''; |
|
109 | + $field_id = ($id) ? $id.'-'.$input_key : $input_key; |
|
110 | + $tabindex = ! empty($input_value['tabindex']) ? ' tabindex="'.$input_value['tabindex'].'"' : ''; |
|
111 | 111 | |
112 | 112 | //rows or cols? |
113 | - $rows = isset($input_value['rows'] ) ? $input_value['rows'] : '10'; |
|
114 | - $cols = isset($input_value['cols'] ) ? $input_value['cols'] : '80'; |
|
113 | + $rows = isset($input_value['rows']) ? $input_value['rows'] : '10'; |
|
114 | + $cols = isset($input_value['cols']) ? $input_value['cols'] : '80'; |
|
115 | 115 | |
116 | 116 | //any content? |
117 | 117 | $append_content = $input_value['append_content']; |
118 | 118 | |
119 | - $output .= (!$close) ? '<ul>' : ''; |
|
119 | + $output .= ( ! $close) ? '<ul>' : ''; |
|
120 | 120 | $output .= '<li>'; |
121 | 121 | |
122 | 122 | // what type of input are we dealing with ? |
@@ -124,15 +124,15 @@ discard block |
||
124 | 124 | |
125 | 125 | // text inputs |
126 | 126 | case 'text' : |
127 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
128 | - $output .= "\n\t\t\t" . '<input id="' . $field_id . '" class="' . $styles . '" type="text" value="' . $input_value['value'] . '" name="' . $input_value['name'] . '"' . $tabindex . '>'; |
|
127 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
128 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" class="'.$styles.'" type="text" value="'.$input_value['value'].'" name="'.$input_value['name'].'"'.$tabindex.'>'; |
|
129 | 129 | break; |
130 | 130 | |
131 | 131 | // dropdowns |
132 | 132 | case 'select' : |
133 | 133 | |
134 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
135 | - $output .= "\n\t\t\t" . '<select id="' . $field_id . '" class="' . $styles . '" name="' . $input_value['name'] . '"' . $tabindex . '>'; |
|
134 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
135 | + $output .= "\n\t\t\t".'<select id="'.$field_id.'" class="'.$styles.'" name="'.$input_value['name'].'"'.$tabindex.'>'; |
|
136 | 136 | |
137 | 137 | if (is_array($input_value['options'])) { |
138 | 138 | $options = $input_value['options']; |
@@ -141,30 +141,30 @@ discard block |
||
141 | 141 | } |
142 | 142 | |
143 | 143 | foreach ($options as $key => $value) { |
144 | - $selected = isset( $input_value['value'] ) && $input_value['value'] == $key ? 'selected=selected' : ''; |
|
144 | + $selected = isset($input_value['value']) && $input_value['value'] == $key ? 'selected=selected' : ''; |
|
145 | 145 | //$key = str_replace( ' ', '_', sanitize_key( $value )); |
146 | - $output .= "\n\t\t\t\t" . '<option '. $selected . ' value="' . $key . '">' . $value . '</option>'; |
|
146 | + $output .= "\n\t\t\t\t".'<option '.$selected.' value="'.$key.'">'.$value.'</option>'; |
|
147 | 147 | } |
148 | - $output .= "\n\t\t\t" . '</select>'; |
|
148 | + $output .= "\n\t\t\t".'</select>'; |
|
149 | 149 | |
150 | 150 | break; |
151 | 151 | |
152 | 152 | case 'textarea' : |
153 | 153 | |
154 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
155 | - $output .= "\n\t\t\t" . '<textarea id="' . $field_id . '" class="' . $styles . '" rows="'.$rows.'" cols="'.$cols.'" name="' . $input_value['name'] . '"' . $tabindex . '>' . $input_value['value'] . '</textarea>'; |
|
154 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
155 | + $output .= "\n\t\t\t".'<textarea id="'.$field_id.'" class="'.$styles.'" rows="'.$rows.'" cols="'.$cols.'" name="'.$input_value['name'].'"'.$tabindex.'>'.$input_value['value'].'</textarea>'; |
|
156 | 156 | break; |
157 | 157 | |
158 | 158 | case 'hidden' : |
159 | 159 | $close = false; |
160 | 160 | $output .= "</li></ul>"; |
161 | - $output .= "\n\t\t\t" . '<input id="' . $field_id . '" type="hidden" name="' . $input_value['name'] . '" value="' . $input_value['value'] . '">'; |
|
161 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" type="hidden" name="'.$input_value['name'].'" value="'.$input_value['value'].'">'; |
|
162 | 162 | break; |
163 | 163 | |
164 | 164 | case 'checkbox' : |
165 | - $checked = ( $input_value['value'] == 1 ) ? 'checked="checked"' : ''; |
|
166 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
167 | - $output .= "\n\t\t\t" . '<input id="' . $field_id. '" type="checkbox" name="' . $input_value['name'] . '" value="1"' . $checked . $tabindex . ' />'; |
|
165 | + $checked = ($input_value['value'] == 1) ? 'checked="checked"' : ''; |
|
166 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
167 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" type="checkbox" name="'.$input_value['name'].'" value="1"'.$checked.$tabindex.' />'; |
|
168 | 168 | break; |
169 | 169 | |
170 | 170 | case 'wp_editor' : |
@@ -177,19 +177,19 @@ discard block |
||
177 | 177 | ); |
178 | 178 | $output .= '</li>'; |
179 | 179 | $output .= '</ul>'; |
180 | - $output .= '<h4>' . $input_value['label'] . '</h4>'; |
|
181 | - if ( $append_content ) { |
|
180 | + $output .= '<h4>'.$input_value['label'].'</h4>'; |
|
181 | + if ($append_content) { |
|
182 | 182 | $output .= $append_content; |
183 | 183 | } |
184 | 184 | ob_start(); |
185 | - wp_editor( $input_value['value'], $field_id, $editor_settings); |
|
185 | + wp_editor($input_value['value'], $field_id, $editor_settings); |
|
186 | 186 | $editor = ob_get_contents(); |
187 | 187 | ob_end_clean(); |
188 | 188 | $output .= $editor; |
189 | 189 | break; |
190 | 190 | |
191 | 191 | } |
192 | - if ( $append_content && $input_value['input'] !== 'wp_editor' ) { |
|
192 | + if ($append_content && $input_value['input'] !== 'wp_editor') { |
|
193 | 193 | $output .= $append_content; |
194 | 194 | } |
195 | 195 | $output .= ($close) ? '</li>' : ''; |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $form_fields = array(); |
231 | 231 | $fields = (array) $fields; |
232 | 232 | |
233 | - foreach ( $fields as $field_name => $field_atts ) { |
|
233 | + foreach ($fields as $field_name => $field_atts) { |
|
234 | 234 | //defaults: |
235 | 235 | $defaults = array( |
236 | 236 | 'label' => '', |
@@ -248,67 +248,67 @@ discard block |
||
248 | 248 | 'wpeditor_args' => array() |
249 | 249 | ); |
250 | 250 | // merge defaults with passed arguments |
251 | - $_fields = wp_parse_args( $field_atts, $defaults); |
|
252 | - extract( $_fields ); |
|
251 | + $_fields = wp_parse_args($field_atts, $defaults); |
|
252 | + extract($_fields); |
|
253 | 253 | // generate label |
254 | - $label = empty($label) ? '' : '<label for="' . $id . '">' . $label . '</label>'; |
|
254 | + $label = empty($label) ? '' : '<label for="'.$id.'">'.$label.'</label>'; |
|
255 | 255 | // generate field name |
256 | - $f_name = !empty($unique_id) ? $field_name . '[' . $unique_id . ']' : $field_name; |
|
256 | + $f_name = ! empty($unique_id) ? $field_name.'['.$unique_id.']' : $field_name; |
|
257 | 257 | |
258 | 258 | //tabindex |
259 | - $tabindex_str = !empty( $tabindex ) ? ' tabindex="' . $tabindex . '"' : ''; |
|
259 | + $tabindex_str = ! empty($tabindex) ? ' tabindex="'.$tabindex.'"' : ''; |
|
260 | 260 | |
261 | 261 | //we determine what we're building based on the type |
262 | - switch ( $type ) { |
|
262 | + switch ($type) { |
|
263 | 263 | |
264 | 264 | case 'textarea' : |
265 | - $fld = '<textarea id="' . $id . '" class="' . $class . '" rows="' . $dimensions[1] . '" cols="' . $dimensions[0] . '" name="' . $f_name . '"' . $tabindex_str . '>' . $value . '</textarea>'; |
|
265 | + $fld = '<textarea id="'.$id.'" class="'.$class.'" rows="'.$dimensions[1].'" cols="'.$dimensions[0].'" name="'.$f_name.'"'.$tabindex_str.'>'.$value.'</textarea>'; |
|
266 | 266 | $fld .= $extra_desc; |
267 | 267 | break; |
268 | 268 | |
269 | 269 | case 'checkbox' : |
270 | 270 | $c_input = ''; |
271 | - if ( is_array($value) ) { |
|
272 | - foreach ( $value as $key => $val ) { |
|
273 | - $c_id = $field_name . '_' . $value; |
|
274 | - $c_class = isset($classes[$key]) ? ' class="' . $classes[$key] . '" ' : ''; |
|
275 | - $c_label = isset($labels[$key]) ? '<label for="' . $c_id . '">' . $labels[$key] . '</label>' : ''; |
|
276 | - $checked = !empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
277 | - $c_input .= '<input name="' . $f_name . '[]" type="checkbox" id="' . $c_id . '"' . $c_class . 'value="' . $val . '"' . $checked . $tabindex_str . ' />' . "\n" . $c_label; |
|
271 | + if (is_array($value)) { |
|
272 | + foreach ($value as $key => $val) { |
|
273 | + $c_id = $field_name.'_'.$value; |
|
274 | + $c_class = isset($classes[$key]) ? ' class="'.$classes[$key].'" ' : ''; |
|
275 | + $c_label = isset($labels[$key]) ? '<label for="'.$c_id.'">'.$labels[$key].'</label>' : ''; |
|
276 | + $checked = ! empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
277 | + $c_input .= '<input name="'.$f_name.'[]" type="checkbox" id="'.$c_id.'"'.$c_class.'value="'.$val.'"'.$checked.$tabindex_str.' />'."\n".$c_label; |
|
278 | 278 | } |
279 | 279 | $fld = $c_input; |
280 | 280 | } else { |
281 | - $checked = !empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
282 | - $fld = '<input name="'. $f_name . '" type="checkbox" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $checked . $tabindex_str . ' />' . "\n"; |
|
281 | + $checked = ! empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
282 | + $fld = '<input name="'.$f_name.'" type="checkbox" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$checked.$tabindex_str.' />'."\n"; |
|
283 | 283 | } |
284 | 284 | break; |
285 | 285 | |
286 | 286 | case 'radio' : |
287 | 287 | $c_input = ''; |
288 | - if ( is_array($value) ) { |
|
289 | - foreach ( $value as $key => $val ) { |
|
290 | - $c_id = $field_name . '_' . $value; |
|
291 | - $c_class = isset($classes[$key]) ? 'class="' . $classes[$key] . '" ' : ''; |
|
292 | - $c_label = isset($labels[$key]) ? '<label for="' . $c_id . '">' . $labels[$key] . '</label>' : ''; |
|
293 | - $checked = !empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
294 | - $c_input .= '<input name="' . $f_name . '" type="checkbox" id="' . $c_id . '"' . $c_class . 'value="' . $val . '"' . $checked . $tabindex_str . ' />' . "\n" . $c_label; |
|
288 | + if (is_array($value)) { |
|
289 | + foreach ($value as $key => $val) { |
|
290 | + $c_id = $field_name.'_'.$value; |
|
291 | + $c_class = isset($classes[$key]) ? 'class="'.$classes[$key].'" ' : ''; |
|
292 | + $c_label = isset($labels[$key]) ? '<label for="'.$c_id.'">'.$labels[$key].'</label>' : ''; |
|
293 | + $checked = ! empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
294 | + $c_input .= '<input name="'.$f_name.'" type="checkbox" id="'.$c_id.'"'.$c_class.'value="'.$val.'"'.$checked.$tabindex_str.' />'."\n".$c_label; |
|
295 | 295 | } |
296 | 296 | $fld = $c_input; |
297 | 297 | } else { |
298 | - $checked = !empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
299 | - $fld = '<input name="'. $f_name . '" type="checkbox" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $checked . $tabindex_str . ' />' . "\n"; |
|
298 | + $checked = ! empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
299 | + $fld = '<input name="'.$f_name.'" type="checkbox" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$checked.$tabindex_str.' />'."\n"; |
|
300 | 300 | } |
301 | 301 | break; |
302 | 302 | |
303 | 303 | case 'hidden' : |
304 | - $fld = '<input name="' . $f_name . '" type="hidden" id="' . $id . '" class="' . $class . '" value="' . $value . '" />' . "\n"; |
|
304 | + $fld = '<input name="'.$f_name.'" type="hidden" id="'.$id.'" class="'.$class.'" value="'.$value.'" />'."\n"; |
|
305 | 305 | break; |
306 | 306 | |
307 | 307 | case 'select' : |
308 | - $fld = '<select name="' . $f_name . '" class="' . $class . '" id="' . $id . '"' . $tabindex_str . '>' . "\n"; |
|
309 | - foreach ( $value as $key => $val ) { |
|
310 | - $checked = !empty($default) && $default == $val ? ' selected="selected"' : ''; |
|
311 | - $fld .= "\t" . '<option value="' . $val . '"' . $checked . '>' . $labels[$key] . '</option>' . "\n"; |
|
308 | + $fld = '<select name="'.$f_name.'" class="'.$class.'" id="'.$id.'"'.$tabindex_str.'>'."\n"; |
|
309 | + foreach ($value as $key => $val) { |
|
310 | + $checked = ! empty($default) && $default == $val ? ' selected="selected"' : ''; |
|
311 | + $fld .= "\t".'<option value="'.$val.'"'.$checked.'>'.$labels[$key].'</option>'."\n"; |
|
312 | 312 | } |
313 | 313 | $fld .= '</select>'; |
314 | 314 | break; |
@@ -320,21 +320,21 @@ discard block |
||
320 | 320 | 'editor_class' => $class, |
321 | 321 | 'tabindex' => $tabindex |
322 | 322 | ); |
323 | - $editor_settings = array_merge( $wpeditor_args, $editor_settings ); |
|
323 | + $editor_settings = array_merge($wpeditor_args, $editor_settings); |
|
324 | 324 | ob_start(); |
325 | - wp_editor( $value, $id, $editor_settings ); |
|
325 | + wp_editor($value, $id, $editor_settings); |
|
326 | 326 | $editor = ob_get_contents(); |
327 | 327 | ob_end_clean(); |
328 | 328 | $fld = $editor; |
329 | 329 | break; |
330 | 330 | |
331 | 331 | default : //'text fields' |
332 | - $fld = '<input name="' . $f_name . '" type="text" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $tabindex_str . ' />' . "\n"; |
|
332 | + $fld = '<input name="'.$f_name.'" type="text" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$tabindex_str.' />'."\n"; |
|
333 | 333 | $fld .= $extra_desc; |
334 | 334 | |
335 | 335 | } |
336 | 336 | |
337 | - $form_fields[ $field_name ] = array( 'label' => $label, 'field' => $fld ); |
|
337 | + $form_fields[$field_name] = array('label' => $label, 'field' => $fld); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | return $form_fields; |
@@ -363,19 +363,19 @@ discard block |
||
363 | 363 | */ |
364 | 364 | static public function select_input($name, $values, $default = '', $parameters = '', $class = '', $autosize = true) { |
365 | 365 | //if $values was submitted in the wrong format, convert it over |
366 | - if(!empty($values) && (!array_key_exists(0,$values) || !is_array($values[0]))){ |
|
367 | - $converted_values=array(); |
|
368 | - foreach($values as $id=>$text){ |
|
369 | - $converted_values[]=array('id'=>$id,'text'=>$text); |
|
366 | + if ( ! empty($values) && ( ! array_key_exists(0, $values) || ! is_array($values[0]))) { |
|
367 | + $converted_values = array(); |
|
368 | + foreach ($values as $id=>$text) { |
|
369 | + $converted_values[] = array('id'=>$id, 'text'=>$text); |
|
370 | 370 | } |
371 | - $values=$converted_values; |
|
371 | + $values = $converted_values; |
|
372 | 372 | } |
373 | 373 | |
374 | - $field = '<select id="' . EEH_Formatter::ee_tep_output_string($name) . '" name="' . EEH_Formatter::ee_tep_output_string($name) . '"'; |
|
374 | + $field = '<select id="'.EEH_Formatter::ee_tep_output_string($name).'" name="'.EEH_Formatter::ee_tep_output_string($name).'"'; |
|
375 | 375 | //Debug |
376 | 376 | //EEH_Debug_Tools::printr( $values, '$values <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
377 | - if ( EEH_Formatter::ee_tep_not_null($parameters)) |
|
378 | - $field .= ' ' . $parameters; |
|
377 | + if (EEH_Formatter::ee_tep_not_null($parameters)) |
|
378 | + $field .= ' '.$parameters; |
|
379 | 379 | if ($autosize) { |
380 | 380 | $size = 'med'; |
381 | 381 | for ($ii = 0, $ni = sizeof($values); $ii < $ni; $ii++) { |
@@ -388,21 +388,21 @@ discard block |
||
388 | 388 | $size = ''; |
389 | 389 | } |
390 | 390 | |
391 | - $field .= ' class="' . $class . ' ' . $size . '">'; |
|
391 | + $field .= ' class="'.$class.' '.$size.'">'; |
|
392 | 392 | |
393 | 393 | if (empty($default) && isset($GLOBALS[$name])) |
394 | 394 | $default = stripslashes($GLOBALS[$name]); |
395 | 395 | |
396 | 396 | |
397 | 397 | for ($i = 0, $n = sizeof($values); $i < $n; $i++) { |
398 | - $field .= '<option value="' . $values[$i]['id'] . '"'; |
|
398 | + $field .= '<option value="'.$values[$i]['id'].'"'; |
|
399 | 399 | if ($default == $values[$i]['id']) { |
400 | 400 | $field .= ' selected = "selected"'; |
401 | 401 | } |
402 | - if ( isset( $values[$i]['class'] ) ) { |
|
403 | - $field .= ' class="' . $values[$i]['class'] . '"'; |
|
402 | + if (isset($values[$i]['class'])) { |
|
403 | + $field .= ' class="'.$values[$i]['class'].'"'; |
|
404 | 404 | } |
405 | - $field .= '>' . $values[$i]['text'] . '</option>'; |
|
405 | + $field .= '>'.$values[$i]['text'].'</option>'; |
|
406 | 406 | } |
407 | 407 | $field .= '</select>'; |
408 | 408 | |
@@ -420,38 +420,38 @@ discard block |
||
420 | 420 | * @param string $question_groups |
421 | 421 | * @return string HTML |
422 | 422 | */ |
423 | - static function generate_question_groups_html( $question_groups = array(), $group_wrapper = 'fieldset' ) { |
|
423 | + static function generate_question_groups_html($question_groups = array(), $group_wrapper = 'fieldset') { |
|
424 | 424 | |
425 | 425 | $html = ''; |
426 | - $before_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '' ); |
|
427 | - $after_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '' ); |
|
426 | + $before_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', ''); |
|
427 | + $after_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', ''); |
|
428 | 428 | |
429 | - if ( ! empty( $question_groups )) { |
|
429 | + if ( ! empty($question_groups)) { |
|
430 | 430 | //EEH_Debug_Tools::printr( $question_groups, '$question_groups <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
431 | 431 | // loop thru question groups |
432 | - foreach ( $question_groups as $QSG ) { |
|
432 | + foreach ($question_groups as $QSG) { |
|
433 | 433 | // check that questions exist |
434 | - if ( ! empty( $QSG['QSG_questions'] )) { |
|
434 | + if ( ! empty($QSG['QSG_questions'])) { |
|
435 | 435 | // use fieldsets |
436 | - $html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG['QSG_identifier'] . '">'; |
|
436 | + $html .= "\n\t".'<'.$group_wrapper.' class="espresso-question-group-wrap" id="'.$QSG['QSG_identifier'].'">'; |
|
437 | 437 | // group_name |
438 | - $html .= $QSG['QSG_show_group_name'] ? "\n\t\t" . '<h5 class="espresso-question-group-title-h5 section-title">' . self::prep_answer( $QSG['QSG_name'] ) . '</h5>' : ''; |
|
438 | + $html .= $QSG['QSG_show_group_name'] ? "\n\t\t".'<h5 class="espresso-question-group-title-h5 section-title">'.self::prep_answer($QSG['QSG_name']).'</h5>' : ''; |
|
439 | 439 | // group_desc |
440 | - $html .= $QSG['QSG_show_group_desc'] && ! empty( $QSG['QSG_desc'] ) ? '<div class="espresso-question-group-desc-pg">' . self::prep_answer( $QSG['QSG_desc'] ) . '</div>' : ''; |
|
440 | + $html .= $QSG['QSG_show_group_desc'] && ! empty($QSG['QSG_desc']) ? '<div class="espresso-question-group-desc-pg">'.self::prep_answer($QSG['QSG_desc']).'</div>' : ''; |
|
441 | 441 | |
442 | 442 | $html .= $before_question_group_questions; |
443 | 443 | // loop thru questions |
444 | - foreach ( $QSG['QSG_questions'] as $question ) { |
|
444 | + foreach ($QSG['QSG_questions'] as $question) { |
|
445 | 445 | // EEH_Debug_Tools::printr( $question, '$question <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
446 | 446 | $QFI = new EE_Question_Form_Input( |
447 | 447 | $question['qst_obj'], |
448 | 448 | $question['ans_obj'], |
449 | 449 | $question |
450 | 450 | ); |
451 | - $html .= self::generate_form_input( $QFI ); |
|
451 | + $html .= self::generate_form_input($QFI); |
|
452 | 452 | } |
453 | 453 | $html .= $after_question_group_questions; |
454 | - $html .= "\n\t" . '</' . $group_wrapper . '>'; |
|
454 | + $html .= "\n\t".'</'.$group_wrapper.'>'; |
|
455 | 455 | } |
456 | 456 | } |
457 | 457 | } |
@@ -471,11 +471,11 @@ discard block |
||
471 | 471 | * @param string $group_wrapper |
472 | 472 | * @return string HTML |
473 | 473 | */ |
474 | - static function generate_question_groups_html2( $question_groups = array(), $q_meta = array(), $from_admin = FALSE, $group_wrapper = 'fieldset' ) { |
|
474 | + static function generate_question_groups_html2($question_groups = array(), $q_meta = array(), $from_admin = FALSE, $group_wrapper = 'fieldset') { |
|
475 | 475 | |
476 | 476 | $html = ''; |
477 | - $before_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '' ); |
|
478 | - $after_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '' ); |
|
477 | + $before_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', ''); |
|
478 | + $after_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', ''); |
|
479 | 479 | |
480 | 480 | $default_q_meta = array( |
481 | 481 | 'att_nmbr' => 1, |
@@ -484,55 +484,55 @@ discard block |
||
484 | 484 | 'input_id' => '', |
485 | 485 | 'input_class' => '' |
486 | 486 | ); |
487 | - $q_meta = array_merge( $default_q_meta, $q_meta ); |
|
487 | + $q_meta = array_merge($default_q_meta, $q_meta); |
|
488 | 488 | //EEH_Debug_Tools::printr( $q_meta, '$q_meta <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
489 | 489 | |
490 | - if ( ! empty( $question_groups )) { |
|
490 | + if ( ! empty($question_groups)) { |
|
491 | 491 | // EEH_Debug_Tools::printr( $question_groups, '$question_groups <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
492 | 492 | // loop thru question groups |
493 | - foreach ( $question_groups as $QSG ) { |
|
494 | - if ( $QSG instanceof EE_Question_Group ) { |
|
493 | + foreach ($question_groups as $QSG) { |
|
494 | + if ($QSG instanceof EE_Question_Group) { |
|
495 | 495 | // check that questions exist |
496 | 496 | |
497 | - $where = array( 'QST_deleted' => 0 ); |
|
498 | - if ( ! $from_admin ) { |
|
497 | + $where = array('QST_deleted' => 0); |
|
498 | + if ( ! $from_admin) { |
|
499 | 499 | $where['QST_admin_only'] = 0; |
500 | 500 | } |
501 | - $questions = $QSG->questions( array( $where, 'order_by' => array( 'Question_Group_Question.QGQ_order' => 'ASC' ))); |
|
502 | - if ( ! empty( $questions )) { |
|
501 | + $questions = $QSG->questions(array($where, 'order_by' => array('Question_Group_Question.QGQ_order' => 'ASC'))); |
|
502 | + if ( ! empty($questions)) { |
|
503 | 503 | // use fieldsets |
504 | - $html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG->get( 'QSG_identifier' ) . '">'; |
|
504 | + $html .= "\n\t".'<'.$group_wrapper.' class="espresso-question-group-wrap" id="'.$QSG->get('QSG_identifier').'">'; |
|
505 | 505 | // group_name |
506 | - if ( $QSG->show_group_name() ) { |
|
507 | - $html .= "\n\t\t" . '<h5 class="espresso-question-group-title-h5 section-title">' . $QSG->get_pretty( 'QSG_name' ) . '</h5>'; |
|
506 | + if ($QSG->show_group_name()) { |
|
507 | + $html .= "\n\t\t".'<h5 class="espresso-question-group-title-h5 section-title">'.$QSG->get_pretty('QSG_name').'</h5>'; |
|
508 | 508 | } |
509 | 509 | // group_desc |
510 | - if ( $QSG->show_group_desc() ) { |
|
511 | - $html .= '<div class="espresso-question-group-desc-pg">' . $QSG->get_pretty( 'QSG_desc' ) . '</div>'; |
|
510 | + if ($QSG->show_group_desc()) { |
|
511 | + $html .= '<div class="espresso-question-group-desc-pg">'.$QSG->get_pretty('QSG_desc').'</div>'; |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | $html .= $before_question_group_questions; |
515 | 515 | // loop thru questions |
516 | - foreach ( $questions as $QST ) { |
|
516 | + foreach ($questions as $QST) { |
|
517 | 517 | $qstn_id = $QST->is_system_question() ? $QST->system_ID() : $QST->ID(); |
518 | 518 | |
519 | 519 | $answer = NULL; |
520 | 520 | |
521 | - if ( isset( $_GET['qstn'] ) && isset( $q_meta['input_id'] ) && isset( $q_meta['att_nmbr'] )) { |
|
521 | + if (isset($_GET['qstn']) && isset($q_meta['input_id']) && isset($q_meta['att_nmbr'])) { |
|
522 | 522 | // check for answer in $_GET in case we are reprocessing a form after an error |
523 | - if ( isset( $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] )) { |
|
524 | - $answer = is_array( $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] ) ? $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] : sanitize_text_field( $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] ); |
|
523 | + if (isset($_GET['qstn'][$q_meta['input_id']][$qstn_id])) { |
|
524 | + $answer = is_array($_GET['qstn'][$q_meta['input_id']][$qstn_id]) ? $_GET['qstn'][$q_meta['input_id']][$qstn_id] : sanitize_text_field($_GET['qstn'][$q_meta['input_id']][$qstn_id]); |
|
525 | 525 | } |
526 | - } else if ( isset( $q_meta['attendee'] ) && $q_meta['attendee'] ) { |
|
526 | + } else if (isset($q_meta['attendee']) && $q_meta['attendee']) { |
|
527 | 527 | //attendee data from the session |
528 | - $answer = isset( $q_meta['attendee'][ $qstn_id ] ) ? $q_meta['attendee'][ $qstn_id ] : NULL; |
|
528 | + $answer = isset($q_meta['attendee'][$qstn_id]) ? $q_meta['attendee'][$qstn_id] : NULL; |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | |
532 | 532 | |
533 | 533 | $QFI = new EE_Question_Form_Input( |
534 | 534 | $QST, |
535 | - EE_Answer::new_instance ( array( |
|
535 | + EE_Answer::new_instance(array( |
|
536 | 536 | 'ANS_ID'=> 0, |
537 | 537 | 'QST_ID'=> 0, |
538 | 538 | 'REG_ID'=> 0, |
@@ -541,10 +541,10 @@ discard block |
||
541 | 541 | $q_meta |
542 | 542 | ); |
543 | 543 | //EEH_Debug_Tools::printr( $QFI, '$QFI <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
544 | - $html .= self::generate_form_input( $QFI ); |
|
544 | + $html .= self::generate_form_input($QFI); |
|
545 | 545 | } |
546 | 546 | $html .= $after_question_group_questions; |
547 | - $html .= "\n\t" . '</' . $group_wrapper . '>'; |
|
547 | + $html .= "\n\t".'</'.$group_wrapper.'>'; |
|
548 | 548 | } |
549 | 549 | } |
550 | 550 | } |
@@ -564,63 +564,63 @@ discard block |
||
564 | 564 | * @param EE_Question_Form_Input $QFI |
565 | 565 | * @return string HTML |
566 | 566 | */ |
567 | - static function generate_form_input( EE_Question_Form_Input $QFI ) { |
|
568 | - if ( isset( $QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin() ) { |
|
567 | + static function generate_form_input(EE_Question_Form_Input $QFI) { |
|
568 | + if (isset($QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin()) { |
|
569 | 569 | return ''; |
570 | 570 | } |
571 | 571 | |
572 | - $QFI = self::_load_system_dropdowns( $QFI ); |
|
573 | - $QFI = self::_load_specialized_dropdowns( $QFI ); |
|
572 | + $QFI = self::_load_system_dropdowns($QFI); |
|
573 | + $QFI = self::_load_specialized_dropdowns($QFI); |
|
574 | 574 | |
575 | 575 | //we also need to verify |
576 | 576 | |
577 | 577 | $display_text = $QFI->get('QST_display_text'); |
578 | 578 | $input_name = $QFI->get('QST_input_name'); |
579 | - $answer = EE_Registry::instance()->REQ->is_set( $input_name ) ? EE_Registry::instance()->REQ->get( $input_name ) : $QFI->get('ANS_value'); |
|
579 | + $answer = EE_Registry::instance()->REQ->is_set($input_name) ? EE_Registry::instance()->REQ->get($input_name) : $QFI->get('ANS_value'); |
|
580 | 580 | $input_id = $QFI->get('QST_input_id'); |
581 | 581 | $input_class = $QFI->get('QST_input_class'); |
582 | 582 | // $disabled = $QFI->get('QST_disabled') ? ' disabled="disabled"' : ''; |
583 | 583 | $disabled = $QFI->get('QST_disabled') ? TRUE : FALSE; |
584 | - $required_label = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>' ); |
|
584 | + $required_label = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>'); |
|
585 | 585 | $QST_required = $QFI->get('QST_required'); |
586 | - $required = $QST_required ? array( 'label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required ) : array(); |
|
587 | - $use_html_entities = $QFI->get_meta( 'htmlentities' ); |
|
588 | - $required_text = $QFI->get('QST_required_text') != '' ? $QFI->get('QST_required_text') : __( 'This field is required', 'event_espresso' ); |
|
589 | - $required_text = $QST_required ? "\n\t\t\t" . '<div class="required-text hidden">' . self::prep_answer( $required_text, $use_html_entities ) . '</div>' : ''; |
|
586 | + $required = $QST_required ? array('label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required) : array(); |
|
587 | + $use_html_entities = $QFI->get_meta('htmlentities'); |
|
588 | + $required_text = $QFI->get('QST_required_text') != '' ? $QFI->get('QST_required_text') : __('This field is required', 'event_espresso'); |
|
589 | + $required_text = $QST_required ? "\n\t\t\t".'<div class="required-text hidden">'.self::prep_answer($required_text, $use_html_entities).'</div>' : ''; |
|
590 | 590 | $label_class = 'espresso-form-input-lbl'; |
591 | - $QST_options = $QFI->options(true,$answer); |
|
592 | - $options = is_array( $QST_options ) ? self::prep_answer_options( $QST_options ) : array(); |
|
591 | + $QST_options = $QFI->options(true, $answer); |
|
592 | + $options = is_array($QST_options) ? self::prep_answer_options($QST_options) : array(); |
|
593 | 593 | $system_ID = $QFI->get('QST_system'); |
594 | - $label_b4 = $QFI->get_meta( 'label_b4' ); |
|
595 | - $use_desc_4_label = $QFI->get_meta( 'use_desc_4_label' ); |
|
594 | + $label_b4 = $QFI->get_meta('label_b4'); |
|
595 | + $use_desc_4_label = $QFI->get_meta('use_desc_4_label'); |
|
596 | 596 | |
597 | 597 | |
598 | - switch ( $QFI->get('QST_type') ){ |
|
598 | + switch ($QFI->get('QST_type')) { |
|
599 | 599 | |
600 | 600 | case 'TEXTAREA' : |
601 | - return EEH_Form_Fields::textarea( $display_text, $answer, $input_name, $input_id, $input_class, array(), $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities ); |
|
601 | + return EEH_Form_Fields::textarea($display_text, $answer, $input_name, $input_id, $input_class, array(), $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities); |
|
602 | 602 | break; |
603 | 603 | |
604 | 604 | case 'DROPDOWN' : |
605 | - return EEH_Form_Fields::select( $display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, TRUE ); |
|
605 | + return EEH_Form_Fields::select($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, TRUE); |
|
606 | 606 | break; |
607 | 607 | |
608 | 608 | |
609 | 609 | case 'RADIO_BTN' : |
610 | - return EEH_Form_Fields::radio( $display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, $label_b4, $use_desc_4_label ); |
|
610 | + return EEH_Form_Fields::radio($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, $label_b4, $use_desc_4_label); |
|
611 | 611 | break; |
612 | 612 | |
613 | 613 | case 'CHECKBOX' : |
614 | - return EEH_Form_Fields::checkbox( $display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $label_b4, $system_ID, $use_html_entities ); |
|
614 | + return EEH_Form_Fields::checkbox($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $label_b4, $system_ID, $use_html_entities); |
|
615 | 615 | break; |
616 | 616 | |
617 | 617 | case 'DATE' : |
618 | - return EEH_Form_Fields::datepicker( $display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities ); |
|
618 | + return EEH_Form_Fields::datepicker($display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities); |
|
619 | 619 | break; |
620 | 620 | |
621 | 621 | case 'TEXT' : |
622 | 622 | default: |
623 | - return EEH_Form_Fields::text( $display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities ); |
|
623 | + return EEH_Form_Fields::text($display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities); |
|
624 | 624 | break; |
625 | 625 | |
626 | 626 | } |
@@ -646,31 +646,31 @@ discard block |
||
646 | 646 | * @param string $disabled disabled="disabled" or null |
647 | 647 | * @return string HTML |
648 | 648 | */ |
649 | - static function text( $question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
649 | + static function text($question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
650 | 650 | // need these |
651 | - if ( ! $question || ! $name ) { |
|
651 | + if ( ! $question || ! $name) { |
|
652 | 652 | return NULL; |
653 | 653 | } |
654 | 654 | // prep the answer |
655 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
655 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
656 | 656 | // prep the required array |
657 | - $required = self::prep_required( $required ); |
|
657 | + $required = self::prep_required($required); |
|
658 | 658 | // set disabled tag |
659 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
659 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
660 | 660 | // ya gots ta have style man!!! |
661 | 661 | $txt_class = is_admin() ? 'regular-text' : 'espresso-text-inp'; |
662 | - $class = empty( $class ) ? $txt_class : $class; |
|
663 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
664 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
662 | + $class = empty($class) ? $txt_class : $class; |
|
663 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
664 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
665 | 665 | |
666 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
666 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
667 | 667 | // filter label but ensure required text comes before it |
668 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
668 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
669 | 669 | |
670 | - $input_html = "\n\t\t\t" . '<input type="text" name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" value="' . esc_attr( $answer ) . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled .' ' . $extra . '/>'; |
|
670 | + $input_html = "\n\t\t\t".'<input type="text" name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" value="'.esc_attr($answer).'" title="'.esc_attr($required['msg']).'" '.$disabled.' '.$extra.'/>'; |
|
671 | 671 | |
672 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
673 | - return $label_html . $input_html; |
|
672 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
673 | + return $label_html.$input_html; |
|
674 | 674 | |
675 | 675 | } |
676 | 676 | |
@@ -692,35 +692,35 @@ discard block |
||
692 | 692 | * @param string $disabled disabled="disabled" or null |
693 | 693 | * @return string HTML |
694 | 694 | */ |
695 | - static function textarea( $question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $dimensions = FALSE, $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
695 | + static function textarea($question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $dimensions = FALSE, $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
696 | 696 | // need these |
697 | - if ( ! $question || ! $name ) { |
|
697 | + if ( ! $question || ! $name) { |
|
698 | 698 | return NULL; |
699 | 699 | } |
700 | 700 | // prep the answer |
701 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
701 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
702 | 702 | // prep the required array |
703 | - $required = self::prep_required( $required ); |
|
703 | + $required = self::prep_required($required); |
|
704 | 704 | // make sure $dimensions is an array |
705 | - $dimensions = is_array( $dimensions ) ? $dimensions : array(); |
|
705 | + $dimensions = is_array($dimensions) ? $dimensions : array(); |
|
706 | 706 | // and set some defaults |
707 | - $dimensions = array_merge( array( 'rows' => 3, 'cols' => 40 ), $dimensions ); |
|
707 | + $dimensions = array_merge(array('rows' => 3, 'cols' => 40), $dimensions); |
|
708 | 708 | // set disabled tag |
709 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
709 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
710 | 710 | // ya gots ta have style man!!! |
711 | 711 | $txt_class = is_admin() ? 'regular-text' : 'espresso-textarea-inp'; |
712 | - $class = empty( $class ) ? $txt_class : $class; |
|
713 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
714 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
712 | + $class = empty($class) ? $txt_class : $class; |
|
713 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
714 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
715 | 715 | |
716 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
716 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
717 | 717 | // filter label but ensure required text comes before it |
718 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
718 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
719 | 719 | |
720 | - $input_html = "\n\t\t\t" . '<textarea name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" rows="' . $dimensions['rows'] . '" cols="' . $dimensions['cols'] . '" title="' . $required['msg'] . '" ' . $disabled . ' ' . $extra . '>' . $answer . '</textarea>'; |
|
720 | + $input_html = "\n\t\t\t".'<textarea name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" rows="'.$dimensions['rows'].'" cols="'.$dimensions['cols'].'" title="'.$required['msg'].'" '.$disabled.' '.$extra.'>'.$answer.'</textarea>'; |
|
721 | 721 | |
722 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
723 | - return $label_html . $input_html; |
|
722 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
723 | + return $label_html.$input_html; |
|
724 | 724 | |
725 | 725 | } |
726 | 726 | |
@@ -743,47 +743,47 @@ discard block |
||
743 | 743 | * @param string $disabled disabled="disabled" or null |
744 | 744 | * @return string HTML |
745 | 745 | */ |
746 | - static function select( $question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $add_please_select_option = FALSE ) { |
|
746 | + static function select($question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $add_please_select_option = FALSE) { |
|
747 | 747 | |
748 | 748 | // need these |
749 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
749 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
750 | 750 | return NULL; |
751 | 751 | } |
752 | 752 | // prep the answer |
753 | - $answer = is_array( $answer ) ? self::prep_answer( array_shift( $answer ), $use_html_entities) : self::prep_answer( $answer, $use_html_entities ); |
|
753 | + $answer = is_array($answer) ? self::prep_answer(array_shift($answer), $use_html_entities) : self::prep_answer($answer, $use_html_entities); |
|
754 | 754 | // prep the required array |
755 | - $required = self::prep_required( $required ); |
|
755 | + $required = self::prep_required($required); |
|
756 | 756 | // set disabled tag |
757 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
757 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
758 | 758 | // ya gots ta have style man!!! |
759 | 759 | $txt_class = is_admin() ? 'wide' : 'espresso-select-inp'; |
760 | - $class = empty( $class ) ? $txt_class : $class; |
|
761 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
762 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
760 | + $class = empty($class) ? $txt_class : $class; |
|
761 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
762 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
763 | 763 | |
764 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
764 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
765 | 765 | // filter label but ensure required text comes before it |
766 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
766 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
767 | 767 | |
768 | - $input_html = "\n\t\t\t" . '<select name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" title="' . esc_attr( $required['msg'] ) . '"' . $disabled . ' ' . $extra . '>'; |
|
768 | + $input_html = "\n\t\t\t".'<select name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" title="'.esc_attr($required['msg']).'"'.$disabled.' '.$extra.'>'; |
|
769 | 769 | // recursively count array elements, to determine total number of options |
770 | - $only_option = count( $options, 1 ) == 1 ? TRUE : FALSE; |
|
771 | - if ( ! $only_option ) { |
|
770 | + $only_option = count($options, 1) == 1 ? TRUE : FALSE; |
|
771 | + if ( ! $only_option) { |
|
772 | 772 | // if there is NO answer set and there are multiple options to choose from, then set the "please select" message as selected |
773 | 773 | $selected = $answer === NULL ? ' selected="selected"' : ''; |
774 | - $input_html .= $add_please_select_option ? "\n\t\t\t\t" . '<option value=""' . $selected . '>' . __(' - please select - ', 'event_espresso') . '</option>' : ''; |
|
774 | + $input_html .= $add_please_select_option ? "\n\t\t\t\t".'<option value=""'.$selected.'>'.__(' - please select - ', 'event_espresso').'</option>' : ''; |
|
775 | 775 | } |
776 | - foreach ( $options as $key => $value ) { |
|
776 | + foreach ($options as $key => $value) { |
|
777 | 777 | // if value is an array, then create option groups, else create regular ol' options |
778 | - $input_html .= is_array( $value ) ? self::_generate_select_option_group( $key, $value, $answer, $use_html_entities ) : self::_generate_select_option( $value->value(), $value->desc(), $answer, $only_option, $use_html_entities ); |
|
778 | + $input_html .= is_array($value) ? self::_generate_select_option_group($key, $value, $answer, $use_html_entities) : self::_generate_select_option($value->value(), $value->desc(), $answer, $only_option, $use_html_entities); |
|
779 | 779 | } |
780 | 780 | |
781 | - $input_html .= "\n\t\t\t" . '</select>'; |
|
781 | + $input_html .= "\n\t\t\t".'</select>'; |
|
782 | 782 | |
783 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__select__before_end_wrapper', $input_html, $question, $answer, $name, $id, $class, $system_ID ); |
|
783 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__select__before_end_wrapper', $input_html, $question, $answer, $name, $id, $class, $system_ID); |
|
784 | 784 | |
785 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
786 | - return $label_html . $input_html; |
|
785 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
786 | + return $label_html.$input_html; |
|
787 | 787 | |
788 | 788 | } |
789 | 789 | |
@@ -801,12 +801,12 @@ discard block |
||
801 | 801 | * @param boolean $use_html_entities |
802 | 802 | * @return string |
803 | 803 | */ |
804 | - private static function _generate_select_option_group( $opt_group, $QSOs, $answer, $use_html_entities = true ){ |
|
805 | - $html = "\n\t\t\t\t" . '<optgroup label="' . self::prep_option_value( $opt_group ) . '">'; |
|
806 | - foreach ( $QSOs as $QSO ) { |
|
807 | - $html .= self::_generate_select_option( $QSO->value(), $QSO->desc(), $answer, false, $use_html_entities ); |
|
804 | + private static function _generate_select_option_group($opt_group, $QSOs, $answer, $use_html_entities = true) { |
|
805 | + $html = "\n\t\t\t\t".'<optgroup label="'.self::prep_option_value($opt_group).'">'; |
|
806 | + foreach ($QSOs as $QSO) { |
|
807 | + $html .= self::_generate_select_option($QSO->value(), $QSO->desc(), $answer, false, $use_html_entities); |
|
808 | 808 | } |
809 | - $html .= "\n\t\t\t\t" . '</optgroup>'; |
|
809 | + $html .= "\n\t\t\t\t".'</optgroup>'; |
|
810 | 810 | return $html; |
811 | 811 | } |
812 | 812 | |
@@ -821,12 +821,12 @@ discard block |
||
821 | 821 | * @param boolean $use_html_entities |
822 | 822 | * @return string |
823 | 823 | */ |
824 | - private static function _generate_select_option( $key, $value, $answer, $only_option = FALSE, $use_html_entities = true ){ |
|
825 | - $key = self::prep_answer( $key, $use_html_entities ); |
|
826 | - $value = self::prep_answer( $value, $use_html_entities ); |
|
827 | - $value = ! empty( $value ) ? $value : $key; |
|
828 | - $selected = ( $answer == $key || $only_option ) ? ' selected="selected"' : ''; |
|
829 | - return "\n\t\t\t\t" . '<option value="' . self::prep_option_value( $key ) . '"' . $selected . '> ' . $value . ' </option>'; |
|
824 | + private static function _generate_select_option($key, $value, $answer, $only_option = FALSE, $use_html_entities = true) { |
|
825 | + $key = self::prep_answer($key, $use_html_entities); |
|
826 | + $value = self::prep_answer($value, $use_html_entities); |
|
827 | + $value = ! empty($value) ? $value : $key; |
|
828 | + $selected = ($answer == $key || $only_option) ? ' selected="selected"' : ''; |
|
829 | + return "\n\t\t\t\t".'<option value="'.self::prep_option_value($key).'"'.$selected.'> '.$value.' </option>'; |
|
830 | 830 | } |
831 | 831 | |
832 | 832 | |
@@ -850,56 +850,56 @@ discard block |
||
850 | 850 | * @param bool $use_desc_4_label |
851 | 851 | * @return string HTML |
852 | 852 | */ |
853 | - static function radio( $question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $label_b4 = FALSE, $use_desc_4_label = FALSE ) { |
|
853 | + static function radio($question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $label_b4 = FALSE, $use_desc_4_label = FALSE) { |
|
854 | 854 | // need these |
855 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
855 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
856 | 856 | return NULL; |
857 | 857 | } |
858 | 858 | // prep the answer |
859 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
859 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
860 | 860 | // prep the required array |
861 | - $required = self::prep_required( $required ); |
|
861 | + $required = self::prep_required($required); |
|
862 | 862 | // set disabled tag |
863 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
863 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
864 | 864 | // ya gots ta have style man!!! |
865 | 865 | $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class; |
866 | - $class = ! empty( $class ) ? $class : 'espresso-radio-btn-inp'; |
|
867 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
866 | + $class = ! empty($class) ? $class : 'espresso-radio-btn-inp'; |
|
867 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
868 | 868 | |
869 | - $label_html = $required_text . "\n\t\t\t" . '<label class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label> '; |
|
869 | + $label_html = $required_text."\n\t\t\t".'<label class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label> '; |
|
870 | 870 | // filter label but ensure required text comes before it |
871 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
871 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
872 | 872 | |
873 | - $input_html = "\n\t\t\t" . '<ul id="' . $id . '-ul" class="espresso-radio-btn-options-ul ' . $label_class . ' ' . $class . '-ul">'; |
|
873 | + $input_html = "\n\t\t\t".'<ul id="'.$id.'-ul" class="espresso-radio-btn-options-ul '.$label_class.' '.$class.'-ul">'; |
|
874 | 874 | |
875 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
876 | - $class .= ! empty( $required['class'] ) ? ' ' . $required['class'] : ''; |
|
875 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
876 | + $class .= ! empty($required['class']) ? ' '.$required['class'] : ''; |
|
877 | 877 | |
878 | - foreach ( $options as $OPT ) { |
|
879 | - if ( $OPT instanceof EE_Question_Option ) { |
|
880 | - $value = self::prep_option_value( $OPT->value() ); |
|
878 | + foreach ($options as $OPT) { |
|
879 | + if ($OPT instanceof EE_Question_Option) { |
|
880 | + $value = self::prep_option_value($OPT->value()); |
|
881 | 881 | $label = $use_desc_4_label ? $OPT->desc() : $OPT->value(); |
882 | - $size = $use_desc_4_label ? self::get_label_size_class( $OPT->value() . ' ' . $OPT->desc() ) : self::get_label_size_class( $OPT->value() ); |
|
883 | - $desc = $OPT->desc();//no self::prep_answer |
|
884 | - $answer = is_numeric( $value ) && empty( $answer ) ? 0 : $answer; |
|
885 | - $checked = (string)$value == (string)$answer ? ' checked="checked"' : ''; |
|
886 | - $opt = '-' . sanitize_key( $value ); |
|
887 | - |
|
888 | - $input_html .= "\n\t\t\t\t" . '<li' . $size . '>'; |
|
889 | - $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-radio-btn-lbl">'; |
|
890 | - $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $label . '</span>' : ''; |
|
891 | - $input_html .= "\n\t\t\t\t\t\t" . '<input type="radio" name="' . $name . '" id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled . $checked . ' ' . $extra . '/>'; |
|
892 | - $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '<span class="espresso-radio-btn-desc">' . $label . '</span>' : ''; |
|
893 | - $input_html .= "\n\t\t\t\t\t" . '</label>'; |
|
894 | - $input_html .= $use_desc_4_label ? '' : '<span class="espresso-radio-btn-option-desc small-text grey-text">' . $desc . '</span>'; |
|
895 | - $input_html .= "\n\t\t\t\t" . '</li>'; |
|
882 | + $size = $use_desc_4_label ? self::get_label_size_class($OPT->value().' '.$OPT->desc()) : self::get_label_size_class($OPT->value()); |
|
883 | + $desc = $OPT->desc(); //no self::prep_answer |
|
884 | + $answer = is_numeric($value) && empty($answer) ? 0 : $answer; |
|
885 | + $checked = (string) $value == (string) $answer ? ' checked="checked"' : ''; |
|
886 | + $opt = '-'.sanitize_key($value); |
|
887 | + |
|
888 | + $input_html .= "\n\t\t\t\t".'<li'.$size.'>'; |
|
889 | + $input_html .= "\n\t\t\t\t\t".'<label class="'.$radio_class.' espresso-radio-btn-lbl">'; |
|
890 | + $input_html .= $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$label.'</span>' : ''; |
|
891 | + $input_html .= "\n\t\t\t\t\t\t".'<input type="radio" name="'.$name.'" id="'.$id.$opt.'" class="'.$class.'" value="'.$value.'" title="'.esc_attr($required['msg']).'" '.$disabled.$checked.' '.$extra.'/>'; |
|
892 | + $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t".'<span class="espresso-radio-btn-desc">'.$label.'</span>' : ''; |
|
893 | + $input_html .= "\n\t\t\t\t\t".'</label>'; |
|
894 | + $input_html .= $use_desc_4_label ? '' : '<span class="espresso-radio-btn-option-desc small-text grey-text">'.$desc.'</span>'; |
|
895 | + $input_html .= "\n\t\t\t\t".'</li>'; |
|
896 | 896 | } |
897 | 897 | } |
898 | 898 | |
899 | - $input_html .= "\n\t\t\t" . '</ul>'; |
|
899 | + $input_html .= "\n\t\t\t".'</ul>'; |
|
900 | 900 | |
901 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
902 | - return $label_html . $input_html; |
|
901 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
902 | + return $label_html.$input_html; |
|
903 | 903 | |
904 | 904 | } |
905 | 905 | |
@@ -922,65 +922,65 @@ discard block |
||
922 | 922 | * @param string $disabled disabled="disabled" or null |
923 | 923 | * @return string HTML |
924 | 924 | */ |
925 | - static function checkbox( $question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $label_b4 = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
925 | + static function checkbox($question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $label_b4 = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
926 | 926 | // need these |
927 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
927 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
928 | 928 | return NULL; |
929 | 929 | } |
930 | - $answer = maybe_unserialize( $answer ); |
|
930 | + $answer = maybe_unserialize($answer); |
|
931 | 931 | |
932 | 932 | // prep the answer(s) |
933 | - $answer = is_array( $answer ) ? $answer : array( sanitize_key( $answer ) => $answer ); |
|
933 | + $answer = is_array($answer) ? $answer : array(sanitize_key($answer) => $answer); |
|
934 | 934 | |
935 | - foreach ( $answer as $key => $value ) { |
|
936 | - $key = self::prep_option_value( $key ); |
|
937 | - $answer[$key] = self::prep_answer( $value, $use_html_entities ); |
|
935 | + foreach ($answer as $key => $value) { |
|
936 | + $key = self::prep_option_value($key); |
|
937 | + $answer[$key] = self::prep_answer($value, $use_html_entities); |
|
938 | 938 | } |
939 | 939 | |
940 | 940 | // prep the required array |
941 | - $required = self::prep_required( $required ); |
|
941 | + $required = self::prep_required($required); |
|
942 | 942 | // set disabled tag |
943 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
943 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
944 | 944 | // ya gots ta have style man!!! |
945 | 945 | $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class; |
946 | - $class = empty( $class ) ? 'espresso-radio-btn-inp' : $class; |
|
947 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
946 | + $class = empty($class) ? 'espresso-radio-btn-inp' : $class; |
|
947 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
948 | 948 | |
949 | - $label_html = $required_text . "\n\t\t\t" . '<label class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label> '; |
|
949 | + $label_html = $required_text."\n\t\t\t".'<label class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label> '; |
|
950 | 950 | // filter label but ensure required text comes before it |
951 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
952 | - |
|
953 | - $input_html = "\n\t\t\t" . '<ul id="' . $id . '-ul" class="espresso-checkbox-options-ul ' . $label_class . ' ' . $class . '-ul">'; |
|
954 | - |
|
955 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
956 | - $class .= ! empty( $required['class'] ) ? ' ' . $required['class'] : ''; |
|
957 | - |
|
958 | - foreach ( $options as $OPT ) { |
|
959 | - $value = $OPT->value();//self::prep_option_value( $OPT->value() ); |
|
960 | - $size = self::get_label_size_class( $OPT->value() . ' ' . $OPT->desc() ); |
|
961 | - $text = self::prep_answer( $OPT->value() ); |
|
962 | - $desc = $OPT->desc() ; |
|
963 | - $opt = '-' . sanitize_key( $value ); |
|
964 | - |
|
965 | - $checked = is_array( $answer ) && in_array( $text, $answer ) ? ' checked="checked"' : ''; |
|
966 | - |
|
967 | - $input_html .= "\n\t\t\t\t" . '<li' . $size . '>'; |
|
968 | - $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-checkbox-lbl">'; |
|
969 | - $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : ''; |
|
970 | - $input_html .= "\n\t\t\t\t\t\t" . '<input type="checkbox" name="' . $name . '[' . $OPT->ID() . ']" id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled . $checked . ' ' . $extra . '/>'; |
|
971 | - $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : ''; |
|
972 | - $input_html .= "\n\t\t\t\t\t" . '</label>'; |
|
973 | - if ( ! empty( $desc ) && $desc != $text ) { |
|
974 | - $input_html .= "\n\t\t\t\t\t" . ' <br/><div class="espresso-checkbox-option-desc small-text grey-text">' . $desc . '</div>'; |
|
951 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
952 | + |
|
953 | + $input_html = "\n\t\t\t".'<ul id="'.$id.'-ul" class="espresso-checkbox-options-ul '.$label_class.' '.$class.'-ul">'; |
|
954 | + |
|
955 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
956 | + $class .= ! empty($required['class']) ? ' '.$required['class'] : ''; |
|
957 | + |
|
958 | + foreach ($options as $OPT) { |
|
959 | + $value = $OPT->value(); //self::prep_option_value( $OPT->value() ); |
|
960 | + $size = self::get_label_size_class($OPT->value().' '.$OPT->desc()); |
|
961 | + $text = self::prep_answer($OPT->value()); |
|
962 | + $desc = $OPT->desc(); |
|
963 | + $opt = '-'.sanitize_key($value); |
|
964 | + |
|
965 | + $checked = is_array($answer) && in_array($text, $answer) ? ' checked="checked"' : ''; |
|
966 | + |
|
967 | + $input_html .= "\n\t\t\t\t".'<li'.$size.'>'; |
|
968 | + $input_html .= "\n\t\t\t\t\t".'<label class="'.$radio_class.' espresso-checkbox-lbl">'; |
|
969 | + $input_html .= $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$text.'</span>' : ''; |
|
970 | + $input_html .= "\n\t\t\t\t\t\t".'<input type="checkbox" name="'.$name.'['.$OPT->ID().']" id="'.$id.$opt.'" class="'.$class.'" value="'.$value.'" title="'.esc_attr($required['msg']).'" '.$disabled.$checked.' '.$extra.'/>'; |
|
971 | + $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$text.'</span>' : ''; |
|
972 | + $input_html .= "\n\t\t\t\t\t".'</label>'; |
|
973 | + if ( ! empty($desc) && $desc != $text) { |
|
974 | + $input_html .= "\n\t\t\t\t\t".' <br/><div class="espresso-checkbox-option-desc small-text grey-text">'.$desc.'</div>'; |
|
975 | 975 | } |
976 | - $input_html .= "\n\t\t\t\t" . '</li>'; |
|
976 | + $input_html .= "\n\t\t\t\t".'</li>'; |
|
977 | 977 | |
978 | 978 | } |
979 | 979 | |
980 | - $input_html .= "\n\t\t\t" . '</ul>'; |
|
980 | + $input_html .= "\n\t\t\t".'</ul>'; |
|
981 | 981 | |
982 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
983 | - return $label_html . $input_html; |
|
982 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
983 | + return $label_html.$input_html; |
|
984 | 984 | |
985 | 985 | } |
986 | 986 | |
@@ -1002,36 +1002,36 @@ discard block |
||
1002 | 1002 | * @param string $disabled disabled="disabled" or null |
1003 | 1003 | * @return string HTML |
1004 | 1004 | */ |
1005 | - static function datepicker( $question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
1005 | + static function datepicker($question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
1006 | 1006 | // need these |
1007 | - if ( ! $question || ! $name ) { |
|
1007 | + if ( ! $question || ! $name) { |
|
1008 | 1008 | return NULL; |
1009 | 1009 | } |
1010 | 1010 | // prep the answer |
1011 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
1011 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
1012 | 1012 | // prep the required array |
1013 | - $required = self::prep_required( $required ); |
|
1013 | + $required = self::prep_required($required); |
|
1014 | 1014 | // set disabled tag |
1015 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
1015 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
1016 | 1016 | // ya gots ta have style man!!! |
1017 | 1017 | $txt_class = is_admin() ? 'regular-text' : 'espresso-datepicker-inp'; |
1018 | - $class = empty( $class ) ? $txt_class : $class; |
|
1019 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
1020 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
1018 | + $class = empty($class) ? $txt_class : $class; |
|
1019 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
1020 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
1021 | 1021 | |
1022 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
1022 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
1023 | 1023 | // filter label but ensure required text comes before it |
1024 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
1024 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
1025 | 1025 | |
1026 | - $input_html = "\n\t\t\t" . '<input type="text" name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . ' datepicker" value="' . $answer . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled . ' ' . $extra . '/>'; |
|
1026 | + $input_html = "\n\t\t\t".'<input type="text" name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].' datepicker" value="'.$answer.'" title="'.esc_attr($required['msg']).'" '.$disabled.' '.$extra.'/>'; |
|
1027 | 1027 | |
1028 | 1028 | // enqueue scripts |
1029 | - wp_register_style( 'espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION ); |
|
1030 | - wp_enqueue_style( 'espresso-ui-theme'); |
|
1031 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
1029 | + wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION); |
|
1030 | + wp_enqueue_style('espresso-ui-theme'); |
|
1031 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
1032 | 1032 | |
1033 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
1034 | - return $label_html . $input_html; |
|
1033 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
1034 | + return $label_html.$input_html; |
|
1035 | 1035 | |
1036 | 1036 | } |
1037 | 1037 | |
@@ -1043,7 +1043,7 @@ discard block |
||
1043 | 1043 | * @access public |
1044 | 1044 | * @return string |
1045 | 1045 | */ |
1046 | - public static function remove_label_keep_required_msg( $label_html, $required_text ) { |
|
1046 | + public static function remove_label_keep_required_msg($label_html, $required_text) { |
|
1047 | 1047 | return $required_text; |
1048 | 1048 | } |
1049 | 1049 | |
@@ -1057,9 +1057,9 @@ discard block |
||
1057 | 1057 | * @param string $value |
1058 | 1058 | * @return string HTML |
1059 | 1059 | */ |
1060 | - static function hidden_input( $name, $value, $id = '' ){ |
|
1061 | - $id = ! empty( $id ) ? $id : $name; |
|
1062 | - return '<input id="' . $id . '" type="hidden" name="'.$name.'" value="' . $value . '"/>'; |
|
1060 | + static function hidden_input($name, $value, $id = '') { |
|
1061 | + $id = ! empty($id) ? $id : $name; |
|
1062 | + return '<input id="'.$id.'" type="hidden" name="'.$name.'" value="'.$value.'"/>'; |
|
1063 | 1063 | } |
1064 | 1064 | |
1065 | 1065 | |
@@ -1071,7 +1071,7 @@ discard block |
||
1071 | 1071 | * @param string $question |
1072 | 1072 | * @return string |
1073 | 1073 | */ |
1074 | - static function prep_question( $question ){ |
|
1074 | + static function prep_question($question) { |
|
1075 | 1075 | return $question; |
1076 | 1076 | // $link = ''; |
1077 | 1077 | // // does this label have a help link attached ? |
@@ -1094,13 +1094,13 @@ discard block |
||
1094 | 1094 | * @param mixed $answer |
1095 | 1095 | * @return string |
1096 | 1096 | */ |
1097 | - static function prep_answer( $answer, $use_html_entities = TRUE ){ |
|
1097 | + static function prep_answer($answer, $use_html_entities = TRUE) { |
|
1098 | 1098 | //make sure we convert bools first. Otherwise (bool) false becomes an empty string which is NOT desired, we want "0". |
1099 | - if ( is_bool( $answer ) ) { |
|
1099 | + if (is_bool($answer)) { |
|
1100 | 1100 | $answer = $answer ? 1 : 0; |
1101 | 1101 | } |
1102 | - $answer = trim( stripslashes( str_replace( ''', "'", $answer ))); |
|
1103 | - return $use_html_entities ? htmlentities( $answer, ENT_QUOTES, 'UTF-8' ) : $answer; |
|
1102 | + $answer = trim(stripslashes(str_replace(''', "'", $answer))); |
|
1103 | + return $use_html_entities ? htmlentities($answer, ENT_QUOTES, 'UTF-8') : $answer; |
|
1104 | 1104 | } |
1105 | 1105 | |
1106 | 1106 | |
@@ -1110,18 +1110,18 @@ discard block |
||
1110 | 1110 | * @param array $QSOs array of EE_Question_Option objects |
1111 | 1111 | * @return array |
1112 | 1112 | */ |
1113 | - public static function prep_answer_options( $QSOs = array() ){ |
|
1113 | + public static function prep_answer_options($QSOs = array()) { |
|
1114 | 1114 | $prepped_answer_options = array(); |
1115 | - if ( is_array( $QSOs ) && ! empty( $QSOs )) { |
|
1116 | - foreach( $QSOs as $key => $QSO ) { |
|
1117 | - if ( ! $QSO instanceof EE_Question_Option ) { |
|
1118 | - $QSO = EE_Question_Option::new_instance( array( |
|
1119 | - 'QSO_value' => is_array( $QSO ) && isset( $QSO['id'] ) ? (string)$QSO['id'] : (string)$key, |
|
1120 | - 'QSO_desc' => is_array( $QSO ) && isset( $QSO['text'] ) ? (string)$QSO['text'] : (string)$QSO |
|
1115 | + if (is_array($QSOs) && ! empty($QSOs)) { |
|
1116 | + foreach ($QSOs as $key => $QSO) { |
|
1117 | + if ( ! $QSO instanceof EE_Question_Option) { |
|
1118 | + $QSO = EE_Question_Option::new_instance(array( |
|
1119 | + 'QSO_value' => is_array($QSO) && isset($QSO['id']) ? (string) $QSO['id'] : (string) $key, |
|
1120 | + 'QSO_desc' => is_array($QSO) && isset($QSO['text']) ? (string) $QSO['text'] : (string) $QSO |
|
1121 | 1121 | )); |
1122 | 1122 | } |
1123 | - if ( $QSO->opt_group() ) { |
|
1124 | - $prepped_answer_options[ $QSO->opt_group() ][] = $QSO; |
|
1123 | + if ($QSO->opt_group()) { |
|
1124 | + $prepped_answer_options[$QSO->opt_group()][] = $QSO; |
|
1125 | 1125 | } else { |
1126 | 1126 | $prepped_answer_options[] = $QSO; |
1127 | 1127 | } |
@@ -1137,8 +1137,8 @@ discard block |
||
1137 | 1137 | * @param string $option_value |
1138 | 1138 | * @return string |
1139 | 1139 | */ |
1140 | - static function prep_option_value( $option_value ){ |
|
1141 | - return esc_attr( trim( stripslashes( $option_value ) ) ); |
|
1140 | + static function prep_option_value($option_value) { |
|
1141 | + return esc_attr(trim(stripslashes($option_value))); |
|
1142 | 1142 | } |
1143 | 1143 | |
1144 | 1144 | |
@@ -1149,11 +1149,11 @@ discard block |
||
1149 | 1149 | * @param string|array $required |
1150 | 1150 | * @return array |
1151 | 1151 | */ |
1152 | - static function prep_required( $required = array() ){ |
|
1152 | + static function prep_required($required = array()) { |
|
1153 | 1153 | // make sure required is an array |
1154 | - $required = is_array( $required ) ? $required : array(); |
|
1154 | + $required = is_array($required) ? $required : array(); |
|
1155 | 1155 | // and set some defaults |
1156 | - $required = array_merge( array( 'label' => '', 'class' => '', 'msg' => '' ), $required ); |
|
1156 | + $required = array_merge(array('label' => '', 'class' => '', 'msg' => ''), $required); |
|
1157 | 1157 | return $required; |
1158 | 1158 | } |
1159 | 1159 | |
@@ -1164,30 +1164,30 @@ discard block |
||
1164 | 1164 | * @param string $value |
1165 | 1165 | * @return string |
1166 | 1166 | */ |
1167 | - static function get_label_size_class( $value = FALSE ){ |
|
1168 | - if ( $value === FALSE || $value == '' ) { |
|
1167 | + static function get_label_size_class($value = FALSE) { |
|
1168 | + if ($value === FALSE || $value == '') { |
|
1169 | 1169 | return ' class="medium-lbl"'; |
1170 | 1170 | } |
1171 | 1171 | // determine length of option value |
1172 | - $val_size = strlen( $value ); |
|
1173 | - switch( $val_size ){ |
|
1172 | + $val_size = strlen($value); |
|
1173 | + switch ($val_size) { |
|
1174 | 1174 | case $val_size < 3 : |
1175 | - $size = ' class="nano-lbl"'; |
|
1175 | + $size = ' class="nano-lbl"'; |
|
1176 | 1176 | break; |
1177 | 1177 | case $val_size < 6 : |
1178 | - $size = ' class="micro-lbl"'; |
|
1178 | + $size = ' class="micro-lbl"'; |
|
1179 | 1179 | break; |
1180 | 1180 | case $val_size < 12 : |
1181 | - $size = ' class="tiny-lbl"'; |
|
1181 | + $size = ' class="tiny-lbl"'; |
|
1182 | 1182 | break; |
1183 | 1183 | case $val_size < 25 : |
1184 | - $size = ' class="small-lbl"'; |
|
1184 | + $size = ' class="small-lbl"'; |
|
1185 | 1185 | break; |
1186 | 1186 | case $val_size > 100 : |
1187 | - $size = ' class="big-lbl"'; |
|
1187 | + $size = ' class="big-lbl"'; |
|
1188 | 1188 | break; |
1189 | 1189 | default: |
1190 | - $size = ' class="medium-lbl"'; |
|
1190 | + $size = ' class="medium-lbl"'; |
|
1191 | 1191 | break; |
1192 | 1192 | } |
1193 | 1193 | return $size; |
@@ -1201,20 +1201,20 @@ discard block |
||
1201 | 1201 | * @param array $QFI |
1202 | 1202 | * @return array |
1203 | 1203 | */ |
1204 | - private static function _load_system_dropdowns( $QFI ){ |
|
1204 | + private static function _load_system_dropdowns($QFI) { |
|
1205 | 1205 | $QST_system = $QFI->get('QST_system'); |
1206 | - switch ( $QST_system ) { |
|
1206 | + switch ($QST_system) { |
|
1207 | 1207 | case 'state' : |
1208 | - $QFI = self::generate_state_dropdown( $QFI ); |
|
1208 | + $QFI = self::generate_state_dropdown($QFI); |
|
1209 | 1209 | break; |
1210 | 1210 | case 'country' : |
1211 | - $QFI = self::generate_country_dropdown( $QFI ); |
|
1211 | + $QFI = self::generate_country_dropdown($QFI); |
|
1212 | 1212 | break; |
1213 | 1213 | case 'admin-state' : |
1214 | - $QFI = self::generate_state_dropdown( $QFI, TRUE ); |
|
1214 | + $QFI = self::generate_state_dropdown($QFI, TRUE); |
|
1215 | 1215 | break; |
1216 | 1216 | case 'admin-country' : |
1217 | - $QFI = self::generate_country_dropdown( $QFI, TRUE ); |
|
1217 | + $QFI = self::generate_country_dropdown($QFI, TRUE); |
|
1218 | 1218 | break; |
1219 | 1219 | } |
1220 | 1220 | return $QFI; |
@@ -1231,13 +1231,13 @@ discard block |
||
1231 | 1231 | * |
1232 | 1232 | * @return EE_Question_Form_Input |
1233 | 1233 | */ |
1234 | - protected static function _load_specialized_dropdowns( $QFI ) { |
|
1235 | - switch( $QFI->get( 'QST_type' ) ) { |
|
1234 | + protected static function _load_specialized_dropdowns($QFI) { |
|
1235 | + switch ($QFI->get('QST_type')) { |
|
1236 | 1236 | case 'STATE' : |
1237 | - $QFI = self::generate_state_dropdown( $QFI ); |
|
1237 | + $QFI = self::generate_state_dropdown($QFI); |
|
1238 | 1238 | break; |
1239 | 1239 | case 'COUNTRY' : |
1240 | - $QFI = self::generate_country_dropdown( $QFI ); |
|
1240 | + $QFI = self::generate_country_dropdown($QFI); |
|
1241 | 1241 | break; |
1242 | 1242 | } |
1243 | 1243 | return $QFI; |
@@ -1251,23 +1251,23 @@ discard block |
||
1251 | 1251 | * @param bool $get_all |
1252 | 1252 | * @return array |
1253 | 1253 | */ |
1254 | - public static function generate_state_dropdown( $QST, $get_all = FALSE ){ |
|
1254 | + public static function generate_state_dropdown($QST, $get_all = FALSE) { |
|
1255 | 1255 | $states = $get_all ? EEM_State::instance()->get_all_states() : EEM_State::instance()->get_all_states_of_active_countries(); |
1256 | - if ( $states && count( $states ) != count( $QST->options() )) { |
|
1257 | - $QST->set( 'QST_type', 'DROPDOWN' ); |
|
1256 | + if ($states && count($states) != count($QST->options())) { |
|
1257 | + $QST->set('QST_type', 'DROPDOWN'); |
|
1258 | 1258 | // if multiple countries, we'll create option groups within the dropdown |
1259 | - foreach ( $states as $state ) { |
|
1260 | - if ( $state instanceof EE_State ) { |
|
1261 | - $QSO = EE_Question_Option::new_instance ( array ( |
|
1259 | + foreach ($states as $state) { |
|
1260 | + if ($state instanceof EE_State) { |
|
1261 | + $QSO = EE_Question_Option::new_instance(array( |
|
1262 | 1262 | 'QSO_value' => $state->ID(), |
1263 | 1263 | 'QSO_desc' => $state->name(), |
1264 | - 'QST_ID' => $QST->get( 'QST_ID' ), |
|
1264 | + 'QST_ID' => $QST->get('QST_ID'), |
|
1265 | 1265 | 'QSO_deleted' => FALSE |
1266 | 1266 | )); |
1267 | 1267 | // set option group |
1268 | - $QSO->set_opt_group( $state->country()->name() ); |
|
1268 | + $QSO->set_opt_group($state->country()->name()); |
|
1269 | 1269 | // add option to question |
1270 | - $QST->add_temp_option( $QSO ); |
|
1270 | + $QST->add_temp_option($QSO); |
|
1271 | 1271 | } |
1272 | 1272 | } |
1273 | 1273 | } |
@@ -1283,20 +1283,20 @@ discard block |
||
1283 | 1283 | * @internal param array $question |
1284 | 1284 | * @return array |
1285 | 1285 | */ |
1286 | - public static function generate_country_dropdown( $QST, $get_all = FALSE ){ |
|
1286 | + public static function generate_country_dropdown($QST, $get_all = FALSE) { |
|
1287 | 1287 | $countries = $get_all ? EEM_Country::instance()->get_all_countries() : EEM_Country::instance()->get_all_active_countries(); |
1288 | - if ( $countries && count( $countries ) != count( $QST->options() ) ) { |
|
1289 | - $QST->set( 'QST_type', 'DROPDOWN' ); |
|
1288 | + if ($countries && count($countries) != count($QST->options())) { |
|
1289 | + $QST->set('QST_type', 'DROPDOWN'); |
|
1290 | 1290 | // now add countries |
1291 | - foreach ( $countries as $country ) { |
|
1292 | - if ( $country instanceof EE_Country ) { |
|
1293 | - $QSO = EE_Question_Option::new_instance ( array ( |
|
1291 | + foreach ($countries as $country) { |
|
1292 | + if ($country instanceof EE_Country) { |
|
1293 | + $QSO = EE_Question_Option::new_instance(array( |
|
1294 | 1294 | 'QSO_value' => $country->ID(), |
1295 | 1295 | 'QSO_desc' => $country->name(), |
1296 | - 'QST_ID' => $QST->get( 'QST_ID' ), |
|
1296 | + 'QST_ID' => $QST->get('QST_ID'), |
|
1297 | 1297 | 'QSO_deleted' => FALSE |
1298 | 1298 | )); |
1299 | - $QST->add_temp_option( $QSO ); |
|
1299 | + $QST->add_temp_option($QSO); |
|
1300 | 1300 | } |
1301 | 1301 | } |
1302 | 1302 | } |
@@ -1313,11 +1313,11 @@ discard block |
||
1313 | 1313 | */ |
1314 | 1314 | public static function two_digit_months_dropdown_options() { |
1315 | 1315 | $options = array(); |
1316 | - for ( $x = 1; $x <= 12; $x++ ) { |
|
1317 | - $mm = str_pad( $x, 2, '0', STR_PAD_LEFT ); |
|
1318 | - $options[ (string)$mm ] = (string)$mm; |
|
1316 | + for ($x = 1; $x <= 12; $x++) { |
|
1317 | + $mm = str_pad($x, 2, '0', STR_PAD_LEFT); |
|
1318 | + $options[(string) $mm] = (string) $mm; |
|
1319 | 1319 | } |
1320 | - return EEH_Form_Fields::prep_answer_options( $options ); |
|
1320 | + return EEH_Form_Fields::prep_answer_options($options); |
|
1321 | 1321 | } |
1322 | 1322 | |
1323 | 1323 | |
@@ -1332,11 +1332,11 @@ discard block |
||
1332 | 1332 | $options = array(); |
1333 | 1333 | $current_year = date('y'); |
1334 | 1334 | $next_decade = $current_year + 10; |
1335 | - for ( $x = $current_year; $x <= $next_decade; $x++ ) { |
|
1336 | - $yy = str_pad( $x, 2, '0', STR_PAD_LEFT ); |
|
1337 | - $options[ (string)$yy ] = (string)$yy; |
|
1335 | + for ($x = $current_year; $x <= $next_decade; $x++) { |
|
1336 | + $yy = str_pad($x, 2, '0', STR_PAD_LEFT); |
|
1337 | + $options[(string) $yy] = (string) $yy; |
|
1338 | 1338 | } |
1339 | - return EEH_Form_Fields::prep_answer_options( $options ); |
|
1339 | + return EEH_Form_Fields::prep_answer_options($options); |
|
1340 | 1340 | } |
1341 | 1341 | |
1342 | 1342 | |
@@ -1350,17 +1350,17 @@ discard block |
||
1350 | 1350 | * @param integer $evt_category Event Category ID if the Event Category filter is selected |
1351 | 1351 | * @return string html |
1352 | 1352 | */ |
1353 | - public static function generate_registration_months_dropdown( $cur_date = '', $status = '', $evt_category = 0 ) { |
|
1353 | + public static function generate_registration_months_dropdown($cur_date = '', $status = '', $evt_category = 0) { |
|
1354 | 1354 | $_where = array(); |
1355 | - if ( !empty( $status ) ) { |
|
1355 | + if ( ! empty($status)) { |
|
1356 | 1356 | $_where['STS_ID'] = $status; |
1357 | 1357 | } |
1358 | 1358 | |
1359 | - if ( $evt_category > 0 ) { |
|
1359 | + if ($evt_category > 0) { |
|
1360 | 1360 | $_where['Event.Term_Taxonomy.term_id'] = $evt_category; |
1361 | 1361 | } |
1362 | 1362 | |
1363 | - $regdtts = EEM_Registration::instance()->get_reg_months_and_years( $_where ); |
|
1363 | + $regdtts = EEM_Registration::instance()->get_reg_months_and_years($_where); |
|
1364 | 1364 | |
1365 | 1365 | //setup vals for select input helper |
1366 | 1366 | $options = array( |
@@ -1370,15 +1370,15 @@ discard block |
||
1370 | 1370 | ) |
1371 | 1371 | ); |
1372 | 1372 | |
1373 | - foreach ( $regdtts as $regdtt ) { |
|
1374 | - $date = $regdtt->reg_month. ' ' . $regdtt->reg_year; |
|
1373 | + foreach ($regdtts as $regdtt) { |
|
1374 | + $date = $regdtt->reg_month.' '.$regdtt->reg_year; |
|
1375 | 1375 | $options[] = array( |
1376 | 1376 | 'text' => $date, |
1377 | 1377 | 'id' => $date |
1378 | 1378 | ); |
1379 | 1379 | } |
1380 | 1380 | |
1381 | - return self::select_input('month_range', $options, $cur_date, '', 'wide' ); |
|
1381 | + return self::select_input('month_range', $options, $cur_date, '', 'wide'); |
|
1382 | 1382 | } |
1383 | 1383 | |
1384 | 1384 | |
@@ -1392,18 +1392,18 @@ discard block |
||
1392 | 1392 | * @param string $evt_active_status "upcoming", "expired", "active", or "inactive" |
1393 | 1393 | * @return string html |
1394 | 1394 | */ |
1395 | - public static function generate_event_months_dropdown( $cur_date = '', $status = NULL, $evt_category = NULL, $evt_active_status = NULL ) { |
|
1395 | + public static function generate_event_months_dropdown($cur_date = '', $status = NULL, $evt_category = NULL, $evt_active_status = NULL) { |
|
1396 | 1396 | //determine what post_status our condition will have for the query. |
1397 | - switch ( $status ) { |
|
1397 | + switch ($status) { |
|
1398 | 1398 | case 'month' : |
1399 | 1399 | case 'today' : |
1400 | 1400 | case NULL : |
1401 | 1401 | case 'all' : |
1402 | - $where['Event.status'] = array( 'NOT IN', array('trash') ); |
|
1402 | + $where['Event.status'] = array('NOT IN', array('trash')); |
|
1403 | 1403 | break; |
1404 | 1404 | |
1405 | 1405 | case 'draft' : |
1406 | - $where['Event.status'] = array( 'IN', array('draft', 'auto-draft') ); |
|
1406 | + $where['Event.status'] = array('IN', array('draft', 'auto-draft')); |
|
1407 | 1407 | |
1408 | 1408 | default : |
1409 | 1409 | $where['Event.status'] = $status; |
@@ -1412,7 +1412,7 @@ discard block |
||
1412 | 1412 | //categories? |
1413 | 1413 | |
1414 | 1414 | |
1415 | - if ( !empty ( $evt_category ) ) { |
|
1415 | + if ( ! empty ($evt_category)) { |
|
1416 | 1416 | $where['Event.Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
1417 | 1417 | $where['Event.Term_Taxonomy.term_id'] = $evt_category; |
1418 | 1418 | } |
@@ -1420,7 +1420,7 @@ discard block |
||
1420 | 1420 | |
1421 | 1421 | // $where['DTT_is_primary'] = 1; |
1422 | 1422 | |
1423 | - $DTTS = EE_Registry::instance()->load_model('Datetime')->get_dtt_months_and_years($where, $evt_active_status ); |
|
1423 | + $DTTS = EE_Registry::instance()->load_model('Datetime')->get_dtt_months_and_years($where, $evt_active_status); |
|
1424 | 1424 | |
1425 | 1425 | //let's setup vals for select input helper |
1426 | 1426 | $options = array( |
@@ -1435,9 +1435,9 @@ discard block |
||
1435 | 1435 | //translate month and date |
1436 | 1436 | global $wp_locale; |
1437 | 1437 | |
1438 | - foreach ( $DTTS as $DTT ) { |
|
1439 | - $localized_date = $wp_locale->get_month( $DTT->dtt_month_num ) . ' ' . $DTT->dtt_year; |
|
1440 | - $id = $DTT->dtt_month . ' ' . $DTT->dtt_year; |
|
1438 | + foreach ($DTTS as $DTT) { |
|
1439 | + $localized_date = $wp_locale->get_month($DTT->dtt_month_num).' '.$DTT->dtt_year; |
|
1440 | + $id = $DTT->dtt_month.' '.$DTT->dtt_year; |
|
1441 | 1441 | $options[] = array( |
1442 | 1442 | 'text' => $localized_date, |
1443 | 1443 | 'id' => $id |
@@ -1445,7 +1445,7 @@ discard block |
||
1445 | 1445 | } |
1446 | 1446 | |
1447 | 1447 | |
1448 | - return self::select_input( 'month_range', $options, $cur_date, '', 'wide' ); |
|
1448 | + return self::select_input('month_range', $options, $cur_date, '', 'wide'); |
|
1449 | 1449 | } |
1450 | 1450 | |
1451 | 1451 | |
@@ -1456,7 +1456,7 @@ discard block |
||
1456 | 1456 | * @param integer $current_cat currently selected category |
1457 | 1457 | * @return string html for dropdown |
1458 | 1458 | */ |
1459 | - public static function generate_event_category_dropdown( $current_cat = -1 ) { |
|
1459 | + public static function generate_event_category_dropdown($current_cat = -1) { |
|
1460 | 1460 | $categories = EEM_Term::instance()->get_all_ee_categories(TRUE); |
1461 | 1461 | $options = array( |
1462 | 1462 | '0' => array( |
@@ -1466,14 +1466,14 @@ discard block |
||
1466 | 1466 | ); |
1467 | 1467 | |
1468 | 1468 | //setup categories for dropdown |
1469 | - foreach ( $categories as $category ) { |
|
1469 | + foreach ($categories as $category) { |
|
1470 | 1470 | $options[] = array( |
1471 | 1471 | 'text' => $category->get('name'), |
1472 | 1472 | 'id' => $category->ID() |
1473 | 1473 | ); |
1474 | 1474 | } |
1475 | 1475 | |
1476 | - return self::select_input( 'EVT_CAT', $options, $current_cat ); |
|
1476 | + return self::select_input('EVT_CAT', $options, $current_cat); |
|
1477 | 1477 | } |
1478 | 1478 | |
1479 | 1479 | |
@@ -1492,20 +1492,20 @@ discard block |
||
1492 | 1492 | * @param string $extra_attributes - any extra attributes that need to be attached to the form input |
1493 | 1493 | * @return void |
1494 | 1494 | */ |
1495 | - public static function submit_button( $url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '' ) { |
|
1495 | + public static function submit_button($url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '') { |
|
1496 | 1496 | $btn = ''; |
1497 | - if ( empty( $url ) || empty( $ID )) { |
|
1497 | + if (empty($url) || empty($ID)) { |
|
1498 | 1498 | return $btn; |
1499 | 1499 | } |
1500 | - $text = ! empty( $text ) ? $text : __('Submit', 'event_espresso' ); |
|
1501 | - $btn .= '<input id="' . $ID . '-btn" class="' . $class . '" type="submit" value="' . $text . '" ' . $extra_attributes . '/>'; |
|
1502 | - if ( ! $input_only ) { |
|
1503 | - $btn_frm = '<form id="' . $ID . '-frm" method="POST" action="' . $url . '">'; |
|
1504 | - $btn_frm .= ! empty( $nonce_action ) ? wp_nonce_field( $nonce_action, $nonce_action . '_nonce', TRUE, FALSE ) : ''; |
|
1500 | + $text = ! empty($text) ? $text : __('Submit', 'event_espresso'); |
|
1501 | + $btn .= '<input id="'.$ID.'-btn" class="'.$class.'" type="submit" value="'.$text.'" '.$extra_attributes.'/>'; |
|
1502 | + if ( ! $input_only) { |
|
1503 | + $btn_frm = '<form id="'.$ID.'-frm" method="POST" action="'.$url.'">'; |
|
1504 | + $btn_frm .= ! empty($nonce_action) ? wp_nonce_field($nonce_action, $nonce_action.'_nonce', TRUE, FALSE) : ''; |
|
1505 | 1505 | $btn_frm .= $btn; |
1506 | 1506 | $btn_frm .= '</form>'; |
1507 | 1507 | $btn = $btn_frm; |
1508 | - unset ( $btn_frm ); |
|
1508 | + unset ($btn_frm); |
|
1509 | 1509 | } |
1510 | 1510 | return $btn; |
1511 | 1511 | } |
@@ -797,7 +797,7 @@ discard block |
||
797 | 797 | * |
798 | 798 | * @param mixed $opt_group |
799 | 799 | * @param mixed $QSOs |
800 | - * @param mixed $answer |
|
800 | + * @param string $answer |
|
801 | 801 | * @param boolean $use_html_entities |
802 | 802 | * @return string |
803 | 803 | */ |
@@ -1147,7 +1147,7 @@ discard block |
||
1147 | 1147 | /** |
1148 | 1148 | * prep_required |
1149 | 1149 | * @param string|array $required |
1150 | - * @return array |
|
1150 | + * @return string |
|
1151 | 1151 | */ |
1152 | 1152 | static function prep_required( $required = array() ){ |
1153 | 1153 | // make sure required is an array |
@@ -1198,8 +1198,8 @@ discard block |
||
1198 | 1198 | |
1199 | 1199 | /** |
1200 | 1200 | * _load_system_dropdowns |
1201 | - * @param array $QFI |
|
1202 | - * @return array |
|
1201 | + * @param EE_Question_Form_Input $QFI |
|
1202 | + * @return EE_Question_Form_Input |
|
1203 | 1203 | */ |
1204 | 1204 | private static function _load_system_dropdowns( $QFI ){ |
1205 | 1205 | $QST_system = $QFI->get('QST_system'); |
@@ -1490,7 +1490,7 @@ discard block |
||
1490 | 1490 | * @param string $nonce_action - if using nonces |
1491 | 1491 | * @param bool|string $input_only - whether to print form header and footer. TRUE returns the input without the form |
1492 | 1492 | * @param string $extra_attributes - any extra attributes that need to be attached to the form input |
1493 | - * @return void |
|
1493 | + * @return string |
|
1494 | 1494 | */ |
1495 | 1495 | public static function submit_button( $url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '' ) { |
1496 | 1496 | $btn = ''; |
@@ -1,21 +1,21 @@ |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | 2 | /** |
3 | - * |
|
4 | - * Class EEH_HTML |
|
5 | - * |
|
3 | + * |
|
4 | + * Class EEH_HTML |
|
5 | + * |
|
6 | 6 | * Sometimes when writing PHP you need to generate some standard HTML, |
7 | 7 | * but either not enough to warrant creating a template file, |
8 | 8 | * or the amount of PHP conditionals and/or loops peppered throughout the HTML |
9 | 9 | * just make it really ugly and difficult to read. |
10 | 10 | * This class simply adds a bunch of methods for generating basic HTML tags. |
11 | 11 | * Most of the methods have the same name as the HTML tag they generate, and most have the same set of parameters. |
12 | - * |
|
13 | - * @package Event Espresso |
|
14 | - * @subpackage core |
|
15 | - * @author Brent Christensen |
|
16 | - * @since $VID:$ |
|
17 | - * |
|
18 | - */ |
|
12 | + * |
|
13 | + * @package Event Espresso |
|
14 | + * @subpackage core |
|
15 | + * @author Brent Christensen |
|
16 | + * @since $VID:$ |
|
17 | + * |
|
18 | + */ |
|
19 | 19 | |
20 | 20 | class EEH_HTML { |
21 | 21 |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public static function instance() { |
43 | 43 | // check if class object is instantiated, and instantiated properly |
44 | - if ( ! self::$_instance instanceof EEH_HTML ) { |
|
44 | + if ( ! self::$_instance instanceof EEH_HTML) { |
|
45 | 45 | self::$_instance = new EEH_HTML(); |
46 | 46 | } |
47 | 47 | return self::$_instance; |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | $other_attributes = '', |
103 | 103 | $force_close = false |
104 | 104 | ) { |
105 | - $attributes = ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : ''; |
|
106 | - $attributes .= ! empty( $class ) ? ' class="' . $class . '"' : ''; |
|
107 | - $attributes .= ! empty( $style ) ? ' style="' . $style . '"' : ''; |
|
108 | - $attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : ''; |
|
109 | - $html = EEH_HTML::nl( 0, $tag ) . '<' . $tag . $attributes . '>'; |
|
110 | - $html .= ! empty( $content ) ? EEH_HTML::nl( 1, $tag ) . $content : ''; |
|
111 | - $indent = ! empty( $content ) || $force_close ? TRUE : FALSE; |
|
112 | - $html .= ! empty( $content ) || $force_close ? EEH_HTML::_close_tag( $tag, $id, $class, $indent ) : ''; |
|
105 | + $attributes = ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : ''; |
|
106 | + $attributes .= ! empty($class) ? ' class="'.$class.'"' : ''; |
|
107 | + $attributes .= ! empty($style) ? ' style="'.$style.'"' : ''; |
|
108 | + $attributes .= ! empty($other_attributes) ? ' '.$other_attributes : ''; |
|
109 | + $html = EEH_HTML::nl(0, $tag).'<'.$tag.$attributes.'>'; |
|
110 | + $html .= ! empty($content) ? EEH_HTML::nl(1, $tag).$content : ''; |
|
111 | + $indent = ! empty($content) || $force_close ? TRUE : FALSE; |
|
112 | + $html .= ! empty($content) || $force_close ? EEH_HTML::_close_tag($tag, $id, $class, $indent) : ''; |
|
113 | 113 | return $html; |
114 | 114 | } |
115 | 115 | |
@@ -126,15 +126,15 @@ discard block |
||
126 | 126 | * @param bool $indent |
127 | 127 | * @return string |
128 | 128 | */ |
129 | - protected static function _close_tag( $tag = 'div', $id = '', $class = '', $indent = TRUE ) { |
|
129 | + protected static function _close_tag($tag = 'div', $id = '', $class = '', $indent = TRUE) { |
|
130 | 130 | $comment = ''; |
131 | - if ( $id ) { |
|
132 | - $comment = EEH_HTML::comment( 'close ' . $id ) . EEH_HTML::nl( 0, $tag ); |
|
133 | - } else if ( $class ) { |
|
134 | - $comment = EEH_HTML::comment( 'close ' . $class ) . EEH_HTML::nl( 0, $tag ); |
|
131 | + if ($id) { |
|
132 | + $comment = EEH_HTML::comment('close '.$id).EEH_HTML::nl(0, $tag); |
|
133 | + } else if ($class) { |
|
134 | + $comment = EEH_HTML::comment('close '.$class).EEH_HTML::nl(0, $tag); |
|
135 | 135 | } |
136 | 136 | $html = $indent ? EEH_HTML::nl( -1, $tag ) : ''; |
137 | - $html .= '</' . $tag . '>' . $comment; |
|
137 | + $html .= '</'.$tag.'>'.$comment; |
|
138 | 138 | return $html; |
139 | 139 | } |
140 | 140 | |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
154 | 154 | * @return string |
155 | 155 | */ |
156 | - public static function div( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
157 | - return EEH_HTML::_open_tag( 'div', $content, $id, $class, $style, $other_attributes ); |
|
156 | + public static function div($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
157 | + return EEH_HTML::_open_tag('div', $content, $id, $class, $style, $other_attributes); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | * @param string $class - html class attribute |
168 | 168 | * @return string |
169 | 169 | */ |
170 | - public static function divx( $id = '', $class = '' ) { |
|
171 | - return EEH_HTML::_close_tag( 'div', $id, $class ); |
|
170 | + public static function divx($id = '', $class = '') { |
|
171 | + return EEH_HTML::_close_tag('div', $id, $class); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | |
@@ -184,8 +184,8 @@ discard block |
||
184 | 184 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
185 | 185 | * @return string |
186 | 186 | */ |
187 | - public static function h1( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
188 | - return EEH_HTML::_open_tag( 'h1', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
187 | + public static function h1($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
188 | + return EEH_HTML::_open_tag('h1', $content, $id, $class, $style, $other_attributes, TRUE); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
202 | 202 | * @return string |
203 | 203 | */ |
204 | - public static function h2( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
205 | - return EEH_HTML::_open_tag( 'h2', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
204 | + public static function h2($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
205 | + return EEH_HTML::_open_tag('h2', $content, $id, $class, $style, $other_attributes, TRUE); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | |
@@ -218,8 +218,8 @@ discard block |
||
218 | 218 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
219 | 219 | * @return string |
220 | 220 | */ |
221 | - public static function h3( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
222 | - return EEH_HTML::_open_tag( 'h3', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
221 | + public static function h3($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
222 | + return EEH_HTML::_open_tag('h3', $content, $id, $class, $style, $other_attributes, TRUE); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
236 | 236 | * @return string |
237 | 237 | */ |
238 | - public static function h4( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
239 | - return EEH_HTML::_open_tag( 'h4', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
238 | + public static function h4($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
239 | + return EEH_HTML::_open_tag('h4', $content, $id, $class, $style, $other_attributes, TRUE); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
253 | 253 | * @return string |
254 | 254 | */ |
255 | - public static function h5( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
256 | - return EEH_HTML::_open_tag( 'h5', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
255 | + public static function h5($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
256 | + return EEH_HTML::_open_tag('h5', $content, $id, $class, $style, $other_attributes, TRUE); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | |
@@ -269,8 +269,8 @@ discard block |
||
269 | 269 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
270 | 270 | * @return string |
271 | 271 | */ |
272 | - public static function h6( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
273 | - return EEH_HTML::_open_tag( 'h6', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
272 | + public static function h6($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
273 | + return EEH_HTML::_open_tag('h6', $content, $id, $class, $style, $other_attributes, TRUE); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | |
@@ -286,8 +286,8 @@ discard block |
||
286 | 286 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
287 | 287 | * @return string |
288 | 288 | */ |
289 | - public static function p( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
290 | - return EEH_HTML::_open_tag( 'p', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
289 | + public static function p($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
290 | + return EEH_HTML::_open_tag('p', $content, $id, $class, $style, $other_attributes, TRUE); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | |
@@ -302,8 +302,8 @@ discard block |
||
302 | 302 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
303 | 303 | * @return string |
304 | 304 | */ |
305 | - public static function ul( $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
306 | - return EEH_HTML::_open_tag( 'ul', '', $id, $class, $style, $other_attributes ); |
|
305 | + public static function ul($id = '', $class = '', $style = '', $other_attributes = '') { |
|
306 | + return EEH_HTML::_open_tag('ul', '', $id, $class, $style, $other_attributes); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | |
@@ -316,8 +316,8 @@ discard block |
||
316 | 316 | * @param string $class - html class attribute |
317 | 317 | * @return string |
318 | 318 | */ |
319 | - public static function ulx( $id = '', $class = '' ) { |
|
320 | - return EEH_HTML::_close_tag( 'ul', $id, $class ); |
|
319 | + public static function ulx($id = '', $class = '') { |
|
320 | + return EEH_HTML::_close_tag('ul', $id, $class); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | |
@@ -334,8 +334,8 @@ discard block |
||
334 | 334 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
335 | 335 | * @return string |
336 | 336 | */ |
337 | - public static function li( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
338 | - return EEH_HTML::_open_tag( 'li', $content, $id, $class, $style, $other_attributes ); |
|
337 | + public static function li($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
338 | + return EEH_HTML::_open_tag('li', $content, $id, $class, $style, $other_attributes); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | |
@@ -348,8 +348,8 @@ discard block |
||
348 | 348 | * @param string $class - html class attribute |
349 | 349 | * @return string |
350 | 350 | */ |
351 | - public static function lix( $id = '', $class = '' ) { |
|
352 | - return EEH_HTML::_close_tag( 'li', $id, $class ); |
|
351 | + public static function lix($id = '', $class = '') { |
|
352 | + return EEH_HTML::_close_tag('li', $id, $class); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
366 | 366 | * @return string |
367 | 367 | */ |
368 | - public static function table( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
369 | - return EEH_HTML::_open_tag( 'table', $content, $id, $class, $style, $other_attributes ); |
|
368 | + public static function table($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
369 | + return EEH_HTML::_open_tag('table', $content, $id, $class, $style, $other_attributes); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | |
@@ -378,8 +378,8 @@ discard block |
||
378 | 378 | * @param string $class - html class attribute |
379 | 379 | * @return string |
380 | 380 | */ |
381 | - public static function tablex( $id = '', $class = '' ) { |
|
382 | - return EEH_HTML::_close_tag( 'table', $id, $class ); |
|
381 | + public static function tablex($id = '', $class = '') { |
|
382 | + return EEH_HTML::_close_tag('table', $id, $class); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | |
@@ -395,8 +395,8 @@ discard block |
||
395 | 395 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
396 | 396 | * @return string |
397 | 397 | */ |
398 | - public static function thead( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
399 | - return EEH_HTML::_open_tag( 'thead', $content, $id, $class, $style, $other_attributes ); |
|
398 | + public static function thead($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
399 | + return EEH_HTML::_open_tag('thead', $content, $id, $class, $style, $other_attributes); |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | |
@@ -408,8 +408,8 @@ discard block |
||
408 | 408 | * @param string $class - html class attribute |
409 | 409 | * @return string |
410 | 410 | */ |
411 | - public static function theadx( $id = '', $class = '' ) { |
|
412 | - return EEH_HTML::_close_tag( 'thead', $id, $class ); |
|
411 | + public static function theadx($id = '', $class = '') { |
|
412 | + return EEH_HTML::_close_tag('thead', $id, $class); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | |
@@ -425,8 +425,8 @@ discard block |
||
425 | 425 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
426 | 426 | * @return string |
427 | 427 | */ |
428 | - public static function tbody( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
429 | - return EEH_HTML::_open_tag( 'tbody', $content, $id, $class, $style, $other_attributes ); |
|
428 | + public static function tbody($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
429 | + return EEH_HTML::_open_tag('tbody', $content, $id, $class, $style, $other_attributes); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | |
@@ -438,8 +438,8 @@ discard block |
||
438 | 438 | * @param string $class - html class attribute |
439 | 439 | * @return string |
440 | 440 | */ |
441 | - public static function tbodyx( $id = '', $class = '' ) { |
|
442 | - return EEH_HTML::_close_tag( 'tbody', $id, $class ); |
|
441 | + public static function tbodyx($id = '', $class = '') { |
|
442 | + return EEH_HTML::_close_tag('tbody', $id, $class); |
|
443 | 443 | } |
444 | 444 | |
445 | 445 | |
@@ -455,8 +455,8 @@ discard block |
||
455 | 455 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
456 | 456 | * @return string |
457 | 457 | */ |
458 | - public static function tr( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
459 | - return EEH_HTML::_open_tag( 'tr', $content, $id, $class, $style, $other_attributes ); |
|
458 | + public static function tr($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
459 | + return EEH_HTML::_open_tag('tr', $content, $id, $class, $style, $other_attributes); |
|
460 | 460 | } |
461 | 461 | |
462 | 462 | |
@@ -468,8 +468,8 @@ discard block |
||
468 | 468 | * @param string $class - html class attribute |
469 | 469 | * @return string |
470 | 470 | */ |
471 | - public static function trx( $id = '', $class = '' ) { |
|
472 | - return EEH_HTML::_close_tag( 'tr', $id, $class ); |
|
471 | + public static function trx($id = '', $class = '') { |
|
472 | + return EEH_HTML::_close_tag('tr', $id, $class); |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | |
@@ -485,8 +485,8 @@ discard block |
||
485 | 485 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
486 | 486 | * @return string |
487 | 487 | */ |
488 | - public static function th( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
489 | - return EEH_HTML::_open_tag( 'th', $content, $id, $class, $style, $other_attributes ); |
|
488 | + public static function th($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
489 | + return EEH_HTML::_open_tag('th', $content, $id, $class, $style, $other_attributes); |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | |
@@ -498,8 +498,8 @@ discard block |
||
498 | 498 | * @param string $class - html class attribute |
499 | 499 | * @return string |
500 | 500 | */ |
501 | - public static function thx( $id = '', $class = '' ) { |
|
502 | - return EEH_HTML::_close_tag( 'th', $id, $class ); |
|
501 | + public static function thx($id = '', $class = '') { |
|
502 | + return EEH_HTML::_close_tag('th', $id, $class); |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | |
@@ -515,8 +515,8 @@ discard block |
||
515 | 515 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
516 | 516 | * @return string |
517 | 517 | */ |
518 | - public static function td( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
519 | - return EEH_HTML::_open_tag( 'td', $content, $id, $class, $style, $other_attributes ); |
|
518 | + public static function td($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
519 | + return EEH_HTML::_open_tag('td', $content, $id, $class, $style, $other_attributes); |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | |
@@ -528,8 +528,8 @@ discard block |
||
528 | 528 | * @param string $class - html class attribute |
529 | 529 | * @return string |
530 | 530 | */ |
531 | - public static function tdx( $id = '', $class = '' ) { |
|
532 | - return EEH_HTML::_close_tag( 'td', $id, $class ); |
|
531 | + public static function tdx($id = '', $class = '') { |
|
532 | + return EEH_HTML::_close_tag('td', $id, $class); |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | |
@@ -543,10 +543,10 @@ discard block |
||
543 | 543 | * @param int $colspan |
544 | 544 | * @return string |
545 | 545 | */ |
546 | - public static function no_row( $content = '', $colspan = 2 ) { |
|
546 | + public static function no_row($content = '', $colspan = 2) { |
|
547 | 547 | return EEH_HTML::tr( |
548 | - EEH_HTML::td( $content, '', '', 'padding:0; border:none;', 'colspan="' . $colspan . '"' ), |
|
549 | - '', '', 'padding:0; border:none;' |
|
548 | + EEH_HTML::td($content, '', '', 'padding:0; border:none;', 'colspan="'.$colspan.'"'), |
|
549 | + '', '', 'padding:0; border:none;' |
|
550 | 550 | ); |
551 | 551 | } |
552 | 552 | |
@@ -566,14 +566,14 @@ discard block |
||
566 | 566 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
567 | 567 | * @return string |
568 | 568 | */ |
569 | - public static function link( $href = '', $link_text = '', $title = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
570 | - $link_text = ! empty( $link_text ) ? $link_text : $href; |
|
571 | - $attributes = ! empty($href ) ? ' href="' . $href . '"' : ''; |
|
572 | - $attributes .= ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : ''; |
|
573 | - $attributes .= ! empty( $class ) ? ' class="' . $class . '"' : ''; |
|
574 | - $attributes .= ! empty( $style ) ? ' style="' . $style . '"' : ''; |
|
575 | - $attributes .= ! empty( $title ) ? ' title="' . esc_attr( $title ) . '"' : ''; |
|
576 | - $attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : ''; |
|
569 | + public static function link($href = '', $link_text = '', $title = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
570 | + $link_text = ! empty($link_text) ? $link_text : $href; |
|
571 | + $attributes = ! empty($href) ? ' href="'.$href.'"' : ''; |
|
572 | + $attributes .= ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : ''; |
|
573 | + $attributes .= ! empty($class) ? ' class="'.$class.'"' : ''; |
|
574 | + $attributes .= ! empty($style) ? ' style="'.$style.'"' : ''; |
|
575 | + $attributes .= ! empty($title) ? ' title="'.esc_attr($title).'"' : ''; |
|
576 | + $attributes .= ! empty($other_attributes) ? ' '.$other_attributes : ''; |
|
577 | 577 | return "<a{$attributes}>{$link_text}</a>"; |
578 | 578 | } |
579 | 579 | |
@@ -591,14 +591,14 @@ discard block |
||
591 | 591 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
592 | 592 | * @return string |
593 | 593 | */ |
594 | - public static function img( $src = '', $alt = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
595 | - $attributes = ! empty( $src ) ? ' src="' . esc_url_raw( $src ) . '"' : ''; |
|
596 | - $attributes .= ! empty( $alt ) ? ' alt="' . esc_attr( $alt ) . '"' : ''; |
|
597 | - $attributes .= ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : ''; |
|
598 | - $attributes .= ! empty( $class ) ? ' class="' . $class . '"' : ''; |
|
599 | - $attributes .= ! empty( $style ) ? ' style="' . $style . '"' : ''; |
|
600 | - $attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : ''; |
|
601 | - return '<img' . $attributes . '/>'; |
|
594 | + public static function img($src = '', $alt = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
595 | + $attributes = ! empty($src) ? ' src="'.esc_url_raw($src).'"' : ''; |
|
596 | + $attributes .= ! empty($alt) ? ' alt="'.esc_attr($alt).'"' : ''; |
|
597 | + $attributes .= ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : ''; |
|
598 | + $attributes .= ! empty($class) ? ' class="'.$class.'"' : ''; |
|
599 | + $attributes .= ! empty($style) ? ' style="'.$style.'"' : ''; |
|
600 | + $attributes .= ! empty($other_attributes) ? ' '.$other_attributes : ''; |
|
601 | + return '<img'.$attributes.'/>'; |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | |
@@ -616,12 +616,12 @@ discard block |
||
616 | 616 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
617 | 617 | * @return string |
618 | 618 | */ |
619 | - protected static function _inline_tag( $tag = 'span', $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
620 | - $attributes = ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : ''; |
|
621 | - $attributes .= ! empty( $class ) ? ' class="' . $class . '"' : ''; |
|
622 | - $attributes .= ! empty( $style ) ? ' style="' . $style . '"' : ''; |
|
623 | - $attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : ''; |
|
624 | - return '<' . $tag . ' ' . $attributes . '>' . $content . '</' . $tag . '>'; |
|
619 | + protected static function _inline_tag($tag = 'span', $content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
620 | + $attributes = ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : ''; |
|
621 | + $attributes .= ! empty($class) ? ' class="'.$class.'"' : ''; |
|
622 | + $attributes .= ! empty($style) ? ' style="'.$style.'"' : ''; |
|
623 | + $attributes .= ! empty($other_attributes) ? ' '.$other_attributes : ''; |
|
624 | + return '<'.$tag.' '.$attributes.'>'.$content.'</'.$tag.'>'; |
|
625 | 625 | } |
626 | 626 | |
627 | 627 | |
@@ -637,8 +637,8 @@ discard block |
||
637 | 637 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
638 | 638 | * @return string |
639 | 639 | */ |
640 | - public static function label( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
641 | - return EEH_HTML::_inline_tag( 'label', $content, $id, $class, $style, $other_attributes ); |
|
640 | + public static function label($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
641 | + return EEH_HTML::_inline_tag('label', $content, $id, $class, $style, $other_attributes); |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | |
@@ -654,8 +654,8 @@ discard block |
||
654 | 654 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
655 | 655 | * @return string |
656 | 656 | */ |
657 | - public static function span( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
658 | - return EEH_HTML::_inline_tag( 'span', $content, $id, $class, $style, $other_attributes ); |
|
657 | + public static function span($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
658 | + return EEH_HTML::_inline_tag('span', $content, $id, $class, $style, $other_attributes); |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | |
@@ -671,8 +671,8 @@ discard block |
||
671 | 671 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
672 | 672 | * @return string |
673 | 673 | */ |
674 | - public static function strong( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
675 | - return EEH_HTML::_inline_tag( 'strong', $content, $id, $class, $style, $other_attributes ); |
|
674 | + public static function strong($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
675 | + return EEH_HTML::_inline_tag('strong', $content, $id, $class, $style, $other_attributes); |
|
676 | 676 | } |
677 | 677 | |
678 | 678 | |
@@ -684,8 +684,8 @@ discard block |
||
684 | 684 | * @param string $comment |
685 | 685 | * @return string |
686 | 686 | */ |
687 | - public static function comment( $comment = '' ) { |
|
688 | - return ! empty( $comment ) ? EEH_HTML::nl() . '<!-- ' . $comment . ' -->' : ''; |
|
687 | + public static function comment($comment = '') { |
|
688 | + return ! empty($comment) ? EEH_HTML::nl().'<!-- '.$comment.' -->' : ''; |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | |
@@ -696,8 +696,8 @@ discard block |
||
696 | 696 | * @param int $nmbr - the number of line breaks to return |
697 | 697 | * @return string |
698 | 698 | */ |
699 | - public static function br( $nmbr = 1 ) { |
|
700 | - return str_repeat( '<br />', $nmbr ); |
|
699 | + public static function br($nmbr = 1) { |
|
700 | + return str_repeat('<br />', $nmbr); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | |
@@ -708,8 +708,8 @@ discard block |
||
708 | 708 | * @param int $nmbr - the number of non-breaking spaces to return |
709 | 709 | * @return string |
710 | 710 | */ |
711 | - public static function nbsp( $nmbr = 1 ) { |
|
712 | - return str_repeat( ' ', $nmbr ); |
|
711 | + public static function nbsp($nmbr = 1) { |
|
712 | + return str_repeat(' ', $nmbr); |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | |
@@ -723,9 +723,9 @@ discard block |
||
723 | 723 | * @param string $id |
724 | 724 | * @return string |
725 | 725 | */ |
726 | - public static function sanitize_id( $id = '' ) { |
|
727 | - $key = str_replace( ' ', '-', trim( $id ) ); |
|
728 | - return preg_replace( '/[^a-zA-Z0-9_\-]/', '', $key ); |
|
726 | + public static function sanitize_id($id = '') { |
|
727 | + $key = str_replace(' ', '-', trim($id)); |
|
728 | + return preg_replace('/[^a-zA-Z0-9_\-]/', '', $key); |
|
729 | 729 | } |
730 | 730 | |
731 | 731 | |
@@ -737,10 +737,10 @@ discard block |
||
737 | 737 | * @param string $tag |
738 | 738 | * @return string - newline character plus # of indents passed (can be + or -) |
739 | 739 | */ |
740 | - public static function nl( $indent = 0, $tag = 'none' ) { |
|
740 | + public static function nl($indent = 0, $tag = 'none') { |
|
741 | 741 | $html = "\n"; |
742 | - EEH_HTML::indent( $indent, $tag ); |
|
743 | - for ( $x = 0; $x < EEH_HTML::$_indent[ $tag ]; $x++ ) { |
|
742 | + EEH_HTML::indent($indent, $tag); |
|
743 | + for ($x = 0; $x < EEH_HTML::$_indent[$tag]; $x++) { |
|
744 | 744 | $html .= "\t"; |
745 | 745 | } |
746 | 746 | return $html; |
@@ -755,17 +755,17 @@ discard block |
||
755 | 755 | * @param int $indent can be negative to decrease the indentation level |
756 | 756 | * @param string $tag |
757 | 757 | */ |
758 | - public static function indent( $indent, $tag = 'none' ){ |
|
758 | + public static function indent($indent, $tag = 'none') { |
|
759 | 759 | static $default_indentation = FALSE; |
760 | - if ( ! $default_indentation ) { |
|
760 | + if ( ! $default_indentation) { |
|
761 | 761 | EEH_HTML::_set_default_indentation(); |
762 | 762 | $default_indentation = TRUE; |
763 | 763 | } |
764 | - if ( ! isset( EEH_HTML::$_indent[ $tag ] )) { |
|
765 | - EEH_HTML::$_indent[ $tag ] = 0; |
|
764 | + if ( ! isset(EEH_HTML::$_indent[$tag])) { |
|
765 | + EEH_HTML::$_indent[$tag] = 0; |
|
766 | 766 | } |
767 | - EEH_HTML::$_indent[ $tag ] += (int)$indent; |
|
768 | - EEH_HTML::$_indent[ $tag ] = EEH_HTML::$_indent[ $tag ] >= 0 ? EEH_HTML::$_indent[ $tag ] : 0; |
|
767 | + EEH_HTML::$_indent[$tag] += (int) $indent; |
|
768 | + EEH_HTML::$_indent[$tag] = EEH_HTML::$_indent[$tag] >= 0 ? EEH_HTML::$_indent[$tag] : 0; |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | |
@@ -811,15 +811,15 @@ discard block |
||
811 | 811 | * @global array $allowedtags |
812 | 812 | * @return array |
813 | 813 | */ |
814 | - public static function get_simple_tags(){ |
|
814 | + public static function get_simple_tags() { |
|
815 | 815 | global $allowedtags; |
816 | 816 | $tags_we_allow = $allowedtags; |
817 | - $tags_we_allow['ol']=array(); |
|
818 | - $tags_we_allow['ul']=array(); |
|
819 | - $tags_we_allow['li']=array(); |
|
820 | - $tags_we_allow['br']=array(); |
|
821 | - $tags_we_allow['p']=array(); |
|
822 | - return apply_filters( 'FHEE__EEH_HTML__get_simple_tags', $tags_we_allow ); |
|
817 | + $tags_we_allow['ol'] = array(); |
|
818 | + $tags_we_allow['ul'] = array(); |
|
819 | + $tags_we_allow['li'] = array(); |
|
820 | + $tags_we_allow['br'] = array(); |
|
821 | + $tags_we_allow['p'] = array(); |
|
822 | + return apply_filters('FHEE__EEH_HTML__get_simple_tags', $tags_we_allow); |
|
823 | 823 | } |
824 | 824 | |
825 | 825 |
@@ -280,7 +280,7 @@ |
||
280 | 280 | $pre_tax_subtotal = self::get_pre_tax_subtotal( $total_line_item ); |
281 | 281 | if ( $pre_tax_subtotal instanceof EE_Line_Item ){ |
282 | 282 | $success = $pre_tax_subtotal->add_child_line_item($item); |
283 | - }else{ |
|
283 | + } else{ |
|
284 | 284 | return FALSE; |
285 | 285 | } |
286 | 286 | $total_line_item->recalculate_total_including_taxes(); |
@@ -551,15 +551,15 @@ discard block |
||
551 | 551 | } |
552 | 552 | |
553 | 553 | /** |
554 | - * Given the grand total line item and a ticket, finds the event sub-total |
|
555 | - * line item the ticket's purchase should be added onto |
|
556 | - * |
|
557 | - * @access public |
|
558 | - * @param EE_Line_Item $grand_total the grand total line item |
|
559 | - * @param EE_Ticket $ticket |
|
560 | - * @throws \EE_Error |
|
561 | - * @return EE_Line_Item |
|
562 | - */ |
|
554 | + * Given the grand total line item and a ticket, finds the event sub-total |
|
555 | + * line item the ticket's purchase should be added onto |
|
556 | + * |
|
557 | + * @access public |
|
558 | + * @param EE_Line_Item $grand_total the grand total line item |
|
559 | + * @param EE_Ticket $ticket |
|
560 | + * @throws \EE_Error |
|
561 | + * @return EE_Line_Item |
|
562 | + */ |
|
563 | 563 | public static function get_event_line_item_for_ticket( EE_Line_Item $grand_total, EE_Ticket $ticket ) { |
564 | 564 | $first_datetime = $ticket->first_datetime(); |
565 | 565 | if ( ! $first_datetime instanceof EE_Datetime ) { |
@@ -807,22 +807,22 @@ discard block |
||
807 | 807 | $add_to_existing_line_item = false |
808 | 808 | ) { |
809 | 809 | $tax_subtotal = self::get_taxes_subtotal( $total_line_item ); |
810 | - $taxable_total = $total_line_item->taxable_total(); |
|
811 | - |
|
812 | - if( $add_to_existing_line_item ) { |
|
813 | - $new_tax = $tax_subtotal->get_child_line_item( $code ); |
|
814 | - EEM_Line_Item::instance()->delete( |
|
815 | - array( array( 'LIN_code' => array( '!=', $code ), 'LIN_parent' => $tax_subtotal->ID() ) ) |
|
816 | - ); |
|
817 | - } else { |
|
818 | - $new_tax = null; |
|
819 | - $tax_subtotal->delete_children_line_items(); |
|
820 | - } |
|
821 | - if( $new_tax ) { |
|
822 | - $new_tax->set_total( $new_tax->total() + $amount ); |
|
823 | - $new_tax->set_percent( $taxable_total ? $new_tax->total() / $taxable_total * 100 : 0 ); |
|
824 | - } else { |
|
825 | - //no existing tax item. Create it |
|
810 | + $taxable_total = $total_line_item->taxable_total(); |
|
811 | + |
|
812 | + if( $add_to_existing_line_item ) { |
|
813 | + $new_tax = $tax_subtotal->get_child_line_item( $code ); |
|
814 | + EEM_Line_Item::instance()->delete( |
|
815 | + array( array( 'LIN_code' => array( '!=', $code ), 'LIN_parent' => $tax_subtotal->ID() ) ) |
|
816 | + ); |
|
817 | + } else { |
|
818 | + $new_tax = null; |
|
819 | + $tax_subtotal->delete_children_line_items(); |
|
820 | + } |
|
821 | + if( $new_tax ) { |
|
822 | + $new_tax->set_total( $new_tax->total() + $amount ); |
|
823 | + $new_tax->set_percent( $taxable_total ? $new_tax->total() / $taxable_total * 100 : 0 ); |
|
824 | + } else { |
|
825 | + //no existing tax item. Create it |
|
826 | 826 | $new_tax = EE_Line_Item::new_instance( array( |
827 | 827 | 'TXN_ID' => $total_line_item->TXN_ID(), |
828 | 828 | 'LIN_name' => $name ? $name : __( 'Tax', 'event_espresso' ), |
@@ -835,16 +835,16 @@ discard block |
||
835 | 835 | ) ); |
836 | 836 | } |
837 | 837 | |
838 | - $new_tax = apply_filters( |
|
838 | + $new_tax = apply_filters( |
|
839 | 839 | 'FHEE__EEH_Line_Item__set_total_tax_to__new_tax_subtotal', |
840 | 840 | $new_tax, |
841 | 841 | $total_line_item |
842 | - ); |
|
843 | - $new_tax->save(); |
|
844 | - $tax_subtotal->set_total( $new_tax->total() ); |
|
845 | - $tax_subtotal->save(); |
|
846 | - $total_line_item->recalculate_total_including_taxes(); |
|
847 | - return $new_tax; |
|
842 | + ); |
|
843 | + $new_tax->save(); |
|
844 | + $tax_subtotal->set_total( $new_tax->total() ); |
|
845 | + $tax_subtotal->save(); |
|
846 | + $total_line_item->recalculate_total_including_taxes(); |
|
847 | + return $new_tax; |
|
848 | 848 | } |
849 | 849 | |
850 | 850 | |
@@ -990,7 +990,7 @@ discard block |
||
990 | 990 | if ( $child_line_item instanceof EE_Line_Item ) { |
991 | 991 | if ( |
992 | 992 | $child_line_item->type() === $line_item_type |
993 | - && ( |
|
993 | + && ( |
|
994 | 994 | $child_line_item->OBJ_type() === $obj_type || $obj_type === null |
995 | 995 | ) |
996 | 996 | ) { |
@@ -871,7 +871,7 @@ discard block |
||
871 | 871 | * Deletes ALL children of the passed line item |
872 | 872 | * |
873 | 873 | * @param EE_Line_Item $parent_line_item |
874 | - * @return bool |
|
874 | + * @return integer |
|
875 | 875 | * @throws \EE_Error |
876 | 876 | */ |
877 | 877 | public static function delete_all_child_items( EE_Line_Item $parent_line_item ) { |
@@ -1135,6 +1135,7 @@ discard block |
||
1135 | 1135 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
1136 | 1136 | * @param string $line_item_type one of the EEM_Line_Item constants |
1137 | 1137 | * @param string | NULL $obj_type object model class name (minus prefix) or NULL to ignore object type when searching |
1138 | + * @param string $obj_type |
|
1138 | 1139 | * @return EE_Line_Item[] |
1139 | 1140 | */ |
1140 | 1141 | protected static function _get_descendants_by_type_and_object_type( |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * |
4 | 4 | * EEH_Line_Item |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | * @return boolean success |
46 | 46 | * @throws \EE_Error |
47 | 47 | */ |
48 | - public static function add_unrelated_item( EE_Line_Item $parent_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = NULL ){ |
|
49 | - $items_subtotal = self::get_pre_tax_subtotal( $parent_line_item ); |
|
48 | + public static function add_unrelated_item(EE_Line_Item $parent_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = NULL) { |
|
49 | + $items_subtotal = self::get_pre_tax_subtotal($parent_line_item); |
|
50 | 50 | $line_item = EE_Line_Item::new_instance(array( |
51 | 51 | 'LIN_name' => $name, |
52 | 52 | 'LIN_desc' => $description, |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | 'LIN_quantity' => $quantity, |
55 | 55 | 'LIN_percent' => null, |
56 | 56 | 'LIN_is_taxable' => $taxable, |
57 | - 'LIN_order' => $items_subtotal instanceof EE_Line_Item ? count( $items_subtotal->children() ) : 0, |
|
57 | + 'LIN_order' => $items_subtotal instanceof EE_Line_Item ? count($items_subtotal->children()) : 0, |
|
58 | 58 | 'LIN_total' => (float) $unit_price * (int) $quantity, |
59 | 59 | 'LIN_type'=> EEM_Line_Item::type_line_item, |
60 | 60 | 'LIN_code' => $code, |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $line_item, |
65 | 65 | $parent_line_item |
66 | 66 | ); |
67 | - return self::add_item( $parent_line_item, $line_item ); |
|
67 | + return self::add_item($parent_line_item, $line_item); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @return boolean success |
87 | 87 | * @throws \EE_Error |
88 | 88 | */ |
89 | - public static function add_percentage_based_item( EE_Line_Item $parent_line_item, $name, $percentage_amount, $description = '', $taxable = FALSE ){ |
|
89 | + public static function add_percentage_based_item(EE_Line_Item $parent_line_item, $name, $percentage_amount, $description = '', $taxable = FALSE) { |
|
90 | 90 | $line_item = EE_Line_Item::new_instance(array( |
91 | 91 | 'LIN_name' => $name, |
92 | 92 | 'LIN_desc' => $description, |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | 'LIN_percent' => $percentage_amount, |
95 | 95 | 'LIN_quantity' => NULL, |
96 | 96 | 'LIN_is_taxable' => $taxable, |
97 | - 'LIN_total' => (float) ( $percentage_amount * ( $parent_line_item->total() / 100 ) ), |
|
97 | + 'LIN_total' => (float) ($percentage_amount * ($parent_line_item->total() / 100)), |
|
98 | 98 | 'LIN_type'=> EEM_Line_Item::type_line_item, |
99 | 99 | 'LIN_parent' => $parent_line_item->ID() |
100 | 100 | )); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | 'FHEE__EEH_Line_Item__add_percentage_based_item__line_item', |
103 | 103 | $line_item |
104 | 104 | ); |
105 | - return self::add_item( $parent_line_item, $line_item ); |
|
105 | + return self::add_item($parent_line_item, $line_item); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | |
@@ -123,15 +123,15 @@ discard block |
||
123 | 123 | * @return \EE_Line_Item |
124 | 124 | * @throws \EE_Error |
125 | 125 | */ |
126 | - public static function add_ticket_purchase( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ){ |
|
127 | - if ( ! $total_line_item instanceof EE_Line_Item || ! $total_line_item->is_total() ) { |
|
128 | - throw new EE_Error( sprintf( __( 'A valid line item total is required in order to add tickets. A line item of type "%s" was passed.', 'event_espresso' ), $ticket->ID(), $total_line_item->ID() ) ); |
|
126 | + public static function add_ticket_purchase(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) { |
|
127 | + if ( ! $total_line_item instanceof EE_Line_Item || ! $total_line_item->is_total()) { |
|
128 | + throw new EE_Error(sprintf(__('A valid line item total is required in order to add tickets. A line item of type "%s" was passed.', 'event_espresso'), $ticket->ID(), $total_line_item->ID())); |
|
129 | 129 | } |
130 | 130 | // either increment the qty for an existing ticket |
131 | - $line_item = self::increment_ticket_qty_if_already_in_cart( $total_line_item, $ticket, $qty ); |
|
131 | + $line_item = self::increment_ticket_qty_if_already_in_cart($total_line_item, $ticket, $qty); |
|
132 | 132 | // or add a new one |
133 | - if ( ! $line_item instanceof EE_Line_Item ) { |
|
134 | - $line_item = self::create_ticket_line_item( $total_line_item, $ticket, $qty ); |
|
133 | + if ( ! $line_item instanceof EE_Line_Item) { |
|
134 | + $line_item = self::create_ticket_line_item($total_line_item, $ticket, $qty); |
|
135 | 135 | } |
136 | 136 | $total_line_item->recalculate_total_including_taxes(); |
137 | 137 | return $line_item; |
@@ -147,11 +147,11 @@ discard block |
||
147 | 147 | * @return \EE_Line_Item |
148 | 148 | * @throws \EE_Error |
149 | 149 | */ |
150 | - public static function increment_ticket_qty_if_already_in_cart( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ) { |
|
150 | + public static function increment_ticket_qty_if_already_in_cart(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) { |
|
151 | 151 | $line_item = null; |
152 | - if ( $total_line_item instanceof EE_Line_Item && $total_line_item->is_total() ) { |
|
153 | - $ticket_line_items = EEH_Line_Item::get_ticket_line_items( $total_line_item ); |
|
154 | - foreach ( (array)$ticket_line_items as $ticket_line_item ) { |
|
152 | + if ($total_line_item instanceof EE_Line_Item && $total_line_item->is_total()) { |
|
153 | + $ticket_line_items = EEH_Line_Item::get_ticket_line_items($total_line_item); |
|
154 | + foreach ((array) $ticket_line_items as $ticket_line_item) { |
|
155 | 155 | if ( |
156 | 156 | $ticket_line_item instanceof EE_Line_Item |
157 | 157 | && (int) $ticket_line_item->OBJ_ID() === (int) $ticket->ID() |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | } |
162 | 162 | } |
163 | 163 | } |
164 | - if ( $line_item instanceof EE_Line_Item ) { |
|
165 | - EEH_Line_Item::increment_quantity( $line_item, $qty ); |
|
164 | + if ($line_item instanceof EE_Line_Item) { |
|
165 | + EEH_Line_Item::increment_quantity($line_item, $qty); |
|
166 | 166 | return $line_item; |
167 | 167 | } |
168 | 168 | return null; |
@@ -179,16 +179,16 @@ discard block |
||
179 | 179 | * @return void |
180 | 180 | * @throws \EE_Error |
181 | 181 | */ |
182 | - public static function increment_quantity( EE_Line_Item $line_item, $qty = 1 ) { |
|
183 | - if( ! $line_item->is_percent() ) { |
|
182 | + public static function increment_quantity(EE_Line_Item $line_item, $qty = 1) { |
|
183 | + if ( ! $line_item->is_percent()) { |
|
184 | 184 | $qty += $line_item->quantity(); |
185 | - $line_item->set_quantity( $qty ); |
|
186 | - $line_item->set_total( $line_item->unit_price() * $qty ); |
|
185 | + $line_item->set_quantity($qty); |
|
186 | + $line_item->set_total($line_item->unit_price() * $qty); |
|
187 | 187 | $line_item->save(); |
188 | 188 | } |
189 | - foreach( $line_item->children() as $child ) { |
|
190 | - if( $child->is_sub_line_item() ) { |
|
191 | - EEH_Line_Item::update_quantity( $child, $qty ); |
|
189 | + foreach ($line_item->children() as $child) { |
|
190 | + if ($child->is_sub_line_item()) { |
|
191 | + EEH_Line_Item::update_quantity($child, $qty); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | } |
@@ -204,17 +204,17 @@ discard block |
||
204 | 204 | * @return void |
205 | 205 | * @throws \EE_Error |
206 | 206 | */ |
207 | - public static function decrement_quantity( EE_Line_Item $line_item, $qty = 1 ) { |
|
208 | - if( ! $line_item->is_percent() ) { |
|
207 | + public static function decrement_quantity(EE_Line_Item $line_item, $qty = 1) { |
|
208 | + if ( ! $line_item->is_percent()) { |
|
209 | 209 | $qty = $line_item->quantity() - $qty; |
210 | - $qty = max( $qty, 0 ); |
|
211 | - $line_item->set_quantity( $qty ); |
|
212 | - $line_item->set_total( $line_item->unit_price() * $qty ); |
|
210 | + $qty = max($qty, 0); |
|
211 | + $line_item->set_quantity($qty); |
|
212 | + $line_item->set_total($line_item->unit_price() * $qty); |
|
213 | 213 | $line_item->save(); |
214 | 214 | } |
215 | - foreach( $line_item->children() as $child ) { |
|
216 | - if( $child->is_sub_line_item() ) { |
|
217 | - EEH_Line_Item::update_quantity( $child, $qty ); |
|
215 | + foreach ($line_item->children() as $child) { |
|
216 | + if ($child->is_sub_line_item()) { |
|
217 | + EEH_Line_Item::update_quantity($child, $qty); |
|
218 | 218 | } |
219 | 219 | } |
220 | 220 | } |
@@ -229,15 +229,15 @@ discard block |
||
229 | 229 | * @param int $new_quantity |
230 | 230 | * @throws \EE_Error |
231 | 231 | */ |
232 | - public static function update_quantity( EE_Line_Item $line_item, $new_quantity ) { |
|
233 | - if( ! $line_item->is_percent() ) { |
|
234 | - $line_item->set_quantity( $new_quantity ); |
|
235 | - $line_item->set_total( $line_item->unit_price() * $new_quantity ); |
|
232 | + public static function update_quantity(EE_Line_Item $line_item, $new_quantity) { |
|
233 | + if ( ! $line_item->is_percent()) { |
|
234 | + $line_item->set_quantity($new_quantity); |
|
235 | + $line_item->set_total($line_item->unit_price() * $new_quantity); |
|
236 | 236 | $line_item->save(); |
237 | 237 | } |
238 | - foreach( $line_item->children() as $child ) { |
|
239 | - if( $child->is_sub_line_item() ) { |
|
240 | - EEH_Line_Item::update_quantity( $child, $new_quantity ); |
|
238 | + foreach ($line_item->children() as $child) { |
|
239 | + if ($child->is_sub_line_item()) { |
|
240 | + EEH_Line_Item::update_quantity($child, $new_quantity); |
|
241 | 241 | } |
242 | 242 | } |
243 | 243 | } |
@@ -252,43 +252,43 @@ discard block |
||
252 | 252 | * @return \EE_Line_Item |
253 | 253 | * @throws \EE_Error |
254 | 254 | */ |
255 | - public static function create_ticket_line_item( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ) { |
|
255 | + public static function create_ticket_line_item(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) { |
|
256 | 256 | $datetimes = $ticket->datetimes(); |
257 | - $first_datetime = reset( $datetimes ); |
|
258 | - if( $first_datetime instanceof EE_Datetime && $first_datetime->event() instanceof EE_Event ) { |
|
257 | + $first_datetime = reset($datetimes); |
|
258 | + if ($first_datetime instanceof EE_Datetime && $first_datetime->event() instanceof EE_Event) { |
|
259 | 259 | $first_datetime_name = $first_datetime->event()->name(); |
260 | 260 | } else { |
261 | - $first_datetime_name = __( 'Event', 'event_espresso' ); |
|
261 | + $first_datetime_name = __('Event', 'event_espresso'); |
|
262 | 262 | } |
263 | - $event = sprintf( _x( '(For %1$s)', '(For Event Name)', 'event_espresso' ), $first_datetime_name ); |
|
263 | + $event = sprintf(_x('(For %1$s)', '(For Event Name)', 'event_espresso'), $first_datetime_name); |
|
264 | 264 | // get event subtotal line |
265 | - $events_sub_total = self::get_event_line_item_for_ticket( $total_line_item, $ticket ); |
|
265 | + $events_sub_total = self::get_event_line_item_for_ticket($total_line_item, $ticket); |
|
266 | 266 | // add $ticket to cart |
267 | - $line_item = EE_Line_Item::new_instance( array( |
|
267 | + $line_item = EE_Line_Item::new_instance(array( |
|
268 | 268 | 'LIN_name' => $ticket->name(), |
269 | - 'LIN_desc' => $ticket->description() !== '' ? $ticket->description() . ' ' . $event : $event, |
|
269 | + 'LIN_desc' => $ticket->description() !== '' ? $ticket->description().' '.$event : $event, |
|
270 | 270 | 'LIN_unit_price' => $ticket->price(), |
271 | 271 | 'LIN_quantity' => $qty, |
272 | 272 | 'LIN_is_taxable' => $ticket->taxable(), |
273 | - 'LIN_order' => count( $events_sub_total->children() ), |
|
273 | + 'LIN_order' => count($events_sub_total->children()), |
|
274 | 274 | 'LIN_total' => $ticket->price() * $qty, |
275 | 275 | 'LIN_type' => EEM_Line_Item::type_line_item, |
276 | 276 | 'OBJ_ID' => $ticket->ID(), |
277 | 277 | 'OBJ_type' => 'Ticket' |
278 | - ) ); |
|
278 | + )); |
|
279 | 279 | $line_item = apply_filters( |
280 | 280 | 'FHEE__EEH_Line_Item__create_ticket_line_item__line_item', |
281 | 281 | $line_item |
282 | 282 | ); |
283 | - $events_sub_total->add_child_line_item( $line_item ); |
|
283 | + $events_sub_total->add_child_line_item($line_item); |
|
284 | 284 | //now add the sub-line items |
285 | 285 | $running_total_for_ticket = 0; |
286 | - foreach ( $ticket->prices( array( 'order_by' => array( 'PRC_order' => 'ASC' ) ) ) as $price ) { |
|
286 | + foreach ($ticket->prices(array('order_by' => array('PRC_order' => 'ASC'))) as $price) { |
|
287 | 287 | $sign = $price->is_discount() ? -1 : 1; |
288 | 288 | $price_total = $price->is_percent() |
289 | 289 | ? $running_total_for_ticket * $price->amount() / 100 |
290 | 290 | : $price->amount() * $qty; |
291 | - $sub_line_item = EE_Line_Item::new_instance( array( |
|
291 | + $sub_line_item = EE_Line_Item::new_instance(array( |
|
292 | 292 | 'LIN_name' => $price->name(), |
293 | 293 | 'LIN_desc' => $price->desc(), |
294 | 294 | 'LIN_quantity' => $price->is_percent() ? null : $qty, |
@@ -298,18 +298,18 @@ discard block |
||
298 | 298 | 'LIN_type' => EEM_Line_Item::type_sub_line_item, |
299 | 299 | 'OBJ_ID' => $price->ID(), |
300 | 300 | 'OBJ_type' => 'Price' |
301 | - ) ); |
|
301 | + )); |
|
302 | 302 | $sub_line_item = apply_filters( |
303 | 303 | 'FHEE__EEH_Line_Item__create_ticket_line_item__sub_line_item', |
304 | 304 | $sub_line_item |
305 | 305 | ); |
306 | - if ( $price->is_percent() ) { |
|
307 | - $sub_line_item->set_percent( $sign * $price->amount() ); |
|
306 | + if ($price->is_percent()) { |
|
307 | + $sub_line_item->set_percent($sign * $price->amount()); |
|
308 | 308 | } else { |
309 | - $sub_line_item->set_unit_price( $sign * $price->amount() ); |
|
309 | + $sub_line_item->set_unit_price($sign * $price->amount()); |
|
310 | 310 | } |
311 | 311 | $running_total_for_ticket += $price_total; |
312 | - $line_item->add_child_line_item( $sub_line_item ); |
|
312 | + $line_item->add_child_line_item($sub_line_item); |
|
313 | 313 | } |
314 | 314 | return $line_item; |
315 | 315 | } |
@@ -329,11 +329,11 @@ discard block |
||
329 | 329 | * @return boolean |
330 | 330 | * @throws \EE_Error |
331 | 331 | */ |
332 | - public static function add_item( EE_Line_Item $total_line_item, EE_Line_Item $item ){ |
|
333 | - $pre_tax_subtotal = self::get_pre_tax_subtotal( $total_line_item ); |
|
334 | - if ( $pre_tax_subtotal instanceof EE_Line_Item ){ |
|
332 | + public static function add_item(EE_Line_Item $total_line_item, EE_Line_Item $item) { |
|
333 | + $pre_tax_subtotal = self::get_pre_tax_subtotal($total_line_item); |
|
334 | + if ($pre_tax_subtotal instanceof EE_Line_Item) { |
|
335 | 335 | $success = $pre_tax_subtotal->add_child_line_item($item); |
336 | - }else{ |
|
336 | + } else { |
|
337 | 337 | return FALSE; |
338 | 338 | } |
339 | 339 | $total_line_item->recalculate_total_including_taxes(); |
@@ -352,34 +352,34 @@ discard block |
||
352 | 352 | * @return bool success |
353 | 353 | * @throws \EE_Error |
354 | 354 | */ |
355 | - public static function cancel_ticket_line_item( EE_Line_Item $ticket_line_item, $qty = 1 ) { |
|
355 | + public static function cancel_ticket_line_item(EE_Line_Item $ticket_line_item, $qty = 1) { |
|
356 | 356 | // validate incoming line_item |
357 | - if ( $ticket_line_item->OBJ_type() !== 'Ticket' ) { |
|
357 | + if ($ticket_line_item->OBJ_type() !== 'Ticket') { |
|
358 | 358 | throw new EE_Error( |
359 | 359 | sprintf( |
360 | - __( 'The supplied line item must have an Object Type of "Ticket", not %1$s.', 'event_espresso' ), |
|
360 | + __('The supplied line item must have an Object Type of "Ticket", not %1$s.', 'event_espresso'), |
|
361 | 361 | $ticket_line_item->type() |
362 | 362 | ) |
363 | 363 | ); |
364 | 364 | } |
365 | - if ( $ticket_line_item->quantity() < $qty ) { |
|
365 | + if ($ticket_line_item->quantity() < $qty) { |
|
366 | 366 | throw new EE_Error( |
367 | 367 | sprintf( |
368 | - __( 'Can not cancel %1$d ticket(s) because the supplied line item has a quantity of %2$d.', 'event_espresso' ), |
|
368 | + __('Can not cancel %1$d ticket(s) because the supplied line item has a quantity of %2$d.', 'event_espresso'), |
|
369 | 369 | $qty, |
370 | 370 | $ticket_line_item->quantity() |
371 | 371 | ) |
372 | 372 | ); |
373 | 373 | } |
374 | 374 | // decrement ticket quantity; don't rely on auto-fixing when recalculating totals to do this |
375 | - $ticket_line_item->set_quantity( $ticket_line_item->quantity() - $qty ); |
|
376 | - foreach( $ticket_line_item->children() as $child_line_item ) { |
|
377 | - if( |
|
375 | + $ticket_line_item->set_quantity($ticket_line_item->quantity() - $qty); |
|
376 | + foreach ($ticket_line_item->children() as $child_line_item) { |
|
377 | + if ( |
|
378 | 378 | $child_line_item->is_sub_line_item() |
379 | 379 | && ! $child_line_item->is_percent() |
380 | 380 | && ! $child_line_item->is_cancellation() |
381 | 381 | ) { |
382 | - $child_line_item->set_quantity( $child_line_item->quantity() - $qty ); |
|
382 | + $child_line_item->set_quantity($child_line_item->quantity() - $qty); |
|
383 | 383 | } |
384 | 384 | } |
385 | 385 | // get cancellation sub line item |
@@ -387,37 +387,37 @@ discard block |
||
387 | 387 | $ticket_line_item, |
388 | 388 | EEM_Line_Item::type_cancellation |
389 | 389 | ); |
390 | - $cancellation_line_item = reset( $cancellation_line_item ); |
|
390 | + $cancellation_line_item = reset($cancellation_line_item); |
|
391 | 391 | // verify that this ticket was indeed previously cancelled |
392 | - if ( $cancellation_line_item instanceof EE_Line_Item ) { |
|
392 | + if ($cancellation_line_item instanceof EE_Line_Item) { |
|
393 | 393 | // increment cancelled quantity |
394 | - $cancellation_line_item->set_quantity( $cancellation_line_item->quantity() + $qty ); |
|
394 | + $cancellation_line_item->set_quantity($cancellation_line_item->quantity() + $qty); |
|
395 | 395 | } else { |
396 | 396 | // create cancellation sub line item |
397 | - $cancellation_line_item = EE_Line_Item::new_instance( array( |
|
398 | - 'LIN_name' => __( 'Cancellation', 'event_espresso' ), |
|
397 | + $cancellation_line_item = EE_Line_Item::new_instance(array( |
|
398 | + 'LIN_name' => __('Cancellation', 'event_espresso'), |
|
399 | 399 | 'LIN_desc' => sprintf( |
400 | - _x( 'Cancelled %1$s : %2$s', 'Cancelled Ticket Name : 2015-01-01 11:11', 'event_espresso' ), |
|
400 | + _x('Cancelled %1$s : %2$s', 'Cancelled Ticket Name : 2015-01-01 11:11', 'event_espresso'), |
|
401 | 401 | $ticket_line_item->name(), |
402 | - current_time( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ) ) |
|
402 | + current_time(get_option('date_format').' '.get_option('time_format')) |
|
403 | 403 | ), |
404 | 404 | 'LIN_unit_price' => 0, // $ticket_line_item->unit_price() |
405 | 405 | 'LIN_quantity' => $qty, |
406 | 406 | 'LIN_is_taxable' => $ticket_line_item->is_taxable(), |
407 | - 'LIN_order' => count( $ticket_line_item->children() ), |
|
407 | + 'LIN_order' => count($ticket_line_item->children()), |
|
408 | 408 | 'LIN_total' => 0, // $ticket_line_item->unit_price() |
409 | 409 | 'LIN_type' => EEM_Line_Item::type_cancellation, |
410 | - ) ); |
|
411 | - $ticket_line_item->add_child_line_item( $cancellation_line_item ); |
|
410 | + )); |
|
411 | + $ticket_line_item->add_child_line_item($cancellation_line_item); |
|
412 | 412 | } |
413 | - if ( $ticket_line_item->save_this_and_descendants() > 0 ) { |
|
413 | + if ($ticket_line_item->save_this_and_descendants() > 0) { |
|
414 | 414 | // decrement parent line item quantity |
415 | 415 | $event_line_item = $ticket_line_item->parent(); |
416 | - if ( $event_line_item instanceof EE_Line_Item && $event_line_item->OBJ_type() === 'Event' ) { |
|
417 | - $event_line_item->set_quantity( $event_line_item->quantity() - $qty ); |
|
416 | + if ($event_line_item instanceof EE_Line_Item && $event_line_item->OBJ_type() === 'Event') { |
|
417 | + $event_line_item->set_quantity($event_line_item->quantity() - $qty); |
|
418 | 418 | $event_line_item->save(); |
419 | 419 | } |
420 | - EEH_Line_Item::get_grand_total_and_recalculate_everything( $ticket_line_item ); |
|
420 | + EEH_Line_Item::get_grand_total_and_recalculate_everything($ticket_line_item); |
|
421 | 421 | return true; |
422 | 422 | } |
423 | 423 | return false; |
@@ -435,12 +435,12 @@ discard block |
||
435 | 435 | * @return bool success |
436 | 436 | * @throws \EE_Error |
437 | 437 | */ |
438 | - public static function reinstate_canceled_ticket_line_item( EE_Line_Item $ticket_line_item, $qty = 1 ) { |
|
438 | + public static function reinstate_canceled_ticket_line_item(EE_Line_Item $ticket_line_item, $qty = 1) { |
|
439 | 439 | // validate incoming line_item |
440 | - if ( $ticket_line_item->OBJ_type() !== 'Ticket' ) { |
|
440 | + if ($ticket_line_item->OBJ_type() !== 'Ticket') { |
|
441 | 441 | throw new EE_Error( |
442 | 442 | sprintf( |
443 | - __( 'The supplied line item must have an Object Type of "Ticket", not %1$s.', 'event_espresso' ), |
|
443 | + __('The supplied line item must have an Object Type of "Ticket", not %1$s.', 'event_espresso'), |
|
444 | 444 | $ticket_line_item->type() |
445 | 445 | ) |
446 | 446 | ); |
@@ -450,42 +450,42 @@ discard block |
||
450 | 450 | $ticket_line_item, |
451 | 451 | EEM_Line_Item::type_cancellation |
452 | 452 | ); |
453 | - $cancellation_line_item = reset( $cancellation_line_item ); |
|
453 | + $cancellation_line_item = reset($cancellation_line_item); |
|
454 | 454 | // verify that this ticket was indeed previously cancelled |
455 | - if ( ! $cancellation_line_item instanceof EE_Line_Item ) { |
|
455 | + if ( ! $cancellation_line_item instanceof EE_Line_Item) { |
|
456 | 456 | return false; |
457 | 457 | } |
458 | - if ( $cancellation_line_item->quantity() > $qty ) { |
|
458 | + if ($cancellation_line_item->quantity() > $qty) { |
|
459 | 459 | // decrement cancelled quantity |
460 | - $cancellation_line_item->set_quantity( $cancellation_line_item->quantity() - $qty ); |
|
461 | - } else if ( $cancellation_line_item->quantity() == $qty ) { |
|
460 | + $cancellation_line_item->set_quantity($cancellation_line_item->quantity() - $qty); |
|
461 | + } else if ($cancellation_line_item->quantity() == $qty) { |
|
462 | 462 | // decrement cancelled quantity in case anyone still has the object kicking around |
463 | - $cancellation_line_item->set_quantity( $cancellation_line_item->quantity() - $qty ); |
|
463 | + $cancellation_line_item->set_quantity($cancellation_line_item->quantity() - $qty); |
|
464 | 464 | // delete because quantity will end up as 0 |
465 | 465 | $cancellation_line_item->delete(); |
466 | 466 | // and attempt to destroy the object, |
467 | 467 | // even though PHP won't actually destroy it until it needs the memory |
468 | - unset( $cancellation_line_item ); |
|
468 | + unset($cancellation_line_item); |
|
469 | 469 | } else { |
470 | 470 | // what ?!?! negative quantity ?!?! |
471 | 471 | throw new EE_Error( |
472 | 472 | sprintf( |
473 | - __( 'Can not reinstate %1$d cancelled ticket(s) because the cancelled ticket quantity is only %2$d.', |
|
474 | - 'event_espresso' ), |
|
473 | + __('Can not reinstate %1$d cancelled ticket(s) because the cancelled ticket quantity is only %2$d.', |
|
474 | + 'event_espresso'), |
|
475 | 475 | $qty, |
476 | 476 | $cancellation_line_item->quantity() |
477 | 477 | ) |
478 | 478 | ); |
479 | 479 | } |
480 | 480 | // increment ticket quantity |
481 | - $ticket_line_item->set_quantity( $ticket_line_item->quantity() + $qty ); |
|
482 | - if ( $ticket_line_item->save_this_and_descendants() > 0 ) { |
|
481 | + $ticket_line_item->set_quantity($ticket_line_item->quantity() + $qty); |
|
482 | + if ($ticket_line_item->save_this_and_descendants() > 0) { |
|
483 | 483 | // increment parent line item quantity |
484 | 484 | $event_line_item = $ticket_line_item->parent(); |
485 | - if ( $event_line_item instanceof EE_Line_Item && $event_line_item->OBJ_type() === 'Event' ) { |
|
486 | - $event_line_item->set_quantity( $event_line_item->quantity() + $qty ); |
|
485 | + if ($event_line_item instanceof EE_Line_Item && $event_line_item->OBJ_type() === 'Event') { |
|
486 | + $event_line_item->set_quantity($event_line_item->quantity() + $qty); |
|
487 | 487 | } |
488 | - EEH_Line_Item::get_grand_total_and_recalculate_everything( $ticket_line_item ); |
|
488 | + EEH_Line_Item::get_grand_total_and_recalculate_everything($ticket_line_item); |
|
489 | 489 | return true; |
490 | 490 | } |
491 | 491 | return false; |
@@ -500,8 +500,8 @@ discard block |
||
500 | 500 | * @param EE_Line_Item $line_item |
501 | 501 | * @return \EE_Line_Item |
502 | 502 | */ |
503 | - public static function get_grand_total_and_recalculate_everything( EE_Line_Item $line_item ){ |
|
504 | - $grand_total_line_item = EEH_Line_Item::find_transaction_grand_total_for_line_item( $line_item ); |
|
503 | + public static function get_grand_total_and_recalculate_everything(EE_Line_Item $line_item) { |
|
504 | + $grand_total_line_item = EEH_Line_Item::find_transaction_grand_total_for_line_item($line_item); |
|
505 | 505 | return $grand_total_line_item->recalculate_total_including_taxes(); |
506 | 506 | } |
507 | 507 | |
@@ -514,11 +514,11 @@ discard block |
||
514 | 514 | * @return \EE_Line_Item |
515 | 515 | * @throws \EE_Error |
516 | 516 | */ |
517 | - public static function get_pre_tax_subtotal( EE_Line_Item $total_line_item ){ |
|
518 | - $pre_tax_subtotal = $total_line_item->get_child_line_item( 'pre-tax-subtotal' ); |
|
517 | + public static function get_pre_tax_subtotal(EE_Line_Item $total_line_item) { |
|
518 | + $pre_tax_subtotal = $total_line_item->get_child_line_item('pre-tax-subtotal'); |
|
519 | 519 | return $pre_tax_subtotal instanceof EE_Line_Item |
520 | 520 | ? $pre_tax_subtotal |
521 | - : self::create_pre_tax_subtotal( $total_line_item ); |
|
521 | + : self::create_pre_tax_subtotal($total_line_item); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | |
@@ -530,9 +530,9 @@ discard block |
||
530 | 530 | * @return \EE_Line_Item |
531 | 531 | * @throws \EE_Error |
532 | 532 | */ |
533 | - public static function get_taxes_subtotal( EE_Line_Item $total_line_item ){ |
|
534 | - $taxes = $total_line_item->get_child_line_item( 'taxes' ); |
|
535 | - return $taxes ? $taxes : self::create_taxes_subtotal( $total_line_item ); |
|
533 | + public static function get_taxes_subtotal(EE_Line_Item $total_line_item) { |
|
534 | + $taxes = $total_line_item->get_child_line_item('taxes'); |
|
535 | + return $taxes ? $taxes : self::create_taxes_subtotal($total_line_item); |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | |
@@ -545,12 +545,12 @@ discard block |
||
545 | 545 | * @return void |
546 | 546 | * @throws \EE_Error |
547 | 547 | */ |
548 | - public static function set_TXN_ID( EE_Line_Item $line_item, $transaction = NULL ){ |
|
549 | - if( $transaction ){ |
|
548 | + public static function set_TXN_ID(EE_Line_Item $line_item, $transaction = NULL) { |
|
549 | + if ($transaction) { |
|
550 | 550 | /** @type EEM_Transaction $EEM_Transaction */ |
551 | - $EEM_Transaction = EE_Registry::instance()->load_model( 'Transaction' ); |
|
552 | - $TXN_ID = $EEM_Transaction->ensure_is_ID( $transaction ); |
|
553 | - $line_item->set_TXN_ID( $TXN_ID ); |
|
551 | + $EEM_Transaction = EE_Registry::instance()->load_model('Transaction'); |
|
552 | + $TXN_ID = $EEM_Transaction->ensure_is_ID($transaction); |
|
553 | + $line_item->set_TXN_ID($TXN_ID); |
|
554 | 554 | } |
555 | 555 | } |
556 | 556 | |
@@ -565,8 +565,8 @@ discard block |
||
565 | 565 | * @return \EE_Line_Item of type total |
566 | 566 | * @throws \EE_Error |
567 | 567 | */ |
568 | - public static function create_total_line_item( $transaction = NULL ){ |
|
569 | - $total_line_item = EE_Line_Item::new_instance( array( |
|
568 | + public static function create_total_line_item($transaction = NULL) { |
|
569 | + $total_line_item = EE_Line_Item::new_instance(array( |
|
570 | 570 | 'LIN_code' => 'total', |
571 | 571 | 'LIN_name' => __('Grand Total', 'event_espresso'), |
572 | 572 | 'LIN_type' => EEM_Line_Item::type_total, |
@@ -576,9 +576,9 @@ discard block |
||
576 | 576 | 'FHEE__EEH_Line_Item__create_total_line_item__total_line_item', |
577 | 577 | $total_line_item |
578 | 578 | ); |
579 | - self::set_TXN_ID( $total_line_item, $transaction ); |
|
580 | - self::create_pre_tax_subtotal( $total_line_item, $transaction ); |
|
581 | - self::create_taxes_subtotal( $total_line_item, $transaction ); |
|
579 | + self::set_TXN_ID($total_line_item, $transaction); |
|
580 | + self::create_pre_tax_subtotal($total_line_item, $transaction); |
|
581 | + self::create_taxes_subtotal($total_line_item, $transaction); |
|
582 | 582 | return $total_line_item; |
583 | 583 | } |
584 | 584 | |
@@ -592,19 +592,19 @@ discard block |
||
592 | 592 | * @return EE_Line_Item |
593 | 593 | * @throws \EE_Error |
594 | 594 | */ |
595 | - protected static function create_pre_tax_subtotal( EE_Line_Item $total_line_item, $transaction = NULL ){ |
|
596 | - $pre_tax_line_item = EE_Line_Item::new_instance( array( |
|
595 | + protected static function create_pre_tax_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
596 | + $pre_tax_line_item = EE_Line_Item::new_instance(array( |
|
597 | 597 | 'LIN_code' => 'pre-tax-subtotal', |
598 | - 'LIN_name' => __( 'Pre-Tax Subtotal', 'event_espresso' ), |
|
598 | + 'LIN_name' => __('Pre-Tax Subtotal', 'event_espresso'), |
|
599 | 599 | 'LIN_type' => EEM_Line_Item::type_sub_total |
600 | - ) ); |
|
600 | + )); |
|
601 | 601 | $pre_tax_line_item = apply_filters( |
602 | 602 | 'FHEE__EEH_Line_Item__create_pre_tax_subtotal__pre_tax_line_item', |
603 | 603 | $pre_tax_line_item |
604 | 604 | ); |
605 | - self::set_TXN_ID( $pre_tax_line_item, $transaction ); |
|
606 | - $total_line_item->add_child_line_item( $pre_tax_line_item ); |
|
607 | - self::create_event_subtotal( $pre_tax_line_item, $transaction ); |
|
605 | + self::set_TXN_ID($pre_tax_line_item, $transaction); |
|
606 | + $total_line_item->add_child_line_item($pre_tax_line_item); |
|
607 | + self::create_event_subtotal($pre_tax_line_item, $transaction); |
|
608 | 608 | return $pre_tax_line_item; |
609 | 609 | } |
610 | 610 | |
@@ -619,21 +619,21 @@ discard block |
||
619 | 619 | * @return EE_Line_Item |
620 | 620 | * @throws \EE_Error |
621 | 621 | */ |
622 | - protected static function create_taxes_subtotal( EE_Line_Item $total_line_item, $transaction = NULL ){ |
|
622 | + protected static function create_taxes_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
623 | 623 | $tax_line_item = EE_Line_Item::new_instance(array( |
624 | 624 | 'LIN_code' => 'taxes', |
625 | 625 | 'LIN_name' => __('Taxes', 'event_espresso'), |
626 | 626 | 'LIN_type' => EEM_Line_Item::type_tax_sub_total, |
627 | - 'LIN_order' => 1000,//this should always come last |
|
627 | + 'LIN_order' => 1000, //this should always come last |
|
628 | 628 | )); |
629 | 629 | $tax_line_item = apply_filters( |
630 | 630 | 'FHEE__EEH_Line_Item__create_taxes_subtotal__tax_line_item', |
631 | 631 | $tax_line_item |
632 | 632 | ); |
633 | - self::set_TXN_ID( $tax_line_item, $transaction ); |
|
634 | - $total_line_item->add_child_line_item( $tax_line_item ); |
|
633 | + self::set_TXN_ID($tax_line_item, $transaction); |
|
634 | + $total_line_item->add_child_line_item($tax_line_item); |
|
635 | 635 | //and lastly, add the actual taxes |
636 | - self::apply_taxes( $total_line_item ); |
|
636 | + self::apply_taxes($total_line_item); |
|
637 | 637 | return $tax_line_item; |
638 | 638 | } |
639 | 639 | |
@@ -648,11 +648,11 @@ discard block |
||
648 | 648 | * @return EE_Line_Item |
649 | 649 | * @throws \EE_Error |
650 | 650 | */ |
651 | - public static function create_event_subtotal( EE_Line_Item $pre_tax_line_item, $transaction = NULL, $event = NULL ){ |
|
651 | + public static function create_event_subtotal(EE_Line_Item $pre_tax_line_item, $transaction = NULL, $event = NULL) { |
|
652 | 652 | $event_line_item = EE_Line_Item::new_instance(array( |
653 | - 'LIN_code' => self::get_event_code( $event ), |
|
654 | - 'LIN_name' => self::get_event_name( $event ), |
|
655 | - 'LIN_desc' => self::get_event_desc( $event ), |
|
653 | + 'LIN_code' => self::get_event_code($event), |
|
654 | + 'LIN_name' => self::get_event_name($event), |
|
655 | + 'LIN_desc' => self::get_event_desc($event), |
|
656 | 656 | 'LIN_type' => EEM_Line_Item::type_sub_total, |
657 | 657 | 'OBJ_type' => 'Event', |
658 | 658 | 'OBJ_ID' => $event instanceof EE_Event ? $event->ID() : 0 |
@@ -661,8 +661,8 @@ discard block |
||
661 | 661 | 'FHEE__EEH_Line_Item__create_event_subtotal__event_line_item', |
662 | 662 | $event_line_item |
663 | 663 | ); |
664 | - self::set_TXN_ID( $event_line_item, $transaction ); |
|
665 | - $pre_tax_line_item->add_child_line_item( $event_line_item ); |
|
664 | + self::set_TXN_ID($event_line_item, $transaction); |
|
665 | + $pre_tax_line_item->add_child_line_item($event_line_item); |
|
666 | 666 | return $event_line_item; |
667 | 667 | } |
668 | 668 | |
@@ -675,8 +675,8 @@ discard block |
||
675 | 675 | * @return string |
676 | 676 | * @throws \EE_Error |
677 | 677 | */ |
678 | - public static function get_event_code( $event ) { |
|
679 | - return 'event-' . ( $event instanceof EE_Event ? $event->ID() : '0' ); |
|
678 | + public static function get_event_code($event) { |
|
679 | + return 'event-'.($event instanceof EE_Event ? $event->ID() : '0'); |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | /** |
@@ -684,8 +684,8 @@ discard block |
||
684 | 684 | * @param EE_Event $event |
685 | 685 | * @return string |
686 | 686 | */ |
687 | - public static function get_event_name( $event ) { |
|
688 | - return $event instanceof EE_Event ? $event->name() : __( 'Event', 'event_espresso' ); |
|
687 | + public static function get_event_name($event) { |
|
688 | + return $event instanceof EE_Event ? $event->name() : __('Event', 'event_espresso'); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | /** |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | * @param EE_Event $event |
694 | 694 | * @return string |
695 | 695 | */ |
696 | - public static function get_event_desc( $event ) { |
|
696 | + public static function get_event_desc($event) { |
|
697 | 697 | return $event instanceof EE_Event ? $event->short_description() : ''; |
698 | 698 | } |
699 | 699 | |
@@ -707,27 +707,27 @@ discard block |
||
707 | 707 | * @throws \EE_Error |
708 | 708 | * @return EE_Line_Item |
709 | 709 | */ |
710 | - public static function get_event_line_item_for_ticket( EE_Line_Item $grand_total, EE_Ticket $ticket ) { |
|
710 | + public static function get_event_line_item_for_ticket(EE_Line_Item $grand_total, EE_Ticket $ticket) { |
|
711 | 711 | $first_datetime = $ticket->first_datetime(); |
712 | - if ( ! $first_datetime instanceof EE_Datetime ) { |
|
712 | + if ( ! $first_datetime instanceof EE_Datetime) { |
|
713 | 713 | throw new EE_Error( |
714 | - sprintf( __( 'The supplied ticket (ID %d) has no datetimes', 'event_espresso' ), $ticket->ID() ) |
|
714 | + sprintf(__('The supplied ticket (ID %d) has no datetimes', 'event_espresso'), $ticket->ID()) |
|
715 | 715 | ); |
716 | 716 | } |
717 | 717 | $event = $first_datetime->event(); |
718 | - if ( ! $event instanceof EE_Event ) { |
|
718 | + if ( ! $event instanceof EE_Event) { |
|
719 | 719 | throw new EE_Error( |
720 | 720 | sprintf( |
721 | - __( 'The supplied ticket (ID %d) has no event data associated with it.', 'event_espresso' ), |
|
721 | + __('The supplied ticket (ID %d) has no event data associated with it.', 'event_espresso'), |
|
722 | 722 | $ticket->ID() |
723 | 723 | ) |
724 | 724 | ); |
725 | 725 | } |
726 | - $events_sub_total = EEH_Line_Item::get_event_line_item( $grand_total, $event ); |
|
727 | - if ( ! $events_sub_total instanceof EE_Line_Item ) { |
|
726 | + $events_sub_total = EEH_Line_Item::get_event_line_item($grand_total, $event); |
|
727 | + if ( ! $events_sub_total instanceof EE_Line_Item) { |
|
728 | 728 | throw new EE_Error( |
729 | 729 | sprintf( |
730 | - __( 'There is no events sub-total for ticket %s on total line item %d', 'event_espresso' ), |
|
730 | + __('There is no events sub-total for ticket %s on total line item %d', 'event_espresso'), |
|
731 | 731 | $ticket->ID(), |
732 | 732 | $grand_total->ID() |
733 | 733 | ) |
@@ -746,31 +746,31 @@ discard block |
||
746 | 746 | * @return EE_Line_Item for the event subtotal which is a child of $grand_total |
747 | 747 | * @throws \EE_Error |
748 | 748 | */ |
749 | - public static function get_event_line_item( EE_Line_Item $grand_total, $event ) { |
|
749 | + public static function get_event_line_item(EE_Line_Item $grand_total, $event) { |
|
750 | 750 | /** @type EE_Event $event */ |
751 | - $event = EEM_Event::instance()->ensure_is_obj( $event, true ); |
|
751 | + $event = EEM_Event::instance()->ensure_is_obj($event, true); |
|
752 | 752 | $event_line_item = NULL; |
753 | 753 | $found = false; |
754 | - foreach ( EEH_Line_Item::get_event_subtotals( $grand_total ) as $event_line_item ) { |
|
754 | + foreach (EEH_Line_Item::get_event_subtotals($grand_total) as $event_line_item) { |
|
755 | 755 | // default event subtotal, we should only ever find this the first time this method is called |
756 | - if ( ! $event_line_item->OBJ_ID() ) { |
|
756 | + if ( ! $event_line_item->OBJ_ID()) { |
|
757 | 757 | // let's use this! but first... set the event details |
758 | - EEH_Line_Item::set_event_subtotal_details( $event_line_item, $event ); |
|
758 | + EEH_Line_Item::set_event_subtotal_details($event_line_item, $event); |
|
759 | 759 | $found = true; |
760 | 760 | break; |
761 | - } else if ( $event_line_item->OBJ_ID() === $event->ID() ) { |
|
761 | + } else if ($event_line_item->OBJ_ID() === $event->ID()) { |
|
762 | 762 | // found existing line item for this event in the cart, so break out of loop and use this one |
763 | 763 | $found = true; |
764 | 764 | break; |
765 | 765 | } |
766 | 766 | } |
767 | - if ( ! $found ) { |
|
767 | + if ( ! $found) { |
|
768 | 768 | //there is no event sub-total yet, so add it |
769 | - $pre_tax_subtotal = EEH_Line_Item::get_pre_tax_subtotal( $grand_total ); |
|
769 | + $pre_tax_subtotal = EEH_Line_Item::get_pre_tax_subtotal($grand_total); |
|
770 | 770 | // create a new "event" subtotal below that |
771 | - $event_line_item = EEH_Line_Item::create_event_subtotal( $pre_tax_subtotal, null, $event ); |
|
771 | + $event_line_item = EEH_Line_Item::create_event_subtotal($pre_tax_subtotal, null, $event); |
|
772 | 772 | // and set the event details |
773 | - EEH_Line_Item::set_event_subtotal_details( $event_line_item, $event ); |
|
773 | + EEH_Line_Item::set_event_subtotal_details($event_line_item, $event); |
|
774 | 774 | } |
775 | 775 | return $event_line_item; |
776 | 776 | } |
@@ -791,13 +791,13 @@ discard block |
||
791 | 791 | EE_Event $event, |
792 | 792 | $transaction = null |
793 | 793 | ) { |
794 | - if ( $event instanceof EE_Event ) { |
|
795 | - $event_line_item->set_code( self::get_event_code( $event ) ); |
|
796 | - $event_line_item->set_name( self::get_event_name( $event ) ); |
|
797 | - $event_line_item->set_desc( self::get_event_desc( $event ) ); |
|
798 | - $event_line_item->set_OBJ_ID( $event->ID() ); |
|
794 | + if ($event instanceof EE_Event) { |
|
795 | + $event_line_item->set_code(self::get_event_code($event)); |
|
796 | + $event_line_item->set_name(self::get_event_name($event)); |
|
797 | + $event_line_item->set_desc(self::get_event_desc($event)); |
|
798 | + $event_line_item->set_OBJ_ID($event->ID()); |
|
799 | 799 | } |
800 | - self::set_TXN_ID( $event_line_item, $transaction ); |
|
800 | + self::set_TXN_ID($event_line_item, $transaction); |
|
801 | 801 | } |
802 | 802 | |
803 | 803 | |
@@ -810,19 +810,19 @@ discard block |
||
810 | 810 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
811 | 811 | * @throws \EE_Error |
812 | 812 | */ |
813 | - public static function apply_taxes( EE_Line_Item $total_line_item ){ |
|
813 | + public static function apply_taxes(EE_Line_Item $total_line_item) { |
|
814 | 814 | /** @type EEM_Price $EEM_Price */ |
815 | - $EEM_Price = EE_Registry::instance()->load_model( 'Price' ); |
|
815 | + $EEM_Price = EE_Registry::instance()->load_model('Price'); |
|
816 | 816 | // get array of taxes via Price Model |
817 | 817 | $ordered_taxes = $EEM_Price->get_all_prices_that_are_taxes(); |
818 | - ksort( $ordered_taxes ); |
|
819 | - $taxes_line_item = self::get_taxes_subtotal( $total_line_item ); |
|
818 | + ksort($ordered_taxes); |
|
819 | + $taxes_line_item = self::get_taxes_subtotal($total_line_item); |
|
820 | 820 | //just to be safe, remove its old tax line items |
821 | 821 | $taxes_line_item->delete_children_line_items(); |
822 | 822 | //loop thru taxes |
823 | - foreach ( $ordered_taxes as $order => $taxes ) { |
|
824 | - foreach ( $taxes as $tax ) { |
|
825 | - if ( $tax instanceof EE_Price ) { |
|
823 | + foreach ($ordered_taxes as $order => $taxes) { |
|
824 | + foreach ($taxes as $tax) { |
|
825 | + if ($tax instanceof EE_Price) { |
|
826 | 826 | $tax_line_item = EE_Line_Item::new_instance( |
827 | 827 | array( |
828 | 828 | 'LIN_name' => $tax->name(), |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | 'FHEE__EEH_Line_Item__apply_taxes__tax_line_item', |
841 | 841 | $tax_line_item |
842 | 842 | ); |
843 | - $taxes_line_item->add_child_line_item( $tax_line_item ); |
|
843 | + $taxes_line_item->add_child_line_item($tax_line_item); |
|
844 | 844 | } |
845 | 845 | } |
846 | 846 | } |
@@ -857,10 +857,10 @@ discard block |
||
857 | 857 | * @return float |
858 | 858 | * @throws \EE_Error |
859 | 859 | */ |
860 | - public static function ensure_taxes_applied( $total_line_item ){ |
|
861 | - $taxes_subtotal = self::get_taxes_subtotal( $total_line_item ); |
|
862 | - if( ! $taxes_subtotal->children()){ |
|
863 | - self::apply_taxes( $total_line_item ); |
|
860 | + public static function ensure_taxes_applied($total_line_item) { |
|
861 | + $taxes_subtotal = self::get_taxes_subtotal($total_line_item); |
|
862 | + if ( ! $taxes_subtotal->children()) { |
|
863 | + self::apply_taxes($total_line_item); |
|
864 | 864 | } |
865 | 865 | return $taxes_subtotal->total(); |
866 | 866 | } |
@@ -874,16 +874,16 @@ discard block |
||
874 | 874 | * @return bool |
875 | 875 | * @throws \EE_Error |
876 | 876 | */ |
877 | - public static function delete_all_child_items( EE_Line_Item $parent_line_item ) { |
|
877 | + public static function delete_all_child_items(EE_Line_Item $parent_line_item) { |
|
878 | 878 | $deleted = 0; |
879 | - foreach ( $parent_line_item->children() as $child_line_item ) { |
|
880 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
881 | - $deleted += EEH_Line_Item::delete_all_child_items( $child_line_item ); |
|
882 | - if ( $child_line_item->ID() ) { |
|
879 | + foreach ($parent_line_item->children() as $child_line_item) { |
|
880 | + if ($child_line_item instanceof EE_Line_Item) { |
|
881 | + $deleted += EEH_Line_Item::delete_all_child_items($child_line_item); |
|
882 | + if ($child_line_item->ID()) { |
|
883 | 883 | $child_line_item->delete(); |
884 | - unset( $child_line_item ); |
|
884 | + unset($child_line_item); |
|
885 | 885 | } else { |
886 | - $parent_line_item->delete_child_line_item( $child_line_item->code() ); |
|
886 | + $parent_line_item->delete_child_line_item($child_line_item->code()); |
|
887 | 887 | } |
888 | 888 | $deleted++; |
889 | 889 | } |
@@ -905,9 +905,9 @@ discard block |
||
905 | 905 | * @param array|bool|string $line_item_codes |
906 | 906 | * @return int number of items successfully removed |
907 | 907 | */ |
908 | - public static function delete_items( EE_Line_Item $total_line_item, $line_item_codes = FALSE ) { |
|
908 | + public static function delete_items(EE_Line_Item $total_line_item, $line_item_codes = FALSE) { |
|
909 | 909 | |
910 | - if( $total_line_item->type() !== EEM_Line_Item::type_total ){ |
|
910 | + if ($total_line_item->type() !== EEM_Line_Item::type_total) { |
|
911 | 911 | EE_Error::doing_it_wrong( |
912 | 912 | 'EEH_Line_Item::delete_items', |
913 | 913 | __( |
@@ -917,20 +917,20 @@ discard block |
||
917 | 917 | '4.6.18' |
918 | 918 | ); |
919 | 919 | } |
920 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
920 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
921 | 921 | |
922 | 922 | // check if only a single line_item_id was passed |
923 | - if ( ! empty( $line_item_codes ) && ! is_array( $line_item_codes )) { |
|
923 | + if ( ! empty($line_item_codes) && ! is_array($line_item_codes)) { |
|
924 | 924 | // place single line_item_id in an array to appear as multiple line_item_ids |
925 | - $line_item_codes = array ( $line_item_codes ); |
|
925 | + $line_item_codes = array($line_item_codes); |
|
926 | 926 | } |
927 | 927 | $removals = 0; |
928 | 928 | // cycle thru line_item_ids |
929 | - foreach ( $line_item_codes as $line_item_id ) { |
|
929 | + foreach ($line_item_codes as $line_item_id) { |
|
930 | 930 | $removals += $total_line_item->delete_child_line_item($line_item_id); |
931 | 931 | } |
932 | 932 | |
933 | - if ( $removals > 0 ) { |
|
933 | + if ($removals > 0) { |
|
934 | 934 | $total_line_item->recalculate_taxes_and_tax_total(); |
935 | 935 | return $removals; |
936 | 936 | } else { |
@@ -963,33 +963,33 @@ discard block |
||
963 | 963 | $code = null, |
964 | 964 | $add_to_existing_line_item = false |
965 | 965 | ) { |
966 | - $tax_subtotal = self::get_taxes_subtotal( $total_line_item ); |
|
966 | + $tax_subtotal = self::get_taxes_subtotal($total_line_item); |
|
967 | 967 | $taxable_total = $total_line_item->taxable_total(); |
968 | 968 | |
969 | - if( $add_to_existing_line_item ) { |
|
970 | - $new_tax = $tax_subtotal->get_child_line_item( $code ); |
|
969 | + if ($add_to_existing_line_item) { |
|
970 | + $new_tax = $tax_subtotal->get_child_line_item($code); |
|
971 | 971 | EEM_Line_Item::instance()->delete( |
972 | - array( array( 'LIN_code' => array( '!=', $code ), 'LIN_parent' => $tax_subtotal->ID() ) ) |
|
972 | + array(array('LIN_code' => array('!=', $code), 'LIN_parent' => $tax_subtotal->ID())) |
|
973 | 973 | ); |
974 | 974 | } else { |
975 | 975 | $new_tax = null; |
976 | 976 | $tax_subtotal->delete_children_line_items(); |
977 | 977 | } |
978 | - if( $new_tax ) { |
|
979 | - $new_tax->set_total( $new_tax->total() + $amount ); |
|
980 | - $new_tax->set_percent( $taxable_total ? $new_tax->total() / $taxable_total * 100 : 0 ); |
|
978 | + if ($new_tax) { |
|
979 | + $new_tax->set_total($new_tax->total() + $amount); |
|
980 | + $new_tax->set_percent($taxable_total ? $new_tax->total() / $taxable_total * 100 : 0); |
|
981 | 981 | } else { |
982 | 982 | //no existing tax item. Create it |
983 | - $new_tax = EE_Line_Item::new_instance( array( |
|
983 | + $new_tax = EE_Line_Item::new_instance(array( |
|
984 | 984 | 'TXN_ID' => $total_line_item->TXN_ID(), |
985 | - 'LIN_name' => $name ? $name : __( 'Tax', 'event_espresso' ), |
|
985 | + 'LIN_name' => $name ? $name : __('Tax', 'event_espresso'), |
|
986 | 986 | 'LIN_desc' => $description ? $description : '', |
987 | - 'LIN_percent' => $taxable_total ? ( $amount / $taxable_total * 100 ) : 0, |
|
987 | + 'LIN_percent' => $taxable_total ? ($amount / $taxable_total * 100) : 0, |
|
988 | 988 | 'LIN_total' => $amount, |
989 | 989 | 'LIN_parent' => $tax_subtotal->ID(), |
990 | 990 | 'LIN_type' => EEM_Line_Item::type_tax, |
991 | 991 | 'LIN_code' => $code |
992 | - ) ); |
|
992 | + )); |
|
993 | 993 | } |
994 | 994 | |
995 | 995 | $new_tax = apply_filters( |
@@ -998,7 +998,7 @@ discard block |
||
998 | 998 | $total_line_item |
999 | 999 | ); |
1000 | 1000 | $new_tax->save(); |
1001 | - $tax_subtotal->set_total( $new_tax->total() ); |
|
1001 | + $tax_subtotal->set_total($new_tax->total()); |
|
1002 | 1002 | $tax_subtotal->save(); |
1003 | 1003 | $total_line_item->recalculate_total_including_taxes(); |
1004 | 1004 | return $new_tax; |
@@ -1020,14 +1020,14 @@ discard block |
||
1020 | 1020 | $code_substring_for_whitelist = null |
1021 | 1021 | ) { |
1022 | 1022 | $whitelisted = false; |
1023 | - if( $code_substring_for_whitelist !== null ) { |
|
1024 | - $whitelisted = strpos( $line_item->code(), $code_substring_for_whitelist ) !== false ? true : false; |
|
1023 | + if ($code_substring_for_whitelist !== null) { |
|
1024 | + $whitelisted = strpos($line_item->code(), $code_substring_for_whitelist) !== false ? true : false; |
|
1025 | 1025 | } |
1026 | - if( ! $whitelisted && $line_item->is_line_item() ) { |
|
1027 | - $line_item->set_is_taxable( $taxable ); |
|
1026 | + if ( ! $whitelisted && $line_item->is_line_item()) { |
|
1027 | + $line_item->set_is_taxable($taxable); |
|
1028 | 1028 | } |
1029 | - foreach( $line_item->children() as $child_line_item ) { |
|
1030 | - EEH_Line_Item::set_line_items_taxable( $child_line_item, $taxable, $code_substring_for_whitelist ); |
|
1029 | + foreach ($line_item->children() as $child_line_item) { |
|
1030 | + EEH_Line_Item::set_line_items_taxable($child_line_item, $taxable, $code_substring_for_whitelist); |
|
1031 | 1031 | } |
1032 | 1032 | } |
1033 | 1033 | |
@@ -1040,8 +1040,8 @@ discard block |
||
1040 | 1040 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
1041 | 1041 | * @return EE_Line_Item[] |
1042 | 1042 | */ |
1043 | - public static function get_event_subtotals( EE_Line_Item $parent_line_item ) { |
|
1044 | - return self::get_subtotals_of_object_type( $parent_line_item, 'Event' ); |
|
1043 | + public static function get_event_subtotals(EE_Line_Item $parent_line_item) { |
|
1044 | + return self::get_subtotals_of_object_type($parent_line_item, 'Event'); |
|
1045 | 1045 | } |
1046 | 1046 | |
1047 | 1047 | |
@@ -1054,7 +1054,7 @@ discard block |
||
1054 | 1054 | * @param string $obj_type |
1055 | 1055 | * @return EE_Line_Item[] |
1056 | 1056 | */ |
1057 | - public static function get_subtotals_of_object_type( EE_Line_Item $parent_line_item, $obj_type = '' ) { |
|
1057 | + public static function get_subtotals_of_object_type(EE_Line_Item $parent_line_item, $obj_type = '') { |
|
1058 | 1058 | return self::_get_descendants_by_type_and_object_type( |
1059 | 1059 | $parent_line_item, |
1060 | 1060 | EEM_Line_Item::type_sub_total, |
@@ -1071,8 +1071,8 @@ discard block |
||
1071 | 1071 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
1072 | 1072 | * @return EE_Line_Item[] |
1073 | 1073 | */ |
1074 | - public static function get_ticket_line_items( EE_Line_Item $parent_line_item ) { |
|
1075 | - return self::get_line_items_of_object_type( $parent_line_item, 'Ticket' ); |
|
1074 | + public static function get_ticket_line_items(EE_Line_Item $parent_line_item) { |
|
1075 | + return self::get_line_items_of_object_type($parent_line_item, 'Ticket'); |
|
1076 | 1076 | } |
1077 | 1077 | |
1078 | 1078 | |
@@ -1085,8 +1085,8 @@ discard block |
||
1085 | 1085 | * @param string $obj_type |
1086 | 1086 | * @return EE_Line_Item[] |
1087 | 1087 | */ |
1088 | - public static function get_line_items_of_object_type( EE_Line_Item $parent_line_item, $obj_type = '' ) { |
|
1089 | - return self::_get_descendants_by_type_and_object_type( $parent_line_item, EEM_Line_Item::type_line_item, $obj_type ); |
|
1088 | + public static function get_line_items_of_object_type(EE_Line_Item $parent_line_item, $obj_type = '') { |
|
1089 | + return self::_get_descendants_by_type_and_object_type($parent_line_item, EEM_Line_Item::type_line_item, $obj_type); |
|
1090 | 1090 | } |
1091 | 1091 | |
1092 | 1092 | |
@@ -1097,8 +1097,8 @@ discard block |
||
1097 | 1097 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
1098 | 1098 | * @return EE_Line_Item[] |
1099 | 1099 | */ |
1100 | - public static function get_tax_descendants( EE_Line_Item $parent_line_item ) { |
|
1101 | - return EEH_Line_Item::get_descendants_of_type( $parent_line_item, EEM_Line_Item::type_tax ); |
|
1100 | + public static function get_tax_descendants(EE_Line_Item $parent_line_item) { |
|
1101 | + return EEH_Line_Item::get_descendants_of_type($parent_line_item, EEM_Line_Item::type_tax); |
|
1102 | 1102 | } |
1103 | 1103 | |
1104 | 1104 | |
@@ -1109,8 +1109,8 @@ discard block |
||
1109 | 1109 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
1110 | 1110 | * @return EE_Line_Item[] |
1111 | 1111 | */ |
1112 | - public static function get_line_item_descendants( EE_Line_Item $parent_line_item ) { |
|
1113 | - return EEH_Line_Item::get_descendants_of_type( $parent_line_item, EEM_Line_Item::type_line_item ); |
|
1112 | + public static function get_line_item_descendants(EE_Line_Item $parent_line_item) { |
|
1113 | + return EEH_Line_Item::get_descendants_of_type($parent_line_item, EEM_Line_Item::type_line_item); |
|
1114 | 1114 | } |
1115 | 1115 | |
1116 | 1116 | |
@@ -1123,8 +1123,8 @@ discard block |
||
1123 | 1123 | * @param string $line_item_type one of the EEM_Line_Item constants |
1124 | 1124 | * @return EE_Line_Item[] |
1125 | 1125 | */ |
1126 | - public static function get_descendants_of_type( EE_Line_Item $parent_line_item, $line_item_type ) { |
|
1127 | - return self::_get_descendants_by_type_and_object_type( $parent_line_item, $line_item_type, NULL ); |
|
1126 | + public static function get_descendants_of_type(EE_Line_Item $parent_line_item, $line_item_type) { |
|
1127 | + return self::_get_descendants_by_type_and_object_type($parent_line_item, $line_item_type, NULL); |
|
1128 | 1128 | } |
1129 | 1129 | |
1130 | 1130 | |
@@ -1143,8 +1143,8 @@ discard block |
||
1143 | 1143 | $obj_type = null |
1144 | 1144 | ) { |
1145 | 1145 | $objects = array(); |
1146 | - foreach ( $parent_line_item->children() as $child_line_item ) { |
|
1147 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
1146 | + foreach ($parent_line_item->children() as $child_line_item) { |
|
1147 | + if ($child_line_item instanceof EE_Line_Item) { |
|
1148 | 1148 | if ( |
1149 | 1149 | $child_line_item->type() === $line_item_type |
1150 | 1150 | && ( |
@@ -1184,7 +1184,7 @@ discard block |
||
1184 | 1184 | $OBJ_type = '', |
1185 | 1185 | $OBJ_IDs = array() |
1186 | 1186 | ) { |
1187 | - return self::_get_descendants_by_object_type_and_object_ID( $parent_line_item, $OBJ_type, $OBJ_IDs ); |
|
1187 | + return self::_get_descendants_by_object_type_and_object_ID($parent_line_item, $OBJ_type, $OBJ_IDs); |
|
1188 | 1188 | } |
1189 | 1189 | |
1190 | 1190 | |
@@ -1203,12 +1203,12 @@ discard block |
||
1203 | 1203 | $OBJ_IDs |
1204 | 1204 | ) { |
1205 | 1205 | $objects = array(); |
1206 | - foreach ( $parent_line_item->children() as $child_line_item ) { |
|
1207 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
1206 | + foreach ($parent_line_item->children() as $child_line_item) { |
|
1207 | + if ($child_line_item instanceof EE_Line_Item) { |
|
1208 | 1208 | if ( |
1209 | 1209 | $child_line_item->OBJ_type() === $OBJ_type |
1210 | - && is_array( $OBJ_IDs ) |
|
1211 | - && in_array( $child_line_item->OBJ_ID(), $OBJ_IDs ) |
|
1210 | + && is_array($OBJ_IDs) |
|
1211 | + && in_array($child_line_item->OBJ_ID(), $OBJ_IDs) |
|
1212 | 1212 | ) { |
1213 | 1213 | $objects[] = $child_line_item; |
1214 | 1214 | } else { |
@@ -1238,8 +1238,8 @@ discard block |
||
1238 | 1238 | * @param string $type like one of the EEM_Line_Item::type_* |
1239 | 1239 | * @return EE_Line_Item |
1240 | 1240 | */ |
1241 | - public static function get_nearest_descendant_of_type( EE_Line_Item $parent_line_item, $type ) { |
|
1242 | - return self::_get_nearest_descendant( $parent_line_item, 'LIN_type' , $type ); |
|
1241 | + public static function get_nearest_descendant_of_type(EE_Line_Item $parent_line_item, $type) { |
|
1242 | + return self::_get_nearest_descendant($parent_line_item, 'LIN_type', $type); |
|
1243 | 1243 | } |
1244 | 1244 | |
1245 | 1245 | |
@@ -1253,8 +1253,8 @@ discard block |
||
1253 | 1253 | * @param string $code any value used for LIN_code |
1254 | 1254 | * @return EE_Line_Item |
1255 | 1255 | */ |
1256 | - public static function get_nearest_descendant_having_code( EE_Line_Item $parent_line_item, $code ) { |
|
1257 | - return self::_get_nearest_descendant( $parent_line_item, 'LIN_code' , $code ); |
|
1256 | + public static function get_nearest_descendant_having_code(EE_Line_Item $parent_line_item, $code) { |
|
1257 | + return self::_get_nearest_descendant($parent_line_item, 'LIN_code', $code); |
|
1258 | 1258 | } |
1259 | 1259 | |
1260 | 1260 | |
@@ -1268,15 +1268,15 @@ discard block |
||
1268 | 1268 | * @param string $value any value stored in $search_field |
1269 | 1269 | * @return EE_Line_Item |
1270 | 1270 | */ |
1271 | - protected static function _get_nearest_descendant( EE_Line_Item $parent_line_item, $search_field, $value ) { |
|
1272 | - foreach( $parent_line_item->children() as $child ){ |
|
1273 | - if ( $child->get( $search_field ) == $value ){ |
|
1271 | + protected static function _get_nearest_descendant(EE_Line_Item $parent_line_item, $search_field, $value) { |
|
1272 | + foreach ($parent_line_item->children() as $child) { |
|
1273 | + if ($child->get($search_field) == $value) { |
|
1274 | 1274 | return $child; |
1275 | 1275 | } |
1276 | 1276 | } |
1277 | - foreach( $parent_line_item->children() as $child ){ |
|
1278 | - $descendant_found = self::_get_nearest_descendant( $child, $search_field, $value ); |
|
1279 | - if ( $descendant_found ){ |
|
1277 | + foreach ($parent_line_item->children() as $child) { |
|
1278 | + $descendant_found = self::_get_nearest_descendant($child, $search_field, $value); |
|
1279 | + if ($descendant_found) { |
|
1280 | 1280 | return $descendant_found; |
1281 | 1281 | } |
1282 | 1282 | } |
@@ -1293,24 +1293,24 @@ discard block |
||
1293 | 1293 | * @return \EE_Line_Item |
1294 | 1294 | * @throws \EE_Error |
1295 | 1295 | */ |
1296 | - public static function find_transaction_grand_total_for_line_item( EE_Line_Item $line_item ){ |
|
1297 | - if ( $line_item->TXN_ID() ) { |
|
1298 | - $total_line_item = $line_item->transaction()->total_line_item( false ); |
|
1299 | - if ( $total_line_item instanceof EE_Line_Item ) { |
|
1296 | + public static function find_transaction_grand_total_for_line_item(EE_Line_Item $line_item) { |
|
1297 | + if ($line_item->TXN_ID()) { |
|
1298 | + $total_line_item = $line_item->transaction()->total_line_item(false); |
|
1299 | + if ($total_line_item instanceof EE_Line_Item) { |
|
1300 | 1300 | return $total_line_item; |
1301 | 1301 | } |
1302 | 1302 | } else { |
1303 | 1303 | $line_item_parent = $line_item->parent(); |
1304 | - if ( $line_item_parent instanceof EE_Line_Item ) { |
|
1305 | - if ( $line_item_parent->is_total() ) { |
|
1304 | + if ($line_item_parent instanceof EE_Line_Item) { |
|
1305 | + if ($line_item_parent->is_total()) { |
|
1306 | 1306 | return $line_item_parent; |
1307 | 1307 | } |
1308 | - return EEH_Line_Item::find_transaction_grand_total_for_line_item( $line_item_parent ); |
|
1308 | + return EEH_Line_Item::find_transaction_grand_total_for_line_item($line_item_parent); |
|
1309 | 1309 | } |
1310 | 1310 | } |
1311 | 1311 | throw new EE_Error( |
1312 | 1312 | sprintf( |
1313 | - __( 'A valid grand total for line item %1$d was not found.', 'event_espresso' ), |
|
1313 | + __('A valid grand total for line item %1$d was not found.', 'event_espresso'), |
|
1314 | 1314 | $line_item->ID() |
1315 | 1315 | ) |
1316 | 1316 | ); |
@@ -1327,31 +1327,31 @@ discard block |
||
1327 | 1327 | * @return void |
1328 | 1328 | * @throws \EE_Error |
1329 | 1329 | */ |
1330 | - public static function visualize( EE_Line_Item $line_item, $indentation = 0 ){ |
|
1330 | + public static function visualize(EE_Line_Item $line_item, $indentation = 0) { |
|
1331 | 1331 | echo defined('EE_TESTS_DIR') ? "\n" : '<br />'; |
1332 | - if ( ! $indentation ) { |
|
1333 | - echo defined( 'EE_TESTS_DIR' ) ? "\n" : '<br />'; |
|
1332 | + if ( ! $indentation) { |
|
1333 | + echo defined('EE_TESTS_DIR') ? "\n" : '<br />'; |
|
1334 | 1334 | } |
1335 | - for( $i = 0; $i < $indentation; $i++ ){ |
|
1335 | + for ($i = 0; $i < $indentation; $i++) { |
|
1336 | 1336 | echo ". "; |
1337 | 1337 | } |
1338 | 1338 | $breakdown = ''; |
1339 | - if ( $line_item->is_line_item()){ |
|
1340 | - if ( $line_item->is_percent() ) { |
|
1339 | + if ($line_item->is_line_item()) { |
|
1340 | + if ($line_item->is_percent()) { |
|
1341 | 1341 | $breakdown = "{$line_item->percent()}%"; |
1342 | 1342 | } else { |
1343 | - $breakdown = '$' . "{$line_item->unit_price()} x {$line_item->quantity()}"; |
|
1343 | + $breakdown = '$'."{$line_item->unit_price()} x {$line_item->quantity()}"; |
|
1344 | 1344 | } |
1345 | 1345 | } |
1346 | - echo $line_item->name() . " [ ID:{$line_item->ID()} | qty:{$line_item->quantity()} ] {$line_item->type()} : " . '$' . "{$line_item->total()}"; |
|
1347 | - if ( $breakdown ) { |
|
1346 | + echo $line_item->name()." [ ID:{$line_item->ID()} | qty:{$line_item->quantity()} ] {$line_item->type()} : ".'$'."{$line_item->total()}"; |
|
1347 | + if ($breakdown) { |
|
1348 | 1348 | echo " ( {$breakdown} )"; |
1349 | 1349 | } |
1350 | - if( $line_item->is_taxable() ){ |
|
1350 | + if ($line_item->is_taxable()) { |
|
1351 | 1351 | echo " * taxable"; |
1352 | 1352 | } |
1353 | - if( $line_item->children() ){ |
|
1354 | - foreach($line_item->children() as $child){ |
|
1353 | + if ($line_item->children()) { |
|
1354 | + foreach ($line_item->children() as $child) { |
|
1355 | 1355 | self::visualize($child, $indentation + 1); |
1356 | 1356 | } |
1357 | 1357 | } |
@@ -1392,97 +1392,97 @@ discard block |
||
1392 | 1392 | * is theirs, which can be done with |
1393 | 1393 | * `EEM_Line_Item::instance()->get_line_item_for_registration( $registration );` |
1394 | 1394 | */ |
1395 | - public static function calculate_reg_final_prices_per_line_item( EE_Line_Item $line_item, $billable_ticket_quantities = array() ) { |
|
1395 | + public static function calculate_reg_final_prices_per_line_item(EE_Line_Item $line_item, $billable_ticket_quantities = array()) { |
|
1396 | 1396 | //init running grand total if not already |
1397 | - if ( ! isset( $running_totals[ 'total' ] ) ) { |
|
1398 | - $running_totals[ 'total' ] = 0; |
|
1397 | + if ( ! isset($running_totals['total'])) { |
|
1398 | + $running_totals['total'] = 0; |
|
1399 | 1399 | } |
1400 | - if( ! isset( $running_totals[ 'taxable' ] ) ) { |
|
1401 | - $running_totals[ 'taxable' ] = array( 'total' => 0 ); |
|
1400 | + if ( ! isset($running_totals['taxable'])) { |
|
1401 | + $running_totals['taxable'] = array('total' => 0); |
|
1402 | 1402 | } |
1403 | - foreach ( $line_item->children() as $child_line_item ) { |
|
1404 | - switch ( $child_line_item->type() ) { |
|
1403 | + foreach ($line_item->children() as $child_line_item) { |
|
1404 | + switch ($child_line_item->type()) { |
|
1405 | 1405 | |
1406 | 1406 | case EEM_Line_Item::type_sub_total : |
1407 | - $running_totals_from_subtotal = EEH_Line_Item::calculate_reg_final_prices_per_line_item( $child_line_item, $billable_ticket_quantities ); |
|
1407 | + $running_totals_from_subtotal = EEH_Line_Item::calculate_reg_final_prices_per_line_item($child_line_item, $billable_ticket_quantities); |
|
1408 | 1408 | //combine arrays but preserve numeric keys |
1409 | - $running_totals = array_replace_recursive( $running_totals_from_subtotal, $running_totals ); |
|
1410 | - $running_totals[ 'total' ] += $running_totals_from_subtotal[ 'total' ]; |
|
1411 | - $running_totals[ 'taxable'][ 'total' ] += $running_totals_from_subtotal[ 'taxable' ][ 'total' ]; |
|
1409 | + $running_totals = array_replace_recursive($running_totals_from_subtotal, $running_totals); |
|
1410 | + $running_totals['total'] += $running_totals_from_subtotal['total']; |
|
1411 | + $running_totals['taxable']['total'] += $running_totals_from_subtotal['taxable']['total']; |
|
1412 | 1412 | break; |
1413 | 1413 | |
1414 | 1414 | case EEM_Line_Item::type_tax_sub_total : |
1415 | 1415 | |
1416 | 1416 | //find how much the taxes percentage is |
1417 | - if ( $child_line_item->percent() !== 0 ) { |
|
1417 | + if ($child_line_item->percent() !== 0) { |
|
1418 | 1418 | $tax_percent_decimal = $child_line_item->percent() / 100; |
1419 | 1419 | } else { |
1420 | 1420 | $tax_percent_decimal = EE_Taxes::get_total_taxes_percentage() / 100; |
1421 | 1421 | } |
1422 | 1422 | //and apply to all the taxable totals, and add to the pretax totals |
1423 | - foreach ( $running_totals as $line_item_id => $this_running_total ) { |
|
1423 | + foreach ($running_totals as $line_item_id => $this_running_total) { |
|
1424 | 1424 | //"total" and "taxable" array key is an exception |
1425 | - if ( $line_item_id === 'taxable' ) { |
|
1425 | + if ($line_item_id === 'taxable') { |
|
1426 | 1426 | continue; |
1427 | 1427 | } |
1428 | - $taxable_total = $running_totals[ 'taxable' ][ $line_item_id ]; |
|
1429 | - $running_totals[ $line_item_id ] += ( $taxable_total * $tax_percent_decimal ); |
|
1428 | + $taxable_total = $running_totals['taxable'][$line_item_id]; |
|
1429 | + $running_totals[$line_item_id] += ($taxable_total * $tax_percent_decimal); |
|
1430 | 1430 | } |
1431 | 1431 | break; |
1432 | 1432 | |
1433 | 1433 | case EEM_Line_Item::type_line_item : |
1434 | 1434 | |
1435 | 1435 | // ticket line items or ???? |
1436 | - if ( $child_line_item->OBJ_type() === 'Ticket' ) { |
|
1436 | + if ($child_line_item->OBJ_type() === 'Ticket') { |
|
1437 | 1437 | // kk it's a ticket |
1438 | - if ( isset( $running_totals[ $child_line_item->ID() ] ) ) { |
|
1438 | + if (isset($running_totals[$child_line_item->ID()])) { |
|
1439 | 1439 | //huh? that shouldn't happen. |
1440 | - $running_totals[ 'total' ] += $child_line_item->total(); |
|
1440 | + $running_totals['total'] += $child_line_item->total(); |
|
1441 | 1441 | } else { |
1442 | 1442 | //its not in our running totals yet. great. |
1443 | - if ( $child_line_item->is_taxable() ) { |
|
1443 | + if ($child_line_item->is_taxable()) { |
|
1444 | 1444 | $taxable_amount = $child_line_item->unit_price(); |
1445 | 1445 | } else { |
1446 | 1446 | $taxable_amount = 0; |
1447 | 1447 | } |
1448 | 1448 | // are we only calculating totals for some tickets? |
1449 | - if ( isset( $billable_ticket_quantities[ $child_line_item->OBJ_ID() ] ) ) { |
|
1450 | - $quantity = $billable_ticket_quantities[ $child_line_item->OBJ_ID() ]; |
|
1451 | - $running_totals[ $child_line_item->ID() ] = $quantity |
|
1449 | + if (isset($billable_ticket_quantities[$child_line_item->OBJ_ID()])) { |
|
1450 | + $quantity = $billable_ticket_quantities[$child_line_item->OBJ_ID()]; |
|
1451 | + $running_totals[$child_line_item->ID()] = $quantity |
|
1452 | 1452 | ? $child_line_item->unit_price() |
1453 | 1453 | : 0; |
1454 | - $running_totals[ 'taxable' ][ $child_line_item->ID() ] = $quantity |
|
1454 | + $running_totals['taxable'][$child_line_item->ID()] = $quantity |
|
1455 | 1455 | ? $taxable_amount |
1456 | 1456 | : 0; |
1457 | 1457 | } else { |
1458 | 1458 | $quantity = $child_line_item->quantity(); |
1459 | - $running_totals[ $child_line_item->ID() ] = $child_line_item->unit_price(); |
|
1460 | - $running_totals[ 'taxable' ][ $child_line_item->ID() ] = $taxable_amount; |
|
1459 | + $running_totals[$child_line_item->ID()] = $child_line_item->unit_price(); |
|
1460 | + $running_totals['taxable'][$child_line_item->ID()] = $taxable_amount; |
|
1461 | 1461 | } |
1462 | - $running_totals[ 'taxable' ][ 'total' ] += $taxable_amount * $quantity; |
|
1463 | - $running_totals[ 'total' ] += $child_line_item->unit_price() * $quantity; |
|
1462 | + $running_totals['taxable']['total'] += $taxable_amount * $quantity; |
|
1463 | + $running_totals['total'] += $child_line_item->unit_price() * $quantity; |
|
1464 | 1464 | } |
1465 | 1465 | } else { |
1466 | 1466 | // it's some other type of item added to the cart |
1467 | 1467 | // it should affect the running totals |
1468 | 1468 | // basically we want to convert it into a PERCENT modifier. Because |
1469 | 1469 | // more clearly affect all registration's final price equally |
1470 | - $line_items_percent_of_running_total = $running_totals[ 'total' ] > 0 |
|
1471 | - ? ( $child_line_item->total() / $running_totals[ 'total' ] ) + 1 |
|
1470 | + $line_items_percent_of_running_total = $running_totals['total'] > 0 |
|
1471 | + ? ($child_line_item->total() / $running_totals['total']) + 1 |
|
1472 | 1472 | : 1; |
1473 | - foreach ( $running_totals as $line_item_id => $this_running_total ) { |
|
1473 | + foreach ($running_totals as $line_item_id => $this_running_total) { |
|
1474 | 1474 | //the "taxable" array key is an exception |
1475 | - if ( $line_item_id === 'taxable' ) { |
|
1475 | + if ($line_item_id === 'taxable') { |
|
1476 | 1476 | continue; |
1477 | 1477 | } |
1478 | 1478 | // update the running totals |
1479 | 1479 | // yes this actually even works for the running grand total! |
1480 | - $running_totals[ $line_item_id ] = |
|
1480 | + $running_totals[$line_item_id] = |
|
1481 | 1481 | $line_items_percent_of_running_total * $this_running_total; |
1482 | 1482 | |
1483 | - if ( $child_line_item->is_taxable() ) { |
|
1484 | - $running_totals[ 'taxable' ][ $line_item_id ] = |
|
1485 | - $line_items_percent_of_running_total * $running_totals[ 'taxable' ][ $line_item_id ]; |
|
1483 | + if ($child_line_item->is_taxable()) { |
|
1484 | + $running_totals['taxable'][$line_item_id] = |
|
1485 | + $line_items_percent_of_running_total * $running_totals['taxable'][$line_item_id]; |
|
1486 | 1486 | } |
1487 | 1487 | } |
1488 | 1488 | } |
@@ -1500,16 +1500,16 @@ discard block |
||
1500 | 1500 | * @return float | null |
1501 | 1501 | * @throws \OutOfRangeException |
1502 | 1502 | */ |
1503 | - public static function calculate_final_price_for_ticket_line_item( \EE_Line_Item $total_line_item, \EE_Line_Item $ticket_line_item ) { |
|
1503 | + public static function calculate_final_price_for_ticket_line_item(\EE_Line_Item $total_line_item, \EE_Line_Item $ticket_line_item) { |
|
1504 | 1504 | static $final_prices_per_ticket_line_item = array(); |
1505 | - if ( empty( $final_prices_per_ticket_line_item ) ) { |
|
1505 | + if (empty($final_prices_per_ticket_line_item)) { |
|
1506 | 1506 | $final_prices_per_ticket_line_item = \EEH_Line_Item::calculate_reg_final_prices_per_line_item( |
1507 | 1507 | $total_line_item |
1508 | 1508 | ); |
1509 | 1509 | } |
1510 | 1510 | //ok now find this new registration's final price |
1511 | - if ( isset( $final_prices_per_ticket_line_item[ $ticket_line_item->ID() ] ) ) { |
|
1512 | - return $final_prices_per_ticket_line_item[ $ticket_line_item->ID() ]; |
|
1511 | + if (isset($final_prices_per_ticket_line_item[$ticket_line_item->ID()])) { |
|
1512 | + return $final_prices_per_ticket_line_item[$ticket_line_item->ID()]; |
|
1513 | 1513 | } |
1514 | 1514 | $message = sprintf( |
1515 | 1515 | __( |
@@ -1518,11 +1518,11 @@ discard block |
||
1518 | 1518 | ), |
1519 | 1519 | $ticket_line_item->ID() |
1520 | 1520 | ); |
1521 | - if ( WP_DEBUG ) { |
|
1522 | - $message .= '<br>' . print_r( $final_prices_per_ticket_line_item, true ); |
|
1523 | - throw new \OutOfRangeException( $message ); |
|
1521 | + if (WP_DEBUG) { |
|
1522 | + $message .= '<br>'.print_r($final_prices_per_ticket_line_item, true); |
|
1523 | + throw new \OutOfRangeException($message); |
|
1524 | 1524 | } else { |
1525 | - EE_Log::instance()->log( __CLASS__, __FUNCTION__, $message ); |
|
1525 | + EE_Log::instance()->log(__CLASS__, __FUNCTION__, $message); |
|
1526 | 1526 | } |
1527 | 1527 | return null; |
1528 | 1528 | } |
@@ -1538,15 +1538,15 @@ discard block |
||
1538 | 1538 | * @return \EE_Line_Item |
1539 | 1539 | * @throws \EE_Error |
1540 | 1540 | */ |
1541 | - public static function billable_line_item_tree( EE_Line_Item $line_item, $registrations ) { |
|
1542 | - $copy_li = EEH_Line_Item::billable_line_item( $line_item, $registrations ); |
|
1543 | - foreach ( $line_item->children() as $child_li ) { |
|
1544 | - $copy_li->add_child_line_item( EEH_Line_Item::billable_line_item_tree( $child_li, $registrations ) ); |
|
1541 | + public static function billable_line_item_tree(EE_Line_Item $line_item, $registrations) { |
|
1542 | + $copy_li = EEH_Line_Item::billable_line_item($line_item, $registrations); |
|
1543 | + foreach ($line_item->children() as $child_li) { |
|
1544 | + $copy_li->add_child_line_item(EEH_Line_Item::billable_line_item_tree($child_li, $registrations)); |
|
1545 | 1545 | } |
1546 | 1546 | //if this is the grand total line item, make sure the totals all add up |
1547 | 1547 | //(we could have duplicated this logic AS we copied the line items, but |
1548 | 1548 | //it seems DRYer this way) |
1549 | - if ( $copy_li->type() === EEM_Line_Item::type_total ) { |
|
1549 | + if ($copy_li->type() === EEM_Line_Item::type_total) { |
|
1550 | 1550 | $copy_li->recalculate_total_including_taxes(); |
1551 | 1551 | } |
1552 | 1552 | return $copy_li; |
@@ -1563,24 +1563,24 @@ discard block |
||
1563 | 1563 | * @throws \EE_Error |
1564 | 1564 | * @param EE_Registration[] $registrations |
1565 | 1565 | */ |
1566 | - public static function billable_line_item( EE_Line_Item $line_item, $registrations ) { |
|
1566 | + public static function billable_line_item(EE_Line_Item $line_item, $registrations) { |
|
1567 | 1567 | $new_li_fields = $line_item->model_field_array(); |
1568 | - if ( $line_item->type() === EEM_Line_Item::type_line_item && |
|
1568 | + if ($line_item->type() === EEM_Line_Item::type_line_item && |
|
1569 | 1569 | $line_item->OBJ_type() === 'Ticket' |
1570 | 1570 | ) { |
1571 | 1571 | $count = 0; |
1572 | - foreach ( $registrations as $registration ) { |
|
1573 | - if ( $line_item->OBJ_ID() === $registration->ticket_ID() && |
|
1574 | - in_array( $registration->status_ID(), EEM_Registration::reg_statuses_that_allow_payment() ) |
|
1572 | + foreach ($registrations as $registration) { |
|
1573 | + if ($line_item->OBJ_ID() === $registration->ticket_ID() && |
|
1574 | + in_array($registration->status_ID(), EEM_Registration::reg_statuses_that_allow_payment()) |
|
1575 | 1575 | ) { |
1576 | 1576 | $count++; |
1577 | 1577 | } |
1578 | 1578 | } |
1579 | - $new_li_fields[ 'LIN_quantity' ] = $count; |
|
1579 | + $new_li_fields['LIN_quantity'] = $count; |
|
1580 | 1580 | } |
1581 | 1581 | //don't set the total. We'll leave that up to the code that calculates it |
1582 | - unset( $new_li_fields[ 'LIN_ID' ], $new_li_fields[ 'LIN_parent' ], $new_li_fields[ 'LIN_total' ] ); |
|
1583 | - return EE_Line_Item::new_instance( $new_li_fields ); |
|
1582 | + unset($new_li_fields['LIN_ID'], $new_li_fields['LIN_parent'], $new_li_fields['LIN_total']); |
|
1583 | + return EE_Line_Item::new_instance($new_li_fields); |
|
1584 | 1584 | } |
1585 | 1585 | |
1586 | 1586 | |
@@ -1593,19 +1593,19 @@ discard block |
||
1593 | 1593 | * @return \EE_Line_Item|null |
1594 | 1594 | * @throws \EE_Error |
1595 | 1595 | */ |
1596 | - public static function non_empty_line_items( EE_Line_Item $line_item ) { |
|
1597 | - $copied_li = EEH_Line_Item::non_empty_line_item( $line_item ); |
|
1598 | - if ( $copied_li === null ) { |
|
1596 | + public static function non_empty_line_items(EE_Line_Item $line_item) { |
|
1597 | + $copied_li = EEH_Line_Item::non_empty_line_item($line_item); |
|
1598 | + if ($copied_li === null) { |
|
1599 | 1599 | return null; |
1600 | 1600 | } |
1601 | 1601 | //if this is an event subtotal, we want to only include it if it |
1602 | 1602 | //has a non-zero total and at least one ticket line item child |
1603 | 1603 | $ticket_children = 0; |
1604 | - foreach ( $line_item->children() as $child_li ) { |
|
1605 | - $child_li_copy = EEH_Line_Item::non_empty_line_items( $child_li ); |
|
1606 | - if ( $child_li_copy !== null ) { |
|
1607 | - $copied_li->add_child_line_item( $child_li_copy ); |
|
1608 | - if ( $child_li_copy->type() === EEM_Line_Item::type_line_item && |
|
1604 | + foreach ($line_item->children() as $child_li) { |
|
1605 | + $child_li_copy = EEH_Line_Item::non_empty_line_items($child_li); |
|
1606 | + if ($child_li_copy !== null) { |
|
1607 | + $copied_li->add_child_line_item($child_li_copy); |
|
1608 | + if ($child_li_copy->type() === EEM_Line_Item::type_line_item && |
|
1609 | 1609 | $child_li_copy->OBJ_type() === 'Ticket' |
1610 | 1610 | ) { |
1611 | 1611 | $ticket_children++; |
@@ -1635,8 +1635,8 @@ discard block |
||
1635 | 1635 | * @return EE_Line_Item |
1636 | 1636 | * @throws \EE_Error |
1637 | 1637 | */ |
1638 | - public static function non_empty_line_item( EE_Line_Item $line_item ) { |
|
1639 | - if ( $line_item->type() === EEM_Line_Item::type_line_item && |
|
1638 | + public static function non_empty_line_item(EE_Line_Item $line_item) { |
|
1639 | + if ($line_item->type() === EEM_Line_Item::type_line_item && |
|
1640 | 1640 | $line_item->OBJ_type() === 'Ticket' && |
1641 | 1641 | $line_item->quantity() === 0 |
1642 | 1642 | ) { |
@@ -1644,8 +1644,8 @@ discard block |
||
1644 | 1644 | } |
1645 | 1645 | $new_li_fields = $line_item->model_field_array(); |
1646 | 1646 | //don't set the total. We'll leave that up to the code that calculates it |
1647 | - unset( $new_li_fields[ 'LIN_ID' ], $new_li_fields[ 'LIN_parent' ] ); |
|
1648 | - return EE_Line_Item::new_instance( $new_li_fields ); |
|
1647 | + unset($new_li_fields['LIN_ID'], $new_li_fields['LIN_parent']); |
|
1648 | + return EE_Line_Item::new_instance($new_li_fields); |
|
1649 | 1649 | } |
1650 | 1650 | |
1651 | 1651 | |
@@ -1657,9 +1657,9 @@ discard block |
||
1657 | 1657 | * @return \EE_Line_Item |
1658 | 1658 | * @throws \EE_Error |
1659 | 1659 | */ |
1660 | - public static function get_items_subtotal( EE_Line_Item $total_line_item ){ |
|
1661 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::get_items_subtotal()', __('Method replaced with EEH_Line_Item::get_pre_tax_subtotal()', 'event_espresso'), '4.6.0' ); |
|
1662 | - return self::get_pre_tax_subtotal( $total_line_item ); |
|
1660 | + public static function get_items_subtotal(EE_Line_Item $total_line_item) { |
|
1661 | + EE_Error::doing_it_wrong('EEH_Line_Item::get_items_subtotal()', __('Method replaced with EEH_Line_Item::get_pre_tax_subtotal()', 'event_espresso'), '4.6.0'); |
|
1662 | + return self::get_pre_tax_subtotal($total_line_item); |
|
1663 | 1663 | } |
1664 | 1664 | |
1665 | 1665 | |
@@ -1670,9 +1670,9 @@ discard block |
||
1670 | 1670 | * @return \EE_Line_Item |
1671 | 1671 | * @throws \EE_Error |
1672 | 1672 | */ |
1673 | - public static function create_default_total_line_item( $transaction = NULL) { |
|
1674 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_total_line_item()', __('Method replaced with EEH_Line_Item::create_total_line_item()', 'event_espresso'), '4.6.0' ); |
|
1675 | - return self::create_total_line_item( $transaction ); |
|
1673 | + public static function create_default_total_line_item($transaction = NULL) { |
|
1674 | + EE_Error::doing_it_wrong('EEH_Line_Item::create_default_total_line_item()', __('Method replaced with EEH_Line_Item::create_total_line_item()', 'event_espresso'), '4.6.0'); |
|
1675 | + return self::create_total_line_item($transaction); |
|
1676 | 1676 | } |
1677 | 1677 | |
1678 | 1678 | |
@@ -1684,9 +1684,9 @@ discard block |
||
1684 | 1684 | * @return \EE_Line_Item |
1685 | 1685 | * @throws \EE_Error |
1686 | 1686 | */ |
1687 | - public static function create_default_tickets_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1688 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_tickets_subtotal()', __('Method replaced with EEH_Line_Item::create_pre_tax_subtotal()', 'event_espresso'), '4.6.0' ); |
|
1689 | - return self::create_pre_tax_subtotal( $total_line_item, $transaction ); |
|
1687 | + public static function create_default_tickets_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1688 | + EE_Error::doing_it_wrong('EEH_Line_Item::create_default_tickets_subtotal()', __('Method replaced with EEH_Line_Item::create_pre_tax_subtotal()', 'event_espresso'), '4.6.0'); |
|
1689 | + return self::create_pre_tax_subtotal($total_line_item, $transaction); |
|
1690 | 1690 | } |
1691 | 1691 | |
1692 | 1692 | |
@@ -1698,9 +1698,9 @@ discard block |
||
1698 | 1698 | * @return \EE_Line_Item |
1699 | 1699 | * @throws \EE_Error |
1700 | 1700 | */ |
1701 | - public static function create_default_taxes_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1702 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_taxes_subtotal()', __('Method replaced with EEH_Line_Item::create_taxes_subtotal()', 'event_espresso'), '4.6.0' ); |
|
1703 | - return self::create_taxes_subtotal( $total_line_item, $transaction ); |
|
1701 | + public static function create_default_taxes_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1702 | + EE_Error::doing_it_wrong('EEH_Line_Item::create_default_taxes_subtotal()', __('Method replaced with EEH_Line_Item::create_taxes_subtotal()', 'event_espresso'), '4.6.0'); |
|
1703 | + return self::create_taxes_subtotal($total_line_item, $transaction); |
|
1704 | 1704 | } |
1705 | 1705 | |
1706 | 1706 | |
@@ -1712,9 +1712,9 @@ discard block |
||
1712 | 1712 | * @return \EE_Line_Item |
1713 | 1713 | * @throws \EE_Error |
1714 | 1714 | */ |
1715 | - public static function create_default_event_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1716 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_event_subtotal()', __('Method replaced with EEH_Line_Item::create_event_subtotal()', 'event_espresso'), '4.6.0' ); |
|
1717 | - return self::create_event_subtotal( $total_line_item, $transaction ); |
|
1715 | + public static function create_default_event_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1716 | + EE_Error::doing_it_wrong('EEH_Line_Item::create_default_event_subtotal()', __('Method replaced with EEH_Line_Item::create_event_subtotal()', 'event_espresso'), '4.6.0'); |
|
1717 | + return self::create_event_subtotal($total_line_item, $transaction); |
|
1718 | 1718 | } |
1719 | 1719 | |
1720 | 1720 |
@@ -6,7 +6,9 @@ |
||
6 | 6 | * @package Event Espresso |
7 | 7 | * @subpackage helper |
8 | 8 | */ |
9 | -if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
10 | + exit('No direct script access allowed'); |
|
11 | +} |
|
10 | 12 | /** |
11 | 13 | * |
12 | 14 | * Money helper class. |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * |
21 | 21 | * ------------------------------------------------------------------------ |
22 | 22 | */ |
23 | -class EEH_Money extends EEH_Base { |
|
23 | +class EEH_Money extends EEH_Base { |
|
24 | 24 | |
25 | 25 | |
26 | 26 | /** |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | * @return float |
62 | 62 | * @throws EE_Error |
63 | 63 | */ |
64 | - public static function convert_to_float_from_localized_money($money_value ) { |
|
64 | + public static function convert_to_float_from_localized_money($money_value) { |
|
65 | 65 | //float it! and round to three decimal places |
66 | - return round ( (float) EEH_Money::strip_localized_money_formatting($money_value), 3 ); |
|
66 | + return round((float) EEH_Money::strip_localized_money_formatting($money_value), 3); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -82,12 +82,12 @@ discard block |
||
82 | 82 | * @throws EE_Error |
83 | 83 | */ |
84 | 84 | |
85 | - public static function compare_floats( $float1, $float2, $operator='=' ) { |
|
85 | + public static function compare_floats($float1, $float2, $operator = '=') { |
|
86 | 86 | // Check numbers to 5 digits of precision |
87 | 87 | $epsilon = 0.00001; |
88 | 88 | |
89 | - $float1 = (float)$float1; |
|
90 | - $float2 = (float)$float2; |
|
89 | + $float1 = (float) $float1; |
|
90 | + $float2 = (float) $float2; |
|
91 | 91 | |
92 | 92 | switch ($operator) { |
93 | 93 | // equal |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | } |
144 | 144 | break; |
145 | 145 | default: |
146 | - throw new EE_Error(__( "Unknown operator '" . $operator . "' in EEH_Money::compare_floats()", 'event_espresso' ) ); |
|
146 | + throw new EE_Error(__("Unknown operator '".$operator."' in EEH_Money::compare_floats()", 'event_espresso')); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | return false; |
@@ -159,14 +159,14 @@ discard block |
||
159 | 159 | * @return string |
160 | 160 | * @throws EE_Error |
161 | 161 | */ |
162 | - public static function get_format_for_jqplot( $CNT_ISO = '') { |
|
162 | + public static function get_format_for_jqplot($CNT_ISO = '') { |
|
163 | 163 | //default format |
164 | 164 | $format = 'f'; |
165 | 165 | $currency_config = $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
166 | 166 | //first get the decimal place and number of places |
167 | - $format = "%'." . $currency_config->dec_plc . $format; |
|
167 | + $format = "%'.".$currency_config->dec_plc.$format; |
|
168 | 168 | //currency symbol on right side. |
169 | - $format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign; |
|
169 | + $format = $currency_config->sign_b4 ? $currency_config->sign.$format : $format.$currency_config->sign; |
|
170 | 170 | return $format; |
171 | 171 | } |
172 | 172 | |
@@ -182,20 +182,20 @@ discard block |
||
182 | 182 | * @return string |
183 | 183 | * @throws EE_Error |
184 | 184 | */ |
185 | - public static function get_format_for_google_charts( $CNT_ISO = '' ) { |
|
185 | + public static function get_format_for_google_charts($CNT_ISO = '') { |
|
186 | 186 | $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
187 | - $decimal_places_placeholder = str_pad( '', $currency_config->dec_plc, '0' ); |
|
187 | + $decimal_places_placeholder = str_pad('', $currency_config->dec_plc, '0'); |
|
188 | 188 | //first get the decimal place and number of places |
189 | - $format = '#,##0.' . $decimal_places_placeholder; |
|
189 | + $format = '#,##0.'.$decimal_places_placeholder; |
|
190 | 190 | |
191 | 191 | //currency symbol on right side. |
192 | - $format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign; |
|
192 | + $format = $currency_config->sign_b4 ? $currency_config->sign.$format : $format.$currency_config->sign; |
|
193 | 193 | $formatterObject = array( |
194 | 194 | 'decimalSymbol' => $currency_config->dec_mrk, |
195 | 195 | 'groupingSymbol' => $currency_config->thsnds, |
196 | 196 | 'fractionDigits' => $currency_config->dec_plc, |
197 | 197 | ); |
198 | - if ( $currency_config->sign_b4 ) { |
|
198 | + if ($currency_config->sign_b4) { |
|
199 | 199 | $formatterObject['prefix'] = $currency_config->sign; |
200 | 200 | } else { |
201 | 201 | $formatterObject['suffix'] = $currency_config->sign; |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | ? new EE_Currency_Config($CNT_ISO) |
221 | 221 | : null; |
222 | 222 | //default currency settings for site if not set |
223 | - if (! $currency_config instanceof EE_Currency_Config) { |
|
223 | + if ( ! $currency_config instanceof EE_Currency_Config) { |
|
224 | 224 | $currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config |
225 | 225 | ? EE_Registry::instance()->CFG->currency |
226 | 226 | : new EE_Currency_Config(); |
@@ -8,71 +8,71 @@ discard block |
||
8 | 8 | */ |
9 | 9 | if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
10 | 10 | /** |
11 | - * |
|
12 | - * Money helper class. |
|
13 | - * This class has helper methods that help with money related conversions and calculations. |
|
14 | - * |
|
15 | - * @since %VER% |
|
16 | - * |
|
17 | - * @package Event Espresso |
|
18 | - * @subpackage helpers |
|
19 | - * @author Darren Ethier |
|
20 | - * |
|
21 | - * ------------------------------------------------------------------------ |
|
22 | - */ |
|
11 | + * |
|
12 | + * Money helper class. |
|
13 | + * This class has helper methods that help with money related conversions and calculations. |
|
14 | + * |
|
15 | + * @since %VER% |
|
16 | + * |
|
17 | + * @package Event Espresso |
|
18 | + * @subpackage helpers |
|
19 | + * @author Darren Ethier |
|
20 | + * |
|
21 | + * ------------------------------------------------------------------------ |
|
22 | + */ |
|
23 | 23 | class EEH_Money extends EEH_Base { |
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * This removes all localized money formatting from the incoming value |
|
28 | - * |
|
29 | - * Note: uses this site's currency settings for deciding what is considered a |
|
30 | - * "thousands separator" (usually the character "," ) |
|
31 | - * and what is a "decimal mark" (usually the character ".") |
|
32 | - * |
|
33 | - * @param int|float|string $money_value |
|
34 | - * @param string $CNT_ISO |
|
35 | - * @return float |
|
36 | - * @throws EE_Error |
|
37 | - */ |
|
26 | + /** |
|
27 | + * This removes all localized money formatting from the incoming value |
|
28 | + * |
|
29 | + * Note: uses this site's currency settings for deciding what is considered a |
|
30 | + * "thousands separator" (usually the character "," ) |
|
31 | + * and what is a "decimal mark" (usually the character ".") |
|
32 | + * |
|
33 | + * @param int|float|string $money_value |
|
34 | + * @param string $CNT_ISO |
|
35 | + * @return float |
|
36 | + * @throws EE_Error |
|
37 | + */ |
|
38 | 38 | public static function strip_localized_money_formatting($money_value, $CNT_ISO = '') { |
39 | - $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
|
40 | - $money_value = str_replace( |
|
41 | - array( |
|
42 | - $currency_config->thsnds, |
|
43 | - $currency_config->dec_mrk, |
|
44 | - ), |
|
45 | - array( |
|
46 | - '', // remove thousands separator |
|
47 | - '.', // convert decimal mark to what PHP expects |
|
48 | - ), |
|
49 | - $money_value |
|
50 | - ); |
|
51 | - $money_value = filter_var( |
|
52 | - $money_value, |
|
53 | - FILTER_SANITIZE_NUMBER_FLOAT, |
|
54 | - FILTER_FLAG_ALLOW_FRACTION |
|
55 | - ); |
|
56 | - return $money_value; |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * This converts an incoming localized money value into a standard float item (to three decimal places) |
|
63 | - * |
|
64 | - * Only use this if you know the $money_value follows your currency configuration's |
|
65 | - * settings. Note: this uses this site's currency settings for deciding what is considered a |
|
66 | - * "thousands separator" (usually the character "," ) |
|
67 | - * and what is a "decimal mark" (usually the character ".") |
|
68 | - * |
|
69 | - * @param int|string $money_value |
|
70 | - * @return float |
|
71 | - * @throws EE_Error |
|
72 | - */ |
|
39 | + $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
|
40 | + $money_value = str_replace( |
|
41 | + array( |
|
42 | + $currency_config->thsnds, |
|
43 | + $currency_config->dec_mrk, |
|
44 | + ), |
|
45 | + array( |
|
46 | + '', // remove thousands separator |
|
47 | + '.', // convert decimal mark to what PHP expects |
|
48 | + ), |
|
49 | + $money_value |
|
50 | + ); |
|
51 | + $money_value = filter_var( |
|
52 | + $money_value, |
|
53 | + FILTER_SANITIZE_NUMBER_FLOAT, |
|
54 | + FILTER_FLAG_ALLOW_FRACTION |
|
55 | + ); |
|
56 | + return $money_value; |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * This converts an incoming localized money value into a standard float item (to three decimal places) |
|
63 | + * |
|
64 | + * Only use this if you know the $money_value follows your currency configuration's |
|
65 | + * settings. Note: this uses this site's currency settings for deciding what is considered a |
|
66 | + * "thousands separator" (usually the character "," ) |
|
67 | + * and what is a "decimal mark" (usually the character ".") |
|
68 | + * |
|
69 | + * @param int|string $money_value |
|
70 | + * @return float |
|
71 | + * @throws EE_Error |
|
72 | + */ |
|
73 | 73 | public static function convert_to_float_from_localized_money($money_value ) { |
74 | 74 | //float it! and round to three decimal places |
75 | - return round ( (float) EEH_Money::strip_localized_money_formatting($money_value), 3 ); |
|
75 | + return round ( (float) EEH_Money::strip_localized_money_formatting($money_value), 3 ); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | |
@@ -160,19 +160,19 @@ discard block |
||
160 | 160 | |
161 | 161 | |
162 | 162 | |
163 | - /** |
|
164 | - * This returns a localized format string suitable for jQplot. |
|
165 | - * |
|
166 | - * @param string $CNT_ISO If this is provided, then will attempt to get the currency settings for the country. |
|
167 | - * Otherwise will use currency settings for current active country on site. |
|
168 | - * @return string |
|
169 | - * @throws EE_Error |
|
170 | - */ |
|
163 | + /** |
|
164 | + * This returns a localized format string suitable for jQplot. |
|
165 | + * |
|
166 | + * @param string $CNT_ISO If this is provided, then will attempt to get the currency settings for the country. |
|
167 | + * Otherwise will use currency settings for current active country on site. |
|
168 | + * @return string |
|
169 | + * @throws EE_Error |
|
170 | + */ |
|
171 | 171 | public static function get_format_for_jqplot( $CNT_ISO = '') { |
172 | 172 | //default format |
173 | 173 | $format = 'f'; |
174 | 174 | $currency_config = $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
175 | - //first get the decimal place and number of places |
|
175 | + //first get the decimal place and number of places |
|
176 | 176 | $format = "%'." . $currency_config->dec_plc . $format; |
177 | 177 | //currency symbol on right side. |
178 | 178 | $format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign; |
@@ -181,16 +181,16 @@ discard block |
||
181 | 181 | |
182 | 182 | |
183 | 183 | |
184 | - /** |
|
185 | - * This returns a localized format string suitable for usage with the Google Charts API format param. |
|
186 | - * |
|
187 | - * @param string $CNT_ISO If this is provided, then will attempt to get the currency settings for the country. |
|
188 | - * Otherwise will use currency settings for current active country on site. |
|
189 | - * Note: GoogleCharts uses ICU pattern set |
|
190 | - * (@see http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details) |
|
191 | - * @return string |
|
192 | - * @throws EE_Error |
|
193 | - */ |
|
184 | + /** |
|
185 | + * This returns a localized format string suitable for usage with the Google Charts API format param. |
|
186 | + * |
|
187 | + * @param string $CNT_ISO If this is provided, then will attempt to get the currency settings for the country. |
|
188 | + * Otherwise will use currency settings for current active country on site. |
|
189 | + * Note: GoogleCharts uses ICU pattern set |
|
190 | + * (@see http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details) |
|
191 | + * @return string |
|
192 | + * @throws EE_Error |
|
193 | + */ |
|
194 | 194 | public static function get_format_for_google_charts( $CNT_ISO = '' ) { |
195 | 195 | $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
196 | 196 | $decimal_places_placeholder = str_pad( '', $currency_config->dec_plc, '0' ); |
@@ -217,24 +217,24 @@ discard block |
||
217 | 217 | |
218 | 218 | |
219 | 219 | |
220 | - /** |
|
221 | - * @param string $CNT_ISO |
|
222 | - * @return EE_Currency_Config|null |
|
223 | - * @throws EE_Error |
|
224 | - */ |
|
225 | - public static function get_currency_config($CNT_ISO = '') |
|
226 | - { |
|
227 | - //if CNT_ISO passed lets try to get currency settings for it. |
|
228 | - $currency_config = $CNT_ISO !== '' |
|
229 | - ? new EE_Currency_Config($CNT_ISO) |
|
230 | - : null; |
|
231 | - //default currency settings for site if not set |
|
232 | - if (! $currency_config instanceof EE_Currency_Config) { |
|
233 | - $currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config |
|
234 | - ? EE_Registry::instance()->CFG->currency |
|
235 | - : new EE_Currency_Config(); |
|
236 | - } |
|
237 | - return $currency_config; |
|
238 | - } |
|
220 | + /** |
|
221 | + * @param string $CNT_ISO |
|
222 | + * @return EE_Currency_Config|null |
|
223 | + * @throws EE_Error |
|
224 | + */ |
|
225 | + public static function get_currency_config($CNT_ISO = '') |
|
226 | + { |
|
227 | + //if CNT_ISO passed lets try to get currency settings for it. |
|
228 | + $currency_config = $CNT_ISO !== '' |
|
229 | + ? new EE_Currency_Config($CNT_ISO) |
|
230 | + : null; |
|
231 | + //default currency settings for site if not set |
|
232 | + if (! $currency_config instanceof EE_Currency_Config) { |
|
233 | + $currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config |
|
234 | + ? EE_Registry::instance()->CFG->currency |
|
235 | + : new EE_Currency_Config(); |
|
236 | + } |
|
237 | + return $currency_config; |
|
238 | + } |
|
239 | 239 | |
240 | 240 | } //end class EEH_Money |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @param mixed $info |
26 | 26 | * @return bool |
27 | 27 | */ |
28 | - public function add( $object, $info = null ); |
|
28 | + public function add($object, $info = null); |
|
29 | 29 | |
30 | 30 | |
31 | 31 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @param mixed $info |
40 | 40 | * @return bool |
41 | 41 | */ |
42 | - public function set_info( $object, $info = null ); |
|
42 | + public function set_info($object, $info = null); |
|
43 | 43 | |
44 | 44 | |
45 | 45 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @param mixed |
53 | 53 | * @return null | object |
54 | 54 | */ |
55 | - public function get_by_info( $info ); |
|
55 | + public function get_by_info($info); |
|
56 | 56 | |
57 | 57 | |
58 | 58 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param object $object |
66 | 66 | * @return bool |
67 | 67 | */ |
68 | - public function has( $object ); |
|
68 | + public function has($object); |
|
69 | 69 | |
70 | 70 | |
71 | 71 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @param $object |
79 | 79 | * @return void |
80 | 80 | */ |
81 | - public function remove( $object ); |
|
81 | + public function remove($object); |
|
82 | 82 | |
83 | 83 | |
84 | 84 |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @return bool | int |
31 | 31 | * @throws \EE_Error |
32 | 32 | */ |
33 | - public function persist( $persistence_callback = '', $persistence_arguments = array() ); |
|
33 | + public function persist($persistence_callback = '', $persistence_arguments = array()); |
|
34 | 34 | |
35 | 35 | |
36 | 36 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param string $persistence_callback name of method found on object that can be used for persisting it |
44 | 44 | * @return bool | int |
45 | 45 | */ |
46 | - public function persist_all( $persistence_callback = '' ); |
|
46 | + public function persist_all($persistence_callback = ''); |
|
47 | 47 | |
48 | 48 | } |
49 | 49 | // End of file EEI_Repository.interface.php |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * Class EEI_Line_Item |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @param mixed $field_value |
19 | 19 | * @param bool $use_default |
20 | 20 | */ |
21 | - public function set( $field_name, $field_value, $use_default = false ); |
|
21 | + public function set($field_name, $field_value, $use_default = false); |
|
22 | 22 | |
23 | 23 | |
24 | 24 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * Sets quantity |
57 | 57 | * @param int $quantity |
58 | 58 | */ |
59 | - function set_quantity( $quantity ); |
|
59 | + function set_quantity($quantity); |
|
60 | 60 | |
61 | 61 | |
62 | 62 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @param int $txn_id if none is provided, assumes $this->TXN_ID() |
116 | 116 | * @return int count of items saved |
117 | 117 | */ |
118 | - function save_this_and_descendants_to_txn( $txn_id = null ); |
|
118 | + function save_this_and_descendants_to_txn($txn_id = null); |
|
119 | 119 | |
120 | 120 | |
121 | 121 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @param bool $set_order |
143 | 143 | * @return bool true for success, false for fail |
144 | 144 | */ |
145 | - function add_child_line_item( EEI_Line_Item $line_item, $set_order = true ); |
|
145 | + function add_child_line_item(EEI_Line_Item $line_item, $set_order = true); |
|
146 | 146 | |
147 | 147 | |
148 | 148 | |
@@ -197,14 +197,14 @@ discard block |
||
197 | 197 | * @param float $total |
198 | 198 | * @return boolean |
199 | 199 | */ |
200 | - function set_total( $total ); |
|
200 | + function set_total($total); |
|
201 | 201 | |
202 | 202 | /** |
203 | 203 | * Sets unit_price |
204 | 204 | * @param float $unit_price |
205 | 205 | * @return boolean |
206 | 206 | */ |
207 | - function set_unit_price( $unit_price ); |
|
207 | + function set_unit_price($unit_price); |
|
208 | 208 | |
209 | 209 | /** |
210 | 210 | * If this line item has been saved to the DB, deletes its child with LIN_code == $code. If this line |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * @param bool $stop_search_once_found |
216 | 216 | * @return int count of items deleted (or simply removed from the line item's cache, if not has not been saved to the DB yet) |
217 | 217 | */ |
218 | - function delete_child_line_item( $code, $stop_search_once_found = true ); |
|
218 | + function delete_child_line_item($code, $stop_search_once_found = true); |
|
219 | 219 | |
220 | 220 | /** |
221 | 221 | * Forgets the cached model of the given relation Name. So the next time we request it, |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * @param boolean $allow_persist |
239 | 239 | * @return boolean |
240 | 240 | */ |
241 | - function set_allow_persist( $allow_persist ); |
|
241 | + function set_allow_persist($allow_persist); |
|
242 | 242 | |
243 | 243 | |
244 | 244 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @param \EEI_Line_Item $line_item |
27 | 27 | * @return \EEI_Line_Item |
28 | 28 | */ |
29 | - public function process( EEI_Line_Item $line_item ); |
|
29 | + public function process(EEI_Line_Item $line_item); |
|
30 | 30 | |
31 | 31 | |
32 | 32 |