@@ -445,8 +445,8 @@ discard block |
||
445 | 445 | $new_question->set_admin_label( sprintf( __( '%s **Duplicate**', 'event_espresso' ), $this->admin_label() ) ); |
446 | 446 | $new_question->set_system_ID( null ); |
447 | 447 | $new_question->set_wp_user( get_current_user_id() ); |
448 | - //if we're duplicating a trashed question, assume we don't want the new one to be trashed |
|
449 | - $new_question->set_deleted( false ); |
|
448 | + //if we're duplicating a trashed question, assume we don't want the new one to be trashed |
|
449 | + $new_question->set_deleted( false ); |
|
450 | 450 | $success = $new_question->save(); |
451 | 451 | if( $success ) { |
452 | 452 | //we don't totally want to duplicate the question options, because we want them to be for the NEW question |
@@ -501,8 +501,8 @@ discard block |
||
501 | 501 | } |
502 | 502 | // has this question been answered ? |
503 | 503 | if ( $answer instanceof EE_Answer |
504 | - && $answer->value() !== '' |
|
505 | - ) { |
|
504 | + && $answer->value() !== '' |
|
505 | + ) { |
|
506 | 506 | //answer gets htmlspecialchars called on it, undo that please |
507 | 507 | //because the form input's display strategy may call esc_attr too |
508 | 508 | //which also does html special characters |
@@ -628,17 +628,17 @@ discard block |
||
628 | 628 | |
629 | 629 | |
630 | 630 | |
631 | - /** |
|
632 | - * Returns whether or not this question type should have question option entries |
|
633 | - * @return bool |
|
634 | - */ |
|
631 | + /** |
|
632 | + * Returns whether or not this question type should have question option entries |
|
633 | + * @return bool |
|
634 | + */ |
|
635 | 635 | public function should_have_question_options() |
636 | - { |
|
637 | - return in_array( |
|
638 | - $this->type(), |
|
639 | - $this->_model->question_types_with_options(), |
|
640 | - true |
|
641 | - ); |
|
642 | - } |
|
636 | + { |
|
637 | + return in_array( |
|
638 | + $this->type(), |
|
639 | + $this->_model->question_types_with_options(), |
|
640 | + true |
|
641 | + ); |
|
642 | + } |
|
643 | 643 | |
644 | 644 | } |
@@ -71,10 +71,10 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @access protected |
73 | 73 | * @var array $_question_type_categories { |
74 | - * @type string $text |
|
75 | - * @type string $single-answer-enum |
|
76 | - * @type string $multi-answer-enum |
|
77 | - * } |
|
74 | + * @type string $text |
|
75 | + * @type string $single-answer-enum |
|
76 | + * @type string $multi-answer-enum |
|
77 | + * } |
|
78 | 78 | */ |
79 | 79 | protected $_question_type_categories = array(); |
80 | 80 | |
@@ -156,14 +156,14 @@ discard block |
||
156 | 156 | 'text' => array( |
157 | 157 | EEM_Question::QST_type_text, |
158 | 158 | EEM_Question::QST_type_textarea, |
159 | - EEM_Question::QST_type_date, |
|
159 | + EEM_Question::QST_type_date, |
|
160 | 160 | EEM_Question::QST_type_html_textarea, |
161 | 161 | EEM_Question::QST_type_email, |
162 | 162 | EEM_Question::QST_type_us_phone, |
163 | 163 | EEM_Question::QST_type_decimal, |
164 | - EEM_Question::QST_type_int, |
|
164 | + EEM_Question::QST_type_int, |
|
165 | 165 | EEM_Question::QST_type_url, |
166 | - EEM_Question::QST_type_year |
|
166 | + EEM_Question::QST_type_year |
|
167 | 167 | ), |
168 | 168 | 'single-answer-enum' => array( |
169 | 169 | EEM_Question::QST_type_radio, |
@@ -251,32 +251,32 @@ discard block |
||
251 | 251 | |
252 | 252 | |
253 | 253 | |
254 | - /** |
|
255 | - * Returns all the question types in the given category |
|
256 | - * @param string $category |
|
257 | - * @return array|mixed |
|
258 | - */ |
|
254 | + /** |
|
255 | + * Returns all the question types in the given category |
|
256 | + * @param string $category |
|
257 | + * @return array|mixed |
|
258 | + */ |
|
259 | 259 | public function question_types_in_category($category) |
260 | - { |
|
261 | - if( isset($this->_question_type_categories[$category])) { |
|
262 | - return $this->_question_type_categories[$category]; |
|
263 | - } |
|
264 | - return array(); |
|
265 | - } |
|
266 | - |
|
267 | - |
|
268 | - |
|
269 | - /** |
|
270 | - * Returns all the question types that should have question options |
|
271 | - * @return array |
|
272 | - */ |
|
273 | - public function question_types_with_options() |
|
274 | - { |
|
275 | - return array_merge( |
|
276 | - $this->question_types_in_category('single-answer-enum'), |
|
277 | - $this->question_types_in_category('multi-answer-enum') |
|
278 | - ); |
|
279 | - } |
|
260 | + { |
|
261 | + if( isset($this->_question_type_categories[$category])) { |
|
262 | + return $this->_question_type_categories[$category]; |
|
263 | + } |
|
264 | + return array(); |
|
265 | + } |
|
266 | + |
|
267 | + |
|
268 | + |
|
269 | + /** |
|
270 | + * Returns all the question types that should have question options |
|
271 | + * @return array |
|
272 | + */ |
|
273 | + public function question_types_with_options() |
|
274 | + { |
|
275 | + return array_merge( |
|
276 | + $this->question_types_in_category('single-answer-enum'), |
|
277 | + $this->question_types_in_category('multi-answer-enum') |
|
278 | + ); |
|
279 | + } |
|
280 | 280 | |
281 | 281 | /** |
282 | 282 | * Returns the question type categories 2d array |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | -require_once( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
|
5 | -require_once( EE_CLASSES . 'EE_Question.class.php' ); |
|
4 | +require_once(EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
5 | +require_once(EE_CLASSES.'EE_Question.class.php'); |
|
6 | 6 | |
7 | 7 | |
8 | 8 | |
@@ -105,52 +105,52 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @param null $timezone |
107 | 107 | */ |
108 | - protected function __construct( $timezone = NULL ) { |
|
109 | - $this->singular_item = __('Question','event_espresso'); |
|
110 | - $this->plural_item = __('Questions','event_espresso'); |
|
111 | - $this->_allowed_question_types=apply_filters( |
|
108 | + protected function __construct($timezone = NULL) { |
|
109 | + $this->singular_item = __('Question', 'event_espresso'); |
|
110 | + $this->plural_item = __('Questions', 'event_espresso'); |
|
111 | + $this->_allowed_question_types = apply_filters( |
|
112 | 112 | 'FHEE__EEM_Question__construct__allowed_question_types', |
113 | 113 | array( |
114 | - EEM_Question::QST_type_text =>__('Text','event_espresso'), |
|
115 | - EEM_Question::QST_type_textarea =>__('Textarea','event_espresso'), |
|
116 | - EEM_Question::QST_type_checkbox =>__('Checkboxes','event_espresso'), |
|
117 | - EEM_Question::QST_type_radio =>__('Radio Buttons','event_espresso'), |
|
118 | - EEM_Question::QST_type_dropdown =>__('Dropdown','event_espresso'), |
|
119 | - EEM_Question::QST_type_state =>__('State/Province Dropdown','event_espresso'), |
|
120 | - EEM_Question::QST_type_country =>__('Country Dropdown','event_espresso'), |
|
121 | - EEM_Question::QST_type_date =>__('Date Picker','event_espresso'), |
|
122 | - EEM_Question::QST_type_html_textarea => __( 'HTML Textarea', 'event_espresso' ), |
|
123 | - EEM_Question::QST_type_email => __( 'Email', 'event_espresso' ), |
|
124 | - EEM_Question::QST_type_us_phone => __( 'USA - Format Phone', 'event_espresso' ), |
|
125 | - EEM_Question::QST_type_decimal => __( 'Number', 'event_espresso' ), |
|
126 | - EEM_Question::QST_type_int => __( 'Whole Number', 'event_espresso' ), |
|
127 | - EEM_Question::QST_type_url => __( 'URL', 'event_espresso' ), |
|
128 | - EEM_Question::QST_type_year => __( 'Year', 'event_espresso' ), |
|
129 | - EEM_Question::QST_type_multi_select => __( 'Multi Select', 'event_espresso' ) |
|
114 | + EEM_Question::QST_type_text =>__('Text', 'event_espresso'), |
|
115 | + EEM_Question::QST_type_textarea =>__('Textarea', 'event_espresso'), |
|
116 | + EEM_Question::QST_type_checkbox =>__('Checkboxes', 'event_espresso'), |
|
117 | + EEM_Question::QST_type_radio =>__('Radio Buttons', 'event_espresso'), |
|
118 | + EEM_Question::QST_type_dropdown =>__('Dropdown', 'event_espresso'), |
|
119 | + EEM_Question::QST_type_state =>__('State/Province Dropdown', 'event_espresso'), |
|
120 | + EEM_Question::QST_type_country =>__('Country Dropdown', 'event_espresso'), |
|
121 | + EEM_Question::QST_type_date =>__('Date Picker', 'event_espresso'), |
|
122 | + EEM_Question::QST_type_html_textarea => __('HTML Textarea', 'event_espresso'), |
|
123 | + EEM_Question::QST_type_email => __('Email', 'event_espresso'), |
|
124 | + EEM_Question::QST_type_us_phone => __('USA - Format Phone', 'event_espresso'), |
|
125 | + EEM_Question::QST_type_decimal => __('Number', 'event_espresso'), |
|
126 | + EEM_Question::QST_type_int => __('Whole Number', 'event_espresso'), |
|
127 | + EEM_Question::QST_type_url => __('URL', 'event_espresso'), |
|
128 | + EEM_Question::QST_type_year => __('Year', 'event_espresso'), |
|
129 | + EEM_Question::QST_type_multi_select => __('Multi Select', 'event_espresso') |
|
130 | 130 | ) |
131 | 131 | ); |
132 | 132 | $this->_question_descriptions = apply_filters( |
133 | 133 | 'FHEE__EEM_Question__construct__allowed_question_types', |
134 | 134 | array( |
135 | - EEM_Question::QST_type_text => __( 'A single line text input field', 'event_espresso' ), |
|
136 | - EEM_Question::QST_type_textarea => __( 'A multi line text input field', 'event_espresso' ), |
|
137 | - EEM_Question::QST_type_checkbox => __( 'Allows multiple preset options to be selected', 'event_espresso' ), |
|
138 | - EEM_Question::QST_type_radio => __( 'Allows a single preset option to be selected', 'event_espresso' ), |
|
139 | - EEM_Question::QST_type_dropdown => __( 'A dropdown that allows a single selection', 'event_espresso' ), |
|
140 | - EEM_Question::QST_type_state => __( 'A dropdown that lists states/provinces', 'event_espresso' ), |
|
141 | - EEM_Question::QST_type_country => __( 'A dropdown that lists countries', 'event_espresso' ), |
|
142 | - EEM_Question::QST_type_date => __( 'A popup calendar that allows date selections', 'event_espresso' ), |
|
143 | - EEM_Question::QST_type_html_textarea => __( 'A multi line text input field that allows HTML', 'event_espresso' ), |
|
144 | - EEM_Question::QST_type_email => __( 'A text field that must contain a valid Email address', 'event_espresso' ), |
|
145 | - EEM_Question::QST_type_us_phone => __( 'A text field that must contain a valid US phone number', 'event_espresso' ), |
|
146 | - EEM_Question::QST_type_decimal => __( 'A text field that allows number values with decimals', 'event_espresso' ), |
|
147 | - EEM_Question::QST_type_int => __( 'A text field that only allows whole numbers (no decimals)', 'event_espresso' ), |
|
148 | - EEM_Question::QST_type_url => __( 'A text field that must contain a valid URL', 'event_espresso' ), |
|
149 | - EEM_Question::QST_type_year => __( 'A dropdown that lists the last 100 years', 'event_espresso' ), |
|
150 | - EEM_Question::QST_type_multi_select => __( 'A dropdown that allows multiple selections', 'event_espresso' ) |
|
135 | + EEM_Question::QST_type_text => __('A single line text input field', 'event_espresso'), |
|
136 | + EEM_Question::QST_type_textarea => __('A multi line text input field', 'event_espresso'), |
|
137 | + EEM_Question::QST_type_checkbox => __('Allows multiple preset options to be selected', 'event_espresso'), |
|
138 | + EEM_Question::QST_type_radio => __('Allows a single preset option to be selected', 'event_espresso'), |
|
139 | + EEM_Question::QST_type_dropdown => __('A dropdown that allows a single selection', 'event_espresso'), |
|
140 | + EEM_Question::QST_type_state => __('A dropdown that lists states/provinces', 'event_espresso'), |
|
141 | + EEM_Question::QST_type_country => __('A dropdown that lists countries', 'event_espresso'), |
|
142 | + EEM_Question::QST_type_date => __('A popup calendar that allows date selections', 'event_espresso'), |
|
143 | + EEM_Question::QST_type_html_textarea => __('A multi line text input field that allows HTML', 'event_espresso'), |
|
144 | + EEM_Question::QST_type_email => __('A text field that must contain a valid Email address', 'event_espresso'), |
|
145 | + EEM_Question::QST_type_us_phone => __('A text field that must contain a valid US phone number', 'event_espresso'), |
|
146 | + EEM_Question::QST_type_decimal => __('A text field that allows number values with decimals', 'event_espresso'), |
|
147 | + EEM_Question::QST_type_int => __('A text field that only allows whole numbers (no decimals)', 'event_espresso'), |
|
148 | + EEM_Question::QST_type_url => __('A text field that must contain a valid URL', 'event_espresso'), |
|
149 | + EEM_Question::QST_type_year => __('A dropdown that lists the last 100 years', 'event_espresso'), |
|
150 | + EEM_Question::QST_type_multi_select => __('A dropdown that allows multiple selections', 'event_espresso') |
|
151 | 151 | ) |
152 | 152 | ); |
153 | - $this->_question_type_categories = (array)apply_filters( |
|
153 | + $this->_question_type_categories = (array) apply_filters( |
|
154 | 154 | 'FHEE__EEM_Question__construct__question_type_categories', |
155 | 155 | array( |
156 | 156 | 'text' => array( |
@@ -177,22 +177,22 @@ discard block |
||
177 | 177 | ); |
178 | 178 | |
179 | 179 | $this->_tables = array( |
180 | - 'Question'=>new EE_Primary_Table('esp_question','QST_ID') |
|
180 | + 'Question'=>new EE_Primary_Table('esp_question', 'QST_ID') |
|
181 | 181 | ); |
182 | 182 | $this->_fields = array( |
183 | 183 | 'Question'=>array( |
184 | - 'QST_ID'=>new EE_Primary_Key_Int_Field('QST_ID', __('Question ID','event_espresso')), |
|
185 | - 'QST_display_text'=>new EE_Post_Content_Field('QST_display_text', __('Question Text','event_espresso'), true, ''), |
|
186 | - 'QST_admin_label'=>new EE_Plain_Text_Field('QST_admin_label', __('Question Label (admin-only)','event_espresso'), true, ''), |
|
187 | - 'QST_system'=>new EE_Plain_Text_Field('QST_system', __('Internal string ID for question','event_espresso'), false, '' ), |
|
188 | - 'QST_type'=>new EE_Enum_Text_Field('QST_type', __('Question Type','event_espresso'),false, 'TEXT',$this->_allowed_question_types), |
|
189 | - 'QST_required'=>new EE_Boolean_Field('QST_required', __('Required Question?','event_espresso'), false, false), |
|
190 | - 'QST_required_text'=>new EE_Simple_HTML_Field('QST_required_text', __('Text to Display if Not Provided','event_espresso'), true, ''), |
|
191 | - 'QST_order'=>new EE_Integer_Field('QST_order', __('Question Order','event_espresso'), false, 0), |
|
192 | - 'QST_admin_only'=>new EE_Boolean_Field('QST_admin_only', __('Admin-Only Question?','event_espresso'), false, false), |
|
193 | - 'QST_max' => new EE_Infinite_Integer_Field( 'QST_max', __( 'Max Size', 'event_espresso' ), false, EE_INF ), |
|
194 | - 'QST_wp_user'=>new EE_WP_User_Field('QST_wp_user', __('Question Creator ID','event_espresso'), false ), |
|
195 | - 'QST_deleted'=>new EE_Trashed_Flag_Field('QST_deleted', __('Flag Indicating question was deleted','event_espresso'), false, false) |
|
184 | + 'QST_ID'=>new EE_Primary_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso')), |
|
185 | + 'QST_display_text'=>new EE_Post_Content_Field('QST_display_text', __('Question Text', 'event_espresso'), true, ''), |
|
186 | + 'QST_admin_label'=>new EE_Plain_Text_Field('QST_admin_label', __('Question Label (admin-only)', 'event_espresso'), true, ''), |
|
187 | + 'QST_system'=>new EE_Plain_Text_Field('QST_system', __('Internal string ID for question', 'event_espresso'), false, ''), |
|
188 | + 'QST_type'=>new EE_Enum_Text_Field('QST_type', __('Question Type', 'event_espresso'), false, 'TEXT', $this->_allowed_question_types), |
|
189 | + 'QST_required'=>new EE_Boolean_Field('QST_required', __('Required Question?', 'event_espresso'), false, false), |
|
190 | + 'QST_required_text'=>new EE_Simple_HTML_Field('QST_required_text', __('Text to Display if Not Provided', 'event_espresso'), true, ''), |
|
191 | + 'QST_order'=>new EE_Integer_Field('QST_order', __('Question Order', 'event_espresso'), false, 0), |
|
192 | + 'QST_admin_only'=>new EE_Boolean_Field('QST_admin_only', __('Admin-Only Question?', 'event_espresso'), false, false), |
|
193 | + 'QST_max' => new EE_Infinite_Integer_Field('QST_max', __('Max Size', 'event_espresso'), false, EE_INF), |
|
194 | + 'QST_wp_user'=>new EE_WP_User_Field('QST_wp_user', __('Question Creator ID', 'event_espresso'), false), |
|
195 | + 'QST_deleted'=>new EE_Trashed_Flag_Field('QST_deleted', __('Flag Indicating question was deleted', 'event_espresso'), false, false) |
|
196 | 196 | ) |
197 | 197 | ); |
198 | 198 | $this->_model_relations = array( |
@@ -204,11 +204,11 @@ discard block |
||
204 | 204 | 'Question_Group_Question'=>new EE_Has_Many_Relation() |
205 | 205 | ); |
206 | 206 | //this model is generally available for reading |
207 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
208 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('QST_system'); |
|
209 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('QST_system'); |
|
210 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('QST_system'); |
|
211 | - parent::__construct( $timezone ); |
|
207 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
208 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Reg_Form('QST_system'); |
|
209 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Reg_Form('QST_system'); |
|
210 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Reg_Form('QST_system'); |
|
211 | + parent::__construct($timezone); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * but they can be extended |
217 | 217 | * @return string[] |
218 | 218 | */ |
219 | - public function allowed_question_types(){ |
|
219 | + public function allowed_question_types() { |
|
220 | 220 | return $this->_allowed_question_types; |
221 | 221 | } |
222 | 222 | /** |
@@ -224,16 +224,16 @@ discard block |
||
224 | 224 | * @param string $question_type one of EEM_Question::allowed_question_types( |
225 | 225 | * @return string[] like EEM_Question::allowed_question_types() |
226 | 226 | */ |
227 | - public function question_types_in_same_category( $question_type ) { |
|
228 | - $question_types = array( $question_type ); |
|
229 | - foreach( $this->_question_type_categories as $category => $question_types_in_category ) { |
|
230 | - if( in_array( $question_type, $question_types_in_category ) ) { |
|
227 | + public function question_types_in_same_category($question_type) { |
|
228 | + $question_types = array($question_type); |
|
229 | + foreach ($this->_question_type_categories as $category => $question_types_in_category) { |
|
230 | + if (in_array($question_type, $question_types_in_category)) { |
|
231 | 231 | $question_types = $question_types_in_category; |
232 | 232 | break; |
233 | 233 | } |
234 | 234 | } |
235 | 235 | |
236 | - return array_intersect_key( $this->allowed_question_types(), array_flip( $question_types ) ); |
|
236 | + return array_intersect_key($this->allowed_question_types(), array_flip($question_types)); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | /** |
@@ -242,11 +242,11 @@ discard block |
||
242 | 242 | * @param string $category one of the top-level keys of EEM_Question::question_type_categories() |
243 | 243 | * @return boolean |
244 | 244 | */ |
245 | - public function question_type_is_in_category( $question_type, $category ) { |
|
246 | - if( ! isset( $this->_question_type_categories[ $category ] ) ) { |
|
245 | + public function question_type_is_in_category($question_type, $category) { |
|
246 | + if ( ! isset($this->_question_type_categories[$category])) { |
|
247 | 247 | return false; |
248 | 248 | } |
249 | - return in_array( $question_type, $this->_question_type_categories[ $category ] ); |
|
249 | + return in_array($question_type, $this->_question_type_categories[$category]); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | */ |
259 | 259 | public function question_types_in_category($category) |
260 | 260 | { |
261 | - if( isset($this->_question_type_categories[$category])) { |
|
261 | + if (isset($this->_question_type_categories[$category])) { |
|
262 | 262 | return $this->_question_type_categories[$category]; |
263 | 263 | } |
264 | 264 | return array(); |
@@ -292,9 +292,9 @@ discard block |
||
292 | 292 | * @param string $system_question_group_id QSG_system |
293 | 293 | * @return array of system question names (QST_system) |
294 | 294 | */ |
295 | - public function allowed_system_questions_in_system_question_group( $system_question_group_id ) { |
|
295 | + public function allowed_system_questions_in_system_question_group($system_question_group_id) { |
|
296 | 296 | $question_system_ids = array(); |
297 | - switch( $system_question_group_id ) { |
|
297 | + switch ($system_question_group_id) { |
|
298 | 298 | case EEM_Question_Group::system_personal: |
299 | 299 | $question_system_ids = array( |
300 | 300 | EEM_Attendee::system_question_fname, |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | ); |
316 | 316 | break; |
317 | 317 | } |
318 | - return apply_filters( 'FHEE__EEM_Question__system_questions_allowed_in_system_question_group__return', $question_system_ids, $system_question_group_id ); |
|
318 | + return apply_filters('FHEE__EEM_Question__system_questions_allowed_in_system_question_group__return', $question_system_ids, $system_question_group_id); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | /** |
@@ -324,11 +324,11 @@ discard block |
||
324 | 324 | * @param string $system_question_group_id QSG_system |
325 | 325 | * @return array of system question names (QST_system) |
326 | 326 | */ |
327 | - public function required_system_questions_in_system_question_group( $system_question_group_id ) { |
|
327 | + public function required_system_questions_in_system_question_group($system_question_group_id) { |
|
328 | 328 | $question_system_ids = null; |
329 | - switch( $system_question_group_id ) { |
|
329 | + switch ($system_question_group_id) { |
|
330 | 330 | case EEM_Question_Group::system_personal: |
331 | - $question_system_ids = array( |
|
331 | + $question_system_ids = array( |
|
332 | 332 | EEM_Attendee::system_question_fname, |
333 | 333 | EEM_Attendee::system_question_email, |
334 | 334 | ); |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | default: |
337 | 337 | $question_system_ids = array(); |
338 | 338 | } |
339 | - return apply_filters( 'FHEE__EEM_Question__system_questions_required_in_system_question_group', $question_system_ids, $system_question_group_id ); |
|
339 | + return apply_filters('FHEE__EEM_Question__system_questions_required_in_system_question_group', $question_system_ids, $system_question_group_id); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | |
@@ -347,8 +347,8 @@ discard block |
||
347 | 347 | * @param $QST_system |
348 | 348 | * @return int of QST_ID for the question that corresponds to that QST_system |
349 | 349 | */ |
350 | - public function get_Question_ID_from_system_string( $QST_system ){ |
|
351 | - return $this->get_var( array( array( 'QST_system' => $QST_system ) ) ); |
|
350 | + public function get_Question_ID_from_system_string($QST_system) { |
|
351 | + return $this->get_var(array(array('QST_system' => $QST_system))); |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | |
@@ -360,10 +360,10 @@ discard block |
||
360 | 360 | */ |
361 | 361 | public function get_latest_question_order() { |
362 | 362 | $columns_to_select = array( |
363 | - 'max_order' => array("MAX(QST_order)","%d") |
|
363 | + 'max_order' => array("MAX(QST_order)", "%d") |
|
364 | 364 | ); |
365 | - $max = $this->_get_all_wpdb_results( array(), ARRAY_A, $columns_to_select ); |
|
366 | - return isset( $max[0], $max[0]['max_order'] ) ? $max[0]['max_order'] : 0; |
|
365 | + $max = $this->_get_all_wpdb_results(array(), ARRAY_A, $columns_to_select); |
|
366 | + return isset($max[0], $max[0]['max_order']) ? $max[0]['max_order'] : 0; |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | /** |
@@ -392,10 +392,10 @@ discard block |
||
392 | 392 | * @param string $system_question_value |
393 | 393 | * @return int|float |
394 | 394 | */ |
395 | - public function absolute_max_for_system_question( $system_question_value ) { |
|
395 | + public function absolute_max_for_system_question($system_question_value) { |
|
396 | 396 | $maxes = $this->system_question_maxes(); |
397 | - if( isset( $maxes[ $system_question_value ] ) ) { |
|
398 | - return $maxes[ $system_question_value ]; |
|
397 | + if (isset($maxes[$system_question_value])) { |
|
398 | + return $maxes[$system_question_value]; |
|
399 | 399 | } else { |
400 | 400 | return EE_INF; |
401 | 401 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -17,157 +17,157 @@ discard block |
||
17 | 17 | { |
18 | 18 | |
19 | 19 | |
20 | - /** |
|
21 | - * enqueues css and js, so that this can be called statically |
|
22 | - */ |
|
23 | - public static function enqueue_styles_and_scripts() |
|
24 | - { |
|
25 | - wp_register_style( |
|
26 | - 'checkbox_dropdown_selector', |
|
27 | - EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css', |
|
28 | - array('espresso_default'), |
|
29 | - EVENT_ESPRESSO_VERSION |
|
30 | - ); |
|
31 | - wp_register_style( |
|
32 | - 'espresso_default', |
|
33 | - EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
34 | - array('dashicons'), |
|
35 | - EVENT_ESPRESSO_VERSION |
|
36 | - ); |
|
37 | - wp_enqueue_style('checkbox_dropdown_selector'); |
|
38 | - wp_register_script( |
|
39 | - 'checkbox_dropdown_selector', |
|
40 | - EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js', |
|
41 | - array('jquery'), |
|
42 | - EVENT_ESPRESSO_VERSION, |
|
43 | - true |
|
44 | - ); |
|
45 | - wp_enqueue_script('checkbox_dropdown_selector'); |
|
46 | - } |
|
47 | - |
|
48 | - |
|
49 | - |
|
50 | - /** |
|
51 | - * Informs the rest of the forms system what CSS and JS is needed to display the input |
|
52 | - */ |
|
53 | - public function enqueue_js(){ |
|
54 | - EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts(); |
|
55 | - } |
|
56 | - |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * callback for Iframe::addStylesheets() child class methods |
|
61 | - * |
|
62 | - * @param array $iframe_css |
|
63 | - * @return array |
|
64 | - */ |
|
65 | - public function iframe_css(array $iframe_css){ |
|
66 | - $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css'; |
|
67 | - return $iframe_css; |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * callback for Iframe::addScripts() child class methods |
|
74 | - * |
|
75 | - * @param array $iframe_js |
|
76 | - * @return array |
|
77 | - */ |
|
78 | - public function iframe_js(array $iframe_js){ |
|
79 | - $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js'; |
|
80 | - return $iframe_js; |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * @throws EE_Error |
|
86 | - * @return string of html to display the field |
|
87 | - */ |
|
88 | - public function display() |
|
89 | - { |
|
90 | - $input = $this->get_input(); |
|
91 | - $select_button_text = $input instanceof EE_Checkbox_Dropdown_Selector_Input ? $input->select_button_text() : ''; |
|
92 | - // $multi = count( $input->options() ) > 1 ? TRUE : FALSE; |
|
93 | - $input->set_label_sizes(); |
|
94 | - $label_size_class = $input->get_label_size_class(); |
|
95 | - if ( ! is_array($input->raw_value()) && $input->raw_value() !== null) { |
|
96 | - EE_Error::doing_it_wrong( |
|
97 | - 'EE_Checkbox_Display_Strategy::display()', |
|
98 | - sprintf( |
|
99 | - esc_html__( |
|
100 | - 'Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"', |
|
101 | - 'event_espresso' |
|
102 | - ), |
|
103 | - $input->html_id(), |
|
104 | - var_export($input->raw_value(), true), |
|
105 | - $input->html_name() . '[]' |
|
106 | - ), |
|
107 | - '4.8.1' |
|
108 | - ); |
|
109 | - } |
|
110 | - |
|
111 | - |
|
112 | - $html = \EEH_HTML::div('', '', 'checkbox-dropdown-selector-wrap-dv'); |
|
113 | - $html .= '<button id="' . $input->html_id() . '-btn"'; |
|
114 | - // $html .= ' name="' . $input->html_name() . '"'; |
|
115 | - $html .= ' class="' . $input->html_class() . ' checkbox-dropdown-selector-btn button-secondary button"'; |
|
116 | - $html .= ' style="' . $input->html_style() . '"'; |
|
117 | - $html .= ' data-target="' . $input->html_id() . '-options-dv"'; |
|
118 | - $html .= ' ' . $input->html_other_attributes() . '>'; |
|
119 | - $html .= '<span class="checkbox-dropdown-selector-selected-spn">'; |
|
120 | - $html .= $select_button_text; |
|
121 | - $html .= '</span> <span class="dashicons dashicons-arrow-down"></span>'; |
|
122 | - $html .= '</button>'; |
|
123 | - $html .= EEH_HTML::div( |
|
124 | - '', |
|
125 | - $input->html_id() . '-options-dv', |
|
126 | - 'checkbox-dropdown-selector' |
|
127 | - ); |
|
128 | - $html .= EEH_HTML::link( |
|
129 | - '', |
|
130 | - '<span class="dashicons dashicons-no"></span>', |
|
131 | - esc_html__('close datetime selector', 'event_espresso'), |
|
132 | - '', |
|
133 | - 'close-espresso-notice' |
|
134 | - ); |
|
135 | - $html .= EEH_HTML::ul(); |
|
136 | - $input_raw_value = (array)$input->raw_value(); |
|
137 | - foreach ($input->options() as $value => $display_text) { |
|
138 | - $html .= EEH_HTML::li(); |
|
139 | - $value = $input->get_normalization_strategy()->unnormalize_one($value); |
|
140 | - $html_id = $this->get_sub_input_id($value); |
|
141 | - $html .= EEH_HTML::nl(0, 'checkbox'); |
|
142 | - $html .= '<label for="' |
|
143 | - . $html_id |
|
144 | - . '" id="' |
|
145 | - . $html_id |
|
146 | - . '-lbl" class="ee-checkbox-label-after' |
|
147 | - . $label_size_class |
|
148 | - . '">'; |
|
149 | - $html .= EEH_HTML::nl(1, 'checkbox'); |
|
150 | - $html .= '<input type="checkbox"'; |
|
151 | - $html .= ' name="' . $input->html_name() . '[]"'; |
|
152 | - $html .= ' id="' . $html_id . '"'; |
|
153 | - $html .= ' class="' . $input->html_class() . '-option"'; |
|
154 | - $html .= ' style="' . $input->html_style() . '"'; |
|
155 | - $html .= ' value="' . esc_attr($value) . '"'; |
|
156 | - $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true) |
|
157 | - ? ' checked="checked"' |
|
158 | - : ''; |
|
159 | - $html .= ' ' . $this->_input->other_html_attributes(); |
|
160 | - $html .= '>'; |
|
161 | - $html .= '<span class="datetime-selector-option-text-spn">' . $display_text . '</span>'; |
|
162 | - $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>'; |
|
163 | - $html .= EEH_HTML::lix(); |
|
164 | - } |
|
165 | - $html .= EEH_HTML::ulx(); |
|
166 | - $html .= EEH_HTML::divx(); |
|
167 | - $html .= EEH_HTML::divx(); |
|
168 | - $html .= \EEH_HTML::br(); |
|
169 | - return $html; |
|
170 | - } |
|
20 | + /** |
|
21 | + * enqueues css and js, so that this can be called statically |
|
22 | + */ |
|
23 | + public static function enqueue_styles_and_scripts() |
|
24 | + { |
|
25 | + wp_register_style( |
|
26 | + 'checkbox_dropdown_selector', |
|
27 | + EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css', |
|
28 | + array('espresso_default'), |
|
29 | + EVENT_ESPRESSO_VERSION |
|
30 | + ); |
|
31 | + wp_register_style( |
|
32 | + 'espresso_default', |
|
33 | + EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
34 | + array('dashicons'), |
|
35 | + EVENT_ESPRESSO_VERSION |
|
36 | + ); |
|
37 | + wp_enqueue_style('checkbox_dropdown_selector'); |
|
38 | + wp_register_script( |
|
39 | + 'checkbox_dropdown_selector', |
|
40 | + EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js', |
|
41 | + array('jquery'), |
|
42 | + EVENT_ESPRESSO_VERSION, |
|
43 | + true |
|
44 | + ); |
|
45 | + wp_enqueue_script('checkbox_dropdown_selector'); |
|
46 | + } |
|
47 | + |
|
48 | + |
|
49 | + |
|
50 | + /** |
|
51 | + * Informs the rest of the forms system what CSS and JS is needed to display the input |
|
52 | + */ |
|
53 | + public function enqueue_js(){ |
|
54 | + EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts(); |
|
55 | + } |
|
56 | + |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * callback for Iframe::addStylesheets() child class methods |
|
61 | + * |
|
62 | + * @param array $iframe_css |
|
63 | + * @return array |
|
64 | + */ |
|
65 | + public function iframe_css(array $iframe_css){ |
|
66 | + $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css'; |
|
67 | + return $iframe_css; |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * callback for Iframe::addScripts() child class methods |
|
74 | + * |
|
75 | + * @param array $iframe_js |
|
76 | + * @return array |
|
77 | + */ |
|
78 | + public function iframe_js(array $iframe_js){ |
|
79 | + $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js'; |
|
80 | + return $iframe_js; |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * @throws EE_Error |
|
86 | + * @return string of html to display the field |
|
87 | + */ |
|
88 | + public function display() |
|
89 | + { |
|
90 | + $input = $this->get_input(); |
|
91 | + $select_button_text = $input instanceof EE_Checkbox_Dropdown_Selector_Input ? $input->select_button_text() : ''; |
|
92 | + // $multi = count( $input->options() ) > 1 ? TRUE : FALSE; |
|
93 | + $input->set_label_sizes(); |
|
94 | + $label_size_class = $input->get_label_size_class(); |
|
95 | + if ( ! is_array($input->raw_value()) && $input->raw_value() !== null) { |
|
96 | + EE_Error::doing_it_wrong( |
|
97 | + 'EE_Checkbox_Display_Strategy::display()', |
|
98 | + sprintf( |
|
99 | + esc_html__( |
|
100 | + 'Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"', |
|
101 | + 'event_espresso' |
|
102 | + ), |
|
103 | + $input->html_id(), |
|
104 | + var_export($input->raw_value(), true), |
|
105 | + $input->html_name() . '[]' |
|
106 | + ), |
|
107 | + '4.8.1' |
|
108 | + ); |
|
109 | + } |
|
110 | + |
|
111 | + |
|
112 | + $html = \EEH_HTML::div('', '', 'checkbox-dropdown-selector-wrap-dv'); |
|
113 | + $html .= '<button id="' . $input->html_id() . '-btn"'; |
|
114 | + // $html .= ' name="' . $input->html_name() . '"'; |
|
115 | + $html .= ' class="' . $input->html_class() . ' checkbox-dropdown-selector-btn button-secondary button"'; |
|
116 | + $html .= ' style="' . $input->html_style() . '"'; |
|
117 | + $html .= ' data-target="' . $input->html_id() . '-options-dv"'; |
|
118 | + $html .= ' ' . $input->html_other_attributes() . '>'; |
|
119 | + $html .= '<span class="checkbox-dropdown-selector-selected-spn">'; |
|
120 | + $html .= $select_button_text; |
|
121 | + $html .= '</span> <span class="dashicons dashicons-arrow-down"></span>'; |
|
122 | + $html .= '</button>'; |
|
123 | + $html .= EEH_HTML::div( |
|
124 | + '', |
|
125 | + $input->html_id() . '-options-dv', |
|
126 | + 'checkbox-dropdown-selector' |
|
127 | + ); |
|
128 | + $html .= EEH_HTML::link( |
|
129 | + '', |
|
130 | + '<span class="dashicons dashicons-no"></span>', |
|
131 | + esc_html__('close datetime selector', 'event_espresso'), |
|
132 | + '', |
|
133 | + 'close-espresso-notice' |
|
134 | + ); |
|
135 | + $html .= EEH_HTML::ul(); |
|
136 | + $input_raw_value = (array)$input->raw_value(); |
|
137 | + foreach ($input->options() as $value => $display_text) { |
|
138 | + $html .= EEH_HTML::li(); |
|
139 | + $value = $input->get_normalization_strategy()->unnormalize_one($value); |
|
140 | + $html_id = $this->get_sub_input_id($value); |
|
141 | + $html .= EEH_HTML::nl(0, 'checkbox'); |
|
142 | + $html .= '<label for="' |
|
143 | + . $html_id |
|
144 | + . '" id="' |
|
145 | + . $html_id |
|
146 | + . '-lbl" class="ee-checkbox-label-after' |
|
147 | + . $label_size_class |
|
148 | + . '">'; |
|
149 | + $html .= EEH_HTML::nl(1, 'checkbox'); |
|
150 | + $html .= '<input type="checkbox"'; |
|
151 | + $html .= ' name="' . $input->html_name() . '[]"'; |
|
152 | + $html .= ' id="' . $html_id . '"'; |
|
153 | + $html .= ' class="' . $input->html_class() . '-option"'; |
|
154 | + $html .= ' style="' . $input->html_style() . '"'; |
|
155 | + $html .= ' value="' . esc_attr($value) . '"'; |
|
156 | + $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true) |
|
157 | + ? ' checked="checked"' |
|
158 | + : ''; |
|
159 | + $html .= ' ' . $this->_input->other_html_attributes(); |
|
160 | + $html .= '>'; |
|
161 | + $html .= '<span class="datetime-selector-option-text-spn">' . $display_text . '</span>'; |
|
162 | + $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>'; |
|
163 | + $html .= EEH_HTML::lix(); |
|
164 | + } |
|
165 | + $html .= EEH_HTML::ulx(); |
|
166 | + $html .= EEH_HTML::divx(); |
|
167 | + $html .= EEH_HTML::divx(); |
|
168 | + $html .= \EEH_HTML::br(); |
|
169 | + return $html; |
|
170 | + } |
|
171 | 171 | |
172 | 172 | |
173 | 173 |
@@ -24,20 +24,20 @@ discard block |
||
24 | 24 | { |
25 | 25 | wp_register_style( |
26 | 26 | 'checkbox_dropdown_selector', |
27 | - EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css', |
|
27 | + EE_GLOBAL_ASSETS_URL.'css/checkbox_dropdown_selector.css', |
|
28 | 28 | array('espresso_default'), |
29 | 29 | EVENT_ESPRESSO_VERSION |
30 | 30 | ); |
31 | 31 | wp_register_style( |
32 | 32 | 'espresso_default', |
33 | - EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
33 | + EE_GLOBAL_ASSETS_URL.'css/espresso_default.css', |
|
34 | 34 | array('dashicons'), |
35 | 35 | EVENT_ESPRESSO_VERSION |
36 | 36 | ); |
37 | 37 | wp_enqueue_style('checkbox_dropdown_selector'); |
38 | 38 | wp_register_script( |
39 | 39 | 'checkbox_dropdown_selector', |
40 | - EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js', |
|
40 | + EE_GLOBAL_ASSETS_URL.'scripts/checkbox_dropdown_selector.js', |
|
41 | 41 | array('jquery'), |
42 | 42 | EVENT_ESPRESSO_VERSION, |
43 | 43 | true |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | /** |
51 | 51 | * Informs the rest of the forms system what CSS and JS is needed to display the input |
52 | 52 | */ |
53 | - public function enqueue_js(){ |
|
53 | + public function enqueue_js() { |
|
54 | 54 | EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts(); |
55 | 55 | } |
56 | 56 | |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | * @param array $iframe_css |
63 | 63 | * @return array |
64 | 64 | */ |
65 | - public function iframe_css(array $iframe_css){ |
|
66 | - $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css'; |
|
65 | + public function iframe_css(array $iframe_css) { |
|
66 | + $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL.'css/checkbox_dropdown_selector.css'; |
|
67 | 67 | return $iframe_css; |
68 | 68 | } |
69 | 69 | |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | * @param array $iframe_js |
76 | 76 | * @return array |
77 | 77 | */ |
78 | - public function iframe_js(array $iframe_js){ |
|
79 | - $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js'; |
|
78 | + public function iframe_js(array $iframe_js) { |
|
79 | + $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL.'scripts/checkbox_dropdown_selector.js'; |
|
80 | 80 | return $iframe_js; |
81 | 81 | } |
82 | 82 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | ), |
103 | 103 | $input->html_id(), |
104 | 104 | var_export($input->raw_value(), true), |
105 | - $input->html_name() . '[]' |
|
105 | + $input->html_name().'[]' |
|
106 | 106 | ), |
107 | 107 | '4.8.1' |
108 | 108 | ); |
@@ -110,19 +110,19 @@ discard block |
||
110 | 110 | |
111 | 111 | |
112 | 112 | $html = \EEH_HTML::div('', '', 'checkbox-dropdown-selector-wrap-dv'); |
113 | - $html .= '<button id="' . $input->html_id() . '-btn"'; |
|
113 | + $html .= '<button id="'.$input->html_id().'-btn"'; |
|
114 | 114 | // $html .= ' name="' . $input->html_name() . '"'; |
115 | - $html .= ' class="' . $input->html_class() . ' checkbox-dropdown-selector-btn button-secondary button"'; |
|
116 | - $html .= ' style="' . $input->html_style() . '"'; |
|
117 | - $html .= ' data-target="' . $input->html_id() . '-options-dv"'; |
|
118 | - $html .= ' ' . $input->html_other_attributes() . '>'; |
|
115 | + $html .= ' class="'.$input->html_class().' checkbox-dropdown-selector-btn button-secondary button"'; |
|
116 | + $html .= ' style="'.$input->html_style().'"'; |
|
117 | + $html .= ' data-target="'.$input->html_id().'-options-dv"'; |
|
118 | + $html .= ' '.$input->html_other_attributes().'>'; |
|
119 | 119 | $html .= '<span class="checkbox-dropdown-selector-selected-spn">'; |
120 | 120 | $html .= $select_button_text; |
121 | 121 | $html .= '</span> <span class="dashicons dashicons-arrow-down"></span>'; |
122 | 122 | $html .= '</button>'; |
123 | 123 | $html .= EEH_HTML::div( |
124 | 124 | '', |
125 | - $input->html_id() . '-options-dv', |
|
125 | + $input->html_id().'-options-dv', |
|
126 | 126 | 'checkbox-dropdown-selector' |
127 | 127 | ); |
128 | 128 | $html .= EEH_HTML::link( |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | 'close-espresso-notice' |
134 | 134 | ); |
135 | 135 | $html .= EEH_HTML::ul(); |
136 | - $input_raw_value = (array)$input->raw_value(); |
|
136 | + $input_raw_value = (array) $input->raw_value(); |
|
137 | 137 | foreach ($input->options() as $value => $display_text) { |
138 | 138 | $html .= EEH_HTML::li(); |
139 | 139 | $value = $input->get_normalization_strategy()->unnormalize_one($value); |
@@ -148,18 +148,18 @@ discard block |
||
148 | 148 | . '">'; |
149 | 149 | $html .= EEH_HTML::nl(1, 'checkbox'); |
150 | 150 | $html .= '<input type="checkbox"'; |
151 | - $html .= ' name="' . $input->html_name() . '[]"'; |
|
152 | - $html .= ' id="' . $html_id . '"'; |
|
153 | - $html .= ' class="' . $input->html_class() . '-option"'; |
|
154 | - $html .= ' style="' . $input->html_style() . '"'; |
|
155 | - $html .= ' value="' . esc_attr($value) . '"'; |
|
151 | + $html .= ' name="'.$input->html_name().'[]"'; |
|
152 | + $html .= ' id="'.$html_id.'"'; |
|
153 | + $html .= ' class="'.$input->html_class().'-option"'; |
|
154 | + $html .= ' style="'.$input->html_style().'"'; |
|
155 | + $html .= ' value="'.esc_attr($value).'"'; |
|
156 | 156 | $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true) |
157 | 157 | ? ' checked="checked"' |
158 | 158 | : ''; |
159 | - $html .= ' ' . $this->_input->other_html_attributes(); |
|
159 | + $html .= ' '.$this->_input->other_html_attributes(); |
|
160 | 160 | $html .= '>'; |
161 | - $html .= '<span class="datetime-selector-option-text-spn">' . $display_text . '</span>'; |
|
162 | - $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>'; |
|
161 | + $html .= '<span class="datetime-selector-option-text-spn">'.$display_text.'</span>'; |
|
162 | + $html .= EEH_HTML::nl(-1, 'checkbox').'</label>'; |
|
163 | 163 | $html .= EEH_HTML::lix(); |
164 | 164 | } |
165 | 165 | $html .= EEH_HTML::ulx(); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
3 | - exit('NO direct script access allowed'); |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -28,593 +28,593 @@ discard block |
||
28 | 28 | class Registration_Form_Admin_Page extends EE_Admin_Page |
29 | 29 | { |
30 | 30 | |
31 | - /** |
|
32 | - * _question |
|
33 | - * holds the specific question object for the question details screen |
|
34 | - * |
|
35 | - * @var EE_Question $_question |
|
36 | - */ |
|
37 | - protected $_question; |
|
38 | - |
|
39 | - /** |
|
40 | - * _question_group |
|
41 | - * holds the specific question group object for the question group details screen |
|
42 | - * |
|
43 | - * @var EE_Question_Group $_question_group |
|
44 | - */ |
|
45 | - protected $_question_group; |
|
46 | - |
|
47 | - /** |
|
48 | - *_question_model EEM_Question model instance (for queries) |
|
49 | - * |
|
50 | - * @var EEM_Question $_question_model ; |
|
51 | - */ |
|
52 | - protected $_question_model; |
|
53 | - |
|
54 | - /** |
|
55 | - * _question_group_model EEM_Question_group instance (for queries) |
|
56 | - * |
|
57 | - * @var EEM_Question_Group $_question_group_model |
|
58 | - */ |
|
59 | - protected $_question_group_model; |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * @Constructor |
|
64 | - * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
|
65 | - * @access public |
|
66 | - */ |
|
67 | - public function __construct($routing = true) |
|
68 | - { |
|
69 | - require_once(EE_MODELS . 'EEM_Question.model.php'); |
|
70 | - require_once(EE_MODELS . 'EEM_Question_Group.model.php'); |
|
71 | - $this->_question_model = EEM_Question::instance(); |
|
72 | - $this->_question_group_model = EEM_Question_Group::instance(); |
|
73 | - parent::__construct($routing); |
|
74 | - } |
|
75 | - |
|
76 | - |
|
77 | - protected function _init_page_props() |
|
78 | - { |
|
79 | - $this->page_slug = REGISTRATION_FORM_PG_SLUG; |
|
80 | - $this->page_label = esc_html__('Registration Form', 'event_espresso'); |
|
81 | - $this->_admin_base_url = REGISTRATION_FORM_ADMIN_URL; |
|
82 | - $this->_admin_base_path = REGISTRATION_FORM_ADMIN; |
|
83 | - } |
|
84 | - |
|
85 | - |
|
86 | - protected function _ajax_hooks() |
|
87 | - { |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - protected function _define_page_props() |
|
92 | - { |
|
93 | - $this->_admin_page_title = esc_html__('Registration Form', 'event_espresso'); |
|
94 | - $this->_labels = array( |
|
95 | - 'buttons' => array( |
|
96 | - 'edit_question' => esc_html__('Edit Question', 'event_espresso'), |
|
97 | - ), |
|
98 | - ); |
|
99 | - } |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - *_set_page_routes |
|
104 | - */ |
|
105 | - protected function _set_page_routes() |
|
106 | - { |
|
107 | - $qst_id = ! empty($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0; |
|
108 | - $this->_page_routes = array( |
|
109 | - 'default' => array( |
|
110 | - 'func' => '_questions_overview_list_table', |
|
111 | - 'capability' => 'ee_read_questions', |
|
112 | - ), |
|
113 | - |
|
114 | - 'edit_question' => array( |
|
115 | - 'func' => '_edit_question', |
|
116 | - 'capability' => 'ee_edit_question', |
|
117 | - 'obj_id' => $qst_id, |
|
118 | - 'args' => array('edit'), |
|
119 | - ), |
|
120 | - |
|
121 | - 'question_groups' => array( |
|
122 | - 'func' => '_questions_groups_preview', |
|
123 | - 'capability' => 'ee_read_question_groups', |
|
124 | - ), |
|
125 | - |
|
126 | - 'update_question' => array( |
|
127 | - 'func' => '_insert_or_update_question', |
|
128 | - 'args' => array('new_question' => false), |
|
129 | - 'capability' => 'ee_edit_question', |
|
130 | - 'obj_id' => $qst_id, |
|
131 | - 'noheader' => true, |
|
132 | - ), |
|
133 | - ); |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - protected function _set_page_config() |
|
138 | - { |
|
139 | - $this->_page_config = array( |
|
140 | - 'default' => array( |
|
141 | - 'nav' => array( |
|
142 | - 'label' => esc_html__('Questions', 'event_espresso'), |
|
143 | - 'order' => 10, |
|
144 | - ), |
|
145 | - 'list_table' => 'Registration_Form_Questions_Admin_List_Table', |
|
146 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
147 | - 'help_tabs' => array( |
|
148 | - 'registration_form_questions_overview_help_tab' => array( |
|
149 | - 'title' => esc_html__('Questions Overview', 'event_espresso'), |
|
150 | - 'filename' => 'registration_form_questions_overview', |
|
151 | - ), |
|
152 | - 'registration_form_questions_overview_table_column_headings_help_tab' => array( |
|
153 | - 'title' => esc_html__('Questions Overview Table Column Headings', 'event_espresso'), |
|
154 | - 'filename' => 'registration_form_questions_overview_table_column_headings', |
|
155 | - ), |
|
156 | - 'registration_form_questions_overview_views_bulk_actions_search_help_tab' => array( |
|
157 | - 'title' => esc_html__('Question Overview Views & Bulk Actions & Search', 'event_espresso'), |
|
158 | - 'filename' => 'registration_form_questions_overview_views_bulk_actions_search', |
|
159 | - ), |
|
160 | - ), |
|
161 | - 'help_tour' => array('Registration_Form_Questions_Overview_Help_Tour'), |
|
162 | - 'require_nonce' => false, |
|
163 | - 'qtips' => array( |
|
164 | - 'EE_Registration_Form_Tips', |
|
165 | - )/**/ |
|
166 | - ), |
|
167 | - |
|
168 | - 'question_groups' => array( |
|
169 | - 'nav' => array( |
|
170 | - 'label' => esc_html__('Question Groups', 'event_espresso'), |
|
171 | - 'order' => 20, |
|
172 | - ), |
|
173 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
174 | - 'help_tabs' => array( |
|
175 | - 'registration_form_question_groups_help_tab' => array( |
|
176 | - 'title' => esc_html__('Question Groups', 'event_espresso'), |
|
177 | - 'filename' => 'registration_form_question_groups', |
|
178 | - ), |
|
179 | - ), |
|
180 | - 'help_tour' => array('Registration_Form_Question_Groups_Help_Tour'), |
|
181 | - 'require_nonce' => false, |
|
182 | - ), |
|
183 | - |
|
184 | - 'edit_question' => array( |
|
185 | - 'nav' => array( |
|
186 | - 'label' => esc_html__('Edit Question', 'event_espresso'), |
|
187 | - 'order' => 15, |
|
188 | - 'persistent' => false, |
|
189 | - 'url' => isset($this->_req_data['question_id']) ? add_query_arg(array('question_id' => $this->_req_data['question_id']), |
|
190 | - $this->_current_page_view_url) : $this->_admin_base_url, |
|
191 | - ), |
|
192 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
193 | - 'help_tabs' => array( |
|
194 | - 'registration_form_edit_question_group_help_tab' => array( |
|
195 | - 'title' => esc_html__('Edit Question', 'event_espresso'), |
|
196 | - 'filename' => 'registration_form_edit_question', |
|
197 | - ), |
|
198 | - ), |
|
199 | - 'help_tour' => array('Registration_Form_Edit_Question_Help_Tour'), |
|
200 | - 'require_nonce' => false, |
|
201 | - ), |
|
202 | - ); |
|
203 | - } |
|
204 | - |
|
205 | - |
|
206 | - protected function _add_screen_options() |
|
207 | - { |
|
208 | - //todo |
|
209 | - } |
|
210 | - |
|
211 | - protected function _add_screen_options_default() |
|
212 | - { |
|
213 | - $page_title = $this->_admin_page_title; |
|
214 | - $this->_admin_page_title = esc_html__('Questions', 'event_espresso'); |
|
215 | - $this->_per_page_screen_option(); |
|
216 | - $this->_admin_page_title = $page_title; |
|
217 | - } |
|
218 | - |
|
219 | - protected function _add_screen_options_question_groups() |
|
220 | - { |
|
221 | - $page_title = $this->_admin_page_title; |
|
222 | - $this->_admin_page_title = esc_html__('Question Groups', 'event_espresso'); |
|
223 | - $this->_per_page_screen_option(); |
|
224 | - $this->_admin_page_title = $page_title; |
|
225 | - } |
|
226 | - |
|
227 | - //none of the below group are currently used for Event Categories |
|
228 | - protected function _add_feature_pointers() |
|
229 | - { |
|
230 | - } |
|
231 | - |
|
232 | - public function load_scripts_styles() |
|
233 | - { |
|
234 | - wp_register_style('espresso_registration', |
|
235 | - REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
236 | - wp_enqueue_style('espresso_registration'); |
|
237 | - } |
|
238 | - |
|
239 | - public function admin_init() |
|
240 | - { |
|
241 | - } |
|
242 | - |
|
243 | - public function admin_notices() |
|
244 | - { |
|
245 | - } |
|
246 | - |
|
247 | - public function admin_footer_scripts() |
|
248 | - { |
|
249 | - } |
|
250 | - |
|
251 | - |
|
252 | - public function load_scripts_styles_default() |
|
253 | - { |
|
254 | - } |
|
255 | - |
|
256 | - |
|
257 | - public function load_scripts_styles_add_question() |
|
258 | - { |
|
259 | - $this->load_scripts_styles_forms(); |
|
260 | - wp_register_script('espresso_registration_form_single', |
|
261 | - REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), |
|
262 | - EVENT_ESPRESSO_VERSION, true); |
|
263 | - wp_enqueue_script('espresso_registration_form_single'); |
|
264 | - } |
|
265 | - |
|
266 | - public function load_scripts_styles_edit_question() |
|
267 | - { |
|
268 | - $this->load_scripts_styles_forms(); |
|
269 | - wp_register_script('espresso_registration_form_single', |
|
270 | - REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), |
|
271 | - EVENT_ESPRESSO_VERSION, true); |
|
272 | - wp_enqueue_script('espresso_registration_form_single'); |
|
273 | - } |
|
274 | - |
|
275 | - |
|
276 | - public function recaptcha_info_help_tab() |
|
277 | - { |
|
278 | - $template = REGISTRATION_FORM_TEMPLATE_PATH . 'recaptcha_info_help_tab.template.php'; |
|
279 | - EEH_Template::display_template($template, array()); |
|
280 | - } |
|
281 | - |
|
282 | - |
|
283 | - public function load_scripts_styles_forms() |
|
284 | - { |
|
285 | - //styles |
|
286 | - wp_enqueue_style('espresso-ui-theme'); |
|
287 | - //scripts |
|
288 | - wp_enqueue_script('ee_admin_js'); |
|
289 | - } |
|
290 | - |
|
291 | - |
|
292 | - protected function _set_list_table_views_default() |
|
293 | - { |
|
294 | - $this->_views = array( |
|
295 | - 'all' => array( |
|
296 | - 'slug' => 'all', |
|
297 | - 'label' => esc_html__('View All Questions', 'event_espresso'), |
|
298 | - 'count' => 0, |
|
31 | + /** |
|
32 | + * _question |
|
33 | + * holds the specific question object for the question details screen |
|
34 | + * |
|
35 | + * @var EE_Question $_question |
|
36 | + */ |
|
37 | + protected $_question; |
|
38 | + |
|
39 | + /** |
|
40 | + * _question_group |
|
41 | + * holds the specific question group object for the question group details screen |
|
42 | + * |
|
43 | + * @var EE_Question_Group $_question_group |
|
44 | + */ |
|
45 | + protected $_question_group; |
|
46 | + |
|
47 | + /** |
|
48 | + *_question_model EEM_Question model instance (for queries) |
|
49 | + * |
|
50 | + * @var EEM_Question $_question_model ; |
|
51 | + */ |
|
52 | + protected $_question_model; |
|
53 | + |
|
54 | + /** |
|
55 | + * _question_group_model EEM_Question_group instance (for queries) |
|
56 | + * |
|
57 | + * @var EEM_Question_Group $_question_group_model |
|
58 | + */ |
|
59 | + protected $_question_group_model; |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * @Constructor |
|
64 | + * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
|
65 | + * @access public |
|
66 | + */ |
|
67 | + public function __construct($routing = true) |
|
68 | + { |
|
69 | + require_once(EE_MODELS . 'EEM_Question.model.php'); |
|
70 | + require_once(EE_MODELS . 'EEM_Question_Group.model.php'); |
|
71 | + $this->_question_model = EEM_Question::instance(); |
|
72 | + $this->_question_group_model = EEM_Question_Group::instance(); |
|
73 | + parent::__construct($routing); |
|
74 | + } |
|
75 | + |
|
76 | + |
|
77 | + protected function _init_page_props() |
|
78 | + { |
|
79 | + $this->page_slug = REGISTRATION_FORM_PG_SLUG; |
|
80 | + $this->page_label = esc_html__('Registration Form', 'event_espresso'); |
|
81 | + $this->_admin_base_url = REGISTRATION_FORM_ADMIN_URL; |
|
82 | + $this->_admin_base_path = REGISTRATION_FORM_ADMIN; |
|
83 | + } |
|
84 | + |
|
85 | + |
|
86 | + protected function _ajax_hooks() |
|
87 | + { |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + protected function _define_page_props() |
|
92 | + { |
|
93 | + $this->_admin_page_title = esc_html__('Registration Form', 'event_espresso'); |
|
94 | + $this->_labels = array( |
|
95 | + 'buttons' => array( |
|
96 | + 'edit_question' => esc_html__('Edit Question', 'event_espresso'), |
|
97 | + ), |
|
98 | + ); |
|
99 | + } |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + *_set_page_routes |
|
104 | + */ |
|
105 | + protected function _set_page_routes() |
|
106 | + { |
|
107 | + $qst_id = ! empty($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0; |
|
108 | + $this->_page_routes = array( |
|
109 | + 'default' => array( |
|
110 | + 'func' => '_questions_overview_list_table', |
|
111 | + 'capability' => 'ee_read_questions', |
|
112 | + ), |
|
113 | + |
|
114 | + 'edit_question' => array( |
|
115 | + 'func' => '_edit_question', |
|
116 | + 'capability' => 'ee_edit_question', |
|
117 | + 'obj_id' => $qst_id, |
|
118 | + 'args' => array('edit'), |
|
119 | + ), |
|
120 | + |
|
121 | + 'question_groups' => array( |
|
122 | + 'func' => '_questions_groups_preview', |
|
123 | + 'capability' => 'ee_read_question_groups', |
|
124 | + ), |
|
125 | + |
|
126 | + 'update_question' => array( |
|
127 | + 'func' => '_insert_or_update_question', |
|
128 | + 'args' => array('new_question' => false), |
|
129 | + 'capability' => 'ee_edit_question', |
|
130 | + 'obj_id' => $qst_id, |
|
131 | + 'noheader' => true, |
|
132 | + ), |
|
133 | + ); |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + protected function _set_page_config() |
|
138 | + { |
|
139 | + $this->_page_config = array( |
|
140 | + 'default' => array( |
|
141 | + 'nav' => array( |
|
142 | + 'label' => esc_html__('Questions', 'event_espresso'), |
|
143 | + 'order' => 10, |
|
144 | + ), |
|
145 | + 'list_table' => 'Registration_Form_Questions_Admin_List_Table', |
|
146 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
147 | + 'help_tabs' => array( |
|
148 | + 'registration_form_questions_overview_help_tab' => array( |
|
149 | + 'title' => esc_html__('Questions Overview', 'event_espresso'), |
|
150 | + 'filename' => 'registration_form_questions_overview', |
|
151 | + ), |
|
152 | + 'registration_form_questions_overview_table_column_headings_help_tab' => array( |
|
153 | + 'title' => esc_html__('Questions Overview Table Column Headings', 'event_espresso'), |
|
154 | + 'filename' => 'registration_form_questions_overview_table_column_headings', |
|
155 | + ), |
|
156 | + 'registration_form_questions_overview_views_bulk_actions_search_help_tab' => array( |
|
157 | + 'title' => esc_html__('Question Overview Views & Bulk Actions & Search', 'event_espresso'), |
|
158 | + 'filename' => 'registration_form_questions_overview_views_bulk_actions_search', |
|
159 | + ), |
|
160 | + ), |
|
161 | + 'help_tour' => array('Registration_Form_Questions_Overview_Help_Tour'), |
|
162 | + 'require_nonce' => false, |
|
163 | + 'qtips' => array( |
|
164 | + 'EE_Registration_Form_Tips', |
|
165 | + )/**/ |
|
166 | + ), |
|
167 | + |
|
168 | + 'question_groups' => array( |
|
169 | + 'nav' => array( |
|
170 | + 'label' => esc_html__('Question Groups', 'event_espresso'), |
|
171 | + 'order' => 20, |
|
172 | + ), |
|
173 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
174 | + 'help_tabs' => array( |
|
175 | + 'registration_form_question_groups_help_tab' => array( |
|
176 | + 'title' => esc_html__('Question Groups', 'event_espresso'), |
|
177 | + 'filename' => 'registration_form_question_groups', |
|
178 | + ), |
|
179 | + ), |
|
180 | + 'help_tour' => array('Registration_Form_Question_Groups_Help_Tour'), |
|
181 | + 'require_nonce' => false, |
|
182 | + ), |
|
183 | + |
|
184 | + 'edit_question' => array( |
|
185 | + 'nav' => array( |
|
186 | + 'label' => esc_html__('Edit Question', 'event_espresso'), |
|
187 | + 'order' => 15, |
|
188 | + 'persistent' => false, |
|
189 | + 'url' => isset($this->_req_data['question_id']) ? add_query_arg(array('question_id' => $this->_req_data['question_id']), |
|
190 | + $this->_current_page_view_url) : $this->_admin_base_url, |
|
191 | + ), |
|
192 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
193 | + 'help_tabs' => array( |
|
194 | + 'registration_form_edit_question_group_help_tab' => array( |
|
195 | + 'title' => esc_html__('Edit Question', 'event_espresso'), |
|
196 | + 'filename' => 'registration_form_edit_question', |
|
197 | + ), |
|
198 | + ), |
|
199 | + 'help_tour' => array('Registration_Form_Edit_Question_Help_Tour'), |
|
200 | + 'require_nonce' => false, |
|
201 | + ), |
|
202 | + ); |
|
203 | + } |
|
204 | + |
|
205 | + |
|
206 | + protected function _add_screen_options() |
|
207 | + { |
|
208 | + //todo |
|
209 | + } |
|
210 | + |
|
211 | + protected function _add_screen_options_default() |
|
212 | + { |
|
213 | + $page_title = $this->_admin_page_title; |
|
214 | + $this->_admin_page_title = esc_html__('Questions', 'event_espresso'); |
|
215 | + $this->_per_page_screen_option(); |
|
216 | + $this->_admin_page_title = $page_title; |
|
217 | + } |
|
218 | + |
|
219 | + protected function _add_screen_options_question_groups() |
|
220 | + { |
|
221 | + $page_title = $this->_admin_page_title; |
|
222 | + $this->_admin_page_title = esc_html__('Question Groups', 'event_espresso'); |
|
223 | + $this->_per_page_screen_option(); |
|
224 | + $this->_admin_page_title = $page_title; |
|
225 | + } |
|
226 | + |
|
227 | + //none of the below group are currently used for Event Categories |
|
228 | + protected function _add_feature_pointers() |
|
229 | + { |
|
230 | + } |
|
231 | + |
|
232 | + public function load_scripts_styles() |
|
233 | + { |
|
234 | + wp_register_style('espresso_registration', |
|
235 | + REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
236 | + wp_enqueue_style('espresso_registration'); |
|
237 | + } |
|
238 | + |
|
239 | + public function admin_init() |
|
240 | + { |
|
241 | + } |
|
242 | + |
|
243 | + public function admin_notices() |
|
244 | + { |
|
245 | + } |
|
246 | + |
|
247 | + public function admin_footer_scripts() |
|
248 | + { |
|
249 | + } |
|
250 | + |
|
251 | + |
|
252 | + public function load_scripts_styles_default() |
|
253 | + { |
|
254 | + } |
|
255 | + |
|
256 | + |
|
257 | + public function load_scripts_styles_add_question() |
|
258 | + { |
|
259 | + $this->load_scripts_styles_forms(); |
|
260 | + wp_register_script('espresso_registration_form_single', |
|
261 | + REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), |
|
262 | + EVENT_ESPRESSO_VERSION, true); |
|
263 | + wp_enqueue_script('espresso_registration_form_single'); |
|
264 | + } |
|
265 | + |
|
266 | + public function load_scripts_styles_edit_question() |
|
267 | + { |
|
268 | + $this->load_scripts_styles_forms(); |
|
269 | + wp_register_script('espresso_registration_form_single', |
|
270 | + REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), |
|
271 | + EVENT_ESPRESSO_VERSION, true); |
|
272 | + wp_enqueue_script('espresso_registration_form_single'); |
|
273 | + } |
|
274 | + |
|
275 | + |
|
276 | + public function recaptcha_info_help_tab() |
|
277 | + { |
|
278 | + $template = REGISTRATION_FORM_TEMPLATE_PATH . 'recaptcha_info_help_tab.template.php'; |
|
279 | + EEH_Template::display_template($template, array()); |
|
280 | + } |
|
281 | + |
|
282 | + |
|
283 | + public function load_scripts_styles_forms() |
|
284 | + { |
|
285 | + //styles |
|
286 | + wp_enqueue_style('espresso-ui-theme'); |
|
287 | + //scripts |
|
288 | + wp_enqueue_script('ee_admin_js'); |
|
289 | + } |
|
290 | + |
|
291 | + |
|
292 | + protected function _set_list_table_views_default() |
|
293 | + { |
|
294 | + $this->_views = array( |
|
295 | + 'all' => array( |
|
296 | + 'slug' => 'all', |
|
297 | + 'label' => esc_html__('View All Questions', 'event_espresso'), |
|
298 | + 'count' => 0, |
|
299 | 299 | // 'bulk_action' => array( |
300 | 300 | // 'trash_questions' => esc_html__('Trash', 'event_espresso'), |
301 | 301 | // ) |
302 | - ), |
|
303 | - ); |
|
304 | - |
|
305 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_questions', |
|
306 | - 'espresso_registration_form_trash_questions') |
|
307 | - ) { |
|
308 | - $this->_views['trash'] = array( |
|
309 | - 'slug' => 'trash', |
|
310 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
311 | - 'count' => 0, |
|
302 | + ), |
|
303 | + ); |
|
304 | + |
|
305 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_questions', |
|
306 | + 'espresso_registration_form_trash_questions') |
|
307 | + ) { |
|
308 | + $this->_views['trash'] = array( |
|
309 | + 'slug' => 'trash', |
|
310 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
311 | + 'count' => 0, |
|
312 | 312 | // 'bulk_action' => array( |
313 | 313 | // 'delete_questions' => esc_html__('Delete Permanently', 'event_espresso'), |
314 | 314 | // 'restore_questions' => esc_html__('Restore', 'event_espresso'), |
315 | - ); |
|
316 | - } |
|
317 | - } |
|
318 | - |
|
319 | - /** |
|
320 | - * This just previews the question groups tab that comes in caffeinated. |
|
321 | - * |
|
322 | - * @return string html |
|
323 | - */ |
|
324 | - protected function _questions_groups_preview() |
|
325 | - { |
|
326 | - $this->_admin_page_title = esc_html__('Question Groups (Preview)', 'event_espresso'); |
|
327 | - $this->_template_args['preview_img'] = '<img src="' . REGISTRATION_FORM_ASSETS_URL . 'caf_reg_form_preview.jpg" alt="' . esc_attr__('Preview Question Groups Overview List Table screenshot', |
|
328 | - 'event_espresso') . '" />'; |
|
329 | - $this->_template_args['preview_text'] = '<strong>' . esc_html__('Question Groups is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. With the Question Groups feature you are able to create new question groups, edit existing question groups, and create and edit new questions and add them to question groups.', |
|
330 | - 'event_espresso') . '</strong>'; |
|
331 | - $this->display_admin_caf_preview_page('question_groups_tab'); |
|
332 | - } |
|
333 | - |
|
334 | - |
|
335 | - /** |
|
336 | - * Extracts the question field's values from the POST request to update or insert them |
|
337 | - * |
|
338 | - * @param \EEM_Base $model |
|
339 | - * @return array where each key is the name of a model's field/db column, and each value is its value. |
|
340 | - */ |
|
341 | - protected function _set_column_values_for(EEM_Base $model) |
|
342 | - { |
|
343 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
344 | - $set_column_values = array(); |
|
345 | - |
|
346 | - //some initial checks for proper values. |
|
347 | - //if QST_admin_only, then no matter what QST_required is we disable. |
|
348 | - if (! empty($this->_req_data['QST_admin_only'])) { |
|
349 | - $this->_req_data['QST_required'] = 0; |
|
350 | - } |
|
351 | - foreach ($model->field_settings() as $fieldName => $settings) { |
|
352 | - // basically if QSG_identifier is empty or not set |
|
353 | - if ($fieldName === 'QSG_identifier' && (isset($this->_req_data['QSG_identifier']) && empty($this->_req_data['QSG_identifier']))) { |
|
354 | - $QSG_name = isset($this->_req_data['QSG_name']) ? $this->_req_data['QSG_name'] : ''; |
|
355 | - $set_column_values[$fieldName] = sanitize_title($QSG_name) . '-' . uniqid('', true); |
|
315 | + ); |
|
316 | + } |
|
317 | + } |
|
318 | + |
|
319 | + /** |
|
320 | + * This just previews the question groups tab that comes in caffeinated. |
|
321 | + * |
|
322 | + * @return string html |
|
323 | + */ |
|
324 | + protected function _questions_groups_preview() |
|
325 | + { |
|
326 | + $this->_admin_page_title = esc_html__('Question Groups (Preview)', 'event_espresso'); |
|
327 | + $this->_template_args['preview_img'] = '<img src="' . REGISTRATION_FORM_ASSETS_URL . 'caf_reg_form_preview.jpg" alt="' . esc_attr__('Preview Question Groups Overview List Table screenshot', |
|
328 | + 'event_espresso') . '" />'; |
|
329 | + $this->_template_args['preview_text'] = '<strong>' . esc_html__('Question Groups is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. With the Question Groups feature you are able to create new question groups, edit existing question groups, and create and edit new questions and add them to question groups.', |
|
330 | + 'event_espresso') . '</strong>'; |
|
331 | + $this->display_admin_caf_preview_page('question_groups_tab'); |
|
332 | + } |
|
333 | + |
|
334 | + |
|
335 | + /** |
|
336 | + * Extracts the question field's values from the POST request to update or insert them |
|
337 | + * |
|
338 | + * @param \EEM_Base $model |
|
339 | + * @return array where each key is the name of a model's field/db column, and each value is its value. |
|
340 | + */ |
|
341 | + protected function _set_column_values_for(EEM_Base $model) |
|
342 | + { |
|
343 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
344 | + $set_column_values = array(); |
|
345 | + |
|
346 | + //some initial checks for proper values. |
|
347 | + //if QST_admin_only, then no matter what QST_required is we disable. |
|
348 | + if (! empty($this->_req_data['QST_admin_only'])) { |
|
349 | + $this->_req_data['QST_required'] = 0; |
|
350 | + } |
|
351 | + foreach ($model->field_settings() as $fieldName => $settings) { |
|
352 | + // basically if QSG_identifier is empty or not set |
|
353 | + if ($fieldName === 'QSG_identifier' && (isset($this->_req_data['QSG_identifier']) && empty($this->_req_data['QSG_identifier']))) { |
|
354 | + $QSG_name = isset($this->_req_data['QSG_name']) ? $this->_req_data['QSG_name'] : ''; |
|
355 | + $set_column_values[$fieldName] = sanitize_title($QSG_name) . '-' . uniqid('', true); |
|
356 | 356 | // dd($set_column_values); |
357 | - } //if the admin label is blank, use a slug version of the question text |
|
358 | - else if ($fieldName === 'QST_admin_label' && (isset($this->_req_data['QST_admin_label']) && empty($this->_req_data['QST_admin_label']))) { |
|
359 | - $QST_text = isset($this->_req_data['QST_display_text']) ? $this->_req_data['QST_display_text'] : ''; |
|
360 | - $set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text, 10)); |
|
361 | - } else if ($fieldName === 'QST_admin_only' && (! isset($this->_req_data['QST_admin_only']))) { |
|
362 | - $set_column_values[$fieldName] = 0; |
|
363 | - } else if ($fieldName === 'QST_max') { |
|
364 | - $qst_system = EEM_Question::instance()->get_var( |
|
365 | - array( |
|
366 | - array( |
|
367 | - 'QST_ID' => isset($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0, |
|
368 | - ), |
|
369 | - ), |
|
370 | - 'QST_system'); |
|
371 | - $max_max = EEM_Question::instance()->absolute_max_for_system_question($qst_system); |
|
372 | - if (empty($this->_req_data['QST_max']) || |
|
373 | - $this->_req_data['QST_max'] > $max_max |
|
374 | - ) { |
|
375 | - $set_column_values[$fieldName] = $max_max; |
|
376 | - } |
|
377 | - } |
|
378 | - |
|
379 | - |
|
380 | - //only add a property to the array if it's not null (otherwise the model should just use the default value) |
|
381 | - if ( |
|
382 | - ! isset($set_column_values[$fieldName]) && |
|
383 | - isset($this->_req_data[$fieldName]) |
|
384 | - ) { |
|
385 | - $set_column_values[$fieldName] = $this->_req_data[$fieldName]; |
|
386 | - } |
|
387 | - |
|
388 | - } |
|
389 | - return $set_column_values;//validation fo this data to be performed by the model before insertion. |
|
390 | - } |
|
391 | - |
|
392 | - |
|
393 | - /** |
|
394 | - *_questions_overview_list_table |
|
395 | - */ |
|
396 | - protected function _questions_overview_list_table() |
|
397 | - { |
|
398 | - $this->_search_btn_label = esc_html__('Questions', 'event_espresso'); |
|
399 | - $this->display_admin_list_table_page_with_sidebar(); |
|
400 | - } |
|
401 | - |
|
402 | - |
|
403 | - /** |
|
404 | - * _edit_question |
|
405 | - */ |
|
406 | - protected function _edit_question() |
|
407 | - { |
|
408 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
409 | - $ID = isset($this->_req_data['QST_ID']) && ! empty($this->_req_data['QST_ID']) ? absint($this->_req_data['QST_ID']) : false; |
|
410 | - |
|
411 | - switch ($this->_req_action) { |
|
412 | - case 'add_question' : |
|
413 | - $this->_admin_page_title = esc_html__('Add Question', 'event_espresso'); |
|
414 | - break; |
|
415 | - case 'edit_question' : |
|
416 | - $this->_admin_page_title = esc_html__('Edit Question', 'event_espresso'); |
|
417 | - break; |
|
418 | - default : |
|
419 | - $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
420 | - } |
|
421 | - |
|
422 | - // add PRC_ID to title if editing |
|
423 | - $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
424 | - if ($ID) { |
|
425 | - $question = $this->_question_model->get_one_by_ID($ID); |
|
426 | - $additional_hidden_fields = array('QST_ID' => array('type' => 'hidden', 'value' => $ID)); |
|
427 | - $this->_set_add_edit_form_tags('update_question', $additional_hidden_fields); |
|
428 | - } else { |
|
429 | - $question = EE_Question::new_instance(); |
|
430 | - $question->set_order_to_latest(); |
|
431 | - $this->_set_add_edit_form_tags('insert_question'); |
|
432 | - } |
|
433 | - if( $question->system_ID() === EEM_Attendee::system_question_phone ){ |
|
434 | - $question_types = array_intersect_key( |
|
435 | - EEM_Question::instance()->allowed_question_types(), |
|
436 | - array_flip( |
|
437 | - array( |
|
438 | - EEM_Question::QST_type_text, |
|
439 | - EEM_Question::QST_type_us_phone |
|
440 | - ) |
|
441 | - ) |
|
442 | - ); |
|
443 | - } else { |
|
444 | - $question_types = $question->has_answers() ? $this->_question_model->question_types_in_same_category($question->type()) : $this->_question_model->allowed_question_types(); |
|
445 | - } |
|
446 | - $this->_template_args['QST_ID'] = $ID; |
|
447 | - $this->_template_args['question'] = $question; |
|
448 | - $this->_template_args['question_types'] = $question_types; |
|
449 | - $this->_template_args['max_max'] = EEM_Question::instance()->absolute_max_for_system_question( |
|
450 | - $question->system_ID() |
|
451 | - ); |
|
452 | - $this->_template_args['question_type_descriptions'] = $this->_get_question_type_descriptions(); |
|
453 | - $this->_set_publish_post_box_vars('id', $ID); |
|
454 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
455 | - REGISTRATION_FORM_TEMPLATE_PATH . 'questions_main_meta_box.template.php', |
|
456 | - $this->_template_args, true |
|
457 | - ); |
|
458 | - |
|
459 | - // the details template wrapper |
|
460 | - $this->display_admin_page_with_sidebar(); |
|
461 | - } |
|
462 | - |
|
463 | - |
|
464 | - /** |
|
465 | - * @return string |
|
466 | - */ |
|
467 | - protected function _get_question_type_descriptions() |
|
468 | - { |
|
469 | - EE_Registry::instance()->load_helper('HTML'); |
|
470 | - $descriptions = ''; |
|
471 | - $question_type_descriptions = EEM_Question::instance()->question_descriptions(); |
|
472 | - foreach ($question_type_descriptions as $type => $question_type_description) { |
|
473 | - if ($type == 'HTML_TEXTAREA') { |
|
474 | - $html = new EE_Simple_HTML_Validation_Strategy(); |
|
475 | - $question_type_description .= sprintf( |
|
476 | - esc_html__('%1$s(allowed tags: %2$s)', 'event_espresso'), |
|
477 | - '<br/>', |
|
478 | - $html->get_list_of_allowed_tags() |
|
479 | - ); |
|
480 | - } |
|
481 | - $descriptions .= EEH_HTML::p( |
|
482 | - $question_type_description, |
|
483 | - 'question_type_description-' . $type, |
|
484 | - 'question_type_description description', |
|
485 | - 'display:none;' |
|
486 | - ); |
|
487 | - } |
|
488 | - return $descriptions; |
|
489 | - } |
|
490 | - |
|
491 | - |
|
492 | - /** |
|
493 | - * @param bool|true $new_question |
|
494 | - * @throws \EE_Error |
|
495 | - */ |
|
496 | - protected function _insert_or_update_question($new_question = true) |
|
497 | - { |
|
498 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
499 | - $set_column_values = $this->_set_column_values_for($this->_question_model); |
|
500 | - if ($new_question) { |
|
501 | - $question = EE_Question::new_instance($set_column_values); |
|
502 | - $action_desc = 'added'; |
|
503 | - } else { |
|
504 | - $question = EEM_Question::instance()->get_one_by_ID(absint($this->_req_data['QST_ID'])); |
|
505 | - $action_desc = 'updated'; |
|
506 | - } |
|
507 | - $success = $question->save(); |
|
508 | - $ID = $question->ID(); |
|
509 | - if ($ID && $question->should_have_question_options()) { |
|
510 | - //save the related options |
|
511 | - //trash removed options, save old ones |
|
512 | - //get list of all options |
|
513 | - $options = $question->options(); |
|
514 | - if (! empty($options)) { |
|
515 | - foreach ($options as $option_ID => $option) { |
|
516 | - $option_req_index = $this->_get_option_req_data_index($option_ID); |
|
517 | - if ($option_req_index !== false) { |
|
518 | - $option->save($this->_req_data['question_options'][$option_req_index]); |
|
519 | - } else { |
|
520 | - //not found, remove it |
|
521 | - $option->delete(); |
|
522 | - } |
|
523 | - } |
|
524 | - } |
|
525 | - //save new related options |
|
526 | - foreach ($this->_req_data['question_options'] as $index => $option_req_data) { |
|
527 | - //skip $index that is from our sample |
|
528 | - if ( $index === 'xxcountxx' ) { |
|
529 | - continue; |
|
530 | - } |
|
531 | - //note we allow saving blank options. |
|
532 | - if (empty($option_req_data['QSO_ID']) |
|
533 | - ) {//no ID! save it! |
|
534 | - $new_option = EE_Question_Option::new_instance(array( |
|
535 | - 'QSO_value' => $option_req_data['QSO_value'], |
|
536 | - 'QSO_desc' => $option_req_data['QSO_desc'], |
|
537 | - 'QSO_order' => $option_req_data['QSO_order'], |
|
538 | - 'QST_ID' => $question->ID(), |
|
539 | - )); |
|
540 | - $new_option->save(); |
|
541 | - } |
|
542 | - } |
|
543 | - } |
|
544 | - $query_args = array('action' => 'edit_question', 'QST_ID' => $ID); |
|
545 | - if ($success !== false) { |
|
546 | - $msg = $new_question ? sprintf(esc_html__('The %s has been created', 'event_espresso'), |
|
547 | - $this->_question_model->item_name()) : sprintf(esc_html__('The %s has been updated', 'event_espresso'), |
|
548 | - $this->_question_model->item_name()); |
|
549 | - EE_Error::add_success($msg); |
|
550 | - } |
|
551 | - |
|
552 | - $this->_redirect_after_action(false, '', $action_desc, $query_args, true); |
|
553 | - } |
|
554 | - |
|
555 | - |
|
556 | - /** |
|
557 | - * Upon saving a question, there should be an array of 'question_options'. This array is index numerically, but not |
|
558 | - * by ID |
|
559 | - * (this is done because new question options don't have an ID, but we may want to add multiple simultaneously). |
|
560 | - * So, this function gets the index in that request data array called question_options. Returns FALSE if not found. |
|
561 | - * |
|
562 | - * @param int $ID of the question option to find |
|
563 | - * @return int index in question_options array if successful, FALSE if unsuccessful |
|
564 | - */ |
|
565 | - protected function _get_option_req_data_index($ID) |
|
566 | - { |
|
567 | - $req_data_for_question_options = $this->_req_data['question_options']; |
|
568 | - foreach ($req_data_for_question_options as $num => $option_data) { |
|
569 | - if (array_key_exists('QSO_ID', $option_data) && (int)$option_data['QSO_ID'] === $ID) { |
|
570 | - return $num; |
|
571 | - } |
|
572 | - } |
|
573 | - return false; |
|
574 | - } |
|
575 | - |
|
576 | - |
|
577 | - |
|
578 | - |
|
579 | - /***********/ |
|
580 | - /* QUERIES */ |
|
581 | - /** |
|
582 | - * For internal use in getting all the query parameters |
|
583 | - * (because it's pretty well the same between question, question groups, |
|
584 | - * and for both when searching for trashed and untrashed ones) |
|
585 | - * |
|
586 | - * @param EEM_Base $model either EEM_Question or EEM_Question_Group |
|
587 | - * @param int $per_page |
|
588 | - * @param int $current_page |
|
589 | - * @return array lik EEM_Base::get_all's $query_params parameter |
|
590 | - */ |
|
591 | - protected function get_query_params($model, $per_page = 10, $current_page = 10) |
|
592 | - { |
|
593 | - $query_params = array(); |
|
594 | - $offset = ($current_page - 1) * $per_page; |
|
595 | - $query_params['limit'] = array($offset, $per_page); |
|
596 | - $order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC'; |
|
597 | - $orderby_field = $model instanceof EEM_Question ? 'QST_ID' : 'QSG_order'; |
|
598 | - $field_to_order_by = empty($this->_req_data['orderby']) ? $orderby_field : $this->_req_data['orderby']; |
|
599 | - $query_params['order_by'] = array($field_to_order_by => $order); |
|
600 | - $search_string = array_key_exists('s', $this->_req_data) ? $this->_req_data['s'] : null; |
|
601 | - if (! empty($search_string)) { |
|
602 | - if ($model instanceof EEM_Question_Group) { |
|
603 | - $query_params[0] = array( |
|
604 | - 'OR' => array( |
|
605 | - 'QSG_name' => array('LIKE', "%$search_string%"), |
|
606 | - 'QSG_desc' => array('LIKE', "%$search_string%"), |
|
607 | - ), |
|
608 | - ); |
|
609 | - } else { |
|
610 | - $query_params[0] = array( |
|
611 | - 'QST_display_text' => array('LIKE', "%$search_string%"), |
|
612 | - ); |
|
613 | - } |
|
614 | - } |
|
615 | - |
|
616 | - //capability checks (just leaving this commented out for reference because it illustrates some complicated query params that could be useful when fully implemented) |
|
617 | - /*if ( $model instanceof EEM_Question_Group ) { |
|
357 | + } //if the admin label is blank, use a slug version of the question text |
|
358 | + else if ($fieldName === 'QST_admin_label' && (isset($this->_req_data['QST_admin_label']) && empty($this->_req_data['QST_admin_label']))) { |
|
359 | + $QST_text = isset($this->_req_data['QST_display_text']) ? $this->_req_data['QST_display_text'] : ''; |
|
360 | + $set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text, 10)); |
|
361 | + } else if ($fieldName === 'QST_admin_only' && (! isset($this->_req_data['QST_admin_only']))) { |
|
362 | + $set_column_values[$fieldName] = 0; |
|
363 | + } else if ($fieldName === 'QST_max') { |
|
364 | + $qst_system = EEM_Question::instance()->get_var( |
|
365 | + array( |
|
366 | + array( |
|
367 | + 'QST_ID' => isset($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0, |
|
368 | + ), |
|
369 | + ), |
|
370 | + 'QST_system'); |
|
371 | + $max_max = EEM_Question::instance()->absolute_max_for_system_question($qst_system); |
|
372 | + if (empty($this->_req_data['QST_max']) || |
|
373 | + $this->_req_data['QST_max'] > $max_max |
|
374 | + ) { |
|
375 | + $set_column_values[$fieldName] = $max_max; |
|
376 | + } |
|
377 | + } |
|
378 | + |
|
379 | + |
|
380 | + //only add a property to the array if it's not null (otherwise the model should just use the default value) |
|
381 | + if ( |
|
382 | + ! isset($set_column_values[$fieldName]) && |
|
383 | + isset($this->_req_data[$fieldName]) |
|
384 | + ) { |
|
385 | + $set_column_values[$fieldName] = $this->_req_data[$fieldName]; |
|
386 | + } |
|
387 | + |
|
388 | + } |
|
389 | + return $set_column_values;//validation fo this data to be performed by the model before insertion. |
|
390 | + } |
|
391 | + |
|
392 | + |
|
393 | + /** |
|
394 | + *_questions_overview_list_table |
|
395 | + */ |
|
396 | + protected function _questions_overview_list_table() |
|
397 | + { |
|
398 | + $this->_search_btn_label = esc_html__('Questions', 'event_espresso'); |
|
399 | + $this->display_admin_list_table_page_with_sidebar(); |
|
400 | + } |
|
401 | + |
|
402 | + |
|
403 | + /** |
|
404 | + * _edit_question |
|
405 | + */ |
|
406 | + protected function _edit_question() |
|
407 | + { |
|
408 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
409 | + $ID = isset($this->_req_data['QST_ID']) && ! empty($this->_req_data['QST_ID']) ? absint($this->_req_data['QST_ID']) : false; |
|
410 | + |
|
411 | + switch ($this->_req_action) { |
|
412 | + case 'add_question' : |
|
413 | + $this->_admin_page_title = esc_html__('Add Question', 'event_espresso'); |
|
414 | + break; |
|
415 | + case 'edit_question' : |
|
416 | + $this->_admin_page_title = esc_html__('Edit Question', 'event_espresso'); |
|
417 | + break; |
|
418 | + default : |
|
419 | + $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
420 | + } |
|
421 | + |
|
422 | + // add PRC_ID to title if editing |
|
423 | + $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
424 | + if ($ID) { |
|
425 | + $question = $this->_question_model->get_one_by_ID($ID); |
|
426 | + $additional_hidden_fields = array('QST_ID' => array('type' => 'hidden', 'value' => $ID)); |
|
427 | + $this->_set_add_edit_form_tags('update_question', $additional_hidden_fields); |
|
428 | + } else { |
|
429 | + $question = EE_Question::new_instance(); |
|
430 | + $question->set_order_to_latest(); |
|
431 | + $this->_set_add_edit_form_tags('insert_question'); |
|
432 | + } |
|
433 | + if( $question->system_ID() === EEM_Attendee::system_question_phone ){ |
|
434 | + $question_types = array_intersect_key( |
|
435 | + EEM_Question::instance()->allowed_question_types(), |
|
436 | + array_flip( |
|
437 | + array( |
|
438 | + EEM_Question::QST_type_text, |
|
439 | + EEM_Question::QST_type_us_phone |
|
440 | + ) |
|
441 | + ) |
|
442 | + ); |
|
443 | + } else { |
|
444 | + $question_types = $question->has_answers() ? $this->_question_model->question_types_in_same_category($question->type()) : $this->_question_model->allowed_question_types(); |
|
445 | + } |
|
446 | + $this->_template_args['QST_ID'] = $ID; |
|
447 | + $this->_template_args['question'] = $question; |
|
448 | + $this->_template_args['question_types'] = $question_types; |
|
449 | + $this->_template_args['max_max'] = EEM_Question::instance()->absolute_max_for_system_question( |
|
450 | + $question->system_ID() |
|
451 | + ); |
|
452 | + $this->_template_args['question_type_descriptions'] = $this->_get_question_type_descriptions(); |
|
453 | + $this->_set_publish_post_box_vars('id', $ID); |
|
454 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
455 | + REGISTRATION_FORM_TEMPLATE_PATH . 'questions_main_meta_box.template.php', |
|
456 | + $this->_template_args, true |
|
457 | + ); |
|
458 | + |
|
459 | + // the details template wrapper |
|
460 | + $this->display_admin_page_with_sidebar(); |
|
461 | + } |
|
462 | + |
|
463 | + |
|
464 | + /** |
|
465 | + * @return string |
|
466 | + */ |
|
467 | + protected function _get_question_type_descriptions() |
|
468 | + { |
|
469 | + EE_Registry::instance()->load_helper('HTML'); |
|
470 | + $descriptions = ''; |
|
471 | + $question_type_descriptions = EEM_Question::instance()->question_descriptions(); |
|
472 | + foreach ($question_type_descriptions as $type => $question_type_description) { |
|
473 | + if ($type == 'HTML_TEXTAREA') { |
|
474 | + $html = new EE_Simple_HTML_Validation_Strategy(); |
|
475 | + $question_type_description .= sprintf( |
|
476 | + esc_html__('%1$s(allowed tags: %2$s)', 'event_espresso'), |
|
477 | + '<br/>', |
|
478 | + $html->get_list_of_allowed_tags() |
|
479 | + ); |
|
480 | + } |
|
481 | + $descriptions .= EEH_HTML::p( |
|
482 | + $question_type_description, |
|
483 | + 'question_type_description-' . $type, |
|
484 | + 'question_type_description description', |
|
485 | + 'display:none;' |
|
486 | + ); |
|
487 | + } |
|
488 | + return $descriptions; |
|
489 | + } |
|
490 | + |
|
491 | + |
|
492 | + /** |
|
493 | + * @param bool|true $new_question |
|
494 | + * @throws \EE_Error |
|
495 | + */ |
|
496 | + protected function _insert_or_update_question($new_question = true) |
|
497 | + { |
|
498 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
499 | + $set_column_values = $this->_set_column_values_for($this->_question_model); |
|
500 | + if ($new_question) { |
|
501 | + $question = EE_Question::new_instance($set_column_values); |
|
502 | + $action_desc = 'added'; |
|
503 | + } else { |
|
504 | + $question = EEM_Question::instance()->get_one_by_ID(absint($this->_req_data['QST_ID'])); |
|
505 | + $action_desc = 'updated'; |
|
506 | + } |
|
507 | + $success = $question->save(); |
|
508 | + $ID = $question->ID(); |
|
509 | + if ($ID && $question->should_have_question_options()) { |
|
510 | + //save the related options |
|
511 | + //trash removed options, save old ones |
|
512 | + //get list of all options |
|
513 | + $options = $question->options(); |
|
514 | + if (! empty($options)) { |
|
515 | + foreach ($options as $option_ID => $option) { |
|
516 | + $option_req_index = $this->_get_option_req_data_index($option_ID); |
|
517 | + if ($option_req_index !== false) { |
|
518 | + $option->save($this->_req_data['question_options'][$option_req_index]); |
|
519 | + } else { |
|
520 | + //not found, remove it |
|
521 | + $option->delete(); |
|
522 | + } |
|
523 | + } |
|
524 | + } |
|
525 | + //save new related options |
|
526 | + foreach ($this->_req_data['question_options'] as $index => $option_req_data) { |
|
527 | + //skip $index that is from our sample |
|
528 | + if ( $index === 'xxcountxx' ) { |
|
529 | + continue; |
|
530 | + } |
|
531 | + //note we allow saving blank options. |
|
532 | + if (empty($option_req_data['QSO_ID']) |
|
533 | + ) {//no ID! save it! |
|
534 | + $new_option = EE_Question_Option::new_instance(array( |
|
535 | + 'QSO_value' => $option_req_data['QSO_value'], |
|
536 | + 'QSO_desc' => $option_req_data['QSO_desc'], |
|
537 | + 'QSO_order' => $option_req_data['QSO_order'], |
|
538 | + 'QST_ID' => $question->ID(), |
|
539 | + )); |
|
540 | + $new_option->save(); |
|
541 | + } |
|
542 | + } |
|
543 | + } |
|
544 | + $query_args = array('action' => 'edit_question', 'QST_ID' => $ID); |
|
545 | + if ($success !== false) { |
|
546 | + $msg = $new_question ? sprintf(esc_html__('The %s has been created', 'event_espresso'), |
|
547 | + $this->_question_model->item_name()) : sprintf(esc_html__('The %s has been updated', 'event_espresso'), |
|
548 | + $this->_question_model->item_name()); |
|
549 | + EE_Error::add_success($msg); |
|
550 | + } |
|
551 | + |
|
552 | + $this->_redirect_after_action(false, '', $action_desc, $query_args, true); |
|
553 | + } |
|
554 | + |
|
555 | + |
|
556 | + /** |
|
557 | + * Upon saving a question, there should be an array of 'question_options'. This array is index numerically, but not |
|
558 | + * by ID |
|
559 | + * (this is done because new question options don't have an ID, but we may want to add multiple simultaneously). |
|
560 | + * So, this function gets the index in that request data array called question_options. Returns FALSE if not found. |
|
561 | + * |
|
562 | + * @param int $ID of the question option to find |
|
563 | + * @return int index in question_options array if successful, FALSE if unsuccessful |
|
564 | + */ |
|
565 | + protected function _get_option_req_data_index($ID) |
|
566 | + { |
|
567 | + $req_data_for_question_options = $this->_req_data['question_options']; |
|
568 | + foreach ($req_data_for_question_options as $num => $option_data) { |
|
569 | + if (array_key_exists('QSO_ID', $option_data) && (int)$option_data['QSO_ID'] === $ID) { |
|
570 | + return $num; |
|
571 | + } |
|
572 | + } |
|
573 | + return false; |
|
574 | + } |
|
575 | + |
|
576 | + |
|
577 | + |
|
578 | + |
|
579 | + /***********/ |
|
580 | + /* QUERIES */ |
|
581 | + /** |
|
582 | + * For internal use in getting all the query parameters |
|
583 | + * (because it's pretty well the same between question, question groups, |
|
584 | + * and for both when searching for trashed and untrashed ones) |
|
585 | + * |
|
586 | + * @param EEM_Base $model either EEM_Question or EEM_Question_Group |
|
587 | + * @param int $per_page |
|
588 | + * @param int $current_page |
|
589 | + * @return array lik EEM_Base::get_all's $query_params parameter |
|
590 | + */ |
|
591 | + protected function get_query_params($model, $per_page = 10, $current_page = 10) |
|
592 | + { |
|
593 | + $query_params = array(); |
|
594 | + $offset = ($current_page - 1) * $per_page; |
|
595 | + $query_params['limit'] = array($offset, $per_page); |
|
596 | + $order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC'; |
|
597 | + $orderby_field = $model instanceof EEM_Question ? 'QST_ID' : 'QSG_order'; |
|
598 | + $field_to_order_by = empty($this->_req_data['orderby']) ? $orderby_field : $this->_req_data['orderby']; |
|
599 | + $query_params['order_by'] = array($field_to_order_by => $order); |
|
600 | + $search_string = array_key_exists('s', $this->_req_data) ? $this->_req_data['s'] : null; |
|
601 | + if (! empty($search_string)) { |
|
602 | + if ($model instanceof EEM_Question_Group) { |
|
603 | + $query_params[0] = array( |
|
604 | + 'OR' => array( |
|
605 | + 'QSG_name' => array('LIKE', "%$search_string%"), |
|
606 | + 'QSG_desc' => array('LIKE', "%$search_string%"), |
|
607 | + ), |
|
608 | + ); |
|
609 | + } else { |
|
610 | + $query_params[0] = array( |
|
611 | + 'QST_display_text' => array('LIKE', "%$search_string%"), |
|
612 | + ); |
|
613 | + } |
|
614 | + } |
|
615 | + |
|
616 | + //capability checks (just leaving this commented out for reference because it illustrates some complicated query params that could be useful when fully implemented) |
|
617 | + /*if ( $model instanceof EEM_Question_Group ) { |
|
618 | 618 | if ( ! EE_Registry::instance()->CAP->current_user_can( 'edit_others_question_groups', 'espresso_registration_form_edit_question_group' ) ) { |
619 | 619 | $query_params[0] = array( |
620 | 620 | 'AND' => array( |
@@ -644,62 +644,62 @@ discard block |
||
644 | 644 | } |
645 | 645 | }/**/ |
646 | 646 | |
647 | - return $query_params; |
|
648 | - |
|
649 | - } |
|
650 | - |
|
651 | - |
|
652 | - /** |
|
653 | - * @param int $per_page |
|
654 | - * @param int $current_page |
|
655 | - * @param bool|false $count |
|
656 | - * @return \EE_Soft_Delete_Base_Class[]|int |
|
657 | - */ |
|
658 | - public function get_questions($per_page = 10, $current_page = 1, $count = false) |
|
659 | - { |
|
660 | - $QST = EEM_Question::instance(); |
|
661 | - $query_params = $this->get_query_params($QST, $per_page, $current_page); |
|
662 | - if ($count) { |
|
663 | - $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
664 | - $results = $QST->count($where); |
|
665 | - } else { |
|
666 | - $results = $QST->get_all($query_params); |
|
667 | - } |
|
668 | - return $results; |
|
669 | - |
|
670 | - } |
|
671 | - |
|
672 | - |
|
673 | - /** |
|
674 | - * @param $per_page |
|
675 | - * @param int $current_page |
|
676 | - * @param bool|false $count |
|
677 | - * @return \EE_Soft_Delete_Base_Class[]|int |
|
678 | - */ |
|
679 | - public function get_trashed_questions($per_page, $current_page = 1, $count = false) |
|
680 | - { |
|
681 | - $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page); |
|
682 | - $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
683 | - $questions = $count ? EEM_Question::instance()->count_deleted($where) : EEM_Question::instance()->get_all_deleted($query_params); |
|
684 | - return $questions; |
|
685 | - } |
|
686 | - |
|
687 | - |
|
688 | - /** |
|
689 | - * @param $per_page |
|
690 | - * @param int $current_page |
|
691 | - * @param bool|false $count |
|
692 | - * @return \EE_Soft_Delete_Base_Class[] |
|
693 | - */ |
|
694 | - public function get_question_groups($per_page, $current_page = 1, $count = false) |
|
695 | - { |
|
696 | - /** @type EEM_Question_Group $questionGroupModel */ |
|
697 | - $questionGroupModel = EEM_Question_Group::instance(); |
|
698 | - //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
699 | - return $questionGroupModel->get_all( |
|
700 | - $this->get_query_params($questionGroupModel, $per_page, $current_page) |
|
701 | - ); |
|
702 | - } |
|
647 | + return $query_params; |
|
648 | + |
|
649 | + } |
|
650 | + |
|
651 | + |
|
652 | + /** |
|
653 | + * @param int $per_page |
|
654 | + * @param int $current_page |
|
655 | + * @param bool|false $count |
|
656 | + * @return \EE_Soft_Delete_Base_Class[]|int |
|
657 | + */ |
|
658 | + public function get_questions($per_page = 10, $current_page = 1, $count = false) |
|
659 | + { |
|
660 | + $QST = EEM_Question::instance(); |
|
661 | + $query_params = $this->get_query_params($QST, $per_page, $current_page); |
|
662 | + if ($count) { |
|
663 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
664 | + $results = $QST->count($where); |
|
665 | + } else { |
|
666 | + $results = $QST->get_all($query_params); |
|
667 | + } |
|
668 | + return $results; |
|
669 | + |
|
670 | + } |
|
671 | + |
|
672 | + |
|
673 | + /** |
|
674 | + * @param $per_page |
|
675 | + * @param int $current_page |
|
676 | + * @param bool|false $count |
|
677 | + * @return \EE_Soft_Delete_Base_Class[]|int |
|
678 | + */ |
|
679 | + public function get_trashed_questions($per_page, $current_page = 1, $count = false) |
|
680 | + { |
|
681 | + $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page); |
|
682 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
683 | + $questions = $count ? EEM_Question::instance()->count_deleted($where) : EEM_Question::instance()->get_all_deleted($query_params); |
|
684 | + return $questions; |
|
685 | + } |
|
686 | + |
|
687 | + |
|
688 | + /** |
|
689 | + * @param $per_page |
|
690 | + * @param int $current_page |
|
691 | + * @param bool|false $count |
|
692 | + * @return \EE_Soft_Delete_Base_Class[] |
|
693 | + */ |
|
694 | + public function get_question_groups($per_page, $current_page = 1, $count = false) |
|
695 | + { |
|
696 | + /** @type EEM_Question_Group $questionGroupModel */ |
|
697 | + $questionGroupModel = EEM_Question_Group::instance(); |
|
698 | + //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
699 | + return $questionGroupModel->get_all( |
|
700 | + $this->get_query_params($questionGroupModel, $per_page, $current_page) |
|
701 | + ); |
|
702 | + } |
|
703 | 703 | |
704 | 704 | |
705 | 705 | } //ends Registration_Form_Admin_Page class |
@@ -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 | |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function __construct($routing = true) |
68 | 68 | { |
69 | - require_once(EE_MODELS . 'EEM_Question.model.php'); |
|
70 | - require_once(EE_MODELS . 'EEM_Question_Group.model.php'); |
|
69 | + require_once(EE_MODELS.'EEM_Question.model.php'); |
|
70 | + require_once(EE_MODELS.'EEM_Question_Group.model.php'); |
|
71 | 71 | $this->_question_model = EEM_Question::instance(); |
72 | 72 | $this->_question_group_model = EEM_Question_Group::instance(); |
73 | 73 | parent::__construct($routing); |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | public function load_scripts_styles() |
233 | 233 | { |
234 | 234 | wp_register_style('espresso_registration', |
235 | - REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
235 | + REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
236 | 236 | wp_enqueue_style('espresso_registration'); |
237 | 237 | } |
238 | 238 | |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | { |
259 | 259 | $this->load_scripts_styles_forms(); |
260 | 260 | wp_register_script('espresso_registration_form_single', |
261 | - REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), |
|
261 | + REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.js', array('jquery-ui-sortable'), |
|
262 | 262 | EVENT_ESPRESSO_VERSION, true); |
263 | 263 | wp_enqueue_script('espresso_registration_form_single'); |
264 | 264 | } |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | { |
268 | 268 | $this->load_scripts_styles_forms(); |
269 | 269 | wp_register_script('espresso_registration_form_single', |
270 | - REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), |
|
270 | + REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.js', array('jquery-ui-sortable'), |
|
271 | 271 | EVENT_ESPRESSO_VERSION, true); |
272 | 272 | wp_enqueue_script('espresso_registration_form_single'); |
273 | 273 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | |
276 | 276 | public function recaptcha_info_help_tab() |
277 | 277 | { |
278 | - $template = REGISTRATION_FORM_TEMPLATE_PATH . 'recaptcha_info_help_tab.template.php'; |
|
278 | + $template = REGISTRATION_FORM_TEMPLATE_PATH.'recaptcha_info_help_tab.template.php'; |
|
279 | 279 | EEH_Template::display_template($template, array()); |
280 | 280 | } |
281 | 281 | |
@@ -324,10 +324,10 @@ discard block |
||
324 | 324 | protected function _questions_groups_preview() |
325 | 325 | { |
326 | 326 | $this->_admin_page_title = esc_html__('Question Groups (Preview)', 'event_espresso'); |
327 | - $this->_template_args['preview_img'] = '<img src="' . REGISTRATION_FORM_ASSETS_URL . 'caf_reg_form_preview.jpg" alt="' . esc_attr__('Preview Question Groups Overview List Table screenshot', |
|
328 | - 'event_espresso') . '" />'; |
|
329 | - $this->_template_args['preview_text'] = '<strong>' . esc_html__('Question Groups is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. With the Question Groups feature you are able to create new question groups, edit existing question groups, and create and edit new questions and add them to question groups.', |
|
330 | - 'event_espresso') . '</strong>'; |
|
327 | + $this->_template_args['preview_img'] = '<img src="'.REGISTRATION_FORM_ASSETS_URL.'caf_reg_form_preview.jpg" alt="'.esc_attr__('Preview Question Groups Overview List Table screenshot', |
|
328 | + 'event_espresso').'" />'; |
|
329 | + $this->_template_args['preview_text'] = '<strong>'.esc_html__('Question Groups is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. With the Question Groups feature you are able to create new question groups, edit existing question groups, and create and edit new questions and add them to question groups.', |
|
330 | + 'event_espresso').'</strong>'; |
|
331 | 331 | $this->display_admin_caf_preview_page('question_groups_tab'); |
332 | 332 | } |
333 | 333 | |
@@ -345,20 +345,20 @@ discard block |
||
345 | 345 | |
346 | 346 | //some initial checks for proper values. |
347 | 347 | //if QST_admin_only, then no matter what QST_required is we disable. |
348 | - if (! empty($this->_req_data['QST_admin_only'])) { |
|
348 | + if ( ! empty($this->_req_data['QST_admin_only'])) { |
|
349 | 349 | $this->_req_data['QST_required'] = 0; |
350 | 350 | } |
351 | 351 | foreach ($model->field_settings() as $fieldName => $settings) { |
352 | 352 | // basically if QSG_identifier is empty or not set |
353 | 353 | if ($fieldName === 'QSG_identifier' && (isset($this->_req_data['QSG_identifier']) && empty($this->_req_data['QSG_identifier']))) { |
354 | 354 | $QSG_name = isset($this->_req_data['QSG_name']) ? $this->_req_data['QSG_name'] : ''; |
355 | - $set_column_values[$fieldName] = sanitize_title($QSG_name) . '-' . uniqid('', true); |
|
355 | + $set_column_values[$fieldName] = sanitize_title($QSG_name).'-'.uniqid('', true); |
|
356 | 356 | // dd($set_column_values); |
357 | 357 | } //if the admin label is blank, use a slug version of the question text |
358 | 358 | else if ($fieldName === 'QST_admin_label' && (isset($this->_req_data['QST_admin_label']) && empty($this->_req_data['QST_admin_label']))) { |
359 | 359 | $QST_text = isset($this->_req_data['QST_display_text']) ? $this->_req_data['QST_display_text'] : ''; |
360 | 360 | $set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text, 10)); |
361 | - } else if ($fieldName === 'QST_admin_only' && (! isset($this->_req_data['QST_admin_only']))) { |
|
361 | + } else if ($fieldName === 'QST_admin_only' && ( ! isset($this->_req_data['QST_admin_only']))) { |
|
362 | 362 | $set_column_values[$fieldName] = 0; |
363 | 363 | } else if ($fieldName === 'QST_max') { |
364 | 364 | $qst_system = EEM_Question::instance()->get_var( |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | ), |
369 | 369 | ), |
370 | 370 | 'QST_system'); |
371 | - $max_max = EEM_Question::instance()->absolute_max_for_system_question($qst_system); |
|
371 | + $max_max = EEM_Question::instance()->absolute_max_for_system_question($qst_system); |
|
372 | 372 | if (empty($this->_req_data['QST_max']) || |
373 | 373 | $this->_req_data['QST_max'] > $max_max |
374 | 374 | ) { |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | } |
387 | 387 | |
388 | 388 | } |
389 | - return $set_column_values;//validation fo this data to be performed by the model before insertion. |
|
389 | + return $set_column_values; //validation fo this data to be performed by the model before insertion. |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | } |
421 | 421 | |
422 | 422 | // add PRC_ID to title if editing |
423 | - $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
423 | + $this->_admin_page_title = $ID ? $this->_admin_page_title.' # '.$ID : $this->_admin_page_title; |
|
424 | 424 | if ($ID) { |
425 | 425 | $question = $this->_question_model->get_one_by_ID($ID); |
426 | 426 | $additional_hidden_fields = array('QST_ID' => array('type' => 'hidden', 'value' => $ID)); |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | $question->set_order_to_latest(); |
431 | 431 | $this->_set_add_edit_form_tags('insert_question'); |
432 | 432 | } |
433 | - if( $question->system_ID() === EEM_Attendee::system_question_phone ){ |
|
433 | + if ($question->system_ID() === EEM_Attendee::system_question_phone) { |
|
434 | 434 | $question_types = array_intersect_key( |
435 | 435 | EEM_Question::instance()->allowed_question_types(), |
436 | 436 | array_flip( |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | $this->_template_args['question_type_descriptions'] = $this->_get_question_type_descriptions(); |
453 | 453 | $this->_set_publish_post_box_vars('id', $ID); |
454 | 454 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
455 | - REGISTRATION_FORM_TEMPLATE_PATH . 'questions_main_meta_box.template.php', |
|
455 | + REGISTRATION_FORM_TEMPLATE_PATH.'questions_main_meta_box.template.php', |
|
456 | 456 | $this->_template_args, true |
457 | 457 | ); |
458 | 458 | |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | } |
481 | 481 | $descriptions .= EEH_HTML::p( |
482 | 482 | $question_type_description, |
483 | - 'question_type_description-' . $type, |
|
483 | + 'question_type_description-'.$type, |
|
484 | 484 | 'question_type_description description', |
485 | 485 | 'display:none;' |
486 | 486 | ); |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | $question = EE_Question::new_instance($set_column_values); |
502 | 502 | $action_desc = 'added'; |
503 | 503 | } else { |
504 | - $question = EEM_Question::instance()->get_one_by_ID(absint($this->_req_data['QST_ID'])); |
|
504 | + $question = EEM_Question::instance()->get_one_by_ID(absint($this->_req_data['QST_ID'])); |
|
505 | 505 | $action_desc = 'updated'; |
506 | 506 | } |
507 | 507 | $success = $question->save(); |
@@ -510,8 +510,8 @@ discard block |
||
510 | 510 | //save the related options |
511 | 511 | //trash removed options, save old ones |
512 | 512 | //get list of all options |
513 | - $options = $question->options(); |
|
514 | - if (! empty($options)) { |
|
513 | + $options = $question->options(); |
|
514 | + if ( ! empty($options)) { |
|
515 | 515 | foreach ($options as $option_ID => $option) { |
516 | 516 | $option_req_index = $this->_get_option_req_data_index($option_ID); |
517 | 517 | if ($option_req_index !== false) { |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | //save new related options |
526 | 526 | foreach ($this->_req_data['question_options'] as $index => $option_req_data) { |
527 | 527 | //skip $index that is from our sample |
528 | - if ( $index === 'xxcountxx' ) { |
|
528 | + if ($index === 'xxcountxx') { |
|
529 | 529 | continue; |
530 | 530 | } |
531 | 531 | //note we allow saving blank options. |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | { |
567 | 567 | $req_data_for_question_options = $this->_req_data['question_options']; |
568 | 568 | foreach ($req_data_for_question_options as $num => $option_data) { |
569 | - if (array_key_exists('QSO_ID', $option_data) && (int)$option_data['QSO_ID'] === $ID) { |
|
569 | + if (array_key_exists('QSO_ID', $option_data) && (int) $option_data['QSO_ID'] === $ID) { |
|
570 | 570 | return $num; |
571 | 571 | } |
572 | 572 | } |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | $field_to_order_by = empty($this->_req_data['orderby']) ? $orderby_field : $this->_req_data['orderby']; |
599 | 599 | $query_params['order_by'] = array($field_to_order_by => $order); |
600 | 600 | $search_string = array_key_exists('s', $this->_req_data) ? $this->_req_data['s'] : null; |
601 | - if (! empty($search_string)) { |
|
601 | + if ( ! empty($search_string)) { |
|
602 | 602 | if ($model instanceof EEM_Question_Group) { |
603 | 603 | $query_params[0] = array( |
604 | 604 | 'OR' => array( |
@@ -38,217 +38,217 @@ |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | - /** |
|
43 | - * espresso_duplicate_plugin_error |
|
44 | - * displays if more than one version of EE is activated at the same time |
|
45 | - */ |
|
46 | - function espresso_duplicate_plugin_error() |
|
47 | - { |
|
48 | - ?> |
|
41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | + /** |
|
43 | + * espresso_duplicate_plugin_error |
|
44 | + * displays if more than one version of EE is activated at the same time |
|
45 | + */ |
|
46 | + function espresso_duplicate_plugin_error() |
|
47 | + { |
|
48 | + ?> |
|
49 | 49 | <div class="error"> |
50 | 50 | <p> |
51 | 51 | <?php |
52 | - echo esc_html__( |
|
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
52 | + echo esc_html__( |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
61 | - } |
|
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | + } |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | |
64 | 64 | } else { |
65 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
66 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
67 | - /** |
|
68 | - * espresso_minimum_php_version_error |
|
69 | - * |
|
70 | - * @return void |
|
71 | - */ |
|
72 | - function espresso_minimum_php_version_error() |
|
73 | - { |
|
74 | - ?> |
|
65 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
66 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
67 | + /** |
|
68 | + * espresso_minimum_php_version_error |
|
69 | + * |
|
70 | + * @return void |
|
71 | + */ |
|
72 | + function espresso_minimum_php_version_error() |
|
73 | + { |
|
74 | + ?> |
|
75 | 75 | <div class="error"> |
76 | 76 | <p> |
77 | 77 | <?php |
78 | - printf( |
|
79 | - esc_html__( |
|
80 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
81 | - 'event_espresso' |
|
82 | - ), |
|
83 | - EE_MIN_PHP_VER_REQUIRED, |
|
84 | - PHP_VERSION, |
|
85 | - '<br/>', |
|
86 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
87 | - ); |
|
88 | - ?> |
|
78 | + printf( |
|
79 | + esc_html__( |
|
80 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
81 | + 'event_espresso' |
|
82 | + ), |
|
83 | + EE_MIN_PHP_VER_REQUIRED, |
|
84 | + PHP_VERSION, |
|
85 | + '<br/>', |
|
86 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
87 | + ); |
|
88 | + ?> |
|
89 | 89 | </p> |
90 | 90 | </div> |
91 | 91 | <?php |
92 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
93 | - } |
|
92 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
93 | + } |
|
94 | 94 | |
95 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
96 | - } else { |
|
97 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
98 | - /** |
|
99 | - * espresso_version |
|
100 | - * Returns the plugin version |
|
101 | - * |
|
102 | - * @return string |
|
103 | - */ |
|
104 | - function espresso_version() |
|
105 | - { |
|
106 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.51.rc.006'); |
|
107 | - } |
|
95 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
96 | + } else { |
|
97 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
98 | + /** |
|
99 | + * espresso_version |
|
100 | + * Returns the plugin version |
|
101 | + * |
|
102 | + * @return string |
|
103 | + */ |
|
104 | + function espresso_version() |
|
105 | + { |
|
106 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.51.rc.006'); |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * espresso_plugin_activation |
|
111 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
112 | - */ |
|
113 | - function espresso_plugin_activation() |
|
114 | - { |
|
115 | - update_option('ee_espresso_activation', true); |
|
116 | - } |
|
109 | + /** |
|
110 | + * espresso_plugin_activation |
|
111 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
112 | + */ |
|
113 | + function espresso_plugin_activation() |
|
114 | + { |
|
115 | + update_option('ee_espresso_activation', true); |
|
116 | + } |
|
117 | 117 | |
118 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
119 | - /** |
|
120 | - * espresso_load_error_handling |
|
121 | - * this function loads EE's class for handling exceptions and errors |
|
122 | - */ |
|
123 | - function espresso_load_error_handling() |
|
124 | - { |
|
125 | - static $error_handling_loaded = false; |
|
126 | - if ($error_handling_loaded) { |
|
127 | - return; |
|
128 | - } |
|
129 | - // load debugging tools |
|
130 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
131 | - require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php'; |
|
132 | - \EEH_Debug_Tools::instance(); |
|
133 | - } |
|
134 | - // load error handling |
|
135 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
136 | - require_once EE_CORE . 'EE_Error.core.php'; |
|
137 | - } else { |
|
138 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
139 | - } |
|
140 | - $error_handling_loaded = true; |
|
141 | - } |
|
118 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
119 | + /** |
|
120 | + * espresso_load_error_handling |
|
121 | + * this function loads EE's class for handling exceptions and errors |
|
122 | + */ |
|
123 | + function espresso_load_error_handling() |
|
124 | + { |
|
125 | + static $error_handling_loaded = false; |
|
126 | + if ($error_handling_loaded) { |
|
127 | + return; |
|
128 | + } |
|
129 | + // load debugging tools |
|
130 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
131 | + require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php'; |
|
132 | + \EEH_Debug_Tools::instance(); |
|
133 | + } |
|
134 | + // load error handling |
|
135 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
136 | + require_once EE_CORE . 'EE_Error.core.php'; |
|
137 | + } else { |
|
138 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
139 | + } |
|
140 | + $error_handling_loaded = true; |
|
141 | + } |
|
142 | 142 | |
143 | - /** |
|
144 | - * espresso_load_required |
|
145 | - * given a class name and path, this function will load that file or throw an exception |
|
146 | - * |
|
147 | - * @param string $classname |
|
148 | - * @param string $full_path_to_file |
|
149 | - * @throws EE_Error |
|
150 | - */ |
|
151 | - function espresso_load_required($classname, $full_path_to_file) |
|
152 | - { |
|
153 | - if (is_readable($full_path_to_file)) { |
|
154 | - require_once $full_path_to_file; |
|
155 | - } else { |
|
156 | - throw new \EE_Error ( |
|
157 | - sprintf( |
|
158 | - esc_html__( |
|
159 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
160 | - 'event_espresso' |
|
161 | - ), |
|
162 | - $classname |
|
163 | - ) |
|
164 | - ); |
|
165 | - } |
|
166 | - } |
|
143 | + /** |
|
144 | + * espresso_load_required |
|
145 | + * given a class name and path, this function will load that file or throw an exception |
|
146 | + * |
|
147 | + * @param string $classname |
|
148 | + * @param string $full_path_to_file |
|
149 | + * @throws EE_Error |
|
150 | + */ |
|
151 | + function espresso_load_required($classname, $full_path_to_file) |
|
152 | + { |
|
153 | + if (is_readable($full_path_to_file)) { |
|
154 | + require_once $full_path_to_file; |
|
155 | + } else { |
|
156 | + throw new \EE_Error ( |
|
157 | + sprintf( |
|
158 | + esc_html__( |
|
159 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
160 | + 'event_espresso' |
|
161 | + ), |
|
162 | + $classname |
|
163 | + ) |
|
164 | + ); |
|
165 | + } |
|
166 | + } |
|
167 | 167 | |
168 | - /** |
|
169 | - * @since 4.9.27 |
|
170 | - * @throws \EE_Error |
|
171 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
172 | - * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
173 | - * @throws \EventEspresso\core\exceptions\InvalidIdentifierException |
|
174 | - * @throws \EventEspresso\core\exceptions\InvalidClassException |
|
175 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
176 | - * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException |
|
177 | - * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException |
|
178 | - * @throws \OutOfBoundsException |
|
179 | - */ |
|
180 | - function bootstrap_espresso() |
|
181 | - { |
|
182 | - require_once __DIR__ . '/core/espresso_definitions.php'; |
|
183 | - try { |
|
184 | - espresso_load_error_handling(); |
|
185 | - espresso_load_required( |
|
186 | - 'EEH_Base', |
|
187 | - EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' |
|
188 | - ); |
|
189 | - espresso_load_required( |
|
190 | - 'EEH_File', |
|
191 | - EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php' |
|
192 | - ); |
|
193 | - espresso_load_required( |
|
194 | - 'EEH_File', |
|
195 | - EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' |
|
196 | - ); |
|
197 | - espresso_load_required( |
|
198 | - 'EEH_Array', |
|
199 | - EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php' |
|
200 | - ); |
|
201 | - // instantiate and configure PSR4 autoloader |
|
202 | - espresso_load_required( |
|
203 | - 'Psr4Autoloader', |
|
204 | - EE_CORE . 'Psr4Autoloader.php' |
|
205 | - ); |
|
206 | - espresso_load_required( |
|
207 | - 'EE_Psr4AutoloaderInit', |
|
208 | - EE_CORE . 'EE_Psr4AutoloaderInit.core.php' |
|
209 | - ); |
|
210 | - $AutoloaderInit = new EE_Psr4AutoloaderInit(); |
|
211 | - $AutoloaderInit->initializeAutoloader(); |
|
212 | - espresso_load_required( |
|
213 | - 'EE_Request', |
|
214 | - EE_CORE . 'request_stack' . DS . 'EE_Request.core.php' |
|
215 | - ); |
|
216 | - espresso_load_required( |
|
217 | - 'EE_Response', |
|
218 | - EE_CORE . 'request_stack' . DS . 'EE_Response.core.php' |
|
219 | - ); |
|
220 | - espresso_load_required( |
|
221 | - 'EE_Bootstrap', |
|
222 | - EE_CORE . 'EE_Bootstrap.core.php' |
|
223 | - ); |
|
224 | - // bootstrap EE and the request stack |
|
225 | - new EE_Bootstrap( |
|
226 | - new EE_Request($_GET, $_POST, $_COOKIE), |
|
227 | - new EE_Response() |
|
228 | - ); |
|
229 | - } catch (Exception $e) { |
|
230 | - require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php'; |
|
231 | - new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e); |
|
232 | - } |
|
233 | - } |
|
234 | - bootstrap_espresso(); |
|
235 | - } |
|
168 | + /** |
|
169 | + * @since 4.9.27 |
|
170 | + * @throws \EE_Error |
|
171 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
172 | + * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
173 | + * @throws \EventEspresso\core\exceptions\InvalidIdentifierException |
|
174 | + * @throws \EventEspresso\core\exceptions\InvalidClassException |
|
175 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
176 | + * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException |
|
177 | + * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException |
|
178 | + * @throws \OutOfBoundsException |
|
179 | + */ |
|
180 | + function bootstrap_espresso() |
|
181 | + { |
|
182 | + require_once __DIR__ . '/core/espresso_definitions.php'; |
|
183 | + try { |
|
184 | + espresso_load_error_handling(); |
|
185 | + espresso_load_required( |
|
186 | + 'EEH_Base', |
|
187 | + EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' |
|
188 | + ); |
|
189 | + espresso_load_required( |
|
190 | + 'EEH_File', |
|
191 | + EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php' |
|
192 | + ); |
|
193 | + espresso_load_required( |
|
194 | + 'EEH_File', |
|
195 | + EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' |
|
196 | + ); |
|
197 | + espresso_load_required( |
|
198 | + 'EEH_Array', |
|
199 | + EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php' |
|
200 | + ); |
|
201 | + // instantiate and configure PSR4 autoloader |
|
202 | + espresso_load_required( |
|
203 | + 'Psr4Autoloader', |
|
204 | + EE_CORE . 'Psr4Autoloader.php' |
|
205 | + ); |
|
206 | + espresso_load_required( |
|
207 | + 'EE_Psr4AutoloaderInit', |
|
208 | + EE_CORE . 'EE_Psr4AutoloaderInit.core.php' |
|
209 | + ); |
|
210 | + $AutoloaderInit = new EE_Psr4AutoloaderInit(); |
|
211 | + $AutoloaderInit->initializeAutoloader(); |
|
212 | + espresso_load_required( |
|
213 | + 'EE_Request', |
|
214 | + EE_CORE . 'request_stack' . DS . 'EE_Request.core.php' |
|
215 | + ); |
|
216 | + espresso_load_required( |
|
217 | + 'EE_Response', |
|
218 | + EE_CORE . 'request_stack' . DS . 'EE_Response.core.php' |
|
219 | + ); |
|
220 | + espresso_load_required( |
|
221 | + 'EE_Bootstrap', |
|
222 | + EE_CORE . 'EE_Bootstrap.core.php' |
|
223 | + ); |
|
224 | + // bootstrap EE and the request stack |
|
225 | + new EE_Bootstrap( |
|
226 | + new EE_Request($_GET, $_POST, $_COOKIE), |
|
227 | + new EE_Response() |
|
228 | + ); |
|
229 | + } catch (Exception $e) { |
|
230 | + require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php'; |
|
231 | + new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e); |
|
232 | + } |
|
233 | + } |
|
234 | + bootstrap_espresso(); |
|
235 | + } |
|
236 | 236 | } |
237 | 237 | if (! function_exists('espresso_deactivate_plugin')) { |
238 | - /** |
|
239 | - * deactivate_plugin |
|
240 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
241 | - * |
|
242 | - * @access public |
|
243 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
244 | - * @return void |
|
245 | - */ |
|
246 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
247 | - { |
|
248 | - if (! function_exists('deactivate_plugins')) { |
|
249 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
250 | - } |
|
251 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
252 | - deactivate_plugins($plugin_basename); |
|
253 | - } |
|
238 | + /** |
|
239 | + * deactivate_plugin |
|
240 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
241 | + * |
|
242 | + * @access public |
|
243 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
244 | + * @return void |
|
245 | + */ |
|
246 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
247 | + { |
|
248 | + if (! function_exists('deactivate_plugins')) { |
|
249 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
250 | + } |
|
251 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
252 | + deactivate_plugins($plugin_basename); |
|
253 | + } |
|
254 | 254 | } |