@@ -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 | * |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * @author Mike Nelson |
14 | 14 | * @since 4.6.0 |
15 | 15 | */ |
16 | -class EE_Soft_Delete_Where_Conditions extends EE_Default_Where_Conditions{ |
|
16 | +class EE_Soft_Delete_Where_Conditions extends EE_Default_Where_Conditions { |
|
17 | 17 | /** |
18 | 18 | * Strategy for setting default soft delete where conditions. This strategy will find |
19 | 19 | * the field of type 'EE_Trashed_Flag_Field', and add a condition that it be FALSE on all queries involving |
@@ -22,12 +22,12 @@ discard block |
||
22 | 22 | * Eg, |
23 | 23 | * |
24 | 24 | */ |
25 | - function __construct(){} |
|
25 | + function __construct() {} |
|
26 | 26 | /** |
27 | 27 | * Gets the where default where conditions for a custom post type model |
28 | 28 | * @return array like EEM_Base::get_all's $query_params's index [0] (where conditions) |
29 | 29 | */ |
30 | - protected function _get_default_where_conditions(){ |
|
30 | + protected function _get_default_where_conditions() { |
|
31 | 31 | $trashed_field_name = $this->deleted_field_name(); |
32 | 32 | return array( |
33 | 33 | $trashed_field_name => false |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | * @return string |
40 | 40 | * @throws EE_Error |
41 | 41 | */ |
42 | - private function deleted_field_name(){ |
|
42 | + private function deleted_field_name() { |
|
43 | 43 | $field = $this->_model->get_a_field_of_type('EE_Trashed_Flag_Field'); |
44 | - if($field){ |
|
44 | + if ($field) { |
|
45 | 45 | return $field->get_name(); |
46 | - }else{ |
|
47 | - throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?','event_espresso'),get_class($this),get_class($this))); |
|
46 | + } else { |
|
47 | + throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', 'event_espresso'), get_class($this), get_class($this))); |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | } |
51 | 51 | \ No newline at end of file |
@@ -58,10 +58,10 @@ discard block |
||
58 | 58 | * @return string |
59 | 59 | * @todo: at some point we can break this down into other static methods to abstract it a bit better. |
60 | 60 | */ |
61 | - static public function get_form_fields( $input_vars = array(), $id = FALSE ) { |
|
61 | + static public function get_form_fields($input_vars = array(), $id = FALSE) { |
|
62 | 62 | |
63 | - if ( empty($input_vars) ) { |
|
64 | - EE_Error::add_error( __('missing required variables for the form field generator', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
63 | + if (empty($input_vars)) { |
|
64 | + EE_Error::add_error(__('missing required variables for the form field generator', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
65 | 65 | return FALSE; |
66 | 66 | } |
67 | 67 | |
@@ -87,25 +87,25 @@ discard block |
||
87 | 87 | 'append_content' => '' |
88 | 88 | ); |
89 | 89 | |
90 | - $input_value = wp_parse_args( $input_value, $defaults ); |
|
90 | + $input_value = wp_parse_args($input_value, $defaults); |
|
91 | 91 | |
92 | 92 | // required fields get a * |
93 | 93 | $required = isset($input_value['required']) && $input_value['required'] ? ' <span>*</span>: ' : ': '; |
94 | 94 | // and the css class "required" |
95 | - $css_class = isset( $input_value['css_class'] ) ? $input_value['css_class'] : ''; |
|
96 | - $styles = $input_value['required'] ? 'required ' . $css_class : $css_class; |
|
95 | + $css_class = isset($input_value['css_class']) ? $input_value['css_class'] : ''; |
|
96 | + $styles = $input_value['required'] ? 'required '.$css_class : $css_class; |
|
97 | 97 | |
98 | - $field_id = ($id) ? $id . '-' . $input_key : $input_key; |
|
99 | - $tabindex = !empty($input_value['tabindex']) ? ' tabindex="' . $input_value['tabindex'] . '"' : ''; |
|
98 | + $field_id = ($id) ? $id.'-'.$input_key : $input_key; |
|
99 | + $tabindex = ! empty($input_value['tabindex']) ? ' tabindex="'.$input_value['tabindex'].'"' : ''; |
|
100 | 100 | |
101 | 101 | //rows or cols? |
102 | - $rows = isset($input_value['rows'] ) ? $input_value['rows'] : '10'; |
|
103 | - $cols = isset($input_value['cols'] ) ? $input_value['cols'] : '80'; |
|
102 | + $rows = isset($input_value['rows']) ? $input_value['rows'] : '10'; |
|
103 | + $cols = isset($input_value['cols']) ? $input_value['cols'] : '80'; |
|
104 | 104 | |
105 | 105 | //any content? |
106 | 106 | $append_content = $input_value['append_content']; |
107 | 107 | |
108 | - $output .= (!$close) ? '<ul>' : ''; |
|
108 | + $output .= ( ! $close) ? '<ul>' : ''; |
|
109 | 109 | $output .= '<li>'; |
110 | 110 | |
111 | 111 | // what type of input are we dealing with ? |
@@ -113,15 +113,15 @@ discard block |
||
113 | 113 | |
114 | 114 | // text inputs |
115 | 115 | case 'text' : |
116 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
117 | - $output .= "\n\t\t\t" . '<input id="' . $field_id . '" class="' . $styles . '" type="text" value="' . $input_value['value'] . '" name="' . $input_value['name'] . '"' . $tabindex . '>'; |
|
116 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
117 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" class="'.$styles.'" type="text" value="'.$input_value['value'].'" name="'.$input_value['name'].'"'.$tabindex.'>'; |
|
118 | 118 | break; |
119 | 119 | |
120 | 120 | // dropdowns |
121 | 121 | case 'select' : |
122 | 122 | |
123 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
124 | - $output .= "\n\t\t\t" . '<select id="' . $field_id . '" class="' . $styles . '" name="' . $input_value['name'] . '"' . $tabindex . '>'; |
|
123 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
124 | + $output .= "\n\t\t\t".'<select id="'.$field_id.'" class="'.$styles.'" name="'.$input_value['name'].'"'.$tabindex.'>'; |
|
125 | 125 | |
126 | 126 | if (is_array($input_value['options'])) { |
127 | 127 | $options = $input_value['options']; |
@@ -130,30 +130,30 @@ discard block |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | foreach ($options as $key => $value) { |
133 | - $selected = isset( $input_value['value'] ) && $input_value['value'] == $key ? 'selected=selected' : ''; |
|
133 | + $selected = isset($input_value['value']) && $input_value['value'] == $key ? 'selected=selected' : ''; |
|
134 | 134 | //$key = str_replace( ' ', '_', sanitize_key( $value )); |
135 | - $output .= "\n\t\t\t\t" . '<option '. $selected . ' value="' . $key . '">' . $value . '</option>'; |
|
135 | + $output .= "\n\t\t\t\t".'<option '.$selected.' value="'.$key.'">'.$value.'</option>'; |
|
136 | 136 | } |
137 | - $output .= "\n\t\t\t" . '</select>'; |
|
137 | + $output .= "\n\t\t\t".'</select>'; |
|
138 | 138 | |
139 | 139 | break; |
140 | 140 | |
141 | 141 | case 'textarea' : |
142 | 142 | |
143 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
144 | - $output .= "\n\t\t\t" . '<textarea id="' . $field_id . '" class="' . $styles . '" rows="'.$rows.'" cols="'.$cols.'" name="' . $input_value['name'] . '"' . $tabindex . '>' . $input_value['value'] . '</textarea>'; |
|
143 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
144 | + $output .= "\n\t\t\t".'<textarea id="'.$field_id.'" class="'.$styles.'" rows="'.$rows.'" cols="'.$cols.'" name="'.$input_value['name'].'"'.$tabindex.'>'.$input_value['value'].'</textarea>'; |
|
145 | 145 | break; |
146 | 146 | |
147 | 147 | case 'hidden' : |
148 | 148 | $close = false; |
149 | 149 | $output .= "</li></ul>"; |
150 | - $output .= "\n\t\t\t" . '<input id="' . $field_id . '" type="hidden" name="' . $input_value['name'] . '" value="' . $input_value['value'] . '">'; |
|
150 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" type="hidden" name="'.$input_value['name'].'" value="'.$input_value['value'].'">'; |
|
151 | 151 | break; |
152 | 152 | |
153 | 153 | case 'checkbox' : |
154 | - $checked = ( $input_value['value'] == 1 ) ? 'checked="checked"' : ''; |
|
155 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
156 | - $output .= "\n\t\t\t" . '<input id="' . $field_id. '" type="checkbox" name="' . $input_value['name'] . '" value="1"' . $checked . $tabindex . ' />'; |
|
154 | + $checked = ($input_value['value'] == 1) ? 'checked="checked"' : ''; |
|
155 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
156 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" type="checkbox" name="'.$input_value['name'].'" value="1"'.$checked.$tabindex.' />'; |
|
157 | 157 | break; |
158 | 158 | |
159 | 159 | case 'wp_editor' : |
@@ -166,19 +166,19 @@ discard block |
||
166 | 166 | ); |
167 | 167 | $output .= '</li>'; |
168 | 168 | $output .= '</ul>'; |
169 | - $output .= '<h4>' . $input_value['label'] . '</h4>'; |
|
170 | - if ( $append_content ) { |
|
169 | + $output .= '<h4>'.$input_value['label'].'</h4>'; |
|
170 | + if ($append_content) { |
|
171 | 171 | $output .= $append_content; |
172 | 172 | } |
173 | 173 | ob_start(); |
174 | - wp_editor( $input_value['value'], $field_id, $editor_settings); |
|
174 | + wp_editor($input_value['value'], $field_id, $editor_settings); |
|
175 | 175 | $editor = ob_get_contents(); |
176 | 176 | ob_end_clean(); |
177 | 177 | $output .= $editor; |
178 | 178 | break; |
179 | 179 | |
180 | 180 | } |
181 | - if ( $append_content && $input_value['input'] !== 'wp_editor' ) { |
|
181 | + if ($append_content && $input_value['input'] !== 'wp_editor') { |
|
182 | 182 | $output .= $append_content; |
183 | 183 | } |
184 | 184 | $output .= ($close) ? '</li>' : ''; |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | $form_fields = array(); |
220 | 220 | $fields = (array) $fields; |
221 | 221 | |
222 | - foreach ( $fields as $field_name => $field_atts ) { |
|
222 | + foreach ($fields as $field_name => $field_atts) { |
|
223 | 223 | //defaults: |
224 | 224 | $defaults = array( |
225 | 225 | 'label' => '', |
@@ -237,67 +237,67 @@ discard block |
||
237 | 237 | 'wpeditor_args' => array() |
238 | 238 | ); |
239 | 239 | // merge defaults with passed arguments |
240 | - $_fields = wp_parse_args( $field_atts, $defaults); |
|
241 | - extract( $_fields ); |
|
240 | + $_fields = wp_parse_args($field_atts, $defaults); |
|
241 | + extract($_fields); |
|
242 | 242 | // generate label |
243 | - $label = empty($label) ? '' : '<label for="' . $id . '">' . $label . '</label>'; |
|
243 | + $label = empty($label) ? '' : '<label for="'.$id.'">'.$label.'</label>'; |
|
244 | 244 | // generate field name |
245 | - $f_name = !empty($unique_id) ? $field_name . '[' . $unique_id . ']' : $field_name; |
|
245 | + $f_name = ! empty($unique_id) ? $field_name.'['.$unique_id.']' : $field_name; |
|
246 | 246 | |
247 | 247 | //tabindex |
248 | - $tabindex_str = !empty( $tabindex ) ? ' tabindex="' . $tabindex . '"' : ''; |
|
248 | + $tabindex_str = ! empty($tabindex) ? ' tabindex="'.$tabindex.'"' : ''; |
|
249 | 249 | |
250 | 250 | //we determine what we're building based on the type |
251 | - switch ( $type ) { |
|
251 | + switch ($type) { |
|
252 | 252 | |
253 | 253 | case 'textarea' : |
254 | - $fld = '<textarea id="' . $id . '" class="' . $class . '" rows="' . $dimensions[1] . '" cols="' . $dimensions[0] . '" name="' . $f_name . '"' . $tabindex_str . '>' . $value . '</textarea>'; |
|
254 | + $fld = '<textarea id="'.$id.'" class="'.$class.'" rows="'.$dimensions[1].'" cols="'.$dimensions[0].'" name="'.$f_name.'"'.$tabindex_str.'>'.$value.'</textarea>'; |
|
255 | 255 | $fld .= $extra_desc; |
256 | 256 | break; |
257 | 257 | |
258 | 258 | case 'checkbox' : |
259 | 259 | $c_input = ''; |
260 | - if ( is_array($value) ) { |
|
261 | - foreach ( $value as $key => $val ) { |
|
262 | - $c_id = $field_name . '_' . $value; |
|
263 | - $c_class = isset($classes[$key]) ? ' class="' . $classes[$key] . '" ' : ''; |
|
264 | - $c_label = isset($labels[$key]) ? '<label for="' . $c_id . '">' . $labels[$key] . '</label>' : ''; |
|
265 | - $checked = !empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
266 | - $c_input .= '<input name="' . $f_name . '[]" type="checkbox" id="' . $c_id . '"' . $c_class . 'value="' . $val . '"' . $checked . $tabindex_str . ' />' . "\n" . $c_label; |
|
260 | + if (is_array($value)) { |
|
261 | + foreach ($value as $key => $val) { |
|
262 | + $c_id = $field_name.'_'.$value; |
|
263 | + $c_class = isset($classes[$key]) ? ' class="'.$classes[$key].'" ' : ''; |
|
264 | + $c_label = isset($labels[$key]) ? '<label for="'.$c_id.'">'.$labels[$key].'</label>' : ''; |
|
265 | + $checked = ! empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
266 | + $c_input .= '<input name="'.$f_name.'[]" type="checkbox" id="'.$c_id.'"'.$c_class.'value="'.$val.'"'.$checked.$tabindex_str.' />'."\n".$c_label; |
|
267 | 267 | } |
268 | 268 | $fld = $c_input; |
269 | 269 | } else { |
270 | - $checked = !empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
271 | - $fld = '<input name="'. $f_name . '" type="checkbox" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $checked . $tabindex_str . ' />' . "\n"; |
|
270 | + $checked = ! empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
271 | + $fld = '<input name="'.$f_name.'" type="checkbox" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$checked.$tabindex_str.' />'."\n"; |
|
272 | 272 | } |
273 | 273 | break; |
274 | 274 | |
275 | 275 | case 'radio' : |
276 | 276 | $c_input = ''; |
277 | - if ( is_array($value) ) { |
|
278 | - foreach ( $value as $key => $val ) { |
|
279 | - $c_id = $field_name . '_' . $value; |
|
280 | - $c_class = isset($classes[$key]) ? 'class="' . $classes[$key] . '" ' : ''; |
|
281 | - $c_label = isset($labels[$key]) ? '<label for="' . $c_id . '">' . $labels[$key] . '</label>' : ''; |
|
282 | - $checked = !empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
283 | - $c_input .= '<input name="' . $f_name . '" type="checkbox" id="' . $c_id . '"' . $c_class . 'value="' . $val . '"' . $checked . $tabindex_str . ' />' . "\n" . $c_label; |
|
277 | + if (is_array($value)) { |
|
278 | + foreach ($value as $key => $val) { |
|
279 | + $c_id = $field_name.'_'.$value; |
|
280 | + $c_class = isset($classes[$key]) ? 'class="'.$classes[$key].'" ' : ''; |
|
281 | + $c_label = isset($labels[$key]) ? '<label for="'.$c_id.'">'.$labels[$key].'</label>' : ''; |
|
282 | + $checked = ! empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
283 | + $c_input .= '<input name="'.$f_name.'" type="checkbox" id="'.$c_id.'"'.$c_class.'value="'.$val.'"'.$checked.$tabindex_str.' />'."\n".$c_label; |
|
284 | 284 | } |
285 | 285 | $fld = $c_input; |
286 | 286 | } else { |
287 | - $checked = !empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
288 | - $fld = '<input name="'. $f_name . '" type="checkbox" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $checked . $tabindex_str . ' />' . "\n"; |
|
287 | + $checked = ! empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
288 | + $fld = '<input name="'.$f_name.'" type="checkbox" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$checked.$tabindex_str.' />'."\n"; |
|
289 | 289 | } |
290 | 290 | break; |
291 | 291 | |
292 | 292 | case 'hidden' : |
293 | - $fld = '<input name="' . $f_name . '" type="hidden" id="' . $id . '" class="' . $class . '" value="' . $value . '" />' . "\n"; |
|
293 | + $fld = '<input name="'.$f_name.'" type="hidden" id="'.$id.'" class="'.$class.'" value="'.$value.'" />'."\n"; |
|
294 | 294 | break; |
295 | 295 | |
296 | 296 | case 'select' : |
297 | - $fld = '<select name="' . $f_name . '" class="' . $class . '" id="' . $id . '"' . $tabindex_str . '>' . "\n"; |
|
298 | - foreach ( $value as $key => $val ) { |
|
299 | - $checked = !empty($default) && $default == $val ? ' selected="selected"' : ''; |
|
300 | - $fld .= "\t" . '<option value="' . $val . '"' . $checked . '>' . $labels[$key] . '</option>' . "\n"; |
|
297 | + $fld = '<select name="'.$f_name.'" class="'.$class.'" id="'.$id.'"'.$tabindex_str.'>'."\n"; |
|
298 | + foreach ($value as $key => $val) { |
|
299 | + $checked = ! empty($default) && $default == $val ? ' selected="selected"' : ''; |
|
300 | + $fld .= "\t".'<option value="'.$val.'"'.$checked.'>'.$labels[$key].'</option>'."\n"; |
|
301 | 301 | } |
302 | 302 | $fld .= '</select>'; |
303 | 303 | break; |
@@ -309,21 +309,21 @@ discard block |
||
309 | 309 | 'editor_class' => $class, |
310 | 310 | 'tabindex' => $tabindex |
311 | 311 | ); |
312 | - $editor_settings = array_merge( $wpeditor_args, $editor_settings ); |
|
312 | + $editor_settings = array_merge($wpeditor_args, $editor_settings); |
|
313 | 313 | ob_start(); |
314 | - wp_editor( $value, $id, $editor_settings ); |
|
314 | + wp_editor($value, $id, $editor_settings); |
|
315 | 315 | $editor = ob_get_contents(); |
316 | 316 | ob_end_clean(); |
317 | 317 | $fld = $editor; |
318 | 318 | break; |
319 | 319 | |
320 | 320 | default : //'text fields' |
321 | - $fld = '<input name="' . $f_name . '" type="text" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $tabindex_str . ' />' . "\n"; |
|
321 | + $fld = '<input name="'.$f_name.'" type="text" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$tabindex_str.' />'."\n"; |
|
322 | 322 | $fld .= $extra_desc; |
323 | 323 | |
324 | 324 | } |
325 | 325 | |
326 | - $form_fields[ $field_name ] = array( 'label' => $label, 'field' => $fld ); |
|
326 | + $form_fields[$field_name] = array('label' => $label, 'field' => $fld); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | return $form_fields; |
@@ -352,22 +352,22 @@ discard block |
||
352 | 352 | */ |
353 | 353 | static public function select_input($name, $values, $default = '', $parameters = '', $class = '', $autosize = true) { |
354 | 354 | //if $values was submitted in the wrong format, convert it over |
355 | - if(!empty($values) && (!array_key_exists(0,$values) || !is_array($values[0]))){ |
|
356 | - $converted_values=array(); |
|
357 | - foreach($values as $id=>$text){ |
|
358 | - $converted_values[]=array('id'=>$id,'text'=>$text); |
|
355 | + if ( ! empty($values) && ( ! array_key_exists(0, $values) || ! is_array($values[0]))) { |
|
356 | + $converted_values = array(); |
|
357 | + foreach ($values as $id=>$text) { |
|
358 | + $converted_values[] = array('id'=>$id, 'text'=>$text); |
|
359 | 359 | } |
360 | - $values=$converted_values; |
|
360 | + $values = $converted_values; |
|
361 | 361 | } |
362 | 362 | //load formatter helper |
363 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
363 | + EE_Registry::instance()->load_helper('Formatter'); |
|
364 | 364 | //EE_Registry::instance()->load_helper( 'Formatter' ); |
365 | 365 | |
366 | - $field = '<select id="' . EEH_Formatter::ee_tep_output_string($name) . '" name="' . EEH_Formatter::ee_tep_output_string($name) . '"'; |
|
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 | if ($autosize) { |
372 | 372 | $size = 'med'; |
373 | 373 | for ($ii = 0, $ni = sizeof($values); $ii < $ni; $ii++) { |
@@ -380,21 +380,21 @@ discard block |
||
380 | 380 | $size = ''; |
381 | 381 | } |
382 | 382 | |
383 | - $field .= ' class="' . $class . ' ' . $size . '">'; |
|
383 | + $field .= ' class="'.$class.' '.$size.'">'; |
|
384 | 384 | |
385 | 385 | if (empty($default) && isset($GLOBALS[$name])) |
386 | 386 | $default = stripslashes($GLOBALS[$name]); |
387 | 387 | |
388 | 388 | |
389 | 389 | for ($i = 0, $n = sizeof($values); $i < $n; $i++) { |
390 | - $field .= '<option value="' . $values[$i]['id'] . '"'; |
|
390 | + $field .= '<option value="'.$values[$i]['id'].'"'; |
|
391 | 391 | if ($default == $values[$i]['id']) { |
392 | 392 | $field .= ' selected = "selected"'; |
393 | 393 | } |
394 | - if ( isset( $values[$i]['class'] ) ) { |
|
395 | - $field .= ' class="' . $values[$i]['class'] . '"'; |
|
394 | + if (isset($values[$i]['class'])) { |
|
395 | + $field .= ' class="'.$values[$i]['class'].'"'; |
|
396 | 396 | } |
397 | - $field .= '>' . $values[$i]['text'] . '</option>'; |
|
397 | + $field .= '>'.$values[$i]['text'].'</option>'; |
|
398 | 398 | } |
399 | 399 | $field .= '</select>'; |
400 | 400 | |
@@ -412,38 +412,38 @@ discard block |
||
412 | 412 | * @param string $question_groups |
413 | 413 | * @return string HTML |
414 | 414 | */ |
415 | - static function generate_question_groups_html( $question_groups = array(), $group_wrapper = 'fieldset' ) { |
|
415 | + static function generate_question_groups_html($question_groups = array(), $group_wrapper = 'fieldset') { |
|
416 | 416 | |
417 | 417 | $html = ''; |
418 | - $before_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '' ); |
|
419 | - $after_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '' ); |
|
418 | + $before_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', ''); |
|
419 | + $after_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', ''); |
|
420 | 420 | |
421 | - if ( ! empty( $question_groups )) { |
|
421 | + if ( ! empty($question_groups)) { |
|
422 | 422 | //EEH_Debug_Tools::printr( $question_groups, '$question_groups <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
423 | 423 | // loop thru question groups |
424 | - foreach ( $question_groups as $QSG ) { |
|
424 | + foreach ($question_groups as $QSG) { |
|
425 | 425 | // check that questions exist |
426 | - if ( ! empty( $QSG['QSG_questions'] )) { |
|
426 | + if ( ! empty($QSG['QSG_questions'])) { |
|
427 | 427 | // use fieldsets |
428 | - $html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG['QSG_identifier'] . '">'; |
|
428 | + $html .= "\n\t".'<'.$group_wrapper.' class="espresso-question-group-wrap" id="'.$QSG['QSG_identifier'].'">'; |
|
429 | 429 | // group_name |
430 | - $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>' : ''; |
|
430 | + $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>' : ''; |
|
431 | 431 | // group_desc |
432 | - $html .= $QSG['QSG_show_group_desc'] && ! empty( $QSG['QSG_desc'] ) ? '<div class="espresso-question-group-desc-pg">' . self::prep_answer( $QSG['QSG_desc'] ) . '</div>' : ''; |
|
432 | + $html .= $QSG['QSG_show_group_desc'] && ! empty($QSG['QSG_desc']) ? '<div class="espresso-question-group-desc-pg">'.self::prep_answer($QSG['QSG_desc']).'</div>' : ''; |
|
433 | 433 | |
434 | 434 | $html .= $before_question_group_questions; |
435 | 435 | // loop thru questions |
436 | - foreach ( $QSG['QSG_questions'] as $question ) { |
|
436 | + foreach ($QSG['QSG_questions'] as $question) { |
|
437 | 437 | // EEH_Debug_Tools::printr( $question, '$question <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
438 | 438 | $QFI = new EE_Question_Form_Input( |
439 | 439 | $question['qst_obj'], |
440 | 440 | $question['ans_obj'], |
441 | 441 | $question |
442 | 442 | ); |
443 | - $html .= self::generate_form_input( $QFI ); |
|
443 | + $html .= self::generate_form_input($QFI); |
|
444 | 444 | } |
445 | 445 | $html .= $after_question_group_questions; |
446 | - $html .= "\n\t" . '</' . $group_wrapper . '>'; |
|
446 | + $html .= "\n\t".'</'.$group_wrapper.'>'; |
|
447 | 447 | } |
448 | 448 | } |
449 | 449 | } |
@@ -463,11 +463,11 @@ discard block |
||
463 | 463 | * @param string $group_wrapper |
464 | 464 | * @return string HTML |
465 | 465 | */ |
466 | - static function generate_question_groups_html2( $question_groups = array(), $q_meta = array(), $from_admin = FALSE, $group_wrapper = 'fieldset' ) { |
|
466 | + static function generate_question_groups_html2($question_groups = array(), $q_meta = array(), $from_admin = FALSE, $group_wrapper = 'fieldset') { |
|
467 | 467 | |
468 | 468 | $html = ''; |
469 | - $before_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '' ); |
|
470 | - $after_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '' ); |
|
469 | + $before_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', ''); |
|
470 | + $after_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', ''); |
|
471 | 471 | |
472 | 472 | $default_q_meta = array( |
473 | 473 | 'att_nmbr' => 1, |
@@ -476,55 +476,55 @@ discard block |
||
476 | 476 | 'input_id' => '', |
477 | 477 | 'input_class' => '' |
478 | 478 | ); |
479 | - $q_meta = array_merge( $default_q_meta, $q_meta ); |
|
479 | + $q_meta = array_merge($default_q_meta, $q_meta); |
|
480 | 480 | //EEH_Debug_Tools::printr( $q_meta, '$q_meta <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
481 | 481 | |
482 | - if ( ! empty( $question_groups )) { |
|
482 | + if ( ! empty($question_groups)) { |
|
483 | 483 | // EEH_Debug_Tools::printr( $question_groups, '$question_groups <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
484 | 484 | // loop thru question groups |
485 | - foreach ( $question_groups as $QSG ) { |
|
486 | - if ( $QSG instanceof EE_Question_Group ) { |
|
485 | + foreach ($question_groups as $QSG) { |
|
486 | + if ($QSG instanceof EE_Question_Group) { |
|
487 | 487 | // check that questions exist |
488 | 488 | |
489 | - $where = array( 'QST_deleted' => 0 ); |
|
490 | - if ( ! $from_admin ) { |
|
489 | + $where = array('QST_deleted' => 0); |
|
490 | + if ( ! $from_admin) { |
|
491 | 491 | $where['QST_admin_only'] = 0; |
492 | 492 | } |
493 | - $questions = $QSG->questions( array( $where, 'order_by' => array( 'Question_Group_Question.QGQ_order' => 'ASC' ))); |
|
494 | - if ( ! empty( $questions )) { |
|
493 | + $questions = $QSG->questions(array($where, 'order_by' => array('Question_Group_Question.QGQ_order' => 'ASC'))); |
|
494 | + if ( ! empty($questions)) { |
|
495 | 495 | // use fieldsets |
496 | - $html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG->get( 'QSG_identifier' ) . '">'; |
|
496 | + $html .= "\n\t".'<'.$group_wrapper.' class="espresso-question-group-wrap" id="'.$QSG->get('QSG_identifier').'">'; |
|
497 | 497 | // group_name |
498 | - if ( $QSG->show_group_name() ) { |
|
499 | - $html .= "\n\t\t" . '<h5 class="espresso-question-group-title-h5 section-title">' . $QSG->get_pretty( 'QSG_name' ) . '</h5>'; |
|
498 | + if ($QSG->show_group_name()) { |
|
499 | + $html .= "\n\t\t".'<h5 class="espresso-question-group-title-h5 section-title">'.$QSG->get_pretty('QSG_name').'</h5>'; |
|
500 | 500 | } |
501 | 501 | // group_desc |
502 | - if ( $QSG->show_group_desc() ) { |
|
503 | - $html .= '<div class="espresso-question-group-desc-pg">' . $QSG->get_pretty( 'QSG_desc' ) . '</div>'; |
|
502 | + if ($QSG->show_group_desc()) { |
|
503 | + $html .= '<div class="espresso-question-group-desc-pg">'.$QSG->get_pretty('QSG_desc').'</div>'; |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | $html .= $before_question_group_questions; |
507 | 507 | // loop thru questions |
508 | - foreach ( $questions as $QST ) { |
|
508 | + foreach ($questions as $QST) { |
|
509 | 509 | $qstn_id = $QST->is_system_question() ? $QST->system_ID() : $QST->ID(); |
510 | 510 | |
511 | 511 | $answer = NULL; |
512 | 512 | |
513 | - if ( isset( $_GET['qstn'] ) && isset( $q_meta['input_id'] ) && isset( $q_meta['att_nmbr'] )) { |
|
513 | + if (isset($_GET['qstn']) && isset($q_meta['input_id']) && isset($q_meta['att_nmbr'])) { |
|
514 | 514 | // check for answer in $_GET in case we are reprocessing a form after an error |
515 | - if ( isset( $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] )) { |
|
516 | - $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 ] ); |
|
515 | + if (isset($_GET['qstn'][$q_meta['input_id']][$qstn_id])) { |
|
516 | + $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]); |
|
517 | 517 | } |
518 | - } else if ( isset( $q_meta['attendee'] ) && $q_meta['attendee'] ) { |
|
518 | + } else if (isset($q_meta['attendee']) && $q_meta['attendee']) { |
|
519 | 519 | //attendee data from the session |
520 | - $answer = isset( $q_meta['attendee'][ $qstn_id ] ) ? $q_meta['attendee'][ $qstn_id ] : NULL; |
|
520 | + $answer = isset($q_meta['attendee'][$qstn_id]) ? $q_meta['attendee'][$qstn_id] : NULL; |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | |
524 | 524 | |
525 | 525 | $QFI = new EE_Question_Form_Input( |
526 | 526 | $QST, |
527 | - EE_Answer::new_instance ( array( |
|
527 | + EE_Answer::new_instance(array( |
|
528 | 528 | 'ANS_ID'=> 0, |
529 | 529 | 'QST_ID'=> 0, |
530 | 530 | 'REG_ID'=> 0, |
@@ -533,10 +533,10 @@ discard block |
||
533 | 533 | $q_meta |
534 | 534 | ); |
535 | 535 | //EEH_Debug_Tools::printr( $QFI, '$QFI <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
536 | - $html .= self::generate_form_input( $QFI ); |
|
536 | + $html .= self::generate_form_input($QFI); |
|
537 | 537 | } |
538 | 538 | $html .= $after_question_group_questions; |
539 | - $html .= "\n\t" . '</' . $group_wrapper . '>'; |
|
539 | + $html .= "\n\t".'</'.$group_wrapper.'>'; |
|
540 | 540 | } |
541 | 541 | } |
542 | 542 | } |
@@ -556,63 +556,63 @@ discard block |
||
556 | 556 | * @param EE_Question_Form_Input $QFI |
557 | 557 | * @return string HTML |
558 | 558 | */ |
559 | - static function generate_form_input( EE_Question_Form_Input $QFI ) { |
|
560 | - if ( isset( $QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin() ) { |
|
559 | + static function generate_form_input(EE_Question_Form_Input $QFI) { |
|
560 | + if (isset($QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin()) { |
|
561 | 561 | return ''; |
562 | 562 | } |
563 | 563 | |
564 | - $QFI = self::_load_system_dropdowns( $QFI ); |
|
565 | - $QFI = self::_load_specialized_dropdowns( $QFI ); |
|
564 | + $QFI = self::_load_system_dropdowns($QFI); |
|
565 | + $QFI = self::_load_specialized_dropdowns($QFI); |
|
566 | 566 | |
567 | 567 | //we also need to verify |
568 | 568 | |
569 | 569 | $display_text = $QFI->get('QST_display_text'); |
570 | 570 | $input_name = $QFI->get('QST_input_name'); |
571 | - $answer = EE_Registry::instance()->REQ->is_set( $input_name ) ? EE_Registry::instance()->REQ->get( $input_name ) : $QFI->get('ANS_value'); |
|
571 | + $answer = EE_Registry::instance()->REQ->is_set($input_name) ? EE_Registry::instance()->REQ->get($input_name) : $QFI->get('ANS_value'); |
|
572 | 572 | $input_id = $QFI->get('QST_input_id'); |
573 | 573 | $input_class = $QFI->get('QST_input_class'); |
574 | 574 | // $disabled = $QFI->get('QST_disabled') ? ' disabled="disabled"' : ''; |
575 | 575 | $disabled = $QFI->get('QST_disabled') ? TRUE : FALSE; |
576 | - $required_label = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>' ); |
|
576 | + $required_label = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>'); |
|
577 | 577 | $QST_required = $QFI->get('QST_required'); |
578 | - $required = $QST_required ? array( 'label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required ) : array(); |
|
579 | - $use_html_entities = $QFI->get_meta( 'htmlentities' ); |
|
580 | - $required_text = $QFI->get('QST_required_text') != '' ? $QFI->get('QST_required_text') : __( 'This field is required', 'event_espresso' ); |
|
581 | - $required_text = $QST_required ? "\n\t\t\t" . '<div class="required-text hidden">' . self::prep_answer( $required_text, $use_html_entities ) . '</div>' : ''; |
|
578 | + $required = $QST_required ? array('label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required) : array(); |
|
579 | + $use_html_entities = $QFI->get_meta('htmlentities'); |
|
580 | + $required_text = $QFI->get('QST_required_text') != '' ? $QFI->get('QST_required_text') : __('This field is required', 'event_espresso'); |
|
581 | + $required_text = $QST_required ? "\n\t\t\t".'<div class="required-text hidden">'.self::prep_answer($required_text, $use_html_entities).'</div>' : ''; |
|
582 | 582 | $label_class = 'espresso-form-input-lbl'; |
583 | - $QST_options = $QFI->options(true,$answer); |
|
584 | - $options = is_array( $QST_options ) ? self::prep_answer_options( $QST_options ) : array(); |
|
583 | + $QST_options = $QFI->options(true, $answer); |
|
584 | + $options = is_array($QST_options) ? self::prep_answer_options($QST_options) : array(); |
|
585 | 585 | $system_ID = $QFI->get('QST_system'); |
586 | - $label_b4 = $QFI->get_meta( 'label_b4' ); |
|
587 | - $use_desc_4_label = $QFI->get_meta( 'use_desc_4_label' ); |
|
586 | + $label_b4 = $QFI->get_meta('label_b4'); |
|
587 | + $use_desc_4_label = $QFI->get_meta('use_desc_4_label'); |
|
588 | 588 | |
589 | 589 | |
590 | - switch ( $QFI->get('QST_type') ){ |
|
590 | + switch ($QFI->get('QST_type')) { |
|
591 | 591 | |
592 | 592 | case 'TEXTAREA' : |
593 | - 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 ); |
|
593 | + 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); |
|
594 | 594 | break; |
595 | 595 | |
596 | 596 | case 'DROPDOWN' : |
597 | - 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 ); |
|
597 | + 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); |
|
598 | 598 | break; |
599 | 599 | |
600 | 600 | |
601 | 601 | case 'RADIO_BTN' : |
602 | - 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 ); |
|
602 | + 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); |
|
603 | 603 | break; |
604 | 604 | |
605 | 605 | case 'CHECKBOX' : |
606 | - 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 ); |
|
606 | + 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); |
|
607 | 607 | break; |
608 | 608 | |
609 | 609 | case 'DATE' : |
610 | - 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 ); |
|
610 | + 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); |
|
611 | 611 | break; |
612 | 612 | |
613 | 613 | case 'TEXT' : |
614 | 614 | default: |
615 | - 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 ); |
|
615 | + 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); |
|
616 | 616 | break; |
617 | 617 | |
618 | 618 | } |
@@ -638,31 +638,31 @@ discard block |
||
638 | 638 | * @param string $disabled disabled="disabled" or null |
639 | 639 | * @return string HTML |
640 | 640 | */ |
641 | - 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 ) { |
|
641 | + 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) { |
|
642 | 642 | // need these |
643 | - if ( ! $question || ! $name ) { |
|
643 | + if ( ! $question || ! $name) { |
|
644 | 644 | return NULL; |
645 | 645 | } |
646 | 646 | // prep the answer |
647 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
647 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
648 | 648 | // prep the required array |
649 | - $required = self::prep_required( $required ); |
|
649 | + $required = self::prep_required($required); |
|
650 | 650 | // set disabled tag |
651 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
651 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
652 | 652 | // ya gots ta have style man!!! |
653 | 653 | $txt_class = is_admin() ? 'regular-text' : 'espresso-text-inp'; |
654 | - $class = empty( $class ) ? $txt_class : $class; |
|
655 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
656 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
654 | + $class = empty($class) ? $txt_class : $class; |
|
655 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
656 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
657 | 657 | |
658 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
658 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
659 | 659 | // filter label but ensure required text comes before it |
660 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
660 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
661 | 661 | |
662 | - $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 . '/>'; |
|
662 | + $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.'/>'; |
|
663 | 663 | |
664 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
665 | - return $label_html . $input_html; |
|
664 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
665 | + return $label_html.$input_html; |
|
666 | 666 | |
667 | 667 | } |
668 | 668 | |
@@ -684,35 +684,35 @@ discard block |
||
684 | 684 | * @param string $disabled disabled="disabled" or null |
685 | 685 | * @return string HTML |
686 | 686 | */ |
687 | - 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 ) { |
|
687 | + 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) { |
|
688 | 688 | // need these |
689 | - if ( ! $question || ! $name ) { |
|
689 | + if ( ! $question || ! $name) { |
|
690 | 690 | return NULL; |
691 | 691 | } |
692 | 692 | // prep the answer |
693 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
693 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
694 | 694 | // prep the required array |
695 | - $required = self::prep_required( $required ); |
|
695 | + $required = self::prep_required($required); |
|
696 | 696 | // make sure $dimensions is an array |
697 | - $dimensions = is_array( $dimensions ) ? $dimensions : array(); |
|
697 | + $dimensions = is_array($dimensions) ? $dimensions : array(); |
|
698 | 698 | // and set some defaults |
699 | - $dimensions = array_merge( array( 'rows' => 3, 'cols' => 40 ), $dimensions ); |
|
699 | + $dimensions = array_merge(array('rows' => 3, 'cols' => 40), $dimensions); |
|
700 | 700 | // set disabled tag |
701 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
701 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
702 | 702 | // ya gots ta have style man!!! |
703 | 703 | $txt_class = is_admin() ? 'regular-text' : 'espresso-textarea-inp'; |
704 | - $class = empty( $class ) ? $txt_class : $class; |
|
705 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
706 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
704 | + $class = empty($class) ? $txt_class : $class; |
|
705 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
706 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
707 | 707 | |
708 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
708 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
709 | 709 | // filter label but ensure required text comes before it |
710 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
710 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
711 | 711 | |
712 | - $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>'; |
|
712 | + $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>'; |
|
713 | 713 | |
714 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
715 | - return $label_html . $input_html; |
|
714 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
715 | + return $label_html.$input_html; |
|
716 | 716 | |
717 | 717 | } |
718 | 718 | |
@@ -735,47 +735,47 @@ discard block |
||
735 | 735 | * @param string $disabled disabled="disabled" or null |
736 | 736 | * @return string HTML |
737 | 737 | */ |
738 | - 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 ) { |
|
738 | + 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) { |
|
739 | 739 | |
740 | 740 | // need these |
741 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
741 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
742 | 742 | return NULL; |
743 | 743 | } |
744 | 744 | // prep the answer |
745 | - $answer = is_array( $answer ) ? self::prep_answer( array_shift( $answer ), $use_html_entities) : self::prep_answer( $answer, $use_html_entities ); |
|
745 | + $answer = is_array($answer) ? self::prep_answer(array_shift($answer), $use_html_entities) : self::prep_answer($answer, $use_html_entities); |
|
746 | 746 | // prep the required array |
747 | - $required = self::prep_required( $required ); |
|
747 | + $required = self::prep_required($required); |
|
748 | 748 | // set disabled tag |
749 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
749 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
750 | 750 | // ya gots ta have style man!!! |
751 | 751 | $txt_class = is_admin() ? 'wide' : 'espresso-select-inp'; |
752 | - $class = empty( $class ) ? $txt_class : $class; |
|
753 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
754 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
752 | + $class = empty($class) ? $txt_class : $class; |
|
753 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
754 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
755 | 755 | |
756 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
756 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
757 | 757 | // filter label but ensure required text comes before it |
758 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
758 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
759 | 759 | |
760 | - $input_html = "\n\t\t\t" . '<select name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" title="' . esc_attr( $required['msg'] ) . '"' . $disabled . ' ' . $extra . '>'; |
|
760 | + $input_html = "\n\t\t\t".'<select name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" title="'.esc_attr($required['msg']).'"'.$disabled.' '.$extra.'>'; |
|
761 | 761 | // recursively count array elements, to determine total number of options |
762 | - $only_option = count( $options, 1 ) == 1 ? TRUE : FALSE; |
|
763 | - if ( ! $only_option ) { |
|
762 | + $only_option = count($options, 1) == 1 ? TRUE : FALSE; |
|
763 | + if ( ! $only_option) { |
|
764 | 764 | // if there is NO answer set and there are multiple options to choose from, then set the "please select" message as selected |
765 | 765 | $selected = $answer === NULL ? ' selected="selected"' : ''; |
766 | - $input_html .= $add_please_select_option ? "\n\t\t\t\t" . '<option value=""' . $selected . '>' . __(' - please select - ', 'event_espresso') . '</option>' : ''; |
|
766 | + $input_html .= $add_please_select_option ? "\n\t\t\t\t".'<option value=""'.$selected.'>'.__(' - please select - ', 'event_espresso').'</option>' : ''; |
|
767 | 767 | } |
768 | - foreach ( $options as $key => $value ) { |
|
768 | + foreach ($options as $key => $value) { |
|
769 | 769 | // if value is an array, then create option groups, else create regular ol' options |
770 | - $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 ); |
|
770 | + $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); |
|
771 | 771 | } |
772 | 772 | |
773 | - $input_html .= "\n\t\t\t" . '</select>'; |
|
773 | + $input_html .= "\n\t\t\t".'</select>'; |
|
774 | 774 | |
775 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__select__before_end_wrapper', $input_html, $question, $answer, $name, $id, $class, $system_ID ); |
|
775 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__select__before_end_wrapper', $input_html, $question, $answer, $name, $id, $class, $system_ID); |
|
776 | 776 | |
777 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
778 | - return $label_html . $input_html; |
|
777 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
778 | + return $label_html.$input_html; |
|
779 | 779 | |
780 | 780 | } |
781 | 781 | |
@@ -793,12 +793,12 @@ discard block |
||
793 | 793 | * @param boolean $use_html_entities |
794 | 794 | * @return string |
795 | 795 | */ |
796 | - private static function _generate_select_option_group( $opt_group, $QSOs, $answer, $use_html_entities = true ){ |
|
797 | - $html = "\n\t\t\t\t" . '<optgroup label="' . self::prep_option_value( $opt_group ) . '">'; |
|
798 | - foreach ( $QSOs as $QSO ) { |
|
799 | - $html .= self::_generate_select_option( $QSO->value(), $QSO->desc(), $answer, false, $use_html_entities ); |
|
796 | + private static function _generate_select_option_group($opt_group, $QSOs, $answer, $use_html_entities = true) { |
|
797 | + $html = "\n\t\t\t\t".'<optgroup label="'.self::prep_option_value($opt_group).'">'; |
|
798 | + foreach ($QSOs as $QSO) { |
|
799 | + $html .= self::_generate_select_option($QSO->value(), $QSO->desc(), $answer, false, $use_html_entities); |
|
800 | 800 | } |
801 | - $html .= "\n\t\t\t\t" . '</optgroup>'; |
|
801 | + $html .= "\n\t\t\t\t".'</optgroup>'; |
|
802 | 802 | return $html; |
803 | 803 | } |
804 | 804 | |
@@ -813,12 +813,12 @@ discard block |
||
813 | 813 | * @param boolean $use_html_entities |
814 | 814 | * @return string |
815 | 815 | */ |
816 | - private static function _generate_select_option( $key, $value, $answer, $only_option = FALSE, $use_html_entities = true ){ |
|
817 | - $key = self::prep_answer( $key, $use_html_entities ); |
|
818 | - $value = self::prep_answer( $value, $use_html_entities ); |
|
819 | - $value = ! empty( $value ) ? $value : $key; |
|
820 | - $selected = ( $answer == $key || $only_option ) ? ' selected="selected"' : ''; |
|
821 | - return "\n\t\t\t\t" . '<option value="' . self::prep_option_value( $key ) . '"' . $selected . '> ' . $value . ' </option>'; |
|
816 | + private static function _generate_select_option($key, $value, $answer, $only_option = FALSE, $use_html_entities = true) { |
|
817 | + $key = self::prep_answer($key, $use_html_entities); |
|
818 | + $value = self::prep_answer($value, $use_html_entities); |
|
819 | + $value = ! empty($value) ? $value : $key; |
|
820 | + $selected = ($answer == $key || $only_option) ? ' selected="selected"' : ''; |
|
821 | + return "\n\t\t\t\t".'<option value="'.self::prep_option_value($key).'"'.$selected.'> '.$value.' </option>'; |
|
822 | 822 | } |
823 | 823 | |
824 | 824 | |
@@ -842,56 +842,56 @@ discard block |
||
842 | 842 | * @param bool $use_desc_4_label |
843 | 843 | * @return string HTML |
844 | 844 | */ |
845 | - 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 ) { |
|
845 | + 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) { |
|
846 | 846 | // need these |
847 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
847 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
848 | 848 | return NULL; |
849 | 849 | } |
850 | 850 | // prep the answer |
851 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
851 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
852 | 852 | // prep the required array |
853 | - $required = self::prep_required( $required ); |
|
853 | + $required = self::prep_required($required); |
|
854 | 854 | // set disabled tag |
855 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
855 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
856 | 856 | // ya gots ta have style man!!! |
857 | 857 | $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class; |
858 | - $class = ! empty( $class ) ? $class : 'espresso-radio-btn-inp'; |
|
859 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
858 | + $class = ! empty($class) ? $class : 'espresso-radio-btn-inp'; |
|
859 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
860 | 860 | |
861 | - $label_html = $required_text . "\n\t\t\t" . '<label class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label> '; |
|
861 | + $label_html = $required_text."\n\t\t\t".'<label class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label> '; |
|
862 | 862 | // filter label but ensure required text comes before it |
863 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
863 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
864 | 864 | |
865 | - $input_html = "\n\t\t\t" . '<ul id="' . $id . '-ul" class="espresso-radio-btn-options-ul ' . $label_class . ' ' . $class . '-ul">'; |
|
865 | + $input_html = "\n\t\t\t".'<ul id="'.$id.'-ul" class="espresso-radio-btn-options-ul '.$label_class.' '.$class.'-ul">'; |
|
866 | 866 | |
867 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
868 | - $class .= ! empty( $required['class'] ) ? ' ' . $required['class'] : ''; |
|
867 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
868 | + $class .= ! empty($required['class']) ? ' '.$required['class'] : ''; |
|
869 | 869 | |
870 | - foreach ( $options as $OPT ) { |
|
871 | - if ( $OPT instanceof EE_Question_Option ) { |
|
872 | - $value = self::prep_option_value( $OPT->value() ); |
|
870 | + foreach ($options as $OPT) { |
|
871 | + if ($OPT instanceof EE_Question_Option) { |
|
872 | + $value = self::prep_option_value($OPT->value()); |
|
873 | 873 | $label = $use_desc_4_label ? $OPT->desc() : $OPT->value(); |
874 | - $size = $use_desc_4_label ? self::get_label_size_class( $OPT->value() . ' ' . $OPT->desc() ) : self::get_label_size_class( $OPT->value() ); |
|
875 | - $desc = $OPT->desc();//no self::prep_answer |
|
876 | - $answer = is_numeric( $value ) && empty( $answer ) ? 0 : $answer; |
|
877 | - $checked = (string)$value == (string)$answer ? ' checked="checked"' : ''; |
|
878 | - $opt = '-' . sanitize_key( $value ); |
|
879 | - |
|
880 | - $input_html .= "\n\t\t\t\t" . '<li' . $size . '>'; |
|
881 | - $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-radio-btn-lbl">'; |
|
882 | - $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $label . '</span>' : ''; |
|
883 | - $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 . '/>'; |
|
884 | - $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '<span class="espresso-radio-btn-desc">' . $label . '</span>' : ''; |
|
885 | - $input_html .= "\n\t\t\t\t\t" . '</label>'; |
|
886 | - $input_html .= $use_desc_4_label ? '' : '<span class="espresso-radio-btn-option-desc small-text grey-text">' . $desc . '</span>'; |
|
887 | - $input_html .= "\n\t\t\t\t" . '</li>'; |
|
874 | + $size = $use_desc_4_label ? self::get_label_size_class($OPT->value().' '.$OPT->desc()) : self::get_label_size_class($OPT->value()); |
|
875 | + $desc = $OPT->desc(); //no self::prep_answer |
|
876 | + $answer = is_numeric($value) && empty($answer) ? 0 : $answer; |
|
877 | + $checked = (string) $value == (string) $answer ? ' checked="checked"' : ''; |
|
878 | + $opt = '-'.sanitize_key($value); |
|
879 | + |
|
880 | + $input_html .= "\n\t\t\t\t".'<li'.$size.'>'; |
|
881 | + $input_html .= "\n\t\t\t\t\t".'<label class="'.$radio_class.' espresso-radio-btn-lbl">'; |
|
882 | + $input_html .= $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$label.'</span>' : ''; |
|
883 | + $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.'/>'; |
|
884 | + $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t".'<span class="espresso-radio-btn-desc">'.$label.'</span>' : ''; |
|
885 | + $input_html .= "\n\t\t\t\t\t".'</label>'; |
|
886 | + $input_html .= $use_desc_4_label ? '' : '<span class="espresso-radio-btn-option-desc small-text grey-text">'.$desc.'</span>'; |
|
887 | + $input_html .= "\n\t\t\t\t".'</li>'; |
|
888 | 888 | } |
889 | 889 | } |
890 | 890 | |
891 | - $input_html .= "\n\t\t\t" . '</ul>'; |
|
891 | + $input_html .= "\n\t\t\t".'</ul>'; |
|
892 | 892 | |
893 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
894 | - return $label_html . $input_html; |
|
893 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
894 | + return $label_html.$input_html; |
|
895 | 895 | |
896 | 896 | } |
897 | 897 | |
@@ -914,65 +914,65 @@ discard block |
||
914 | 914 | * @param string $disabled disabled="disabled" or null |
915 | 915 | * @return string HTML |
916 | 916 | */ |
917 | - 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 ) { |
|
917 | + 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) { |
|
918 | 918 | // need these |
919 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
919 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
920 | 920 | return NULL; |
921 | 921 | } |
922 | - $answer = maybe_unserialize( $answer ); |
|
922 | + $answer = maybe_unserialize($answer); |
|
923 | 923 | |
924 | 924 | // prep the answer(s) |
925 | - $answer = is_array( $answer ) ? $answer : array( sanitize_key( $answer ) => $answer ); |
|
925 | + $answer = is_array($answer) ? $answer : array(sanitize_key($answer) => $answer); |
|
926 | 926 | |
927 | - foreach ( $answer as $key => $value ) { |
|
928 | - $key = self::prep_option_value( $key ); |
|
929 | - $answer[$key] = self::prep_answer( $value, $use_html_entities ); |
|
927 | + foreach ($answer as $key => $value) { |
|
928 | + $key = self::prep_option_value($key); |
|
929 | + $answer[$key] = self::prep_answer($value, $use_html_entities); |
|
930 | 930 | } |
931 | 931 | |
932 | 932 | // prep the required array |
933 | - $required = self::prep_required( $required ); |
|
933 | + $required = self::prep_required($required); |
|
934 | 934 | // set disabled tag |
935 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
935 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
936 | 936 | // ya gots ta have style man!!! |
937 | 937 | $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class; |
938 | - $class = empty( $class ) ? 'espresso-radio-btn-inp' : $class; |
|
939 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
938 | + $class = empty($class) ? 'espresso-radio-btn-inp' : $class; |
|
939 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
940 | 940 | |
941 | - $label_html = $required_text . "\n\t\t\t" . '<label class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label> '; |
|
941 | + $label_html = $required_text."\n\t\t\t".'<label class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label> '; |
|
942 | 942 | // filter label but ensure required text comes before it |
943 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
944 | - |
|
945 | - $input_html = "\n\t\t\t" . '<ul id="' . $id . '-ul" class="espresso-checkbox-options-ul ' . $label_class . ' ' . $class . '-ul">'; |
|
946 | - |
|
947 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
948 | - $class .= ! empty( $required['class'] ) ? ' ' . $required['class'] : ''; |
|
949 | - |
|
950 | - foreach ( $options as $OPT ) { |
|
951 | - $value = $OPT->value();//self::prep_option_value( $OPT->value() ); |
|
952 | - $size = self::get_label_size_class( $OPT->value() . ' ' . $OPT->desc() ); |
|
953 | - $text = self::prep_answer( $OPT->value() ); |
|
954 | - $desc = $OPT->desc() ; |
|
955 | - $opt = '-' . sanitize_key( $value ); |
|
956 | - |
|
957 | - $checked = is_array( $answer ) && in_array( $text, $answer ) ? ' checked="checked"' : ''; |
|
958 | - |
|
959 | - $input_html .= "\n\t\t\t\t" . '<li' . $size . '>'; |
|
960 | - $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-checkbox-lbl">'; |
|
961 | - $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : ''; |
|
962 | - $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 . '/>'; |
|
963 | - $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : ''; |
|
964 | - $input_html .= "\n\t\t\t\t\t" . '</label>'; |
|
965 | - if ( ! empty( $desc ) && $desc != $text ) { |
|
966 | - $input_html .= "\n\t\t\t\t\t" . ' <br/><div class="espresso-checkbox-option-desc small-text grey-text">' . $desc . '</div>'; |
|
943 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
944 | + |
|
945 | + $input_html = "\n\t\t\t".'<ul id="'.$id.'-ul" class="espresso-checkbox-options-ul '.$label_class.' '.$class.'-ul">'; |
|
946 | + |
|
947 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
948 | + $class .= ! empty($required['class']) ? ' '.$required['class'] : ''; |
|
949 | + |
|
950 | + foreach ($options as $OPT) { |
|
951 | + $value = $OPT->value(); //self::prep_option_value( $OPT->value() ); |
|
952 | + $size = self::get_label_size_class($OPT->value().' '.$OPT->desc()); |
|
953 | + $text = self::prep_answer($OPT->value()); |
|
954 | + $desc = $OPT->desc(); |
|
955 | + $opt = '-'.sanitize_key($value); |
|
956 | + |
|
957 | + $checked = is_array($answer) && in_array($text, $answer) ? ' checked="checked"' : ''; |
|
958 | + |
|
959 | + $input_html .= "\n\t\t\t\t".'<li'.$size.'>'; |
|
960 | + $input_html .= "\n\t\t\t\t\t".'<label class="'.$radio_class.' espresso-checkbox-lbl">'; |
|
961 | + $input_html .= $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$text.'</span>' : ''; |
|
962 | + $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.'/>'; |
|
963 | + $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$text.'</span>' : ''; |
|
964 | + $input_html .= "\n\t\t\t\t\t".'</label>'; |
|
965 | + if ( ! empty($desc) && $desc != $text) { |
|
966 | + $input_html .= "\n\t\t\t\t\t".' <br/><div class="espresso-checkbox-option-desc small-text grey-text">'.$desc.'</div>'; |
|
967 | 967 | } |
968 | - $input_html .= "\n\t\t\t\t" . '</li>'; |
|
968 | + $input_html .= "\n\t\t\t\t".'</li>'; |
|
969 | 969 | |
970 | 970 | } |
971 | 971 | |
972 | - $input_html .= "\n\t\t\t" . '</ul>'; |
|
972 | + $input_html .= "\n\t\t\t".'</ul>'; |
|
973 | 973 | |
974 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
975 | - return $label_html . $input_html; |
|
974 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
975 | + return $label_html.$input_html; |
|
976 | 976 | |
977 | 977 | } |
978 | 978 | |
@@ -994,36 +994,36 @@ discard block |
||
994 | 994 | * @param string $disabled disabled="disabled" or null |
995 | 995 | * @return string HTML |
996 | 996 | */ |
997 | - 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 ) { |
|
997 | + 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) { |
|
998 | 998 | // need these |
999 | - if ( ! $question || ! $name ) { |
|
999 | + if ( ! $question || ! $name) { |
|
1000 | 1000 | return NULL; |
1001 | 1001 | } |
1002 | 1002 | // prep the answer |
1003 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
1003 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
1004 | 1004 | // prep the required array |
1005 | - $required = self::prep_required( $required ); |
|
1005 | + $required = self::prep_required($required); |
|
1006 | 1006 | // set disabled tag |
1007 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
1007 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
1008 | 1008 | // ya gots ta have style man!!! |
1009 | 1009 | $txt_class = is_admin() ? 'regular-text' : 'espresso-datepicker-inp'; |
1010 | - $class = empty( $class ) ? $txt_class : $class; |
|
1011 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
1012 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
1010 | + $class = empty($class) ? $txt_class : $class; |
|
1011 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
1012 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
1013 | 1013 | |
1014 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
1014 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
1015 | 1015 | // filter label but ensure required text comes before it |
1016 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
1016 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
1017 | 1017 | |
1018 | - $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 . '/>'; |
|
1018 | + $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.'/>'; |
|
1019 | 1019 | |
1020 | 1020 | // enqueue scripts |
1021 | - 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 ); |
|
1022 | - wp_enqueue_style( 'espresso-ui-theme'); |
|
1023 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
1021 | + 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); |
|
1022 | + wp_enqueue_style('espresso-ui-theme'); |
|
1023 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
1024 | 1024 | |
1025 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
1026 | - return $label_html . $input_html; |
|
1025 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
1026 | + return $label_html.$input_html; |
|
1027 | 1027 | |
1028 | 1028 | } |
1029 | 1029 | |
@@ -1035,7 +1035,7 @@ discard block |
||
1035 | 1035 | * @access public |
1036 | 1036 | * @return string |
1037 | 1037 | */ |
1038 | - public static function remove_label_keep_required_msg( $label_html, $required_text ) { |
|
1038 | + public static function remove_label_keep_required_msg($label_html, $required_text) { |
|
1039 | 1039 | return $required_text; |
1040 | 1040 | } |
1041 | 1041 | |
@@ -1049,9 +1049,9 @@ discard block |
||
1049 | 1049 | * @param string $value |
1050 | 1050 | * @return string HTML |
1051 | 1051 | */ |
1052 | - static function hidden_input( $name, $value, $id = '' ){ |
|
1053 | - $id = ! empty( $id ) ? $id : $name; |
|
1054 | - return '<input id="' . $id . '" type="hidden" name="'.$name.'" value="' . $value . '"/>'; |
|
1052 | + static function hidden_input($name, $value, $id = '') { |
|
1053 | + $id = ! empty($id) ? $id : $name; |
|
1054 | + return '<input id="'.$id.'" type="hidden" name="'.$name.'" value="'.$value.'"/>'; |
|
1055 | 1055 | } |
1056 | 1056 | |
1057 | 1057 | |
@@ -1063,7 +1063,7 @@ discard block |
||
1063 | 1063 | * @param string $question |
1064 | 1064 | * @return string |
1065 | 1065 | */ |
1066 | - static function prep_question( $question ){ |
|
1066 | + static function prep_question($question) { |
|
1067 | 1067 | return $question; |
1068 | 1068 | // $link = ''; |
1069 | 1069 | // // does this label have a help link attached ? |
@@ -1086,13 +1086,13 @@ discard block |
||
1086 | 1086 | * @param mixed $answer |
1087 | 1087 | * @return string |
1088 | 1088 | */ |
1089 | - static function prep_answer( $answer, $use_html_entities = TRUE ){ |
|
1089 | + static function prep_answer($answer, $use_html_entities = TRUE) { |
|
1090 | 1090 | //make sure we convert bools first. Otherwise (bool) false becomes an empty string which is NOT desired, we want "0". |
1091 | - if ( is_bool( $answer ) ) { |
|
1091 | + if (is_bool($answer)) { |
|
1092 | 1092 | $answer = $answer ? 1 : 0; |
1093 | 1093 | } |
1094 | - $answer = trim( stripslashes( str_replace( ''', "'", $answer ))); |
|
1095 | - return $use_html_entities ? htmlentities( $answer, ENT_QUOTES, 'UTF-8' ) : $answer; |
|
1094 | + $answer = trim(stripslashes(str_replace(''', "'", $answer))); |
|
1095 | + return $use_html_entities ? htmlentities($answer, ENT_QUOTES, 'UTF-8') : $answer; |
|
1096 | 1096 | } |
1097 | 1097 | |
1098 | 1098 | |
@@ -1102,18 +1102,18 @@ discard block |
||
1102 | 1102 | * @param array $QSOs array of EE_Question_Option objects |
1103 | 1103 | * @return array |
1104 | 1104 | */ |
1105 | - public static function prep_answer_options( $QSOs = array() ){ |
|
1105 | + public static function prep_answer_options($QSOs = array()) { |
|
1106 | 1106 | $prepped_answer_options = array(); |
1107 | - if ( is_array( $QSOs ) && ! empty( $QSOs )) { |
|
1108 | - foreach( $QSOs as $key => $QSO ) { |
|
1109 | - if ( ! $QSO instanceof EE_Question_Option ) { |
|
1110 | - $QSO = EE_Question_Option::new_instance( array( |
|
1111 | - 'QSO_value' => is_array( $QSO ) && isset( $QSO['id'] ) ? (string)$QSO['id'] : (string)$key, |
|
1112 | - 'QSO_desc' => is_array( $QSO ) && isset( $QSO['text'] ) ? (string)$QSO['text'] : (string)$QSO |
|
1107 | + if (is_array($QSOs) && ! empty($QSOs)) { |
|
1108 | + foreach ($QSOs as $key => $QSO) { |
|
1109 | + if ( ! $QSO instanceof EE_Question_Option) { |
|
1110 | + $QSO = EE_Question_Option::new_instance(array( |
|
1111 | + 'QSO_value' => is_array($QSO) && isset($QSO['id']) ? (string) $QSO['id'] : (string) $key, |
|
1112 | + 'QSO_desc' => is_array($QSO) && isset($QSO['text']) ? (string) $QSO['text'] : (string) $QSO |
|
1113 | 1113 | )); |
1114 | 1114 | } |
1115 | - if ( $QSO->opt_group() ) { |
|
1116 | - $prepped_answer_options[ $QSO->opt_group() ][] = $QSO; |
|
1115 | + if ($QSO->opt_group()) { |
|
1116 | + $prepped_answer_options[$QSO->opt_group()][] = $QSO; |
|
1117 | 1117 | } else { |
1118 | 1118 | $prepped_answer_options[] = $QSO; |
1119 | 1119 | } |
@@ -1129,8 +1129,8 @@ discard block |
||
1129 | 1129 | * @param string $option_value |
1130 | 1130 | * @return string |
1131 | 1131 | */ |
1132 | - static function prep_option_value( $option_value ){ |
|
1133 | - return esc_attr( trim( stripslashes( $option_value ) ) ); |
|
1132 | + static function prep_option_value($option_value) { |
|
1133 | + return esc_attr(trim(stripslashes($option_value))); |
|
1134 | 1134 | } |
1135 | 1135 | |
1136 | 1136 | |
@@ -1141,11 +1141,11 @@ discard block |
||
1141 | 1141 | * @param string|array $required |
1142 | 1142 | * @return array |
1143 | 1143 | */ |
1144 | - static function prep_required( $required = array() ){ |
|
1144 | + static function prep_required($required = array()) { |
|
1145 | 1145 | // make sure required is an array |
1146 | - $required = is_array( $required ) ? $required : array(); |
|
1146 | + $required = is_array($required) ? $required : array(); |
|
1147 | 1147 | // and set some defaults |
1148 | - $required = array_merge( array( 'label' => '', 'class' => '', 'msg' => '' ), $required ); |
|
1148 | + $required = array_merge(array('label' => '', 'class' => '', 'msg' => ''), $required); |
|
1149 | 1149 | return $required; |
1150 | 1150 | } |
1151 | 1151 | |
@@ -1156,30 +1156,30 @@ discard block |
||
1156 | 1156 | * @param string $value |
1157 | 1157 | * @return string |
1158 | 1158 | */ |
1159 | - static function get_label_size_class( $value = FALSE ){ |
|
1160 | - if ( $value === FALSE || $value == '' ) { |
|
1159 | + static function get_label_size_class($value = FALSE) { |
|
1160 | + if ($value === FALSE || $value == '') { |
|
1161 | 1161 | return ' class="medium-lbl"'; |
1162 | 1162 | } |
1163 | 1163 | // determine length of option value |
1164 | - $val_size = strlen( $value ); |
|
1165 | - switch( $val_size ){ |
|
1164 | + $val_size = strlen($value); |
|
1165 | + switch ($val_size) { |
|
1166 | 1166 | case $val_size < 3 : |
1167 | - $size = ' class="nano-lbl"'; |
|
1167 | + $size = ' class="nano-lbl"'; |
|
1168 | 1168 | break; |
1169 | 1169 | case $val_size < 6 : |
1170 | - $size = ' class="micro-lbl"'; |
|
1170 | + $size = ' class="micro-lbl"'; |
|
1171 | 1171 | break; |
1172 | 1172 | case $val_size < 12 : |
1173 | - $size = ' class="tiny-lbl"'; |
|
1173 | + $size = ' class="tiny-lbl"'; |
|
1174 | 1174 | break; |
1175 | 1175 | case $val_size < 25 : |
1176 | - $size = ' class="small-lbl"'; |
|
1176 | + $size = ' class="small-lbl"'; |
|
1177 | 1177 | break; |
1178 | 1178 | case $val_size > 100 : |
1179 | - $size = ' class="big-lbl"'; |
|
1179 | + $size = ' class="big-lbl"'; |
|
1180 | 1180 | break; |
1181 | 1181 | default: |
1182 | - $size = ' class="medium-lbl"'; |
|
1182 | + $size = ' class="medium-lbl"'; |
|
1183 | 1183 | break; |
1184 | 1184 | } |
1185 | 1185 | return $size; |
@@ -1193,20 +1193,20 @@ discard block |
||
1193 | 1193 | * @param array $QFI |
1194 | 1194 | * @return array |
1195 | 1195 | */ |
1196 | - private static function _load_system_dropdowns( $QFI ){ |
|
1196 | + private static function _load_system_dropdowns($QFI) { |
|
1197 | 1197 | $QST_system = $QFI->get('QST_system'); |
1198 | - switch ( $QST_system ) { |
|
1198 | + switch ($QST_system) { |
|
1199 | 1199 | case 'state' : |
1200 | - $QFI = self::generate_state_dropdown( $QFI ); |
|
1200 | + $QFI = self::generate_state_dropdown($QFI); |
|
1201 | 1201 | break; |
1202 | 1202 | case 'country' : |
1203 | - $QFI = self::generate_country_dropdown( $QFI ); |
|
1203 | + $QFI = self::generate_country_dropdown($QFI); |
|
1204 | 1204 | break; |
1205 | 1205 | case 'admin-state' : |
1206 | - $QFI = self::generate_state_dropdown( $QFI, TRUE ); |
|
1206 | + $QFI = self::generate_state_dropdown($QFI, TRUE); |
|
1207 | 1207 | break; |
1208 | 1208 | case 'admin-country' : |
1209 | - $QFI = self::generate_country_dropdown( $QFI, TRUE ); |
|
1209 | + $QFI = self::generate_country_dropdown($QFI, TRUE); |
|
1210 | 1210 | break; |
1211 | 1211 | } |
1212 | 1212 | return $QFI; |
@@ -1223,13 +1223,13 @@ discard block |
||
1223 | 1223 | * |
1224 | 1224 | * @return EE_Question_Form_Input |
1225 | 1225 | */ |
1226 | - protected static function _load_specialized_dropdowns( $QFI ) { |
|
1227 | - switch( $QFI->get( 'QST_type' ) ) { |
|
1226 | + protected static function _load_specialized_dropdowns($QFI) { |
|
1227 | + switch ($QFI->get('QST_type')) { |
|
1228 | 1228 | case 'STATE' : |
1229 | - $QFI = self::generate_state_dropdown( $QFI ); |
|
1229 | + $QFI = self::generate_state_dropdown($QFI); |
|
1230 | 1230 | break; |
1231 | 1231 | case 'COUNTRY' : |
1232 | - $QFI = self::generate_country_dropdown( $QFI ); |
|
1232 | + $QFI = self::generate_country_dropdown($QFI); |
|
1233 | 1233 | break; |
1234 | 1234 | } |
1235 | 1235 | return $QFI; |
@@ -1243,23 +1243,23 @@ discard block |
||
1243 | 1243 | * @param bool $get_all |
1244 | 1244 | * @return array |
1245 | 1245 | */ |
1246 | - public static function generate_state_dropdown( $QST, $get_all = FALSE ){ |
|
1246 | + public static function generate_state_dropdown($QST, $get_all = FALSE) { |
|
1247 | 1247 | $states = $get_all ? EEM_State::instance()->get_all_states() : EEM_State::instance()->get_all_states_of_active_countries(); |
1248 | - if ( $states && count( $states ) != count( $QST->options() )) { |
|
1249 | - $QST->set( 'QST_type', 'DROPDOWN' ); |
|
1248 | + if ($states && count($states) != count($QST->options())) { |
|
1249 | + $QST->set('QST_type', 'DROPDOWN'); |
|
1250 | 1250 | // if multiple countries, we'll create option groups within the dropdown |
1251 | - foreach ( $states as $state ) { |
|
1252 | - if ( $state instanceof EE_State ) { |
|
1253 | - $QSO = EE_Question_Option::new_instance ( array ( |
|
1251 | + foreach ($states as $state) { |
|
1252 | + if ($state instanceof EE_State) { |
|
1253 | + $QSO = EE_Question_Option::new_instance(array( |
|
1254 | 1254 | 'QSO_value' => $state->ID(), |
1255 | 1255 | 'QSO_desc' => $state->name(), |
1256 | - 'QST_ID' => $QST->get( 'QST_ID' ), |
|
1256 | + 'QST_ID' => $QST->get('QST_ID'), |
|
1257 | 1257 | 'QSO_deleted' => FALSE |
1258 | 1258 | )); |
1259 | 1259 | // set option group |
1260 | - $QSO->set_opt_group( $state->country()->name() ); |
|
1260 | + $QSO->set_opt_group($state->country()->name()); |
|
1261 | 1261 | // add option to question |
1262 | - $QST->add_temp_option( $QSO ); |
|
1262 | + $QST->add_temp_option($QSO); |
|
1263 | 1263 | } |
1264 | 1264 | } |
1265 | 1265 | } |
@@ -1275,20 +1275,20 @@ discard block |
||
1275 | 1275 | * @internal param array $question |
1276 | 1276 | * @return array |
1277 | 1277 | */ |
1278 | - public static function generate_country_dropdown( $QST, $get_all = FALSE ){ |
|
1278 | + public static function generate_country_dropdown($QST, $get_all = FALSE) { |
|
1279 | 1279 | $countries = $get_all ? EEM_Country::instance()->get_all_countries() : EEM_Country::instance()->get_all_active_countries(); |
1280 | - if ( $countries && count( $countries ) != count( $QST->options() ) ) { |
|
1281 | - $QST->set( 'QST_type', 'DROPDOWN' ); |
|
1280 | + if ($countries && count($countries) != count($QST->options())) { |
|
1281 | + $QST->set('QST_type', 'DROPDOWN'); |
|
1282 | 1282 | // now add countries |
1283 | - foreach ( $countries as $country ) { |
|
1284 | - if ( $country instanceof EE_Country ) { |
|
1285 | - $QSO = EE_Question_Option::new_instance ( array ( |
|
1283 | + foreach ($countries as $country) { |
|
1284 | + if ($country instanceof EE_Country) { |
|
1285 | + $QSO = EE_Question_Option::new_instance(array( |
|
1286 | 1286 | 'QSO_value' => $country->ID(), |
1287 | 1287 | 'QSO_desc' => $country->name(), |
1288 | - 'QST_ID' => $QST->get( 'QST_ID' ), |
|
1288 | + 'QST_ID' => $QST->get('QST_ID'), |
|
1289 | 1289 | 'QSO_deleted' => FALSE |
1290 | 1290 | )); |
1291 | - $QST->add_temp_option( $QSO ); |
|
1291 | + $QST->add_temp_option($QSO); |
|
1292 | 1292 | } |
1293 | 1293 | } |
1294 | 1294 | } |
@@ -1305,11 +1305,11 @@ discard block |
||
1305 | 1305 | */ |
1306 | 1306 | public static function two_digit_months_dropdown_options() { |
1307 | 1307 | $options = array(); |
1308 | - for ( $x = 1; $x <= 12; $x++ ) { |
|
1309 | - $mm = str_pad( $x, 2, '0', STR_PAD_LEFT ); |
|
1310 | - $options[ (string)$mm ] = (string)$mm; |
|
1308 | + for ($x = 1; $x <= 12; $x++) { |
|
1309 | + $mm = str_pad($x, 2, '0', STR_PAD_LEFT); |
|
1310 | + $options[(string) $mm] = (string) $mm; |
|
1311 | 1311 | } |
1312 | - return EEH_Form_Fields::prep_answer_options( $options ); |
|
1312 | + return EEH_Form_Fields::prep_answer_options($options); |
|
1313 | 1313 | } |
1314 | 1314 | |
1315 | 1315 | |
@@ -1324,11 +1324,11 @@ discard block |
||
1324 | 1324 | $options = array(); |
1325 | 1325 | $current_year = date('y'); |
1326 | 1326 | $next_decade = $current_year + 10; |
1327 | - for ( $x = $current_year; $x <= $next_decade; $x++ ) { |
|
1328 | - $yy = str_pad( $x, 2, '0', STR_PAD_LEFT ); |
|
1329 | - $options[ (string)$yy ] = (string)$yy; |
|
1327 | + for ($x = $current_year; $x <= $next_decade; $x++) { |
|
1328 | + $yy = str_pad($x, 2, '0', STR_PAD_LEFT); |
|
1329 | + $options[(string) $yy] = (string) $yy; |
|
1330 | 1330 | } |
1331 | - return EEH_Form_Fields::prep_answer_options( $options ); |
|
1331 | + return EEH_Form_Fields::prep_answer_options($options); |
|
1332 | 1332 | } |
1333 | 1333 | |
1334 | 1334 | |
@@ -1342,17 +1342,17 @@ discard block |
||
1342 | 1342 | * @param integer $evt_category Event Category ID if the Event Category filter is selected |
1343 | 1343 | * @return string html |
1344 | 1344 | */ |
1345 | - public static function generate_registration_months_dropdown( $cur_date = '', $status = '', $evt_category = 0 ) { |
|
1345 | + public static function generate_registration_months_dropdown($cur_date = '', $status = '', $evt_category = 0) { |
|
1346 | 1346 | $_where = array(); |
1347 | - if ( !empty( $status ) ) { |
|
1347 | + if ( ! empty($status)) { |
|
1348 | 1348 | $_where['STS_ID'] = $status; |
1349 | 1349 | } |
1350 | 1350 | |
1351 | - if ( $evt_category > 0 ) { |
|
1351 | + if ($evt_category > 0) { |
|
1352 | 1352 | $_where['Event.Term_Taxonomy.term_id'] = $evt_category; |
1353 | 1353 | } |
1354 | 1354 | |
1355 | - $regdtts = EEM_Registration::instance()->get_reg_months_and_years( $_where ); |
|
1355 | + $regdtts = EEM_Registration::instance()->get_reg_months_and_years($_where); |
|
1356 | 1356 | |
1357 | 1357 | //setup vals for select input helper |
1358 | 1358 | $options = array( |
@@ -1362,15 +1362,15 @@ discard block |
||
1362 | 1362 | ) |
1363 | 1363 | ); |
1364 | 1364 | |
1365 | - foreach ( $regdtts as $regdtt ) { |
|
1366 | - $date = $regdtt->reg_month. ' ' . $regdtt->reg_year; |
|
1365 | + foreach ($regdtts as $regdtt) { |
|
1366 | + $date = $regdtt->reg_month.' '.$regdtt->reg_year; |
|
1367 | 1367 | $options[] = array( |
1368 | 1368 | 'text' => $date, |
1369 | 1369 | 'id' => $date |
1370 | 1370 | ); |
1371 | 1371 | } |
1372 | 1372 | |
1373 | - return self::select_input('month_range', $options, $cur_date, '', 'wide' ); |
|
1373 | + return self::select_input('month_range', $options, $cur_date, '', 'wide'); |
|
1374 | 1374 | } |
1375 | 1375 | |
1376 | 1376 | |
@@ -1384,18 +1384,18 @@ discard block |
||
1384 | 1384 | * @param string $evt_active_status "upcoming", "expired", "active", or "inactive" |
1385 | 1385 | * @return string html |
1386 | 1386 | */ |
1387 | - public static function generate_event_months_dropdown( $cur_date = '', $status = NULL, $evt_category = NULL, $evt_active_status = NULL ) { |
|
1387 | + public static function generate_event_months_dropdown($cur_date = '', $status = NULL, $evt_category = NULL, $evt_active_status = NULL) { |
|
1388 | 1388 | //determine what post_status our condition will have for the query. |
1389 | - switch ( $status ) { |
|
1389 | + switch ($status) { |
|
1390 | 1390 | case 'month' : |
1391 | 1391 | case 'today' : |
1392 | 1392 | case NULL : |
1393 | 1393 | case 'all' : |
1394 | - $where['Event.status'] = array( 'NOT IN', array('trash') ); |
|
1394 | + $where['Event.status'] = array('NOT IN', array('trash')); |
|
1395 | 1395 | break; |
1396 | 1396 | |
1397 | 1397 | case 'draft' : |
1398 | - $where['Event.status'] = array( 'IN', array('draft', 'auto-draft') ); |
|
1398 | + $where['Event.status'] = array('IN', array('draft', 'auto-draft')); |
|
1399 | 1399 | |
1400 | 1400 | default : |
1401 | 1401 | $where['Event.status'] = $status; |
@@ -1404,7 +1404,7 @@ discard block |
||
1404 | 1404 | //categories? |
1405 | 1405 | |
1406 | 1406 | |
1407 | - if ( !empty ( $evt_category ) ) { |
|
1407 | + if ( ! empty ($evt_category)) { |
|
1408 | 1408 | $where['Event.Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
1409 | 1409 | $where['Event.Term_Taxonomy.term_id'] = $evt_category; |
1410 | 1410 | } |
@@ -1412,7 +1412,7 @@ discard block |
||
1412 | 1412 | |
1413 | 1413 | // $where['DTT_is_primary'] = 1; |
1414 | 1414 | |
1415 | - $DTTS = EE_Registry::instance()->load_model('Datetime')->get_dtt_months_and_years($where, $evt_active_status ); |
|
1415 | + $DTTS = EE_Registry::instance()->load_model('Datetime')->get_dtt_months_and_years($where, $evt_active_status); |
|
1416 | 1416 | |
1417 | 1417 | //let's setup vals for select input helper |
1418 | 1418 | $options = array( |
@@ -1425,9 +1425,9 @@ discard block |
||
1425 | 1425 | //translate month and date |
1426 | 1426 | global $wp_locale; |
1427 | 1427 | |
1428 | - foreach ( $DTTS as $DTT ) { |
|
1429 | - $localized_date = $wp_locale->get_month( date('m', strtotime($DTT->dtt_month)) ) . ' ' . $DTT->dtt_year; |
|
1430 | - $id = $DTT->dtt_month . ' ' . $DTT->dtt_year; |
|
1428 | + foreach ($DTTS as $DTT) { |
|
1429 | + $localized_date = $wp_locale->get_month(date('m', strtotime($DTT->dtt_month))).' '.$DTT->dtt_year; |
|
1430 | + $id = $DTT->dtt_month.' '.$DTT->dtt_year; |
|
1431 | 1431 | $options[] = array( |
1432 | 1432 | 'text' => $localized_date, |
1433 | 1433 | 'id' => $id |
@@ -1435,7 +1435,7 @@ discard block |
||
1435 | 1435 | } |
1436 | 1436 | |
1437 | 1437 | |
1438 | - return self::select_input( 'month_range', $options, $cur_date, '', 'wide' ); |
|
1438 | + return self::select_input('month_range', $options, $cur_date, '', 'wide'); |
|
1439 | 1439 | } |
1440 | 1440 | |
1441 | 1441 | |
@@ -1446,7 +1446,7 @@ discard block |
||
1446 | 1446 | * @param integer $current_cat currently selected category |
1447 | 1447 | * @return string html for dropdown |
1448 | 1448 | */ |
1449 | - public static function generate_event_category_dropdown( $current_cat = -1 ) { |
|
1449 | + public static function generate_event_category_dropdown($current_cat = -1) { |
|
1450 | 1450 | $categories = EEM_Term::instance()->get_all_ee_categories(TRUE); |
1451 | 1451 | $options = array( |
1452 | 1452 | '0' => array( |
@@ -1456,14 +1456,14 @@ discard block |
||
1456 | 1456 | ); |
1457 | 1457 | |
1458 | 1458 | //setup categories for dropdown |
1459 | - foreach ( $categories as $category ) { |
|
1459 | + foreach ($categories as $category) { |
|
1460 | 1460 | $options[] = array( |
1461 | 1461 | 'text' => $category->get('name'), |
1462 | 1462 | 'id' => $category->ID() |
1463 | 1463 | ); |
1464 | 1464 | } |
1465 | 1465 | |
1466 | - return self::select_input( 'EVT_CAT', $options, $current_cat ); |
|
1466 | + return self::select_input('EVT_CAT', $options, $current_cat); |
|
1467 | 1467 | } |
1468 | 1468 | |
1469 | 1469 | |
@@ -1482,20 +1482,20 @@ discard block |
||
1482 | 1482 | * @param string $extra_attributes - any extra attributes that need to be attached to the form input |
1483 | 1483 | * @return void |
1484 | 1484 | */ |
1485 | - public static function submit_button( $url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '' ) { |
|
1485 | + public static function submit_button($url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '') { |
|
1486 | 1486 | $btn = ''; |
1487 | - if ( empty( $url ) || empty( $ID )) { |
|
1487 | + if (empty($url) || empty($ID)) { |
|
1488 | 1488 | return $btn; |
1489 | 1489 | } |
1490 | - $text = ! empty( $text ) ? $text : __('Submit', 'event_espresso' ); |
|
1491 | - $btn .= '<input id="' . $ID . '-btn" class="' . $class . '" type="submit" value="' . $text . '" ' . $extra_attributes . '/>'; |
|
1492 | - if ( ! $input_only ) { |
|
1493 | - $btn_frm = '<form id="' . $ID . '-frm" method="POST" action="' . $url . '">'; |
|
1494 | - $btn_frm .= ! empty( $nonce_action ) ? wp_nonce_field( $nonce_action, $nonce_action . '_nonce', TRUE, FALSE ) : ''; |
|
1490 | + $text = ! empty($text) ? $text : __('Submit', 'event_espresso'); |
|
1491 | + $btn .= '<input id="'.$ID.'-btn" class="'.$class.'" type="submit" value="'.$text.'" '.$extra_attributes.'/>'; |
|
1492 | + if ( ! $input_only) { |
|
1493 | + $btn_frm = '<form id="'.$ID.'-frm" method="POST" action="'.$url.'">'; |
|
1494 | + $btn_frm .= ! empty($nonce_action) ? wp_nonce_field($nonce_action, $nonce_action.'_nonce', TRUE, FALSE) : ''; |
|
1495 | 1495 | $btn_frm .= $btn; |
1496 | 1496 | $btn_frm .= '</form>'; |
1497 | 1497 | $btn = $btn_frm; |
1498 | - unset ( $btn_frm ); |
|
1498 | + unset ($btn_frm); |
|
1499 | 1499 | } |
1500 | 1500 | return $btn; |
1501 | 1501 | } |
@@ -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,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | -require_once( EE_MODELS . 'EEM_CPT_Base.model.php'); |
|
2 | +require_once(EE_MODELS.'EEM_CPT_Base.model.php'); |
|
3 | 3 | /** |
4 | 4 | * |
5 | 5 | * EEM_Event Model |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @author Michael Nelson, Brent Christensen |
12 | 12 | * |
13 | 13 | */ |
14 | -class EEM_Event extends EEM_CPT_Base{ |
|
14 | +class EEM_Event extends EEM_CPT_Base { |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * constant used by status(), indicating that no more tickets can be purchased for any of the datetimes for the event |
@@ -51,15 +51,15 @@ discard block |
||
51 | 51 | * @param string $timezone |
52 | 52 | * @return EEM_Event |
53 | 53 | */ |
54 | - public static function instance( $timezone = NULL ){ |
|
54 | + public static function instance($timezone = NULL) { |
|
55 | 55 | |
56 | 56 | // check if instance of EEM_Event already exists |
57 | - if ( ! self::$_instance instanceof EEM_Event ) { |
|
57 | + if ( ! self::$_instance instanceof EEM_Event) { |
|
58 | 58 | // instantiate Espresso_model |
59 | - self::$_instance = new self( $timezone ); |
|
59 | + self::$_instance = new self($timezone); |
|
60 | 60 | } |
61 | 61 | //we might have a timezone set, let set_timezone decide what to do with it |
62 | - self::$_instance->set_timezone( $timezone ); |
|
62 | + self::$_instance->set_timezone($timezone); |
|
63 | 63 | // EEM_Event object |
64 | 64 | return self::$_instance; |
65 | 65 | } |
@@ -70,12 +70,12 @@ discard block |
||
70 | 70 | * @param string $timezone |
71 | 71 | * @return EEM_Event |
72 | 72 | */ |
73 | - protected function __construct($timezone = null){ |
|
73 | + protected function __construct($timezone = null) { |
|
74 | 74 | |
75 | - EE_Registry::instance()->load_model( 'Registration' ); |
|
75 | + EE_Registry::instance()->load_model('Registration'); |
|
76 | 76 | |
77 | - $this->singular_item = __('Event','event_espresso'); |
|
78 | - $this->plural_item = __('Events','event_espresso'); |
|
77 | + $this->singular_item = __('Event', 'event_espresso'); |
|
78 | + $this->plural_item = __('Events', 'event_espresso'); |
|
79 | 79 | |
80 | 80 | // to remove Cancelled events from the frontend, copy the following filter to your functions.php file |
81 | 81 | // add_filter( 'AFEE__EEM_Event__construct___custom_stati__cancelled__Public', '__return_false' ); |
@@ -89,57 +89,57 @@ discard block |
||
89 | 89 | array( |
90 | 90 | EEM_Event::cancelled => array( |
91 | 91 | 'label' => __('Cancelled', 'event_espresso'), |
92 | - 'public' => apply_filters( 'AFEE__EEM_Event__construct___custom_stati__cancelled__Public', TRUE ) |
|
92 | + 'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__cancelled__Public', TRUE) |
|
93 | 93 | ), |
94 | 94 | EEM_Event::postponed => array( |
95 | 95 | 'label' => __('Postponed', 'event_espresso'), |
96 | - 'public' => apply_filters( 'AFEE__EEM_Event__construct___custom_stati__postponed__Public', TRUE ) |
|
96 | + 'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__postponed__Public', TRUE) |
|
97 | 97 | ), |
98 | 98 | EEM_Event::sold_out => array( |
99 | 99 | 'label' => __('Sold Out', 'event_espresso'), |
100 | - 'public' => apply_filters( 'AFEE__EEM_Event__construct___custom_stati__sold_out__Public', TRUE ) |
|
100 | + 'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__sold_out__Public', TRUE) |
|
101 | 101 | ) |
102 | 102 | ) |
103 | 103 | ); |
104 | 104 | |
105 | - self::$_default_reg_status = empty( self::$_default_reg_status ) ? EEM_Registration::status_id_pending_payment : self::$_default_reg_status; |
|
105 | + self::$_default_reg_status = empty(self::$_default_reg_status) ? EEM_Registration::status_id_pending_payment : self::$_default_reg_status; |
|
106 | 106 | |
107 | 107 | $this->_tables = array( |
108 | - 'Event_CPT'=>new EE_Primary_Table( 'posts','ID' ), |
|
109 | - 'Event_Meta'=> new EE_Secondary_Table( 'esp_event_meta', 'EVTM_ID', 'EVT_ID' ) |
|
108 | + 'Event_CPT'=>new EE_Primary_Table('posts', 'ID'), |
|
109 | + 'Event_Meta'=> new EE_Secondary_Table('esp_event_meta', 'EVTM_ID', 'EVT_ID') |
|
110 | 110 | ); |
111 | 111 | |
112 | 112 | $this->_fields = array( |
113 | 113 | 'Event_CPT'=>array( |
114 | - 'EVT_ID'=>new EE_Primary_Key_Int_Field( 'ID', __( 'Post ID for Event','event_espresso' )), |
|
115 | - 'EVT_name'=>new EE_Plain_Text_Field( 'post_title', __( 'Event Name','event_espresso' ), FALSE, '' ), |
|
116 | - 'EVT_desc'=>new EE_Post_Content_Field( 'post_content', __( 'Event Description', 'event_espresso' ), FALSE, '' ), |
|
117 | - 'EVT_slug'=>new EE_Slug_Field( 'post_name', __( 'Event Slug', 'event_espresso' ), FALSE, '' ), |
|
118 | - 'EVT_created'=>new EE_Datetime_Field( 'post_date', __( 'Date/Time Event Created', 'event_espresso' ), FALSE, time()), |
|
119 | - 'EVT_short_desc'=>new EE_Simple_HTML_Field( 'post_excerpt', __( 'Event Short Description', 'event_espresso' ), FALSE,'' ), |
|
120 | - 'EVT_modified'=>new EE_Datetime_Field( 'post_modified', __( 'Date/Time Event Modified', 'event_espresso' ), FALSE, time()), |
|
121 | - 'EVT_wp_user'=>new EE_WP_User_Field( 'post_author', __( 'Event Creator ID', 'event_espresso'), FALSE), |
|
122 | - 'parent'=>new EE_Integer_Field( 'post_parent', __( 'Event Parent ID', 'event_espresso' ), FALSE, 0 ), |
|
123 | - 'EVT_order'=>new EE_Integer_Field( 'menu_order', __( 'Event Menu Order', 'event_espresso' ), FALSE, 1 ), |
|
124 | - 'post_type'=>new EE_WP_Post_Type_Field('espresso_events'),// EE_Plain_Text_Field( 'post_type', __( 'Event Post Type', 'event_espresso' ), FALSE, 'espresso_events' ), |
|
125 | - 'status' => new EE_WP_Post_Status_Field( 'post_status', __( 'Event Status', 'event_espresso' ), FALSE, 'draft', $this->_custom_stati ) |
|
114 | + 'EVT_ID'=>new EE_Primary_Key_Int_Field('ID', __('Post ID for Event', 'event_espresso')), |
|
115 | + 'EVT_name'=>new EE_Plain_Text_Field('post_title', __('Event Name', 'event_espresso'), FALSE, ''), |
|
116 | + 'EVT_desc'=>new EE_Post_Content_Field('post_content', __('Event Description', 'event_espresso'), FALSE, ''), |
|
117 | + 'EVT_slug'=>new EE_Slug_Field('post_name', __('Event Slug', 'event_espresso'), FALSE, ''), |
|
118 | + 'EVT_created'=>new EE_Datetime_Field('post_date', __('Date/Time Event Created', 'event_espresso'), FALSE, time()), |
|
119 | + 'EVT_short_desc'=>new EE_Simple_HTML_Field('post_excerpt', __('Event Short Description', 'event_espresso'), FALSE, ''), |
|
120 | + 'EVT_modified'=>new EE_Datetime_Field('post_modified', __('Date/Time Event Modified', 'event_espresso'), FALSE, time()), |
|
121 | + 'EVT_wp_user'=>new EE_WP_User_Field('post_author', __('Event Creator ID', 'event_espresso'), FALSE), |
|
122 | + 'parent'=>new EE_Integer_Field('post_parent', __('Event Parent ID', 'event_espresso'), FALSE, 0), |
|
123 | + 'EVT_order'=>new EE_Integer_Field('menu_order', __('Event Menu Order', 'event_espresso'), FALSE, 1), |
|
124 | + 'post_type'=>new EE_WP_Post_Type_Field('espresso_events'), // EE_Plain_Text_Field( 'post_type', __( 'Event Post Type', 'event_espresso' ), FALSE, 'espresso_events' ), |
|
125 | + 'status' => new EE_WP_Post_Status_Field('post_status', __('Event Status', 'event_espresso'), FALSE, 'draft', $this->_custom_stati) |
|
126 | 126 | ), |
127 | 127 | 'Event_Meta'=>array( |
128 | - 'EVTM_ID'=> new EE_DB_Only_Float_Field( 'EVTM_ID', __( 'Event Meta Row ID','event_espresso' ), FALSE ), |
|
129 | - 'EVT_ID_fk'=>new EE_DB_Only_Int_Field( 'EVT_ID', __( 'Foreign key to Event ID from Event Meta table', 'event_espresso' ), FALSE ), |
|
130 | - 'EVT_display_desc'=>new EE_Boolean_Field( 'EVT_display_desc', __( 'Display Description Flag', 'event_espresso' ), FALSE, 1 ), |
|
131 | - 'EVT_display_ticket_selector'=>new EE_Boolean_Field( 'EVT_display_ticket_selector', __( 'Display Ticket Selector Flag', 'event_espresso' ), FALSE, 1 ), |
|
132 | - 'EVT_visible_on'=>new EE_Datetime_Field( 'EVT_visible_on', __( 'Event Visible Date', 'event_espresso' ), TRUE, time()), |
|
133 | - 'EVT_additional_limit'=>new EE_Integer_Field( 'EVT_additional_limit', __( 'Limit of Additional Registrations on Same Transaction', 'event_espresso' ), TRUE, 10 ), |
|
128 | + 'EVTM_ID'=> new EE_DB_Only_Float_Field('EVTM_ID', __('Event Meta Row ID', 'event_espresso'), FALSE), |
|
129 | + 'EVT_ID_fk'=>new EE_DB_Only_Int_Field('EVT_ID', __('Foreign key to Event ID from Event Meta table', 'event_espresso'), FALSE), |
|
130 | + 'EVT_display_desc'=>new EE_Boolean_Field('EVT_display_desc', __('Display Description Flag', 'event_espresso'), FALSE, 1), |
|
131 | + 'EVT_display_ticket_selector'=>new EE_Boolean_Field('EVT_display_ticket_selector', __('Display Ticket Selector Flag', 'event_espresso'), FALSE, 1), |
|
132 | + 'EVT_visible_on'=>new EE_Datetime_Field('EVT_visible_on', __('Event Visible Date', 'event_espresso'), TRUE, time()), |
|
133 | + 'EVT_additional_limit'=>new EE_Integer_Field('EVT_additional_limit', __('Limit of Additional Registrations on Same Transaction', 'event_espresso'), TRUE, 10), |
|
134 | 134 | 'EVT_default_registration_status'=>new EE_Enum_Text_Field( |
135 | - 'EVT_default_registration_status', __( 'Default Registration Status on this Event', 'event_espresso' ), FALSE, EEM_Event::$_default_reg_status, EEM_Registration::reg_status_array() |
|
135 | + 'EVT_default_registration_status', __('Default Registration Status on this Event', 'event_espresso'), FALSE, EEM_Event::$_default_reg_status, EEM_Registration::reg_status_array() |
|
136 | 136 | ), |
137 | - 'EVT_member_only'=>new EE_Boolean_Field( 'EVT_member_only', __( 'Member-Only Event Flag', 'event_espresso' ), FALSE, FALSE ), |
|
138 | - 'EVT_phone'=> new EE_Plain_Text_Field('EVT_phone', __( 'Event Phone Number', 'event_espresso' ), FALSE ), |
|
139 | - 'EVT_allow_overflow'=>new EE_Boolean_Field( 'EVT_allow_overflow', __( 'Allow Overflow on Event', 'event_espresso' ), FALSE, FALSE ), |
|
140 | - 'EVT_timezone_string'=>new EE_Plain_Text_Field( 'EVT_timezone_string', __( 'Timezone (name) for Event times', 'event_espresso' ), FALSE ), |
|
141 | - 'EVT_external_URL'=>new EE_Plain_Text_Field( 'EVT_external_URL', __( 'URL of Event Page if hosted elsewhere', 'event_espresso' ), TRUE ), |
|
142 | - 'EVT_donations'=>new EE_Boolean_Field( 'EVT_donations', __( 'Accept Donations?', 'event_espresso' ), FALSE, FALSE ) |
|
137 | + 'EVT_member_only'=>new EE_Boolean_Field('EVT_member_only', __('Member-Only Event Flag', 'event_espresso'), FALSE, FALSE), |
|
138 | + 'EVT_phone'=> new EE_Plain_Text_Field('EVT_phone', __('Event Phone Number', 'event_espresso'), FALSE), |
|
139 | + 'EVT_allow_overflow'=>new EE_Boolean_Field('EVT_allow_overflow', __('Allow Overflow on Event', 'event_espresso'), FALSE, FALSE), |
|
140 | + 'EVT_timezone_string'=>new EE_Plain_Text_Field('EVT_timezone_string', __('Timezone (name) for Event times', 'event_espresso'), FALSE), |
|
141 | + 'EVT_external_URL'=>new EE_Plain_Text_Field('EVT_external_URL', __('URL of Event Page if hosted elsewhere', 'event_espresso'), TRUE), |
|
142 | + 'EVT_donations'=>new EE_Boolean_Field('EVT_donations', __('Accept Donations?', 'event_espresso'), FALSE, FALSE) |
|
143 | 143 | |
144 | 144 | )); |
145 | 145 | |
@@ -154,8 +154,8 @@ discard block |
||
154 | 154 | 'WP_User' => new EE_Belongs_To_Relation(), |
155 | 155 | ); |
156 | 156 | //this model is generally available for reading |
157 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
158 | - parent::__construct( $timezone ); |
|
157 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
158 | + parent::__construct($timezone); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | |
@@ -163,14 +163,14 @@ discard block |
||
163 | 163 | /** |
164 | 164 | * @param string $default_reg_status |
165 | 165 | */ |
166 | - public static function set_default_reg_status( $default_reg_status ) { |
|
166 | + public static function set_default_reg_status($default_reg_status) { |
|
167 | 167 | self::$_default_reg_status = $default_reg_status; |
168 | 168 | //if EEM_Event has already been instantiated, then we need to reset the `EVT_default_reg_status` field to use the new default. |
169 | - if ( self::$_instance instanceof EEM_Event ) { |
|
169 | + if (self::$_instance instanceof EEM_Event) { |
|
170 | 170 | self::$_instance->_fields['Event_Meta']['EVT_default_registration_status'] = new EE_Enum_Text_Field( |
171 | - 'EVT_default_registration_status', __( 'Default Registration Status on this Event', 'event_espresso' ), false, $default_reg_status, EEM_Registration::reg_status_array() |
|
171 | + 'EVT_default_registration_status', __('Default Registration Status on this Event', 'event_espresso'), false, $default_reg_status, EEM_Registration::reg_status_array() |
|
172 | 172 | ); |
173 | - self::$_instance->_fields['Event_Meta']['EVT_default_registration_status']->_construct_finalize( 'Event_Meta', 'EVT_default_registration_status', 'EEM_Event' ); |
|
173 | + self::$_instance->_fields['Event_Meta']['EVT_default_registration_status']->_construct_finalize('Event_Meta', 'EVT_default_registration_status', 'EEM_Event'); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
@@ -183,9 +183,9 @@ discard block |
||
183 | 183 | * @return array |
184 | 184 | */ |
185 | 185 | public function get_all_question_groups() { |
186 | - return EE_Registry::instance()->load_model( 'Question_Group' )->get_all( array( |
|
187 | - array( 'QSG_deleted' => FALSE ), |
|
188 | - 'order_by' => array( 'QSG_order' => 'ASC' ) |
|
186 | + return EE_Registry::instance()->load_model('Question_Group')->get_all(array( |
|
187 | + array('QSG_deleted' => FALSE), |
|
188 | + 'order_by' => array('QSG_order' => 'ASC') |
|
189 | 189 | )); |
190 | 190 | } |
191 | 191 | |
@@ -201,13 +201,13 @@ discard block |
||
201 | 201 | * @param int $EVT_ID |
202 | 202 | * @return array |
203 | 203 | */ |
204 | - public function get_all_event_question_groups( $EVT_ID = 0 ) { |
|
205 | - if ( ! isset( $EVT_ID) || ! absint( $EVT_ID )) { |
|
206 | - EE_Error::add_error( __( 'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
204 | + public function get_all_event_question_groups($EVT_ID = 0) { |
|
205 | + if ( ! isset($EVT_ID) || ! absint($EVT_ID)) { |
|
206 | + EE_Error::add_error(__('An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
207 | 207 | return FALSE; |
208 | 208 | } |
209 | - return EE_Registry::instance()->load_model( 'Event_Question_Group' )->get_all( array( |
|
210 | - array( 'EVT_ID' => $EVT_ID ) |
|
209 | + return EE_Registry::instance()->load_model('Event_Question_Group')->get_all(array( |
|
210 | + array('EVT_ID' => $EVT_ID) |
|
211 | 211 | )); |
212 | 212 | } |
213 | 213 | |
@@ -223,13 +223,13 @@ discard block |
||
223 | 223 | * @param boolean $for_primary_attendee |
224 | 224 | * @return array |
225 | 225 | */ |
226 | - public function get_event_question_groups( $EVT_ID = 0, $for_primary_attendee = TRUE ) { |
|
227 | - if ( ! isset( $EVT_ID) || ! absint( $EVT_ID )) { |
|
228 | - EE_Error::add_error( __( 'An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
226 | + public function get_event_question_groups($EVT_ID = 0, $for_primary_attendee = TRUE) { |
|
227 | + if ( ! isset($EVT_ID) || ! absint($EVT_ID)) { |
|
228 | + EE_Error::add_error(__('An error occurred. No Event Question Groups could be retrieved because an Event ID was not received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
229 | 229 | return FALSE; |
230 | 230 | } |
231 | - return EE_Registry::instance()->load_model( 'Event_Question_Group' )->get_all( array( |
|
232 | - array( 'EVT_ID' => $EVT_ID, 'EQG_primary' => $for_primary_attendee ) |
|
231 | + return EE_Registry::instance()->load_model('Event_Question_Group')->get_all(array( |
|
232 | + array('EVT_ID' => $EVT_ID, 'EQG_primary' => $for_primary_attendee) |
|
233 | 233 | )); |
234 | 234 | } |
235 | 235 | |
@@ -246,10 +246,10 @@ discard block |
||
246 | 246 | * @param EE_Registration $registration |
247 | 247 | * @return array |
248 | 248 | */ |
249 | - public function get_question_groups_for_event( $EVT_ID = 0, EE_Registration $registration ) { |
|
249 | + public function get_question_groups_for_event($EVT_ID = 0, EE_Registration $registration) { |
|
250 | 250 | |
251 | - if ( ! isset( $EVT_ID) || ! absint( $EVT_ID )) { |
|
252 | - EE_Error::add_error( __( 'An error occurred. No Question Groups could be retrieved because an Event ID was not received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
251 | + if ( ! isset($EVT_ID) || ! absint($EVT_ID)) { |
|
252 | + EE_Error::add_error(__('An error occurred. No Question Groups could be retrieved because an Event ID was not received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
253 | 253 | return FALSE; |
254 | 254 | } |
255 | 255 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | 'QSG_deleted' => FALSE |
260 | 260 | ); |
261 | 261 | |
262 | - return EE_Registry::instance()->load_model( 'Question_Group' )->get_all( array( |
|
262 | + return EE_Registry::instance()->load_model('Question_Group')->get_all(array( |
|
263 | 263 | $where_params, |
264 | 264 | 'order_by' => array('QSG_order' => 'ASC') |
265 | 265 | )); |
@@ -279,16 +279,16 @@ discard block |
||
279 | 279 | * @param string $QSG_IDs csv list of $QSG IDs |
280 | 280 | * @return array |
281 | 281 | */ |
282 | - public function get_questions_in_groups( $QSG_IDs = '' ) { |
|
282 | + public function get_questions_in_groups($QSG_IDs = '') { |
|
283 | 283 | |
284 | - if ( empty( $QSG_IDs )) { |
|
285 | - EE_Error::add_error( __( 'An error occurred. No Question Group IDs were received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
284 | + if (empty($QSG_IDs)) { |
|
285 | + EE_Error::add_error(__('An error occurred. No Question Group IDs were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
286 | 286 | return FALSE; |
287 | 287 | } |
288 | 288 | |
289 | - return EE_Registry::instance()->load_model( 'Question' )->get_all( array( |
|
289 | + return EE_Registry::instance()->load_model('Question')->get_all(array( |
|
290 | 290 | array( |
291 | - 'Question_Group.QSG_ID' => array( 'IN', $QSG_IDs ), |
|
291 | + 'Question_Group.QSG_ID' => array('IN', $QSG_IDs), |
|
292 | 292 | 'QST_deleted' => FALSE, |
293 | 293 | 'QST_admin_only' => is_admin() |
294 | 294 | ), |
@@ -310,16 +310,16 @@ discard block |
||
310 | 310 | * @param string $QST_IDs csv list of $QST IDs |
311 | 311 | * @return array |
312 | 312 | */ |
313 | - public function get_options_for_question( $QST_IDs ) { |
|
313 | + public function get_options_for_question($QST_IDs) { |
|
314 | 314 | |
315 | - if ( empty( $QST_IDs )) { |
|
316 | - EE_Error::add_error( __( 'An error occurred. No Question IDs were received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
315 | + if (empty($QST_IDs)) { |
|
316 | + EE_Error::add_error(__('An error occurred. No Question IDs were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
317 | 317 | return FALSE; |
318 | 318 | } |
319 | 319 | |
320 | - return EE_Registry::instance()->load_model( 'Question_Option' )->get_all( array( |
|
320 | + return EE_Registry::instance()->load_model('Question_Option')->get_all(array( |
|
321 | 321 | array( |
322 | - 'Question.QST_ID' => array( 'IN', $QST_IDs ), |
|
322 | + 'Question.QST_ID' => array('IN', $QST_IDs), |
|
323 | 323 | 'QSO_deleted' => FALSE |
324 | 324 | ), |
325 | 325 | 'order_by' => 'QSO_ID' |
@@ -338,46 +338,46 @@ discard block |
||
338 | 338 | * @throws EE_Error |
339 | 339 | * @return array |
340 | 340 | */ |
341 | - public function assemble_array_of_groups_questions_and_options( EE_Registration $registration, $EVT_ID = 0 ) { |
|
341 | + public function assemble_array_of_groups_questions_and_options(EE_Registration $registration, $EVT_ID = 0) { |
|
342 | 342 | |
343 | - if ( empty( $EVT_ID ) ) { |
|
344 | - throw new EE_Error( __( 'An error occurred. No EVT_ID is included. Needed to know which question groups to retrieve.', 'event_espresso' ) ); |
|
343 | + if (empty($EVT_ID)) { |
|
344 | + throw new EE_Error(__('An error occurred. No EVT_ID is included. Needed to know which question groups to retrieve.', 'event_espresso')); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | $questions = array(); |
348 | 348 | |
349 | 349 | // get all question groups for event |
350 | - $qgs = $this->get_question_groups_for_event( $EVT_ID, $registration ); |
|
351 | - if ( !empty( $qgs ) ) { |
|
352 | - foreach ( $qgs as $qg ) { |
|
350 | + $qgs = $this->get_question_groups_for_event($EVT_ID, $registration); |
|
351 | + if ( ! empty($qgs)) { |
|
352 | + foreach ($qgs as $qg) { |
|
353 | 353 | $qsts = $qg->questions(); |
354 | - $questions[ $qg->ID() ] = $qg->model_field_array(); |
|
355 | - $questions[ $qg->ID() ]['QSG_questions'] = array(); |
|
356 | - foreach ( $qsts as $qst ) { |
|
357 | - if ( $qst->is_system_question() ) |
|
354 | + $questions[$qg->ID()] = $qg->model_field_array(); |
|
355 | + $questions[$qg->ID()]['QSG_questions'] = array(); |
|
356 | + foreach ($qsts as $qst) { |
|
357 | + if ($qst->is_system_question()) |
|
358 | 358 | continue; |
359 | - $answer = EEM_Answer::instance()->get_one( array( array( 'QST_ID' => $qst->ID(), 'REG_ID' => $registration->ID() ) ) ); |
|
359 | + $answer = EEM_Answer::instance()->get_one(array(array('QST_ID' => $qst->ID(), 'REG_ID' => $registration->ID()))); |
|
360 | 360 | $answer = $answer instanceof EE_Answer ? $answer : EEM_Answer::instance()->create_default_object(); |
361 | 361 | $qst_name = $qstn_id = $qst->ID(); |
362 | 362 | $ans_id = $answer->ID(); |
363 | - $qst_name = !empty( $ans_id ) ? '[' . $qst_name . '][' . $ans_id . ']' : '[' . $qst_name . ']'; |
|
363 | + $qst_name = ! empty($ans_id) ? '['.$qst_name.']['.$ans_id.']' : '['.$qst_name.']'; |
|
364 | 364 | $input_name = ''; |
365 | - $input_id = sanitize_key( $qst->display_text() ); |
|
365 | + $input_id = sanitize_key($qst->display_text()); |
|
366 | 366 | $input_class = ''; |
367 | 367 | $questions[$qg->ID()]['QSG_questions'][$qst->ID()] = $qst->model_field_array(); |
368 | - $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_name'] = 'qstn' . $input_name . $qst_name; |
|
369 | - $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_id'] = $input_id . '-' . $qstn_id; |
|
370 | - $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_class'] = $input_class; |
|
371 | - $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_options'] = array(); |
|
372 | - $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['qst_obj'] = $qst; |
|
373 | - $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['ans_obj'] = $answer; |
|
368 | + $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_name'] = 'qstn'.$input_name.$qst_name; |
|
369 | + $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_id'] = $input_id.'-'.$qstn_id; |
|
370 | + $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_class'] = $input_class; |
|
371 | + $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'] = array(); |
|
372 | + $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['qst_obj'] = $qst; |
|
373 | + $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['ans_obj'] = $answer; |
|
374 | 374 | //leave responses as-is, don't convert stuff into html entities please! |
375 | - $questions[ $qg->ID() ][ 'QSG_questions'][ $qst->ID() ][ 'htmlentities' ] = false; |
|
376 | - if ( $qst->type() == 'RADIO_BTN' || $qst->type() == 'CHECKBOX' || $qst->type() == 'DROPDOWN' ) { |
|
377 | - $QSOs = $qst->options(TRUE,$answer->value()); |
|
378 | - if ( is_array( $QSOs ) ) { |
|
379 | - foreach ( $QSOs as $QSO_ID => $QSO ) { |
|
380 | - $questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_options'][ $QSO_ID ] = $QSO->model_field_array(); |
|
375 | + $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['htmlentities'] = false; |
|
376 | + if ($qst->type() == 'RADIO_BTN' || $qst->type() == 'CHECKBOX' || $qst->type() == 'DROPDOWN') { |
|
377 | + $QSOs = $qst->options(TRUE, $answer->value()); |
|
378 | + if (is_array($QSOs)) { |
|
379 | + foreach ($QSOs as $QSO_ID => $QSO) { |
|
380 | + $questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'][$QSO_ID] = $QSO->model_field_array(); |
|
381 | 381 | } |
382 | 382 | } |
383 | 383 | } |
@@ -401,9 +401,9 @@ discard block |
||
401 | 401 | * @param $QST |
402 | 402 | * @return string string |
403 | 403 | */ |
404 | - private function _generate_question_input_name( $QST ) { |
|
404 | + private function _generate_question_input_name($QST) { |
|
405 | 405 | |
406 | - if ( $QST->QST_system ) { |
|
406 | + if ($QST->QST_system) { |
|
407 | 407 | $qst_name = $QST->QST_system; |
408 | 408 | /* switch( $QST->QST_system ) { |
409 | 409 | |
@@ -470,36 +470,36 @@ discard block |
||
470 | 470 | * @param bool $count whether to return the count or not (default FALSE) |
471 | 471 | * @return array EE_Event objects |
472 | 472 | */ |
473 | - public function get_active_events( $query_params, $count = FALSE ) { |
|
474 | - if ( array_key_exists( 0, $query_params ) ) { |
|
473 | + public function get_active_events($query_params, $count = FALSE) { |
|
474 | + if (array_key_exists(0, $query_params)) { |
|
475 | 475 | $where_params = $query_params[0]; |
476 | - unset( $query_params[0] ); |
|
476 | + unset($query_params[0]); |
|
477 | 477 | } else { |
478 | 478 | $where_params = array(); |
479 | 479 | } |
480 | 480 | |
481 | 481 | //if we have count make sure we don't include group by |
482 | - if ( $count && isset( $query_params['group_by'] ) ) { |
|
483 | - unset( $query_params['group_by'] ); |
|
482 | + if ($count && isset($query_params['group_by'])) { |
|
483 | + unset($query_params['group_by']); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | //let's add specific query_params for active_events - keep in mind this will override any sent status in the query AND any date queries. |
487 | 487 | $where_params['status'] = 'publish'; |
488 | 488 | //if already have where params for DTT_EVT_start or DTT_EVT_end then append these conditions |
489 | - if ( isset( $where_params['Datetime.DTT_EVT_start'] ) ) { |
|
490 | - $where_params['Datetime.DTT_EVT_start******'] = array('<', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_start' ) ); |
|
489 | + if (isset($where_params['Datetime.DTT_EVT_start'])) { |
|
490 | + $where_params['Datetime.DTT_EVT_start******'] = array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start')); |
|
491 | 491 | } else { |
492 | - $where_params['Datetime.DTT_EVT_start'] = array('<', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_start' ) ); |
|
492 | + $where_params['Datetime.DTT_EVT_start'] = array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start')); |
|
493 | 493 | } |
494 | 494 | |
495 | - if ( isset( $where_params['Datetime.DTT_EVT_end'] ) ) { |
|
496 | - $where_params['Datetime.DTT_EVT_end*****'] = array('>', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) ); |
|
495 | + if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
496 | + $where_params['Datetime.DTT_EVT_end*****'] = array('>', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')); |
|
497 | 497 | } else { |
498 | - $where_params['Datetime.DTT_EVT_end'] = array('>', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) ); |
|
498 | + $where_params['Datetime.DTT_EVT_end'] = array('>', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')); |
|
499 | 499 | } |
500 | 500 | $query_params[0] = $where_params; |
501 | 501 | // don't use $query_params with count() because we don't want to include additional query clauses like "GROUP BY" |
502 | - return $count ? $this->count( array( $where_params ), 'EVT_ID', true ) : $this->get_all( $query_params ); |
|
502 | + return $count ? $this->count(array($where_params), 'EVT_ID', true) : $this->get_all($query_params); |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | |
@@ -514,30 +514,30 @@ discard block |
||
514 | 514 | * @param bool $count whether to return the count or not (default FALSE) |
515 | 515 | * @return array EE_Event objects |
516 | 516 | */ |
517 | - public function get_upcoming_events( $query_params, $count = FALSE ) { |
|
518 | - if ( array_key_exists( 0, $query_params ) ) { |
|
517 | + public function get_upcoming_events($query_params, $count = FALSE) { |
|
518 | + if (array_key_exists(0, $query_params)) { |
|
519 | 519 | $where_params = $query_params[0]; |
520 | - unset( $query_params[0] ); |
|
520 | + unset($query_params[0]); |
|
521 | 521 | } else { |
522 | 522 | $where_params = array(); |
523 | 523 | } |
524 | 524 | |
525 | 525 | //if we have count make sure we don't include group by |
526 | - if ( $count && isset( $query_params['group_by'] ) ) { |
|
527 | - unset( $query_params['group_by'] ); |
|
526 | + if ($count && isset($query_params['group_by'])) { |
|
527 | + unset($query_params['group_by']); |
|
528 | 528 | } |
529 | 529 | |
530 | 530 | //let's add specific query_params for active_events - keep in mind this will override any sent status in the query AND any date queries. |
531 | 531 | $where_params['status'] = 'publish'; |
532 | 532 | //if there are already query_params matching DTT_EVT_start then we need to modify that to add them. |
533 | - if ( isset( $where_params['Datetime.DTT_EVT_start'] ) ) { |
|
534 | - $where_params['Datetime.DTT_EVT_start*****'] = array('>', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_start' ) ); |
|
533 | + if (isset($where_params['Datetime.DTT_EVT_start'])) { |
|
534 | + $where_params['Datetime.DTT_EVT_start*****'] = array('>', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start')); |
|
535 | 535 | } else { |
536 | - $where_params['Datetime.DTT_EVT_start'] = array('>', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_start' ) ); |
|
536 | + $where_params['Datetime.DTT_EVT_start'] = array('>', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start')); |
|
537 | 537 | } |
538 | 538 | $query_params[0] = $where_params; |
539 | 539 | // don't use $query_params with count() because we don't want to include additional query clauses like "GROUP BY" |
540 | - return $count ? $this->count( array( $where_params ), 'EVT_ID', true ) : $this->get_all( $query_params ); |
|
540 | + return $count ? $this->count(array($where_params), 'EVT_ID', true) : $this->get_all($query_params); |
|
541 | 541 | } |
542 | 542 | |
543 | 543 | |
@@ -549,56 +549,56 @@ discard block |
||
549 | 549 | * @param bool $count whether to return the count or not (default FALSE) |
550 | 550 | * @return array EE_Event objects |
551 | 551 | */ |
552 | - public function get_expired_events( $query_params, $count = FALSE ) { |
|
552 | + public function get_expired_events($query_params, $count = FALSE) { |
|
553 | 553 | |
554 | - $where_params = isset( $query_params[0] ) ? $query_params[0] : array(); |
|
554 | + $where_params = isset($query_params[0]) ? $query_params[0] : array(); |
|
555 | 555 | |
556 | 556 | //if we have count make sure we don't include group by |
557 | - if ( $count && isset( $query_params['group_by'] ) ) { |
|
558 | - unset( $query_params['group_by'] ); |
|
557 | + if ($count && isset($query_params['group_by'])) { |
|
558 | + unset($query_params['group_by']); |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | //let's add specific query_params for active_events - keep in mind this will override any sent status in the query AND any date queries. |
562 | - if ( isset( $where_params['status'] ) ) { |
|
563 | - unset( $where_params['status'] ); |
|
562 | + if (isset($where_params['status'])) { |
|
563 | + unset($where_params['status']); |
|
564 | 564 | } |
565 | 565 | $exclude_query = $query_params; |
566 | - if ( isset( $exclude_query[0] ) ) { |
|
567 | - unset( $exclude_query[0] ); |
|
566 | + if (isset($exclude_query[0])) { |
|
567 | + unset($exclude_query[0]); |
|
568 | 568 | } |
569 | - $exclude_query[0] = array( 'Datetime.DTT_EVT_end' => array( '>', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) ) ); |
|
569 | + $exclude_query[0] = array('Datetime.DTT_EVT_end' => array('>', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'))); |
|
570 | 570 | //first get all events that have datetimes where its not expired. |
571 | - $event_ids = $this->_get_all_wpdb_results( $exclude_query, OBJECT_K, 'Event_CPT.ID' ); |
|
572 | - $event_ids = array_keys( $event_ids ); |
|
571 | + $event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Event_CPT.ID'); |
|
572 | + $event_ids = array_keys($event_ids); |
|
573 | 573 | |
574 | 574 | //if we have any additional query_params, let's add them to the 'AND' condition |
575 | 575 | $and_condition = array( |
576 | - 'Datetime.DTT_EVT_end' => array( '<', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) ), |
|
577 | - 'EVT_ID' => array( 'NOT IN', $event_ids ) |
|
576 | + 'Datetime.DTT_EVT_end' => array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end')), |
|
577 | + 'EVT_ID' => array('NOT IN', $event_ids) |
|
578 | 578 | ); |
579 | 579 | |
580 | - if ( isset( $where_params['OR'] ) ) { |
|
580 | + if (isset($where_params['OR'])) { |
|
581 | 581 | $and_condition['OR'] = $where_params['OR']; |
582 | - unset( $where_params['OR'] ); |
|
582 | + unset($where_params['OR']); |
|
583 | 583 | } |
584 | 584 | |
585 | - if ( isset( $where_params['Datetime.DTT_EVT_end'] ) ) { |
|
585 | + if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
586 | 586 | $and_condition['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end']; |
587 | - unset( $where_params['Datetime.DTT_EVT_end'] ); |
|
587 | + unset($where_params['Datetime.DTT_EVT_end']); |
|
588 | 588 | } |
589 | 589 | |
590 | - if ( isset( $where_params['Datetime.DTT_EVT_start'] ) ) { |
|
590 | + if (isset($where_params['Datetime.DTT_EVT_start'])) { |
|
591 | 591 | $and_condition['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start']; |
592 | - unset( $where_params['Datetime.DTT_EVT_start'] ); |
|
592 | + unset($where_params['Datetime.DTT_EVT_start']); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | //merge remaining $where params with the and conditions. |
596 | - $and_condtion = array_merge( $and_condition, $where_params ); |
|
596 | + $and_condtion = array_merge($and_condition, $where_params); |
|
597 | 597 | |
598 | 598 | $where_params['AND'] = $and_condition; |
599 | 599 | $query_params[0] = $where_params; |
600 | 600 | // don't use $query_params with count() because we don't want to include additional query clauses like "GROUP BY" |
601 | - return $count ? $this->count( array( $where_params ), 'EVT_ID', true ) : $this->get_all( $query_params ); |
|
601 | + return $count ? $this->count(array($where_params), 'EVT_ID', true) : $this->get_all($query_params); |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | |
@@ -609,40 +609,40 @@ discard block |
||
609 | 609 | * @param boolean $count whether to return the count or not (default FALSE) |
610 | 610 | * @return EE_Event[] array of EE_Event objects |
611 | 611 | */ |
612 | - public function get_inactive_events( $query_params, $count = FALSE ) { |
|
613 | - $where_params = isset( $query_params[0] ) ? $query_params[0] : array(); |
|
612 | + public function get_inactive_events($query_params, $count = FALSE) { |
|
613 | + $where_params = isset($query_params[0]) ? $query_params[0] : array(); |
|
614 | 614 | |
615 | 615 | //let's add in specific query_params for inactive events. |
616 | - if ( isset( $where_params['status'] ) ) { |
|
617 | - unset( $where_params['status'] ); |
|
616 | + if (isset($where_params['status'])) { |
|
617 | + unset($where_params['status']); |
|
618 | 618 | } |
619 | 619 | |
620 | 620 | //if we have count make sure we don't include group by |
621 | - if ( $count && isset( $query_params['group_by'] ) ) { |
|
622 | - unset( $query_params['group_by'] ); |
|
621 | + if ($count && isset($query_params['group_by'])) { |
|
622 | + unset($query_params['group_by']); |
|
623 | 623 | } |
624 | 624 | |
625 | 625 | //if we have any additional query_params, let's add them to the 'AND' condition |
626 | - $where_params['AND']['status'] = array( '!=', 'publish' ); |
|
626 | + $where_params['AND']['status'] = array('!=', 'publish'); |
|
627 | 627 | |
628 | - if ( isset( $where_params['OR'] ) ) { |
|
628 | + if (isset($where_params['OR'])) { |
|
629 | 629 | $where_params['AND']['OR'] = $where_params['OR']; |
630 | - unset( $where_params['OR'] ); |
|
630 | + unset($where_params['OR']); |
|
631 | 631 | } |
632 | 632 | |
633 | - if ( isset( $where_params['Datetime.DTT_EVT_end'] ) ) { |
|
633 | + if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
634 | 634 | $where_params['AND']['Datetime.DTT_EVT_end****'] = $where_params['Datetime.DTT_EVT_end']; |
635 | - unset( $where_params['Datetime.DTT_EVT_end'] ); |
|
635 | + unset($where_params['Datetime.DTT_EVT_end']); |
|
636 | 636 | } |
637 | 637 | |
638 | - if ( isset( $where_params['Datetime.DTT_EVT_start'] ) ) { |
|
638 | + if (isset($where_params['Datetime.DTT_EVT_start'])) { |
|
639 | 639 | $where_params['AND']['Datetime.DTT_EVT_start'] = $where_params['Datetime.DTT_EVT_start']; |
640 | - unset( $where_params['Datetime.DTT_EVT_start'] ); |
|
640 | + unset($where_params['Datetime.DTT_EVT_start']); |
|
641 | 641 | } |
642 | 642 | |
643 | 643 | $query_params[0] = $where_params; |
644 | 644 | // don't use $query_params with count() because we don't want to include additional query clauses like "GROUP BY" |
645 | - return $count ? $this->count( array( $where_params ), 'EVT_ID', true ) : $this->get_all( $query_params ); |
|
645 | + return $count ? $this->count(array($where_params), 'EVT_ID', true) : $this->get_all($query_params); |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | |
@@ -650,13 +650,13 @@ discard block |
||
650 | 650 | * This is just injecting into the parent add_relationship_to so we do special handling on price relationships because we don't want to override any existing global default prices but instead insert NEW prices that get attached to the event. |
651 | 651 | * See parent for param descriptions |
652 | 652 | */ |
653 | - public function add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $where_query = array()){ |
|
653 | + public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) { |
|
654 | 654 | |
655 | - if ( $relationName == 'Price' ) { |
|
655 | + if ($relationName == 'Price') { |
|
656 | 656 | //let's get the PRC object for the given ID to make sure that we aren't dealing with a default |
657 | 657 | $prc_chk = $this->get_related_model_obj($relationName)->ensure_is_obj($other_model_id_or_obj); |
658 | 658 | //if EVT_ID = 0, then this is a default |
659 | - if ( $prc_chk->get('EVT_ID') == 0 ) { |
|
659 | + if ($prc_chk->get('EVT_ID') == 0) { |
|
660 | 660 | //let's set the prc_id as 0 so we force an insert on the add_relation_to carried out by relation |
661 | 661 | $prc_chk->set('PRC_ID', 0); |
662 | 662 | } |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | } |
667 | 667 | |
668 | 668 | //otherwise carry on as normal |
669 | - return parent::add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $where_query); |
|
669 | + return parent::add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | * But either way, the string or the array's values can ONLY contain simple HTML tags. |
25 | 25 | * If you want to allow Full HTML in the value, use EE_Maybe_Serialized_Text_Field |
26 | 26 | */ |
27 | -class EE_Maybe_Serialized_Simple_HTML_Field extends EE_Maybe_Serialized_Text_Field{ |
|
27 | +class EE_Maybe_Serialized_Simple_HTML_Field extends EE_Maybe_Serialized_Text_Field { |
|
28 | 28 | /** |
29 | 29 | * removes all non-basic tags when setting |
30 | 30 | * @param string $value_inputted_for_field_on_model_object |
31 | 31 | * @return string |
32 | 32 | */ |
33 | 33 | function prepare_for_set($value_inputted_for_field_on_model_object) { |
34 | - return parent::prepare_for_set( $this->_remove_tags( $value_inputted_for_field_on_model_object ) ); |
|
34 | + return parent::prepare_for_set($this->_remove_tags($value_inputted_for_field_on_model_object)); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | * @param array|string $value |
40 | 40 | * @return array|string |
41 | 41 | */ |
42 | - protected function _remove_tags( $value ) { |
|
43 | - if( is_array( $value ) ) { |
|
44 | - foreach( $value as $key => $v ) { |
|
45 | - $value[ $key ] = $this->_remove_tags( $v ); |
|
42 | + protected function _remove_tags($value) { |
|
43 | + if (is_array($value)) { |
|
44 | + foreach ($value as $key => $v) { |
|
45 | + $value[$key] = $this->_remove_tags($v); |
|
46 | 46 | } |
47 | - }elseif( is_string( $value ) ) { |
|
48 | - $value = wp_kses("$value", $this->_get_allowed_tags() ); |
|
47 | + }elseif (is_string($value)) { |
|
48 | + $value = wp_kses("$value", $this->_get_allowed_tags()); |
|
49 | 49 | } |
50 | 50 | return $value; |
51 | 51 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @return array|string |
57 | 57 | */ |
58 | 58 | function prepare_for_set_from_db($value_found_in_db_for_model_object) { |
59 | - return $this->_remove_tags( parent::prepare_for_set_from_db( $value_found_in_db_for_model_object ) ); |
|
59 | + return $this->_remove_tags(parent::prepare_for_set_from_db($value_found_in_db_for_model_object)); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | * @global array $allowedtags |
66 | 66 | * @return array |
67 | 67 | */ |
68 | - function _get_allowed_tags(){ |
|
68 | + function _get_allowed_tags() { |
|
69 | 69 | global $allowedtags; |
70 | 70 | $tags_we_allow = $allowedtags; |
71 | - $tags_we_allow['ol']=array(); |
|
72 | - $tags_we_allow['ul']=array(); |
|
73 | - $tags_we_allow['li']=array(); |
|
74 | - return apply_filters( 'FHEE__EE_Maybe_Serialized_Simple_HTML_Field___get_allowed_tags', $tags_we_allow, $this ); |
|
71 | + $tags_we_allow['ol'] = array(); |
|
72 | + $tags_we_allow['ul'] = array(); |
|
73 | + $tags_we_allow['li'] = array(); |
|
74 | + return apply_filters('FHEE__EE_Maybe_Serialized_Simple_HTML_Field___get_allowed_tags', $tags_we_allow, $this); |
|
75 | 75 | } |
76 | 76 | } |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
|
25 | -require_once ( EE_CLASSES . 'EE_Ticket.class.php' ); |
|
24 | +require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
25 | +require_once (EE_CLASSES.'EE_Ticket.class.php'); |
|
26 | 26 | |
27 | 27 | class EEM_Ticket extends EEM_Soft_Delete_Base { |
28 | 28 | |
@@ -35,35 +35,35 @@ discard block |
||
35 | 35 | * @access private |
36 | 36 | * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
37 | 37 | */ |
38 | - protected function __construct( $timezone ) { |
|
39 | - $this->singular_item = __('Ticket','event_espresso'); |
|
40 | - $this->plural_item = __('Tickets','event_espresso'); |
|
38 | + protected function __construct($timezone) { |
|
39 | + $this->singular_item = __('Ticket', 'event_espresso'); |
|
40 | + $this->plural_item = __('Tickets', 'event_espresso'); |
|
41 | 41 | |
42 | 42 | $this->_tables = array( |
43 | 43 | 'Ticket'=> new EE_Primary_Table('esp_ticket', 'TKT_ID') |
44 | 44 | ); |
45 | 45 | $this->_fields = array( |
46 | 46 | 'Ticket'=>array( |
47 | - 'TKT_ID'=> new EE_Primary_Key_Int_Field('TKT_ID', __('Ticket ID','event_espresso')), |
|
48 | - 'TTM_ID'=>new EE_Foreign_Key_Int_Field('TTM_ID', __('Ticket Template ID','event_espresso'), false, 0, 'Ticket_Template'), |
|
47 | + 'TKT_ID'=> new EE_Primary_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso')), |
|
48 | + 'TTM_ID'=>new EE_Foreign_Key_Int_Field('TTM_ID', __('Ticket Template ID', 'event_espresso'), false, 0, 'Ticket_Template'), |
|
49 | 49 | 'TKT_name'=>new EE_Plain_Text_Field('TKT_name', __('Ticket Name', 'event_espresso'), false, ''), |
50 | - 'TKT_description'=>new EE_Full_HTML_Field('TKT_description', __('Description of Ticket', 'event_espresso'), false, '' ), |
|
51 | - 'TKT_start_date'=>new EE_Datetime_Field('TKT_start_date', __('Start time/date of Ticket','event_espresso'), false, time(), $timezone ), |
|
52 | - 'TKT_end_date'=>new EE_Datetime_Field('TKT_end_date', __('End time/date of Ticket','event_espresso'), false, time(), $timezone ), |
|
53 | - 'TKT_min'=>new EE_Integer_Field('TKT_min', __('Minimum quantity of this ticket that must be purchased', 'event_espresso'), false, 0 ), |
|
54 | - 'TKT_max'=>new EE_Infinite_Integer_Field('TKT_max', __('Maximum quantity of this ticket that can be purchased in one transaction', 'event_espresso'), false, EE_INF ), |
|
50 | + 'TKT_description'=>new EE_Full_HTML_Field('TKT_description', __('Description of Ticket', 'event_espresso'), false, ''), |
|
51 | + 'TKT_start_date'=>new EE_Datetime_Field('TKT_start_date', __('Start time/date of Ticket', 'event_espresso'), false, time(), $timezone), |
|
52 | + 'TKT_end_date'=>new EE_Datetime_Field('TKT_end_date', __('End time/date of Ticket', 'event_espresso'), false, time(), $timezone), |
|
53 | + 'TKT_min'=>new EE_Integer_Field('TKT_min', __('Minimum quantity of this ticket that must be purchased', 'event_espresso'), false, 0), |
|
54 | + 'TKT_max'=>new EE_Infinite_Integer_Field('TKT_max', __('Maximum quantity of this ticket that can be purchased in one transaction', 'event_espresso'), false, EE_INF), |
|
55 | 55 | 'TKT_price'=> new EE_Money_Field('TKT_price', 'Final calculated price for ticket', false, 0), |
56 | 56 | 'TKT_sold' => new EE_Integer_Field('TKT_sold', __('Number of this ticket sold', 'event_espresso'), false, 0), |
57 | - 'TKT_qty'=>new EE_Infinite_Integer_Field('TKT_qty', __('Quantity of this ticket that is available','event_espresso'), false, EE_INF), |
|
58 | - 'TKT_uses'=>new EE_Infinite_Integer_Field('TKT_uses', __('Number of datetimes this ticket can be used at', 'event_espresso'), false, EE_INF ), |
|
59 | - 'TKT_required'=>new EE_Boolean_Field('TKT_required', __("Flag indicating whether this ticket must be purchased with a transaction", "event_espresso"), false, false ), |
|
60 | - 'TKT_taxable'=>new EE_Boolean_Field('TKT_taxable', __("Flag indicating whether there is tax applied on this ticket", "event_espresso"), false,false), |
|
61 | - 'TKT_is_default'=>new EE_Boolean_Field('TKT_is_default', __('Flag indicating that this ticket is a default ticket', 'event_espresso'), false, false ), |
|
57 | + 'TKT_qty'=>new EE_Infinite_Integer_Field('TKT_qty', __('Quantity of this ticket that is available', 'event_espresso'), false, EE_INF), |
|
58 | + 'TKT_uses'=>new EE_Infinite_Integer_Field('TKT_uses', __('Number of datetimes this ticket can be used at', 'event_espresso'), false, EE_INF), |
|
59 | + 'TKT_required'=>new EE_Boolean_Field('TKT_required', __("Flag indicating whether this ticket must be purchased with a transaction", "event_espresso"), false, false), |
|
60 | + 'TKT_taxable'=>new EE_Boolean_Field('TKT_taxable', __("Flag indicating whether there is tax applied on this ticket", "event_espresso"), false, false), |
|
61 | + 'TKT_is_default'=>new EE_Boolean_Field('TKT_is_default', __('Flag indicating that this ticket is a default ticket', 'event_espresso'), false, false), |
|
62 | 62 | 'TKT_order' => new EE_Integer_Field('TKT_order', __('The order in which the Ticket is displayed in the editor (used for autosaves when the form doesn\'t have the ticket ID yet)', 'event_espresso'), false, 0), |
63 | - 'TKT_row' => new EE_Integer_Field('TKT_row', __('How tickets are displayed in the ui', 'event_espresso'), false, 0 ), |
|
63 | + 'TKT_row' => new EE_Integer_Field('TKT_row', __('How tickets are displayed in the ui', 'event_espresso'), false, 0), |
|
64 | 64 | 'TKT_deleted' => new EE_Trashed_Flag_Field('TKT_deleted', __('Flag indicating if this has been archived or not', 'event_espresso'), false, false), |
65 | - 'TKT_wp_user' => new EE_WP_User_Field('TKT_wp_user', __('Ticket Creator ID', 'event_espresso'), FALSE ), |
|
66 | - 'TKT_parent' => new EE_Integer_Field('TKT_parent', __('Indicates what TKT_ID is the parent of this TKT_ID (used in autosaves/revisions)'), true, 0 ) |
|
65 | + 'TKT_wp_user' => new EE_WP_User_Field('TKT_wp_user', __('Ticket Creator ID', 'event_espresso'), FALSE), |
|
66 | + 'TKT_parent' => new EE_Integer_Field('TKT_parent', __('Indicates what TKT_ID is the parent of this TKT_ID (used in autosaves/revisions)'), true, 0) |
|
67 | 67 | )); |
68 | 68 | $this->_model_relations = array( |
69 | 69 | 'Datetime'=>new EE_HABTM_Relation('Datetime_Ticket'), |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | ); |
76 | 76 | |
77 | 77 | //this model is generally available for reading |
78 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public('TKT_is_default', 'Datetime.Event'); |
|
78 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Default_Public('TKT_is_default', 'Datetime.Event'); |
|
79 | 79 | //account for default tickets in the caps |
80 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected( 'TKT_is_default', 'Datetime.Event' ); |
|
81 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected( 'TKT_is_default', 'Datetime.Event' ); |
|
82 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected( 'TKT_is_default', 'Datetime.Event' ); |
|
83 | - parent::__construct( $timezone ); |
|
80 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Default_Protected('TKT_is_default', 'Datetime.Event'); |
|
81 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Default_Protected('TKT_is_default', 'Datetime.Event'); |
|
82 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Default_Protected('TKT_is_default', 'Datetime.Event'); |
|
83 | + parent::__construct($timezone); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function get_all_default_tickets() { |
93 | 93 | /** @type EE_Ticket[] $tickets */ |
94 | - $tickets = $this->get_all( array( array('TKT_is_default' => 1), 'order_by' => array('TKT_ID' => 'ASC')) ); |
|
94 | + $tickets = $this->get_all(array(array('TKT_is_default' => 1), 'order_by' => array('TKT_ID' => 'ASC'))); |
|
95 | 95 | //we need to set the start date and end date to today's date and the start of the default dtt |
96 | - return $this->_set_default_dates( $tickets ); |
|
96 | + return $this->_set_default_dates($tickets); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | * @param EE_Ticket[] $tickets |
104 | 104 | * @return EE_Ticket[] |
105 | 105 | */ |
106 | - private function _set_default_dates( $tickets ) { |
|
107 | - foreach ( $tickets as $ticket ) { |
|
108 | - $ticket->set('TKT_start_date', $this->current_time_for_query('TKT_start_date', true) ); |
|
109 | - $ticket->set('TKT_end_date', $this->current_time_for_query( 'TKT_end_date', true ) + (60 * 60 * 24 * 30 ) ); |
|
110 | - $ticket->set_end_time( $this->convert_datetime_for_query( 'TKT_end_date', '11:59 pm', 'g:i a', $this->_timezone ) ); |
|
106 | + private function _set_default_dates($tickets) { |
|
107 | + foreach ($tickets as $ticket) { |
|
108 | + $ticket->set('TKT_start_date', $this->current_time_for_query('TKT_start_date', true)); |
|
109 | + $ticket->set('TKT_end_date', $this->current_time_for_query('TKT_end_date', true) + (60 * 60 * 24 * 30)); |
|
110 | + $ticket->set_end_time($this->convert_datetime_for_query('TKT_end_date', '11:59 pm', 'g:i a', $this->_timezone)); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | return $tickets; |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | * @param array $query_params |
123 | 123 | * @return int |
124 | 124 | */ |
125 | - public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()){ |
|
126 | - return EEM_Datetime::instance()->sum_tickets_currently_available_at_datetime( $DTT_ID, $query_params ); |
|
125 | + public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()) { |
|
126 | + return EEM_Datetime::instance()->sum_tickets_currently_available_at_datetime($DTT_ID, $query_params); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | * @param EE_Ticket[] $tickets |
134 | 134 | * @return void |
135 | 135 | */ |
136 | - public function update_tickets_sold($tickets){ |
|
137 | - foreach($tickets as $ticket){ |
|
136 | + public function update_tickets_sold($tickets) { |
|
137 | + foreach ($tickets as $ticket) { |
|
138 | 138 | /* @var $ticket EE_Ticket */ |
139 | 139 | $ticket->update_tickets_sold(); |
140 | 140 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -54,23 +54,23 @@ discard block |
||
54 | 54 | $this->_name = 'pricing'; |
55 | 55 | |
56 | 56 | //capability check |
57 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_default_prices', 'advanced_ticket_datetime_metabox' ) ) { |
|
57 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_default_prices', 'advanced_ticket_datetime_metabox')) { |
|
58 | 58 | return; |
59 | 59 | } |
60 | 60 | |
61 | - EE_Registry::instance()->load_helper( 'DTT_Helper' ); |
|
61 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
62 | 62 | |
63 | 63 | //if we were going to add our own metaboxes we'd use the below. |
64 | 64 | $this->_metaboxes = array( |
65 | 65 | 0 => array( |
66 | - 'page_route' => array('edit','create_new'), |
|
66 | + 'page_route' => array('edit', 'create_new'), |
|
67 | 67 | 'func' => 'pricing_metabox', |
68 | 68 | 'label' => __('Event Tickets & Datetimes', 'event_espresso'), |
69 | 69 | 'priority' => 'high', |
70 | 70 | 'context' => 'normal' |
71 | 71 | ), |
72 | 72 | |
73 | - );/**/ |
|
73 | + ); /**/ |
|
74 | 74 | |
75 | 75 | $this->_remove_metaboxes = array( |
76 | 76 | 0 => array( |
@@ -89,24 +89,24 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @var array Expected an array returned with 'date' and 'time' keys. |
91 | 91 | */ |
92 | - $this->_date_format_strings = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings', array( |
|
92 | + $this->_date_format_strings = apply_filters('FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings', array( |
|
93 | 93 | 'date' => 'Y-m-d', |
94 | 94 | 'time' => 'h:i a' |
95 | 95 | )); |
96 | 96 | |
97 | 97 | //validate |
98 | - $this->_date_format_strings['date'] = isset( $this->_date_format_strings['date'] ) ? $this->_date_format_strings['date'] : null; |
|
99 | - $this->_date_format_strings['time'] = isset( $this->_date_format_strings['time'] ) ? $this->_date_format_strings['time'] : null; |
|
98 | + $this->_date_format_strings['date'] = isset($this->_date_format_strings['date']) ? $this->_date_format_strings['date'] : null; |
|
99 | + $this->_date_format_strings['time'] = isset($this->_date_format_strings['time']) ? $this->_date_format_strings['time'] : null; |
|
100 | 100 | |
101 | 101 | //validate format strings |
102 | - $format_validation = EEH_DTT_Helper::validate_format_string( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ); |
|
103 | - if ( is_array( $format_validation ) ) { |
|
104 | - $msg = '<p>' . sprintf( __( 'The format "%s" was likely added via a filter and is invalid for the following reasons:', 'event_espresso' ), $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ) . '</p><ul>'; |
|
105 | - foreach ( $format_validation as $error ) { |
|
106 | - $msg .= '<li>' . $error . '</li>'; |
|
102 | + $format_validation = EEH_DTT_Helper::validate_format_string($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']); |
|
103 | + if (is_array($format_validation)) { |
|
104 | + $msg = '<p>'.sprintf(__('The format "%s" was likely added via a filter and is invalid for the following reasons:', 'event_espresso'), $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']).'</p><ul>'; |
|
105 | + foreach ($format_validation as $error) { |
|
106 | + $msg .= '<li>'.$error.'</li>'; |
|
107 | 107 | } |
108 | - $msg .= '</ul></p><p>' . sprintf( __( '%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s', 'event_espresso' ), '<span style="color:#D54E21;">', '</span>' ) . '</p>'; |
|
109 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
108 | + $msg .= '</ul></p><p>'.sprintf(__('%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s', 'event_espresso'), '<span style="color:#D54E21;">', '</span>').'</p>'; |
|
109 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
110 | 110 | $this->_date_format_strings = array( |
111 | 111 | 'date' => 'Y-m-d', |
112 | 112 | 'time' => 'h:i a' |
@@ -117,60 +117,60 @@ discard block |
||
117 | 117 | $this->_scripts_styles = array( |
118 | 118 | 'registers' => array( |
119 | 119 | 'ee-tickets-datetimes-css' => array( |
120 | - 'url' => PRICING_ASSETS_URL . 'event-tickets-datetimes.css', |
|
120 | + 'url' => PRICING_ASSETS_URL.'event-tickets-datetimes.css', |
|
121 | 121 | 'type' => 'css' |
122 | 122 | ), |
123 | 123 | 'ee-dtt-ticket-metabox' => array( |
124 | - 'url' => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js', |
|
124 | + 'url' => PRICING_ASSETS_URL.'ee-datetime-ticket-metabox.js', |
|
125 | 125 | 'depends' => array('ee-datepicker', 'ee-dialog', 'underscore') |
126 | 126 | ) |
127 | 127 | ), |
128 | 128 | 'deregisters' => array( |
129 | - 'event-editor-css' => array('type' => 'css' ), |
|
129 | + 'event-editor-css' => array('type' => 'css'), |
|
130 | 130 | 'event-datetime-metabox' => array('type' => 'js') |
131 | 131 | ), |
132 | 132 | 'enqueues' => array( |
133 | - 'ee-tickets-datetimes-css' => array( 'edit', 'create_new' ), |
|
134 | - 'ee-dtt-ticket-metabox' => array( 'edit', 'create_new' ) |
|
133 | + 'ee-tickets-datetimes-css' => array('edit', 'create_new'), |
|
134 | + 'ee-dtt-ticket-metabox' => array('edit', 'create_new') |
|
135 | 135 | ), |
136 | 136 | 'localize' => array( |
137 | 137 | 'ee-dtt-ticket-metabox' => array( |
138 | 138 | 'DTT_TRASH_BLOCK' => array( |
139 | 139 | 'main_warning' => __('The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):', 'event_espresso'), |
140 | 140 | 'after_warning' => __('In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.', 'event_espresso'), |
141 | - 'cancel_button' => '<button class="button-secondary ee-modal-cancel">' . __('Cancel', 'event_espresso') . '</button>', |
|
141 | + 'cancel_button' => '<button class="button-secondary ee-modal-cancel">'.__('Cancel', 'event_espresso').'</button>', |
|
142 | 142 | 'single_warning_from_tkt' => __('The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.', 'event_espresso'), |
143 | 143 | 'single_warning_from_dtt' => __('The ticket you are attempting to unassign from this datetime cannot be unassigned because the datetime is the only remaining datetime for the ticket. Tickets must always have at least one datetime assigned to them.', 'event_espresso'), |
144 | - 'dismiss_button' => '<button class="button-secondary ee-modal-cancel">' . __('Dismiss', 'event_espresso') . '</button>' |
|
144 | + 'dismiss_button' => '<button class="button-secondary ee-modal-cancel">'.__('Dismiss', 'event_espresso').'</button>' |
|
145 | 145 | ), |
146 | 146 | 'DTT_ERROR_MSG' => array( |
147 | 147 | 'no_ticket_name' => __('General Admission', 'event_espresso'), |
148 | - 'dismiss_button' => '<div class="save-cancel-button-container"><button class="button-secondary ee-modal-cancel">' . __('Dismiss', 'event_espresso') . '</button></div>' |
|
148 | + 'dismiss_button' => '<div class="save-cancel-button-container"><button class="button-secondary ee-modal-cancel">'.__('Dismiss', 'event_espresso').'</button></div>' |
|
149 | 149 | ), |
150 | 150 | 'DTT_OVERSELL_WARNING' => array( |
151 | 151 | 'datetime_ticket' => __('You cannot add this ticket to this datetime because it has a sold amount that is greater than the amount of spots remaining for this datetime.', 'event_espresso'), |
152 | 152 | 'ticket_datetime' => __('You cannot add this datetime to this ticket because the ticket has a sold amount that is greater than the amount of spots remaining on the datetime.', 'event_espresso') |
153 | 153 | ), |
154 | - 'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats( $this->_date_format_strings['date'], $this->_date_format_strings['time'] ), |
|
155 | - 'DTT_START_OF_WEEK' => array( 'dayValue' => (int) get_option( 'start_of_week' ) ) |
|
154 | + 'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats($this->_date_format_strings['date'], $this->_date_format_strings['time']), |
|
155 | + 'DTT_START_OF_WEEK' => array('dayValue' => (int) get_option('start_of_week')) |
|
156 | 156 | ) |
157 | 157 | ) |
158 | 158 | ); |
159 | 159 | |
160 | 160 | |
161 | - add_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page', array( $this, 'autosave_handling' ), 10 ); |
|
162 | - add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array( $this, 'caf_updates' ), 10 ); |
|
161 | + add_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page', array($this, 'autosave_handling'), 10); |
|
162 | + add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array($this, 'caf_updates'), 10); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
166 | 166 | |
167 | - public function caf_updates( $update_callbacks ) { |
|
168 | - foreach ( $update_callbacks as $key => $callback ) { |
|
169 | - if ( $callback[1] == '_default_tickets_update' ) |
|
170 | - unset( $update_callbacks[$key] ); |
|
167 | + public function caf_updates($update_callbacks) { |
|
168 | + foreach ($update_callbacks as $key => $callback) { |
|
169 | + if ($callback[1] == '_default_tickets_update') |
|
170 | + unset($update_callbacks[$key]); |
|
171 | 171 | } |
172 | 172 | |
173 | - $update_callbacks[] = array( $this, 'dtt_and_tickets_caf_update' ); |
|
173 | + $update_callbacks[] = array($this, 'dtt_and_tickets_caf_update'); |
|
174 | 174 | return $update_callbacks; |
175 | 175 | } |
176 | 176 | |
@@ -183,11 +183,11 @@ discard block |
||
183 | 183 | * @param array $data The request data from the form |
184 | 184 | * @return bool success or fail |
185 | 185 | */ |
186 | - public function dtt_and_tickets_caf_update( $evtobj, $data ) { |
|
186 | + public function dtt_and_tickets_caf_update($evtobj, $data) { |
|
187 | 187 | //first we need to start with datetimes cause they are the "root" items attached to events. |
188 | - $saved_dtts = $this->_update_dtts( $evtobj, $data ); |
|
188 | + $saved_dtts = $this->_update_dtts($evtobj, $data); |
|
189 | 189 | //next tackle the tickets (and prices?) |
190 | - $this->_update_tkts( $evtobj, $saved_dtts, $data ); |
|
190 | + $this->_update_tkts($evtobj, $saved_dtts, $data); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | |
@@ -198,41 +198,41 @@ discard block |
||
198 | 198 | * @param array $data the request data from the form |
199 | 199 | * @return EE_Datetime[] |
200 | 200 | */ |
201 | - protected function _update_dtts( $evt_obj, $data ) { |
|
202 | - $timezone = isset( $data['timezone_string'] ) ? $data['timezone_string'] : NULL; |
|
201 | + protected function _update_dtts($evt_obj, $data) { |
|
202 | + $timezone = isset($data['timezone_string']) ? $data['timezone_string'] : NULL; |
|
203 | 203 | $saved_dtt_ids = array(); |
204 | 204 | $saved_dtt_objs = array(); |
205 | 205 | |
206 | - foreach ( $data['edit_event_datetimes'] as $row => $dtt ) { |
|
206 | + foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
207 | 207 | //trim all values to ensure any excess whitespace is removed. |
208 | 208 | $dtt = array_map( |
209 | - function( $datetime_data ) { |
|
210 | - return is_array( $datetime_data ) ? $datetime_data : trim( $datetime_data ); |
|
209 | + function($datetime_data) { |
|
210 | + return is_array($datetime_data) ? $datetime_data : trim($datetime_data); |
|
211 | 211 | }, |
212 | 212 | $dtt |
213 | 213 | ); |
214 | - $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
214 | + $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
215 | 215 | $datetime_values = array( |
216 | - 'DTT_ID' => ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : NULL, |
|
217 | - 'DTT_name' => ! empty( $dtt['DTT_name'] ) ? $dtt['DTT_name'] : '', |
|
218 | - 'DTT_description' => ! empty( $dtt['DTT_description'] ) ? $dtt['DTT_description'] : '', |
|
216 | + 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : NULL, |
|
217 | + 'DTT_name' => ! empty($dtt['DTT_name']) ? $dtt['DTT_name'] : '', |
|
218 | + 'DTT_description' => ! empty($dtt['DTT_description']) ? $dtt['DTT_description'] : '', |
|
219 | 219 | 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
220 | 220 | 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
221 | - 'DTT_reg_limit' => empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt[ 'DTT_reg_limit' ], |
|
222 | - 'DTT_order' => ! isset( $dtt['DTT_order'] ) ? $row : $dtt['DTT_order'], |
|
221 | + 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
222 | + 'DTT_order' => ! isset($dtt['DTT_order']) ? $row : $dtt['DTT_order'], |
|
223 | 223 | ); |
224 | 224 | |
225 | 225 | //if we have an id then let's get existing object first and then set the new values. Otherwise we instantiate a new object for save. |
226 | 226 | |
227 | - if ( !empty( $dtt['DTT_ID'] ) ) { |
|
228 | - $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone) )->get_one_by_ID($dtt['DTT_ID'] ); |
|
227 | + if ( ! empty($dtt['DTT_ID'])) { |
|
228 | + $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone))->get_one_by_ID($dtt['DTT_ID']); |
|
229 | 229 | |
230 | 230 | //set date and time format according to what is set in this class. |
231 | - $DTM->set_date_format( $this->_date_format_strings['date'] ); |
|
232 | - $DTM->set_time_format( $this->_date_format_strings['time'] ); |
|
231 | + $DTM->set_date_format($this->_date_format_strings['date']); |
|
232 | + $DTM->set_time_format($this->_date_format_strings['time']); |
|
233 | 233 | |
234 | - foreach ( $datetime_values as $field => $value ) { |
|
235 | - $DTM->set( $field, $value ); |
|
234 | + foreach ($datetime_values as $field => $value) { |
|
235 | + $DTM->set($field, $value); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | // make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it. |
@@ -240,24 +240,24 @@ discard block |
||
240 | 240 | $saved_dtt_ids[$DTM->ID()] = $DTM->ID(); |
241 | 241 | |
242 | 242 | } else { |
243 | - $DTM = EE_Registry::instance()->load_class('Datetime', array( $datetime_values, $timezone ), FALSE, FALSE ); |
|
243 | + $DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values, $timezone), FALSE, FALSE); |
|
244 | 244 | |
245 | 245 | //reset date and times to match the format |
246 | - $DTM->set_date_format( $this->_date_format_strings['date'] ); |
|
247 | - $DTM->set_time_format( $this->_date_format_strings['time'] ); |
|
248 | - foreach( $datetime_values as $field => $value ) { |
|
249 | - $DTM->set( $field, $value ); |
|
246 | + $DTM->set_date_format($this->_date_format_strings['date']); |
|
247 | + $DTM->set_time_format($this->_date_format_strings['time']); |
|
248 | + foreach ($datetime_values as $field => $value) { |
|
249 | + $DTM->set($field, $value); |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
253 | 253 | |
254 | 254 | $DTM->save(); |
255 | - $DTM = $evt_obj->_add_relation_to( $DTM, 'Datetime' ); |
|
255 | + $DTM = $evt_obj->_add_relation_to($DTM, 'Datetime'); |
|
256 | 256 | $evt_obj->save(); |
257 | 257 | |
258 | 258 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
259 | - if( $DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end') ) { |
|
260 | - $DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start') ); |
|
259 | + if ($DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end')) { |
|
260 | + $DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start')); |
|
261 | 261 | EE_Registry::instance()->load_helper('DTT_Helper'); |
262 | 262 | $DTM = EEH_DTT_Helper::date_time_add($DTM, 'DTT_EVT_end', 'days'); |
263 | 263 | $DTM->save(); |
@@ -273,25 +273,25 @@ discard block |
||
273 | 273 | } |
274 | 274 | |
275 | 275 | //now we need to REMOVE any dtts that got deleted. Keep in mind that this process will only kick in for DTT's that don't have any DTT_sold on them. So its safe to permanently delete at this point. |
276 | - $old_datetimes = explode(',', $data['datetime_IDs'] ); |
|
276 | + $old_datetimes = explode(',', $data['datetime_IDs']); |
|
277 | 277 | $old_datetimes = $old_datetimes[0] == '' ? array() : $old_datetimes; |
278 | 278 | |
279 | - if ( is_array( $old_datetimes ) ) { |
|
280 | - $dtts_to_delete = array_diff( $old_datetimes, $saved_dtt_ids ); |
|
281 | - foreach ( $dtts_to_delete as $id ) { |
|
282 | - $id = absint( $id ); |
|
283 | - if ( empty( $id ) ) |
|
279 | + if (is_array($old_datetimes)) { |
|
280 | + $dtts_to_delete = array_diff($old_datetimes, $saved_dtt_ids); |
|
281 | + foreach ($dtts_to_delete as $id) { |
|
282 | + $id = absint($id); |
|
283 | + if (empty($id)) |
|
284 | 284 | continue; |
285 | 285 | |
286 | 286 | $dtt_to_remove = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($id); |
287 | 287 | |
288 | 288 | //remove tkt relationships. |
289 | 289 | $related_tickets = $dtt_to_remove->get_many_related('Ticket'); |
290 | - foreach ( $related_tickets as $tkt ) { |
|
290 | + foreach ($related_tickets as $tkt) { |
|
291 | 291 | $dtt_to_remove->_remove_relation_to($tkt, 'Ticket'); |
292 | 292 | } |
293 | 293 | |
294 | - $evt_obj->_remove_relation_to( $id, 'Datetime' ); |
|
294 | + $evt_obj->_remove_relation_to($id, 'Datetime'); |
|
295 | 295 | $dtt_to_remove->refresh_cache_of_related_objects(); |
296 | 296 | |
297 | 297 | } |
@@ -312,86 +312,86 @@ discard block |
||
312 | 312 | * @param array $data incoming request data |
313 | 313 | * @return EE_Ticket[] |
314 | 314 | */ |
315 | - protected function _update_tkts( $evtobj, $saved_dtts, $data ) { |
|
315 | + protected function _update_tkts($evtobj, $saved_dtts, $data) { |
|
316 | 316 | |
317 | 317 | $new_tkt = null; |
318 | 318 | $new_default = null; |
319 | 319 | //stripslashes because WP filtered the $_POST ($data) array to add slashes |
320 | 320 | $data = stripslashes_deep($data); |
321 | - $timezone = isset( $data['timezone_string'] ) ? $data['timezone_string'] : NULL; |
|
321 | + $timezone = isset($data['timezone_string']) ? $data['timezone_string'] : NULL; |
|
322 | 322 | $saved_tickets = $dtts_on_existing = array(); |
323 | - $old_tickets = isset( $data['ticket_IDs'] ) ? explode(',', $data['ticket_IDs'] ) : array(); |
|
323 | + $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
324 | 324 | |
325 | 325 | //load money helper |
326 | - EE_Registry::instance()->load_helper( 'Money' ); |
|
326 | + EE_Registry::instance()->load_helper('Money'); |
|
327 | 327 | |
328 | - foreach ( $data['edit_tickets'] as $row => $tkt ) { |
|
328 | + foreach ($data['edit_tickets'] as $row => $tkt) { |
|
329 | 329 | |
330 | 330 | $update_prices = $create_new_TKT = FALSE; |
331 | 331 | |
332 | 332 | //figure out what dtts were added to the ticket and what dtts were removed from the ticket in the session. |
333 | 333 | |
334 | - $starting_tkt_dtt_rows = explode(',',$data['starting_ticket_datetime_rows'][$row]); |
|
335 | - $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row] ); |
|
334 | + $starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][$row]); |
|
335 | + $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row]); |
|
336 | 336 | $dtts_added = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows); |
337 | 337 | $dtts_removed = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows); |
338 | 338 | |
339 | 339 | // trim inputs to ensure any excess whitespace is removed. |
340 | 340 | $tkt = array_map( |
341 | - function( $ticket_data ) { |
|
342 | - return is_array( $ticket_data ) ? $ticket_data : trim( $ticket_data ); |
|
341 | + function($ticket_data) { |
|
342 | + return is_array($ticket_data) ? $ticket_data : trim($ticket_data); |
|
343 | 343 | }, |
344 | 344 | $tkt |
345 | 345 | ); |
346 | 346 | |
347 | 347 | //note we are doing conversions to floats here instead of allowing EE_Money_Field to handle because we're doing calcs prior to using the models. |
348 | 348 | //note incoming ['TKT_price'] value is already in standard notation (via js). |
349 | - $ticket_price = isset( $tkt['TKT_price'] ) ? round ( (float) $tkt['TKT_price'], 3 ) : 0; |
|
349 | + $ticket_price = isset($tkt['TKT_price']) ? round((float) $tkt['TKT_price'], 3) : 0; |
|
350 | 350 | |
351 | 351 | //note incoming base price needs converted from localized value. |
352 | - $base_price = isset( $tkt['TKT_base_price'] ) ? EEH_Money::convert_to_float_from_localized_money( $tkt['TKT_base_price'] ) : 0; |
|
352 | + $base_price = isset($tkt['TKT_base_price']) ? EEH_Money::convert_to_float_from_localized_money($tkt['TKT_base_price']) : 0; |
|
353 | 353 | //if ticket price == 0 and $base_price != 0 then ticket price == base_price |
354 | 354 | $ticket_price = $ticket_price === 0 && $base_price !== 0 ? $base_price : $ticket_price; |
355 | - $base_price_id = isset( $tkt['TKT_base_price_ID'] ) ? $tkt['TKT_base_price_ID'] : 0; |
|
355 | + $base_price_id = isset($tkt['TKT_base_price_ID']) ? $tkt['TKT_base_price_ID'] : 0; |
|
356 | 356 | |
357 | 357 | $price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][$row]) ? $data['edit_prices'][$row] : array(); |
358 | 358 | |
359 | 359 | $now = null; |
360 | - if ( empty( $tkt['TKT_start_date'] ) ) { |
|
360 | + if (empty($tkt['TKT_start_date'])) { |
|
361 | 361 | //lets' use now in the set timezone. |
362 | - $now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) ); |
|
363 | - $tkt['TKT_start_date'] = $now->format( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ); |
|
362 | + $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
363 | + $tkt['TKT_start_date'] = $now->format($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']); |
|
364 | 364 | } |
365 | 365 | |
366 | - if ( empty( $tkt['TKT_end_date'] ) ) { |
|
366 | + if (empty($tkt['TKT_end_date'])) { |
|
367 | 367 | /** |
368 | 368 | * set the TKT_end_date to the first datetime attached to the ticket. |
369 | 369 | */ |
370 | - $first_dtt = $saved_dtts[reset( $tkt_dtt_rows )]; |
|
371 | - $tkt['TKT_end_date'] = $first_dtt->start_date_and_time( $this->_date_format_strings['date'] . ' ' . $this->_date_format_string['time'] ); |
|
370 | + $first_dtt = $saved_dtts[reset($tkt_dtt_rows)]; |
|
371 | + $tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_format_strings['date'].' '.$this->_date_format_string['time']); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | $TKT_values = array( |
375 | - 'TKT_ID' => ! empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : NULL, |
|
376 | - 'TTM_ID' => ! empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0, |
|
377 | - 'TKT_name' => ! empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '', |
|
378 | - 'TKT_description' => ! empty( $tkt['TKT_description'] ) && $tkt['TKT_description'] != __('You can modify this description', 'event_espresso') ? $tkt['TKT_description'] : '', |
|
375 | + 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : NULL, |
|
376 | + 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
377 | + 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
378 | + 'TKT_description' => ! empty($tkt['TKT_description']) && $tkt['TKT_description'] != __('You can modify this description', 'event_espresso') ? $tkt['TKT_description'] : '', |
|
379 | 379 | 'TKT_start_date' => $tkt['TKT_start_date'], |
380 | 380 | 'TKT_end_date' => $tkt['TKT_end_date'], |
381 | - 'TKT_qty' => ! isset( $tkt[ 'TKT_qty' ] ) || $tkt[ 'TKT_qty' ] === '' ? EE_INF : $tkt[ 'TKT_qty' ], |
|
382 | - 'TKT_uses' => ! isset( $tkt[ 'TKT_uses' ] ) || $tkt[ 'TKT_uses' ] === '' ? EE_INF : $tkt['TKT_uses'], |
|
383 | - 'TKT_min' => empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'], |
|
384 | - 'TKT_max' => empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'], |
|
381 | + 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
382 | + 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
383 | + 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
384 | + 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
385 | 385 | 'TKT_row' => $row, |
386 | - 'TKT_order' => isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : 0, |
|
387 | - 'TKT_taxable' => ! empty( $tkt['TKT_taxable'] ) ? 1 : 0, |
|
388 | - 'TKT_required' => ! empty( $tkt['TKT_required'] ) ? 1 : 0, |
|
386 | + 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : 0, |
|
387 | + 'TKT_taxable' => ! empty($tkt['TKT_taxable']) ? 1 : 0, |
|
388 | + 'TKT_required' => ! empty($tkt['TKT_required']) ? 1 : 0, |
|
389 | 389 | 'TKT_price' => $ticket_price |
390 | 390 | ); |
391 | 391 | |
392 | 392 | |
393 | 393 | //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well. |
394 | - if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) { |
|
394 | + if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
395 | 395 | $TKT_values['TKT_ID'] = 0; |
396 | 396 | $TKT_values['TKT_is_default'] = 0; |
397 | 397 | $update_prices = TRUE; |
@@ -403,21 +403,21 @@ discard block |
||
403 | 403 | // but DID have it's items modified. |
404 | 404 | // keep in mind that if the TKT has been sold (and we have changed pricing information), |
405 | 405 | // then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
406 | - if ( absint( $TKT_values['TKT_ID'] ) ) { |
|
407 | - $TKT = EE_Registry::instance()->load_model( 'Ticket', array( $timezone ) )->get_one_by_ID( $tkt['TKT_ID'] ); |
|
408 | - if ( $TKT instanceof EE_Ticket ) { |
|
406 | + if (absint($TKT_values['TKT_ID'])) { |
|
407 | + $TKT = EE_Registry::instance()->load_model('Ticket', array($timezone))->get_one_by_ID($tkt['TKT_ID']); |
|
408 | + if ($TKT instanceof EE_Ticket) { |
|
409 | 409 | |
410 | - $TKT = $this->_update_ticket_datetimes( $TKT, $saved_dtts, $dtts_added, $dtts_removed ); |
|
410 | + $TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed); |
|
411 | 411 | // are there any registrations using this ticket ? |
412 | 412 | $tickets_sold = $TKT->count_related( |
413 | 413 | 'Registration', |
414 | - array( array( |
|
415 | - 'STS_ID' => array( 'NOT IN', array( EEM_Registration::status_id_incomplete ) ) |
|
416 | - ) ) |
|
414 | + array(array( |
|
415 | + 'STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete)) |
|
416 | + )) |
|
417 | 417 | ); |
418 | 418 | //set ticket formats |
419 | - $TKT->set_date_format( $this->_date_format_strings['date'] ); |
|
420 | - $TKT->set_time_format( $this->_date_format_strings['time'] ); |
|
419 | + $TKT->set_date_format($this->_date_format_strings['date']); |
|
420 | + $TKT->set_time_format($this->_date_format_strings['time']); |
|
421 | 421 | |
422 | 422 | // let's just check the total price for the existing ticket |
423 | 423 | // and determine if it matches the new total price. |
@@ -427,17 +427,17 @@ discard block |
||
427 | 427 | ? TRUE : FALSE; |
428 | 428 | |
429 | 429 | //set new values |
430 | - foreach ( $TKT_values as $field => $value ) { |
|
431 | - if ( $field === 'TKT_qty' ) { |
|
432 | - $TKT->set_qty( $value ); |
|
430 | + foreach ($TKT_values as $field => $value) { |
|
431 | + if ($field === 'TKT_qty') { |
|
432 | + $TKT->set_qty($value); |
|
433 | 433 | } else { |
434 | - $TKT->set( $field, $value ); |
|
434 | + $TKT->set($field, $value); |
|
435 | 435 | } |
436 | 436 | } |
437 | 437 | |
438 | 438 | //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
439 | - if ( $create_new_TKT ) { |
|
440 | - $new_tkt = $this->_duplicate_ticket( $TKT, $price_rows, $ticket_price, $base_price, $base_price_id ); |
|
439 | + if ($create_new_TKT) { |
|
440 | + $new_tkt = $this->_duplicate_ticket($TKT, $price_rows, $ticket_price, $base_price, $base_price_id); |
|
441 | 441 | } |
442 | 442 | } |
443 | 443 | |
@@ -446,12 +446,12 @@ discard block |
||
446 | 446 | $TKT = EE_Ticket::new_instance( |
447 | 447 | $TKT_values, |
448 | 448 | $timezone, |
449 | - array( $this->_date_format_strings[ 'date' ], $this->_date_format_strings[ 'time' ] ) |
|
449 | + array($this->_date_format_strings['date'], $this->_date_format_strings['time']) |
|
450 | 450 | ); |
451 | - if ( $TKT instanceof EE_Ticket ) { |
|
451 | + if ($TKT instanceof EE_Ticket) { |
|
452 | 452 | // make sure ticket has an ID of setting relations won't work |
453 | 453 | $TKT->save(); |
454 | - $TKT = $this->_update_ticket_datetimes( $TKT, $saved_dtts, $dtts_added, $dtts_removed ); |
|
454 | + $TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed); |
|
455 | 455 | $update_prices = TRUE; |
456 | 456 | } |
457 | 457 | } |
@@ -459,38 +459,38 @@ discard block |
||
459 | 459 | //$TKT->save(); |
460 | 460 | |
461 | 461 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
462 | - if( $TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date') ) { |
|
463 | - $TKT->set('TKT_end_date', $TKT->get('TKT_start_date') ); |
|
462 | + if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
463 | + $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
464 | 464 | EE_Registry::instance()->load_helper('DTT_Helper'); |
465 | 465 | $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
466 | 466 | } |
467 | 467 | |
468 | 468 | //let's make sure the base price is handled |
469 | - $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket( array(), $TKT, $update_prices, $base_price, $base_price_id ) : $TKT; |
|
469 | + $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket(array(), $TKT, $update_prices, $base_price, $base_price_id) : $TKT; |
|
470 | 470 | |
471 | 471 | //add/update price_modifiers |
472 | - $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket( $price_rows, $TKT, $update_prices ) : $TKT; |
|
472 | + $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket($price_rows, $TKT, $update_prices) : $TKT; |
|
473 | 473 | |
474 | 474 | //need to make sue that the TKT_price is accurate after saving the prices. |
475 | 475 | $TKT->ensure_TKT_Price_correct(); |
476 | 476 | |
477 | 477 | //handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave. |
478 | - if ( ! defined('DOING_AUTOSAVE' ) ) { |
|
479 | - if ( !empty($tkt['TKT_is_default_selector'] ) ) { |
|
478 | + if ( ! defined('DOING_AUTOSAVE')) { |
|
479 | + if ( ! empty($tkt['TKT_is_default_selector'])) { |
|
480 | 480 | $update_prices = TRUE; |
481 | 481 | $new_default = clone $TKT; |
482 | - $new_default->set( 'TKT_ID', 0 ); |
|
483 | - $new_default->set( 'TKT_is_default', 1 ); |
|
484 | - $new_default->set( 'TKT_row', 1 ); |
|
485 | - $new_default->set( 'TKT_price', $ticket_price ); |
|
482 | + $new_default->set('TKT_ID', 0); |
|
483 | + $new_default->set('TKT_is_default', 1); |
|
484 | + $new_default->set('TKT_row', 1); |
|
485 | + $new_default->set('TKT_price', $ticket_price); |
|
486 | 486 | //remove any dtt relations cause we DON'T want dtt relations attached (note this is just removing the cached relations in the object) |
487 | 487 | $new_default->_remove_relations('Datetime'); |
488 | 488 | //todo we need to add the current attached prices as new prices to the new default ticket. |
489 | - $new_default = $this->_add_prices_to_ticket( $price_rows, $new_default, $update_prices ); |
|
489 | + $new_default = $this->_add_prices_to_ticket($price_rows, $new_default, $update_prices); |
|
490 | 490 | //don't forget the base price! |
491 | - $new_default = $this->_add_prices_to_ticket( array(), $new_default, $update_prices, $base_price, $base_price_id ); |
|
491 | + $new_default = $this->_add_prices_to_ticket(array(), $new_default, $update_prices, $base_price, $base_price_id); |
|
492 | 492 | $new_default->save(); |
493 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default, $row, $TKT, $data ); |
|
493 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default, $row, $TKT, $data); |
|
494 | 494 | } |
495 | 495 | } |
496 | 496 | |
@@ -501,19 +501,19 @@ discard block |
||
501 | 501 | //let's assign any tickets that have been setup to the saved_tickets tracker |
502 | 502 | //save existing TKT |
503 | 503 | $TKT->save(); |
504 | - if ( $create_new_TKT && $new_tkt instanceof EE_Ticket ) { |
|
504 | + if ($create_new_TKT && $new_tkt instanceof EE_Ticket) { |
|
505 | 505 | //save new TKT |
506 | 506 | $new_tkt->save(); |
507 | 507 | //add new ticket to array |
508 | - $saved_tickets[ $new_tkt->ID() ] = $new_tkt; |
|
508 | + $saved_tickets[$new_tkt->ID()] = $new_tkt; |
|
509 | 509 | |
510 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data ); |
|
510 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data); |
|
511 | 511 | |
512 | 512 | } else { |
513 | 513 | //add tkt to saved tkts |
514 | - $saved_tickets[ $TKT->ID() ] = $TKT; |
|
514 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
515 | 515 | |
516 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data ); |
|
516 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data); |
|
517 | 517 | } |
518 | 518 | |
519 | 519 | } |
@@ -523,22 +523,22 @@ discard block |
||
523 | 523 | // (i.e. autosaves are happening and then in between autosaves the user trashes a ticket). |
524 | 524 | // Or a draft event was saved and in the process of editing a ticket is trashed. |
525 | 525 | // No sense in keeping all the related data in the db! |
526 | - $old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
527 | - $tickets_removed = array_diff( $old_tickets, array_keys($saved_tickets) ); |
|
526 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
527 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
528 | 528 | |
529 | - foreach ( $tickets_removed as $id ) { |
|
530 | - $id = absint( $id ); |
|
529 | + foreach ($tickets_removed as $id) { |
|
530 | + $id = absint($id); |
|
531 | 531 | |
532 | 532 | //get the ticket for this id |
533 | 533 | $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
534 | 534 | |
535 | 535 | //if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime |
536 | - if ( $tkt_to_remove->get('TKT_is_default') ) |
|
536 | + if ($tkt_to_remove->get('TKT_is_default')) |
|
537 | 537 | continue; |
538 | 538 | |
539 | 539 | // if this tkt has any registrations attached so then we just ARCHIVE |
540 | 540 | // because we don't actually permanently delete these tickets. |
541 | - if ( $tkt_to_remove->count_related('Registration') > 0 ) { |
|
541 | + if ($tkt_to_remove->count_related('Registration') > 0) { |
|
542 | 542 | $tkt_to_remove->delete(); |
543 | 543 | continue; |
544 | 544 | } |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | // (remember this process can ONLY kick off if there are NO tkts_sold) |
548 | 548 | $dtts = $tkt_to_remove->get_many_related('Datetime'); |
549 | 549 | |
550 | - foreach( $dtts as $dtt ) { |
|
550 | + foreach ($dtts as $dtt) { |
|
551 | 551 | $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
552 | 552 | } |
553 | 553 | |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | // tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived)) |
556 | 556 | $tkt_to_remove->delete_related_permanently('Price'); |
557 | 557 | |
558 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove ); |
|
558 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove); |
|
559 | 559 | |
560 | 560 | // finally let's delete this ticket |
561 | 561 | // (which should not be blocked at this point b/c we've removed all our relationships) |
@@ -587,39 +587,39 @@ discard block |
||
587 | 587 | // and removing the ticket from datetimes it got removed from. |
588 | 588 | |
589 | 589 | // first let's add datetimes |
590 | - if ( ! empty( $added_datetimes ) && is_array( $added_datetimes ) ) { |
|
591 | - foreach ( $added_datetimes as $row_id ) { |
|
592 | - $row_id = (int)$row_id; |
|
593 | - if ( isset( $saved_datetimes[ $row_id ] ) && $saved_datetimes[ $row_id ] instanceof EE_Datetime ) { |
|
594 | - $ticket->_add_relation_to( $saved_datetimes[ $row_id ], 'Datetime' ); |
|
590 | + if ( ! empty($added_datetimes) && is_array($added_datetimes)) { |
|
591 | + foreach ($added_datetimes as $row_id) { |
|
592 | + $row_id = (int) $row_id; |
|
593 | + if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) { |
|
594 | + $ticket->_add_relation_to($saved_datetimes[$row_id], 'Datetime'); |
|
595 | 595 | // Is this an existing ticket (has an ID) and does it have any sold? |
596 | 596 | // If so, then we need to add that to the DTT sold because this DTT is getting added. |
597 | - if ( $ticket->ID() && $ticket->sold() > 0 ) { |
|
598 | - $saved_datetimes[ $row_id ]->increase_sold( $ticket->sold() ); |
|
599 | - $saved_datetimes[ $row_id ]->save(); |
|
597 | + if ($ticket->ID() && $ticket->sold() > 0) { |
|
598 | + $saved_datetimes[$row_id]->increase_sold($ticket->sold()); |
|
599 | + $saved_datetimes[$row_id]->save(); |
|
600 | 600 | } |
601 | 601 | } |
602 | 602 | } |
603 | 603 | } |
604 | 604 | // then remove datetimes |
605 | - if ( ! empty( $removed_datetimes ) && is_array( $removed_datetimes ) ) { |
|
606 | - foreach ( $removed_datetimes as $row_id ) { |
|
607 | - $row_id = (int)$row_id; |
|
605 | + if ( ! empty($removed_datetimes) && is_array($removed_datetimes)) { |
|
606 | + foreach ($removed_datetimes as $row_id) { |
|
607 | + $row_id = (int) $row_id; |
|
608 | 608 | // its entirely possible that a datetime got deleted (instead of just removed from relationship. |
609 | 609 | // So make sure we skip over this if the dtt isn't in the $saved_datetimes array) |
610 | - if ( isset( $saved_datetimes[ $row_id ] ) && $saved_datetimes[ $row_id ] instanceof EE_Datetime ) { |
|
611 | - $ticket->_remove_relation_to( $saved_datetimes[ $row_id ], 'Datetime' ); |
|
610 | + if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) { |
|
611 | + $ticket->_remove_relation_to($saved_datetimes[$row_id], 'Datetime'); |
|
612 | 612 | // Is this an existing ticket (has an ID) and does it have any sold? |
613 | 613 | // If so, then we need to remove it's sold from the DTT_sold. |
614 | - if ( $ticket->ID() && $ticket->sold() > 0 ) { |
|
615 | - $saved_datetimes[ $row_id ]->decrease_sold( $ticket->sold() ); |
|
616 | - $saved_datetimes[ $row_id ]->save(); |
|
614 | + if ($ticket->ID() && $ticket->sold() > 0) { |
|
615 | + $saved_datetimes[$row_id]->decrease_sold($ticket->sold()); |
|
616 | + $saved_datetimes[$row_id]->save(); |
|
617 | 617 | } |
618 | 618 | } |
619 | 619 | } |
620 | 620 | } |
621 | 621 | // cap ticket qty by datetime reg limits |
622 | - $ticket->set_qty( min( $ticket->qty(), $ticket->qty( 'reg_limit' ) ) ); |
|
622 | + $ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit'))); |
|
623 | 623 | return $ticket; |
624 | 624 | } |
625 | 625 | |
@@ -640,39 +640,39 @@ discard block |
||
640 | 640 | EE_Ticket $ticket, |
641 | 641 | $price_rows = array(), |
642 | 642 | $ticket_price = 0, |
643 | - $base_price = 0 , |
|
643 | + $base_price = 0, |
|
644 | 644 | $base_price_id = 0 |
645 | 645 | ) { |
646 | 646 | |
647 | 647 | // create new ticket that's a copy of the existing |
648 | 648 | // except a new id of course (and not archived) |
649 | 649 | // AND has the new TKT_price associated with it. |
650 | - $new_ticket = clone( $ticket ); |
|
651 | - $new_ticket->set( 'TKT_ID', 0 ); |
|
652 | - $new_ticket->set( 'TKT_deleted', 0 ); |
|
653 | - $new_ticket->set( 'TKT_price', $ticket_price ); |
|
654 | - $new_ticket->set( 'TKT_sold', 0 ); |
|
650 | + $new_ticket = clone($ticket); |
|
651 | + $new_ticket->set('TKT_ID', 0); |
|
652 | + $new_ticket->set('TKT_deleted', 0); |
|
653 | + $new_ticket->set('TKT_price', $ticket_price); |
|
654 | + $new_ticket->set('TKT_sold', 0); |
|
655 | 655 | // let's get a new ID for this ticket |
656 | 656 | $new_ticket->save(); |
657 | 657 | // we also need to make sure this new ticket gets the same datetime attachments as the archived ticket |
658 | - $datetimes_on_existing = $ticket->get_many_related( 'Datetime' ); |
|
658 | + $datetimes_on_existing = $ticket->get_many_related('Datetime'); |
|
659 | 659 | $new_ticket = $this->_update_ticket_datetimes( |
660 | 660 | $new_ticket, |
661 | 661 | $datetimes_on_existing, |
662 | - array_keys( $datetimes_on_existing ) |
|
662 | + array_keys($datetimes_on_existing) |
|
663 | 663 | ); |
664 | 664 | |
665 | 665 | // $ticket will get archived later b/c we are NOT adding it to the saved_tickets array. |
666 | 666 | // if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining |
667 | 667 | // available. |
668 | - if ( $ticket->sold() > 0 ) { |
|
668 | + if ($ticket->sold() > 0) { |
|
669 | 669 | $new_qty = $ticket->qty() - $ticket->sold(); |
670 | - $new_ticket->set_qty( $new_qty ); |
|
670 | + $new_ticket->set_qty($new_qty); |
|
671 | 671 | } |
672 | 672 | //now we update the prices just for this ticket |
673 | - $new_ticket = $this->_add_prices_to_ticket( $price_rows, $new_ticket, true ); |
|
673 | + $new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true); |
|
674 | 674 | //and we update the base price |
675 | - $new_ticket = $this->_add_prices_to_ticket( array(), $new_ticket, true, $base_price, $base_price_id ); |
|
675 | + $new_ticket = $this->_add_prices_to_ticket(array(), $new_ticket, true, $base_price, $base_price_id); |
|
676 | 676 | return $new_ticket; |
677 | 677 | } |
678 | 678 | |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | * @param int|bool $base_price_id if present then this is the base_price_id being updated. |
693 | 693 | * @return EE_Ticket |
694 | 694 | */ |
695 | - protected function _add_prices_to_ticket( $prices = array(), EE_Ticket $ticket, $new_prices = FALSE, $base_price = FALSE, $base_price_id = FALSE ) { |
|
695 | + protected function _add_prices_to_ticket($prices = array(), EE_Ticket $ticket, $new_prices = FALSE, $base_price = FALSE, $base_price_id = FALSE) { |
|
696 | 696 | |
697 | 697 | //let's just get any current prices that may exist on the given ticket so we can remove any prices that got trashed in this session. |
698 | 698 | $current_prices_on_ticket = $base_price !== FALSE ? $ticket->base_price(TRUE) : $ticket->price_modifiers(); |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | $updated_prices = array(); |
701 | 701 | |
702 | 702 | // if $base_price ! FALSE then updating a base price. |
703 | - if ( $base_price !== FALSE ) { |
|
703 | + if ($base_price !== FALSE) { |
|
704 | 704 | $prices[1] = array( |
705 | 705 | 'PRC_ID' => $new_prices || $base_price_id === 1 ? NULL : $base_price_id, |
706 | 706 | 'PRT_ID' => 1, |
@@ -711,47 +711,47 @@ discard block |
||
711 | 711 | } |
712 | 712 | |
713 | 713 | //possibly need to save tkt |
714 | - if ( ! $ticket->ID() ) |
|
714 | + if ( ! $ticket->ID()) |
|
715 | 715 | $ticket->save(); |
716 | 716 | |
717 | - foreach ( $prices as $row => $prc ) { |
|
718 | - $prt_id = !empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : NULL; |
|
719 | - if ( empty($prt_id) ) |
|
717 | + foreach ($prices as $row => $prc) { |
|
718 | + $prt_id = ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : NULL; |
|
719 | + if (empty($prt_id)) |
|
720 | 720 | continue; //prices MUST have a price type id. |
721 | 721 | $PRC_values = array( |
722 | - 'PRC_ID' => !empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : NULL, |
|
722 | + 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : NULL, |
|
723 | 723 | 'PRT_ID' => $prt_id, |
724 | - 'PRC_amount' => !empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0, |
|
725 | - 'PRC_name' => !empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '', |
|
726 | - 'PRC_desc' => !empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '', |
|
724 | + 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
725 | + 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
726 | + 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
727 | 727 | 'PRC_is_default' => false, //make sure we set PRC_is_default to false for all ticket saves from event_editor |
728 | 728 | 'PRC_order' => $row |
729 | 729 | ); |
730 | - if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) { |
|
730 | + if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
731 | 731 | $PRC_values['PRC_ID'] = 0; |
732 | - $PRC = EE_Registry::instance()->load_class('Price', array( $PRC_values ), FALSE, FALSE); |
|
732 | + $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), FALSE, FALSE); |
|
733 | 733 | } else { |
734 | - $PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] ); |
|
734 | + $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
735 | 735 | //update this price with new values |
736 | - foreach ( $PRC_values as $field => $newprc ) { |
|
737 | - $PRC->set( $field, $newprc ); |
|
736 | + foreach ($PRC_values as $field => $newprc) { |
|
737 | + $PRC->set($field, $newprc); |
|
738 | 738 | } |
739 | 739 | } |
740 | 740 | $PRC->save(); |
741 | 741 | $prcid = $PRC->ID(); |
742 | 742 | $updated_prices[$prcid] = $PRC; |
743 | - $ticket->_add_relation_to( $PRC, 'Price' ); |
|
743 | + $ticket->_add_relation_to($PRC, 'Price'); |
|
744 | 744 | } |
745 | 745 | |
746 | 746 | //now let's remove any prices that got removed from the ticket |
747 | - if ( !empty ( $current_prices_on_ticket ) ) { |
|
747 | + if ( ! empty ($current_prices_on_ticket)) { |
|
748 | 748 | $current = array_keys($current_prices_on_ticket); |
749 | 749 | $updated = array_keys($updated_prices); |
750 | 750 | $prices_to_remove = array_diff($current, $updated); |
751 | - if ( !empty( $prices_to_remove ) ) { |
|
752 | - foreach ( $prices_to_remove as $prc_id ) { |
|
751 | + if ( ! empty($prices_to_remove)) { |
|
752 | + foreach ($prices_to_remove as $prc_id) { |
|
753 | 753 | $p = $current_prices_on_ticket[$prc_id]; |
754 | - $ticket->_remove_relation_to( $p, 'Price' ); |
|
754 | + $ticket->_remove_relation_to($p, 'Price'); |
|
755 | 755 | |
756 | 756 | //delete permanently the price |
757 | 757 | $p->delete_permanently(); |
@@ -764,7 +764,7 @@ discard block |
||
764 | 764 | |
765 | 765 | |
766 | 766 | |
767 | - public function autosave_handling( $event_admin_obj ) { |
|
767 | + public function autosave_handling($event_admin_obj) { |
|
768 | 768 | return $event_admin_obj; //doing nothing for the moment. |
769 | 769 | //todo when I get to this remember that I need to set the template args on the $event_admin_obj (use the set_template_args() method) |
770 | 770 | |
@@ -798,12 +798,12 @@ discard block |
||
798 | 798 | |
799 | 799 | //default main template args |
800 | 800 | $main_template_args = array( |
801 | - 'event_datetime_help_link' => EEH_Template::get_help_tab_link('event_editor_event_datetimes_help_tab', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add a filter to the template for the help text in the Events_Admin_Page core file so we can add further help |
|
801 | + 'event_datetime_help_link' => EEH_Template::get_help_tab_link('event_editor_event_datetimes_help_tab', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add a filter to the template for the help text in the Events_Admin_Page core file so we can add further help |
|
802 | 802 | 'existing_datetime_ids' => '', |
803 | 803 | 'total_dtt_rows' => 1, |
804 | - 'add_new_dtt_help_link' => EEH_Template::get_help_tab_link('add_new_dtt_info', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
804 | + 'add_new_dtt_help_link' => EEH_Template::get_help_tab_link('add_new_dtt_info', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
805 | 805 | 'datetime_rows' => '', |
806 | - 'show_tickets_container' => '',//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '', |
|
806 | + 'show_tickets_container' => '', //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '', |
|
807 | 807 | 'ticket_rows' => '', |
808 | 808 | 'existing_ticket_ids' => '', |
809 | 809 | 'total_ticket_rows' => 1, |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | |
814 | 814 | $timezone = $evtobj instanceof EE_Event ? $evtobj->timezone_string() : NULL; |
815 | 815 | |
816 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
816 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
817 | 817 | |
818 | 818 | /** |
819 | 819 | * 1. Start with retrieving Datetimes |
@@ -821,37 +821,37 @@ discard block |
||
821 | 821 | * 3. For each ticket get related prices |
822 | 822 | */ |
823 | 823 | |
824 | - $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone) ); |
|
825 | - $times = $DTM->get_all_event_dates( $evtID ); |
|
824 | + $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone)); |
|
825 | + $times = $DTM->get_all_event_dates($evtID); |
|
826 | 826 | |
827 | 827 | |
828 | 828 | |
829 | 829 | $main_template_args['total_dtt_rows'] = count($times); |
830 | - foreach ( $times as $time ) { |
|
830 | + foreach ($times as $time) { |
|
831 | 831 | $dttid = $time->get('DTT_ID'); |
832 | 832 | $dttrow = $time->get('DTT_order'); |
833 | 833 | $existing_datetime_ids[] = $dttid; |
834 | 834 | |
835 | 835 | //tickets attached |
836 | - $related_tickets = $time->ID() > 0 ? $time->get_many_related('Ticket', array( array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ), 'default_where_conditions' => 'none', 'order_by' => array('TKT_order' => 'ASC' ) ) ) : array(); |
|
836 | + $related_tickets = $time->ID() > 0 ? $time->get_many_related('Ticket', array(array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), 'default_where_conditions' => 'none', 'order_by' => array('TKT_order' => 'ASC'))) : array(); |
|
837 | 837 | |
838 | 838 | //if there are no related tickets this is likely a new event OR autodraft |
839 | 839 | // event so we need to generate the default tickets because dtts |
840 | 840 | // ALWAYS have at least one related ticket!!. EXCEPT, we dont' do this if there is already more than one |
841 | 841 | // datetime on the event. |
842 | - if ( empty ( $related_tickets ) && count( $times ) < 2 ) { |
|
842 | + if (empty ($related_tickets) && count($times) < 2) { |
|
843 | 843 | $related_tickets = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
844 | 844 | |
845 | 845 | //this should be ordered by TKT_ID, so let's grab the first default ticket (which will be the main default) and ensure it has any default prices added to it (but do NOT save). |
846 | 846 | $default_prices = EEM_Price::instance()->get_all_default_prices(); |
847 | 847 | |
848 | - $main_default_ticket = reset( $related_tickets ); |
|
849 | - if ( $main_default_ticket instanceof EE_Ticket ) { |
|
850 | - foreach ( $default_prices as $default_price ) { |
|
851 | - if ( $default_price->is_base_price() ) { |
|
848 | + $main_default_ticket = reset($related_tickets); |
|
849 | + if ($main_default_ticket instanceof EE_Ticket) { |
|
850 | + foreach ($default_prices as $default_price) { |
|
851 | + if ($default_price->is_base_price()) { |
|
852 | 852 | continue; |
853 | 853 | } |
854 | - $main_default_ticket->cache( 'Price', $default_price ); |
|
854 | + $main_default_ticket->cache('Price', $default_price); |
|
855 | 855 | } |
856 | 856 | } |
857 | 857 | } |
@@ -860,11 +860,11 @@ discard block |
||
860 | 860 | //we can't actually setup rows in this loop yet cause we don't know all the unique tickets for this event yet (tickets are linked through all datetimes). So we're going to temporarily cache some of that information. |
861 | 861 | |
862 | 862 | //loop through and setup the ticket rows and make sure the order is set. |
863 | - foreach ( $related_tickets as $ticket ) { |
|
863 | + foreach ($related_tickets as $ticket) { |
|
864 | 864 | $tktid = $ticket->get('TKT_ID'); |
865 | 865 | $tktrow = $ticket->get('TKT_row'); |
866 | 866 | //we only want unique tickets in our final display!! |
867 | - if ( !in_array( $tktid, $existing_ticket_ids ) ) { |
|
867 | + if ( ! in_array($tktid, $existing_ticket_ids)) { |
|
868 | 868 | $existing_ticket_ids[] = $tktid; |
869 | 869 | $all_tickets[] = $ticket; |
870 | 870 | } |
@@ -873,56 +873,56 @@ discard block |
||
873 | 873 | $datetime_tickets[$dttid][] = $tktrow; |
874 | 874 | |
875 | 875 | //temporary cache of this datetime info for this ticket for later processing of ticket rows. |
876 | - if ( !isset( $ticket_datetimes[$tktid] ) || ! in_array( $dttrow, $ticket_datetimes[$tktid] ) ) |
|
876 | + if ( ! isset($ticket_datetimes[$tktid]) || ! in_array($dttrow, $ticket_datetimes[$tktid])) |
|
877 | 877 | $ticket_datetimes[$tktid][] = $dttrow; |
878 | 878 | } |
879 | 879 | } |
880 | 880 | |
881 | - $main_template_args['total_ticket_rows'] = count( $existing_ticket_ids ); |
|
882 | - $main_template_args['existing_ticket_ids'] = implode( ',', $existing_ticket_ids ); |
|
883 | - $main_template_args['existing_datetime_ids'] = implode( ',', $existing_datetime_ids ); |
|
881 | + $main_template_args['total_ticket_rows'] = count($existing_ticket_ids); |
|
882 | + $main_template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
|
883 | + $main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
|
884 | 884 | |
885 | 885 | //sort $all_tickets by order |
886 | - usort( $all_tickets, function( $a, $b ) { |
|
886 | + usort($all_tickets, function($a, $b) { |
|
887 | 887 | $a_order = (int) $a->get('TKT_order'); |
888 | 888 | $b_order = (int) $b->get('TKT_order'); |
889 | - if ( $a_order == $b_order ) { |
|
889 | + if ($a_order == $b_order) { |
|
890 | 890 | return 0; |
891 | 891 | } |
892 | - return ( $a_order < $b_order ) ? -1 : 1; |
|
892 | + return ($a_order < $b_order) ? -1 : 1; |
|
893 | 893 | }); |
894 | 894 | |
895 | 895 | //k NOW we have all the data we need for setting up the dtt rows and ticket rows so we start our dtt loop again. |
896 | 896 | $dttrow = 1; |
897 | - foreach ( $times as $time ) { |
|
898 | - $main_template_args['datetime_rows'] .= $this->_get_datetime_row( $dttrow, $time, $datetime_tickets, $all_tickets, FALSE, $times ); |
|
897 | + foreach ($times as $time) { |
|
898 | + $main_template_args['datetime_rows'] .= $this->_get_datetime_row($dttrow, $time, $datetime_tickets, $all_tickets, FALSE, $times); |
|
899 | 899 | $dttrow++; |
900 | 900 | } |
901 | 901 | |
902 | 902 | //then loop through all tickets for the ticket rows. |
903 | 903 | $tktrow = 1; |
904 | - foreach ( $all_tickets as $ticket ) { |
|
905 | - $main_template_args['ticket_rows'] .= $this->_get_ticket_row( $tktrow, $ticket, $ticket_datetimes, $times, FALSE, $all_tickets ); |
|
904 | + foreach ($all_tickets as $ticket) { |
|
905 | + $main_template_args['ticket_rows'] .= $this->_get_ticket_row($tktrow, $ticket, $ticket_datetimes, $times, FALSE, $all_tickets); |
|
906 | 906 | $tktrow++; |
907 | 907 | } |
908 | 908 | |
909 | 909 | $main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($times, $all_tickets); |
910 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'; |
|
911 | - EEH_Template::display_template( $template, $main_template_args ); |
|
910 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_metabox_main.template.php'; |
|
911 | + EEH_Template::display_template($template, $main_template_args); |
|
912 | 912 | return; |
913 | 913 | } |
914 | 914 | |
915 | 915 | |
916 | 916 | |
917 | - protected function _get_datetime_row( $dttrow, EE_Datetime $dtt, $datetime_tickets, $all_tickets, $default = FALSE, $all_dtts = array() ) { |
|
917 | + protected function _get_datetime_row($dttrow, EE_Datetime $dtt, $datetime_tickets, $all_tickets, $default = FALSE, $all_dtts = array()) { |
|
918 | 918 | |
919 | 919 | $dtt_display_template_args = array( |
920 | - 'dtt_edit_row' => $this->_get_dtt_edit_row( $dttrow, $dtt, $default, $all_dtts ), |
|
921 | - 'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row( $dttrow, $dtt, $datetime_tickets, $all_tickets, $default ), |
|
920 | + 'dtt_edit_row' => $this->_get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts), |
|
921 | + 'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default), |
|
922 | 922 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow |
923 | 923 | ); |
924 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php'; |
|
925 | - return EEH_Template::display_template( $template, $dtt_display_template_args, TRUE); |
|
924 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_row_wrapper.template.php'; |
|
925 | + return EEH_Template::display_template($template, $dtt_display_template_args, TRUE); |
|
926 | 926 | } |
927 | 927 | |
928 | 928 | |
@@ -940,7 +940,7 @@ discard block |
||
940 | 940 | * |
941 | 941 | * @return string Generated edit row. |
942 | 942 | */ |
943 | - protected function _get_dtt_edit_row( $dttrow, $dtt, $default, $all_dtts ) { |
|
943 | + protected function _get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts) { |
|
944 | 944 | |
945 | 945 | // if the incomign $dtt object is NOT an instance of EE_Datetime then force default to true. |
946 | 946 | $default = ! $dtt instanceof EE_Datetime ? true : false; |
@@ -948,30 +948,30 @@ discard block |
||
948 | 948 | $template_args = array( |
949 | 949 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow, |
950 | 950 | 'event_datetimes_name' => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes', |
951 | - 'edit_dtt_expanded' => '',//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing', |
|
951 | + 'edit_dtt_expanded' => '', //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing', |
|
952 | 952 | 'DTT_ID' => $default ? '' : $dtt->ID(), |
953 | 953 | 'DTT_name' => $default ? '' : $dtt->name(), |
954 | 954 | 'DTT_description' => $default ? '' : $dtt->description(), |
955 | - 'DTT_EVT_start' => $default ? '' : $dtt->start_date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
956 | - 'DTT_EVT_end' => $default ? '' : $dtt->end_date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
957 | - 'DTT_reg_limit' => $default ? '' : $dtt->get_pretty('DTT_reg_limit','input'), |
|
955 | + 'DTT_EVT_start' => $default ? '' : $dtt->start_date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
956 | + 'DTT_EVT_end' => $default ? '' : $dtt->end_date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
957 | + 'DTT_reg_limit' => $default ? '' : $dtt->get_pretty('DTT_reg_limit', 'input'), |
|
958 | 958 | 'DTT_order' => $default ? 'DTTNUM' : $dttrow, |
959 | 959 | 'dtt_sold' => $default ? '0' : $dtt->get('DTT_sold'), |
960 | - 'clone_icon' => !empty( $dtt ) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable', |
|
961 | - 'trash_icon' => !empty( $dtt ) && $dtt->get('DTT_sold') > 0 ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable' |
|
960 | + 'clone_icon' => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable', |
|
961 | + 'trash_icon' => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable' |
|
962 | 962 | ); |
963 | 963 | |
964 | - $template_args['show_trash'] = count( $all_dtts ) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
964 | + $template_args['show_trash'] = count($all_dtts) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
965 | 965 | |
966 | 966 | //allow filtering of template args at this point. |
967 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args', $template_args, $dttrow, $dtt, $default, $all_dtts, $this->_is_creating_event ); |
|
967 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args', $template_args, $dttrow, $dtt, $default, $all_dtts, $this->_is_creating_event); |
|
968 | 968 | |
969 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php'; |
|
970 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
969 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_edit_row.template.php'; |
|
970 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
971 | 971 | } |
972 | 972 | |
973 | 973 | |
974 | - protected function _get_dtt_attached_tickets_row( $dttrow, $dtt, $datetime_tickets, $all_tickets, $default ) { |
|
974 | + protected function _get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default) { |
|
975 | 975 | |
976 | 976 | $template_args = array( |
977 | 977 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow, |
@@ -979,47 +979,47 @@ discard block |
||
979 | 979 | 'DTT_description' => $default ? '' : $dtt->description(), |
980 | 980 | 'datetime_tickets_list' => $default ? '<li class="hidden"></li>' : '', |
981 | 981 | 'show_tickets_row' => ' style="display:none;"', //$default || $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' style="display:none;"' : '', |
982 | - 'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link('add_new_ticket_via_datetime', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
982 | + 'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link('add_new_ticket_via_datetime', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
983 | 983 | 'DTT_ID' => $default ? '' : $dtt->ID() |
984 | 984 | ); |
985 | 985 | |
986 | 986 | //need to setup the list items (but only if this isnt' a default skeleton setup) |
987 | - if ( !$default ) { |
|
987 | + if ( ! $default) { |
|
988 | 988 | $tktrow = 1; |
989 | - foreach ( $all_tickets as $ticket ) { |
|
990 | - $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default ); |
|
989 | + foreach ($all_tickets as $ticket) { |
|
990 | + $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default); |
|
991 | 991 | $tktrow++; |
992 | 992 | } |
993 | 993 | } |
994 | 994 | |
995 | 995 | //filter template args at this point |
996 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args', $template_args, $dttrow, $dtt, $datetime_tickets, $all_tickets, $default, $this->_is_creating_event ); |
|
996 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args', $template_args, $dttrow, $dtt, $datetime_tickets, $all_tickets, $default, $this->_is_creating_event); |
|
997 | 997 | |
998 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php'; |
|
999 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
998 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_attached_tickets_row.template.php'; |
|
999 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1000 | 1000 | } |
1001 | 1001 | |
1002 | 1002 | |
1003 | 1003 | |
1004 | - protected function _get_datetime_tickets_list_item( $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default ) { |
|
1005 | - $tktid = !empty( $ticket ) ? $ticket->ID() : 0; |
|
1006 | - $dtt_tkts = $dtt instanceof EE_Datetime && isset( $datetime_tickets[$dtt->ID()] ) ? $datetime_tickets[$dtt->ID()] : array(); |
|
1004 | + protected function _get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default) { |
|
1005 | + $tktid = ! empty($ticket) ? $ticket->ID() : 0; |
|
1006 | + $dtt_tkts = $dtt instanceof EE_Datetime && isset($datetime_tickets[$dtt->ID()]) ? $datetime_tickets[$dtt->ID()] : array(); |
|
1007 | 1007 | |
1008 | - $displayrow = !empty( $ticket ) ? $ticket->get('TKT_row') : 0; |
|
1008 | + $displayrow = ! empty($ticket) ? $ticket->get('TKT_row') : 0; |
|
1009 | 1009 | $template_args = array( |
1010 | 1010 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow, |
1011 | - 'tkt_row' => $default && empty( $ticket ) ? 'TICKETNUM' : $tktrow, |
|
1011 | + 'tkt_row' => $default && empty($ticket) ? 'TICKETNUM' : $tktrow, |
|
1012 | 1012 | 'datetime_ticket_checked' => in_array($displayrow, $dtt_tkts) ? ' checked="checked"' : '', |
1013 | 1013 | 'ticket_selected' => in_array($displayrow, $dtt_tkts) ? ' ticket-selected' : '', |
1014 | - 'TKT_name' => $default && empty( $ticket ) ? 'TKTNAME' : $ticket->get('TKT_name'), |
|
1015 | - 'tkt_status_class' => ( $default && empty( $ticket ) ) || $this->_is_creating_event ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status(), |
|
1014 | + 'TKT_name' => $default && empty($ticket) ? 'TKTNAME' : $ticket->get('TKT_name'), |
|
1015 | + 'tkt_status_class' => ($default && empty($ticket)) || $this->_is_creating_event ? ' tkt-status-'.EE_Ticket::onsale : ' tkt-status-'.$ticket->ticket_status(), |
|
1016 | 1016 | ); |
1017 | 1017 | |
1018 | 1018 | //filter template args |
1019 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default, $this->_is_creating_event ); |
|
1019 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default, $this->_is_creating_event); |
|
1020 | 1020 | |
1021 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php'; |
|
1022 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1021 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_dtt_tickets_list.template.php'; |
|
1022 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1023 | 1023 | } |
1024 | 1024 | |
1025 | 1025 | |
@@ -1041,37 +1041,37 @@ discard block |
||
1041 | 1041 | * |
1042 | 1042 | * @return [type] [description] |
1043 | 1043 | */ |
1044 | - protected function _get_ticket_row( $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default = FALSE, $all_tickets = array() ) { |
|
1044 | + protected function _get_ticket_row($tktrow, $ticket, $ticket_datetimes, $all_dtts, $default = FALSE, $all_tickets = array()) { |
|
1045 | 1045 | |
1046 | 1046 | //if $ticket is not an instance of EE_Ticket then force default to true. |
1047 | - $default = ! $ticket instanceof EE_Ticket ? true : false; |
|
1047 | + $default = ! $ticket instanceof EE_Ticket ? true : false; |
|
1048 | 1048 | |
1049 | - $prices = ! empty( $ticket ) && ! $default ? $ticket->get_many_related('Price', array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC') ) ) : array(); |
|
1049 | + $prices = ! empty($ticket) && ! $default ? $ticket->get_many_related('Price', array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))) : array(); |
|
1050 | 1050 | |
1051 | 1051 | //if there is only one price (which would be the base price) or NO prices and this ticket is a default ticket, let's just make sure there are no cached default prices on |
1052 | 1052 | //the object. This is done by not including any query_params. |
1053 | - if ( $ticket instanceof EE_Ticket && $ticket->is_default() && ( count( $prices ) === 1 || empty( $prices ) ) ) { |
|
1054 | - $prices = $ticket->get_many_related( 'Price' ); |
|
1053 | + if ($ticket instanceof EE_Ticket && $ticket->is_default() && (count($prices) === 1 || empty($prices))) { |
|
1054 | + $prices = $ticket->get_many_related('Price'); |
|
1055 | 1055 | } |
1056 | 1056 | |
1057 | 1057 | // check if we're dealing with a default ticket in which case we don't want any starting_ticket_datetime_row values set (otherwise there won't be any new relationships created for tickets based off of the default ticket). This will future proof in case there is ever any behaviour change between what the primary_key defaults to. |
1058 | - $default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default') ) ? TRUE : FALSE; |
|
1058 | + $default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default')) ? TRUE : FALSE; |
|
1059 | 1059 | |
1060 | - $tkt_dtts = $ticket instanceof EE_Ticket && isset( $ticket_datetimes[$ticket->ID()] ) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1060 | + $tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1061 | 1061 | |
1062 | 1062 | $ticket_subtotal = $default ? 0 : $ticket->get_ticket_subtotal(); |
1063 | - $base_price = $default ? NULL : $ticket->base_price(); |
|
1063 | + $base_price = $default ? NULL : $ticket->base_price(); |
|
1064 | 1064 | $count_price_mods = EEM_Price::instance()->get_all_default_prices(TRUE); |
1065 | 1065 | |
1066 | 1066 | //breaking out complicated condition for ticket_status |
1067 | - if ( $default ) { |
|
1068 | - $ticket_status_class = ' tkt-status-' . EE_Ticket::onsale; |
|
1067 | + if ($default) { |
|
1068 | + $ticket_status_class = ' tkt-status-'.EE_Ticket::onsale; |
|
1069 | 1069 | } else { |
1070 | - $ticket_status_class = $ticket->is_default() ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status(); |
|
1070 | + $ticket_status_class = $ticket->is_default() ? ' tkt-status-'.EE_Ticket::onsale : ' tkt-status-'.$ticket->ticket_status(); |
|
1071 | 1071 | } |
1072 | 1072 | |
1073 | 1073 | //breaking out complicated condition for TKT_taxable |
1074 | - if ( $default ) { |
|
1074 | + if ($default) { |
|
1075 | 1075 | $TKT_taxable = ''; |
1076 | 1076 | } else { |
1077 | 1077 | $TKT_taxable = $ticket->get('TKT_taxable') ? ' checked="checked"' : ''; |
@@ -1086,19 +1086,19 @@ discard block |
||
1086 | 1086 | 'edit_tkt_expanded' => '', |
1087 | 1087 | 'edit_tickets_name' => $default ? 'TICKETNAMEATTR' : 'edit_tickets', |
1088 | 1088 | 'TKT_name' => $default ? '' : $ticket->get('TKT_name'), |
1089 | - 'TKT_start_date' => $default ? '' : $ticket->get_date('TKT_start_date', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
1090 | - 'TKT_end_date' => $default ? '' : $ticket->get_date('TKT_end_date', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
1091 | - 'TKT_status' => $default ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->is_default() ? EEH_Template::pretty_status( EE_Ticket::onsale, FALSE, 'sentence') : $ticket->ticket_status(TRUE), |
|
1089 | + 'TKT_start_date' => $default ? '' : $ticket->get_date('TKT_start_date', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
1090 | + 'TKT_end_date' => $default ? '' : $ticket->get_date('TKT_end_date', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
1091 | + 'TKT_status' => $default ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->is_default() ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->ticket_status(TRUE), |
|
1092 | 1092 | 'TKT_price' => $default ? '' : EEH_Template::format_currency($ticket->get_ticket_total_with_taxes(), FALSE, FALSE), |
1093 | 1093 | 'TKT_price_code' => EE_Registry::instance()->CFG->currency->code, |
1094 | 1094 | 'TKT_price_amount' => $default ? 0 : $ticket_subtotal, |
1095 | - 'TKT_qty' => $default ? '' : $ticket->get_pretty('TKT_qty','symbol'), |
|
1096 | - 'TKT_qty_for_input'=> $default ? '' : $ticket->get_pretty('TKT_qty','input'), |
|
1097 | - 'TKT_uses' => $default ? '' : $ticket->get_pretty('TKT_uses','input'), |
|
1098 | - 'TKT_min' => $default ? '' : ( $ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min') ), |
|
1099 | - 'TKT_max' => $default ? '' : $ticket->get_pretty('TKT_max','input'), |
|
1095 | + 'TKT_qty' => $default ? '' : $ticket->get_pretty('TKT_qty', 'symbol'), |
|
1096 | + 'TKT_qty_for_input'=> $default ? '' : $ticket->get_pretty('TKT_qty', 'input'), |
|
1097 | + 'TKT_uses' => $default ? '' : $ticket->get_pretty('TKT_uses', 'input'), |
|
1098 | + 'TKT_min' => $default ? '' : ($ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min')), |
|
1099 | + 'TKT_max' => $default ? '' : $ticket->get_pretty('TKT_max', 'input'), |
|
1100 | 1100 | 'TKT_sold' => $default ? 0 : $ticket->tickets_sold('ticket'), |
1101 | - 'TKT_registrations' => $default ? 0 : $ticket->count_registrations( array( array( 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) ) ) ), |
|
1101 | + 'TKT_registrations' => $default ? 0 : $ticket->count_registrations(array(array('STS_ID' => array('!=', EEM_Registration::status_id_incomplete)))), |
|
1102 | 1102 | 'TKT_ID' => $default ? 0 : $ticket->get('TKT_ID'), |
1103 | 1103 | 'TKT_description' => $default ? '' : $ticket->get('TKT_description'), |
1104 | 1104 | 'TKT_is_default' => $default ? 0 : $ticket->get('TKT_is_default'), |
@@ -1107,99 +1107,99 @@ discard block |
||
1107 | 1107 | 'ticket_price_rows' => '', |
1108 | 1108 | 'TKT_base_price' => $default || ! $base_price instanceof EE_Price ? '' : $base_price->get_pretty('PRC_amount', 'localized_float'), |
1109 | 1109 | 'TKT_base_price_ID' => $default || ! $base_price instanceof EE_Price ? 0 : $base_price->ID(), |
1110 | - 'show_price_modifier' => count($prices) > 1 || ( $default && $count_price_mods > 0 ) ? '' : ' style="display:none;"', |
|
1111 | - 'show_price_mod_button' => count($prices) > 1 || ( $default && $count_price_mods > 0 ) || ( !$default && $ticket->get('TKT_deleted') ) ? ' style="display:none;"' : '', |
|
1110 | + 'show_price_modifier' => count($prices) > 1 || ($default && $count_price_mods > 0) ? '' : ' style="display:none;"', |
|
1111 | + 'show_price_mod_button' => count($prices) > 1 || ($default && $count_price_mods > 0) || ( ! $default && $ticket->get('TKT_deleted')) ? ' style="display:none;"' : '', |
|
1112 | 1112 | 'total_price_rows' => count($prices) > 1 ? count($prices) : 1, |
1113 | 1113 | 'ticket_datetimes_list' => $default ? '<li class="hidden"></li>' : '', |
1114 | 1114 | 'starting_ticket_datetime_rows' => $default || $default_dtt ? '' : implode(',', $tkt_dtts), |
1115 | 1115 | 'ticket_datetime_rows' => $default ? '' : implode(',', $tkt_dtts), |
1116 | - 'existing_ticket_price_ids' => $default, '', implode(',', array_keys( $prices) ), |
|
1116 | + 'existing_ticket_price_ids' => $default, '', implode(',', array_keys($prices)), |
|
1117 | 1117 | 'ticket_template_id' => $default ? 0 : $ticket->get('TTM_ID'), |
1118 | 1118 | 'TKT_taxable' => $TKT_taxable, |
1119 | 1119 | 'display_subtotal' => $ticket instanceof EE_Ticket && $ticket->get('TKT_taxable') ? '' : ' style="display:none"', |
1120 | 1120 | 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
1121 | - 'TKT_subtotal_amount_display' => EEH_Template::format_currency($ticket_subtotal, FALSE, FALSE ), |
|
1121 | + 'TKT_subtotal_amount_display' => EEH_Template::format_currency($ticket_subtotal, FALSE, FALSE), |
|
1122 | 1122 | 'TKT_subtotal_amount' => $ticket_subtotal, |
1123 | - 'tax_rows' => $this->_get_tax_rows( $tktrow, $ticket ), |
|
1124 | - 'disabled' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? TRUE: FALSE, |
|
1123 | + 'tax_rows' => $this->_get_tax_rows($tktrow, $ticket), |
|
1124 | + 'disabled' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? TRUE : FALSE, |
|
1125 | 1125 | 'ticket_archive_class' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? ' ticket-archived' : '', |
1126 | 1126 | 'trash_icon' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? 'ee-lock-icon ' : 'trash-icon dashicons dashicons-post-trash clickable', |
1127 | 1127 | 'clone_icon' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? '' : 'clone-icon ee-icon ee-icon-clone clickable' |
1128 | 1128 | ); |
1129 | 1129 | |
1130 | - $template_args['trash_hidden'] = count( $all_tickets ) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
1130 | + $template_args['trash_hidden'] = count($all_tickets) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
1131 | 1131 | |
1132 | 1132 | //handle rows that should NOT be empty |
1133 | - if ( empty( $template_args['TKT_start_date'] ) ) { |
|
1133 | + if (empty($template_args['TKT_start_date'])) { |
|
1134 | 1134 | //if empty then the start date will be now. |
1135 | - $template_args['TKT_start_date'] = date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] , current_time('timestamp')); |
|
1136 | - $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale; |
|
1135 | + $template_args['TKT_start_date'] = date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time'], current_time('timestamp')); |
|
1136 | + $template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale; |
|
1137 | 1137 | } |
1138 | 1138 | |
1139 | - if ( empty( $template_args['TKT_end_date'] ) ) { |
|
1139 | + if (empty($template_args['TKT_end_date'])) { |
|
1140 | 1140 | |
1141 | 1141 | //get the earliest datetime (if present); |
1142 | - $earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL; |
|
1142 | + $earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC'))) : NULL; |
|
1143 | 1143 | |
1144 | - if ( !empty( $earliest_dtt ) ) { |
|
1145 | - $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ); |
|
1144 | + if ( ! empty($earliest_dtt)) { |
|
1145 | + $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']); |
|
1146 | 1146 | } else { |
1147 | 1147 | //default so let's just use what's been set for the default date-time which is 30 days from now. |
1148 | - $template_args['TKT_end_date'] = date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] , mktime(24, 0, 0, date("m"), date("d") + 29, date("Y") ) ); |
|
1148 | + $template_args['TKT_end_date'] = date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time'], mktime(24, 0, 0, date("m"), date("d") + 29, date("Y"))); |
|
1149 | 1149 | } |
1150 | - $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale; |
|
1150 | + $template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale; |
|
1151 | 1151 | } |
1152 | 1152 | |
1153 | 1153 | //generate ticket_datetime items |
1154 | - if ( ! $default ) { |
|
1154 | + if ( ! $default) { |
|
1155 | 1155 | $dttrow = 1; |
1156 | - foreach ( $all_dtts as $dtt ) { |
|
1157 | - $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default ); |
|
1156 | + foreach ($all_dtts as $dtt) { |
|
1157 | + $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default); |
|
1158 | 1158 | $dttrow++; |
1159 | 1159 | } |
1160 | 1160 | } |
1161 | 1161 | |
1162 | 1162 | $prcrow = 1; |
1163 | - foreach ( $prices as $price ) { |
|
1164 | - if ( $price->is_base_price() ) { |
|
1163 | + foreach ($prices as $price) { |
|
1164 | + if ($price->is_base_price()) { |
|
1165 | 1165 | $prcrow++; |
1166 | 1166 | continue; |
1167 | 1167 | } |
1168 | - $show_trash = ( count( $prices ) > 1 && $prcrow === 1 ) || count( $prices ) === 1 ? FALSE : TRUE; |
|
1169 | - $show_create = count( $prices ) > 1 && count( $prices ) !== $prcrow ? FALSE : TRUE; |
|
1170 | - $template_args['ticket_price_rows'] .= $this->_get_ticket_price_row( $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create ); |
|
1168 | + $show_trash = (count($prices) > 1 && $prcrow === 1) || count($prices) === 1 ? FALSE : TRUE; |
|
1169 | + $show_create = count($prices) > 1 && count($prices) !== $prcrow ? FALSE : TRUE; |
|
1170 | + $template_args['ticket_price_rows'] .= $this->_get_ticket_price_row($tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create); |
|
1171 | 1171 | $prcrow++; |
1172 | 1172 | } |
1173 | 1173 | |
1174 | 1174 | //filter $template_args |
1175 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args', $template_args, $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets, $this->_is_creating_event ); |
|
1175 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args', $template_args, $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets, $this->_is_creating_event); |
|
1176 | 1176 | |
1177 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php'; |
|
1178 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1177 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_row.template.php'; |
|
1178 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1179 | 1179 | } |
1180 | 1180 | |
1181 | 1181 | |
1182 | 1182 | |
1183 | 1183 | |
1184 | 1184 | |
1185 | - protected function _get_tax_rows( $tktrow, $ticket ) { |
|
1185 | + protected function _get_tax_rows($tktrow, $ticket) { |
|
1186 | 1186 | $tax_rows = ''; |
1187 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php'; |
|
1187 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_tax_row.template.php'; |
|
1188 | 1188 | $template_args = array(); |
1189 | - $taxes = empty( $ticket ) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin(); |
|
1190 | - foreach ( $taxes as $tax ) { |
|
1191 | - $tax_added = $this->_get_tax_added( $tax, $ticket ); |
|
1189 | + $taxes = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin(); |
|
1190 | + foreach ($taxes as $tax) { |
|
1191 | + $tax_added = $this->_get_tax_added($tax, $ticket); |
|
1192 | 1192 | $template_args = array( |
1193 | - 'display_tax' => !empty( $ticket ) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"', |
|
1193 | + 'display_tax' => ! empty($ticket) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"', |
|
1194 | 1194 | 'tax_id' => $tax->ID(), |
1195 | 1195 | 'tkt_row' => $tktrow, |
1196 | 1196 | 'tax_label' => $tax->get('PRC_name'), |
1197 | 1197 | 'tax_added' => $tax_added, |
1198 | - 'tax_added_display' => EEH_Template::format_currency($tax_added, FALSE, FALSE ), |
|
1198 | + 'tax_added_display' => EEH_Template::format_currency($tax_added, FALSE, FALSE), |
|
1199 | 1199 | 'tax_amount' => $tax->get('PRC_amount') |
1200 | 1200 | ); |
1201 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', $template_args, $tktrow, $ticket, $this->_is_creating_event ); |
|
1202 | - $tax_rows .= EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1201 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', $template_args, $tktrow, $ticket, $this->_is_creating_event); |
|
1202 | + $tax_rows .= EEH_Template::display_template($template, $template_args, TRUE); |
|
1203 | 1203 | } |
1204 | 1204 | |
1205 | 1205 | |
@@ -1207,81 +1207,81 @@ discard block |
||
1207 | 1207 | } |
1208 | 1208 | |
1209 | 1209 | |
1210 | - protected function _get_tax_added( EE_Price $tax, $ticket ) { |
|
1211 | - $subtotal = empty( $ticket ) ? 0 : $ticket->get_ticket_subtotal(); |
|
1210 | + protected function _get_tax_added(EE_Price $tax, $ticket) { |
|
1211 | + $subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal(); |
|
1212 | 1212 | return $subtotal * $tax->get('PRC_amount') / 100; |
1213 | 1213 | } |
1214 | 1214 | |
1215 | 1215 | |
1216 | 1216 | |
1217 | 1217 | |
1218 | - protected function _get_ticket_price_row( $tktrow, $prcrow, $price, $default, $ticket, $show_trash = TRUE, $show_create = TRUE ) { |
|
1219 | - $send_disabled = !empty( $ticket ) && $ticket->get('TKT_deleted') ? TRUE : FALSE; |
|
1218 | + protected function _get_ticket_price_row($tktrow, $prcrow, $price, $default, $ticket, $show_trash = TRUE, $show_create = TRUE) { |
|
1219 | + $send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted') ? TRUE : FALSE; |
|
1220 | 1220 | $template_args = array( |
1221 | 1221 | 'tkt_row' => $default && empty($ticket) ? 'TICKETNUM' : $tktrow, |
1222 | 1222 | 'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow, |
1223 | 1223 | 'edit_prices_name' => $default && empty($price) ? 'PRICENAMEATTR' : 'edit_prices', |
1224 | - 'price_type_selector' => $default && empty( $price ) ? $this->_get_base_price_template( $tktrow, $prcrow, $price, $default ) : $this->_get_price_type_selector( $tktrow, $prcrow, $price, $default, $send_disabled ), |
|
1224 | + 'price_type_selector' => $default && empty($price) ? $this->_get_base_price_template($tktrow, $prcrow, $price, $default) : $this->_get_price_type_selector($tktrow, $prcrow, $price, $default, $send_disabled), |
|
1225 | 1225 | 'PRC_ID' => $default && empty($price) ? 0 : $price->ID(), |
1226 | 1226 | 'PRC_is_default' => $default && empty($price) ? 0 : $price->get('PRC_is_default'), |
1227 | 1227 | 'PRC_name' => $default && empty($price) ? '' : $price->get('PRC_name'), |
1228 | 1228 | 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
1229 | 1229 | 'show_plus_or_minus' => $default && empty($price) ? '' : ' style="display:none;"', |
1230 | - 'show_plus' => $default && empty( $price ) ? ' style="display:none;"' : ( $price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''), |
|
1231 | - 'show_minus' => $default && empty( $price ) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'), |
|
1232 | - 'show_currency_symbol' => $default && empty( $price ) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : '' ), |
|
1233 | - 'PRC_amount' => $default && empty( $price ) ? 0 : $price->get_pretty('PRC_amount', 'localized_float'), |
|
1234 | - 'show_percentage' => $default && empty( $price ) ? ' style="display:none;"' : ( $price->is_percent() ? '' : ' style="display:none;"' ), |
|
1230 | + 'show_plus' => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''), |
|
1231 | + 'show_minus' => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'), |
|
1232 | + 'show_currency_symbol' => $default && empty($price) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : ''), |
|
1233 | + 'PRC_amount' => $default && empty($price) ? 0 : $price->get_pretty('PRC_amount', 'localized_float'), |
|
1234 | + 'show_percentage' => $default && empty($price) ? ' style="display:none;"' : ($price->is_percent() ? '' : ' style="display:none;"'), |
|
1235 | 1235 | 'show_trash_icon' => $show_trash ? '' : ' style="display:none;"', |
1236 | 1236 | 'show_create_button' => $show_create ? '' : ' style="display:none;"', |
1237 | - 'PRC_desc' => $default && empty( $price ) ? '' : $price->get('PRC_desc'), |
|
1238 | - 'disabled' => !empty( $ticket ) && $ticket->get('TKT_deleted') ? TRUE : FALSE |
|
1237 | + 'PRC_desc' => $default && empty($price) ? '' : $price->get('PRC_desc'), |
|
1238 | + 'disabled' => ! empty($ticket) && $ticket->get('TKT_deleted') ? TRUE : FALSE |
|
1239 | 1239 | ); |
1240 | 1240 | |
1241 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args', $template_args, $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create, $this->_is_creating_event ); |
|
1241 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args', $template_args, $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create, $this->_is_creating_event); |
|
1242 | 1242 | |
1243 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php'; |
|
1244 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1243 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_price_row.template.php'; |
|
1244 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1245 | 1245 | } |
1246 | 1246 | |
1247 | 1247 | |
1248 | - protected function _get_price_type_selector( $tktrow, $prcrow, $price, $default, $disabled = FALSE ) { |
|
1249 | - if ( $price->is_base_price() ) { |
|
1250 | - return $this->_get_base_price_template( $tktrow, $prcrow, $price, $default ); |
|
1248 | + protected function _get_price_type_selector($tktrow, $prcrow, $price, $default, $disabled = FALSE) { |
|
1249 | + if ($price->is_base_price()) { |
|
1250 | + return $this->_get_base_price_template($tktrow, $prcrow, $price, $default); |
|
1251 | 1251 | } else { |
1252 | - return $this->_get_price_modifier_template( $tktrow, $prcrow, $price, $default, $disabled ); |
|
1252 | + return $this->_get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled); |
|
1253 | 1253 | } |
1254 | 1254 | |
1255 | 1255 | } |
1256 | 1256 | |
1257 | 1257 | |
1258 | - protected function _get_base_price_template( $tktrow, $prcrow, $price, $default ) { |
|
1258 | + protected function _get_base_price_template($tktrow, $prcrow, $price, $default) { |
|
1259 | 1259 | $template_args = array( |
1260 | 1260 | 'tkt_row' => $default ? 'TICKETNUM' : $tktrow, |
1261 | - 'PRC_order' => $default && empty( $price ) ? 'PRICENUM' : $prcrow, |
|
1262 | - 'PRT_ID' => $default && empty( $price ) ? 1 : $price->get('PRT_ID'), |
|
1261 | + 'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow, |
|
1262 | + 'PRT_ID' => $default && empty($price) ? 1 : $price->get('PRT_ID'), |
|
1263 | 1263 | 'PRT_name' => __('Price', 'event_espresso'), |
1264 | 1264 | 'price_selected_operator' => '+', |
1265 | 1265 | 'price_selected_is_percent' => 0 |
1266 | 1266 | ); |
1267 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php'; |
|
1267 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_type_base.template.php'; |
|
1268 | 1268 | |
1269 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $this->_is_creating_event ); |
|
1269 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $this->_is_creating_event); |
|
1270 | 1270 | |
1271 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1271 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1272 | 1272 | } |
1273 | 1273 | |
1274 | 1274 | |
1275 | 1275 | |
1276 | - protected function _get_price_modifier_template( $tktrow, $prcrow, $price, $default, $disabled = FALSE ) { |
|
1277 | - $select_name = $default && empty( $price ) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices[' . $tktrow . '][' . $prcrow . '][PRT_ID]'; |
|
1278 | - $price_types = EE_Registry::instance()->load_model('Price_Type')->get_all(array( array('OR' => array('PBT_ID' => '2', 'PBT_ID*' => '3' ) ) ) ); |
|
1279 | - $price_option_span_template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php'; |
|
1280 | - $all_price_types = $default && empty( $price ) ? array(array('id' => 0, 'text' => __('Select Modifier', 'event_espresso')) ) : array(); |
|
1281 | - $selected_price_type_id = $default && empty( $price ) ? 0 : $price->type(); |
|
1276 | + protected function _get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled = FALSE) { |
|
1277 | + $select_name = $default && empty($price) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices['.$tktrow.']['.$prcrow.'][PRT_ID]'; |
|
1278 | + $price_types = EE_Registry::instance()->load_model('Price_Type')->get_all(array(array('OR' => array('PBT_ID' => '2', 'PBT_ID*' => '3')))); |
|
1279 | + $price_option_span_template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_option_span.template.php'; |
|
1280 | + $all_price_types = $default && empty($price) ? array(array('id' => 0, 'text' => __('Select Modifier', 'event_espresso'))) : array(); |
|
1281 | + $selected_price_type_id = $default && empty($price) ? 0 : $price->type(); |
|
1282 | 1282 | $price_option_spans = ''; |
1283 | 1283 | //setup pricetypes for selector |
1284 | - foreach ( $price_types as $price_type ) { |
|
1284 | + foreach ($price_types as $price_type) { |
|
1285 | 1285 | $all_price_types[] = array( |
1286 | 1286 | 'id' => $price_type->ID(), |
1287 | 1287 | 'text' => $price_type->get('PRT_name'), |
@@ -1293,50 +1293,50 @@ discard block |
||
1293 | 1293 | 'PRT_operator' => $price_type->is_discount() ? '-' : '+', |
1294 | 1294 | 'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0 |
1295 | 1295 | ); |
1296 | - $price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, TRUE ); |
|
1296 | + $price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, TRUE); |
|
1297 | 1297 | } |
1298 | 1298 | |
1299 | - $select_params = $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"'; |
|
1299 | + $select_params = $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"'; |
|
1300 | 1300 | $main_name = $select_name; |
1301 | - $select_name = $disabled ? 'archive_price[' . $tktrow . '][' . $prcrow . '][PRT_ID]' : $main_name; |
|
1301 | + $select_name = $disabled ? 'archive_price['.$tktrow.']['.$prcrow.'][PRT_ID]' : $main_name; |
|
1302 | 1302 | |
1303 | 1303 | $template_args = array( |
1304 | 1304 | 'tkt_row' => $default ? 'TICKETNUM' : $tktrow, |
1305 | - 'PRC_order' => $default && empty( $price ) ? 'PRICENUM' : $prcrow, |
|
1306 | - 'price_modifier_selector' => EEH_Form_Fields::select_input( $select_name, $all_price_types, $selected_price_type_id, $select_params, 'edit-price-PRT_ID' ), |
|
1305 | + 'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow, |
|
1306 | + 'price_modifier_selector' => EEH_Form_Fields::select_input($select_name, $all_price_types, $selected_price_type_id, $select_params, 'edit-price-PRT_ID'), |
|
1307 | 1307 | 'main_name' => $main_name, |
1308 | 1308 | 'selected_price_type_id' => $selected_price_type_id, |
1309 | 1309 | 'price_option_spans' => $price_option_spans, |
1310 | - 'price_selected_operator' => $default && empty( $price ) ? '' : ( $price->is_discount() ? '-' : '+' ), |
|
1311 | - 'price_selected_is_percent' => $default && empty( $price ) ? '' : ( $price->is_percent() ? 1 : 0 ), |
|
1310 | + 'price_selected_operator' => $default && empty($price) ? '' : ($price->is_discount() ? '-' : '+'), |
|
1311 | + 'price_selected_is_percent' => $default && empty($price) ? '' : ($price->is_percent() ? 1 : 0), |
|
1312 | 1312 | 'disabled' => $disabled |
1313 | 1313 | ); |
1314 | 1314 | |
1315 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $disabled, $this->_is_creating_event ); |
|
1315 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $disabled, $this->_is_creating_event); |
|
1316 | 1316 | |
1317 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php'; |
|
1317 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_modifier_selector.template.php'; |
|
1318 | 1318 | |
1319 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1319 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1320 | 1320 | } |
1321 | 1321 | |
1322 | 1322 | |
1323 | 1323 | |
1324 | - protected function _get_ticket_datetime_list_item( $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default ) { |
|
1325 | - $dttid = !empty($dtt) ? $dtt->ID() : 0; |
|
1326 | - $displayrow = !empty($dtt) ? $dtt->get('DTT_order') : 0; |
|
1327 | - $tkt_dtts = $ticket instanceof EE_Ticket && isset( $ticket_datetimes[$ticket->ID()] ) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1324 | + protected function _get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default) { |
|
1325 | + $dttid = ! empty($dtt) ? $dtt->ID() : 0; |
|
1326 | + $displayrow = ! empty($dtt) ? $dtt->get('DTT_order') : 0; |
|
1327 | + $tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1328 | 1328 | $template_args = array( |
1329 | - 'dtt_row' => $default && empty( $dtt ) ? 'DTTNUM' : $dttrow, |
|
1329 | + 'dtt_row' => $default && empty($dtt) ? 'DTTNUM' : $dttrow, |
|
1330 | 1330 | 'tkt_row' => $default ? 'TICKETNUM' : $tktrow, |
1331 | - 'ticket_datetime_selected' => in_array( $displayrow, $tkt_dtts ) ? ' ticket-selected' : '', |
|
1332 | - 'ticket_datetime_checked' => in_array( $displayrow, $tkt_dtts ) ? ' checked="checked"' : '', |
|
1333 | - 'DTT_name' => $default && empty( $dtt ) ? 'DTTNAME' : $dtt->get_dtt_display_name( TRUE ), |
|
1331 | + 'ticket_datetime_selected' => in_array($displayrow, $tkt_dtts) ? ' ticket-selected' : '', |
|
1332 | + 'ticket_datetime_checked' => in_array($displayrow, $tkt_dtts) ? ' checked="checked"' : '', |
|
1333 | + 'DTT_name' => $default && empty($dtt) ? 'DTTNAME' : $dtt->get_dtt_display_name(TRUE), |
|
1334 | 1334 | 'tkt_status_class' => '', |
1335 | 1335 | ); |
1336 | 1336 | |
1337 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default, $this->_is_creating_event ); |
|
1338 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php'; |
|
1339 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1337 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default, $this->_is_creating_event); |
|
1338 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_datetimes_list_item.template.php'; |
|
1339 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1340 | 1340 | } |
1341 | 1341 | |
1342 | 1342 | |
@@ -1344,53 +1344,53 @@ discard block |
||
1344 | 1344 | protected function _get_ticket_js_structure($all_dtts, $all_tickets) { |
1345 | 1345 | $template_args = array( |
1346 | 1346 | 'default_datetime_edit_row' => $this->_get_dtt_edit_row('DTTNUM', NULL, TRUE, $all_dtts), |
1347 | - 'default_ticket_row' => $this->_get_ticket_row( 'TICKETNUM', NULL, array(), array(), TRUE), |
|
1348 | - 'default_price_row' => $this->_get_ticket_price_row( 'TICKETNUM', 'PRICENUM', NULL, TRUE, NULL ), |
|
1347 | + 'default_ticket_row' => $this->_get_ticket_row('TICKETNUM', NULL, array(), array(), TRUE), |
|
1348 | + 'default_price_row' => $this->_get_ticket_price_row('TICKETNUM', 'PRICENUM', NULL, TRUE, NULL), |
|
1349 | 1349 | 'default_price_rows' => '', |
1350 | 1350 | 'default_base_price_amount' => 0, |
1351 | 1351 | 'default_base_price_name' => '', |
1352 | 1352 | 'default_base_price_description' => '', |
1353 | - 'default_price_modifier_selector_row' => $this->_get_price_modifier_template( 'TICKETNUM', 'PRICENUM', NULL, TRUE ), |
|
1354 | - 'default_available_tickets_for_datetime' => $this->_get_dtt_attached_tickets_row( 'DTTNUM', NULL, array(), array(), TRUE ), |
|
1353 | + 'default_price_modifier_selector_row' => $this->_get_price_modifier_template('TICKETNUM', 'PRICENUM', NULL, TRUE), |
|
1354 | + 'default_available_tickets_for_datetime' => $this->_get_dtt_attached_tickets_row('DTTNUM', NULL, array(), array(), TRUE), |
|
1355 | 1355 | 'existing_available_datetime_tickets_list' => '', |
1356 | 1356 | 'existing_available_ticket_datetimes_list' => '', |
1357 | - 'new_available_datetime_ticket_list_item' => $this->_get_datetime_tickets_list_item( 'DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE ), |
|
1358 | - 'new_available_ticket_datetime_list_item' => $this->_get_ticket_datetime_list_item( 'DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE ) |
|
1357 | + 'new_available_datetime_ticket_list_item' => $this->_get_datetime_tickets_list_item('DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE), |
|
1358 | + 'new_available_ticket_datetime_list_item' => $this->_get_ticket_datetime_list_item('DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE) |
|
1359 | 1359 | ); |
1360 | 1360 | |
1361 | 1361 | $tktrow = 1; |
1362 | - foreach ( $all_tickets as $ticket ) { |
|
1363 | - $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( 'DTTNUM', $tktrow, NULL, $ticket, array(), TRUE ); |
|
1362 | + foreach ($all_tickets as $ticket) { |
|
1363 | + $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item('DTTNUM', $tktrow, NULL, $ticket, array(), TRUE); |
|
1364 | 1364 | $tktrow++; |
1365 | 1365 | } |
1366 | 1366 | |
1367 | 1367 | |
1368 | 1368 | $dttrow = 1; |
1369 | - foreach ( $all_dtts as $dtt ) { |
|
1370 | - $template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( $dttrow, 'TICKETNUM', $dtt, NULL, array(), TRUE ); |
|
1369 | + foreach ($all_dtts as $dtt) { |
|
1370 | + $template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, 'TICKETNUM', $dtt, NULL, array(), TRUE); |
|
1371 | 1371 | $dttrow++; |
1372 | 1372 | } |
1373 | 1373 | |
1374 | 1374 | $default_prices = EE_Registry::instance()->load_model('Price')->get_all_default_prices(); |
1375 | 1375 | $prcrow = 1; |
1376 | - foreach ( $default_prices as $price ) { |
|
1377 | - if ( $price->is_base_price() ) { |
|
1376 | + foreach ($default_prices as $price) { |
|
1377 | + if ($price->is_base_price()) { |
|
1378 | 1378 | $template_args['default_base_price_amount'] = $price->get_pretty('PRC_amount', 'localized_float'); |
1379 | 1379 | $template_args['default_base_price_name'] = $price->get('PRC_name'); |
1380 | 1380 | $template_args['default_base_price_description'] = $price->get('PRC_desc'); |
1381 | 1381 | $prcrow++; |
1382 | 1382 | continue; |
1383 | 1383 | } |
1384 | - $show_trash = ( count( $default_prices ) > 1 && $prcrow === 1 ) || count( $default_prices ) === 1 ? FALSE : TRUE; |
|
1385 | - $show_create = count( $default_prices ) > 1 && count( $default_prices ) !== $prcrow ? FALSE : TRUE; |
|
1386 | - $template_args['default_price_rows'] .= $this->_get_ticket_price_row( 'TICKETNUM', $prcrow, $price, TRUE, NULL, $show_trash, $show_create ); |
|
1384 | + $show_trash = (count($default_prices) > 1 && $prcrow === 1) || count($default_prices) === 1 ? FALSE : TRUE; |
|
1385 | + $show_create = count($default_prices) > 1 && count($default_prices) !== $prcrow ? FALSE : TRUE; |
|
1386 | + $template_args['default_price_rows'] .= $this->_get_ticket_price_row('TICKETNUM', $prcrow, $price, TRUE, NULL, $show_trash, $show_create); |
|
1387 | 1387 | $prcrow++; |
1388 | 1388 | } |
1389 | 1389 | |
1390 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args', $template_args, $all_dtts, $all_tickets, $this->_is_creating_event ); |
|
1390 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args', $template_args, $all_dtts, $all_tickets, $this->_is_creating_event); |
|
1391 | 1391 | |
1392 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php'; |
|
1393 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1392 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_js_structure.template.php'; |
|
1393 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1394 | 1394 | } |
1395 | 1395 | |
1396 | 1396 |
@@ -36,53 +36,53 @@ discard block |
||
36 | 36 | <h2 id="invoice-hdr"><?php _e('Order Confirmation', 'event_espresso')?></h2> |
37 | 37 | <h3 id="invoice-date"><?php _e('Date:', 'event_espresso')?> <span class="plain-text">[registration_date]</span></h3> |
38 | 38 | <h3 id="invoice-txn-id"><?php _e('Transaction ID:', 'event_espresso')?> <span class="plain-text">[transaction_id]</span></h3> |
39 | - <h3 id="invoice-txn-status"><?php _e('Status:', 'event_espresso')?> <span class="<?php echo $transaction->status_ID()?> plain-text"><?php echo $transaction->pretty_status();?></span></h3> |
|
39 | + <h3 id="invoice-txn-status"><?php _e('Status:', 'event_espresso')?> <span class="<?php echo $transaction->status_ID()?> plain-text"><?php echo $transaction->pretty_status(); ?></span></h3> |
|
40 | 40 | </div> |
41 | 41 | </td> |
42 | 42 | </tr> |
43 | 43 | </table> |
44 | 44 | <div class="events"> |
45 | - <?php foreach($events_for_txn as $event_id => $event){ |
|
46 | - ?><h3 class="section-title event-name"><img class="icon" src="<?php echo EE_IMAGES_URL.'calendar_year-24x24.png';?>"><?php _e("Event Name:","event_espresso")?> <span class="plain-text"><?php echo $event->name();?></span> <span class="small-text link">[ <a href='<?php echo $event->get_permalink()?>'><?php _e('view', 'event_espresso'); ?></a> ]</span></h3> |
|
47 | - <?php if (strlen($event->description()>1)){?><p class="event-description"><?php $event->description()?></p><?php }?> |
|
45 | + <?php foreach ($events_for_txn as $event_id => $event) { |
|
46 | + ?><h3 class="section-title event-name"><img class="icon" src="<?php echo EE_IMAGES_URL.'calendar_year-24x24.png'; ?>"><?php _e("Event Name:", "event_espresso")?> <span class="plain-text"><?php echo $event->name(); ?></span> <span class="small-text link">[ <a href='<?php echo $event->get_permalink()?>'><?php _e('view', 'event_espresso'); ?></a> ]</span></h3> |
|
47 | + <?php if (strlen($event->description() > 1)) {?><p class="event-description"><?php $event->description()?></p><?php }?> |
|
48 | 48 | <ul class="tickets-per-event"> |
49 | - <?php foreach($ticket_line_items_per_event[$event_id] as $line_item_id => $line_item){ |
|
49 | + <?php foreach ($ticket_line_items_per_event[$event_id] as $line_item_id => $line_item) { |
|
50 | 50 | $ticket = $line_item->ticket(); |
51 | - $taxable_html = $ticket->taxable() ? '*': ''; |
|
51 | + $taxable_html = $ticket->taxable() ? '*' : ''; |
|
52 | 52 | $subitems = $line_item->children(); |
53 | - $ticket_uses = $ticket->get_pretty('TKT_uses', __("any", "event_espresso")); |
|
53 | + $ticket_uses = $ticket->get_pretty('TKT_uses', __("any", "event_espresso")); |
|
54 | 54 | ?> |
55 | 55 | <li class="event-ticket"> |
56 | 56 | <div class="ticket-details"> |
57 | 57 | <table class="invoice-amount"> |
58 | 58 | <thead> |
59 | 59 | <tr class="header_row"> |
60 | - <th class="name-column"><?php _e("Ticket", "event_espresso");?></th> |
|
61 | - <th colspan="2" class="desc-column"><?php _e("Description", "event_espresso");?></th> |
|
62 | - <th class="number-column item_c"><?php _e("Quantity", "event_espresso");?></th> |
|
63 | - <th class="number-column item_c"><?php _e("Price", "event_espresso");?></th> |
|
64 | - <th class="number-column item_r"><?php _e("Total", "event_espresso");?></th> |
|
60 | + <th class="name-column"><?php _e("Ticket", "event_espresso"); ?></th> |
|
61 | + <th colspan="2" class="desc-column"><?php _e("Description", "event_espresso"); ?></th> |
|
62 | + <th class="number-column item_c"><?php _e("Quantity", "event_espresso"); ?></th> |
|
63 | + <th class="number-column item_c"><?php _e("Price", "event_espresso"); ?></th> |
|
64 | + <th class="number-column item_r"><?php _e("Total", "event_espresso"); ?></th> |
|
65 | 65 | </tr> |
66 | 66 | </thead> |
67 | 67 | <tbody> |
68 | - <?php if( count($subitems) < 2){?> |
|
68 | + <?php if (count($subitems) < 2) {?> |
|
69 | 69 | <tr class="item"> |
70 | 70 | <td><?php echo $line_item->name().$taxable_html?></td> |
71 | - <td colspan="2"><?php echo $line_item->desc();?><p class="ticket-note"><?php echo sprintf(__('This ticket can be used once at %s of the dates/times below.', 'event_espresso'), $ticket_uses); ?></p></td> |
|
71 | + <td colspan="2"><?php echo $line_item->desc(); ?><p class="ticket-note"><?php echo sprintf(__('This ticket can be used once at %s of the dates/times below.', 'event_espresso'), $ticket_uses); ?></p></td> |
|
72 | 72 | <td class="item_c"><?php echo $line_item->quantity()?></td> |
73 | 73 | <td class="item_c"><?php echo $line_item->unit_price_no_code()?></td> |
74 | 74 | <td class="item_r"><?php echo $line_item->total_no_code()?></td> |
75 | 75 | </tr> |
76 | - <?php }else{?> |
|
76 | + <?php } else {?> |
|
77 | 77 | <tr class="item"> |
78 | 78 | <td class="aln-left"><?php echo $line_item->name().$taxable_html?></td> |
79 | - <td colspan="2"><?php echo $line_item->desc();?><p class="ticket-note"><?php echo sprintf(__('This ticket can be used once at %s of the dates/times below.', 'event_espresso'), $ticket_uses); ?></p></td> |
|
79 | + <td colspan="2"><?php echo $line_item->desc(); ?><p class="ticket-note"><?php echo sprintf(__('This ticket can be used once at %s of the dates/times below.', 'event_espresso'), $ticket_uses); ?></p></td> |
|
80 | 80 | <td class="item_c"><?php echo $line_item->quantity()?></td> |
81 | 81 | <td class="item_c"><?php echo $line_item->unit_price_no_code()?></td> |
82 | 82 | <td class="item_r"><?php echo $line_item->total_no_code()?></td> |
83 | 83 | </tr> |
84 | - <?php foreach($subitems as $sub_line_item){ |
|
85 | - $is_percent = $sub_line_item->is_percent();?> |
|
84 | + <?php foreach ($subitems as $sub_line_item) { |
|
85 | + $is_percent = $sub_line_item->is_percent(); ?> |
|
86 | 86 | <tr class="subitem-row"> |
87 | 87 | <td class="subitem"><?php echo $sub_line_item->name()?></td> |
88 | 88 | <td colspan="2"><?php echo $sub_line_item->desc()?></td> |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | <?php } ?> |
94 | 94 | <tr class="total_tr odd"> |
95 | 95 | <td colspan="4"></td> |
96 | - <td class="total" nowrap="nowrap"><?php _e("Ticket Total:", "event_espresso");?></td> |
|
96 | + <td class="total" nowrap="nowrap"><?php _e("Ticket Total:", "event_espresso"); ?></td> |
|
97 | 97 | <td class="item_r"><?php echo $line_item->total_no_code()?></td> |
98 | 98 | </tr> |
99 | 99 | <?php }?> |
@@ -104,22 +104,22 @@ discard block |
||
104 | 104 | <div class="reg-details-for-ticket"> |
105 | 105 | <div class="ticket-time-and-place-details"> |
106 | 106 | <div class="ticket-time-details"> |
107 | - <h4 class="sub-section-title no-bottom-margin"><img class="icon" src="<?php echo EE_IMAGES_URL.'clock-16x16.png';?>"><?php echo _n("Date/Time:","Dates/Times:",count($ticket->datetimes()), "event_espresso");?></h4> |
|
107 | + <h4 class="sub-section-title no-bottom-margin"><img class="icon" src="<?php echo EE_IMAGES_URL.'clock-16x16.png'; ?>"><?php echo _n("Date/Time:", "Dates/Times:", count($ticket->datetimes()), "event_espresso"); ?></h4> |
|
108 | 108 | <ul class="event-dates"> |
109 | - <?php foreach($ticket->datetimes_ordered() as $datetime){ |
|
109 | + <?php foreach ($ticket->datetimes_ordered() as $datetime) { |
|
110 | 110 | /* @var $datetime EE_Datetime */ ?> |
111 | 111 | <li><?php |
112 | - echo $datetime->name() ? '<b>'.$datetime->name().' </b>' : '' ; |
|
113 | - echo sprintf(__("%s - %s (%s)", "event_espresso"),$datetime->start_date_and_time(),$datetime->end_date_and_time(),$datetime->get_timezone()); |
|
112 | + echo $datetime->name() ? '<b>'.$datetime->name().' </b>' : ''; |
|
113 | + echo sprintf(__("%s - %s (%s)", "event_espresso"), $datetime->start_date_and_time(), $datetime->end_date_and_time(), $datetime->get_timezone()); |
|
114 | 114 | echo $datetime->description() ? '<p class="ticket-note">'.$datetime->description().'</p>' : '' ?></li> |
115 | 115 | <?php }?> |
116 | 116 | </ul> |
117 | 117 | </div> |
118 | - <?php if ($event->venues()){?> |
|
118 | + <?php if ($event->venues()) {?> |
|
119 | 119 | <div class="ticket-place-details"> |
120 | - <h4 class="sub-section-title no-bottom-margin"><img class="icon" src="<?php echo EE_IMAGES_URL.'location-pin-16x16.png';?>"><?php echo _n("Venue:","Venues:",count($event->venues()), "event_espresso");?></h4> |
|
120 | + <h4 class="sub-section-title no-bottom-margin"><img class="icon" src="<?php echo EE_IMAGES_URL.'location-pin-16x16.png'; ?>"><?php echo _n("Venue:", "Venues:", count($event->venues()), "event_espresso"); ?></h4> |
|
121 | 121 | <ul class="event-venues"> |
122 | - <?php foreach($event->venues() as $venue){?> |
|
122 | + <?php foreach ($event->venues() as $venue) {?> |
|
123 | 123 | <li><?php echo $venue->name()?> <span class="small-text">[ <a href='<?php echo $venue->get_permalink()?>'><?php _e('view', 'event_espresso'); ?></a> ]</span></li> |
124 | 124 | <?php } ?> |
125 | 125 | </ul> |
@@ -127,34 +127,34 @@ discard block |
||
127 | 127 | <?php }?> |
128 | 128 | </div> |
129 | 129 | <div class="ticket-registrations-area"> |
130 | - <h4 class="sub-section-title"><img class="icon" src="<?php echo EE_IMAGES_URL.'users-16x16.png';?>"><?php echo __("Registration Details", "event_espresso");?> <span class="small-text link">[ <a class="print_button noPrint" href="<?php echo $edit_reg_info_url; ?>"><?php _e('edit', 'event_espresso'); ?></a> ]</span></h4> |
|
130 | + <h4 class="sub-section-title"><img class="icon" src="<?php echo EE_IMAGES_URL.'users-16x16.png'; ?>"><?php echo __("Registration Details", "event_espresso"); ?> <span class="small-text link">[ <a class="print_button noPrint" href="<?php echo $edit_reg_info_url; ?>"><?php _e('edit', 'event_espresso'); ?></a> ]</span></h4> |
|
131 | 131 | <ul class="ticket-registrations-list"> |
132 | - <?php foreach($registrations_per_line_item[$line_item_id] as $registration){ |
|
132 | + <?php foreach ($registrations_per_line_item[$line_item_id] as $registration) { |
|
133 | 133 | /* @var $registration EE_Registration */ |
134 | 134 | $attendee = $registration->attendee(); |
135 | - $answers = $registration->answers(array('order_by'=>array('Question.Question_Group_Question.QGQ_order'=>'ASC')));?> |
|
135 | + $answers = $registration->answers(array('order_by'=>array('Question.Question_Group_Question.QGQ_order'=>'ASC'))); ?> |
|
136 | 136 | <li class="ticket-registration"> |
137 | 137 | <table class="registration-details"> |
138 | 138 | <tr class="odd"> |
139 | - <th><?php echo _e("Registration Code:", "event_espresso");?></th> |
|
140 | - <td><?php echo $registration->reg_code();?> - <span class="<?php echo $registration->status_ID()?>"><?php echo $registration->pretty_status()?></span></td> |
|
139 | + <th><?php echo _e("Registration Code:", "event_espresso"); ?></th> |
|
140 | + <td><?php echo $registration->reg_code(); ?> - <span class="<?php echo $registration->status_ID()?>"><?php echo $registration->pretty_status()?></span></td> |
|
141 | 141 | </tr> |
142 | 142 | <?php |
143 | - foreach($event->question_groups() as $question_group){ |
|
144 | - ?><tr><th><?php $question_group->e('QSG_name');?></th><td></td></tr><?php |
|
143 | + foreach ($event->question_groups() as $question_group) { |
|
144 | + ?><tr><th><?php $question_group->e('QSG_name'); ?></th><td></td></tr><?php |
|
145 | 145 | $has_personal_info = false; |
146 | - foreach($question_group->questions() as $question){ |
|
147 | - if( in_array($question->system_ID(),$questions_to_skip)){ |
|
146 | + foreach ($question_group->questions() as $question) { |
|
147 | + if (in_array($question->system_ID(), $questions_to_skip)) { |
|
148 | 148 | $has_personal_info = true; |
149 | 149 | continue; |
150 | 150 | } |
151 | 151 | ?><tr> |
152 | 152 | <th><?php echo $question->display_text()?></th> |
153 | - <td><?php echo $registration->answer_value_to_question($question);?></td> |
|
153 | + <td><?php echo $registration->answer_value_to_question($question); ?></td> |
|
154 | 154 | </tr><?php |
155 | 155 | } |
156 | - if($has_personal_info){ |
|
157 | - ?><tr><th><?php _e('Attendee', 'event_espresso');?></th><td><?php echo sprintf(__('%s (%s)', "event_espresso"),$attendee->full_name(),$attendee->email())?></td></tr><?php |
|
156 | + if ($has_personal_info) { |
|
157 | + ?><tr><th><?php _e('Attendee', 'event_espresso'); ?></th><td><?php echo sprintf(__('%s (%s)', "event_espresso"), $attendee->full_name(), $attendee->email())?></td></tr><?php |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | ?> |
@@ -171,21 +171,21 @@ discard block |
||
171 | 171 | <?php }?> |
172 | 172 | </div> |
173 | 173 | <div class="taxes"> |
174 | - <?php if ($tax_total_line_item && $tax_total_line_item->children()){?> |
|
175 | - <h3 class="section-title"><?php _e("Taxes",'event_espresso')?></h3> |
|
174 | + <?php if ($tax_total_line_item && $tax_total_line_item->children()) {?> |
|
175 | + <h3 class="section-title"><?php _e("Taxes", 'event_espresso')?></h3> |
|
176 | 176 | <table class="invoice-amount"> |
177 | 177 | |
178 | 178 | <thead> |
179 | 179 | <tr class="header_row"> |
180 | - <th class="left ticket_th"><?php _e("Tax Name", "event_espresso");?></th> |
|
181 | - <th class="left"><?php _e('Description', 'event_espresso');?></th> |
|
180 | + <th class="left ticket_th"><?php _e("Tax Name", "event_espresso"); ?></th> |
|
181 | + <th class="left"><?php _e('Description', 'event_espresso'); ?></th> |
|
182 | 182 | <th class="event_th item_c"><?php _e('Rate', 'event_espresso'); ?></th> |
183 | 183 | <th class="subtotal_th"><?php _e('Tax Amount', 'event_espresso'); ?></th> |
184 | 184 | </tr> |
185 | 185 | </thead> |
186 | 186 | <tbody> |
187 | 187 | <?php |
188 | - foreach($tax_total_line_item->children() as $child_tax){?> |
|
188 | + foreach ($tax_total_line_item->children() as $child_tax) {?> |
|
189 | 189 | <tr> |
190 | 190 | <td><?php echo $child_tax->name()?></td> |
191 | 191 | <td><?php echo $child_tax->desc()?></td> |
@@ -195,26 +195,26 @@ discard block |
||
195 | 195 | <?php } ?> |
196 | 196 | <tr class="total_tr odd"> |
197 | 197 | <td class="total_tr" colspan="2"></td> |
198 | - <td class="total"><?php _e("Tax Total:", "event_espresso");?></td> |
|
198 | + <td class="total"><?php _e("Tax Total:", "event_espresso"); ?></td> |
|
199 | 199 | <td class="item_r"><?php echo $tax_total_line_item->total_no_code()?></td> |
200 | 200 | </tr> |
201 | 201 | </tbody> |
202 | 202 | |
203 | 203 | </table> |
204 | 204 | <?php }?> |
205 | - <p><?php _e("* taxable items", "event_espresso");?></p> |
|
205 | + <p><?php _e("* taxable items", "event_espresso"); ?></p> |
|
206 | 206 | </div> |
207 | 207 | <div class="grand-total-dv"> |
208 | - <h2 class="grand-total"><?php printf(__("Grand Total: %s", "event_espresso"),EEH_Template::format_currency($total_cost));?></h2> |
|
208 | + <h2 class="grand-total"><?php printf(__("Grand Total: %s", "event_espresso"), EEH_Template::format_currency($total_cost)); ?></h2> |
|
209 | 209 | </div> |
210 | 210 | <div class="payment-dv"> |
211 | - <h3 class="section-title"><?php _e("Payments",'event_espresso')?></h3> |
|
211 | + <h3 class="section-title"><?php _e("Payments", 'event_espresso')?></h3> |
|
212 | 212 | <p>[instructions]</p> |
213 | 213 | <table class="invoice-amount"> |
214 | 214 | <thead> |
215 | 215 | <tr class="header_row"> |
216 | 216 | <th><span class=""><?php _e('Payment Method', 'event_espresso'); ?></span></th> |
217 | - <th class='left datetime_th'><?php _e("Date",'event_espresso')?></th> |
|
217 | + <th class='left datetime_th'><?php _e("Date", 'event_espresso')?></th> |
|
218 | 218 | <th><span class=""><?php _e('Transaction Id / Cheque #', 'event_espresso'); ?></span></th> |
219 | 219 | <th><span class=""><?php _e('P.O. / S.O.#', 'event_espresso'); ?></span></th> |
220 | 220 | <th><span class=""><?php _e('Status', 'event_espresso'); ?></span></th> |
@@ -224,11 +224,11 @@ discard block |
||
224 | 224 | <tbody> |
225 | 225 | <?php |
226 | 226 | $c = false; |
227 | - if(!empty($payments)){ |
|
227 | + if ( ! empty($payments)) { |
|
228 | 228 | |
229 | - foreach($payments as $payment){ |
|
229 | + foreach ($payments as $payment) { |
|
230 | 230 | /* @var $payment EE_Payment */?> |
231 | - <tr class='item <?php echo (($c = !$c) ? ' odd' : '')?>'> |
|
231 | + <tr class='item <?php echo (($c = ! $c) ? ' odd' : '')?>'> |
|
232 | 232 | <td><?php $payment->e('PAY_gateway')?></td> |
233 | 233 | <td><?php echo $payment->timestamp()?></td> |
234 | 234 | <td><?php $payment->e('PAY_txn_id_chq_nmbr')?></td> |
@@ -237,17 +237,17 @@ discard block |
||
237 | 237 | <td class='item_r'><?php echo $payment->amount_no_code()?></td> |
238 | 238 | </tr> |
239 | 239 | <?php } |
240 | - }else{?> |
|
240 | + } else {?> |
|
241 | 241 | <tr class='item'> |
242 | - <td class='aln-cntr' colspan="6"><?php _e("No approved payments have been received.",'event_espresso')?> </td> |
|
242 | + <td class='aln-cntr' colspan="6"><?php _e("No approved payments have been received.", 'event_espresso')?> </td> |
|
243 | 243 | </tr> |
244 | 244 | <?php } |
245 | - ?><tr class="item" ><td class='aln-cntr' colspan="6"><?php if($amount_owed){?><a class="noPrint" href='<?php echo $retry_payment_url?>'><?php _e("Please make a payment.", "event_espresso");}?></a></td></tr> |
|
245 | + ?><tr class="item" ><td class='aln-cntr' colspan="6"><?php if ($amount_owed) {?><a class="noPrint" href='<?php echo $retry_payment_url?>'><?php _e("Please make a payment.", "event_espresso"); }?></a></td></tr> |
|
246 | 246 | </tbody> |
247 | 247 | <tfoot> |
248 | 248 | <tr class='total_tr'><td colspan="4"> </td> |
249 | - <td class="item_r"><?php _e('Total Paid','event_espresso')?></td> |
|
250 | - <td class="item_r"><?php echo EEH_Template::format_currency($amount_pd,false,false)?> </td> |
|
249 | + <td class="item_r"><?php _e('Total Paid', 'event_espresso')?></td> |
|
250 | + <td class="item_r"><?php echo EEH_Template::format_currency($amount_pd, false, false)?> </td> |
|
251 | 251 | </tr> |
252 | 252 | <?php //echo $discount; ?> |
253 | 253 | <tr class="total_tr odd"> |
@@ -259,20 +259,20 @@ discard block |
||
259 | 259 | </table> |
260 | 260 | </div> |
261 | 261 | <div class="additional-info-dv"> |
262 | - <h3 class="section-title"><?php _e("Additional Information:", "event_espresso");?></h3> |
|
262 | + <h3 class="section-title"><?php _e("Additional Information:", "event_espresso"); ?></h3> |
|
263 | 263 | <div class="additional-info"> |
264 | - <?php if($venues_for_events){?> |
|
265 | - <h2><?php echo _n("Venue Details:", "Venues Details:", "event_espresso",count($venues_for_events));?></h2> |
|
264 | + <?php if ($venues_for_events) {?> |
|
265 | + <h2><?php echo _n("Venue Details:", "Venues Details:", "event_espresso", count($venues_for_events)); ?></h2> |
|
266 | 266 | <table class="venue-list"> |
267 | - <?php foreach($venues_for_events as $venue){?> |
|
267 | + <?php foreach ($venues_for_events as $venue) {?> |
|
268 | 268 | <tr class="venue-details"> |
269 | 269 | <td class="venue-details-part venue-address-dv"> |
270 | 270 | <h3><a href='<?php echo $venue->get_permalink()?>'><?php |
271 | 271 | echo $venue->name() |
272 | 272 | ?></a></h3> |
273 | 273 | <p><?php echo $venue->description()?></p> |
274 | - <?php echo EEH_Address::format($venue);?></td> |
|
275 | - <?php if($venue->enable_for_gmap()){?> |
|
274 | + <?php echo EEH_Address::format($venue); ?></td> |
|
275 | + <?php if ($venue->enable_for_gmap()) {?> |
|
276 | 276 | <td class="venue-details-part venue-image-dv"><?php echo EEH_Venue_View::espresso_google_static_map($venue)?></td> |
277 | 277 | <?php } ?> |
278 | 278 | </tr> |
@@ -280,9 +280,9 @@ discard block |
||
280 | 280 | </table> |
281 | 281 | <?php } ?> |
282 | 282 | |
283 | - <?php if($shameless_plug){?> |
|
283 | + <?php if ($shameless_plug) {?> |
|
284 | 284 | <div class='aln-cntr'><?php |
285 | - printf(__("Powered by %sEvent Espresso %s", "event_espresso"),"<a href='https://eventespresso.com'>","</a>"); |
|
285 | + printf(__("Powered by %sEvent Espresso %s", "event_espresso"), "<a href='https://eventespresso.com'>", "</a>"); |
|
286 | 286 | ?></div> |
287 | 287 | <?php } ?> |
288 | 288 | </div> |
@@ -23,15 +23,15 @@ discard block |
||
23 | 23 | </td> |
24 | 24 | <td> |
25 | 25 | <div id="invoice-info"> |
26 | - <h2 id="invoice-hdr"><?php _e( 'Order Confirmation', 'event_espresso' ) ?></h2> |
|
26 | + <h2 id="invoice-hdr"><?php _e('Order Confirmation', 'event_espresso') ?></h2> |
|
27 | 27 | |
28 | - <h3 id="invoice-date"><?php _e( 'Date:', 'event_espresso' ) ?> |
|
28 | + <h3 id="invoice-date"><?php _e('Date:', 'event_espresso') ?> |
|
29 | 29 | <span class="plain-text">[PRIMARY_REGISTRANT_REGISTRATION_DATE]</span></h3> |
30 | 30 | |
31 | - <h3 id="invoice-txn-id"><?php _e( 'Transaction ID:', 'event_espresso' ) ?> |
|
31 | + <h3 id="invoice-txn-id"><?php _e('Transaction ID:', 'event_espresso') ?> |
|
32 | 32 | <span class="plain-text">[TXN_ID]</span></h3> |
33 | 33 | |
34 | - <h3 id="invoice-txn-status"><?php _e( 'Status:', 'event_espresso' ) ?> |
|
34 | + <h3 id="invoice-txn-status"><?php _e('Status:', 'event_espresso') ?> |
|
35 | 35 | <span class="[TXN_STATUS_ID] plain-text">[TXN_STATUS]</span></h3> |
36 | 36 | </div> |
37 | 37 | </td> |
@@ -41,15 +41,15 @@ discard block |
||
41 | 41 | [EVENT_LIST] |
42 | 42 | </div> |
43 | 43 | <div class="taxes"> |
44 | - <h3 class="section-title"><?php _e( "Additional Charges/Discounts", 'event_espresso' ) ?></h3> |
|
44 | + <h3 class="section-title"><?php _e("Additional Charges/Discounts", 'event_espresso') ?></h3> |
|
45 | 45 | <table class="invoice-amount"> |
46 | 46 | <thead> |
47 | 47 | <tr class="header_row"> |
48 | - <th class="left ticket_th"><?php _e( "Name", "event_espresso" ); ?></th> |
|
49 | - <th class="left"><?php _e( 'Description', 'event_espresso' ); ?></th> |
|
50 | - <th class="event_th item_c"><?php _e( 'Quantity', 'event_espresso' ); ?></th> |
|
51 | - <th class="event_th item_c"><?php _e( 'Unit Price', 'event_espresso' ); ?></th> |
|
52 | - <th class="subtotal_th"><?php _e( 'Total', 'event_espresso' ); ?></th> |
|
48 | + <th class="left ticket_th"><?php _e("Name", "event_espresso"); ?></th> |
|
49 | + <th class="left"><?php _e('Description', 'event_espresso'); ?></th> |
|
50 | + <th class="event_th item_c"><?php _e('Quantity', 'event_espresso'); ?></th> |
|
51 | + <th class="event_th item_c"><?php _e('Unit Price', 'event_espresso'); ?></th> |
|
52 | + <th class="subtotal_th"><?php _e('Total', 'event_espresso'); ?></th> |
|
53 | 53 | </tr> |
54 | 54 | </thead> |
55 | 55 | <tbody> |
@@ -60,15 +60,15 @@ discard block |
||
60 | 60 | </table> |
61 | 61 | </div> |
62 | 62 | <div class="taxes"> |
63 | - <h3 class="section-title"><?php _e( "Taxes", 'event_espresso' ) ?></h3> |
|
64 | - <p><?php printf( __( '%s*%s Taxable items. The total amount collected for taxes is reflected in the total(s) below.', 'event_espresso' ), '<strong>', '</strong>' ); ?></p> |
|
63 | + <h3 class="section-title"><?php _e("Taxes", 'event_espresso') ?></h3> |
|
64 | + <p><?php printf(__('%s*%s Taxable items. The total amount collected for taxes is reflected in the total(s) below.', 'event_espresso'), '<strong>', '</strong>'); ?></p> |
|
65 | 65 | <table class="invoice-amount"> |
66 | 66 | <thead> |
67 | 67 | <tr class="header_row"> |
68 | - <th class="left ticket_th"><?php _e( "Tax Name", "event_espresso" ); ?></th> |
|
69 | - <th class="left"><?php _e( 'Description', 'event_espresso' ); ?></th> |
|
70 | - <th class="event_th item_c"><?php _e( 'Rate', 'event_espresso' ); ?></th> |
|
71 | - <th class="subtotal_th"><?php _e( 'Tax Amount', 'event_espresso' ); ?></th> |
|
68 | + <th class="left ticket_th"><?php _e("Tax Name", "event_espresso"); ?></th> |
|
69 | + <th class="left"><?php _e('Description', 'event_espresso'); ?></th> |
|
70 | + <th class="event_th item_c"><?php _e('Rate', 'event_espresso'); ?></th> |
|
71 | + <th class="subtotal_th"><?php _e('Tax Amount', 'event_espresso'); ?></th> |
|
72 | 72 | </tr> |
73 | 73 | </thead> |
74 | 74 | <tbody> |
@@ -79,19 +79,19 @@ discard block |
||
79 | 79 | </table> |
80 | 80 | </div> |
81 | 81 | <div class="grand-total-dv"> |
82 | - <h2 class="grand-total"><?php printf( __( "Grand Total: %s", "event_espresso" ), '[TOTAL_COST]' ); ?></h2> |
|
82 | + <h2 class="grand-total"><?php printf(__("Grand Total: %s", "event_espresso"), '[TOTAL_COST]'); ?></h2> |
|
83 | 83 | </div> |
84 | 84 | <div class="payment-dv"> |
85 | - <h3 class="section-title"><?php _e( "Payments", 'event_espresso' ) ?></h3> |
|
85 | + <h3 class="section-title"><?php _e("Payments", 'event_espresso') ?></h3> |
|
86 | 86 | <table class="invoice-amount"> |
87 | 87 | <thead> |
88 | 88 | <tr class="header_row"> |
89 | - <th><span class=""><?php _e( 'Payment Method', 'event_espresso' ); ?></span></th> |
|
90 | - <th class='left datetime_th'><?php _e( "Date", 'event_espresso' ) ?></th> |
|
91 | - <th><span class=""><?php _e( 'Transaction Id / Cheque #', 'event_espresso' ); ?></span></th> |
|
92 | - <th><span class=""><?php _e( 'P.O. / S.O.#', 'event_espresso' ); ?></span></th> |
|
93 | - <th><span class=""><?php _e( 'Status', 'event_espresso' ); ?></span></th> |
|
94 | - <th><?php _e( 'Amount', 'event_espresso' ); ?></th> |
|
89 | + <th><span class=""><?php _e('Payment Method', 'event_espresso'); ?></span></th> |
|
90 | + <th class='left datetime_th'><?php _e("Date", 'event_espresso') ?></th> |
|
91 | + <th><span class=""><?php _e('Transaction Id / Cheque #', 'event_espresso'); ?></span></th> |
|
92 | + <th><span class=""><?php _e('P.O. / S.O.#', 'event_espresso'); ?></span></th> |
|
93 | + <th><span class=""><?php _e('Status', 'event_espresso'); ?></span></th> |
|
94 | + <th><?php _e('Amount', 'event_espresso'); ?></th> |
|
95 | 95 | </tr> |
96 | 96 | </thead> |
97 | 97 | <tbody> |
@@ -105,21 +105,21 @@ discard block |
||
105 | 105 | <tfoot> |
106 | 106 | <tr class='total_tr'> |
107 | 107 | <td colspan="4"> </td> |
108 | - <td class="item_r"><?php _e( 'Total Paid', 'event_espresso' ) ?></td> |
|
108 | + <td class="item_r"><?php _e('Total Paid', 'event_espresso') ?></td> |
|
109 | 109 | <td class="item_r">[TOTAL_AMOUNT_PAID]</td> |
110 | 110 | </tr> |
111 | 111 | <tr class="total_tr odd"> |
112 | 112 | <td colspan="4"> </td> |
113 | - <td class="total" id="total_currency"><?php _e( 'Amount Owed:', 'event_espresso' ); ?></td> |
|
113 | + <td class="total" id="total_currency"><?php _e('Amount Owed:', 'event_espresso'); ?></td> |
|
114 | 114 | <td class="total">[TOTAL_OWING]</td> |
115 | 115 | </tr> |
116 | 116 | </tfoot> |
117 | 117 | </table> |
118 | 118 | </div> |
119 | 119 | <div class="additional-info-dv"> |
120 | - <h3 class="section-title"><?php _e( "Additional Information:", "event_espresso" ); ?></h3> |
|
120 | + <h3 class="section-title"><?php _e("Additional Information:", "event_espresso"); ?></h3> |
|
121 | 121 | <div class="additional-info"> |
122 | - <h2><?php _e( "Venue Details:", "event_espresso" ); ?></h2> |
|
122 | + <h2><?php _e("Venue Details:", "event_espresso"); ?></h2> |
|
123 | 123 | <table class="venue-list"> |
124 | 124 | <tr class="venue-details"> |
125 | 125 | <td class="venue-details-part venue-address-dv"> |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | <td class="venue-details-part venue-image-dv">[GOOGLE_MAP_IMAGE]</td> |
132 | 132 | </tr> |
133 | 133 | </table> |
134 | - <div class='aln-cntr'><?php printf( __( "Powered by %sEvent Espresso %s", "event_espresso" ), "<a href='https://eventespresso.com'>", "</a>" ); ?></div> |
|
134 | + <div class='aln-cntr'><?php printf(__("Powered by %sEvent Espresso %s", "event_espresso"), "<a href='https://eventespresso.com'>", "</a>"); ?></div> |
|
135 | 135 | </div> |
136 | 136 | </div> |
137 | 137 | </div> |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @return EED_Event_Single |
41 | 41 | */ |
42 | 42 | public static function instance() { |
43 | - return parent::get_instance( __CLASS__ ); |
|
43 | + return parent::get_instance(__CLASS__); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | * @return void |
53 | 53 | */ |
54 | 54 | public static function set_hooks() { |
55 | - add_filter( 'FHEE_run_EE_wp', '__return_true' ); |
|
56 | - add_action( 'wp_loaded', array( 'EED_Event_Single', 'set_definitions' ), 2 ); |
|
57 | - EE_Config::register_route( __( 'event', 'event_espresso' ), 'Event_Single', 'run' ); |
|
55 | + add_filter('FHEE_run_EE_wp', '__return_true'); |
|
56 | + add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2); |
|
57 | + EE_Config::register_route(__('event', 'event_espresso'), 'Event_Single', 'run'); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @return void |
65 | 65 | */ |
66 | 66 | public static function set_hooks_admin() { |
67 | - add_action( 'wp_loaded', array( 'EED_Event_Single', 'set_definitions' ), 2 ); |
|
67 | + add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | * @return void |
79 | 79 | */ |
80 | 80 | public static function set_definitions() { |
81 | - define( 'EVENT_SINGLE_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
82 | - define( 'EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path( __FILE__ ) . 'templates' . DS ); |
|
81 | + define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
82 | + define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__).'templates'.DS); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @void |
91 | 91 | */ |
92 | - protected function set_config(){ |
|
93 | - $this->set_config_section( 'template_settings' ); |
|
94 | - $this->set_config_class( 'EE_Event_Single_Config' ); |
|
95 | - $this->set_config_name( 'EED_Event_Single' ); |
|
92 | + protected function set_config() { |
|
93 | + $this->set_config_section('template_settings'); |
|
94 | + $this->set_config_class('EE_Event_Single_Config'); |
|
95 | + $this->set_config_name('EED_Event_Single'); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | |
@@ -105,35 +105,35 @@ discard block |
||
105 | 105 | * @param \EE_Event_Single_Config $config |
106 | 106 | * @return \EE_Template_Part_Manager |
107 | 107 | */ |
108 | - public function initialize_template_parts( EE_Event_Single_Config $config = null ) { |
|
108 | + public function initialize_template_parts(EE_Event_Single_Config $config = null) { |
|
109 | 109 | $config = $config instanceof EE_Event_Single_Config ? $config : $this->config(); |
110 | 110 | EEH_Autoloader::instance()->register_template_part_autoloaders(); |
111 | 111 | $template_parts = new EE_Template_Part_Manager(); |
112 | 112 | $template_parts->add_template_part( |
113 | 113 | 'tickets', |
114 | - __( 'Ticket Selector', 'event_espresso' ), |
|
114 | + __('Ticket Selector', 'event_espresso'), |
|
115 | 115 | 'content-espresso_events-tickets.php', |
116 | 116 | $config->display_order_tickets |
117 | 117 | ); |
118 | 118 | $template_parts->add_template_part( |
119 | 119 | 'datetimes', |
120 | - __( 'Dates and Times', 'event_espresso' ), |
|
120 | + __('Dates and Times', 'event_espresso'), |
|
121 | 121 | 'content-espresso_events-datetimes.php', |
122 | 122 | $config->display_order_datetimes |
123 | 123 | ); |
124 | 124 | $template_parts->add_template_part( |
125 | 125 | 'event', |
126 | - __( 'Event Description', 'event_espresso' ), |
|
126 | + __('Event Description', 'event_espresso'), |
|
127 | 127 | 'content-espresso_events-details.php', |
128 | 128 | $config->display_order_event |
129 | 129 | ); |
130 | 130 | $template_parts->add_template_part( |
131 | 131 | 'venue', |
132 | - __( 'Venue Information', 'event_espresso' ), |
|
132 | + __('Venue Information', 'event_espresso'), |
|
133 | 133 | 'content-espresso_events-venues.php', |
134 | 134 | $config->display_order_venue |
135 | 135 | ); |
136 | - do_action( 'AHEE__EED_Event_Single__initialize_template_parts', $template_parts ); |
|
136 | + do_action('AHEE__EED_Event_Single__initialize_template_parts', $template_parts); |
|
137 | 137 | return $template_parts; |
138 | 138 | } |
139 | 139 | |
@@ -147,15 +147,15 @@ discard block |
||
147 | 147 | * @param WP $WP |
148 | 148 | * @return void |
149 | 149 | */ |
150 | - public function run( $WP ) { |
|
150 | + public function run($WP) { |
|
151 | 151 | // ensure valid EE_Events_Single_Config() object exists |
152 | 152 | $this->set_config(); |
153 | 153 | // check what template is loaded |
154 | - add_filter( 'template_include', array( $this, 'template_include' ), 999, 1 ); |
|
155 | - add_filter( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' ); |
|
154 | + add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
155 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
156 | 156 | // load css |
157 | - add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 10 ); |
|
158 | - EE_Registry::instance()->load_helper( 'Venue_View' ); |
|
157 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
158 | + EE_Registry::instance()->load_helper('Venue_View'); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | |
@@ -167,27 +167,27 @@ discard block |
||
167 | 167 | * @param string $template |
168 | 168 | * @return string |
169 | 169 | */ |
170 | - public function template_include( $template ) { |
|
170 | + public function template_include($template) { |
|
171 | 171 | global $post; |
172 | 172 | /** @type EE_Event_Single_Config $config */ |
173 | 173 | $config = $this->config(); |
174 | - if ( $config->display_status_banner_single ) { |
|
175 | - add_filter( 'the_title', array( 'EED_Event_Single', 'the_title' ), 100, 2 ); |
|
174 | + if ($config->display_status_banner_single) { |
|
175 | + add_filter('the_title', array('EED_Event_Single', 'the_title'), 100, 2); |
|
176 | 176 | } |
177 | 177 | // not a custom template? |
178 | 178 | if ( |
179 | 179 | EE_Front_Controller::instance()->get_selected_template() != 'single-espresso_events.php' |
180 | - || apply_filters( 'FHEE__EED_Event_Single__template_include__allow_custom_selected_template', FALSE ) |
|
181 | - && ! post_password_required( $post ) |
|
180 | + || apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', FALSE) |
|
181 | + && ! post_password_required($post) |
|
182 | 182 | ) { |
183 | 183 | EEH_Template::load_espresso_theme_functions(); |
184 | 184 | // then add extra event data via hooks |
185 | - add_action( 'loop_start', array( 'EED_Event_Single', 'loop_start' )); |
|
186 | - add_filter( 'get_the_excerpt', array( 'EED_Event_Single', 'get_the_excerpt' ), 1, 1 ); |
|
187 | - add_filter( 'the_content', array( 'EED_Event_Single', 'event_details' ), 100 ); |
|
188 | - add_action( 'loop_end', array( 'EED_Event_Single', 'loop_end' )); |
|
185 | + add_action('loop_start', array('EED_Event_Single', 'loop_start')); |
|
186 | + add_filter('get_the_excerpt', array('EED_Event_Single', 'get_the_excerpt'), 1, 1); |
|
187 | + add_filter('the_content', array('EED_Event_Single', 'event_details'), 100); |
|
188 | + add_action('loop_end', array('EED_Event_Single', 'loop_end')); |
|
189 | 189 | // don't display entry meta because the existing theme will take car of that |
190 | - add_filter( 'FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false' ); |
|
190 | + add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
191 | 191 | } |
192 | 192 | return $template; |
193 | 193 | } |
@@ -201,9 +201,9 @@ discard block |
||
201 | 201 | * @param array $wp_query_array an array containing the WP_Query object |
202 | 202 | * @return void |
203 | 203 | */ |
204 | - public static function loop_start( $wp_query_array ) { |
|
204 | + public static function loop_start($wp_query_array) { |
|
205 | 205 | global $post; |
206 | - do_action( 'AHEE_event_details_before_post', $post, $wp_query_array ); |
|
206 | + do_action('AHEE_event_details_before_post', $post, $wp_query_array); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | |
@@ -216,9 +216,9 @@ discard block |
||
216 | 216 | * @param int $id |
217 | 217 | * @return string |
218 | 218 | */ |
219 | - public static function the_title( $title = '', $id = 0 ) { |
|
219 | + public static function the_title($title = '', $id = 0) { |
|
220 | 220 | global $post; |
221 | - return in_the_loop() && $post->ID == $id ? espresso_event_status_banner( $post->ID ) . $title : $title; |
|
221 | + return in_the_loop() && $post->ID == $id ? espresso_event_status_banner($post->ID).$title : $title; |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | |
@@ -230,9 +230,9 @@ discard block |
||
230 | 230 | * @param string $excerpt |
231 | 231 | * @return string |
232 | 232 | */ |
233 | - public static function get_the_excerpt( $excerpt = '' ) { |
|
233 | + public static function get_the_excerpt($excerpt = '') { |
|
234 | 234 | EED_Event_Single::$using_get_the_excerpt = true; |
235 | - add_filter( 'wp_trim_excerpt', array( 'EED_Event_Single', 'end_get_the_excerpt' ), 999, 1 ); |
|
235 | + add_filter('wp_trim_excerpt', array('EED_Event_Single', 'end_get_the_excerpt'), 999, 1); |
|
236 | 236 | return $excerpt; |
237 | 237 | } |
238 | 238 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * @param string $text |
246 | 246 | * @return string |
247 | 247 | */ |
248 | - public static function end_get_the_excerpt( $text = '' ) { |
|
248 | + public static function end_get_the_excerpt($text = '') { |
|
249 | 249 | EED_Event_Single::$using_get_the_excerpt = false; |
250 | 250 | return $text; |
251 | 251 | } |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * @param string $content |
260 | 260 | * @return string |
261 | 261 | */ |
262 | - public static function event_details( $content ) { |
|
262 | + public static function event_details($content) { |
|
263 | 263 | global $post; |
264 | 264 | static $current_post_ID = 0; |
265 | 265 | if ( |
@@ -274,15 +274,15 @@ discard block |
||
274 | 274 | // We want to allow those plugins to still do their thing and have access to our content, but depending on |
275 | 275 | // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice, |
276 | 276 | // so the following allows this filter to be applied multiple times, but only once for real |
277 | - $current_post_ID = did_action( 'loop_start' ) ? $post->ID : 0; |
|
278 | - if ( EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order ) { |
|
277 | + $current_post_ID = did_action('loop_start') ? $post->ID : 0; |
|
278 | + if (EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order) { |
|
279 | 279 | // we need to first remove this callback from being applied to the_content() |
280 | 280 | // (otherwise it will recurse and blow up the interweb) |
281 | - remove_filter( 'the_content', array( 'EED_Event_Single', 'event_details' ), 100 ); |
|
281 | + remove_filter('the_content', array('EED_Event_Single', 'event_details'), 100); |
|
282 | 282 | EED_Event_Single::instance()->template_parts = EED_Event_Single::instance()->initialize_template_parts(); |
283 | - $content = EEH_Template::locate_template( 'content-espresso_events-details.php' ); |
|
284 | - $content = EED_Event_Single::instance()->template_parts->apply_template_part_filters( $content ); |
|
285 | - add_filter( 'the_content', array( 'EED_Event_Single', 'event_details' ), 100 ); |
|
283 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
284 | + $content = EED_Event_Single::instance()->template_parts->apply_template_part_filters($content); |
|
285 | + add_filter('the_content', array('EED_Event_Single', 'event_details'), 100); |
|
286 | 286 | } else { |
287 | 287 | $content = EED_Event_Single::use_filterable_display_order(); |
288 | 288 | } |
@@ -303,19 +303,19 @@ discard block |
||
303 | 303 | // it uses the_content() for displaying the $post->post_content |
304 | 304 | // so in order to load a template that uses the_content() from within a callback being used to filter the_content(), |
305 | 305 | // we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb) |
306 | - remove_filter( 'the_content', array( 'EED_Event_Single', 'event_details' ), 100 ); |
|
306 | + remove_filter('the_content', array('EED_Event_Single', 'event_details'), 100); |
|
307 | 307 | //now add additional content |
308 | - add_filter( 'the_content', array( 'EED_Event_Single', 'event_datetimes' ), 110, 1 ); |
|
309 | - add_filter( 'the_content', array( 'EED_Event_Single', 'event_tickets' ), 120, 1 ); |
|
310 | - add_filter( 'the_content', array( 'EED_Event_Single', 'event_venues' ), 130, 1 ); |
|
311 | - do_action( 'AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters' ); |
|
308 | + add_filter('the_content', array('EED_Event_Single', 'event_datetimes'), 110, 1); |
|
309 | + add_filter('the_content', array('EED_Event_Single', 'event_tickets'), 120, 1); |
|
310 | + add_filter('the_content', array('EED_Event_Single', 'event_venues'), 130, 1); |
|
311 | + do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters'); |
|
312 | 312 | // now load our template |
313 | - $content = EEH_Template::locate_template( 'content-espresso_events-details.php' ); |
|
313 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
314 | 314 | //now add our filter back in, plus some others |
315 | - add_filter( 'the_content', array( 'EED_Event_Single', 'event_details' ), 100 ); |
|
316 | - remove_filter( 'the_content', array( 'EED_Event_Single', 'event_datetimes' ), 110 ); |
|
317 | - remove_filter( 'the_content', array( 'EED_Event_Single', 'event_tickets' ), 120 ); |
|
318 | - remove_filter( 'the_content', array( 'EED_Event_Single', 'event_venues' ), 130 ); |
|
315 | + add_filter('the_content', array('EED_Event_Single', 'event_details'), 100); |
|
316 | + remove_filter('the_content', array('EED_Event_Single', 'event_datetimes'), 110); |
|
317 | + remove_filter('the_content', array('EED_Event_Single', 'event_tickets'), 120); |
|
318 | + remove_filter('the_content', array('EED_Event_Single', 'event_venues'), 130); |
|
319 | 319 | // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
320 | 320 | return $content; |
321 | 321 | } |
@@ -329,8 +329,8 @@ discard block |
||
329 | 329 | * @param string $content |
330 | 330 | * @return string |
331 | 331 | */ |
332 | - public static function event_datetimes( $content ) { |
|
333 | - return EEH_Template::locate_template( 'content-espresso_events-datetimes.php' ) . $content; |
|
332 | + public static function event_datetimes($content) { |
|
333 | + return EEH_Template::locate_template('content-espresso_events-datetimes.php').$content; |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | |
@@ -342,8 +342,8 @@ discard block |
||
342 | 342 | * @param string $content |
343 | 343 | * @return string |
344 | 344 | */ |
345 | - public static function event_tickets( $content ) { |
|
346 | - return EEH_Template::locate_template( 'content-espresso_events-tickets.php' ) . $content; |
|
345 | + public static function event_tickets($content) { |
|
346 | + return EEH_Template::locate_template('content-espresso_events-tickets.php').$content; |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | |
@@ -355,8 +355,8 @@ discard block |
||
355 | 355 | * @param string $content |
356 | 356 | * @return string |
357 | 357 | */ |
358 | - public static function event_venue( $content ) { |
|
359 | - return EED_Event_Single::event_venues( $content ); |
|
358 | + public static function event_venue($content) { |
|
359 | + return EED_Event_Single::event_venues($content); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | |
@@ -368,8 +368,8 @@ discard block |
||
368 | 368 | * @param string $content |
369 | 369 | * @return string |
370 | 370 | */ |
371 | - public static function event_venues( $content ) { |
|
372 | - return $content . EEH_Template::locate_template( 'content-espresso_events-venues.php' ); |
|
371 | + public static function event_venues($content) { |
|
372 | + return $content.EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | |
@@ -381,9 +381,9 @@ discard block |
||
381 | 381 | * @param array $wp_query_array an array containing the WP_Query object |
382 | 382 | * @return void |
383 | 383 | */ |
384 | - public static function loop_end( $wp_query_array ) { |
|
384 | + public static function loop_end($wp_query_array) { |
|
385 | 385 | global $post; |
386 | - do_action( 'AHEE_event_details_after_post', $post, $wp_query_array ); |
|
386 | + do_action('AHEE_event_details_after_post', $post, $wp_query_array); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | |
@@ -396,18 +396,18 @@ discard block |
||
396 | 396 | */ |
397 | 397 | public function wp_enqueue_scripts() { |
398 | 398 | // get some style |
399 | - if ( apply_filters( 'FHEE_enable_default_espresso_css', TRUE ) && apply_filters( 'FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', TRUE )) { |
|
400 | - EE_Registry::instance()->load_helper( 'File' ); |
|
399 | + if (apply_filters('FHEE_enable_default_espresso_css', TRUE) && apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', TRUE)) { |
|
400 | + EE_Registry::instance()->load_helper('File'); |
|
401 | 401 | // first check uploads folder |
402 | - if ( is_readable( get_stylesheet_directory() . $this->theme . DS . 'style.css' )) { |
|
403 | - wp_register_style( $this->theme, get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', array( 'dashicons', 'espresso_default' )); |
|
402 | + if (is_readable(get_stylesheet_directory().$this->theme.DS.'style.css')) { |
|
403 | + wp_register_style($this->theme, get_stylesheet_directory_uri().$this->theme.DS.'style.css', array('dashicons', 'espresso_default')); |
|
404 | 404 | } else { |
405 | - wp_register_style( $this->theme, EE_TEMPLATES_URL . $this->theme . DS . 'style.css', array( 'dashicons', 'espresso_default' )); |
|
405 | + wp_register_style($this->theme, EE_TEMPLATES_URL.$this->theme.DS.'style.css', array('dashicons', 'espresso_default')); |
|
406 | 406 | } |
407 | - wp_enqueue_script( $this->theme ); |
|
408 | - if ( EE_Registry::instance()->CFG->map_settings->use_google_maps ) { |
|
409 | - EE_Registry::instance()->load_helper( 'Maps' ); |
|
410 | - add_action('wp_enqueue_scripts', array( 'EEH_Maps', 'espresso_google_map_js' ), 11 ); |
|
407 | + wp_enqueue_script($this->theme); |
|
408 | + if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
409 | + EE_Registry::instance()->load_helper('Maps'); |
|
410 | + add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
411 | 411 | } |
412 | 412 | } |
413 | 413 | } |
@@ -426,12 +426,12 @@ discard block |
||
426 | 426 | * @return bool |
427 | 427 | */ |
428 | 428 | public static function display_venue() { |
429 | - EE_Registry::instance()->load_helper( 'Venue_View' ); |
|
429 | + EE_Registry::instance()->load_helper('Venue_View'); |
|
430 | 430 | /** @type EE_Event_Single_Config $config */ |
431 | 431 | $config = EED_Event_Single::instance()->config(); |
432 | - $display_venue= isset( $config->display_venue ) ? $config->display_venue : TRUE; |
|
432 | + $display_venue = isset($config->display_venue) ? $config->display_venue : TRUE; |
|
433 | 433 | $venue_name = EEH_Venue_View::venue_name(); |
434 | - return $display_venue && ! empty( $venue_name ) ? TRUE : FALSE; |
|
434 | + return $display_venue && ! empty($venue_name) ? TRUE : FALSE; |
|
435 | 435 | } |
436 | 436 | |
437 | 437 |