@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * |
|
4 | - * Class EE_Model_Form_Section |
|
5 | - * |
|
6 | - * For auto-generating form sections based off a model. |
|
7 | - * |
|
8 | - * @package Event Espresso |
|
9 | - * @subpackage /core/libraries/form_sections/ |
|
10 | - * @author Michael Nelson |
|
11 | - * @since 4.5.0 |
|
12 | - * |
|
13 | - */ |
|
3 | + * |
|
4 | + * Class EE_Model_Form_Section |
|
5 | + * |
|
6 | + * For auto-generating form sections based off a model. |
|
7 | + * |
|
8 | + * @package Event Espresso |
|
9 | + * @subpackage /core/libraries/form_sections/ |
|
10 | + * @author Michael Nelson |
|
11 | + * @since 4.5.0 |
|
12 | + * |
|
13 | + */ |
|
14 | 14 | class EE_Model_Form_Section extends EE_Form_Section_Proper{ |
15 | 15 | |
16 | 16 | /** |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * |
|
4 | - * Class JobHandlerFile |
|
5 | - * |
|
6 | - * Base class for common implementations of JobHandlerInterface, but ones |
|
7 | - * which write to a temporary file |
|
8 | - * |
|
9 | - * @package Event Espresso |
|
10 | - * @subpackage batch |
|
11 | - * @author Mike Nelson |
|
12 | - * @since 4.8.26 |
|
13 | - * |
|
14 | - */ |
|
3 | + * |
|
4 | + * Class JobHandlerFile |
|
5 | + * |
|
6 | + * Base class for common implementations of JobHandlerInterface, but ones |
|
7 | + * which write to a temporary file |
|
8 | + * |
|
9 | + * @package Event Espresso |
|
10 | + * @subpackage batch |
|
11 | + * @author Mike Nelson |
|
12 | + * @since 4.8.26 |
|
13 | + * |
|
14 | + */ |
|
15 | 15 | namespace EventEspressoBatchRequest\JobHandlerBaseClasses; |
16 | 16 | |
17 | 17 | use EventEspressoBatchRequest\Helpers\BatchRequestException; |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | |
17 | 17 | use EventEspressoBatchRequest\Helpers\BatchRequestException; |
18 | 18 | |
19 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
20 | - exit( 'No direct script access allowed' ); |
|
19 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
20 | + exit('No direct script access allowed'); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @param \EEHI_File|null $file_helper |
41 | 41 | */ |
42 | - public function __construct( \EEHI_File $file_helper = null ) { |
|
43 | - if( ! $file_helper ) { |
|
42 | + public function __construct(\EEHI_File $file_helper = null) { |
|
43 | + if ( ! $file_helper) { |
|
44 | 44 | $this->_file_helper = new \EEH_File(); |
45 | 45 | } |
46 | 46 | } |
@@ -56,39 +56,39 @@ discard block |
||
56 | 56 | * @return string |
57 | 57 | * @throws \EventEspressoBatchRequest\Helpers\BatchRequestException |
58 | 58 | */ |
59 | - public function create_file_from_job_with_name( $job_id, $filename, $filetype = 'application/ms-excel' ) { |
|
59 | + public function create_file_from_job_with_name($job_id, $filename, $filetype = 'application/ms-excel') { |
|
60 | 60 | $filepath = ''; |
61 | - try{ |
|
61 | + try { |
|
62 | 62 | $base_folder = $this->get_base_folder(); |
63 | 63 | $success = $this->_file_helper->ensure_folder_exists_and_is_writable( |
64 | - $base_folder . JobHandlerFile::temp_folder_name |
|
64 | + $base_folder.JobHandlerFile::temp_folder_name |
|
65 | 65 | ); |
66 | - if ( $success ) { |
|
66 | + if ($success) { |
|
67 | 67 | $success = $this->_file_helper->ensure_folder_exists_and_is_writable( |
68 | - $base_folder . JobHandlerFile::temp_folder_name . DS . $job_id |
|
68 | + $base_folder.JobHandlerFile::temp_folder_name.DS.$job_id |
|
69 | 69 | ); |
70 | 70 | } |
71 | - if( $success ) { |
|
72 | - $filepath = $base_folder . JobHandlerFile::temp_folder_name . DS . $job_id . DS. $filename; |
|
73 | - $success = $this->_file_helper->ensure_file_exists_and_is_writable( $filepath ); |
|
71 | + if ($success) { |
|
72 | + $filepath = $base_folder.JobHandlerFile::temp_folder_name.DS.$job_id.DS.$filename; |
|
73 | + $success = $this->_file_helper->ensure_file_exists_and_is_writable($filepath); |
|
74 | 74 | } |
75 | 75 | //let's add the .htaccess file so safari will open the file properly |
76 | - if( $success ) { |
|
77 | - $extension = \EEH_File::get_file_extension( $filepath ); |
|
76 | + if ($success) { |
|
77 | + $extension = \EEH_File::get_file_extension($filepath); |
|
78 | 78 | \EEH_File::write_to_file( |
79 | - $base_folder . JobHandlerFile::temp_folder_name . DS . $job_id . DS . '.htaccess', |
|
80 | - 'AddType ' . $filetype . ' ' . $extension, |
|
79 | + $base_folder.JobHandlerFile::temp_folder_name.DS.$job_id.DS.'.htaccess', |
|
80 | + 'AddType '.$filetype.' '.$extension, |
|
81 | 81 | '.htaccess' |
82 | 82 | ); |
83 | 83 | } |
84 | 84 | //those methods normally fail with an exception, but if not, let's do it |
85 | - if( ! $success ) { |
|
86 | - throw new \EE_Error( __( 'Could not create temporary file, an unknown error occurred', 'event_espresso' ) ); |
|
85 | + if ( ! $success) { |
|
86 | + throw new \EE_Error(__('Could not create temporary file, an unknown error occurred', 'event_espresso')); |
|
87 | 87 | } |
88 | - } catch( \EE_Error $e ) { |
|
88 | + } catch (\EE_Error $e) { |
|
89 | 89 | throw new BatchRequestException( |
90 | 90 | sprintf( |
91 | - __( 'Could not create temporary file for job %1$s, because: %2$s ', 'event_espresso' ), |
|
91 | + __('Could not create temporary file for job %1$s, because: %2$s ', 'event_espresso'), |
|
92 | 92 | $job_id, |
93 | 93 | $e->getMessage() |
94 | 94 | ), |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | * @param string $filepath |
105 | 105 | * @return string url to file |
106 | 106 | */ |
107 | - public function get_url_to_file( $filepath ) { |
|
108 | - return str_replace( $this->get_base_folder(), $this->get_base_url(), $filepath ); |
|
107 | + public function get_url_to_file($filepath) { |
|
108 | + return str_replace($this->get_base_folder(), $this->get_base_url(), $filepath); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | 2 | /** |
3 | - * EE_Year_Input |
|
4 | - * |
|
5 | - * @package Event Espresso |
|
6 | - * @subpackage |
|
7 | - * @author Mike Nelson |
|
8 | - * |
|
9 | - * This input has a default validation strategy of plaintext (which can be removed after construction) |
|
10 | - */ |
|
3 | + * EE_Year_Input |
|
4 | + * |
|
5 | + * @package Event Espresso |
|
6 | + * @subpackage |
|
7 | + * @author Mike Nelson |
|
8 | + * |
|
9 | + * This input has a default validation strategy of plaintext (which can be removed after construction) |
|
10 | + */ |
|
11 | 11 | class EE_Text_Input extends EE_Form_Input_Base{ |
12 | 12 | |
13 | 13 |
@@ -8,19 +8,19 @@ discard block |
||
8 | 8 | * |
9 | 9 | * This input has a default validation strategy of plaintext (which can be removed after construction) |
10 | 10 | */ |
11 | -class EE_Text_Input extends EE_Form_Input_Base{ |
|
11 | +class EE_Text_Input extends EE_Form_Input_Base { |
|
12 | 12 | |
13 | 13 | |
14 | 14 | /** |
15 | 15 | * @param array $options |
16 | 16 | */ |
17 | - function __construct($options = array()){ |
|
17 | + function __construct($options = array()) { |
|
18 | 18 | $this->_set_display_strategy(new EE_Text_Input_Display_Strategy()); |
19 | 19 | $this->_set_normalization_strategy(new EE_Text_Normalization()); |
20 | 20 | parent::__construct($options); |
21 | 21 | //if the input hasn't specifically mentioned a more lenient validation strategy, |
22 | 22 | //apply plaintext validation strategy |
23 | - if( ! $this->has_validation_strategy( |
|
23 | + if ( ! $this->has_validation_strategy( |
|
24 | 24 | array( |
25 | 25 | 'EE_Full_HTML_Validation_Strategy', |
26 | 26 | 'EE_Simple_HTML_Validation_Strategy' |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | ) { |
30 | 30 | //by default we use the plaintext validation. If you want something else, |
31 | 31 | //just remove it after the input is constructed :P using EE_Form_Input_Base::remove_validation_strategy() |
32 | - $this->_add_validation_strategy( new EE_Plaintext_Validation_Strategy() ); |
|
32 | + $this->_add_validation_strategy(new EE_Plaintext_Validation_Strategy()); |
|
33 | 33 | } |
34 | 34 | } |
35 | 35 |
@@ -1,19 +1,19 @@ |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | 2 | /** |
3 | - * |
|
4 | - * EE_Load_Espresso_Core |
|
5 | - * |
|
6 | - * This is the core application loader class at the center of the EE Middleware Request Stack. |
|
7 | - * Although not an instance of EE_Middleware, it DOES implement the EEI_Request_Decorator, allowing it to communicate |
|
8 | - * with the other EE_Middleware classes. |
|
9 | - * Performs all of the basic class loading that used to be in the EE_System constructor. |
|
10 | - * |
|
11 | - * @package Event Espresso |
|
12 | - * @subpackage core/ |
|
13 | - * @author Brent Christensen, Michael Nelson |
|
14 | - * |
|
15 | - * ------------------------------------------------------------------------ |
|
16 | - */ |
|
3 | + * |
|
4 | + * EE_Load_Espresso_Core |
|
5 | + * |
|
6 | + * This is the core application loader class at the center of the EE Middleware Request Stack. |
|
7 | + * Although not an instance of EE_Middleware, it DOES implement the EEI_Request_Decorator, allowing it to communicate |
|
8 | + * with the other EE_Middleware classes. |
|
9 | + * Performs all of the basic class loading that used to be in the EE_System constructor. |
|
10 | + * |
|
11 | + * @package Event Espresso |
|
12 | + * @subpackage core/ |
|
13 | + * @author Brent Christensen, Michael Nelson |
|
14 | + * |
|
15 | + * ------------------------------------------------------------------------ |
|
16 | + */ |
|
17 | 17 | class EE_Load_Espresso_Core implements EEI_Request_Decorator, EEI_Request_Stack_Core_App { |
18 | 18 | |
19 | 19 | /** |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * |
@@ -65,26 +65,26 @@ discard block |
||
65 | 65 | * @param EE_Response $response |
66 | 66 | * @return EE_Response |
67 | 67 | */ |
68 | - public function handle_request( EE_Request $request, EE_Response $response ) { |
|
68 | + public function handle_request(EE_Request $request, EE_Response $response) { |
|
69 | 69 | $this->request = $request; |
70 | 70 | $this->response = $response; |
71 | 71 | // info about how to load classes required by other classes |
72 | 72 | $this->dependency_map = $this->_load_dependency_map(); |
73 | 73 | // central repository for classes |
74 | 74 | $this->registry = $this->_load_registry(); |
75 | - do_action( 'EE_Load_Espresso_Core__handle_request__initialize_core_loading' ); |
|
75 | + do_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading'); |
|
76 | 76 | // workarounds for PHP < 5.3 |
77 | 77 | $this->_load_class_tools(); |
78 | 78 | // deprecated functions |
79 | - espresso_load_required( 'EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php' ); |
|
79 | + espresso_load_required('EE_Deprecated', EE_CORE.'EE_Deprecated.core.php'); |
|
80 | 80 | // load interfaces |
81 | - espresso_load_required( 'EEI_Payment_Method_Interfaces', EE_LIBRARIES . 'payment_methods' . DS . 'EEI_Payment_Method_Interfaces.php' ); |
|
81 | + espresso_load_required('EEI_Payment_Method_Interfaces', EE_LIBRARIES.'payment_methods'.DS.'EEI_Payment_Method_Interfaces.php'); |
|
82 | 82 | // PSR4 Autoloaders |
83 | - $this->registry->load_core( 'EE_Psr4AutoloaderInit' ); |
|
83 | + $this->registry->load_core('EE_Psr4AutoloaderInit'); |
|
84 | 84 | // WP cron jobs |
85 | - $this->registry->load_core( 'Cron_Tasks' ); |
|
86 | - $this->registry->load_core( 'EE_Request_Handler' ); |
|
87 | - $this->registry->load_core( 'EE_System' ); |
|
85 | + $this->registry->load_core('Cron_Tasks'); |
|
86 | + $this->registry->load_core('EE_Request_Handler'); |
|
87 | + $this->registry->load_core('EE_System'); |
|
88 | 88 | |
89 | 89 | return $this->response; |
90 | 90 | } |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | * @throws \EE_Error |
115 | 115 | */ |
116 | 116 | public function dependency_map() { |
117 | - if ( ! $this->dependency_map instanceof EE_Dependency_Map ) { |
|
117 | + if ( ! $this->dependency_map instanceof EE_Dependency_Map) { |
|
118 | 118 | throw new EE_Error( |
119 | 119 | sprintf( |
120 | - __( 'Invalid EE_Dependency_Map: "%1$s"', 'event_espresso' ), |
|
121 | - print_r( $this->dependency_map, true ) |
|
120 | + __('Invalid EE_Dependency_Map: "%1$s"', 'event_espresso'), |
|
121 | + print_r($this->dependency_map, true) |
|
122 | 122 | ) |
123 | 123 | ); |
124 | 124 | } |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | * @throws \EE_Error |
133 | 133 | */ |
134 | 134 | public function registry() { |
135 | - if ( ! $this->registry instanceof EE_Registry ) { |
|
135 | + if ( ! $this->registry instanceof EE_Registry) { |
|
136 | 136 | throw new EE_Error( |
137 | 137 | sprintf( |
138 | - __( 'Invalid EE_Registry: "%1$s"', 'event_espresso' ), |
|
139 | - print_r( $this->registry, true ) |
|
138 | + __('Invalid EE_Registry: "%1$s"', 'event_espresso'), |
|
139 | + print_r($this->registry, true) |
|
140 | 140 | ) |
141 | 141 | ); |
142 | 142 | } |
@@ -152,15 +152,15 @@ discard block |
||
152 | 152 | * @return EE_Dependency_Map |
153 | 153 | */ |
154 | 154 | private function _load_dependency_map() { |
155 | - if ( ! is_readable( EE_CORE . 'EE_Dependency_Map.core.php' ) ) { |
|
155 | + if ( ! is_readable(EE_CORE.'EE_Dependency_Map.core.php')) { |
|
156 | 156 | EE_Error::add_error( |
157 | - __( 'The EE_Dependency_Map core class could not be loaded.', 'event_espresso' ), |
|
157 | + __('The EE_Dependency_Map core class could not be loaded.', 'event_espresso'), |
|
158 | 158 | __FILE__, __FUNCTION__, __LINE__ |
159 | 159 | ); |
160 | - wp_die( EE_Error::get_notices() ); |
|
160 | + wp_die(EE_Error::get_notices()); |
|
161 | 161 | } |
162 | - require_once( EE_CORE . 'EE_Dependency_Map.core.php' ); |
|
163 | - return EE_Dependency_Map::instance( $this->request, $this->response ); |
|
162 | + require_once(EE_CORE.'EE_Dependency_Map.core.php'); |
|
163 | + return EE_Dependency_Map::instance($this->request, $this->response); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | |
@@ -172,15 +172,15 @@ discard block |
||
172 | 172 | * @return EE_Registry |
173 | 173 | */ |
174 | 174 | private function _load_registry() { |
175 | - if ( ! is_readable( EE_CORE . 'EE_Registry.core.php' )) { |
|
175 | + if ( ! is_readable(EE_CORE.'EE_Registry.core.php')) { |
|
176 | 176 | EE_Error::add_error( |
177 | - __( 'The EE_Registry core class could not be loaded.', 'event_espresso' ), |
|
177 | + __('The EE_Registry core class could not be loaded.', 'event_espresso'), |
|
178 | 178 | __FILE__, __FUNCTION__, __LINE__ |
179 | 179 | ); |
180 | - wp_die( EE_Error::get_notices() ); |
|
180 | + wp_die(EE_Error::get_notices()); |
|
181 | 181 | } |
182 | - require_once( EE_CORE . 'EE_Registry.core.php' ); |
|
183 | - return EE_Registry::instance( $this->dependency_map ); |
|
182 | + require_once(EE_CORE.'EE_Registry.core.php'); |
|
183 | + return EE_Registry::instance($this->dependency_map); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | |
@@ -191,13 +191,13 @@ discard block |
||
191 | 191 | * @return void |
192 | 192 | */ |
193 | 193 | private function _load_class_tools() { |
194 | - if ( ! is_readable( EE_HELPERS . 'EEH_Class_Tools.helper.php' )) { |
|
194 | + if ( ! is_readable(EE_HELPERS.'EEH_Class_Tools.helper.php')) { |
|
195 | 195 | EE_Error::add_error( |
196 | - __( 'The EEH_Class_Tools helper could not be loaded.', 'event_espresso' ), |
|
196 | + __('The EEH_Class_Tools helper could not be loaded.', 'event_espresso'), |
|
197 | 197 | __FILE__, __FUNCTION__, __LINE__ |
198 | 198 | ); |
199 | 199 | } |
200 | - require_once( EE_HELPERS . 'EEH_Class_Tools.helper.php' ); |
|
200 | + require_once(EE_HELPERS.'EEH_Class_Tools.helper.php'); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | |
@@ -211,13 +211,13 @@ discard block |
||
211 | 211 | * @param \EE_Request $request |
212 | 212 | * @param \EE_Response $response |
213 | 213 | */ |
214 | - public function handle_response( EE_Request $request, EE_Response $response ) { |
|
214 | + public function handle_response(EE_Request $request, EE_Response $response) { |
|
215 | 215 | //\EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__, 2 ); |
216 | 216 | //EEH_Debug_Tools::printr( $request, '$request', __FILE__, __LINE__ ); |
217 | 217 | //EEH_Debug_Tools::printr( $response, '$response', __FILE__, __LINE__ ); |
218 | 218 | //die(); |
219 | - if ( $response->plugin_deactivated() ) { |
|
220 | - espresso_deactivate_plugin( EE_PLUGIN_BASENAME ); |
|
219 | + if ($response->plugin_deactivated()) { |
|
220 | + espresso_deactivate_plugin(EE_PLUGIN_BASENAME); |
|
221 | 221 | } |
222 | 222 | } |
223 | 223 |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | /** |
263 | 263 | * Sets sensitive_data_removal_strategy |
264 | 264 | * @param EE_Sensitive_Data_Removal_Base $sensitive_data_removal_strategy |
265 | - * @return boolean |
|
265 | + * @return boolean|null |
|
266 | 266 | */ |
267 | 267 | public function set_sensitive_data_removal_strategy($sensitive_data_removal_strategy) { |
268 | 268 | $this->_sensitive_data_removal_strategy = $sensitive_data_removal_strategy; |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | /** |
357 | 357 | * returns true if input employs any of the validation strategy defined by the supplied array of classnames |
358 | 358 | * |
359 | - * @param array $validation_strategy_classnames |
|
359 | + * @param string[] $validation_strategy_classnames |
|
360 | 360 | * @return bool |
361 | 361 | */ |
362 | 362 | public function has_validation_strategy( $validation_strategy_classnames ) { |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | * Returns whether or not any validation errors occurred |
480 | 480 | * |
481 | 481 | * @param array $req_data like $_POST |
482 | - * @return boolean whether or not there was an error |
|
482 | + * @return boolean|null whether or not there was an error |
|
483 | 483 | */ |
484 | 484 | protected function _normalize( $req_data ) { |
485 | 485 | //any existing validation errors don't apply so clear them |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | if( ! $this->_html_name){ |
196 | 196 | if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper){ |
197 | 197 | $this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]"; |
198 | - }else{ |
|
198 | + } else{ |
|
199 | 199 | $this->_html_name = $this->name(); |
200 | 200 | } |
201 | 201 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | protected function _get_display_strategy(){ |
227 | 227 | if( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base){ |
228 | 228 | throw new EE_Error(sprintf(__("Cannot get display strategy for form input with name %s and id %s, because it has not been set in the constructor", "event_espresso"),$this->html_name(),$this->html_id())); |
229 | - }else{ |
|
229 | + } else{ |
|
230 | 230 | return $this->_display_strategy; |
231 | 231 | } |
232 | 232 | } |
@@ -439,14 +439,14 @@ discard block |
||
439 | 439 | if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
440 | 440 | try{ |
441 | 441 | $validation_strategy->validate($this->normalized_value()); |
442 | - }catch(EE_Validation_Error $e){ |
|
442 | + } catch(EE_Validation_Error $e){ |
|
443 | 443 | $this->add_validation_error($e); |
444 | 444 | } |
445 | 445 | } |
446 | 446 | } |
447 | 447 | if( $this->get_validation_errors()){ |
448 | 448 | return false; |
449 | - }else{ |
|
449 | + } else{ |
|
450 | 450 | return true; |
451 | 451 | } |
452 | 452 | } |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | |
632 | 632 | if(! empty($jquery_validation_rules)){ |
633 | 633 | $jquery_validation_js[ $this->html_id( TRUE ) ] = $jquery_validation_rules; |
634 | - }else{ |
|
634 | + } else{ |
|
635 | 635 | return array(); |
636 | 636 | } |
637 | 637 | return $jquery_validation_js; |
@@ -798,7 +798,7 @@ discard block |
||
798 | 798 | if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){ |
799 | 799 | $name_parts = $matches[ 1 ]; |
800 | 800 | array_unshift($name_parts, $before_any_brackets); |
801 | - }else{ |
|
801 | + } else{ |
|
802 | 802 | $name_parts = array( $before_any_brackets ); |
803 | 803 | } |
804 | 804 | // now get the value for the input |
@@ -825,10 +825,10 @@ discard block |
||
825 | 825 | if( isset( $req_data[ $first_part_to_consider ] ) ){ |
826 | 826 | if( empty($html_name_parts ) ){ |
827 | 827 | return $req_data[ $first_part_to_consider ]; |
828 | - }else{ |
|
828 | + } else{ |
|
829 | 829 | return $this->_find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data[ $first_part_to_consider ] ); |
830 | 830 | } |
831 | - }else{ |
|
831 | + } else{ |
|
832 | 832 | return NULL; |
833 | 833 | } |
834 | 834 | } |
@@ -847,7 +847,7 @@ discard block |
||
847 | 847 | $checked_value = $this->find_form_data_for_this_section( $req_data ); |
848 | 848 | if( $checked_value !== null ){ |
849 | 849 | return TRUE; |
850 | - }else{ |
|
850 | + } else{ |
|
851 | 851 | return FALSE; |
852 | 852 | } |
853 | 853 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage |
9 | 9 | * @author Mike Nelson |
10 | 10 | */ |
11 | -abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable{ |
|
11 | +abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * the input's name attribute |
@@ -141,61 +141,61 @@ discard block |
||
141 | 141 | * @type EE_Validation_Strategy_Base[] $validation_strategies |
142 | 142 | * } |
143 | 143 | */ |
144 | - public function __construct( $input_args = array() ){ |
|
145 | - $input_args = apply_filters( 'FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this ); |
|
144 | + public function __construct($input_args = array()) { |
|
145 | + $input_args = apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this); |
|
146 | 146 | // the following properties must be cast as arrays |
147 | - if ( isset( $input_args['validation_strategies'] ) ) { |
|
148 | - foreach ( $input_args['validation_strategies'] as $validation_strategy ) { |
|
149 | - if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
|
150 | - $this->_validation_strategies[ get_class( $validation_strategy ) ] = $validation_strategy; |
|
147 | + if (isset($input_args['validation_strategies'])) { |
|
148 | + foreach ($input_args['validation_strategies'] as $validation_strategy) { |
|
149 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
150 | + $this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy; |
|
151 | 151 | } |
152 | 152 | } |
153 | - unset( $input_args['validation_strategies'] ); |
|
153 | + unset($input_args['validation_strategies']); |
|
154 | 154 | } |
155 | 155 | // loop thru incoming options |
156 | - foreach( $input_args as $key => $value ) { |
|
156 | + foreach ($input_args as $key => $value) { |
|
157 | 157 | // add underscore to $key to match property names |
158 | - $_key = '_' . $key; |
|
159 | - if ( property_exists( $this, $_key )) { |
|
158 | + $_key = '_'.$key; |
|
159 | + if (property_exists($this, $_key)) { |
|
160 | 160 | $this->{$_key} = $value; |
161 | 161 | } |
162 | 162 | } |
163 | 163 | // ensure that "required" is set correctly |
164 | - $this->set_required( $this->_required, isset( $input_args[ 'required_validation_error_message' ] ) ? $input_args[ 'required_validation_error_message' ] : NULL ); |
|
164 | + $this->set_required($this->_required, isset($input_args['required_validation_error_message']) ? $input_args['required_validation_error_message'] : NULL); |
|
165 | 165 | |
166 | 166 | //$this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE; |
167 | 167 | |
168 | 168 | $this->_display_strategy->_construct_finalize($this); |
169 | - foreach( $this->_validation_strategies as $validation_strategy ){ |
|
169 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
170 | 170 | $validation_strategy->_construct_finalize($this); |
171 | 171 | } |
172 | 172 | |
173 | - if( ! $this->_normalization_strategy){ |
|
173 | + if ( ! $this->_normalization_strategy) { |
|
174 | 174 | $this->_normalization_strategy = new EE_Text_Normalization(); |
175 | 175 | } |
176 | 176 | $this->_normalization_strategy->_construct_finalize($this); |
177 | 177 | |
178 | 178 | //at least we can use the normalization strategy to populate the default |
179 | - if( isset( $input_args[ 'default' ] ) ) { |
|
180 | - $this->set_default( $input_args[ 'default' ] ); |
|
179 | + if (isset($input_args['default'])) { |
|
180 | + $this->set_default($input_args['default']); |
|
181 | 181 | } |
182 | 182 | |
183 | - if( ! $this->_sensitive_data_removal_strategy){ |
|
183 | + if ( ! $this->_sensitive_data_removal_strategy) { |
|
184 | 184 | $this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal(); |
185 | 185 | } |
186 | 186 | $this->_sensitive_data_removal_strategy->_construct_finalize($this); |
187 | - parent::__construct( $input_args ); |
|
187 | + parent::__construct($input_args); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
191 | 191 | * Sets the html_name to its default value, if none was specified in teh constructor. |
192 | 192 | * Calculation involves using the name and the parent's html_name |
193 | 193 | */ |
194 | - protected function _set_default_html_name_if_empty(){ |
|
195 | - if( ! $this->_html_name){ |
|
196 | - if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper){ |
|
197 | - $this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]"; |
|
198 | - }else{ |
|
194 | + protected function _set_default_html_name_if_empty() { |
|
195 | + if ( ! $this->_html_name) { |
|
196 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
197 | + $this->_html_name = $this->_parent_section->html_name_prefix()."[{$this->name()}]"; |
|
198 | + } else { |
|
199 | 199 | $this->_html_name = $this->name(); |
200 | 200 | } |
201 | 201 | } |
@@ -210,12 +210,12 @@ discard block |
||
210 | 210 | function _construct_finalize($parent_form_section, $name) { |
211 | 211 | parent::_construct_finalize($parent_form_section, $name); |
212 | 212 | $this->_set_default_html_name_if_empty(); |
213 | - if( ! $this->_html_label ){ |
|
214 | - if( ! $this->_html_label_text){ |
|
215 | - $this->_html_label_text = ucwords( str_replace("_"," ",$name)); |
|
213 | + if ( ! $this->_html_label) { |
|
214 | + if ( ! $this->_html_label_text) { |
|
215 | + $this->_html_label_text = ucwords(str_replace("_", " ", $name)); |
|
216 | 216 | } |
217 | 217 | } |
218 | - do_action( 'AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name ); |
|
218 | + do_action('AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
@@ -223,10 +223,10 @@ discard block |
||
223 | 223 | * @return EE_Display_Strategy_Base |
224 | 224 | * @throws EE_Error |
225 | 225 | */ |
226 | - protected function _get_display_strategy(){ |
|
227 | - if( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base){ |
|
228 | - throw new EE_Error(sprintf(__("Cannot get display strategy for form input with name %s and id %s, because it has not been set in the constructor", "event_espresso"),$this->html_name(),$this->html_id())); |
|
229 | - }else{ |
|
226 | + protected function _get_display_strategy() { |
|
227 | + if ( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) { |
|
228 | + throw new EE_Error(sprintf(__("Cannot get display strategy for form input with name %s and id %s, because it has not been set in the constructor", "event_espresso"), $this->html_name(), $this->html_id())); |
|
229 | + } else { |
|
230 | 230 | return $this->_display_strategy; |
231 | 231 | } |
232 | 232 | } |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * Sets the display strategy. |
235 | 235 | * @param EE_Display_Strategy_Base $strategy |
236 | 236 | */ |
237 | - protected function _set_display_strategy(EE_Display_Strategy_Base $strategy){ |
|
237 | + protected function _set_display_strategy(EE_Display_Strategy_Base $strategy) { |
|
238 | 238 | $this->_display_strategy = $strategy; |
239 | 239 | } |
240 | 240 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * Sets the sanitization strategy |
243 | 243 | * @param EE_Normalization_Strategy_Base $strategy |
244 | 244 | */ |
245 | - protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy){ |
|
245 | + protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy) { |
|
246 | 246 | $this->_normalization_strategy = $strategy; |
247 | 247 | } |
248 | 248 | |
@@ -268,14 +268,14 @@ discard block |
||
268 | 268 | * Gets the display strategy for this input |
269 | 269 | * @return EE_Display_Strategy_Base |
270 | 270 | */ |
271 | - public function get_display_strategy(){ |
|
271 | + public function get_display_strategy() { |
|
272 | 272 | return $this->_display_strategy; |
273 | 273 | } |
274 | 274 | /** |
275 | 275 | * Overwrites the display strategy |
276 | 276 | * @param EE_Display_Strategy_Base $display_strategy |
277 | 277 | */ |
278 | - public function set_display_strategy($display_strategy){ |
|
278 | + public function set_display_strategy($display_strategy) { |
|
279 | 279 | $this->_display_strategy = $display_strategy; |
280 | 280 | $this->_display_strategy->_construct_finalize($this); |
281 | 281 | } |
@@ -283,14 +283,14 @@ discard block |
||
283 | 283 | * Gets the normalization strategy set on this input |
284 | 284 | * @return EE_Normalization_Strategy_Base |
285 | 285 | */ |
286 | - public function get_normalization_strategy(){ |
|
286 | + public function get_normalization_strategy() { |
|
287 | 287 | return $this->_normalization_strategy; |
288 | 288 | } |
289 | 289 | /** |
290 | 290 | * Overwrites the normalization strategy |
291 | 291 | * @param EE_Normalization_Strategy_Base $normalization_strategy |
292 | 292 | */ |
293 | - public function set_normalization_strategy($normalization_strategy){ |
|
293 | + public function set_normalization_strategy($normalization_strategy) { |
|
294 | 294 | $this->_normalization_strategy = $normalization_strategy; |
295 | 295 | $this->_normalization_strategy->_construct_finalize($this); |
296 | 296 | } |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * Returns all teh validation strategies which apply to this field, numerically indexed |
300 | 300 | * @return EE_Validation_Strategy_Base[] |
301 | 301 | */ |
302 | - public function get_validation_strategies(){ |
|
302 | + public function get_validation_strategies() { |
|
303 | 303 | return $this->_validation_strategies; |
304 | 304 | } |
305 | 305 | |
@@ -310,8 +310,8 @@ discard block |
||
310 | 310 | * @param EE_Validation_Strategy_Base $validation_strategy |
311 | 311 | * @return void |
312 | 312 | */ |
313 | - protected function _add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ){ |
|
314 | - $validation_strategy->_construct_finalize( $this ); |
|
313 | + protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) { |
|
314 | + $validation_strategy->_construct_finalize($this); |
|
315 | 315 | $this->_validation_strategies[] = $validation_strategy; |
316 | 316 | } |
317 | 317 | |
@@ -322,8 +322,8 @@ discard block |
||
322 | 322 | * @param EE_Validation_Strategy_Base $validation_strategy |
323 | 323 | * @return void |
324 | 324 | */ |
325 | - public function add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ) { |
|
326 | - $this->_add_validation_strategy( $validation_strategy ); |
|
325 | + public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) { |
|
326 | + $this->_add_validation_strategy($validation_strategy); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | |
@@ -333,13 +333,13 @@ discard block |
||
333 | 333 | * |
334 | 334 | * @param string $validation_strategy_classname |
335 | 335 | */ |
336 | - public function remove_validation_strategy( $validation_strategy_classname ) { |
|
337 | - foreach( $this->_validation_strategies as $key => $validation_strategy ){ |
|
338 | - if( |
|
336 | + public function remove_validation_strategy($validation_strategy_classname) { |
|
337 | + foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
338 | + if ( |
|
339 | 339 | $validation_strategy instanceof $validation_strategy_classname |
340 | - || is_subclass_of( $validation_strategy, $validation_strategy_classname ) |
|
340 | + || is_subclass_of($validation_strategy, $validation_strategy_classname) |
|
341 | 341 | ) { |
342 | - unset( $this->_validation_strategies[ $key ] ); |
|
342 | + unset($this->_validation_strategies[$key]); |
|
343 | 343 | } |
344 | 344 | } |
345 | 345 | } |
@@ -352,12 +352,12 @@ discard block |
||
352 | 352 | * @param array $validation_strategy_classnames |
353 | 353 | * @return bool |
354 | 354 | */ |
355 | - public function has_validation_strategy( $validation_strategy_classnames ) { |
|
356 | - $validation_strategy_classnames = is_array( $validation_strategy_classnames ) |
|
355 | + public function has_validation_strategy($validation_strategy_classnames) { |
|
356 | + $validation_strategy_classnames = is_array($validation_strategy_classnames) |
|
357 | 357 | ? $validation_strategy_classnames |
358 | - : array( $validation_strategy_classnames ); |
|
359 | - foreach( $this->_validation_strategies as $key => $validation_strategy ){ |
|
360 | - if( in_array( $key, $validation_strategy_classnames ) ) { |
|
358 | + : array($validation_strategy_classnames); |
|
359 | + foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
360 | + if (in_array($key, $validation_strategy_classnames)) { |
|
361 | 361 | return true; |
362 | 362 | } |
363 | 363 | } |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | * to the parent form's layout strategy |
372 | 372 | * @return string |
373 | 373 | */ |
374 | - public function get_html_and_js(){ |
|
374 | + public function get_html_and_js() { |
|
375 | 375 | return $this->_parent_section->get_html_for_input($this); |
376 | 376 | } |
377 | 377 | |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * Makes sure the JS and CSS are enqueued for it |
384 | 384 | * @return string |
385 | 385 | */ |
386 | - public function get_html_for_input(){ |
|
386 | + public function get_html_for_input() { |
|
387 | 387 | return $this->_get_display_strategy()->display(); |
388 | 388 | } |
389 | 389 | |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | * @return string |
394 | 394 | */ |
395 | 395 | public function html_other_attributes() { |
396 | - return ! empty( $this->_html_other_attributes ) ? ' ' . $this->_html_other_attributes : ''; |
|
396 | + return ! empty($this->_html_other_attributes) ? ' '.$this->_html_other_attributes : ''; |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | /** |
402 | 402 | * @param string $html_other_attributes |
403 | 403 | */ |
404 | - public function set_html_other_attributes( $html_other_attributes ) { |
|
404 | + public function set_html_other_attributes($html_other_attributes) { |
|
405 | 405 | $this->_html_other_attributes = $html_other_attributes; |
406 | 406 | } |
407 | 407 | |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | * according to the form section's layout strategy |
411 | 411 | * @return string |
412 | 412 | */ |
413 | - public function get_html_for_label(){ |
|
413 | + public function get_html_for_label() { |
|
414 | 414 | return $this->_parent_section->get_layout_strategy()->display_label($this); |
415 | 415 | } |
416 | 416 | /** |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * according to the form section's layout strategy |
419 | 419 | * @return string |
420 | 420 | */ |
421 | - public function get_html_for_errors(){ |
|
421 | + public function get_html_for_errors() { |
|
422 | 422 | return $this->_parent_section->get_layout_strategy()->display_errors($this); |
423 | 423 | } |
424 | 424 | /** |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | * according to the form section's layout strategy |
427 | 427 | * @return string |
428 | 428 | */ |
429 | - public function get_html_for_help(){ |
|
429 | + public function get_html_for_help() { |
|
430 | 430 | return $this->_parent_section->get_layout_strategy()->display_help_text($this); |
431 | 431 | } |
432 | 432 | /** |
@@ -435,18 +435,18 @@ discard block |
||
435 | 435 | * @return boolean |
436 | 436 | */ |
437 | 437 | protected function _validate() { |
438 | - foreach($this->_validation_strategies as $validation_strategy){ |
|
439 | - if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
|
440 | - try{ |
|
438 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
439 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
440 | + try { |
|
441 | 441 | $validation_strategy->validate($this->normalized_value()); |
442 | - }catch(EE_Validation_Error $e){ |
|
442 | + } catch (EE_Validation_Error $e) { |
|
443 | 443 | $this->add_validation_error($e); |
444 | 444 | } |
445 | 445 | } |
446 | 446 | } |
447 | - if( $this->get_validation_errors()){ |
|
447 | + if ($this->get_validation_errors()) { |
|
448 | 448 | return false; |
449 | - }else{ |
|
449 | + } else { |
|
450 | 450 | return true; |
451 | 451 | } |
452 | 452 | } |
@@ -459,8 +459,8 @@ discard block |
||
459 | 459 | * @param string $value |
460 | 460 | * @return null|string |
461 | 461 | */ |
462 | - private function _sanitize($value){ |
|
463 | - return $value !== NULL ?stripslashes(html_entity_decode($value)) : NULL;//don't sanitize_text_field |
|
462 | + private function _sanitize($value) { |
|
463 | + return $value !== NULL ? stripslashes(html_entity_decode($value)) : NULL; //don't sanitize_text_field |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | |
@@ -472,24 +472,24 @@ discard block |
||
472 | 472 | * @param array $req_data like $_POST |
473 | 473 | * @return boolean whether or not there was an error |
474 | 474 | */ |
475 | - protected function _normalize( $req_data ) { |
|
475 | + protected function _normalize($req_data) { |
|
476 | 476 | //any existing validation errors don't apply so clear them |
477 | 477 | $this->_validation_errors = array(); |
478 | 478 | try { |
479 | - $raw_input = $this->find_form_data_for_this_section( $req_data ); |
|
479 | + $raw_input = $this->find_form_data_for_this_section($req_data); |
|
480 | 480 | //super simple sanitization for now |
481 | - if ( is_array( $raw_input )) { |
|
481 | + if (is_array($raw_input)) { |
|
482 | 482 | $this->_raw_value = array(); |
483 | - foreach( $raw_input as $key => $value ) { |
|
484 | - $this->_raw_value[ $key ] = $this->_sanitize( $value ); |
|
483 | + foreach ($raw_input as $key => $value) { |
|
484 | + $this->_raw_value[$key] = $this->_sanitize($value); |
|
485 | 485 | } |
486 | 486 | } else { |
487 | - $this->_raw_value = $this->_sanitize( $raw_input ); |
|
487 | + $this->_raw_value = $this->_sanitize($raw_input); |
|
488 | 488 | } |
489 | 489 | //we want ot mostly leave the input alone in case we need to re-display it to the user |
490 | - $this->_normalized_value = $this->_normalization_strategy->normalize( $this->raw_value() ); |
|
491 | - } catch ( EE_Validation_Error $e ) { |
|
492 | - $this->add_validation_error( $e ); |
|
490 | + $this->_normalized_value = $this->_normalization_strategy->normalize($this->raw_value()); |
|
491 | + } catch (EE_Validation_Error $e) { |
|
492 | + $this->add_validation_error($e); |
|
493 | 493 | } |
494 | 494 | } |
495 | 495 | |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | /** |
499 | 499 | * @return string |
500 | 500 | */ |
501 | - public function html_name(){ |
|
501 | + public function html_name() { |
|
502 | 502 | return $this->_html_name; |
503 | 503 | } |
504 | 504 | |
@@ -507,8 +507,8 @@ discard block |
||
507 | 507 | /** |
508 | 508 | * @return string |
509 | 509 | */ |
510 | - function html_label_id(){ |
|
511 | - return ! empty( $this->_html_label_id ) ? $this->_html_label_id : $this->_html_id . '-lbl'; |
|
510 | + function html_label_id() { |
|
511 | + return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->_html_id.'-lbl'; |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | /** |
517 | 517 | * @return string |
518 | 518 | */ |
519 | - function html_label_class(){ |
|
519 | + function html_label_class() { |
|
520 | 520 | return $this->_html_label_class; |
521 | 521 | } |
522 | 522 | |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | /** |
526 | 526 | * @return string |
527 | 527 | */ |
528 | - function html_label_style(){ |
|
528 | + function html_label_style() { |
|
529 | 529 | return $this->_html_label_style; |
530 | 530 | } |
531 | 531 | |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | /** |
535 | 535 | * @return string |
536 | 536 | */ |
537 | - function html_label_text(){ |
|
537 | + function html_label_text() { |
|
538 | 538 | return $this->_html_label_text; |
539 | 539 | } |
540 | 540 | |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | /** |
544 | 544 | * @return string |
545 | 545 | */ |
546 | - function html_help_text(){ |
|
546 | + function html_help_text() { |
|
547 | 547 | return $this->_html_help_text; |
548 | 548 | } |
549 | 549 | |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | /** |
553 | 553 | * @return string |
554 | 554 | */ |
555 | - function html_help_class(){ |
|
555 | + function html_help_class() { |
|
556 | 556 | return $this->_html_help_class; |
557 | 557 | } |
558 | 558 | |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | /** |
562 | 562 | * @return string |
563 | 563 | */ |
564 | - function html_help_style(){ |
|
564 | + function html_help_style() { |
|
565 | 565 | return $this->_html_style; |
566 | 566 | } |
567 | 567 | /** |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | * in which case, we would have stored the malicious content to our database. |
575 | 575 | * @return string |
576 | 576 | */ |
577 | - function raw_value(){ |
|
577 | + function raw_value() { |
|
578 | 578 | return $this->_raw_value; |
579 | 579 | } |
580 | 580 | /** |
@@ -582,15 +582,15 @@ discard block |
||
582 | 582 | * it escapes all html entities |
583 | 583 | * @return string |
584 | 584 | */ |
585 | - function raw_value_in_form(){ |
|
586 | - return htmlentities($this->raw_value(),ENT_QUOTES, 'UTF-8'); |
|
585 | + function raw_value_in_form() { |
|
586 | + return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8'); |
|
587 | 587 | } |
588 | 588 | /** |
589 | 589 | * returns the value after it's been sanitized, and then converted into it's proper type |
590 | 590 | * in PHP. Eg, a string, an int, an array, |
591 | 591 | * @return mixed |
592 | 592 | */ |
593 | - function normalized_value(){ |
|
593 | + function normalized_value() { |
|
594 | 594 | return $this->_normalized_value; |
595 | 595 | } |
596 | 596 | |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | * the best thing to display |
601 | 601 | * @return string |
602 | 602 | */ |
603 | - function pretty_value(){ |
|
603 | + function pretty_value() { |
|
604 | 604 | return $this->_normalized_value; |
605 | 605 | } |
606 | 606 | /** |
@@ -619,19 +619,19 @@ discard block |
||
619 | 619 | }</code> |
620 | 620 | * @return array |
621 | 621 | */ |
622 | - function get_jquery_validation_rules(){ |
|
622 | + function get_jquery_validation_rules() { |
|
623 | 623 | |
624 | 624 | $jquery_validation_rules = array(); |
625 | - foreach($this->get_validation_strategies() as $validation_strategy){ |
|
625 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
626 | 626 | $jquery_validation_rules = array_replace_recursive( |
627 | 627 | $jquery_validation_rules, |
628 | 628 | $validation_strategy->get_jquery_validation_rule_array() |
629 | 629 | ); |
630 | 630 | } |
631 | 631 | |
632 | - if(! empty($jquery_validation_rules)){ |
|
633 | - $jquery_validation_js[ $this->html_id( TRUE ) ] = $jquery_validation_rules; |
|
634 | - }else{ |
|
632 | + if ( ! empty($jquery_validation_rules)) { |
|
633 | + $jquery_validation_js[$this->html_id(TRUE)] = $jquery_validation_rules; |
|
634 | + } else { |
|
635 | 635 | return array(); |
636 | 636 | } |
637 | 637 | return $jquery_validation_js; |
@@ -643,9 +643,9 @@ discard block |
||
643 | 643 | * @param mixed $value |
644 | 644 | * @return void |
645 | 645 | */ |
646 | - function set_default($value){ |
|
646 | + function set_default($value) { |
|
647 | 647 | $this->_normalized_value = $value; |
648 | - $this->_raw_value = $this->_normalization_strategy->unnormalize( $value ); |
|
648 | + $this->_raw_value = $this->_normalization_strategy->unnormalize($value); |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | /** |
@@ -653,7 +653,7 @@ discard block |
||
653 | 653 | * @param string $label |
654 | 654 | * @return void |
655 | 655 | */ |
656 | - function set_html_label_text($label){ |
|
656 | + function set_html_label_text($label) { |
|
657 | 657 | $this->_html_label_text = $label; |
658 | 658 | } |
659 | 659 | |
@@ -665,12 +665,12 @@ discard block |
||
665 | 665 | * @param boolean $required |
666 | 666 | * @param null $required_text |
667 | 667 | */ |
668 | - function set_required($required = true, $required_text = NULL ){ |
|
669 | - $required = filter_var( $required, FILTER_VALIDATE_BOOLEAN ); |
|
670 | - if ( $required ) { |
|
671 | - $this->_add_validation_strategy( new EE_Required_Validation_Strategy( $required_text ) ); |
|
668 | + function set_required($required = true, $required_text = NULL) { |
|
669 | + $required = filter_var($required, FILTER_VALIDATE_BOOLEAN); |
|
670 | + if ($required) { |
|
671 | + $this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text)); |
|
672 | 672 | } else { |
673 | - unset( $this->_validation_strategies[ 'EE_Required_Validation_Strategy' ] ); |
|
673 | + unset($this->_validation_strategies['EE_Required_Validation_Strategy']); |
|
674 | 674 | } |
675 | 675 | $this->_required = $required; |
676 | 676 | } |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | * Returns whether or not this field is required |
679 | 679 | * @return boolean |
680 | 680 | */ |
681 | - public function required(){ |
|
681 | + public function required() { |
|
682 | 682 | return $this->_required; |
683 | 683 | } |
684 | 684 | |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | /** |
688 | 688 | * @param string $required_css_class |
689 | 689 | */ |
690 | - public function set_required_css_class( $required_css_class ) { |
|
690 | + public function set_required_css_class($required_css_class) { |
|
691 | 691 | $this->_required_css_class = $required_css_class; |
692 | 692 | } |
693 | 693 | |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | * Sets the help text, in case |
707 | 707 | * @param string $text |
708 | 708 | */ |
709 | - public function set_html_help_text($text){ |
|
709 | + public function set_html_help_text($text) { |
|
710 | 710 | $this->_html_help_text = $text; |
711 | 711 | } |
712 | 712 | /** |
@@ -718,8 +718,8 @@ discard block |
||
718 | 718 | public function clean_sensitive_data() { |
719 | 719 | //if we do ANY kind of sensitive data removal on this, then just clear out the raw value |
720 | 720 | //if we need more logic than this we'll make a strategy for it |
721 | - if( $this->_sensitive_data_removal_strategy && |
|
722 | - ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal ){ |
|
721 | + if ($this->_sensitive_data_removal_strategy && |
|
722 | + ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal) { |
|
723 | 723 | $this->_raw_value = NULL; |
724 | 724 | } |
725 | 725 | //and clean the normalized value according to the appropriate strategy |
@@ -733,10 +733,10 @@ discard block |
||
733 | 733 | * @param string $button_size |
734 | 734 | * @param string $other_attributes |
735 | 735 | */ |
736 | - public function set_button_css_attributes( $primary = TRUE, $button_size = '', $other_attributes = '' ) { |
|
736 | + public function set_button_css_attributes($primary = TRUE, $button_size = '', $other_attributes = '') { |
|
737 | 737 | $button_css_attributes = 'button'; |
738 | 738 | $button_css_attributes .= $primary === TRUE ? ' button-primary' : ' button-secondary'; |
739 | - switch ( $button_size ) { |
|
739 | + switch ($button_size) { |
|
740 | 740 | case 'xs' : |
741 | 741 | case 'extra-small' : |
742 | 742 | $button_css_attributes .= ' button-xs'; |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | default : |
758 | 758 | $button_css_attributes .= ''; |
759 | 759 | } |
760 | - $this->_button_css_attributes .= ! empty( $other_attributes ) ? $button_css_attributes . ' ' . $other_attributes : $button_css_attributes; |
|
760 | + $this->_button_css_attributes .= ! empty($other_attributes) ? $button_css_attributes.' '.$other_attributes : $button_css_attributes; |
|
761 | 761 | } |
762 | 762 | |
763 | 763 | |
@@ -766,7 +766,7 @@ discard block |
||
766 | 766 | * @return string |
767 | 767 | */ |
768 | 768 | public function button_css_attributes() { |
769 | - if ( empty( $this->_button_css_attributes )) { |
|
769 | + if (empty($this->_button_css_attributes)) { |
|
770 | 770 | $this->set_button_css_attributes(); |
771 | 771 | } |
772 | 772 | return $this->_button_css_attributes; |
@@ -786,27 +786,27 @@ discard block |
||
786 | 786 | * @param array $req_data |
787 | 787 | * @return mixed whatever the raw value of this form section is in the request data |
788 | 788 | */ |
789 | - public function find_form_data_for_this_section( $req_data ){ |
|
789 | + public function find_form_data_for_this_section($req_data) { |
|
790 | 790 | // break up the html name by "[]" |
791 | - if ( strpos( $this->html_name(), '[' ) !== FALSE ) { |
|
792 | - $before_any_brackets = substr( $this->html_name(), 0, strpos($this->html_name(), '[') ); |
|
791 | + if (strpos($this->html_name(), '[') !== FALSE) { |
|
792 | + $before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '[')); |
|
793 | 793 | } else { |
794 | 794 | $before_any_brackets = $this->html_name(); |
795 | 795 | } |
796 | 796 | // grab all of the segments |
797 | - preg_match_all('~\[([^]]*)\]~',$this->html_name(), $matches); |
|
798 | - if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){ |
|
799 | - $name_parts = $matches[ 1 ]; |
|
797 | + preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches); |
|
798 | + if (isset($matches[1]) && is_array($matches[1])) { |
|
799 | + $name_parts = $matches[1]; |
|
800 | 800 | array_unshift($name_parts, $before_any_brackets); |
801 | - }else{ |
|
802 | - $name_parts = array( $before_any_brackets ); |
|
801 | + } else { |
|
802 | + $name_parts = array($before_any_brackets); |
|
803 | 803 | } |
804 | 804 | // now get the value for the input |
805 | 805 | $value = $this->_find_form_data_for_this_section_using_name_parts($name_parts, $req_data); |
806 | - if( $value === NULL ){ |
|
806 | + if ($value === NULL) { |
|
807 | 807 | //check if this thing's name is at the TOP level of the request data |
808 | - if( isset( $req_data[ $this->name() ] ) ){ |
|
809 | - $value = $req_data[ $this->name() ]; |
|
808 | + if (isset($req_data[$this->name()])) { |
|
809 | + $value = $req_data[$this->name()]; |
|
810 | 810 | } |
811 | 811 | } |
812 | 812 | return $value; |
@@ -820,15 +820,15 @@ discard block |
||
820 | 820 | * @param array $req_data |
821 | 821 | * @return array | NULL |
822 | 822 | */ |
823 | - public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data){ |
|
824 | - $first_part_to_consider = array_shift( $html_name_parts ); |
|
825 | - if( isset( $req_data[ $first_part_to_consider ] ) ){ |
|
826 | - if( empty($html_name_parts ) ){ |
|
827 | - return $req_data[ $first_part_to_consider ]; |
|
828 | - }else{ |
|
829 | - return $this->_find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data[ $first_part_to_consider ] ); |
|
823 | + public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data) { |
|
824 | + $first_part_to_consider = array_shift($html_name_parts); |
|
825 | + if (isset($req_data[$first_part_to_consider])) { |
|
826 | + if (empty($html_name_parts)) { |
|
827 | + return $req_data[$first_part_to_consider]; |
|
828 | + } else { |
|
829 | + return $this->_find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data[$first_part_to_consider]); |
|
830 | 830 | } |
831 | - }else{ |
|
831 | + } else { |
|
832 | 832 | return NULL; |
833 | 833 | } |
834 | 834 | } |
@@ -840,14 +840,14 @@ discard block |
||
840 | 840 | * @param array $req_data like $_POST |
841 | 841 | * @return boolean |
842 | 842 | */ |
843 | - public function form_data_present_in($req_data = NULL){ |
|
844 | - if( $req_data === NULL ){ |
|
843 | + public function form_data_present_in($req_data = NULL) { |
|
844 | + if ($req_data === NULL) { |
|
845 | 845 | $req_data = $_POST; |
846 | 846 | } |
847 | - $checked_value = $this->find_form_data_for_this_section( $req_data ); |
|
848 | - if( $checked_value !== null ){ |
|
847 | + $checked_value = $this->find_form_data_for_this_section($req_data); |
|
848 | + if ($checked_value !== null) { |
|
849 | 849 | return TRUE; |
850 | - }else{ |
|
850 | + } else { |
|
851 | 851 | return FALSE; |
852 | 852 | } |
853 | 853 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -55,34 +55,34 @@ discard block |
||
55 | 55 | '[EVENT_NAME]' => __("This also can be used for the name of the event", 'event_espresso'), |
56 | 56 | '[EVENT_PHONE]' => __('The phone number for the event (usually an info number)', 'event_espresso'), |
57 | 57 | '[EVENT_DESCRIPTION]' => __('The description of the event', 'event_espresso'), |
58 | - '[EVENT_EXCERPT]' => __( 'This gets parsed to the value for the excerpt field in the event or blank if there is no excerpt.', 'event_espresso' ), |
|
58 | + '[EVENT_EXCERPT]' => __('This gets parsed to the value for the excerpt field in the event or blank if there is no excerpt.', 'event_espresso'), |
|
59 | 59 | '[EVENT_LINK]' => __('A link associated with the event', 'event_espresso'), |
60 | 60 | '[EVENT_URL]' => __('A link to the event set up on the host site.', 'event_espresso'), |
61 | 61 | '[VIRTUAL_URL]' => __('What was used for the "URL of Event" field in the Venue settings', 'event_espresso'), |
62 | 62 | '[VIRTUAL_PHONE]' => __('An alternate phone number for the event. Typically used as a "call-in" number', 'event_espresso'), |
63 | 63 | '[EVENT_IMAGE]' => __('This will parse to the Feature image for the event.', 'event_espresso'), |
64 | 64 | '[EVENT_TOTAL_AVAILABLE_SPACES_*]' => sprintf( |
65 | - __( 'This will parse to the total available spaces for an event. Calculating total spaces is approximate because it is dependent on the complexity of limits on your event. There are two methods of calculation (which can be indicated by the %1$smethod%2$s param on the shortcode). %1$scurrent%2$s which will do a more accurate calculation of total available spaces based on current sales, and %1$sfull%2$s which will be the maximum total available spaces that is on the event in optimal conditions. The shortcode will default to current.', 'event_espresso' ), |
|
65 | + __('This will parse to the total available spaces for an event. Calculating total spaces is approximate because it is dependent on the complexity of limits on your event. There are two methods of calculation (which can be indicated by the %1$smethod%2$s param on the shortcode). %1$scurrent%2$s which will do a more accurate calculation of total available spaces based on current sales, and %1$sfull%2$s which will be the maximum total available spaces that is on the event in optimal conditions. The shortcode will default to current.', 'event_espresso'), |
|
66 | 66 | '<code>', |
67 | 67 | '</code>' |
68 | 68 | ), |
69 | - '[EVENT_TOTAL_SPOTS_TAKEN]' => __( 'This shortcode will parse to the output the total approved registrations for this event', 'event_espresso' ), |
|
69 | + '[EVENT_TOTAL_SPOTS_TAKEN]' => __('This shortcode will parse to the output the total approved registrations for this event', 'event_espresso'), |
|
70 | 70 | '[EVENT_FACEBOOK_URL]' => __('This will return the Facebook URL for the event if you have it set via custom field in your event, otherwise it will use the Facebook URL set in "Your Organization Settings". To set the facebook url in your event, add a custom field with the key as <code>event_facebook</code> and the value as your facebook url.', 'event_espresso'), |
71 | 71 | '[EVENT_TWITTER_URL]' => __('This will return the Twitter URL for the event if you have it set via custom field in your event, otherwise it will use the Twitter URL set in "Your Organization Settings". To set the facebook url in your event, add a custom field with the key as <code>event_twitter</code> and the value as your facebook url', 'event_espresso'), |
72 | 72 | '[EVENT_META_*]' => __('This is a special dynamic shortcode. After the "*", add the exact name for your custom field, if there is a value set for that custom field within the event then it will be output in place of this shortcode.', 'event_espresso'), |
73 | - '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]' => __( 'This parses to the url for the registration list table filtered by registrations for this event.', 'event_espresso' ), |
|
73 | + '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]' => __('This parses to the url for the registration list table filtered by registrations for this event.', 'event_espresso'), |
|
74 | 74 | ); |
75 | 75 | } |
76 | 76 | |
77 | 77 | |
78 | - protected function _parser( $shortcode ) { |
|
78 | + protected function _parser($shortcode) { |
|
79 | 79 | |
80 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
80 | + EE_Registry::instance()->load_helper('Formatter'); |
|
81 | 81 | |
82 | 82 | $this->_event = $this->_data instanceof EE_Event ? $this->_data : null; |
83 | 83 | |
84 | 84 | //if no event, then let's see if there is a reg_obj. If there IS, then we'll try and grab the event from the reg_obj instead. |
85 | - if ( empty( $this->_event ) ) { |
|
85 | + if (empty($this->_event)) { |
|
86 | 86 | $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : NULL; |
87 | 87 | $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee; |
88 | 88 | |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | |
92 | 92 | |
93 | 93 | //If there is no event objecdt by now then get out. |
94 | - if ( ! $this->_event instanceof EE_Event ) |
|
94 | + if ( ! $this->_event instanceof EE_Event) |
|
95 | 95 | return ''; |
96 | 96 | |
97 | - switch ( $shortcode ) { |
|
97 | + switch ($shortcode) { |
|
98 | 98 | |
99 | 99 | case '[EVENT_ID]' : |
100 | 100 | return $this->_event->ID(); |
@@ -127,71 +127,71 @@ discard block |
||
127 | 127 | |
128 | 128 | case '[VIRTUAL_URL]' : |
129 | 129 | $venue = $this->_event->get_first_related('Venue'); |
130 | - if ( empty( $venue ) ) |
|
130 | + if (empty($venue)) |
|
131 | 131 | return ''; |
132 | 132 | return $venue->get('VNU_virtual_url'); |
133 | 133 | |
134 | 134 | case '[VIRTUAL_PHONE]' : |
135 | 135 | $venue = $this->_event->get_first_related('Venue'); |
136 | - if ( empty( $venue ) ) |
|
136 | + if (empty($venue)) |
|
137 | 137 | return ''; |
138 | 138 | return $venue->get('VNU_virtual_phone'); |
139 | 139 | break; |
140 | 140 | |
141 | 141 | case '[EVENT_IMAGE]' : |
142 | - $image = $this->_event->feature_image_url(array(600,300) ); |
|
142 | + $image = $this->_event->feature_image_url(array(600, 300)); |
|
143 | 143 | // @todo: eventually we should make this an attribute shortcode so that em can send along what size they want returned. |
144 | - return !empty( $image ) ? '<img src="' . $image . '" alt="' . sprintf( esc_attr__( '%s Feature Image', 'event_espresso'), $this->_event->get('EVT_name') ) . '" />' : ''; |
|
144 | + return ! empty($image) ? '<img src="'.$image.'" alt="'.sprintf(esc_attr__('%s Feature Image', 'event_espresso'), $this->_event->get('EVT_name')).'" />' : ''; |
|
145 | 145 | break; |
146 | 146 | |
147 | 147 | case '[EVENT_FACEBOOK_URL]' : |
148 | - $facebook_url = $this->_event->get_post_meta('event_facebook', true ); |
|
149 | - return empty( $facebook_url ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' ) : $facebook_url; |
|
148 | + $facebook_url = $this->_event->get_post_meta('event_facebook', true); |
|
149 | + return empty($facebook_url) ? EE_Registry::instance()->CFG->organization->get_pretty('facebook') : $facebook_url; |
|
150 | 150 | break; |
151 | 151 | |
152 | 152 | case '[EVENT_TWITTER_URL]' : |
153 | 153 | $twitter_url = $this->_event->get_post_meta('event_twitter', true); |
154 | - return empty( $twitter_url ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' ) : $twitter_url; |
|
154 | + return empty($twitter_url) ? EE_Registry::instance()->CFG->organization->get_pretty('twitter') : $twitter_url; |
|
155 | 155 | break; |
156 | 156 | |
157 | 157 | case '[EVENT_AUTHOR_EMAIL]' : |
158 | 158 | $author_id = $this->_event->get('EVT_wp_user'); |
159 | - $user_data = get_userdata( (int) $author_id ); |
|
159 | + $user_data = get_userdata((int) $author_id); |
|
160 | 160 | return $user_data->user_email; |
161 | 161 | break; |
162 | 162 | |
163 | 163 | case '[EVENT_TOTAL_SPOTS_TAKEN]' : |
164 | - return EEM_Registration::instance()->count( array( array( 'EVT_ID' => $this->_event->ID(), 'STS_ID' => EEM_Registration::status_id_approved ) ), 'REG_ID', true ); |
|
164 | + return EEM_Registration::instance()->count(array(array('EVT_ID' => $this->_event->ID(), 'STS_ID' => EEM_Registration::status_id_approved)), 'REG_ID', true); |
|
165 | 165 | break; |
166 | 166 | |
167 | 167 | case '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]' : |
168 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
168 | + EE_Registry::instance()->load_helper('URL'); |
|
169 | 169 | return EEH_URL::add_query_args_and_nonce( |
170 | 170 | array( |
171 | 171 | 'event_id' => $this->_event->ID(), |
172 | 172 | 'page' => 'espresso_registrations', |
173 | 173 | 'action' => 'default' |
174 | 174 | ), |
175 | - admin_url( 'admin.php' ), |
|
175 | + admin_url('admin.php'), |
|
176 | 176 | true |
177 | 177 | ); |
178 | 178 | break; |
179 | 179 | } |
180 | 180 | |
181 | - if ( strpos( $shortcode, '[EVENT_META_*' ) !== false ) { |
|
182 | - $shortcode = str_replace( '[EVENT_META_*', '', $shortcode ); |
|
183 | - $shortcode = trim( str_replace( ']', '', $shortcode ) ); |
|
181 | + if (strpos($shortcode, '[EVENT_META_*') !== false) { |
|
182 | + $shortcode = str_replace('[EVENT_META_*', '', $shortcode); |
|
183 | + $shortcode = trim(str_replace(']', '', $shortcode)); |
|
184 | 184 | |
185 | 185 | //pull the meta value from the event post |
186 | - $event_meta = $this->_event->get_post_meta( $shortcode, true ); |
|
186 | + $event_meta = $this->_event->get_post_meta($shortcode, true); |
|
187 | 187 | |
188 | - return !empty( $event_meta ) ? $this->_event->get_post_meta( $shortcode, true ) : ''; |
|
188 | + return ! empty($event_meta) ? $this->_event->get_post_meta($shortcode, true) : ''; |
|
189 | 189 | |
190 | 190 | } |
191 | 191 | |
192 | - if ( strpos( $shortcode, '[EVENT_TOTAL_AVAILABLE_SPACES_*' ) !== false ) { |
|
193 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
194 | - $method = empty( $attrs['method'] ) ? 'current' : $attrs['method']; |
|
192 | + if (strpos($shortcode, '[EVENT_TOTAL_AVAILABLE_SPACES_*') !== false) { |
|
193 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
194 | + $method = empty($attrs['method']) ? 'current' : $attrs['method']; |
|
195 | 195 | $method = $method === 'current'; |
196 | 196 | $available = $this->_event->total_available_spaces($method); |
197 | 197 | return $available === EE_INF ? '∞' : $available; |
@@ -207,10 +207,10 @@ discard block |
||
207 | 207 | * @param boolean $full_link if TRUE (default) we return the html for the name of the event linked to the event. Otherwise we just return the url of the event. |
208 | 208 | * @return string |
209 | 209 | */ |
210 | - private function _get_event_link( $event, $full_link = TRUE ) { |
|
210 | + private function _get_event_link($event, $full_link = TRUE) { |
|
211 | 211 | $url = get_permalink($event->ID()); |
212 | 212 | |
213 | - return $full_link ? '<a href="' . $url . '">' . $event->get('EVT_name') . '</a>' : $url; |
|
213 | + return $full_link ? '<a href="'.$url.'">'.$event->get('EVT_name').'</a>' : $url; |
|
214 | 214 | } |
215 | 215 | |
216 | 216 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * |
9 | 9 | * This input has a default validation strategy of plaintext (which can be removed after construction) |
10 | 10 | */ |
11 | -class EE_Text_Area_Input extends EE_Form_Input_Base{ |
|
11 | +class EE_Text_Area_Input extends EE_Form_Input_Base { |
|
12 | 12 | |
13 | 13 | |
14 | 14 | protected $_rows = 2; |
@@ -18,28 +18,28 @@ discard block |
||
18 | 18 | * sets the rows property on this input |
19 | 19 | * @param int $rows |
20 | 20 | */ |
21 | - public function set_rows( $rows ) { |
|
21 | + public function set_rows($rows) { |
|
22 | 22 | $this->_rows = $rows; |
23 | 23 | } |
24 | 24 | /** |
25 | 25 | * sets the cols html property on this input |
26 | 26 | * @param int $cols |
27 | 27 | */ |
28 | - public function set_cols( $cols ) { |
|
28 | + public function set_cols($cols) { |
|
29 | 29 | $this->_cols = $cols; |
30 | 30 | } |
31 | 31 | /** |
32 | 32 | * |
33 | 33 | * @return int |
34 | 34 | */ |
35 | - public function get_rows(){ |
|
35 | + public function get_rows() { |
|
36 | 36 | return $this->_rows; |
37 | 37 | } |
38 | 38 | /** |
39 | 39 | * |
40 | 40 | * @return int |
41 | 41 | */ |
42 | - public function get_cols(){ |
|
42 | + public function get_cols() { |
|
43 | 43 | return $this->_cols; |
44 | 44 | } |
45 | 45 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | //if the input hasn't specifically mentioned a more lenient validation strategy, |
59 | 59 | //apply plaintext validation strategy |
60 | - if( ! $this->has_validation_strategy( |
|
60 | + if ( ! $this->has_validation_strategy( |
|
61 | 61 | array( |
62 | 62 | 'EE_Full_HTML_Validation_Strategy', |
63 | 63 | 'EE_Simple_HTML_Validation_Strategy' |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | ) { |
67 | 67 | //by default we use the plaintext validation. If you want something else, |
68 | 68 | //just remove it after the input is constructed :P using EE_Form_Input_Base::remove_validation_strategy() |
69 | - $this->_add_validation_strategy( new EE_Plaintext_Validation_Strategy() ); |
|
69 | + $this->_add_validation_strategy(new EE_Plaintext_Validation_Strategy()); |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | } |
@@ -8,16 +8,16 @@ discard block |
||
8 | 8 | * @since 4.6 |
9 | 9 | * |
10 | 10 | */ |
11 | -class EE_Email_Validation_Strategy extends EE_Text_Validation_Strategy{ |
|
11 | +class EE_Email_Validation_Strategy extends EE_Text_Validation_Strategy { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * @param null $validation_error_message |
15 | 15 | */ |
16 | - public function __construct( $validation_error_message = NULL ) { |
|
17 | - if( ! $validation_error_message ){ |
|
16 | + public function __construct($validation_error_message = NULL) { |
|
17 | + if ( ! $validation_error_message) { |
|
18 | 18 | $validation_error_message = __("Please enter a valid email address.", "event_espresso"); |
19 | 19 | } |
20 | - parent::__construct( $validation_error_message ); |
|
20 | + parent::__construct($validation_error_message); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | * @return bool |
30 | 30 | * @throws \EE_Validation_Error |
31 | 31 | */ |
32 | - public function validate( $normalized_value ) { |
|
33 | - if( $normalized_value && ! $this->_validate_email( $normalized_value ) ){ |
|
34 | - throw new EE_Validation_Error( $this->get_validation_error_message(), 'required'); |
|
32 | + public function validate($normalized_value) { |
|
33 | + if ($normalized_value && ! $this->_validate_email($normalized_value)) { |
|
34 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'required'); |
|
35 | 35 | } |
36 | 36 | } |
37 | 37 | |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | /** |
41 | 41 | * @return array |
42 | 42 | */ |
43 | - public function get_jquery_validation_rule_array(){ |
|
44 | - return array( 'email'=>true, 'messages' => array( 'email' => $this->get_validation_error_message() ) ); |
|
43 | + public function get_jquery_validation_rule_array() { |
|
44 | + return array('email'=>true, 'messages' => array('email' => $this->get_validation_error_message())); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | |
@@ -54,38 +54,38 @@ discard block |
||
54 | 54 | * @return bool of whether the email is valid or not |
55 | 55 | * @throws \EE_Validation_Error |
56 | 56 | */ |
57 | - private function _validate_email( $email ) { |
|
58 | - $validation_level = isset( EE_Registry::instance()->CFG->registration->email_validation_level ) |
|
57 | + private function _validate_email($email) { |
|
58 | + $validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level) |
|
59 | 59 | ? EE_Registry::instance()->CFG->registration->email_validation_level |
60 | 60 | : 'wp_default'; |
61 | - if ( ! preg_match( '/^.+\@\S+$/', $email ) ) { // \.\S+ |
|
61 | + if ( ! preg_match('/^.+\@\S+$/', $email)) { // \.\S+ |
|
62 | 62 | // email not in correct {string}@{string} format |
63 | 63 | return false; |
64 | 64 | } else { |
65 | - $atIndex = strrpos( $email, "@" ); |
|
66 | - $domain = substr( $email, $atIndex + 1 ); |
|
67 | - $local = substr( $email, 0, $atIndex ); |
|
68 | - $localLen = strlen( $local ); |
|
69 | - $domainLen = strlen( $domain ); |
|
70 | - if ( $localLen < 1 || $localLen > 64 ) { |
|
65 | + $atIndex = strrpos($email, "@"); |
|
66 | + $domain = substr($email, $atIndex + 1); |
|
67 | + $local = substr($email, 0, $atIndex); |
|
68 | + $localLen = strlen($local); |
|
69 | + $domainLen = strlen($domain); |
|
70 | + if ($localLen < 1 || $localLen > 64) { |
|
71 | 71 | // local part length exceeded |
72 | 72 | return false; |
73 | - } else if ( $domainLen < 1 || $domainLen > 255 ) { |
|
73 | + } else if ($domainLen < 1 || $domainLen > 255) { |
|
74 | 74 | // domain part length exceeded |
75 | 75 | return false; |
76 | - } else if ( $local[ 0 ] === '.' || $local[ $localLen - 1 ] === '.' ) { |
|
76 | + } else if ($local[0] === '.' || $local[$localLen - 1] === '.') { |
|
77 | 77 | // local part starts or ends with '.' |
78 | 78 | return false; |
79 | - } else if ( preg_match( '/\\.\\./', $local ) ) { |
|
79 | + } else if (preg_match('/\\.\\./', $local)) { |
|
80 | 80 | // local part has two consecutive dots |
81 | 81 | return false; |
82 | - } else if ( preg_match( '/\\.\\./', $domain ) ) { |
|
82 | + } else if (preg_match('/\\.\\./', $domain)) { |
|
83 | 83 | // domain part has two consecutive dots |
84 | 84 | return false; |
85 | - } else if ( $validation_level === 'wp_default' ) { |
|
86 | - return is_email( $email ); |
|
85 | + } else if ($validation_level === 'wp_default') { |
|
86 | + return is_email($email); |
|
87 | 87 | } else if ( |
88 | - ( $validation_level === 'i18n' || $validation_level === 'i18n_dns' ) |
|
88 | + ($validation_level === 'i18n' || $validation_level === 'i18n_dns') |
|
89 | 89 | // plz see http://stackoverflow.com/a/24817336 re: the following regex |
90 | 90 | && ! preg_match( |
91 | 91 | '/^(?!\.)((?!.*\.{2})[a-zA-Z0-9\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}\.!#$%&\'*+-\/=?^_`{|}~\-\d]+)@(?!\.)([a-zA-Z0-9\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}\-\.\d]+)((\.([a-zA-Z\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}]){2,63})+)$/u', |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | ) { |
95 | 95 | return false; |
96 | 96 | } |
97 | - if ( $validation_level === 'i18n_dns' ) { |
|
98 | - if ( ! checkdnsrr( $domain, "MX" ) ) { |
|
97 | + if ($validation_level === 'i18n_dns') { |
|
98 | + if ( ! checkdnsrr($domain, "MX")) { |
|
99 | 99 | // domain not found in MX records |
100 | 100 | throw new EE_Validation_Error( |
101 | 101 | __( |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | 'event_espresso' |
104 | 104 | ) |
105 | 105 | ); |
106 | - } else if ( ! checkdnsrr( $domain, "A" ) ) { |
|
106 | + } else if ( ! checkdnsrr($domain, "A")) { |
|
107 | 107 | // domain not found in A records |
108 | 108 | throw new EE_Validation_Error( |
109 | 109 | __( |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | *_question_model EEM_Question model instance (for queries) |
51 | 51 | * |
52 | 52 | * @var EEM_Question $_question_model; |
53 | - */ |
|
53 | + */ |
|
54 | 54 | protected $_question_model; |
55 | 55 | |
56 | 56 | /** |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | ), |
152 | 152 | 'list_table' => 'Registration_Form_Questions_Admin_List_Table', |
153 | 153 | 'metaboxes' => $this->_default_espresso_metaboxes, |
154 | - 'help_tabs' => array( |
|
154 | + 'help_tabs' => array( |
|
155 | 155 | 'registration_form_questions_overview_help_tab' => array( |
156 | 156 | 'title' => __('Questions Overview', 'event_espresso'), |
157 | 157 | 'filename' => 'registration_form_questions_overview' |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | 'filename' => 'registration_form_edit_question' |
203 | 203 | ), |
204 | 204 | ), |
205 | - 'help_tour' => array( 'Registration_Form_Edit_Question_Help_Tour'), |
|
205 | + 'help_tour' => array( 'Registration_Form_Edit_Question_Help_Tour'), |
|
206 | 206 | 'require_nonce' => FALSE |
207 | 207 | ), |
208 | 208 | ); |
@@ -1,6 +1,7 @@ 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 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -342,14 +343,9 @@ discard block |
||
342 | 343 | else if ( $fieldName === 'QST_admin_label' && ( isset( $this->_req_data['QST_admin_label'] ) && empty( $this->_req_data['QST_admin_label'] ) )) { |
343 | 344 | $QST_text = isset( $this->_req_data['QST_display_text'] ) ? $this->_req_data['QST_display_text'] : '' ; |
344 | 345 | $set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text,10)); |
345 | - } |
|
346 | - |
|
347 | - |
|
348 | - else if ( $fieldName === 'QST_admin_only' && ( !isset( $this->_req_data['QST_admin_only'] ) ) ) { |
|
346 | + } else if ( $fieldName === 'QST_admin_only' && ( !isset( $this->_req_data['QST_admin_only'] ) ) ) { |
|
349 | 347 | $set_column_values[$fieldName] = 0; |
350 | - } |
|
351 | - |
|
352 | - else if ( $fieldName === 'QST_max' ) { |
|
348 | + } else if ( $fieldName === 'QST_max' ) { |
|
353 | 349 | $qst_system = EEM_Question::instance()->get_var( |
354 | 350 | array( |
355 | 351 | array( |
@@ -402,7 +398,7 @@ discard block |
||
402 | 398 | $question=$this->_question_model->get_one_by_ID($ID); |
403 | 399 | $additional_hidden_fields=array('QST_ID'=>array('type'=>'hidden','value'=>$ID)); |
404 | 400 | $this->_set_add_edit_form_tags('update_question', $additional_hidden_fields); |
405 | - }else{ |
|
401 | + } else{ |
|
406 | 402 | $question= EE_Question::new_instance(); |
407 | 403 | $question->set_order_to_latest(); |
408 | 404 | $this->_set_add_edit_form_tags('insert_question'); |
@@ -433,7 +429,7 @@ discard block |
||
433 | 429 | $ID=$this->_question_model->insert($set_column_values); |
434 | 430 | $success = $ID ? true : false; |
435 | 431 | $action_desc = 'added'; |
436 | - }else{ |
|
432 | + } else{ |
|
437 | 433 | $ID=absint($this->_req_data['QST_ID']); |
438 | 434 | $pk=$this->_question_model->primary_key_name(); |
439 | 435 | $wheres=array($pk=>$ID); |
@@ -454,7 +450,7 @@ discard block |
||
454 | 450 | $option_req_index=$this->_get_option_req_data_index($option_ID); |
455 | 451 | if($option_req_index!==FALSE){ |
456 | 452 | $option->save($this->_req_data['question_options'][$option_req_index]); |
457 | - }else{ |
|
453 | + } else{ |
|
458 | 454 | //not found, remove it |
459 | 455 | $option->delete(); |
460 | 456 | } |
@@ -531,7 +527,7 @@ discard block |
||
531 | 527 | 'QSG_name'=>array('LIKE',"%$search_string%"), |
532 | 528 | 'QSG_desc'=>array('LIKE',"%$search_string%")) |
533 | 529 | ); |
534 | - }else{ |
|
530 | + } else{ |
|
535 | 531 | $query_params[0]=array( |
536 | 532 | 'QST_display_text'=>array('LIKE',"%$search_string%") |
537 | 533 | ); |
@@ -587,7 +583,7 @@ discard block |
||
587 | 583 | if ($count){ |
588 | 584 | $where = isset( $query_params[0] ) ? array( $query_params[0] ) : array(); |
589 | 585 | $results = $QST->count($where); |
590 | - }else{ |
|
586 | + } else{ |
|
591 | 587 | $results = $QST->get_all($query_params); |
592 | 588 | } |
593 | 589 | return $results; |
@@ -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 | /** |
@@ -68,12 +68,12 @@ discard block |
||
68 | 68 | * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
69 | 69 | * @access public |
70 | 70 | */ |
71 | - public function __construct( $routing = TRUE ) { |
|
72 | - require_once( EE_MODELS . 'EEM_Question.model.php' ); |
|
73 | - require_once( EE_MODELS . 'EEM_Question_Group.model.php' ); |
|
74 | - $this->_question_model= EEM_Question::instance(); |
|
75 | - $this->_question_group_model=EEM_Question_Group::instance(); |
|
76 | - parent::__construct( $routing ); |
|
71 | + public function __construct($routing = TRUE) { |
|
72 | + require_once(EE_MODELS.'EEM_Question.model.php'); |
|
73 | + require_once(EE_MODELS.'EEM_Question_Group.model.php'); |
|
74 | + $this->_question_model = EEM_Question::instance(); |
|
75 | + $this->_question_group_model = EEM_Question_Group::instance(); |
|
76 | + parent::__construct($routing); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | *_set_page_routes |
110 | 110 | */ |
111 | 111 | protected function _set_page_routes() { |
112 | - $qst_id = ! empty( $this->_req_data['QST_ID'] ) ? $this->_req_data['QST_ID'] : 0; |
|
112 | + $qst_id = ! empty($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0; |
|
113 | 113 | $this->_page_routes = array( |
114 | 114 | 'default' => array( |
115 | 115 | 'func' => '_questions_overview_list_table', |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | |
131 | 131 | 'update_question' => array( |
132 | 132 | 'func' => '_insert_or_update_question', |
133 | - 'args' => array('new_question' => FALSE ), |
|
133 | + 'args' => array('new_question' => FALSE), |
|
134 | 134 | 'capability' => 'ee_edit_question', |
135 | 135 | 'obj_id' => $qst_id, |
136 | 136 | 'noheader' => TRUE, |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | 'filename' => 'registration_form_questions_overview_views_bulk_actions_search' |
166 | 166 | ) |
167 | 167 | ), |
168 | - 'help_tour' => array( 'Registration_Form_Questions_Overview_Help_Tour'), |
|
168 | + 'help_tour' => array('Registration_Form_Questions_Overview_Help_Tour'), |
|
169 | 169 | 'require_nonce' => FALSE, |
170 | 170 | 'qtips' => array( |
171 | 171 | 'EE_Registration_Form_Tips' |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | 'filename' => 'registration_form_question_groups' |
185 | 185 | ), |
186 | 186 | ), |
187 | - 'help_tour' => array( 'Registration_Form_Question_Groups_Help_Tour'), |
|
187 | + 'help_tour' => array('Registration_Form_Question_Groups_Help_Tour'), |
|
188 | 188 | 'require_nonce' => FALSE |
189 | 189 | ), |
190 | 190 | |
@@ -193,16 +193,16 @@ discard block |
||
193 | 193 | 'label' => __('Edit Question', 'event_espresso'), |
194 | 194 | 'order' => 15, |
195 | 195 | 'persistent' => FALSE, |
196 | - 'url' => isset($this->_req_data['question_id']) ? add_query_arg(array('question_id' => $this->_req_data['question_id'] ), $this->_current_page_view_url ) : $this->_admin_base_url |
|
196 | + 'url' => isset($this->_req_data['question_id']) ? add_query_arg(array('question_id' => $this->_req_data['question_id']), $this->_current_page_view_url) : $this->_admin_base_url |
|
197 | 197 | ), |
198 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ), |
|
198 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
199 | 199 | 'help_tabs' => array( |
200 | 200 | 'registration_form_edit_question_group_help_tab' => array( |
201 | 201 | 'title' => __('Edit Question', 'event_espresso'), |
202 | 202 | 'filename' => 'registration_form_edit_question' |
203 | 203 | ), |
204 | 204 | ), |
205 | - 'help_tour' => array( 'Registration_Form_Edit_Question_Help_Tour'), |
|
205 | + 'help_tour' => array('Registration_Form_Edit_Question_Help_Tour'), |
|
206 | 206 | 'require_nonce' => FALSE |
207 | 207 | ), |
208 | 208 | ); |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | //none of the below group are currently used for Event Categories |
231 | 231 | protected function _add_feature_pointers() {} |
232 | 232 | public function load_scripts_styles() { |
233 | - wp_register_style( 'espresso_registration', REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
233 | + wp_register_style('espresso_registration', REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
234 | 234 | wp_enqueue_style('espresso_registration'); |
235 | 235 | } |
236 | 236 | public function admin_init() {} |
@@ -246,20 +246,20 @@ discard block |
||
246 | 246 | |
247 | 247 | public function load_scripts_styles_add_question() { |
248 | 248 | $this->load_scripts_styles_forms(); |
249 | - wp_register_script( 'espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
250 | - wp_enqueue_script( 'espresso_registration_form_single' ); |
|
249 | + wp_register_script('espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE); |
|
250 | + wp_enqueue_script('espresso_registration_form_single'); |
|
251 | 251 | } |
252 | 252 | public function load_scripts_styles_edit_question() { |
253 | 253 | $this->load_scripts_styles_forms(); |
254 | - wp_register_script( 'espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
255 | - wp_enqueue_script( 'espresso_registration_form_single' ); |
|
254 | + wp_register_script('espresso_registration_form_single', REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE); |
|
255 | + wp_enqueue_script('espresso_registration_form_single'); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | |
259 | 259 | |
260 | 260 | |
261 | 261 | public function recaptcha_info_help_tab() { |
262 | - $template = REGISTRATION_FORM_TEMPLATE_PATH . 'recaptcha_info_help_tab.template.php'; |
|
262 | + $template = REGISTRATION_FORM_TEMPLATE_PATH.'recaptcha_info_help_tab.template.php'; |
|
263 | 263 | EEH_Template::display_template($template, array()); |
264 | 264 | } |
265 | 265 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | ) |
292 | 292 | ); |
293 | 293 | |
294 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_questions', 'espresso_registration_form_trash_questions' ) ) { |
|
294 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_questions', 'espresso_registration_form_trash_questions')) { |
|
295 | 295 | $this->_views['trash'] = array( |
296 | 296 | 'slug' => 'trash', |
297 | 297 | 'label' => __('Trash', 'event_espresso'), |
@@ -309,9 +309,9 @@ discard block |
||
309 | 309 | */ |
310 | 310 | protected function _questions_groups_preview() { |
311 | 311 | $this->_admin_page_title = __('Question Groups (Preview)', 'event_espresso'); |
312 | - $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', 'event_espresso' ) . '" />'; |
|
313 | - $this->_template_args['preview_text'] = '<strong>'.__( 'Question Groups is a feature that is only available in the Caffeinated version of Event Espresso. With the Question Groups feature you are able to: create new question groups, edit existing question groups, and also create and edit new questions and add them to question groups.', 'event_espresso' ).'</strong>'; |
|
314 | - $this->display_admin_caf_preview_page( 'question_groups_tab' ); |
|
312 | + $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', 'event_espresso').'" />'; |
|
313 | + $this->_template_args['preview_text'] = '<strong>'.__('Question Groups is a feature that is only available in the Caffeinated version of Event Espresso. With the Question Groups feature you are able to: create new question groups, edit existing question groups, and also create and edit new questions and add them to question groups.', 'event_espresso').'</strong>'; |
|
314 | + $this->display_admin_caf_preview_page('question_groups_tab'); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | |
@@ -322,58 +322,58 @@ discard block |
||
322 | 322 | * @param \EEM_Base $model |
323 | 323 | * @return array where each key is the name of a model's field/db column, and each value is its value. |
324 | 324 | */ |
325 | - protected function _set_column_values_for(EEM_Base $model){ |
|
326 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
327 | - $set_column_values=array(); |
|
325 | + protected function _set_column_values_for(EEM_Base $model) { |
|
326 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
327 | + $set_column_values = array(); |
|
328 | 328 | |
329 | 329 | //some initial checks for proper values. |
330 | 330 | //if QST_admin_only, then no matter what QST_required is we disable. |
331 | - if ( !empty( $this->_req_data['QST_admin_only'] ) ) { |
|
331 | + if ( ! empty($this->_req_data['QST_admin_only'])) { |
|
332 | 332 | $this->_req_data['QST_required'] = 0; |
333 | 333 | } |
334 | - foreach($model->field_settings() as $fieldName=>$settings){ |
|
334 | + foreach ($model->field_settings() as $fieldName=>$settings) { |
|
335 | 335 | // basically if QSG_identifier is empty or not set |
336 | - if ( $fieldName === 'QSG_identifier' && ( isset( $this->_req_data['QSG_identifier'] ) && empty( $this->_req_data['QSG_identifier'] ) )) { |
|
337 | - $QSG_name = isset( $this->_req_data['QSG_name'] ) ? $this->_req_data['QSG_name'] : '' ; |
|
338 | - $set_column_values[$fieldName] = sanitize_title($QSG_name ) . '-' . uniqid( '', true ); |
|
336 | + if ($fieldName === 'QSG_identifier' && (isset($this->_req_data['QSG_identifier']) && empty($this->_req_data['QSG_identifier']))) { |
|
337 | + $QSG_name = isset($this->_req_data['QSG_name']) ? $this->_req_data['QSG_name'] : ''; |
|
338 | + $set_column_values[$fieldName] = sanitize_title($QSG_name).'-'.uniqid('', true); |
|
339 | 339 | // dd($set_column_values); |
340 | 340 | } |
341 | 341 | //if the admin label is blank, use a slug version of the question text |
342 | - else if ( $fieldName === 'QST_admin_label' && ( isset( $this->_req_data['QST_admin_label'] ) && empty( $this->_req_data['QST_admin_label'] ) )) { |
|
343 | - $QST_text = isset( $this->_req_data['QST_display_text'] ) ? $this->_req_data['QST_display_text'] : '' ; |
|
344 | - $set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text,10)); |
|
342 | + else if ($fieldName === 'QST_admin_label' && (isset($this->_req_data['QST_admin_label']) && empty($this->_req_data['QST_admin_label']))) { |
|
343 | + $QST_text = isset($this->_req_data['QST_display_text']) ? $this->_req_data['QST_display_text'] : ''; |
|
344 | + $set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text, 10)); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | |
348 | - else if ( $fieldName === 'QST_admin_only' && ( !isset( $this->_req_data['QST_admin_only'] ) ) ) { |
|
348 | + else if ($fieldName === 'QST_admin_only' && ( ! isset($this->_req_data['QST_admin_only']))) { |
|
349 | 349 | $set_column_values[$fieldName] = 0; |
350 | 350 | } |
351 | 351 | |
352 | - else if ( $fieldName === 'QST_max' ) { |
|
352 | + else if ($fieldName === 'QST_max') { |
|
353 | 353 | $qst_system = EEM_Question::instance()->get_var( |
354 | 354 | array( |
355 | 355 | array( |
356 | - 'QST_ID' => isset( $this->_req_data[ 'QST_ID' ] ) ? $this->_req_data[ 'QST_ID' ] : 0 |
|
356 | + 'QST_ID' => isset($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0 |
|
357 | 357 | ) |
358 | 358 | ), |
359 | 359 | 'QST_system' ); |
360 | - $max_max = EEM_Question::instance()->absolute_max_for_system_question( $qst_system ); |
|
361 | - if( empty( $this->_req_data[ 'QST_max' ] ) || |
|
362 | - $this->_req_data[ 'QST_max' ] > $max_max ) { |
|
363 | - $set_column_values[ $fieldName ] = $max_max; |
|
360 | + $max_max = EEM_Question::instance()->absolute_max_for_system_question($qst_system); |
|
361 | + if (empty($this->_req_data['QST_max']) || |
|
362 | + $this->_req_data['QST_max'] > $max_max) { |
|
363 | + $set_column_values[$fieldName] = $max_max; |
|
364 | 364 | } |
365 | 365 | } |
366 | 366 | |
367 | 367 | |
368 | 368 | //only add a property to the array if it's not null (otherwise the model should just use the default value) |
369 | - if( |
|
370 | - ! isset( $set_column_values[ $fieldName ] ) && |
|
371 | - isset($this->_req_data[$fieldName] ) ){ |
|
372 | - $set_column_values[$fieldName]=$this->_req_data[$fieldName]; |
|
369 | + if ( |
|
370 | + ! isset($set_column_values[$fieldName]) && |
|
371 | + isset($this->_req_data[$fieldName]) ) { |
|
372 | + $set_column_values[$fieldName] = $this->_req_data[$fieldName]; |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | } |
376 | - return $set_column_values;//validation fo this data to be performed by the model before insertion. |
|
376 | + return $set_column_values; //validation fo this data to be performed by the model before insertion. |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | |
@@ -392,29 +392,29 @@ discard block |
||
392 | 392 | * _edit_question |
393 | 393 | */ |
394 | 394 | protected function _edit_question() { |
395 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
396 | - $ID=isset( $this->_req_data['QST_ID'] ) && ! empty( $this->_req_data['QST_ID'] ) ? absint( $this->_req_data['QST_ID'] ) : FALSE; |
|
395 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
396 | + $ID = isset($this->_req_data['QST_ID']) && ! empty($this->_req_data['QST_ID']) ? absint($this->_req_data['QST_ID']) : FALSE; |
|
397 | 397 | |
398 | - $this->_admin_page_title = ucwords( str_replace( '_', ' ', $this->_req_action )); |
|
398 | + $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
399 | 399 | // add PRC_ID to title if editing |
400 | - $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
401 | - if($ID){ |
|
402 | - $question=$this->_question_model->get_one_by_ID($ID); |
|
403 | - $additional_hidden_fields=array('QST_ID'=>array('type'=>'hidden','value'=>$ID)); |
|
400 | + $this->_admin_page_title = $ID ? $this->_admin_page_title.' # '.$ID : $this->_admin_page_title; |
|
401 | + if ($ID) { |
|
402 | + $question = $this->_question_model->get_one_by_ID($ID); |
|
403 | + $additional_hidden_fields = array('QST_ID'=>array('type'=>'hidden', 'value'=>$ID)); |
|
404 | 404 | $this->_set_add_edit_form_tags('update_question', $additional_hidden_fields); |
405 | - }else{ |
|
406 | - $question= EE_Question::new_instance(); |
|
405 | + } else { |
|
406 | + $question = EE_Question::new_instance(); |
|
407 | 407 | $question->set_order_to_latest(); |
408 | 408 | $this->_set_add_edit_form_tags('insert_question'); |
409 | 409 | } |
410 | - $question_types = $question->has_answers() ? $this->_question_model->question_types_in_same_category( $question->type() ) : $this->_question_model->allowed_question_types(); |
|
411 | - $this->_template_args['QST_ID']=$ID; |
|
412 | - $this->_template_args['question']=$question; |
|
413 | - $this->_template_args['question_types']= $question_types; |
|
414 | - $this->_template_args['max_max'] = EEM_Question::instance()->absolute_max_for_system_question( $question->system_ID() ); |
|
410 | + $question_types = $question->has_answers() ? $this->_question_model->question_types_in_same_category($question->type()) : $this->_question_model->allowed_question_types(); |
|
411 | + $this->_template_args['QST_ID'] = $ID; |
|
412 | + $this->_template_args['question'] = $question; |
|
413 | + $this->_template_args['question_types'] = $question_types; |
|
414 | + $this->_template_args['max_max'] = EEM_Question::instance()->absolute_max_for_system_question($question->system_ID()); |
|
415 | 415 | $this->_template_args['question_type_descriptions'] = $this->_get_question_type_descriptions(); |
416 | - $this->_set_publish_post_box_vars( 'id', $ID ); |
|
417 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( REGISTRATION_FORM_TEMPLATE_PATH . 'questions_main_meta_box.template.php', $this->_template_args, TRUE ); |
|
416 | + $this->_set_publish_post_box_vars('id', $ID); |
|
417 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_TEMPLATE_PATH.'questions_main_meta_box.template.php', $this->_template_args, TRUE); |
|
418 | 418 | |
419 | 419 | // the details template wrapper |
420 | 420 | $this->display_admin_page_with_sidebar(); |
@@ -429,18 +429,18 @@ discard block |
||
429 | 429 | EE_Registry::instance()->load_helper('HTML'); |
430 | 430 | $descriptions = ''; |
431 | 431 | $question_type_descriptions = EEM_Question::instance()->question_descriptions(); |
432 | - foreach ( $question_type_descriptions as $type => $question_type_description ) { |
|
433 | - if ( $type == 'HTML_TEXTAREA' ) { |
|
432 | + foreach ($question_type_descriptions as $type => $question_type_description) { |
|
433 | + if ($type == 'HTML_TEXTAREA') { |
|
434 | 434 | $html = new EE_Simple_HTML_Validation_Strategy(); |
435 | 435 | $question_type_description .= sprintf( |
436 | - __( '%1$s(allowed tags: %2$s)', 'event_espresso' ), |
|
436 | + __('%1$s(allowed tags: %2$s)', 'event_espresso'), |
|
437 | 437 | '<br/>', |
438 | 438 | $html->get_list_of_allowed_tags() |
439 | 439 | ); |
440 | 440 | } |
441 | 441 | $descriptions .= EEH_HTML::p( |
442 | 442 | $question_type_description, |
443 | - 'question_type_description-' . $type, |
|
443 | + 'question_type_description-'.$type, |
|
444 | 444 | 'question_type_description description', |
445 | 445 | 'display:none;' |
446 | 446 | ); |
@@ -454,58 +454,58 @@ discard block |
||
454 | 454 | * @param bool|true $new_question |
455 | 455 | * @throws \EE_Error |
456 | 456 | */ |
457 | - protected function _insert_or_update_question( $new_question = TRUE) { |
|
458 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
459 | - $set_column_values=$this->_set_column_values_for($this->_question_model); |
|
460 | - if($new_question){ |
|
461 | - $ID=$this->_question_model->insert($set_column_values); |
|
457 | + protected function _insert_or_update_question($new_question = TRUE) { |
|
458 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
459 | + $set_column_values = $this->_set_column_values_for($this->_question_model); |
|
460 | + if ($new_question) { |
|
461 | + $ID = $this->_question_model->insert($set_column_values); |
|
462 | 462 | $success = $ID ? true : false; |
463 | 463 | $action_desc = 'added'; |
464 | - }else{ |
|
465 | - $ID=absint($this->_req_data['QST_ID']); |
|
466 | - $pk=$this->_question_model->primary_key_name(); |
|
467 | - $wheres=array($pk=>$ID); |
|
464 | + } else { |
|
465 | + $ID = absint($this->_req_data['QST_ID']); |
|
466 | + $pk = $this->_question_model->primary_key_name(); |
|
467 | + $wheres = array($pk=>$ID); |
|
468 | 468 | unset($set_column_values[$pk]); |
469 | - $success= $this->_question_model->update($set_column_values,array($wheres)); |
|
470 | - $action_desc='updated'; |
|
469 | + $success = $this->_question_model->update($set_column_values, array($wheres)); |
|
470 | + $action_desc = 'updated'; |
|
471 | 471 | } |
472 | 472 | |
473 | - if ($ID){ |
|
473 | + if ($ID) { |
|
474 | 474 | //save the related options |
475 | 475 | //trash removed options, save old ones |
476 | 476 | //get list of all options |
477 | 477 | /** @type EE_Question $question */ |
478 | - $question=$this->_question_model->get_one_by_ID($ID); |
|
479 | - $options=$question->options(); |
|
480 | - if(! empty($options)){ |
|
481 | - foreach($options as $option_ID=>$option){ |
|
482 | - $option_req_index=$this->_get_option_req_data_index($option_ID); |
|
483 | - if($option_req_index!==FALSE){ |
|
478 | + $question = $this->_question_model->get_one_by_ID($ID); |
|
479 | + $options = $question->options(); |
|
480 | + if ( ! empty($options)) { |
|
481 | + foreach ($options as $option_ID=>$option) { |
|
482 | + $option_req_index = $this->_get_option_req_data_index($option_ID); |
|
483 | + if ($option_req_index !== FALSE) { |
|
484 | 484 | $option->save($this->_req_data['question_options'][$option_req_index]); |
485 | - }else{ |
|
485 | + } else { |
|
486 | 486 | //not found, remove it |
487 | 487 | $option->delete(); |
488 | 488 | } |
489 | 489 | } |
490 | 490 | } |
491 | 491 | //save new related options |
492 | - foreach($this->_req_data['question_options'] as $index=>$option_req_data){ |
|
493 | - if( empty($option_req_data['QSO_ID'] ) && ( ( isset( $option_req_data['QSO_value'] ) && $option_req_data['QSO_value'] !== '' ) || ! empty( $option_req_data['QSO_desc'] ) ) ) {//no ID! save it! |
|
494 | - if( ! isset( $option_req_data['QSO_value'] ) || $option_req_data['QSO_value'] === '' ){ |
|
495 | - $option_req_data['QSO_value']=$option_req_data['QSO_desc']; |
|
492 | + foreach ($this->_req_data['question_options'] as $index=>$option_req_data) { |
|
493 | + if (empty($option_req_data['QSO_ID']) && ((isset($option_req_data['QSO_value']) && $option_req_data['QSO_value'] !== '') || ! empty($option_req_data['QSO_desc']))) {//no ID! save it! |
|
494 | + if ( ! isset($option_req_data['QSO_value']) || $option_req_data['QSO_value'] === '') { |
|
495 | + $option_req_data['QSO_value'] = $option_req_data['QSO_desc']; |
|
496 | 496 | } |
497 | - $new_option=EE_Question_Option::new_instance( array( 'QSO_value' => $option_req_data['QSO_value'], 'QSO_desc' => $option_req_data['QSO_desc'], 'QSO_order' => $option_req_data['QSO_order'], 'QST_ID' => $question->ID())); |
|
497 | + $new_option = EE_Question_Option::new_instance(array('QSO_value' => $option_req_data['QSO_value'], 'QSO_desc' => $option_req_data['QSO_desc'], 'QSO_order' => $option_req_data['QSO_order'], 'QST_ID' => $question->ID())); |
|
498 | 498 | $new_option->save(); |
499 | 499 | } |
500 | 500 | } |
501 | 501 | } |
502 | - $query_args = array( 'action' => 'edit_question', 'QST_ID' => $ID ); |
|
503 | - if ( $success !== FALSE ) { |
|
504 | - $msg = $new_question ? sprintf( __('The %s has been created', 'event_espresso'), $this->_question_model->item_name() ) : sprintf( __('The %s has been updated', 'event_espresso' ), $this->_question_model->item_name() ); |
|
505 | - EE_Error::add_success( $msg ); |
|
502 | + $query_args = array('action' => 'edit_question', 'QST_ID' => $ID); |
|
503 | + if ($success !== FALSE) { |
|
504 | + $msg = $new_question ? sprintf(__('The %s has been created', 'event_espresso'), $this->_question_model->item_name()) : sprintf(__('The %s has been updated', 'event_espresso'), $this->_question_model->item_name()); |
|
505 | + EE_Error::add_success($msg); |
|
506 | 506 | } |
507 | 507 | |
508 | - $this->_redirect_after_action( FALSE, '', $action_desc, $query_args, TRUE); |
|
508 | + $this->_redirect_after_action(FALSE, '', $action_desc, $query_args, TRUE); |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | |
@@ -518,10 +518,10 @@ discard block |
||
518 | 518 | * @param int $ID of the question option to find |
519 | 519 | * @return int index in question_options array if successful, FALSE if unsuccessful |
520 | 520 | */ |
521 | - protected function _get_option_req_data_index($ID){ |
|
522 | - $req_data_for_question_options=$this->_req_data['question_options']; |
|
523 | - foreach($req_data_for_question_options as $num=>$option_data){ |
|
524 | - if( array_key_exists('QSO_ID',$option_data) && (int)$option_data['QSO_ID'] === $ID ){ |
|
521 | + protected function _get_option_req_data_index($ID) { |
|
522 | + $req_data_for_question_options = $this->_req_data['question_options']; |
|
523 | + foreach ($req_data_for_question_options as $num=>$option_data) { |
|
524 | + if (array_key_exists('QSO_ID', $option_data) && (int) $option_data['QSO_ID'] === $ID) { |
|
525 | 525 | return $num; |
526 | 526 | } |
527 | 527 | } |
@@ -543,25 +543,25 @@ discard block |
||
543 | 543 | * @param int $current_page |
544 | 544 | * @return array lik EEM_Base::get_all's $query_params parameter |
545 | 545 | */ |
546 | - protected function get_query_params($model, $per_page=10,$current_page=10){ |
|
546 | + protected function get_query_params($model, $per_page = 10, $current_page = 10) { |
|
547 | 547 | $query_params = array(); |
548 | - $offset=($current_page-1)*$per_page; |
|
549 | - $query_params['limit']=array($offset,$per_page); |
|
550 | - $order = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'ASC'; |
|
548 | + $offset = ($current_page - 1) * $per_page; |
|
549 | + $query_params['limit'] = array($offset, $per_page); |
|
550 | + $order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC'; |
|
551 | 551 | $orderby_field = $model instanceof EEM_Question ? 'QST_ID' : 'QSG_order'; |
552 | 552 | $field_to_order_by = empty($this->_req_data['orderby']) ? $orderby_field : $this->_req_data['orderby']; |
553 | - $query_params['order_by']=array( $field_to_order_by => $order ); |
|
554 | - $search_string = array_key_exists('s',$this->_req_data) ? $this->_req_data['s'] : null; |
|
555 | - if(! empty($search_string)){ |
|
556 | - if($model instanceof EEM_Question_Group){ |
|
557 | - $query_params[0]=array( |
|
553 | + $query_params['order_by'] = array($field_to_order_by => $order); |
|
554 | + $search_string = array_key_exists('s', $this->_req_data) ? $this->_req_data['s'] : null; |
|
555 | + if ( ! empty($search_string)) { |
|
556 | + if ($model instanceof EEM_Question_Group) { |
|
557 | + $query_params[0] = array( |
|
558 | 558 | 'OR'=>array( |
559 | - 'QSG_name'=>array('LIKE',"%$search_string%"), |
|
560 | - 'QSG_desc'=>array('LIKE',"%$search_string%")) |
|
559 | + 'QSG_name'=>array('LIKE', "%$search_string%"), |
|
560 | + 'QSG_desc'=>array('LIKE', "%$search_string%")) |
|
561 | 561 | ); |
562 | - }else{ |
|
563 | - $query_params[0]=array( |
|
564 | - 'QST_display_text'=>array('LIKE',"%$search_string%") |
|
562 | + } else { |
|
563 | + $query_params[0] = array( |
|
564 | + 'QST_display_text'=>array('LIKE', "%$search_string%") |
|
565 | 565 | ); |
566 | 566 | } |
567 | 567 | } |
@@ -609,13 +609,13 @@ discard block |
||
609 | 609 | * @param bool|false $count |
610 | 610 | * @return \EE_Soft_Delete_Base_Class[]|int |
611 | 611 | */ |
612 | - public function get_questions( $per_page=10, $current_page = 1, $count = FALSE ) { |
|
612 | + public function get_questions($per_page = 10, $current_page = 1, $count = FALSE) { |
|
613 | 613 | $QST = EEM_Question::instance(); |
614 | 614 | $query_params = $this->get_query_params($QST, $per_page, $current_page); |
615 | - if ($count){ |
|
616 | - $where = isset( $query_params[0] ) ? array( $query_params[0] ) : array(); |
|
615 | + if ($count) { |
|
616 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
617 | 617 | $results = $QST->count($where); |
618 | - }else{ |
|
618 | + } else { |
|
619 | 619 | $results = $QST->get_all($query_params); |
620 | 620 | } |
621 | 621 | return $results; |
@@ -630,10 +630,10 @@ discard block |
||
630 | 630 | * @param bool|false $count |
631 | 631 | * @return \EE_Soft_Delete_Base_Class[]|int |
632 | 632 | */ |
633 | - public function get_trashed_questions( $per_page, $current_page = 1, $count = FALSE ) { |
|
634 | - $query_params =$this->get_query_params( EEM_Question::instance(), $per_page, $current_page); |
|
635 | - $where = isset( $query_params[0] ) ? array($query_params[0]) : array(); |
|
636 | - $questions =$count ? EEM_Question::instance()->count_deleted($where) : EEM_Question::instance()->get_all_deleted($query_params); |
|
633 | + public function get_trashed_questions($per_page, $current_page = 1, $count = FALSE) { |
|
634 | + $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page); |
|
635 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
636 | + $questions = $count ? EEM_Question::instance()->count_deleted($where) : EEM_Question::instance()->get_all_deleted($query_params); |
|
637 | 637 | return $questions; |
638 | 638 | } |
639 | 639 | |
@@ -645,12 +645,12 @@ discard block |
||
645 | 645 | * @param bool|false $count |
646 | 646 | * @return \EE_Soft_Delete_Base_Class[] |
647 | 647 | */ |
648 | - public function get_question_groups( $per_page, $current_page = 1, $count = FALSE ) { |
|
648 | + public function get_question_groups($per_page, $current_page = 1, $count = FALSE) { |
|
649 | 649 | /** @type EEM_Question_Group $questionGroupModel */ |
650 | 650 | $questionGroupModel = EEM_Question_Group::instance(); |
651 | 651 | //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
652 | 652 | return $questionGroupModel->get_all( |
653 | - $this->get_query_params( $questionGroupModel, $per_page, $current_page ) |
|
653 | + $this->get_query_params($questionGroupModel, $per_page, $current_page) |
|
654 | 654 | ); |
655 | 655 | } |
656 | 656 | |
@@ -667,36 +667,36 @@ discard block |
||
667 | 667 | |
668 | 668 | $this->_template_args['values'] = $this->_yes_no_values; |
669 | 669 | |
670 | - $this->_template_args['use_captcha'] = isset( EE_Registry::instance()->CFG->registration->use_captcha ) ? EE_Registry::instance()->CFG->registration->use_captcha : FALSE; |
|
671 | - $this->_template_args['show_captcha_settings'] = $this->_template_args['use_captcha'] ? 'style="display:table-row;"': ''; |
|
670 | + $this->_template_args['use_captcha'] = isset(EE_Registry::instance()->CFG->registration->use_captcha) ? EE_Registry::instance()->CFG->registration->use_captcha : FALSE; |
|
671 | + $this->_template_args['show_captcha_settings'] = $this->_template_args['use_captcha'] ? 'style="display:table-row;"' : ''; |
|
672 | 672 | |
673 | - $this->_template_args['recaptcha_publickey'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_publickey ) ? stripslashes( EE_Registry::instance()->CFG->registration->recaptcha_publickey ) : ''; |
|
674 | - $this->_template_args['recaptcha_privatekey'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_privatekey ) ? stripslashes( EE_Registry::instance()->CFG->registration->recaptcha_privatekey ) : ''; |
|
675 | - $this->_template_args['recaptcha_width'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_width ) ? absint( EE_Registry::instance()->CFG->registration->recaptcha_width ) : 500; |
|
673 | + $this->_template_args['recaptcha_publickey'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_publickey) ? stripslashes(EE_Registry::instance()->CFG->registration->recaptcha_publickey) : ''; |
|
674 | + $this->_template_args['recaptcha_privatekey'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_privatekey) ? stripslashes(EE_Registry::instance()->CFG->registration->recaptcha_privatekey) : ''; |
|
675 | + $this->_template_args['recaptcha_width'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_width) ? absint(EE_Registry::instance()->CFG->registration->recaptcha_width) : 500; |
|
676 | 676 | |
677 | 677 | $this->_template_args['recaptcha_theme_options'] = array( |
678 | - array('id' => 'red','text'=> __('Red', 'event_espresso')), |
|
679 | - array('id' => 'white','text'=> __('White', 'event_espresso')), |
|
680 | - array('id' => 'blackglass','text'=> __('Blackglass', 'event_espresso')), |
|
681 | - array('id' => 'clean','text'=> __('Clean', 'event_espresso')) |
|
678 | + array('id' => 'red', 'text'=> __('Red', 'event_espresso')), |
|
679 | + array('id' => 'white', 'text'=> __('White', 'event_espresso')), |
|
680 | + array('id' => 'blackglass', 'text'=> __('Blackglass', 'event_espresso')), |
|
681 | + array('id' => 'clean', 'text'=> __('Clean', 'event_espresso')) |
|
682 | 682 | ); |
683 | - $this->_template_args['recaptcha_theme'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_theme ) ? EE_Registry::instance()->CFG->registration->get_pretty( 'recaptcha_theme' ) : 'clean'; |
|
683 | + $this->_template_args['recaptcha_theme'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_theme) ? EE_Registry::instance()->CFG->registration->get_pretty('recaptcha_theme') : 'clean'; |
|
684 | 684 | |
685 | 685 | $this->_template_args['recaptcha_language_options'] = array( |
686 | - array('id' => 'en','text'=> __('English', 'event_espresso')), |
|
687 | - array('id' => 'es','text'=> __('Spanish', 'event_espresso')), |
|
688 | - array('id' => 'nl','text'=> __('Dutch', 'event_espresso')), |
|
689 | - array('id' => 'fr','text'=> __('French', 'event_espresso')), |
|
690 | - array('id' => 'de','text'=> __('German', 'event_espresso')), |
|
691 | - array('id' => 'pt','text'=> __('Portuguese', 'event_espresso')), |
|
692 | - array('id' => 'ru','text'=> __('Russian', 'event_espresso')), |
|
693 | - array('id' => 'tr','text'=> __('Turkish', 'event_espresso')) |
|
686 | + array('id' => 'en', 'text'=> __('English', 'event_espresso')), |
|
687 | + array('id' => 'es', 'text'=> __('Spanish', 'event_espresso')), |
|
688 | + array('id' => 'nl', 'text'=> __('Dutch', 'event_espresso')), |
|
689 | + array('id' => 'fr', 'text'=> __('French', 'event_espresso')), |
|
690 | + array('id' => 'de', 'text'=> __('German', 'event_espresso')), |
|
691 | + array('id' => 'pt', 'text'=> __('Portuguese', 'event_espresso')), |
|
692 | + array('id' => 'ru', 'text'=> __('Russian', 'event_espresso')), |
|
693 | + array('id' => 'tr', 'text'=> __('Turkish', 'event_espresso')) |
|
694 | 694 | ); |
695 | - $this->_template_args['recaptcha_language'] = isset( EE_Registry::instance()->CFG->registration->recaptcha_language ) ? EE_Registry::instance()->CFG->registration->recaptcha_language : 'en'; |
|
695 | + $this->_template_args['recaptcha_language'] = isset(EE_Registry::instance()->CFG->registration->recaptcha_language) ? EE_Registry::instance()->CFG->registration->recaptcha_language : 'en'; |
|
696 | 696 | |
697 | - $this->_set_add_edit_form_tags( 'update_reg_form_settings' ); |
|
698 | - $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
699 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( REGISTRATION_FORM_TEMPLATE_PATH . 'reg_form_settings.template.php', $this->_template_args, TRUE ); |
|
697 | + $this->_set_add_edit_form_tags('update_reg_form_settings'); |
|
698 | + $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); |
|
699 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_TEMPLATE_PATH.'reg_form_settings.template.php', $this->_template_args, TRUE); |
|
700 | 700 | $this->display_admin_page_with_sidebar(); |
701 | 701 | } |
702 | 702 |