@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | use EventEspresso\core\services\database\TableAnalysis; |
3 | 3 | use EventEspresso\core\services\database\TableManager; |
4 | 4 | |
5 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION')) { |
|
5 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
6 | 6 | exit('No direct script access allowed'); |
7 | 7 | } |
8 | 8 | |
@@ -125,17 +125,17 @@ discard block |
||
125 | 125 | * @param TableAnalysis $table_analysis |
126 | 126 | * @throws \EE_Error |
127 | 127 | */ |
128 | - public function __construct( TableManager $table_manager = null, TableAnalysis $table_analysis = null ) { |
|
128 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) { |
|
129 | 129 | $this->_migration_stages = (array) apply_filters( |
130 | 130 | 'FHEE__'.get_class($this).'__construct__migration_stages', |
131 | 131 | $this->_migration_stages |
132 | 132 | ); |
133 | - foreach($this->_migration_stages as $migration_stage){ |
|
134 | - if ( $migration_stage instanceof EE_Data_Migration_Script_Stage ) { |
|
133 | + foreach ($this->_migration_stages as $migration_stage) { |
|
134 | + if ($migration_stage instanceof EE_Data_Migration_Script_Stage) { |
|
135 | 135 | $migration_stage->_construct_finalize($this); |
136 | 136 | } |
137 | 137 | } |
138 | - parent::__construct( $table_manager, $table_analysis ); |
|
138 | + parent::__construct($table_manager, $table_analysis); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | |
@@ -148,16 +148,16 @@ discard block |
||
148 | 148 | */ |
149 | 149 | protected function _load_script_stages() { |
150 | 150 | static $script_stages_loaded = array(); |
151 | - $stage = str_replace( 'EE_DMS_Core_', '', get_class( $this ) ); |
|
152 | - if ( isset( $script_stages_loaded[ $stage ] ) ) { |
|
151 | + $stage = str_replace('EE_DMS_Core_', '', get_class($this)); |
|
152 | + if (isset($script_stages_loaded[$stage])) { |
|
153 | 153 | return; |
154 | 154 | } |
155 | - $stages = glob( EE_CORE . "data_migration_scripts/{$stage}_stages/*.dmsstage.php" ); |
|
155 | + $stages = glob(EE_CORE."data_migration_scripts/{$stage}_stages/*.dmsstage.php"); |
|
156 | 156 | $class_to_filepath = array(); |
157 | - foreach ( $stages as $filepath ) { |
|
157 | + foreach ($stages as $filepath) { |
|
158 | 158 | $matches = array(); |
159 | - if ( preg_match( "~{$stage}_stages/(.*).dmsstage.php~", $filepath, $matches ) ) { |
|
160 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
159 | + if (preg_match("~{$stage}_stages/(.*).dmsstage.php~", $filepath, $matches)) { |
|
160 | + $class_to_filepath[$matches[1]] = $filepath; |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | //give addons a chance to autoload their stages too |
@@ -165,8 +165,8 @@ discard block |
||
165 | 165 | "FHEE__EE_DMS_{$stage}__autoloaded_stages", |
166 | 166 | $class_to_filepath |
167 | 167 | ); |
168 | - EEH_Autoloader::register_autoloader( $class_to_filepath ); |
|
169 | - $script_stages_loaded[ $stage ] = true; |
|
168 | + EEH_Autoloader::register_autoloader($class_to_filepath); |
|
169 | + $script_stages_loaded[$stage] = true; |
|
170 | 170 | |
171 | 171 | } |
172 | 172 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * Place to add hooks and filters for tweaking the migrations page, in order |
175 | 175 | * to customize it |
176 | 176 | */ |
177 | - public function migration_page_hooks(){ |
|
177 | + public function migration_page_hooks() { |
|
178 | 178 | //by default none are added because we normally like the default look of the migration page |
179 | 179 | } |
180 | 180 | |
@@ -189,9 +189,9 @@ discard block |
||
189 | 189 | * @param int|string $new_pk eg posts.ID |
190 | 190 | * @return void |
191 | 191 | */ |
192 | - public function set_mapping($old_table,$old_pk,$new_table,$new_pk){ |
|
192 | + public function set_mapping($old_table, $old_pk, $new_table, $new_pk) { |
|
193 | 193 | //make sure it has the needed keys |
194 | - if( ! isset($this->_mappings[$old_table]) || ! isset($this->_mappings[$old_table][$new_table])){ |
|
194 | + if ( ! isset($this->_mappings[$old_table]) || ! isset($this->_mappings[$old_table][$new_table])) { |
|
195 | 195 | $this->_mappings[$old_table][$new_table] = $this->_get_mapping_option($old_table, $new_table); |
196 | 196 | } |
197 | 197 | $this->_mappings[$old_table][$new_table][$old_pk] = $new_pk; |
@@ -207,9 +207,9 @@ discard block |
||
207 | 207 | * @param string $new_table with wpdb prefix (wp_). Eg: wp_posts |
208 | 208 | * @return mixed the primary key on the new table |
209 | 209 | */ |
210 | - public function get_mapping_new_pk($old_table,$old_pk,$new_table){ |
|
211 | - if( ! isset($this->_mappings[$old_table]) || |
|
212 | - ! isset($this->_mappings[$old_table][$new_table])){ |
|
210 | + public function get_mapping_new_pk($old_table, $old_pk, $new_table) { |
|
211 | + if ( ! isset($this->_mappings[$old_table]) || |
|
212 | + ! isset($this->_mappings[$old_table][$new_table])) { |
|
213 | 213 | //try fetching the option |
214 | 214 | $this->_mappings[$old_table][$new_table] = $this->_get_mapping_option($old_table, $new_table); |
215 | 215 | } |
@@ -226,15 +226,15 @@ discard block |
||
226 | 226 | * @param mixed $new_pk |
227 | 227 | * @return mixed |
228 | 228 | */ |
229 | - public function get_mapping_old_pk($old_table,$new_table,$new_pk){ |
|
230 | - if( ! isset($this->_mappings[$old_table]) || |
|
231 | - ! isset($this->_mappings[$old_table][$new_table])){ |
|
229 | + public function get_mapping_old_pk($old_table, $new_table, $new_pk) { |
|
230 | + if ( ! isset($this->_mappings[$old_table]) || |
|
231 | + ! isset($this->_mappings[$old_table][$new_table])) { |
|
232 | 232 | //try fetching the option |
233 | 233 | $this->_mappings[$old_table][$new_table] = $this->_get_mapping_option($old_table, $new_table); |
234 | 234 | } |
235 | - if(isset($this->_mappings[$old_table][$new_table])){ |
|
235 | + if (isset($this->_mappings[$old_table][$new_table])) { |
|
236 | 236 | $new_pk_to_old_pk = array_flip($this->_mappings[$old_table][$new_table]); |
237 | - if(isset($new_pk_to_old_pk[$new_pk])){ |
|
237 | + if (isset($new_pk_to_old_pk[$new_pk])) { |
|
238 | 238 | return $new_pk_to_old_pk[$new_pk]; |
239 | 239 | } |
240 | 240 | } |
@@ -249,8 +249,8 @@ discard block |
||
249 | 249 | * @param string $new_table_name |
250 | 250 | * @return array |
251 | 251 | */ |
252 | - protected function _get_mapping_option($old_table_name,$new_table_name){ |
|
253 | - $option = get_option($this->_get_mapping_option_name($old_table_name, $new_table_name),array()); |
|
252 | + protected function _get_mapping_option($old_table_name, $new_table_name) { |
|
253 | + $option = get_option($this->_get_mapping_option_name($old_table_name, $new_table_name), array()); |
|
254 | 254 | return $option; |
255 | 255 | } |
256 | 256 | |
@@ -263,9 +263,9 @@ discard block |
||
263 | 263 | * @param array $mapping_array |
264 | 264 | * @return boolean success of updating option |
265 | 265 | */ |
266 | - protected function _set_mapping_option($old_table_name,$new_table_name,$mapping_array){ |
|
266 | + protected function _set_mapping_option($old_table_name, $new_table_name, $mapping_array) { |
|
267 | 267 | // echo "set mapping for $old_table_name $new_table_name".count($mapping_array)."<br>"; |
268 | - $success = update_option($this->_get_mapping_option_name($old_table_name, $new_table_name),$mapping_array); |
|
268 | + $success = update_option($this->_get_mapping_option_name($old_table_name, $new_table_name), $mapping_array); |
|
269 | 269 | return $success; |
270 | 270 | } |
271 | 271 | |
@@ -277,12 +277,12 @@ discard block |
||
277 | 277 | * @param string $new_table_name |
278 | 278 | * @return string |
279 | 279 | */ |
280 | - protected function _get_mapping_option_name($old_table_name,$new_table_name){ |
|
280 | + protected function _get_mapping_option_name($old_table_name, $new_table_name) { |
|
281 | 281 | global $wpdb; |
282 | - $old_table_name_sans_wp = str_replace($wpdb->prefix,"",$old_table_name); |
|
283 | - $new_table_name_sans_wp = str_replace($wpdb->prefix,"",$new_table_name); |
|
282 | + $old_table_name_sans_wp = str_replace($wpdb->prefix, "", $old_table_name); |
|
283 | + $new_table_name_sans_wp = str_replace($wpdb->prefix, "", $new_table_name); |
|
284 | 284 | $migrates_to = EE_Data_Migration_Manager::instance()->script_migrates_to_version(get_class($this)); |
285 | - return substr( EE_Data_Migration_Manager::data_migration_script_mapping_option_prefix . $migrates_to [ 'slug' ] . '_' . $migrates_to[ 'version' ] . '_' . $old_table_name_sans_wp . '_' . $new_table_name_sans_wp, 0, 64 ); |
|
285 | + return substr(EE_Data_Migration_Manager::data_migration_script_mapping_option_prefix.$migrates_to ['slug'].'_'.$migrates_to['version'].'_'.$old_table_name_sans_wp.'_'.$new_table_name_sans_wp, 0, 64); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | |
@@ -299,10 +299,10 @@ discard block |
||
299 | 299 | * 99% until the function "migration_step" returns EE_Data_Migration_Script_Base::status_complete. |
300 | 300 | * @return int |
301 | 301 | */ |
302 | - protected function _count_records_to_migrate(){ |
|
302 | + protected function _count_records_to_migrate() { |
|
303 | 303 | $count = 0; |
304 | - foreach($this->stages() as $stage){ |
|
305 | - $count+= $stage->count_records_to_migrate(); |
|
304 | + foreach ($this->stages() as $stage) { |
|
305 | + $count += $stage->count_records_to_migrate(); |
|
306 | 306 | } |
307 | 307 | return $count; |
308 | 308 | } |
@@ -314,10 +314,10 @@ discard block |
||
314 | 314 | * by just setting a transient and updating it after each migration_step |
315 | 315 | * @return int |
316 | 316 | */ |
317 | - public function count_records_migrated(){ |
|
317 | + public function count_records_migrated() { |
|
318 | 318 | $count = 0; |
319 | - foreach($this->stages() as $stage){ |
|
320 | - $count+= $stage->count_records_migrated(); |
|
319 | + foreach ($this->stages() as $stage) { |
|
320 | + $count += $stage->count_records_migrated(); |
|
321 | 321 | } |
322 | 322 | $this->_records_migrated = $count; |
323 | 323 | return $count; |
@@ -331,24 +331,24 @@ discard block |
||
331 | 331 | * @throws EE_Error |
332 | 332 | * @throws Exception |
333 | 333 | */ |
334 | - public function migration_step($num_records_to_migrate_limit){ |
|
334 | + public function migration_step($num_records_to_migrate_limit) { |
|
335 | 335 | //reset the feedback message |
336 | 336 | $this->_feedback_message = ''; |
337 | 337 | //if we haven't yet done the 1st schema changes, do them now. buffer any output |
338 | 338 | $this->_maybe_do_schema_changes(true); |
339 | 339 | |
340 | - $num_records_actually_migrated =0; |
|
340 | + $num_records_actually_migrated = 0; |
|
341 | 341 | $records_migrated_per_stage = array(); |
342 | 342 | //setup the 'stage' variable, which should hold the last run stage of the migration (or none at all if nothing runs) |
343 | 343 | $stage = null; |
344 | 344 | //get the next stage that isn't complete |
345 | - foreach($this->stages() as $stage){ |
|
346 | - if( $stage->get_status() == EE_Data_Migration_Manager::status_continue){ |
|
347 | - try{ |
|
345 | + foreach ($this->stages() as $stage) { |
|
346 | + if ($stage->get_status() == EE_Data_Migration_Manager::status_continue) { |
|
347 | + try { |
|
348 | 348 | $records_migrated_during_stage = $stage->migration_step($num_records_to_migrate_limit - $num_records_actually_migrated); |
349 | 349 | $num_records_actually_migrated += $records_migrated_during_stage; |
350 | 350 | $records_migrated_per_stage[$stage->pretty_name()] = $records_migrated_during_stage; |
351 | - }catch(Exception $e){ |
|
351 | + } catch (Exception $e) { |
|
352 | 352 | //yes if we catch an exception here, we consider that migration stage borked. |
353 | 353 | $stage->set_status(EE_Data_Migration_Manager::status_fatal_error); |
354 | 354 | $this->set_status(EE_Data_Migration_Manager::status_fatal_error); |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | throw $e; |
357 | 357 | } |
358 | 358 | //check that the migration stage didn't mark itself as having a fatal error |
359 | - if($stage->is_broken()){ |
|
359 | + if ($stage->is_broken()) { |
|
360 | 360 | $this->set_broken(); |
361 | 361 | throw new EE_Error($stage->get_last_error()); |
362 | 362 | } |
@@ -364,24 +364,24 @@ discard block |
||
364 | 364 | //once we've migrated all the number we intended to (possibly from different stages), stop migrating |
365 | 365 | //or if we had a fatal error |
366 | 366 | //or if the current script stopped early- its not done, but it's done all it thinks we should do on this step |
367 | - if ($num_records_actually_migrated >= $num_records_to_migrate_limit || $stage->is_broken() || $stage->has_more_to_do()){ |
|
367 | + if ($num_records_actually_migrated >= $num_records_to_migrate_limit || $stage->is_broken() || $stage->has_more_to_do()) { |
|
368 | 368 | break; |
369 | 369 | } |
370 | 370 | } |
371 | 371 | //check if we're all done this data migration... |
372 | 372 | //which is indicated by being done early AND the last stage claims to be done |
373 | - if($stage == NULL){ |
|
373 | + if ($stage == NULL) { |
|
374 | 374 | //this migration script apparently has NO stages... which is super weird, but whatever |
375 | 375 | $this->set_completed(); |
376 | 376 | $this->_maybe_do_schema_changes(false); |
377 | - }else if( $num_records_actually_migrated < $num_records_to_migrate_limit && ! $stage->has_more_to_do()){ |
|
377 | + } else if ($num_records_actually_migrated < $num_records_to_migrate_limit && ! $stage->has_more_to_do()) { |
|
378 | 378 | //apparently we're done, because we couldn't migrate the number we intended to |
379 | 379 | $this->set_completed(); |
380 | 380 | $this->_update_feedback_message(array_reverse($records_migrated_per_stage)); |
381 | 381 | //do schema changes for after the migration now |
382 | 382 | //first double-check we haven't already done this |
383 | 383 | $this->_maybe_do_schema_changes(false); |
384 | - }else{ |
|
384 | + } else { |
|
385 | 385 | //update feedback message, keeping in mind that we show them with the most recent at the top |
386 | 386 | $this->_update_feedback_message(array_reverse($records_migrated_per_stage)); |
387 | 387 | } |
@@ -395,12 +395,12 @@ discard block |
||
395 | 395 | * @param array $records_migrated_per_stage KEYS are pretty names for each stage; values are the count of records migrated from that stage |
396 | 396 | * @return void |
397 | 397 | */ |
398 | - private function _update_feedback_message($records_migrated_per_stage){ |
|
398 | + private function _update_feedback_message($records_migrated_per_stage) { |
|
399 | 399 | $feedback_message_array = array(); |
400 | - foreach($records_migrated_per_stage as $migration_stage_name => $num_records_migrated){ |
|
401 | - $feedback_message_array[] = sprintf(__("Migrated %d records successfully during %s", "event_espresso"),$num_records_migrated,$migration_stage_name) ; |
|
400 | + foreach ($records_migrated_per_stage as $migration_stage_name => $num_records_migrated) { |
|
401 | + $feedback_message_array[] = sprintf(__("Migrated %d records successfully during %s", "event_espresso"), $num_records_migrated, $migration_stage_name); |
|
402 | 402 | } |
403 | - $this->_feedback_message .= implode("<br>",$feedback_message_array); |
|
403 | + $this->_feedback_message .= implode("<br>", $feedback_message_array); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | |
@@ -412,27 +412,27 @@ discard block |
||
412 | 412 | * @throws Exception |
413 | 413 | * @return void |
414 | 414 | */ |
415 | - private function _maybe_do_schema_changes($before = true){ |
|
415 | + private function _maybe_do_schema_changes($before = true) { |
|
416 | 416 | //so this property will be either _schema_changes_after_migration_ran or _schema_changes_before_migration_ran |
417 | - $property_name = '_schema_changes_'. ($before ? 'before' : 'after').'_migration_ran'; |
|
418 | - if ( ! $this->{$property_name} ){ |
|
419 | - try{ |
|
417 | + $property_name = '_schema_changes_'.($before ? 'before' : 'after').'_migration_ran'; |
|
418 | + if ( ! $this->{$property_name} ) { |
|
419 | + try { |
|
420 | 420 | ob_start(); |
421 | - if($before){ |
|
421 | + if ($before) { |
|
422 | 422 | $this->schema_changes_before_migration(); |
423 | - }else{ |
|
423 | + } else { |
|
424 | 424 | $this->schema_changes_after_migration(); |
425 | 425 | } |
426 | 426 | $output = ob_get_contents(); |
427 | 427 | ob_end_clean(); |
428 | - }catch(Exception $e){ |
|
428 | + } catch (Exception $e) { |
|
429 | 429 | $this->set_status(EE_Data_Migration_Manager::status_fatal_error); |
430 | 430 | throw $e; |
431 | 431 | } |
432 | 432 | //record that we've done these schema changes |
433 | 433 | $this->{$property_name} = true; |
434 | 434 | //if there were any warnings etc, record them as non-fatal errors |
435 | - if( $output ){ |
|
435 | + if ($output) { |
|
436 | 436 | //there were some warnings |
437 | 437 | $this->_errors[] = $output; |
438 | 438 | } |
@@ -459,9 +459,9 @@ discard block |
||
459 | 459 | * @param string $table_definition_sql |
460 | 460 | * @param string $engine_string |
461 | 461 | */ |
462 | - protected function _table_is_new_in_this_version($table_name,$table_definition_sql,$engine_string='ENGINE=InnoDB '){ |
|
462 | + protected function _table_is_new_in_this_version($table_name, $table_definition_sql, $engine_string = 'ENGINE=InnoDB ') { |
|
463 | 463 | // EEH_Debug_Tools::instance()->start_timer( '_table_is_new_in_this_version_' . $table_name ); |
464 | - $this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped( true ) ); |
|
464 | + $this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(true)); |
|
465 | 465 | // EEH_Debug_Tools::instance()->stop_timer( '_table_is_new_in_this_version_' . $table_name ); |
466 | 466 | } |
467 | 467 | |
@@ -475,9 +475,9 @@ discard block |
||
475 | 475 | * @param string $table_definition_sql |
476 | 476 | * @param string $engine_string |
477 | 477 | */ |
478 | - protected function _table_is_changed_in_this_version($table_name,$table_definition_sql,$engine_string = 'ENGINE=MyISAM'){ |
|
478 | + protected function _table_is_changed_in_this_version($table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM') { |
|
479 | 479 | // EEH_Debug_Tools::instance()->start_timer( '_table_is_changed_in_this_version' . $table_name ); |
480 | - $this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped( false ) ); |
|
480 | + $this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(false)); |
|
481 | 481 | // EEH_Debug_Tools::instance()->stop_timer( '_table_is_changed_in_this_version' . $table_name ); |
482 | 482 | } |
483 | 483 | |
@@ -488,8 +488,8 @@ discard block |
||
488 | 488 | * @param string $table_name |
489 | 489 | * @return boolean |
490 | 490 | */ |
491 | - protected function _old_table_exists( $table_name ) { |
|
492 | - return $this->_get_table_analysis()->tableExists( $table_name ); |
|
491 | + protected function _old_table_exists($table_name) { |
|
492 | + return $this->_get_table_analysis()->tableExists($table_name); |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | |
@@ -499,8 +499,8 @@ discard block |
||
499 | 499 | * @param string $table_name |
500 | 500 | * @return boolean |
501 | 501 | */ |
502 | - protected function _delete_table_if_empty( $table_name ) { |
|
503 | - return EEH_Activation::delete_db_table_if_empty( $table_name ); |
|
502 | + protected function _delete_table_if_empty($table_name) { |
|
503 | + return EEH_Activation::delete_db_table_if_empty($table_name); |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | |
@@ -519,9 +519,9 @@ discard block |
||
519 | 519 | * @param string $table_definition_sql |
520 | 520 | * @param string $engine_string |
521 | 521 | */ |
522 | - protected function _table_should_exist_previously($table_name,$table_definition_sql,$engine_string = 'ENGINE=MyISAM'){ |
|
522 | + protected function _table_should_exist_previously($table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM') { |
|
523 | 523 | // EEH_Debug_Tools::instance()->start_timer( '_table_should_exist_previously' . $table_name ); |
524 | - $this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped( false ) ); |
|
524 | + $this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(false)); |
|
525 | 525 | // EEH_Debug_Tools::instance()->stop_timer( '_table_should_exist_previously' . $table_name ); |
526 | 526 | } |
527 | 527 | |
@@ -536,13 +536,13 @@ discard block |
||
536 | 536 | * @param string $table_definition_sql |
537 | 537 | * @param string $engine_string |
538 | 538 | */ |
539 | - protected function _table_has_not_changed_since_previous( $table_name,$table_definition_sql,$engine_string = 'ENGINE=MyISAM'){ |
|
540 | - if( $this->_currently_migrating() ) { |
|
539 | + protected function _table_has_not_changed_since_previous($table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM') { |
|
540 | + if ($this->_currently_migrating()) { |
|
541 | 541 | //if we're doing a migration, and this table apparently already exists, then we don't need do anything right? |
542 | 542 | // EEH_Debug_Tools::instance()->stop_timer( '_table_should_exist_previously' . $table_name ); |
543 | 543 | return; |
544 | 544 | } |
545 | - $this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped( false ) ); |
|
545 | + $this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(false)); |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | /** |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | protected function _currently_migrating() { |
553 | 553 | //we want to know if we are currently performing a migration. We could just believe what was set on the _migrating property, but let's double-check (ie the script should apply and we should be in MM) |
554 | 554 | return $this->_migrating && |
555 | - $this->can_migrate_from_version( EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set() ) && |
|
555 | + $this->can_migrate_from_version(EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set()) && |
|
556 | 556 | EE_Maintenance_Mode::instance()->real_level() == EE_Maintenance_Mode::level_2_complete_maintenance; |
557 | 557 | } |
558 | 558 | |
@@ -563,17 +563,17 @@ discard block |
||
563 | 563 | * @param boolean $table_is_new |
564 | 564 | * @return boolean |
565 | 565 | */ |
566 | - protected function _pre_existing_table_should_be_dropped( $table_is_new ) { |
|
567 | - if( $table_is_new ) { |
|
568 | - if( $this->_get_req_type_for_plugin_corresponding_to_this_dms() == EE_System::req_type_new_activation || $this->_currently_migrating() ){ |
|
566 | + protected function _pre_existing_table_should_be_dropped($table_is_new) { |
|
567 | + if ($table_is_new) { |
|
568 | + if ($this->_get_req_type_for_plugin_corresponding_to_this_dms() == EE_System::req_type_new_activation || $this->_currently_migrating()) { |
|
569 | 569 | return true; |
570 | - }else{ |
|
570 | + } else { |
|
571 | 571 | return false; |
572 | 572 | } |
573 | - }else{ |
|
574 | - if(in_array($this->_get_req_type_for_plugin_corresponding_to_this_dms(),array(EE_System::req_type_new_activation))){ |
|
573 | + } else { |
|
574 | + if (in_array($this->_get_req_type_for_plugin_corresponding_to_this_dms(), array(EE_System::req_type_new_activation))) { |
|
575 | 575 | return true; |
576 | - }else{ |
|
576 | + } else { |
|
577 | 577 | return false; |
578 | 578 | } |
579 | 579 | } |
@@ -586,12 +586,12 @@ discard block |
||
586 | 586 | * @param string $engine_string |
587 | 587 | * @param boolean $drop_pre_existing_tables |
588 | 588 | */ |
589 | - private function _create_table_and_catch_errors( $table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM', $drop_pre_existing_tables = FALSE ){ |
|
590 | - try{ |
|
591 | - EEH_Activation::create_table($table_name,$table_definition_sql, $engine_string, $drop_pre_existing_tables); |
|
592 | - }catch( EE_Error $e ) { |
|
593 | - $message = $e->getMessage() . '<br>Stack Trace:' . $e->getTraceAsString(); |
|
594 | - $this->add_error( $message ); |
|
589 | + private function _create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM', $drop_pre_existing_tables = FALSE) { |
|
590 | + try { |
|
591 | + EEH_Activation::create_table($table_name, $table_definition_sql, $engine_string, $drop_pre_existing_tables); |
|
592 | + } catch (EE_Error $e) { |
|
593 | + $message = $e->getMessage().'<br>Stack Trace:'.$e->getTraceAsString(); |
|
594 | + $this->add_error($message); |
|
595 | 595 | $this->_feedback_message .= $message; |
596 | 596 | } |
597 | 597 | } |
@@ -603,15 +603,15 @@ discard block |
||
603 | 603 | * @return int one of EE_System::_req_type_* constants |
604 | 604 | * @throws EE_Error |
605 | 605 | */ |
606 | - private function _get_req_type_for_plugin_corresponding_to_this_dms(){ |
|
607 | - if($this->slug() == 'Core'){ |
|
606 | + private function _get_req_type_for_plugin_corresponding_to_this_dms() { |
|
607 | + if ($this->slug() == 'Core') { |
|
608 | 608 | return EE_System::instance()->detect_req_type(); |
609 | - }else{//it must be for an addon |
|
609 | + } else {//it must be for an addon |
|
610 | 610 | $addon_name = $this->slug(); |
611 | - if( EE_Registry::instance()->get_addon_by_name($addon_name)){ |
|
611 | + if (EE_Registry::instance()->get_addon_by_name($addon_name)) { |
|
612 | 612 | return EE_Registry::instance()->get_addon_by_name($addon_name)->detect_req_type(); |
613 | - }else{ |
|
614 | - throw new EE_Error(sprintf(__("The DMS slug '%s' should correspond to the addon's name, which should also be '%s', but no such addon was registered. These are the registered addons' names: %s", "event_espresso"),$this->slug(),$addon_name,implode(",",array_keys( EE_Registry::instance()->get_addons_by_name() ) ) ) ) ; |
|
613 | + } else { |
|
614 | + throw new EE_Error(sprintf(__("The DMS slug '%s' should correspond to the addon's name, which should also be '%s', but no such addon was registered. These are the registered addons' names: %s", "event_espresso"), $this->slug(), $addon_name, implode(",", array_keys(EE_Registry::instance()->get_addons_by_name())))); |
|
615 | 615 | } |
616 | 616 | } |
617 | 617 | } |
@@ -622,13 +622,13 @@ discard block |
||
622 | 622 | * returns an array of strings describing errors by all the script's stages |
623 | 623 | * @return array |
624 | 624 | */ |
625 | - public function get_errors(){ |
|
625 | + public function get_errors() { |
|
626 | 626 | $all_errors = $this->_errors; |
627 | - if( ! is_array($all_errors)){ |
|
627 | + if ( ! is_array($all_errors)) { |
|
628 | 628 | $all_errors = array(); |
629 | 629 | } |
630 | - foreach($this->stages() as $stage){ |
|
631 | - $all_errors = array_merge($stage->get_errors(),$all_errors); |
|
630 | + foreach ($this->stages() as $stage) { |
|
631 | + $all_errors = array_merge($stage->get_errors(), $all_errors); |
|
632 | 632 | } |
633 | 633 | return $all_errors; |
634 | 634 | } |
@@ -639,8 +639,8 @@ discard block |
||
639 | 639 | * Indicates whether or not this migration script should continue |
640 | 640 | * @return boolean |
641 | 641 | */ |
642 | - public function can_continue(){ |
|
643 | - return in_array($this->get_status(), EE_Data_Migration_Manager::instance()->stati_that_indicate_to_continue_single_migration_script); |
|
642 | + public function can_continue() { |
|
643 | + return in_array($this->get_status(), EE_Data_Migration_Manager::instance()->stati_that_indicate_to_continue_single_migration_script); |
|
644 | 644 | } |
645 | 645 | |
646 | 646 | |
@@ -652,8 +652,8 @@ discard block |
||
652 | 652 | * get ordered by the indexes |
653 | 653 | * @return EE_Data_Migration_Script_Stage[] |
654 | 654 | */ |
655 | - protected function stages(){ |
|
656 | - $stages = apply_filters( 'FHEE__'.get_class($this).'__stages',$this->_migration_stages ); |
|
655 | + protected function stages() { |
|
656 | + $stages = apply_filters('FHEE__'.get_class($this).'__stages', $this->_migration_stages); |
|
657 | 657 | ksort($stages); |
658 | 658 | return $stages; |
659 | 659 | } |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | * can be displayed to the user |
666 | 666 | * @return string |
667 | 667 | */ |
668 | - public function get_feedback_message(){ |
|
668 | + public function get_feedback_message() { |
|
669 | 669 | return $this->_feedback_message; |
670 | 670 | } |
671 | 671 | |
@@ -677,16 +677,16 @@ discard block |
||
677 | 677 | * possible that this class is defined when it goes to sleep, but NOT available when it |
678 | 678 | * awakes (eg, this class is part of an addon that is deactivated at some point). |
679 | 679 | */ |
680 | - public function properties_as_array(){ |
|
680 | + public function properties_as_array() { |
|
681 | 681 | $properties = parent::properties_as_array(); |
682 | 682 | $properties['_migration_stages'] = array(); |
683 | - foreach($this->_migration_stages as $migration_stage_priority => $migration_stage_class){ |
|
683 | + foreach ($this->_migration_stages as $migration_stage_priority => $migration_stage_class) { |
|
684 | 684 | $properties['_migration_stages'][$migration_stage_priority] = $migration_stage_class->properties_as_array(); |
685 | 685 | } |
686 | 686 | unset($properties['_mappings']); |
687 | 687 | |
688 | - foreach($this->_mappings as $old_table_name => $mapping_to_new_table){ |
|
689 | - foreach($mapping_to_new_table as $new_table_name => $mapping){ |
|
688 | + foreach ($this->_mappings as $old_table_name => $mapping_to_new_table) { |
|
689 | + foreach ($mapping_to_new_table as $new_table_name => $mapping) { |
|
690 | 690 | $this->_set_mapping_option($old_table_name, $new_table_name, $mapping); |
691 | 691 | } |
692 | 692 | } |
@@ -701,19 +701,19 @@ discard block |
||
701 | 701 | * @param array $array_of_properties like what's produced from properties_as_array() method |
702 | 702 | * @return void |
703 | 703 | */ |
704 | - public function instantiate_from_array_of_properties($array_of_properties){ |
|
704 | + public function instantiate_from_array_of_properties($array_of_properties) { |
|
705 | 705 | $stages_properties_arrays = $array_of_properties['_migration_stages']; |
706 | 706 | unset($array_of_properties['_migration_stages']); |
707 | 707 | unset($array_of_properties['class']); |
708 | - foreach($array_of_properties as $property_name => $property_value){ |
|
708 | + foreach ($array_of_properties as $property_name => $property_value) { |
|
709 | 709 | $this->{$property_name} = $property_value; |
710 | 710 | } |
711 | 711 | //_migration_stages are already instantiated, but have only default data |
712 | - foreach($this->_migration_stages as $stage){ |
|
713 | - $stage_data = $this->_find_migration_stage_data_with_classname(get_class($stage),$stages_properties_arrays); |
|
712 | + foreach ($this->_migration_stages as $stage) { |
|
713 | + $stage_data = $this->_find_migration_stage_data_with_classname(get_class($stage), $stages_properties_arrays); |
|
714 | 714 | //SO, if we found the stage data that was saved, use it. Otherwise, I guess the stage is new? (maybe added by |
715 | 715 | //an addon? Unlikely... not sure why it wouldn't exist, but if it doesn't just treat it like it was never started yet) |
716 | - if($stage_data){ |
|
716 | + if ($stage_data) { |
|
717 | 717 | $stage->instantiate_from_array_of_properties($stage_data); |
718 | 718 | } |
719 | 719 | } |
@@ -729,9 +729,9 @@ discard block |
||
729 | 729 | * @param array $migration_stage_data_arrays |
730 | 730 | * @return null |
731 | 731 | */ |
732 | - private function _find_migration_stage_data_with_classname($classname,$migration_stage_data_arrays){ |
|
733 | - foreach($migration_stage_data_arrays as $migration_stage_data_array){ |
|
734 | - if(isset($migration_stage_data_array['class']) && $migration_stage_data_array['class'] == $classname){ |
|
732 | + private function _find_migration_stage_data_with_classname($classname, $migration_stage_data_arrays) { |
|
733 | + foreach ($migration_stage_data_arrays as $migration_stage_data_array) { |
|
734 | + if (isset($migration_stage_data_array['class']) && $migration_stage_data_array['class'] == $classname) { |
|
735 | 735 | return $migration_stage_data_array; |
736 | 736 | } |
737 | 737 | } |
@@ -747,8 +747,8 @@ discard block |
||
747 | 747 | * @return array where the first key is the plugin's slug, the 2nd is the version of that plugin |
748 | 748 | * that will be updated to. Eg array('Core','4.1.0') |
749 | 749 | */ |
750 | - public final function migrates_to_version(){ |
|
751 | - return EE_Data_Migration_Manager::instance()->script_migrates_to_version( get_class( $this ) ); |
|
750 | + public final function migrates_to_version() { |
|
751 | + return EE_Data_Migration_Manager::instance()->script_migrates_to_version(get_class($this)); |
|
752 | 752 | } |
753 | 753 | |
754 | 754 | |
@@ -760,10 +760,10 @@ discard block |
||
760 | 760 | * Or 'Core' for core (non-addon). |
761 | 761 | * @return string |
762 | 762 | */ |
763 | - public function slug(){ |
|
763 | + public function slug() { |
|
764 | 764 | $migrates_to_version_info = $this->migrates_to_version(); |
765 | 765 | //the slug is the first part of the array |
766 | - return $migrates_to_version_info[ 'slug' ]; |
|
766 | + return $migrates_to_version_info['slug']; |
|
767 | 767 | } |
768 | 768 | |
769 | 769 | |
@@ -777,7 +777,7 @@ discard block |
||
777 | 777 | * the database up so it can run), then you can set "A" to priority 3 or something. |
778 | 778 | * @return int |
779 | 779 | */ |
780 | - public function priority(){ |
|
780 | + public function priority() { |
|
781 | 781 | return $this->_priority; |
782 | 782 | } |
783 | 783 | |
@@ -790,18 +790,18 @@ discard block |
||
790 | 790 | * @param boolean $migrating |
791 | 791 | * @return void |
792 | 792 | */ |
793 | - public function set_migrating( $migrating = TRUE ){ |
|
793 | + public function set_migrating($migrating = TRUE) { |
|
794 | 794 | $this->_migrating = $migrating; |
795 | 795 | } |
796 | 796 | |
797 | 797 | /** |
798 | 798 | * Marks that we think this migration class can continue to migrate |
799 | 799 | */ |
800 | - public function reattempt(){ |
|
800 | + public function reattempt() { |
|
801 | 801 | parent::reattempt(); |
802 | 802 | //also, we want to reattempt any stages that were marked as borked |
803 | - foreach( $this->stages() as $stage ) { |
|
804 | - if( $stage->is_broken() ) { |
|
803 | + foreach ($this->stages() as $stage) { |
|
804 | + if ($stage->is_broken()) { |
|
805 | 805 | $stage->reattempt(); |
806 | 806 | } |
807 | 807 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * really, you're best off copying the whole thing when 4.1 is released into this file |
21 | 21 | * and wrapping its declaration in if( ! class_exists()){...} |
22 | 22 | */ |
23 | -class EE_DMS_Core_4_1_0 extends EE_Data_Migration_Script_Base{ |
|
23 | +class EE_DMS_Core_4_1_0 extends EE_Data_Migration_Script_Base { |
|
24 | 24 | |
25 | 25 | |
26 | 26 | |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param TableAnalysis $table_analysis |
32 | 32 | * @throws \EE_Error |
33 | 33 | */ |
34 | - public function __construct( TableManager $table_manager = null, TableAnalysis $table_analysis = null ) { |
|
34 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) { |
|
35 | 35 | $this->_load_script_stages(); |
36 | 36 | $this->_pretty_name = __("Data Migration to Event Espresso 4.1.0P", "event_espresso"); |
37 | 37 | $this->_priority = 10; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | new EE_DMS_4_1_0_answers(), |
55 | 55 | new EE_DMS_4_1_0_checkins(), |
56 | 56 | ); |
57 | - parent::__construct( $table_manager, $table_analysis ); |
|
57 | + parent::__construct($table_manager, $table_analysis); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | |
@@ -65,27 +65,27 @@ discard block |
||
65 | 65 | * @global wpdb $wpdb |
66 | 66 | * @return boolean |
67 | 67 | */ |
68 | - private function _checkin_table_exists(){ |
|
68 | + private function _checkin_table_exists() { |
|
69 | 69 | global $wpdb; |
70 | 70 | $results = $wpdb->get_results("SHOW TABLES LIKE '".$wpdb->prefix."events_attendee_checkin"."'"); |
71 | - if($results){ |
|
71 | + if ($results) { |
|
72 | 72 | return true; |
73 | - }else{ |
|
73 | + } else { |
|
74 | 74 | return false; |
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
78 | 78 | public function can_migrate_from_version($version_array) { |
79 | 79 | $version_string = $version_array['Core']; |
80 | - if($version_string < '4.0.0' && $version_string > '3.1.26' ){ |
|
80 | + if ($version_string < '4.0.0' && $version_string > '3.1.26') { |
|
81 | 81 | // echo "$version_string can be migrated fro"; |
82 | 82 | return true; |
83 | - }elseif( ! $version_string ){ |
|
83 | + }elseif ( ! $version_string) { |
|
84 | 84 | // echo "no version string provided: $version_string"; |
85 | 85 | //no version string provided... this must be pre 4.1 |
86 | 86 | //because since 4.1 we're |
87 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
88 | - }else{ |
|
87 | + return false; //changed mind. dont want people thinking they should migrate yet because they cant |
|
88 | + } else { |
|
89 | 89 | // echo "$version_string doesnt apply"; |
90 | 90 | return false; |
91 | 91 | } |
@@ -95,15 +95,15 @@ discard block |
||
95 | 95 | } |
96 | 96 | public function schema_changes_before_migration() { |
97 | 97 | //relies on 4.1's EEH_Activation::create_table |
98 | - require_once( EE_HELPERS . 'EEH_Activation.helper.php' ); |
|
98 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
99 | 99 | |
100 | - $table_name='esp_answer'; |
|
101 | - $sql=" ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
100 | + $table_name = 'esp_answer'; |
|
101 | + $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
102 | 102 | REG_ID INT UNSIGNED NOT NULL, |
103 | 103 | QST_ID INT UNSIGNED NOT NULL, |
104 | 104 | ANS_value TEXT NOT NULL, |
105 | 105 | PRIMARY KEY (ANS_ID)"; |
106 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
106 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
107 | 107 | |
108 | 108 | $table_name = 'esp_attendee_meta'; |
109 | 109 | $sql = "ATTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | CNT_is_EU TINYINT(1) DEFAULT '0', |
144 | 144 | CNT_active TINYINT(1) DEFAULT '0', |
145 | 145 | PRIMARY KEY (CNT_ISO)"; |
146 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB' ); |
|
146 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
147 | 147 | |
148 | 148 | |
149 | 149 | |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | |
165 | 165 | |
166 | 166 | |
167 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB' ); |
|
167 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
168 | 168 | $table_name = 'esp_event_meta'; |
169 | 169 | $sql = " |
170 | 170 | EVTM_ID INT NOT NULL AUTO_INCREMENT, |
@@ -181,41 +181,41 @@ discard block |
||
181 | 181 | EVT_external_URL VARCHAR(200) NULL, |
182 | 182 | EVT_donations TINYINT(1) NULL, |
183 | 183 | PRIMARY KEY (EVTM_ID)"; |
184 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
184 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
185 | 185 | |
186 | 186 | |
187 | 187 | |
188 | - $table_name='esp_event_question_group'; |
|
189 | - $sql="EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
188 | + $table_name = 'esp_event_question_group'; |
|
189 | + $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
190 | 190 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
191 | 191 | QSG_ID INT UNSIGNED NOT NULL, |
192 | 192 | EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
193 | 193 | PRIMARY KEY (EQG_ID)"; |
194 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
194 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
195 | 195 | |
196 | 196 | |
197 | 197 | |
198 | - $table_name='esp_event_venue'; |
|
199 | - $sql="EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
198 | + $table_name = 'esp_event_venue'; |
|
199 | + $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
200 | 200 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
201 | 201 | VNU_ID BIGINT(20) UNSIGNED NOT NULL, |
202 | 202 | EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
203 | 203 | PRIMARY KEY (EVV_ID)"; |
204 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
204 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
205 | 205 | |
206 | 206 | |
207 | 207 | |
208 | - $table_name='esp_extra_meta'; |
|
209 | - $sql="EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
208 | + $table_name = 'esp_extra_meta'; |
|
209 | + $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
210 | 210 | OBJ_ID INT(11) DEFAULT NULL, |
211 | 211 | EXM_type VARCHAR(45) DEFAULT NULL, |
212 | 212 | EXM_key VARCHAR(45) DEFAULT NULL, |
213 | 213 | EXM_value TEXT, |
214 | 214 | PRIMARY KEY (EXM_ID)"; |
215 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
215 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
216 | 216 | |
217 | - $table_name='esp_line_item'; |
|
218 | - $sql="LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
217 | + $table_name = 'esp_line_item'; |
|
218 | + $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
219 | 219 | LIN_code VARCHAR(245) NOT NULL DEFAULT '', |
220 | 220 | TXN_ID INT(11) DEFAULT NULL, |
221 | 221 | LIN_name VARCHAR(245) NOT NULL DEFAULT '', |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | OBJ_ID INT(11) DEFAULT NULL, |
232 | 232 | OBJ_type VARCHAR(45)DEFAULT NULL, |
233 | 233 | PRIMARY KEY (LIN_ID)"; |
234 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB' ); |
|
234 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
235 | 235 | |
236 | 236 | $table_name = 'esp_message_template'; |
237 | 237 | $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | PRIMARY KEY (GRP_ID), |
259 | 259 | KEY EVT_ID (EVT_ID), |
260 | 260 | KEY MTP_user_id (MTP_user_id)"; |
261 | - $this->_table_is_new_in_this_version( $table_name, $sql, 'ENGINE=InnoDB'); |
|
261 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
262 | 262 | |
263 | 263 | |
264 | 264 | |
@@ -366,8 +366,8 @@ discard block |
||
366 | 366 | |
367 | 367 | |
368 | 368 | |
369 | - $table_name='esp_question'; |
|
370 | - $sql='QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
369 | + $table_name = 'esp_question'; |
|
370 | + $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
371 | 371 | QST_display_text TEXT NOT NULL, |
372 | 372 | QST_admin_label VARCHAR(255) NOT NULL, |
373 | 373 | QST_system VARCHAR(25) DEFAULT NULL, |
@@ -379,12 +379,12 @@ discard block |
||
379 | 379 | QST_wp_user BIGINT UNSIGNED NULL, |
380 | 380 | QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0, |
381 | 381 | PRIMARY KEY (QST_ID)'; |
382 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
382 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
383 | 383 | |
384 | - $this->_get_table_manager()->dropIndex( 'esp_question_group', 'QSG_identifier_UNIQUE' ); |
|
384 | + $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
385 | 385 | |
386 | 386 | $table_name = 'esp_question_group'; |
387 | - $sql='QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
387 | + $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
388 | 388 | QSG_name VARCHAR(255) NOT NULL, |
389 | 389 | QSG_identifier VARCHAR(100) NOT NULL, |
390 | 390 | QSG_desc TEXT NULL, |
@@ -395,27 +395,27 @@ discard block |
||
395 | 395 | QSG_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
396 | 396 | PRIMARY KEY (QSG_ID), |
397 | 397 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)'; |
398 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
398 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
399 | 399 | |
400 | 400 | |
401 | 401 | |
402 | - $table_name='esp_question_group_question'; |
|
403 | - $sql="QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
402 | + $table_name = 'esp_question_group_question'; |
|
403 | + $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
404 | 404 | QSG_ID INT UNSIGNED NOT NULL, |
405 | 405 | QST_ID INT UNSIGNED NOT NULL, |
406 | 406 | PRIMARY KEY (QGQ_ID) "; |
407 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
407 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
408 | 408 | |
409 | 409 | |
410 | 410 | |
411 | - $table_name='esp_question_option'; |
|
412 | - $sql="QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
411 | + $table_name = 'esp_question_option'; |
|
412 | + $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
413 | 413 | QSO_value VARCHAR(255) NOT NULL, |
414 | 414 | QSO_desc TEXT NOT NULL, |
415 | 415 | QST_ID INT UNSIGNED NOT NULL, |
416 | 416 | QSO_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
417 | 417 | PRIMARY KEY (QSO_ID)"; |
418 | - $this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
418 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
419 | 419 | |
420 | 420 | |
421 | 421 | |
@@ -448,8 +448,8 @@ discard block |
||
448 | 448 | |
449 | 449 | |
450 | 450 | |
451 | - $table_name='esp_checkin'; |
|
452 | - $sql="CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
451 | + $table_name = 'esp_checkin'; |
|
452 | + $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
453 | 453 | REG_ID INT(10) UNSIGNED NOT NULL, |
454 | 454 | DTT_ID INT(10) UNSIGNED NOT NULL, |
455 | 455 | CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, |
@@ -556,12 +556,12 @@ discard block |
||
556 | 556 | |
557 | 557 | global $wpdb; |
558 | 558 | $state_table = $wpdb->prefix."esp_state"; |
559 | - if ( $this->_get_table_analysis()->tableExists( $state_table ) ) { |
|
559 | + if ($this->_get_table_analysis()->tableExists($state_table)) { |
|
560 | 560 | |
561 | - $SQL = "SELECT COUNT('STA_ID') FROM " . $state_table; |
|
561 | + $SQL = "SELECT COUNT('STA_ID') FROM ".$state_table; |
|
562 | 562 | $states = $wpdb->get_var($SQL); |
563 | - if ( ! $states ) { |
|
564 | - $SQL = "INSERT INTO " . $state_table . " |
|
563 | + if ( ! $states) { |
|
564 | + $SQL = "INSERT INTO ".$state_table." |
|
565 | 565 | (STA_ID, CNT_ISO, STA_abbrev, STA_name, STA_active) VALUES |
566 | 566 | (1, 'US', 'AK', 'Alaska', 1), |
567 | 567 | (2, 'US', 'AL', 'Alabama', 1), |
@@ -648,12 +648,12 @@ discard block |
||
648 | 648 | |
649 | 649 | global $wpdb; |
650 | 650 | $country_table = $wpdb->prefix."esp_country"; |
651 | - if ( $this->_get_table_analysis()->tableExists( $country_table ) ) { |
|
651 | + if ($this->_get_table_analysis()->tableExists($country_table)) { |
|
652 | 652 | |
653 | - $SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table; |
|
653 | + $SQL = "SELECT COUNT('CNT_ISO') FROM ".$country_table; |
|
654 | 654 | $countries = $wpdb->get_var($SQL); |
655 | - if ( ! $countries ) { |
|
656 | - $SQL = "INSERT INTO " . $country_table . " |
|
655 | + if ( ! $countries) { |
|
656 | + $SQL = "INSERT INTO ".$country_table." |
|
657 | 657 | (CNT_ISO, CNT_ISO3, RGN_ID, CNT_name, CNT_cur_code, CNT_cur_single, CNT_cur_plural, CNT_cur_sign, CNT_cur_sign_b4, CNT_cur_dec_plc, CNT_tel_code, CNT_is_EU, CNT_active) VALUES |
658 | 658 | ('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0), |
659 | 659 | ('AE', 'ARE', 0, 'United Arab Emirates', 'AED', 'Dirham', 'Dirhams', 'د.إ', 1, 2, '+971', 0, 0), |
@@ -900,20 +900,20 @@ discard block |
||
900 | 900 | global $wpdb; |
901 | 901 | $price_type_table = $wpdb->prefix."esp_price_type"; |
902 | 902 | |
903 | - if ( $this->_get_table_analysis()->tableExists( $price_type_table ) ) { |
|
903 | + if ($this->_get_table_analysis()->tableExists($price_type_table)) { |
|
904 | 904 | |
905 | - $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table; |
|
906 | - $price_types_exist = $wpdb->get_var( $SQL ); |
|
905 | + $SQL = 'SELECT COUNT(PRT_ID) FROM '.$price_type_table; |
|
906 | + $price_types_exist = $wpdb->get_var($SQL); |
|
907 | 907 | |
908 | - if ( ! $price_types_exist ) { |
|
908 | + if ( ! $price_types_exist) { |
|
909 | 909 | $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES |
910 | - (1, '" . __('Base Price', 'event_espresso') . "', 1, 0, 0, 0), |
|
911 | - (2, '" . __('Percent Discount', 'event_espresso') . "', 2, 1, 20, 0), |
|
912 | - (3, '" . __('Fixed Discount', 'event_espresso') . "', 2, 0, 30, 0), |
|
913 | - (4, '" . __('Percent Surcharge', 'event_espresso') . "', 3, 1, 40, 0), |
|
914 | - (5, '" . __('Fixed Surcharge', 'event_espresso') . "', 3, 0, 50, 0);"; |
|
915 | - $SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL ); |
|
916 | - $wpdb->query( $SQL ); |
|
910 | + (1, '".__('Base Price', 'event_espresso')."', 1, 0, 0, 0), |
|
911 | + (2, '" . __('Percent Discount', 'event_espresso')."', 2, 1, 20, 0), |
|
912 | + (3, '" . __('Fixed Discount', 'event_espresso')."', 2, 0, 30, 0), |
|
913 | + (4, '" . __('Percent Surcharge', 'event_espresso')."', 3, 1, 40, 0), |
|
914 | + (5, '" . __('Fixed Surcharge', 'event_espresso')."', 3, 0, 50, 0);"; |
|
915 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL); |
|
916 | + $wpdb->query($SQL); |
|
917 | 917 | } |
918 | 918 | } |
919 | 919 | } |
@@ -933,16 +933,16 @@ discard block |
||
933 | 933 | global $wpdb; |
934 | 934 | $price_table = $wpdb->prefix."esp_price"; |
935 | 935 | |
936 | - if ( $this->_get_table_analysis()->tableExists( $price_table ) ) { |
|
936 | + if ($this->_get_table_analysis()->tableExists($price_table)) { |
|
937 | 937 | |
938 | - $SQL = 'SELECT COUNT(PRC_ID) FROM ' .$price_table; |
|
939 | - $prices_exist = $wpdb->get_var( $SQL ); |
|
938 | + $SQL = 'SELECT COUNT(PRC_ID) FROM '.$price_table; |
|
939 | + $prices_exist = $wpdb->get_var($SQL); |
|
940 | 940 | |
941 | - if ( ! $prices_exist ) { |
|
941 | + if ( ! $prices_exist) { |
|
942 | 942 | $SQL = "INSERT INTO $price_table |
943 | 943 | (PRC_ID, PRT_ID, PRC_amount, PRC_name, PRC_desc, PRC_is_default, PRC_overrides, PRC_order, PRC_deleted, PRC_parent ) VALUES |
944 | 944 | (1, 1, '0.00', 'Free Admission', '', 1, NULL, 0, 0, 0);"; |
945 | - $SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL ); |
|
945 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL); |
|
946 | 946 | $wpdb->query($SQL); |
947 | 947 | } |
948 | 948 | } |
@@ -959,34 +959,34 @@ discard block |
||
959 | 959 | |
960 | 960 | global $wpdb; |
961 | 961 | $ticket_table = $wpdb->prefix."esp_ticket"; |
962 | - if ( $this->_get_table_analysis()->tableExists( $ticket_table ) ) { |
|
962 | + if ($this->_get_table_analysis()->tableExists($ticket_table)) { |
|
963 | 963 | |
964 | - $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table; |
|
964 | + $SQL = 'SELECT COUNT(TKT_ID) FROM '.$ticket_table; |
|
965 | 965 | $tickets_exist = $wpdb->get_var($SQL); |
966 | 966 | |
967 | - if ( ! $tickets_exist ) { |
|
967 | + if ( ! $tickets_exist) { |
|
968 | 968 | $SQL = "INSERT INTO $ticket_table |
969 | 969 | ( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_deleted ) VALUES |
970 | - ( 1, 0, '" . __("Free Ticket", "event_espresso") . "', '', 100, 0, -1, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);"; |
|
971 | - $SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL ); |
|
970 | + ( 1, 0, '".__("Free Ticket", "event_espresso")."', '', 100, 0, -1, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);"; |
|
971 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL); |
|
972 | 972 | $wpdb->query($SQL); |
973 | 973 | } |
974 | 974 | } |
975 | 975 | $ticket_price_table = $wpdb->prefix."esp_ticket_price"; |
976 | 976 | |
977 | - if ( $this->_get_table_analysis()->tableExists( $ticket_price_table ) ) { |
|
977 | + if ($this->_get_table_analysis()->tableExists($ticket_price_table)) { |
|
978 | 978 | |
979 | - $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table; |
|
979 | + $SQL = 'SELECT COUNT(TKP_ID) FROM '.$ticket_price_table; |
|
980 | 980 | $ticket_prc_exist = $wpdb->get_var($SQL); |
981 | 981 | |
982 | - if ( ! $ticket_prc_exist ) { |
|
982 | + if ( ! $ticket_prc_exist) { |
|
983 | 983 | |
984 | 984 | $SQL = "INSERT INTO $ticket_price_table |
985 | 985 | ( TKP_ID, TKT_ID, PRC_ID ) VALUES |
986 | 986 | ( 1, 1, 1 ) |
987 | 987 | "; |
988 | 988 | |
989 | - $SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL ); |
|
989 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL); |
|
990 | 990 | $wpdb->query($SQL); |
991 | 991 | } |
992 | 992 | } |
@@ -999,20 +999,20 @@ discard block |
||
999 | 999 | * @param string $country_name |
1000 | 1000 | * @return array where keys are columns, values are column values |
1001 | 1001 | */ |
1002 | - public function get_or_create_country($country_name){ |
|
1003 | - if( ! $country_name ){ |
|
1002 | + public function get_or_create_country($country_name) { |
|
1003 | + if ( ! $country_name) { |
|
1004 | 1004 | throw new EE_Error(__("Could not get a country because country name is blank", "event_espresso")); |
1005 | 1005 | } |
1006 | 1006 | global $wpdb; |
1007 | 1007 | $country_table = $wpdb->prefix."esp_country"; |
1008 | - if(is_int($country_name)){ |
|
1008 | + if (is_int($country_name)) { |
|
1009 | 1009 | $country_name = $this->get_iso_from_3_1_country_id($country_name); |
1010 | 1010 | } |
1011 | 1011 | $country = $wpdb->get_row($wpdb->prepare("SELECT * FROM $country_table WHERE |
1012 | 1012 | CNT_ISO LIKE %s OR |
1013 | 1013 | CNT_ISO3 LIKE %s OR |
1014 | - CNT_name LIKE %s LIMIT 1",$country_name,$country_name,$country_name),ARRAY_A); |
|
1015 | - if( ! $country ){ |
|
1014 | + CNT_name LIKE %s LIMIT 1", $country_name, $country_name, $country_name), ARRAY_A); |
|
1015 | + if ( ! $country) { |
|
1016 | 1016 | //insert a new one then |
1017 | 1017 | $cols_n_values = array( |
1018 | 1018 | 'CNT_ISO'=> $this->_find_available_country_iso(2), |
@@ -1032,26 +1032,26 @@ discard block |
||
1032 | 1032 | 'CNT_active'=>true |
1033 | 1033 | ); |
1034 | 1034 | $data_types = array( |
1035 | - '%s',//CNT_ISO |
|
1036 | - '%s',//CNT_ISO3 |
|
1037 | - '%d',//RGN_ID |
|
1038 | - '%s',//CNT_name |
|
1039 | - '%s',//CNT_cur_code |
|
1040 | - '%s',//CNT_cur_single |
|
1041 | - '%s',//CNT_cur_plural |
|
1042 | - '%s',//CNT_cur_sign |
|
1043 | - '%d',//CNT_cur_sign_b4 |
|
1044 | - '%d',//CNT_cur_dec_plc |
|
1045 | - '%s',//CNT_cur_dec_mrk |
|
1046 | - '%s',//CNT_cur_thsnds |
|
1047 | - '%s',//CNT_tel_code |
|
1048 | - '%d',//CNT_is_EU |
|
1049 | - '%d',//CNT_active |
|
1035 | + '%s', //CNT_ISO |
|
1036 | + '%s', //CNT_ISO3 |
|
1037 | + '%d', //RGN_ID |
|
1038 | + '%s', //CNT_name |
|
1039 | + '%s', //CNT_cur_code |
|
1040 | + '%s', //CNT_cur_single |
|
1041 | + '%s', //CNT_cur_plural |
|
1042 | + '%s', //CNT_cur_sign |
|
1043 | + '%d', //CNT_cur_sign_b4 |
|
1044 | + '%d', //CNT_cur_dec_plc |
|
1045 | + '%s', //CNT_cur_dec_mrk |
|
1046 | + '%s', //CNT_cur_thsnds |
|
1047 | + '%s', //CNT_tel_code |
|
1048 | + '%d', //CNT_is_EU |
|
1049 | + '%d', //CNT_active |
|
1050 | 1050 | ); |
1051 | 1051 | $success = $wpdb->insert($country_table, |
1052 | 1052 | $cols_n_values, |
1053 | 1053 | $data_types); |
1054 | - if( ! $success){ |
|
1054 | + if ( ! $success) { |
|
1055 | 1055 | throw new EE_Error($this->_create_error_message_for_db_insertion('N/A', array('country_id'=>$country_name), $country_table, $cols_n_values, $data_types)); |
1056 | 1056 | } |
1057 | 1057 | $country = $cols_n_values; |
@@ -1063,13 +1063,13 @@ discard block |
||
1063 | 1063 | * @global type $wpdb |
1064 | 1064 | * @return string |
1065 | 1065 | */ |
1066 | - private function _find_available_country_iso($num_letters = 2){ |
|
1066 | + private function _find_available_country_iso($num_letters = 2) { |
|
1067 | 1067 | global $wpdb; |
1068 | 1068 | $country_table = $wpdb->prefix."esp_country"; |
1069 | - do{ |
|
1069 | + do { |
|
1070 | 1070 | $current_iso = strtoupper(wp_generate_password($num_letters, false)); |
1071 | - $country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM ".$country_table." WHERE CNT_ISO=%s",$current_iso)); |
|
1072 | - }while(intval($country_with_that_iso)); |
|
1071 | + $country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM ".$country_table." WHERE CNT_ISO=%s", $current_iso)); |
|
1072 | + }while (intval($country_with_that_iso)); |
|
1073 | 1073 | return $current_iso; |
1074 | 1074 | } |
1075 | 1075 | |
@@ -1080,14 +1080,14 @@ discard block |
||
1080 | 1080 | * @param string $state_name |
1081 | 1081 | * @return array where keys are columns, values are column values |
1082 | 1082 | */ |
1083 | - public function get_or_create_state($state_name,$country_name = ''){ |
|
1084 | - if( ! $state_name ){ |
|
1083 | + public function get_or_create_state($state_name, $country_name = '') { |
|
1084 | + if ( ! $state_name) { |
|
1085 | 1085 | throw new EE_Error(__("Could not get-or-create state because no state name was provided", "event_espresso")); |
1086 | 1086 | } |
1087 | - try{ |
|
1087 | + try { |
|
1088 | 1088 | $country = $this->get_or_create_country($country_name); |
1089 | 1089 | $country_iso = $country['CNT_ISO']; |
1090 | - }catch(EE_Error $e){ |
|
1090 | + } catch (EE_Error $e) { |
|
1091 | 1091 | $country_iso = $this->get_default_country_iso(); |
1092 | 1092 | } |
1093 | 1093 | global $wpdb; |
@@ -1095,24 +1095,24 @@ discard block |
||
1095 | 1095 | $state = $wpdb->get_row($wpdb->prepare("SELECT * FROM $state_table WHERE |
1096 | 1096 | (STA_abbrev LIKE %s OR |
1097 | 1097 | STA_name LIKE %s) AND |
1098 | - CNT_ISO LIKE %s LIMIT 1",$state_name,$state_name,$country_iso),ARRAY_A); |
|
1099 | - if ( ! $state){ |
|
1098 | + CNT_ISO LIKE %s LIMIT 1", $state_name, $state_name, $country_iso), ARRAY_A); |
|
1099 | + if ( ! $state) { |
|
1100 | 1100 | //insert a new one then |
1101 | 1101 | $cols_n_values = array( |
1102 | 1102 | 'CNT_ISO'=>$country_iso, |
1103 | - 'STA_abbrev'=>substr($state_name,0,6), |
|
1103 | + 'STA_abbrev'=>substr($state_name, 0, 6), |
|
1104 | 1104 | 'STA_name'=>$state_name, |
1105 | 1105 | 'STA_active'=>true |
1106 | 1106 | ); |
1107 | 1107 | $data_types = array( |
1108 | - '%s',//CNT_ISO |
|
1109 | - '%s',//STA_abbrev |
|
1110 | - '%s',//STA_name |
|
1111 | - '%d',//STA_active |
|
1108 | + '%s', //CNT_ISO |
|
1109 | + '%s', //STA_abbrev |
|
1110 | + '%s', //STA_name |
|
1111 | + '%d', //STA_active |
|
1112 | 1112 | ); |
1113 | - $success = $wpdb->insert($state_table,$cols_n_values,$data_types); |
|
1114 | - if ( ! $success ){ |
|
1115 | - throw new EE_Error($this->_create_error_message_for_db_insertion('N/A', array('state'=>$state_name,'country_id'=>$country_name), $state_table, $cols_n_values, $data_types)); |
|
1113 | + $success = $wpdb->insert($state_table, $cols_n_values, $data_types); |
|
1114 | + if ( ! $success) { |
|
1115 | + throw new EE_Error($this->_create_error_message_for_db_insertion('N/A', array('state'=>$state_name, 'country_id'=>$country_name), $state_table, $cols_n_values, $data_types)); |
|
1116 | 1116 | } |
1117 | 1117 | $state = $cols_n_values; |
1118 | 1118 | $state['STA_ID'] = $wpdb->insert_id; |
@@ -1125,21 +1125,21 @@ discard block |
||
1125 | 1125 | * @param type $timeString |
1126 | 1126 | * @return string in the php DATETIME format: "G:i" (24-hour format hour with leading zeros, a colon, and minutes with leading zeros) |
1127 | 1127 | */ |
1128 | - public function convertTimeFromAMPM($timeString){ |
|
1128 | + public function convertTimeFromAMPM($timeString) { |
|
1129 | 1129 | $matches = array(); |
1130 | - preg_match("~(\\d*):(\\d*)~",$timeString,$matches); |
|
1131 | - if( ! $matches || count($matches)<3){ |
|
1130 | + preg_match("~(\\d*):(\\d*)~", $timeString, $matches); |
|
1131 | + if ( ! $matches || count($matches) < 3) { |
|
1132 | 1132 | $hour = '00'; |
1133 | 1133 | $minutes = '00'; |
1134 | - }else{ |
|
1134 | + } else { |
|
1135 | 1135 | $hour = intval($matches[1]); |
1136 | 1136 | $minutes = $matches[2]; |
1137 | 1137 | } |
1138 | - if(strpos($timeString, 'PM') || strpos($timeString, 'pm')){ |
|
1138 | + if (strpos($timeString, 'PM') || strpos($timeString, 'pm')) { |
|
1139 | 1139 | $hour = intval($hour) + 12; |
1140 | 1140 | } |
1141 | - $hour = str_pad( "$hour", 2, '0',STR_PAD_LEFT); |
|
1142 | - $minutes = str_pad( "$minutes", 2, '0',STR_PAD_LEFT); |
|
1141 | + $hour = str_pad("$hour", 2, '0', STR_PAD_LEFT); |
|
1142 | + $minutes = str_pad("$minutes", 2, '0', STR_PAD_LEFT); |
|
1143 | 1143 | return "$hour:$minutes"; |
1144 | 1144 | } |
1145 | 1145 | |
@@ -1148,7 +1148,7 @@ discard block |
||
1148 | 1148 | * @param int $country_id |
1149 | 1149 | * @return string the country's ISO3 code |
1150 | 1150 | */ |
1151 | - public function get_iso_from_3_1_country_id($country_id){ |
|
1151 | + public function get_iso_from_3_1_country_id($country_id) { |
|
1152 | 1152 | $old_countries = array( |
1153 | 1153 | array(64, 'United States', 'US', 'USA', 1), |
1154 | 1154 | array(15, 'Australia', 'AU', 'AUS', 1), |
@@ -1374,9 +1374,9 @@ discard block |
||
1374 | 1374 | array(226, 'Zimbabwe', 'ZW', 'ZWE', 1)); |
1375 | 1375 | |
1376 | 1376 | $country_iso = 'US'; |
1377 | - foreach($old_countries as $country_array){ |
|
1377 | + foreach ($old_countries as $country_array) { |
|
1378 | 1378 | //note: index 0 is the 3.1 country ID |
1379 | - if($country_array[0] == $country_id){ |
|
1379 | + if ($country_array[0] == $country_id) { |
|
1380 | 1380 | //note: index 2 is the ISO |
1381 | 1381 | $country_iso = $country_array[2]; |
1382 | 1382 | break; |
@@ -1389,8 +1389,8 @@ discard block |
||
1389 | 1389 | * Gets the ISO3 for the |
1390 | 1390 | * @return string |
1391 | 1391 | */ |
1392 | - public function get_default_country_iso(){ |
|
1393 | - $old_org_options= get_option('events_organization_settings'); |
|
1392 | + public function get_default_country_iso() { |
|
1393 | + $old_org_options = get_option('events_organization_settings'); |
|
1394 | 1394 | $iso = $this->get_iso_from_3_1_country_id($old_org_options['organization_country']); |
1395 | 1395 | return $iso; |
1396 | 1396 | } |
@@ -1402,13 +1402,13 @@ discard block |
||
1402 | 1402 | * the event's DEFAULT payment status, or the attendee's payment status) required pre-approval. |
1403 | 1403 | * @return string STS_ID for use in 4.1 |
1404 | 1404 | */ |
1405 | - public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false){ |
|
1405 | + public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false) { |
|
1406 | 1406 | |
1407 | 1407 | //EE team can read the related discussion: https://app.asana.com/0/2400967562914/9418495544455 |
1408 | - if($this_thing_required_pre_approval){ |
|
1408 | + if ($this_thing_required_pre_approval) { |
|
1409 | 1409 | return 'RNA'; |
1410 | - }else{ |
|
1411 | - $mapping = $default_reg_stati_conversions=array( |
|
1410 | + } else { |
|
1411 | + $mapping = $default_reg_stati_conversions = array( |
|
1412 | 1412 | 'Completed'=>'RAP', |
1413 | 1413 | ''=>'RPP', |
1414 | 1414 | 'Incomplete'=>'RPP', |
@@ -1438,22 +1438,22 @@ discard block |
||
1438 | 1438 | * @param EE_Data_Migration_Script_Stage $migration_stage the stage which called this, where errors should be added |
1439 | 1439 | * @return boolean whether or not we had to do the big job of creating an image attachment |
1440 | 1440 | */ |
1441 | - public function convert_image_url_to_attachment_and_attach_to_post($guid,$new_cpt_id, EE_Data_Migration_Script_Stage $migration_stage){ |
|
1441 | + public function convert_image_url_to_attachment_and_attach_to_post($guid, $new_cpt_id, EE_Data_Migration_Script_Stage $migration_stage) { |
|
1442 | 1442 | $created_attachment_post = false; |
1443 | 1443 | $guid = $this->_get_original_guid($guid); |
1444 | - if($guid){ |
|
1444 | + if ($guid) { |
|
1445 | 1445 | //check for an existing attachment post with this guid |
1446 | 1446 | $attachment_post_id = $this->_get_image_attachment_id_by_GUID($guid); |
1447 | - if( ! $attachment_post_id){ |
|
1447 | + if ( ! $attachment_post_id) { |
|
1448 | 1448 | //post thumbnail with that GUID doesn't exist, we should create one |
1449 | 1449 | $attachment_post_id = $this->_create_image_attachment_from_GUID($guid, $migration_stage); |
1450 | 1450 | $created_attachment_post = true; |
1451 | 1451 | } |
1452 | 1452 | //double-check we actually have an attachment post |
1453 | - if( $attachment_post_id){ |
|
1454 | - update_post_meta($new_cpt_id,'_thumbnail_id',$attachment_post_id); |
|
1455 | - }else{ |
|
1456 | - $migration_stage->add_error(sprintf(__("Could not update event image %s for CPT with ID %d, but attachments post ID is %d", "event_espresso"),$guid,$new_cpt_id,$attachment_post_id)); |
|
1453 | + if ($attachment_post_id) { |
|
1454 | + update_post_meta($new_cpt_id, '_thumbnail_id', $attachment_post_id); |
|
1455 | + } else { |
|
1456 | + $migration_stage->add_error(sprintf(__("Could not update event image %s for CPT with ID %d, but attachments post ID is %d", "event_espresso"), $guid, $new_cpt_id, $attachment_post_id)); |
|
1457 | 1457 | } |
1458 | 1458 | } |
1459 | 1459 | return $created_attachment_post; |
@@ -1467,13 +1467,13 @@ discard block |
||
1467 | 1467 | * @param string $guid_in_old_event |
1468 | 1468 | * @return string either the original guid, or $guid_in_old_event if we couldn't figure out what the original was |
1469 | 1469 | */ |
1470 | - private function _get_original_guid($guid_in_old_event){ |
|
1471 | - $original_guid = preg_replace('~-\d*x\d*\.~','.',$guid_in_old_event,1); |
|
1470 | + private function _get_original_guid($guid_in_old_event) { |
|
1471 | + $original_guid = preg_replace('~-\d*x\d*\.~', '.', $guid_in_old_event, 1); |
|
1472 | 1472 | //do a head request to verify the file exists |
1473 | 1473 | $head_response = wp_remote_head($original_guid); |
1474 | - if( ! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK'){ |
|
1474 | + if ( ! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') { |
|
1475 | 1475 | return $original_guid; |
1476 | - }else{ |
|
1476 | + } else { |
|
1477 | 1477 | return $guid_in_old_event; |
1478 | 1478 | } |
1479 | 1479 | } |
@@ -1485,32 +1485,32 @@ discard block |
||
1485 | 1485 | * @param EE_Data_Migration_Script_Stage $migration_stage |
1486 | 1486 | * @return int |
1487 | 1487 | */ |
1488 | - private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage){ |
|
1489 | - if ( ! $guid){ |
|
1488 | + private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage) { |
|
1489 | + if ( ! $guid) { |
|
1490 | 1490 | $migration_stage->add_error(sprintf(__("Cannot create image attachment for a blank GUID!", "event_espresso"))); |
1491 | 1491 | return 0; |
1492 | 1492 | } |
1493 | - $wp_filetype = wp_check_filetype(basename($guid), null ); |
|
1493 | + $wp_filetype = wp_check_filetype(basename($guid), null); |
|
1494 | 1494 | $wp_upload_dir = wp_upload_dir(); |
1495 | 1495 | //if the file is located remotely, download it to our uploads DIR, because wp_genereate_attachmnet_metadata needs the file to be local |
1496 | - if(strpos($guid,$wp_upload_dir['url']) === FALSE){ |
|
1496 | + if (strpos($guid, $wp_upload_dir['url']) === FALSE) { |
|
1497 | 1497 | //image is located remotely. download it and place it in the uploads directory |
1498 | - if( ! is_readable($guid)){ |
|
1499 | - $migration_stage->add_error(sprintf(__("Could not create image attachment from non-existent file: %s", "event_espresso"),$guid)); |
|
1498 | + if ( ! is_readable($guid)) { |
|
1499 | + $migration_stage->add_error(sprintf(__("Could not create image attachment from non-existent file: %s", "event_espresso"), $guid)); |
|
1500 | 1500 | return 0; |
1501 | 1501 | } |
1502 | - $contents= file_get_contents($guid); |
|
1503 | - if($contents === FALSE){ |
|
1504 | - $migration_stage->add_error(sprintf(__("Could not read image at %s, and therefore couldnt create an attachment post for it.", "event_espresso"),$guid)); |
|
1502 | + $contents = file_get_contents($guid); |
|
1503 | + if ($contents === FALSE) { |
|
1504 | + $migration_stage->add_error(sprintf(__("Could not read image at %s, and therefore couldnt create an attachment post for it.", "event_espresso"), $guid)); |
|
1505 | 1505 | return false; |
1506 | 1506 | } |
1507 | - $local_filepath = $wp_upload_dir['path'].DS.basename($guid); |
|
1507 | + $local_filepath = $wp_upload_dir['path'].DS.basename($guid); |
|
1508 | 1508 | $savefile = fopen($local_filepath, 'w'); |
1509 | 1509 | fwrite($savefile, $contents); |
1510 | 1510 | fclose($savefile); |
1511 | - $guid = str_replace($wp_upload_dir['path'],$wp_upload_dir['url'],$local_filepath); |
|
1512 | - }else{ |
|
1513 | - $local_filepath = str_replace($wp_upload_dir['url'],$wp_upload_dir['path'],$guid); |
|
1511 | + $guid = str_replace($wp_upload_dir['path'], $wp_upload_dir['url'], $local_filepath); |
|
1512 | + } else { |
|
1513 | + $local_filepath = str_replace($wp_upload_dir['url'], $wp_upload_dir['path'], $guid); |
|
1514 | 1514 | } |
1515 | 1515 | |
1516 | 1516 | $attachment = array( |
@@ -1520,24 +1520,24 @@ discard block |
||
1520 | 1520 | 'post_content' => '', |
1521 | 1521 | 'post_status' => 'inherit' |
1522 | 1522 | ); |
1523 | - $attach_id = wp_insert_attachment( $attachment, $guid ); |
|
1524 | - if( ! $attach_id ){ |
|
1525 | - $migration_stage->add_error(sprintf(__("Could not create image attachment post from image '%s'. Attachment data was %s.", "event_espresso"),$guid,$this->_json_encode($attachment))); |
|
1523 | + $attach_id = wp_insert_attachment($attachment, $guid); |
|
1524 | + if ( ! $attach_id) { |
|
1525 | + $migration_stage->add_error(sprintf(__("Could not create image attachment post from image '%s'. Attachment data was %s.", "event_espresso"), $guid, $this->_json_encode($attachment))); |
|
1526 | 1526 | return $attach_id; |
1527 | 1527 | } |
1528 | 1528 | |
1529 | 1529 | // you must first include the image.php file |
1530 | 1530 | // for the function wp_generate_attachment_metadata() to work |
1531 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
1531 | + require_once(ABSPATH.'wp-admin/includes/image.php'); |
|
1532 | 1532 | |
1533 | - $attach_data = wp_generate_attachment_metadata( $attach_id, $local_filepath ); |
|
1534 | - if( ! $attach_data){ |
|
1535 | - $migration_stage->add_error(sprintf(__("Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.", "event_espresso"),$attach_id,$local_filepath,$guid)); |
|
1533 | + $attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath); |
|
1534 | + if ( ! $attach_data) { |
|
1535 | + $migration_stage->add_error(sprintf(__("Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.", "event_espresso"), $attach_id, $local_filepath, $guid)); |
|
1536 | 1536 | return $attach_id; |
1537 | 1537 | } |
1538 | - $metadata_save_result = wp_update_attachment_metadata( $attach_id, $attach_data ); |
|
1539 | - if( ! $metadata_save_result ){ |
|
1540 | - $migration_stage->add_error(sprintf(__("Could not update attachment metadata for attachment %d with data %s", "event_espresso"),$attach_id,$this->_json_encode($attach_data))); |
|
1538 | + $metadata_save_result = wp_update_attachment_metadata($attach_id, $attach_data); |
|
1539 | + if ( ! $metadata_save_result) { |
|
1540 | + $migration_stage->add_error(sprintf(__("Could not update attachment metadata for attachment %d with data %s", "event_espresso"), $attach_id, $this->_json_encode($attach_data))); |
|
1541 | 1541 | } |
1542 | 1542 | return $attach_id; |
1543 | 1543 | } |
@@ -1549,9 +1549,9 @@ discard block |
||
1549 | 1549 | * @param string $guid |
1550 | 1550 | * @return int |
1551 | 1551 | */ |
1552 | - private function _get_image_attachment_id_by_GUID($guid){ |
|
1552 | + private function _get_image_attachment_id_by_GUID($guid) { |
|
1553 | 1553 | global $wpdb; |
1554 | - $attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1",$guid)); |
|
1554 | + $attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1", $guid)); |
|
1555 | 1555 | return $attachment_id; |
1556 | 1556 | } |
1557 | 1557 | /** |
@@ -1563,20 +1563,20 @@ discard block |
||
1563 | 1563 | * @param string $timezone |
1564 | 1564 | * @return string |
1565 | 1565 | */ |
1566 | - public function convert_date_string_to_utc(EE_Data_Migration_Script_Stage $stage, $row_of_data, $DATETIME_string,$timezone = null){ |
|
1566 | + public function convert_date_string_to_utc(EE_Data_Migration_Script_Stage $stage, $row_of_data, $DATETIME_string, $timezone = null) { |
|
1567 | 1567 | $original_tz = $timezone; |
1568 | - if( ! $timezone){ |
|
1568 | + if ( ! $timezone) { |
|
1569 | 1569 | $timezone = $this->_get_wp_timezone(); |
1570 | 1570 | } |
1571 | - if( ! $timezone){ |
|
1572 | - $stage->add_error(sprintf(__("Could not find timezone given %s for %s", "event_espresso"),$original_tz,$row_of_data)); |
|
1571 | + if ( ! $timezone) { |
|
1572 | + $stage->add_error(sprintf(__("Could not find timezone given %s for %s", "event_espresso"), $original_tz, $row_of_data)); |
|
1573 | 1573 | $timezone = 'UTC'; |
1574 | 1574 | } |
1575 | - try{ |
|
1576 | - $date_obj = new DateTime( $DATETIME_string, new DateTimeZone( $timezone ) ); |
|
1575 | + try { |
|
1576 | + $date_obj = new DateTime($DATETIME_string, new DateTimeZone($timezone)); |
|
1577 | 1577 | $date_obj->setTimezone(new DateTimeZone('UTC')); |
1578 | - }catch(Exception $e){ |
|
1579 | - $stage->add_error(sprintf(__("Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.", "event_espresso"),$DATETIME_string,$timezone)); |
|
1578 | + } catch (Exception $e) { |
|
1579 | + $stage->add_error(sprintf(__("Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.", "event_espresso"), $DATETIME_string, $timezone)); |
|
1580 | 1580 | $date_obj = new DateTime(); |
1581 | 1581 | } |
1582 | 1582 | |
@@ -1587,14 +1587,14 @@ discard block |
||
1587 | 1587 | * Gets the DEFAULT timezone string from wordpress (even if they set a gmt offset) |
1588 | 1588 | * @return string |
1589 | 1589 | */ |
1590 | - private function _get_wp_timezone(){ |
|
1591 | - $timezone = empty( $timezone ) ? get_option('timezone_string') : $timezone; |
|
1590 | + private function _get_wp_timezone() { |
|
1591 | + $timezone = empty($timezone) ? get_option('timezone_string') : $timezone; |
|
1592 | 1592 | |
1593 | 1593 | //if timezone is STILL empty then let's get the GMT offset and then set the timezone_string using our converter |
1594 | - if ( empty( $timezone ) ) { |
|
1594 | + if (empty($timezone)) { |
|
1595 | 1595 | //let's get a the WordPress UTC offset |
1596 | 1596 | $offset = get_option('gmt_offset'); |
1597 | - $timezone = $this->timezone_convert_to_string_from_offset( $offset ); |
|
1597 | + $timezone = $this->timezone_convert_to_string_from_offset($offset); |
|
1598 | 1598 | } |
1599 | 1599 | return $timezone; |
1600 | 1600 | } |
@@ -1603,11 +1603,11 @@ discard block |
||
1603 | 1603 | * @param int $offset |
1604 | 1604 | * @return boolean |
1605 | 1605 | */ |
1606 | - private function timezone_convert_to_string_from_offset($offset){ |
|
1606 | + private function timezone_convert_to_string_from_offset($offset) { |
|
1607 | 1607 | //shamelessly taken from bottom comment at http://ca1.php.net/manual/en/function.timezone-name-from-abbr.php because timezone_name_from_abbr() did NOT work as expected - its not reliable |
1608 | 1608 | $offset *= 3600; // convert hour offset to seconds |
1609 | 1609 | $abbrarray = timezone_abbreviations_list(); |
1610 | - foreach ($abbrarray as $abbr){ |
|
1610 | + foreach ($abbrarray as $abbr) { |
|
1611 | 1611 | foreach ($abbr as $city) |
1612 | 1612 | { |
1613 | 1613 | if ($city['offset'] == $offset) |
@@ -1621,32 +1621,32 @@ discard block |
||
1621 | 1621 | return FALSE; |
1622 | 1622 | } |
1623 | 1623 | |
1624 | - public function migration_page_hooks(){ |
|
1625 | - add_filter('FHEE__ee_migration_page__header',array($this,'_migrate_page_hook_simplify_version_strings'),10,3); |
|
1626 | - add_filter('FHEE__ee_migration_page__p_after_header',array($this,'_migration_page_hook_simplify_next_db_state'),10,2); |
|
1627 | - add_filter('FHEE__ee_migration_page__option_1_main',array($this,'_migrate_page_hook_simplify_version_strings'),10,3); |
|
1628 | - add_filter('FHEE__ee_migration_page__option_1_button_text',array($this,'_migrate_page_hook_simplify_version_strings'),10,3); |
|
1629 | - add_action('AHEE__ee_migration_page__option_1_extra_details',array($this,'_migration_page_hook_option_1_extra_details'),10,3); |
|
1630 | - add_filter('FHEE__ee_migration_page__option_2_main',array($this,'_migrate_page_hook_simplify_version_strings'),10,4); |
|
1631 | - add_filter('FHEE__ee_migration_page__option_2_button_text',array($this,'_migration_page_hook_simplify_next_db_state'),10,2); |
|
1632 | - add_filter('FHEE__ee_migration_page__option_2_details',array($this,'_migration_page_hook_simplify_next_db_state'),10,2); |
|
1633 | - add_action('AHEE__ee_migration_page__after_migration_options_table',array($this,'_migration_page_hook_after_migration_options_table')); |
|
1634 | - add_filter('FHEE__ee_migration_page__done_migration_header',array($this,'_migration_page_hook_simplify_next_db_state'),10,2); |
|
1635 | - add_filter('FHEE__ee_migration_page__p_after_done_migration_header',array($this,'_migration_page_hook_simplify_next_db_state'),10,2); |
|
1624 | + public function migration_page_hooks() { |
|
1625 | + add_filter('FHEE__ee_migration_page__header', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 3); |
|
1626 | + add_filter('FHEE__ee_migration_page__p_after_header', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2); |
|
1627 | + add_filter('FHEE__ee_migration_page__option_1_main', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 3); |
|
1628 | + add_filter('FHEE__ee_migration_page__option_1_button_text', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 3); |
|
1629 | + add_action('AHEE__ee_migration_page__option_1_extra_details', array($this, '_migration_page_hook_option_1_extra_details'), 10, 3); |
|
1630 | + add_filter('FHEE__ee_migration_page__option_2_main', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 4); |
|
1631 | + add_filter('FHEE__ee_migration_page__option_2_button_text', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2); |
|
1632 | + add_filter('FHEE__ee_migration_page__option_2_details', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2); |
|
1633 | + add_action('AHEE__ee_migration_page__after_migration_options_table', array($this, '_migration_page_hook_after_migration_options_table')); |
|
1634 | + add_filter('FHEE__ee_migration_page__done_migration_header', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2); |
|
1635 | + add_filter('FHEE__ee_migration_page__p_after_done_migration_header', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2); |
|
1636 | 1636 | } |
1637 | 1637 | |
1638 | - public function _migrate_page_hook_simplify_version_strings($old_content,$current_db_state,$next_db_state,$ultimate_db_state = NULL){ |
|
1639 | - return str_replace(array($current_db_state,$next_db_state,$ultimate_db_state),array(__('EE3','event_espresso'),__('EE4','event_espresso'), __("EE4", 'event_espresso')),$old_content); |
|
1638 | + public function _migrate_page_hook_simplify_version_strings($old_content, $current_db_state, $next_db_state, $ultimate_db_state = NULL) { |
|
1639 | + return str_replace(array($current_db_state, $next_db_state, $ultimate_db_state), array(__('EE3', 'event_espresso'), __('EE4', 'event_espresso'), __("EE4", 'event_espresso')), $old_content); |
|
1640 | 1640 | } |
1641 | - public function _migration_page_hook_simplify_next_db_state($old_content,$next_db_state){ |
|
1642 | - return str_replace($next_db_state, __("EE4", 'event_espresso'),$old_content); |
|
1641 | + public function _migration_page_hook_simplify_next_db_state($old_content, $next_db_state) { |
|
1642 | + return str_replace($next_db_state, __("EE4", 'event_espresso'), $old_content); |
|
1643 | 1643 | } |
1644 | - public function _migration_page_hook_option_1_extra_details(){ |
|
1645 | - ?><p><?php printf(__("Note: many of your EE3 shortcodes will be changed to EE4 shortcodes during this migration (among many other things). Should you revert to EE3, then you should restore to your backup or manually change the EE4 shortcodes back to their EE3 equivalents", "event_espresso"));?></p><?php |
|
1644 | + public function _migration_page_hook_option_1_extra_details() { |
|
1645 | + ?><p><?php printf(__("Note: many of your EE3 shortcodes will be changed to EE4 shortcodes during this migration (among many other things). Should you revert to EE3, then you should restore to your backup or manually change the EE4 shortcodes back to their EE3 equivalents", "event_espresso")); ?></p><?php |
|
1646 | 1646 | } |
1647 | - public function _migration_page_hook_after_migration_options_table(){ |
|
1647 | + public function _migration_page_hook_after_migration_options_table() { |
|
1648 | 1648 | ?><p class="ee-attention"> |
1649 | - <strong><span class="reminder-spn"><?php _e("Important note to those using Event Espresso 3 addons: ", "event_espresso");?></span></strong><br/><?php _e("Unless an addon's description on our website explicitly states that it is compatible with EE4, you should consider it incompatible and know that it WILL NOT WORK correctly with this new version of Event Espresso 4 (EE4). As well, any data for incompatible addons will NOT BE MIGRATED until an updated EE4 compatible version of the addon is available. If you want, or need to keep using your EE3 addons, you should simply continue using EE3 until EE4 compatible versions of your addons become available. To continue using EE3 for now, just deactivate EE4 and reactivate EE3.", "event_espresso"); ?> |
|
1649 | + <strong><span class="reminder-spn"><?php _e("Important note to those using Event Espresso 3 addons: ", "event_espresso"); ?></span></strong><br/><?php _e("Unless an addon's description on our website explicitly states that it is compatible with EE4, you should consider it incompatible and know that it WILL NOT WORK correctly with this new version of Event Espresso 4 (EE4). As well, any data for incompatible addons will NOT BE MIGRATED until an updated EE4 compatible version of the addon is available. If you want, or need to keep using your EE3 addons, you should simply continue using EE3 until EE4 compatible versions of your addons become available. To continue using EE3 for now, just deactivate EE4 and reactivate EE3.", "event_espresso"); ?> |
|
1650 | 1650 | </p><?php |
1651 | 1651 | } |
1652 | 1652 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @author Mike Nelson, Brent Christensen |
17 | 17 | * @since 4.7.0 |
18 | 18 | */ |
19 | -class EE_DMS_Core_4_7_0 extends EE_Data_Migration_Script_Base{ |
|
19 | +class EE_DMS_Core_4_7_0 extends EE_Data_Migration_Script_Base { |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * return EE_DMS_Core_4_7_0 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @param TableAnalysis $table_analysis |
26 | 26 | * @throws \EE_Error |
27 | 27 | */ |
28 | - public function __construct( TableManager $table_manager = null, TableAnalysis $table_analysis = null ) { |
|
28 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) { |
|
29 | 29 | $this->_load_script_stages(); |
30 | 30 | $this->_pretty_name = __("Data Migration to Event Espresso 4.7.0.p", "event_espresso"); |
31 | 31 | $this->_priority = 10; |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | new EE_DMS_4_7_0_Add_Taxes_To_REG_Final_Price(), |
34 | 34 | new EE_DMS_4_7_0_Registration_Payments(), |
35 | 35 | ); |
36 | - parent::__construct( $table_manager, $table_analysis ); |
|
36 | + parent::__construct($table_manager, $table_analysis); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | |
@@ -45,15 +45,15 @@ discard block |
||
45 | 45 | public function can_migrate_from_version($version_array) { |
46 | 46 | $version_string = $version_array['Core']; |
47 | 47 | if ( |
48 | - ( $version_string <= '4.7.0' && $version_string >= '4.6.0' ) |
|
48 | + ($version_string <= '4.7.0' && $version_string >= '4.6.0') |
|
49 | 49 | || |
50 | - ( $version_string >= '4.7.0' && |
|
51 | - ! $this->_get_table_analysis()->tableExists( 'esp_registration_payment' ) && |
|
52 | - $this->_get_table_analysis()->tableExists( 'esp_registration' ) ) ) { |
|
50 | + ($version_string >= '4.7.0' && |
|
51 | + ! $this->_get_table_analysis()->tableExists('esp_registration_payment') && |
|
52 | + $this->_get_table_analysis()->tableExists('esp_registration')) ) { |
|
53 | 53 | return true; |
54 | - } elseif ( ! $version_string ) { |
|
54 | + } elseif ( ! $version_string) { |
|
55 | 55 | //no version string provided... this must be pre 4.3 |
56 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
56 | + return false; //changed mind. dont want people thinking they should migrate yet because they cant |
|
57 | 57 | } else { |
58 | 58 | return false; |
59 | 59 | } |
@@ -75,16 +75,16 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function schema_changes_before_migration() { |
77 | 77 | //relies on 4.1's EEH_Activation::create_table |
78 | - require_once( EE_HELPERS . 'EEH_Activation.helper.php' ); |
|
79 | - $table_name='esp_answer'; |
|
80 | - $sql=" ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
78 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
79 | + $table_name = 'esp_answer'; |
|
80 | + $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
81 | 81 | REG_ID INT UNSIGNED NOT NULL, |
82 | 82 | QST_ID INT UNSIGNED NOT NULL, |
83 | 83 | ANS_value TEXT NOT NULL, |
84 | 84 | PRIMARY KEY (ANS_ID), |
85 | 85 | KEY REG_ID (REG_ID), |
86 | 86 | KEY QST_ID (QST_ID)"; |
87 | - $this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
87 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
88 | 88 | |
89 | 89 | $table_name = 'esp_attendee_meta'; |
90 | 90 | $sql = "ATTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | CNT_is_EU TINYINT(1) DEFAULT '0', |
125 | 125 | CNT_active TINYINT(1) DEFAULT '0', |
126 | 126 | PRIMARY KEY (CNT_ISO)"; |
127 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB' ); |
|
127 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
128 | 128 | |
129 | 129 | $table_name = 'esp_currency'; |
130 | 130 | $sql = "CUR_code VARCHAR(6) COLLATE utf8_bin NOT NULL, |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | CUR_dec_plc VARCHAR(1) COLLATE utf8_bin NOT NULL DEFAULT '2', |
135 | 135 | CUR_active TINYINT(1) DEFAULT '0', |
136 | 136 | PRIMARY KEY (CUR_code)"; |
137 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB' ); |
|
137 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
138 | 138 | |
139 | 139 | |
140 | 140 | $table_name = 'esp_currency_payment_method'; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | KEY EVT_ID (EVT_ID), |
165 | 165 | KEY DTT_is_primary (DTT_is_primary)"; |
166 | 166 | |
167 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB' ); |
|
167 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
168 | 168 | |
169 | 169 | $table_name = 'esp_event_meta'; |
170 | 170 | $sql = " |
@@ -183,44 +183,44 @@ discard block |
||
183 | 183 | EVT_donations TINYINT(1) NULL, |
184 | 184 | PRIMARY KEY (EVTM_ID), |
185 | 185 | KEY EVT_ID (EVT_ID)"; |
186 | - $this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
186 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
187 | 187 | |
188 | 188 | |
189 | 189 | |
190 | - $table_name='esp_event_question_group'; |
|
191 | - $sql="EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
190 | + $table_name = 'esp_event_question_group'; |
|
191 | + $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
192 | 192 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
193 | 193 | QSG_ID INT UNSIGNED NOT NULL, |
194 | 194 | EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
195 | 195 | PRIMARY KEY (EQG_ID), |
196 | 196 | KEY EVT_ID (EVT_ID), |
197 | 197 | KEY QSG_ID (QSG_ID)"; |
198 | - $this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
198 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
199 | 199 | |
200 | 200 | |
201 | 201 | |
202 | - $table_name='esp_event_venue'; |
|
203 | - $sql="EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
202 | + $table_name = 'esp_event_venue'; |
|
203 | + $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
204 | 204 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
205 | 205 | VNU_ID BIGINT(20) UNSIGNED NOT NULL, |
206 | 206 | EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
207 | 207 | PRIMARY KEY (EVV_ID)"; |
208 | - $this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB'); |
|
208 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
209 | 209 | |
210 | 210 | |
211 | 211 | |
212 | - $table_name='esp_extra_meta'; |
|
213 | - $sql="EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
212 | + $table_name = 'esp_extra_meta'; |
|
213 | + $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
214 | 214 | OBJ_ID INT(11) DEFAULT NULL, |
215 | 215 | EXM_type VARCHAR(45) DEFAULT NULL, |
216 | 216 | EXM_key VARCHAR(45) DEFAULT NULL, |
217 | 217 | EXM_value TEXT, |
218 | 218 | PRIMARY KEY (EXM_ID), |
219 | 219 | KEY EXM_type (EXM_type, OBJ_ID, EXM_key(45))"; |
220 | - $this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
220 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
221 | 221 | |
222 | - $table_name='esp_line_item'; |
|
223 | - $sql="LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
222 | + $table_name = 'esp_line_item'; |
|
223 | + $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
224 | 224 | LIN_code VARCHAR(245) NOT NULL DEFAULT '', |
225 | 225 | TXN_ID INT(11) DEFAULT NULL, |
226 | 226 | LIN_name VARCHAR(245) NOT NULL DEFAULT '', |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | PRIMARY KEY (LIN_ID), |
239 | 239 | KEY LIN_code (LIN_code(191)), |
240 | 240 | KEY TXN_ID (TXN_ID)"; |
241 | - $this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB' ); |
|
241 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
242 | 242 | |
243 | 243 | $table_name = 'esp_log'; |
244 | 244 | $sql = "LOG_ID INT(11) NOT NULL AUTO_INCREMENT, |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | MTP_is_active TINYINT(1) NOT NULL DEFAULT '1', |
279 | 279 | PRIMARY KEY (GRP_ID), |
280 | 280 | KEY MTP_user_id (MTP_user_id)"; |
281 | - $this->_table_has_not_changed_since_previous( $table_name, $sql, 'ENGINE=InnoDB'); |
|
281 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
282 | 282 | |
283 | 283 | $table_name = 'esp_event_message_template'; |
284 | 284 | $sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | PRIMARY KEY (EMT_ID), |
288 | 288 | KEY EVT_ID (EVT_ID), |
289 | 289 | KEY GRP_ID (GRP_ID)"; |
290 | - $this->_table_has_not_changed_since_previous( $table_name, $sql, 'ENGINE=InnoDB'); |
|
290 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
291 | 291 | |
292 | 292 | |
293 | 293 | $table_name = 'esp_payment'; |
@@ -360,8 +360,8 @@ discard block |
||
360 | 360 | PRIMARY KEY (TTM_ID)"; |
361 | 361 | $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
362 | 362 | |
363 | - $table_name='esp_question'; |
|
364 | - $sql='QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
363 | + $table_name = 'esp_question'; |
|
364 | + $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
365 | 365 | QST_display_text TEXT NOT NULL, |
366 | 366 | QST_admin_label VARCHAR(255) NOT NULL, |
367 | 367 | QST_system VARCHAR(25) DEFAULT NULL, |
@@ -374,22 +374,22 @@ discard block |
||
374 | 374 | QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0, |
375 | 375 | PRIMARY KEY (QST_ID), |
376 | 376 | KEY QST_order (QST_order)'; |
377 | - $this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
377 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
378 | 378 | |
379 | - $table_name='esp_question_group_question'; |
|
380 | - $sql="QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
379 | + $table_name = 'esp_question_group_question'; |
|
380 | + $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
381 | 381 | QSG_ID INT UNSIGNED NOT NULL, |
382 | 382 | QST_ID INT UNSIGNED NOT NULL, |
383 | 383 | QGQ_order INT UNSIGNED NOT NULL DEFAULT 0, |
384 | 384 | PRIMARY KEY (QGQ_ID), |
385 | 385 | KEY QST_ID (QST_ID), |
386 | 386 | KEY QSG_ID_order (QSG_ID, QGQ_order)"; |
387 | - $this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
387 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
388 | 388 | |
389 | 389 | |
390 | 390 | |
391 | - $table_name='esp_question_option'; |
|
392 | - $sql="QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
391 | + $table_name = 'esp_question_option'; |
|
392 | + $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
393 | 393 | QSO_value VARCHAR(255) NOT NULL, |
394 | 394 | QSO_desc TEXT NOT NULL, |
395 | 395 | QST_ID INT UNSIGNED NOT NULL, |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | PRIMARY KEY (QSO_ID), |
399 | 399 | KEY QST_ID (QST_ID), |
400 | 400 | KEY QSO_order (QSO_order)"; |
401 | - $this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
401 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
402 | 402 | |
403 | 403 | |
404 | 404 | |
@@ -444,8 +444,8 @@ discard block |
||
444 | 444 | |
445 | 445 | |
446 | 446 | |
447 | - $table_name='esp_checkin'; |
|
448 | - $sql="CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
447 | + $table_name = 'esp_checkin'; |
|
448 | + $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
449 | 449 | REG_ID INT(10) UNSIGNED NOT NULL, |
450 | 450 | DTT_ID INT(10) UNSIGNED NOT NULL, |
451 | 451 | CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | PRC_parent INT(10) UNSIGNED DEFAULT 0, |
541 | 541 | PRIMARY KEY (PRC_ID), |
542 | 542 | KEY PRT_ID (PRT_ID)"; |
543 | - $this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB'); |
|
543 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
544 | 544 | |
545 | 545 | $table_name = "esp_price_type"; |
546 | 546 | $sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT, |
@@ -578,10 +578,10 @@ discard block |
||
578 | 578 | TKT_deleted TINYINT(1) NOT NULL DEFAULT '0', |
579 | 579 | PRIMARY KEY (TKT_ID), |
580 | 580 | KEY TKT_start_date (TKT_start_date)"; |
581 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB' ); |
|
581 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
582 | 582 | |
583 | 583 | $table_name = 'esp_question_group'; |
584 | - $sql='QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
584 | + $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
585 | 585 | QSG_name VARCHAR(255) NOT NULL, |
586 | 586 | QSG_identifier VARCHAR(100) NOT NULL, |
587 | 587 | QSG_desc TEXT NULL, |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | PRIMARY KEY (QSG_ID), |
595 | 595 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
596 | 596 | KEY QSG_order (QSG_order)'; |
597 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB' ); |
|
597 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
598 | 598 | |
599 | 599 | /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
600 | 600 | $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | return true; |
627 | 627 | } |
628 | 628 | |
629 | - public function migration_page_hooks(){ |
|
629 | + public function migration_page_hooks() { |
|
630 | 630 | |
631 | 631 | } |
632 | 632 | } |
@@ -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 |
@@ -143,54 +143,54 @@ discard block |
||
143 | 143 | * @type EE_Validation_Strategy_Base[] $validation_strategies |
144 | 144 | * } |
145 | 145 | */ |
146 | - public function __construct( $input_args = array() ){ |
|
147 | - $input_args = (array) apply_filters( 'FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this ); |
|
146 | + public function __construct($input_args = array()) { |
|
147 | + $input_args = (array) apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this); |
|
148 | 148 | // the following properties must be cast as arrays |
149 | - if ( isset( $input_args['validation_strategies'] ) ) { |
|
150 | - foreach ( (array) $input_args['validation_strategies'] as $validation_strategy ) { |
|
151 | - if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
|
152 | - $this->_validation_strategies[ get_class( $validation_strategy ) ] = $validation_strategy; |
|
149 | + if (isset($input_args['validation_strategies'])) { |
|
150 | + foreach ((array) $input_args['validation_strategies'] as $validation_strategy) { |
|
151 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
152 | + $this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy; |
|
153 | 153 | } |
154 | 154 | } |
155 | - unset( $input_args['validation_strategies'] ); |
|
155 | + unset($input_args['validation_strategies']); |
|
156 | 156 | } |
157 | 157 | // loop thru incoming options |
158 | - foreach( (array)$input_args as $key => $value ) { |
|
158 | + foreach ((array) $input_args as $key => $value) { |
|
159 | 159 | // add underscore to $key to match property names |
160 | - $_key = '_' . $key; |
|
161 | - if ( property_exists( $this, $_key )) { |
|
160 | + $_key = '_'.$key; |
|
161 | + if (property_exists($this, $_key)) { |
|
162 | 162 | $this->{$_key} = $value; |
163 | 163 | } |
164 | 164 | } |
165 | 165 | // ensure that "required" is set correctly |
166 | 166 | $this->set_required( |
167 | - $this->_required, isset( $input_args[ 'required_validation_error_message' ] ) |
|
168 | - ? $input_args[ 'required_validation_error_message' ] |
|
167 | + $this->_required, isset($input_args['required_validation_error_message']) |
|
168 | + ? $input_args['required_validation_error_message'] |
|
169 | 169 | : null |
170 | 170 | ); |
171 | 171 | |
172 | 172 | //$this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE; |
173 | 173 | |
174 | 174 | $this->_display_strategy->_construct_finalize($this); |
175 | - foreach( $this->_validation_strategies as $validation_strategy ){ |
|
175 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
176 | 176 | $validation_strategy->_construct_finalize($this); |
177 | 177 | } |
178 | 178 | |
179 | - if( ! $this->_normalization_strategy){ |
|
179 | + if ( ! $this->_normalization_strategy) { |
|
180 | 180 | $this->_normalization_strategy = new EE_Text_Normalization(); |
181 | 181 | } |
182 | 182 | $this->_normalization_strategy->_construct_finalize($this); |
183 | 183 | |
184 | 184 | //at least we can use the normalization strategy to populate the default |
185 | - if( isset( $input_args[ 'default' ] ) ) { |
|
186 | - $this->set_default( $input_args[ 'default' ] ); |
|
185 | + if (isset($input_args['default'])) { |
|
186 | + $this->set_default($input_args['default']); |
|
187 | 187 | } |
188 | 188 | |
189 | - if( ! $this->_sensitive_data_removal_strategy){ |
|
189 | + if ( ! $this->_sensitive_data_removal_strategy) { |
|
190 | 190 | $this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal(); |
191 | 191 | } |
192 | 192 | $this->_sensitive_data_removal_strategy->_construct_finalize($this); |
193 | - parent::__construct( $input_args ); |
|
193 | + parent::__construct($input_args); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | |
@@ -201,11 +201,11 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @throws \EE_Error |
203 | 203 | */ |
204 | - protected function _set_default_html_name_if_empty(){ |
|
205 | - if( ! $this->_html_name){ |
|
204 | + protected function _set_default_html_name_if_empty() { |
|
205 | + if ( ! $this->_html_name) { |
|
206 | 206 | $this->_html_name = $this->name(); |
207 | - if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper){ |
|
208 | - $this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]"; |
|
207 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
208 | + $this->_html_name = $this->_parent_section->html_name_prefix()."[{$this->name()}]"; |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 | } |
@@ -220,10 +220,10 @@ discard block |
||
220 | 220 | public function _construct_finalize($parent_form_section, $name) { |
221 | 221 | parent::_construct_finalize($parent_form_section, $name); |
222 | 222 | $this->_set_default_html_name_if_empty(); |
223 | - if( $this->_html_label === null && $this->_html_label_text === null ){ |
|
224 | - $this->_html_label_text = ucwords( str_replace("_"," ",$name)); |
|
223 | + if ($this->_html_label === null && $this->_html_label_text === null) { |
|
224 | + $this->_html_label_text = ucwords(str_replace("_", " ", $name)); |
|
225 | 225 | } |
226 | - do_action( 'AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name ); |
|
226 | + do_action('AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
@@ -231,8 +231,8 @@ discard block |
||
231 | 231 | * @return EE_Display_Strategy_Base |
232 | 232 | * @throws EE_Error |
233 | 233 | */ |
234 | - protected function _get_display_strategy(){ |
|
235 | - if( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base){ |
|
234 | + protected function _get_display_strategy() { |
|
235 | + if ( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) { |
|
236 | 236 | throw new EE_Error( |
237 | 237 | sprintf( |
238 | 238 | __( |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | $this->html_id() |
244 | 244 | ) |
245 | 245 | ); |
246 | - }else{ |
|
246 | + } else { |
|
247 | 247 | return $this->_display_strategy; |
248 | 248 | } |
249 | 249 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * Sets the display strategy. |
252 | 252 | * @param EE_Display_Strategy_Base $strategy |
253 | 253 | */ |
254 | - protected function _set_display_strategy(EE_Display_Strategy_Base $strategy){ |
|
254 | + protected function _set_display_strategy(EE_Display_Strategy_Base $strategy) { |
|
255 | 255 | $this->_display_strategy = $strategy; |
256 | 256 | } |
257 | 257 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * Sets the sanitization strategy |
260 | 260 | * @param EE_Normalization_Strategy_Base $strategy |
261 | 261 | */ |
262 | - protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy){ |
|
262 | + protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy) { |
|
263 | 263 | $this->_normalization_strategy = $strategy; |
264 | 264 | } |
265 | 265 | |
@@ -285,14 +285,14 @@ discard block |
||
285 | 285 | * Gets the display strategy for this input |
286 | 286 | * @return EE_Display_Strategy_Base |
287 | 287 | */ |
288 | - public function get_display_strategy(){ |
|
288 | + public function get_display_strategy() { |
|
289 | 289 | return $this->_display_strategy; |
290 | 290 | } |
291 | 291 | /** |
292 | 292 | * Overwrites the display strategy |
293 | 293 | * @param EE_Display_Strategy_Base $display_strategy |
294 | 294 | */ |
295 | - public function set_display_strategy($display_strategy){ |
|
295 | + public function set_display_strategy($display_strategy) { |
|
296 | 296 | $this->_display_strategy = $display_strategy; |
297 | 297 | $this->_display_strategy->_construct_finalize($this); |
298 | 298 | } |
@@ -300,14 +300,14 @@ discard block |
||
300 | 300 | * Gets the normalization strategy set on this input |
301 | 301 | * @return EE_Normalization_Strategy_Base |
302 | 302 | */ |
303 | - public function get_normalization_strategy(){ |
|
303 | + public function get_normalization_strategy() { |
|
304 | 304 | return $this->_normalization_strategy; |
305 | 305 | } |
306 | 306 | /** |
307 | 307 | * Overwrites the normalization strategy |
308 | 308 | * @param EE_Normalization_Strategy_Base $normalization_strategy |
309 | 309 | */ |
310 | - public function set_normalization_strategy($normalization_strategy){ |
|
310 | + public function set_normalization_strategy($normalization_strategy) { |
|
311 | 311 | $this->_normalization_strategy = $normalization_strategy; |
312 | 312 | $this->_normalization_strategy->_construct_finalize($this); |
313 | 313 | } |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | * Returns all teh validation strategies which apply to this field, numerically indexed |
317 | 317 | * @return EE_Validation_Strategy_Base[] |
318 | 318 | */ |
319 | - public function get_validation_strategies(){ |
|
319 | + public function get_validation_strategies() { |
|
320 | 320 | return $this->_validation_strategies; |
321 | 321 | } |
322 | 322 | |
@@ -327,8 +327,8 @@ discard block |
||
327 | 327 | * @param EE_Validation_Strategy_Base $validation_strategy |
328 | 328 | * @return void |
329 | 329 | */ |
330 | - protected function _add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ){ |
|
331 | - $validation_strategy->_construct_finalize( $this ); |
|
330 | + protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) { |
|
331 | + $validation_strategy->_construct_finalize($this); |
|
332 | 332 | $this->_validation_strategies[] = $validation_strategy; |
333 | 333 | } |
334 | 334 | |
@@ -339,8 +339,8 @@ discard block |
||
339 | 339 | * @param EE_Validation_Strategy_Base $validation_strategy |
340 | 340 | * @return void |
341 | 341 | */ |
342 | - public function add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ) { |
|
343 | - $this->_add_validation_strategy( $validation_strategy ); |
|
342 | + public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) { |
|
343 | + $this->_add_validation_strategy($validation_strategy); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | |
@@ -350,13 +350,13 @@ discard block |
||
350 | 350 | * |
351 | 351 | * @param string $validation_strategy_classname |
352 | 352 | */ |
353 | - public function remove_validation_strategy( $validation_strategy_classname ) { |
|
354 | - foreach( $this->_validation_strategies as $key => $validation_strategy ){ |
|
355 | - if( |
|
353 | + public function remove_validation_strategy($validation_strategy_classname) { |
|
354 | + foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
355 | + if ( |
|
356 | 356 | $validation_strategy instanceof $validation_strategy_classname |
357 | - || is_subclass_of( $validation_strategy, $validation_strategy_classname ) |
|
357 | + || is_subclass_of($validation_strategy, $validation_strategy_classname) |
|
358 | 358 | ) { |
359 | - unset( $this->_validation_strategies[ $key ] ); |
|
359 | + unset($this->_validation_strategies[$key]); |
|
360 | 360 | } |
361 | 361 | } |
362 | 362 | } |
@@ -369,12 +369,12 @@ discard block |
||
369 | 369 | * @param array $validation_strategy_classnames |
370 | 370 | * @return bool |
371 | 371 | */ |
372 | - public function has_validation_strategy( $validation_strategy_classnames ) { |
|
373 | - $validation_strategy_classnames = is_array( $validation_strategy_classnames ) |
|
372 | + public function has_validation_strategy($validation_strategy_classnames) { |
|
373 | + $validation_strategy_classnames = is_array($validation_strategy_classnames) |
|
374 | 374 | ? $validation_strategy_classnames |
375 | - : array( $validation_strategy_classnames ); |
|
376 | - foreach( $this->_validation_strategies as $key => $validation_strategy ){ |
|
377 | - if( in_array( $key, $validation_strategy_classnames ) ) { |
|
375 | + : array($validation_strategy_classnames); |
|
376 | + foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
377 | + if (in_array($key, $validation_strategy_classnames)) { |
|
378 | 378 | return true; |
379 | 379 | } |
380 | 380 | } |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | * Gets the HTML |
388 | 388 | * @return string |
389 | 389 | */ |
390 | - public function get_html(){ |
|
390 | + public function get_html() { |
|
391 | 391 | return $this->_parent_section->get_html_for_input($this); |
392 | 392 | } |
393 | 393 | |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | * @return string |
402 | 402 | * @throws \EE_Error |
403 | 403 | */ |
404 | - public function get_html_for_input(){ |
|
404 | + public function get_html_for_input() { |
|
405 | 405 | return $this->_get_display_strategy()->display(); |
406 | 406 | } |
407 | 407 | |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | * @return string |
412 | 412 | */ |
413 | 413 | public function html_other_attributes() { |
414 | - return ! empty( $this->_html_other_attributes ) ? ' ' . $this->_html_other_attributes : ''; |
|
414 | + return ! empty($this->_html_other_attributes) ? ' '.$this->_html_other_attributes : ''; |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | /** |
420 | 420 | * @param string $html_other_attributes |
421 | 421 | */ |
422 | - public function set_html_other_attributes( $html_other_attributes ) { |
|
422 | + public function set_html_other_attributes($html_other_attributes) { |
|
423 | 423 | $this->_html_other_attributes = $html_other_attributes; |
424 | 424 | } |
425 | 425 | |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | * according to the form section's layout strategy |
429 | 429 | * @return string |
430 | 430 | */ |
431 | - public function get_html_for_label(){ |
|
431 | + public function get_html_for_label() { |
|
432 | 432 | return $this->_parent_section->get_layout_strategy()->display_label($this); |
433 | 433 | } |
434 | 434 | /** |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | * according to the form section's layout strategy |
437 | 437 | * @return string |
438 | 438 | */ |
439 | - public function get_html_for_errors(){ |
|
439 | + public function get_html_for_errors() { |
|
440 | 440 | return $this->_parent_section->get_layout_strategy()->display_errors($this); |
441 | 441 | } |
442 | 442 | /** |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | * according to the form section's layout strategy |
445 | 445 | * @return string |
446 | 446 | */ |
447 | - public function get_html_for_help(){ |
|
447 | + public function get_html_for_help() { |
|
448 | 448 | return $this->_parent_section->get_layout_strategy()->display_help_text($this); |
449 | 449 | } |
450 | 450 | /** |
@@ -453,18 +453,18 @@ discard block |
||
453 | 453 | * @return boolean |
454 | 454 | */ |
455 | 455 | protected function _validate() { |
456 | - foreach($this->_validation_strategies as $validation_strategy){ |
|
457 | - if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
|
458 | - try{ |
|
456 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
457 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
458 | + try { |
|
459 | 459 | $validation_strategy->validate($this->normalized_value()); |
460 | - }catch(EE_Validation_Error $e){ |
|
460 | + } catch (EE_Validation_Error $e) { |
|
461 | 461 | $this->add_validation_error($e); |
462 | 462 | } |
463 | 463 | } |
464 | 464 | } |
465 | - if( $this->get_validation_errors()){ |
|
465 | + if ($this->get_validation_errors()) { |
|
466 | 466 | return false; |
467 | - }else{ |
|
467 | + } else { |
|
468 | 468 | return true; |
469 | 469 | } |
470 | 470 | } |
@@ -478,8 +478,8 @@ discard block |
||
478 | 478 | * @param string $value |
479 | 479 | * @return null|string |
480 | 480 | */ |
481 | - private function _sanitize( $value ) { |
|
482 | - return $value !== null ? stripslashes( html_entity_decode( trim( $value ) ) ) : null; |
|
481 | + private function _sanitize($value) { |
|
482 | + return $value !== null ? stripslashes(html_entity_decode(trim($value))) : null; |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | |
@@ -493,25 +493,25 @@ discard block |
||
493 | 493 | * @return boolean whether or not there was an error |
494 | 494 | * @throws \EE_Error |
495 | 495 | */ |
496 | - protected function _normalize( $req_data ) { |
|
496 | + protected function _normalize($req_data) { |
|
497 | 497 | //any existing validation errors don't apply so clear them |
498 | 498 | $this->_validation_errors = array(); |
499 | 499 | try { |
500 | - $raw_input = $this->find_form_data_for_this_section( $req_data ); |
|
500 | + $raw_input = $this->find_form_data_for_this_section($req_data); |
|
501 | 501 | //super simple sanitization for now |
502 | - if ( is_array( $raw_input )) { |
|
502 | + if (is_array($raw_input)) { |
|
503 | 503 | $raw_value = array(); |
504 | - foreach( $raw_input as $key => $value ) { |
|
505 | - $raw_value[ $key ] = $this->_sanitize( $value ); |
|
504 | + foreach ($raw_input as $key => $value) { |
|
505 | + $raw_value[$key] = $this->_sanitize($value); |
|
506 | 506 | } |
507 | - $this->_set_raw_value( $raw_value ); |
|
507 | + $this->_set_raw_value($raw_value); |
|
508 | 508 | } else { |
509 | - $this->_set_raw_value( $this->_sanitize( $raw_input ) ); |
|
509 | + $this->_set_raw_value($this->_sanitize($raw_input)); |
|
510 | 510 | } |
511 | 511 | //we want to mostly leave the input alone in case we need to re-display it to the user |
512 | - $this->_set_normalized_value( $this->_normalization_strategy->normalize( $this->raw_value() ) ); |
|
513 | - } catch ( EE_Validation_Error $e ) { |
|
514 | - $this->add_validation_error( $e ); |
|
512 | + $this->_set_normalized_value($this->_normalization_strategy->normalize($this->raw_value())); |
|
513 | + } catch (EE_Validation_Error $e) { |
|
514 | + $this->add_validation_error($e); |
|
515 | 515 | } |
516 | 516 | } |
517 | 517 | |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | /** |
521 | 521 | * @return string |
522 | 522 | */ |
523 | - public function html_name(){ |
|
523 | + public function html_name() { |
|
524 | 524 | return $this->_html_name; |
525 | 525 | } |
526 | 526 | |
@@ -529,8 +529,8 @@ discard block |
||
529 | 529 | /** |
530 | 530 | * @return string |
531 | 531 | */ |
532 | - public function html_label_id(){ |
|
533 | - return ! empty( $this->_html_label_id ) ? $this->_html_label_id : $this->_html_id . '-lbl'; |
|
532 | + public function html_label_id() { |
|
533 | + return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->_html_id.'-lbl'; |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | /** |
539 | 539 | * @return string |
540 | 540 | */ |
541 | - public function html_label_class(){ |
|
541 | + public function html_label_class() { |
|
542 | 542 | return $this->_html_label_class; |
543 | 543 | } |
544 | 544 | |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | /** |
548 | 548 | * @return string |
549 | 549 | */ |
550 | - public function html_label_style(){ |
|
550 | + public function html_label_style() { |
|
551 | 551 | return $this->_html_label_style; |
552 | 552 | } |
553 | 553 | |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | /** |
557 | 557 | * @return string |
558 | 558 | */ |
559 | - public function html_label_text(){ |
|
559 | + public function html_label_text() { |
|
560 | 560 | return $this->_html_label_text; |
561 | 561 | } |
562 | 562 | |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | /** |
566 | 566 | * @return string |
567 | 567 | */ |
568 | - public function html_help_text(){ |
|
568 | + public function html_help_text() { |
|
569 | 569 | return $this->_html_help_text; |
570 | 570 | } |
571 | 571 | |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | /** |
575 | 575 | * @return string |
576 | 576 | */ |
577 | - public function html_help_class(){ |
|
577 | + public function html_help_class() { |
|
578 | 578 | return $this->_html_help_class; |
579 | 579 | } |
580 | 580 | |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | /** |
584 | 584 | * @return string |
585 | 585 | */ |
586 | - public function html_help_style(){ |
|
586 | + public function html_help_style() { |
|
587 | 587 | return $this->_html_style; |
588 | 588 | } |
589 | 589 | /** |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | * in which case, we would have stored the malicious content to our database. |
597 | 597 | * @return string |
598 | 598 | */ |
599 | - public function raw_value(){ |
|
599 | + public function raw_value() { |
|
600 | 600 | return $this->_raw_value; |
601 | 601 | } |
602 | 602 | /** |
@@ -604,15 +604,15 @@ discard block |
||
604 | 604 | * it escapes all html entities |
605 | 605 | * @return string |
606 | 606 | */ |
607 | - public function raw_value_in_form(){ |
|
608 | - return htmlentities($this->raw_value(),ENT_QUOTES, 'UTF-8'); |
|
607 | + public function raw_value_in_form() { |
|
608 | + return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8'); |
|
609 | 609 | } |
610 | 610 | /** |
611 | 611 | * returns the value after it's been sanitized, and then converted into it's proper type |
612 | 612 | * in PHP. Eg, a string, an int, an array, |
613 | 613 | * @return mixed |
614 | 614 | */ |
615 | - public function normalized_value(){ |
|
615 | + public function normalized_value() { |
|
616 | 616 | return $this->_normalized_value; |
617 | 617 | } |
618 | 618 | |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | * the best thing to display |
623 | 623 | * @return string |
624 | 624 | */ |
625 | - public function pretty_value(){ |
|
625 | + public function pretty_value() { |
|
626 | 626 | return $this->_normalized_value; |
627 | 627 | } |
628 | 628 | /** |
@@ -641,19 +641,19 @@ discard block |
||
641 | 641 | }</code> |
642 | 642 | * @return array |
643 | 643 | */ |
644 | - public function get_jquery_validation_rules(){ |
|
644 | + public function get_jquery_validation_rules() { |
|
645 | 645 | $jquery_validation_js = array(); |
646 | 646 | $jquery_validation_rules = array(); |
647 | - foreach($this->get_validation_strategies() as $validation_strategy){ |
|
647 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
648 | 648 | $jquery_validation_rules = array_replace_recursive( |
649 | 649 | $jquery_validation_rules, |
650 | 650 | $validation_strategy->get_jquery_validation_rule_array() |
651 | 651 | ); |
652 | 652 | } |
653 | 653 | |
654 | - if(! empty($jquery_validation_rules)){ |
|
655 | - foreach( $this->get_display_strategy()->get_html_input_ids( true ) as $html_id_with_pound_sign ) { |
|
656 | - $jquery_validation_js[ $html_id_with_pound_sign ] = $jquery_validation_rules; |
|
654 | + if ( ! empty($jquery_validation_rules)) { |
|
655 | + foreach ($this->get_display_strategy()->get_html_input_ids(true) as $html_id_with_pound_sign) { |
|
656 | + $jquery_validation_js[$html_id_with_pound_sign] = $jquery_validation_rules; |
|
657 | 657 | } |
658 | 658 | } |
659 | 659 | return $jquery_validation_js; |
@@ -665,16 +665,16 @@ discard block |
||
665 | 665 | * @param mixed $value |
666 | 666 | * @return void |
667 | 667 | */ |
668 | - public function set_default($value){ |
|
669 | - $this->_set_normalized_value( $value ); |
|
670 | - $this->_set_raw_value( $value ); |
|
668 | + public function set_default($value) { |
|
669 | + $this->_set_normalized_value($value); |
|
670 | + $this->_set_raw_value($value); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | /** |
674 | 674 | * Sets the normalized value on this input |
675 | 675 | * @param mixed $value |
676 | 676 | */ |
677 | - protected function _set_normalized_value( $value ) { |
|
677 | + protected function _set_normalized_value($value) { |
|
678 | 678 | $this->_normalized_value = $value; |
679 | 679 | } |
680 | 680 | |
@@ -682,8 +682,8 @@ discard block |
||
682 | 682 | * Sets the raw value on this input (ie, exactly as the user submitted it) |
683 | 683 | * @param mixed $value |
684 | 684 | */ |
685 | - protected function _set_raw_value( $value ) { |
|
686 | - $this->_raw_value = $this->_normalization_strategy->unnormalize( $value ); |
|
685 | + protected function _set_raw_value($value) { |
|
686 | + $this->_raw_value = $this->_normalization_strategy->unnormalize($value); |
|
687 | 687 | } |
688 | 688 | |
689 | 689 | /** |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | * @param string $label |
692 | 692 | * @return void |
693 | 693 | */ |
694 | - public function set_html_label_text($label){ |
|
694 | + public function set_html_label_text($label) { |
|
695 | 695 | $this->_html_label_text = $label; |
696 | 696 | } |
697 | 697 | |
@@ -705,13 +705,13 @@ discard block |
||
705 | 705 | * @param boolean $required boolean |
706 | 706 | * @param null $required_text |
707 | 707 | */ |
708 | - public function set_required($required = true, $required_text = NULL ){ |
|
709 | - $required = filter_var( $required, FILTER_VALIDATE_BOOLEAN ); |
|
708 | + public function set_required($required = true, $required_text = NULL) { |
|
709 | + $required = filter_var($required, FILTER_VALIDATE_BOOLEAN); |
|
710 | 710 | //whether $required is a string or a boolean, we want to add a required validation strategy |
711 | - if ( $required ) { |
|
712 | - $this->_add_validation_strategy( new EE_Required_Validation_Strategy( $required_text ) ); |
|
711 | + if ($required) { |
|
712 | + $this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text)); |
|
713 | 713 | } else { |
714 | - unset( $this->_validation_strategies[ 'EE_Required_Validation_Strategy' ] ); |
|
714 | + unset($this->_validation_strategies['EE_Required_Validation_Strategy']); |
|
715 | 715 | } |
716 | 716 | $this->_required = $required; |
717 | 717 | } |
@@ -719,7 +719,7 @@ discard block |
||
719 | 719 | * Returns whether or not this field is required |
720 | 720 | * @return boolean |
721 | 721 | */ |
722 | - public function required(){ |
|
722 | + public function required() { |
|
723 | 723 | return $this->_required; |
724 | 724 | } |
725 | 725 | |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | /** |
729 | 729 | * @param string $required_css_class |
730 | 730 | */ |
731 | - public function set_required_css_class( $required_css_class ) { |
|
731 | + public function set_required_css_class($required_css_class) { |
|
732 | 732 | $this->_required_css_class = $required_css_class; |
733 | 733 | } |
734 | 734 | |
@@ -747,7 +747,7 @@ discard block |
||
747 | 747 | * Sets the help text, in case |
748 | 748 | * @param string $text |
749 | 749 | */ |
750 | - public function set_html_help_text($text){ |
|
750 | + public function set_html_help_text($text) { |
|
751 | 751 | $this->_html_help_text = $text; |
752 | 752 | } |
753 | 753 | /** |
@@ -759,9 +759,9 @@ discard block |
||
759 | 759 | public function clean_sensitive_data() { |
760 | 760 | //if we do ANY kind of sensitive data removal on this, then just clear out the raw value |
761 | 761 | //if we need more logic than this we'll make a strategy for it |
762 | - if( $this->_sensitive_data_removal_strategy && |
|
763 | - ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal ){ |
|
764 | - $this->_set_raw_value( null ); |
|
762 | + if ($this->_sensitive_data_removal_strategy && |
|
763 | + ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal) { |
|
764 | + $this->_set_raw_value(null); |
|
765 | 765 | } |
766 | 766 | //and clean the normalized value according to the appropriate strategy |
767 | 767 | $this->_set_normalized_value( |
@@ -778,10 +778,10 @@ discard block |
||
778 | 778 | * @param string $button_size |
779 | 779 | * @param string $other_attributes |
780 | 780 | */ |
781 | - public function set_button_css_attributes( $primary = TRUE, $button_size = '', $other_attributes = '' ) { |
|
781 | + public function set_button_css_attributes($primary = TRUE, $button_size = '', $other_attributes = '') { |
|
782 | 782 | $button_css_attributes = 'button'; |
783 | 783 | $button_css_attributes .= $primary === TRUE ? ' button-primary' : ' button-secondary'; |
784 | - switch ( $button_size ) { |
|
784 | + switch ($button_size) { |
|
785 | 785 | case 'xs' : |
786 | 786 | case 'extra-small' : |
787 | 787 | $button_css_attributes .= ' button-xs'; |
@@ -802,8 +802,8 @@ discard block |
||
802 | 802 | default : |
803 | 803 | $button_css_attributes .= ''; |
804 | 804 | } |
805 | - $this->_button_css_attributes .= ! empty( $other_attributes ) |
|
806 | - ? $button_css_attributes . ' ' . $other_attributes |
|
805 | + $this->_button_css_attributes .= ! empty($other_attributes) |
|
806 | + ? $button_css_attributes.' '.$other_attributes |
|
807 | 807 | : $button_css_attributes; |
808 | 808 | } |
809 | 809 | |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | * @return string |
814 | 814 | */ |
815 | 815 | public function button_css_attributes() { |
816 | - if ( empty( $this->_button_css_attributes )) { |
|
816 | + if (empty($this->_button_css_attributes)) { |
|
817 | 817 | $this->set_button_css_attributes(); |
818 | 818 | } |
819 | 819 | return $this->_button_css_attributes; |
@@ -835,26 +835,26 @@ discard block |
||
835 | 835 | * @return mixed whatever the raw value of this form section is in the request data |
836 | 836 | * @throws \EE_Error |
837 | 837 | */ |
838 | - public function find_form_data_for_this_section( $req_data ){ |
|
838 | + public function find_form_data_for_this_section($req_data) { |
|
839 | 839 | // break up the html name by "[]" |
840 | - if ( strpos( $this->html_name(), '[' ) !== FALSE ) { |
|
841 | - $before_any_brackets = substr( $this->html_name(), 0, strpos($this->html_name(), '[') ); |
|
840 | + if (strpos($this->html_name(), '[') !== FALSE) { |
|
841 | + $before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '[')); |
|
842 | 842 | } else { |
843 | 843 | $before_any_brackets = $this->html_name(); |
844 | 844 | } |
845 | 845 | // grab all of the segments |
846 | - preg_match_all('~\[([^]]*)\]~',$this->html_name(), $matches); |
|
847 | - if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){ |
|
848 | - $name_parts = $matches[ 1 ]; |
|
846 | + preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches); |
|
847 | + if (isset($matches[1]) && is_array($matches[1])) { |
|
848 | + $name_parts = $matches[1]; |
|
849 | 849 | array_unshift($name_parts, $before_any_brackets); |
850 | - }else{ |
|
851 | - $name_parts = array( $before_any_brackets ); |
|
850 | + } else { |
|
851 | + $name_parts = array($before_any_brackets); |
|
852 | 852 | } |
853 | 853 | // now get the value for the input |
854 | 854 | $value = $this->_find_form_data_for_this_section_using_name_parts($name_parts, $req_data); |
855 | 855 | // check if this thing's name is at the TOP level of the request data |
856 | - if( $value === null && isset( $req_data[ $this->name() ] ) ){ |
|
857 | - $value = $req_data[ $this->name() ]; |
|
856 | + if ($value === null && isset($req_data[$this->name()])) { |
|
857 | + $value = $req_data[$this->name()]; |
|
858 | 858 | } |
859 | 859 | return $value; |
860 | 860 | } |
@@ -867,18 +867,18 @@ discard block |
||
867 | 867 | * @param array $req_data |
868 | 868 | * @return array | NULL |
869 | 869 | */ |
870 | - public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data){ |
|
871 | - $first_part_to_consider = array_shift( $html_name_parts ); |
|
872 | - if( isset( $req_data[ $first_part_to_consider ] ) ){ |
|
873 | - if( empty($html_name_parts ) ){ |
|
874 | - return $req_data[ $first_part_to_consider ]; |
|
875 | - }else{ |
|
870 | + public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data) { |
|
871 | + $first_part_to_consider = array_shift($html_name_parts); |
|
872 | + if (isset($req_data[$first_part_to_consider])) { |
|
873 | + if (empty($html_name_parts)) { |
|
874 | + return $req_data[$first_part_to_consider]; |
|
875 | + } else { |
|
876 | 876 | return $this->_find_form_data_for_this_section_using_name_parts( |
877 | 877 | $html_name_parts, |
878 | - $req_data[ $first_part_to_consider ] |
|
878 | + $req_data[$first_part_to_consider] |
|
879 | 879 | ); |
880 | 880 | } |
881 | - }else{ |
|
881 | + } else { |
|
882 | 882 | return NULL; |
883 | 883 | } |
884 | 884 | } |
@@ -892,14 +892,14 @@ discard block |
||
892 | 892 | * @return boolean |
893 | 893 | * @throws \EE_Error |
894 | 894 | */ |
895 | - public function form_data_present_in($req_data = NULL){ |
|
896 | - if( $req_data === NULL ){ |
|
895 | + public function form_data_present_in($req_data = NULL) { |
|
896 | + if ($req_data === NULL) { |
|
897 | 897 | $req_data = $_POST; |
898 | 898 | } |
899 | - $checked_value = $this->find_form_data_for_this_section( $req_data ); |
|
900 | - if( $checked_value !== null ){ |
|
899 | + $checked_value = $this->find_form_data_for_this_section($req_data); |
|
900 | + if ($checked_value !== null) { |
|
901 | 901 | return TRUE; |
902 | - }else{ |
|
902 | + } else { |
|
903 | 903 | return FALSE; |
904 | 904 | } |
905 | 905 | } |
@@ -910,8 +910,8 @@ discard block |
||
910 | 910 | * @param array $form_other_js_data |
911 | 911 | * @return array |
912 | 912 | */ |
913 | - public function get_other_js_data( $form_other_js_data = array() ) { |
|
914 | - $form_other_js_data = $this->get_other_js_data_from_strategies( $form_other_js_data ); |
|
913 | + public function get_other_js_data($form_other_js_data = array()) { |
|
914 | + $form_other_js_data = $this->get_other_js_data_from_strategies($form_other_js_data); |
|
915 | 915 | return $form_other_js_data; |
916 | 916 | } |
917 | 917 | |
@@ -924,10 +924,10 @@ discard block |
||
924 | 924 | * @param array $form_other_js_data |
925 | 925 | * @return array |
926 | 926 | */ |
927 | - public function get_other_js_data_from_strategies( $form_other_js_data = array() ) { |
|
928 | - $form_other_js_data = $this->get_display_strategy()->get_other_js_data( $form_other_js_data ); |
|
929 | - foreach( $this->get_validation_strategies() as $validation_strategy ) { |
|
930 | - $form_other_js_data = $validation_strategy->get_other_js_data( $form_other_js_data ); |
|
927 | + public function get_other_js_data_from_strategies($form_other_js_data = array()) { |
|
928 | + $form_other_js_data = $this->get_display_strategy()->get_other_js_data($form_other_js_data); |
|
929 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
930 | + $form_other_js_data = $validation_strategy->get_other_js_data($form_other_js_data); |
|
931 | 931 | } |
932 | 932 | return $form_other_js_data; |
933 | 933 | } |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | * Override parent because we want to give our strategies an opportunity to enqueue some js and css |
937 | 937 | * @return void |
938 | 938 | */ |
939 | - public function enqueue_js(){ |
|
939 | + public function enqueue_js() { |
|
940 | 940 | //ask our display strategy and validation strategies if they have js to enqueue |
941 | 941 | $this->enqueue_js_from_strategies(); |
942 | 942 | } |
@@ -947,7 +947,7 @@ discard block |
||
947 | 947 | */ |
948 | 948 | public function enqueue_js_from_strategies() { |
949 | 949 | $this->get_display_strategy()->enqueue_js(); |
950 | - foreach( $this->get_validation_strategies() as $validation_strategy ) { |
|
950 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
951 | 951 | $validation_strategy->enqueue_js(); |
952 | 952 | } |
953 | 953 | } |