@@ -1,5 +1,5 @@ discard block |
||
| 1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
| 2 | -do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
| 2 | +do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 3 | 3 | /** |
| 4 | 4 | * EE_Export class |
| 5 | 5 | * |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | * @access private |
| 40 | 40 | * @param array $request_data |
| 41 | 41 | */ |
| 42 | - private function __construct( $request_data = array() ) { |
|
| 42 | + private function __construct($request_data = array()) { |
|
| 43 | 43 | $this->_req_data = $request_data; |
| 44 | - $this->today = date("Y-m-d",time()); |
|
| 45 | - require_once( EE_CLASSES . 'EE_CSV.class.php' ); |
|
| 46 | - $this->EE_CSV= EE_CSV::instance(); |
|
| 44 | + $this->today = date("Y-m-d", time()); |
|
| 45 | + require_once(EE_CLASSES.'EE_CSV.class.php'); |
|
| 46 | + $this->EE_CSV = EE_CSV::instance(); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | |
@@ -55,10 +55,10 @@ discard block |
||
| 55 | 55 | * @param array $request_data |
| 56 | 56 | * @return \EE_Export |
| 57 | 57 | */ |
| 58 | - public static function instance( $request_data = array() ) { |
|
| 58 | + public static function instance($request_data = array()) { |
|
| 59 | 59 | // check if class object is instantiated |
| 60 | - if ( self::$_instance === NULL or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Export )) { |
|
| 61 | - self::$_instance = new self( $request_data ); |
|
| 60 | + if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Export)) { |
|
| 61 | + self::$_instance = new self($request_data); |
|
| 62 | 62 | } |
| 63 | 63 | return self::$_instance; |
| 64 | 64 | } |
@@ -72,15 +72,15 @@ discard block |
||
| 72 | 72 | public function export() { |
| 73 | 73 | |
| 74 | 74 | // in case of bulk exports, the "actual" action will be in action2, but first check regular action for "export" keyword |
| 75 | - if ( isset( $this->_req_data['action'] ) && strpos( $this->_req_data['action'], 'export' ) === FALSE ) { |
|
| 75 | + if (isset($this->_req_data['action']) && strpos($this->_req_data['action'], 'export') === FALSE) { |
|
| 76 | 76 | // check if action2 has export action |
| 77 | - if ( isset( $this->_req_data['action2'] ) && strpos( $this->_req_data['action2'], 'export' ) !== FALSE ) { |
|
| 77 | + if (isset($this->_req_data['action2']) && strpos($this->_req_data['action2'], 'export') !== FALSE) { |
|
| 78 | 78 | // whoop! there it is! |
| 79 | 79 | $this->_req_data['action'] = $this->_req_data['action2']; |
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - $this->_req_data['export'] = isset( $this->_req_data['export'] ) ? $this->_req_data['export'] : ''; |
|
| 83 | + $this->_req_data['export'] = isset($this->_req_data['export']) ? $this->_req_data['export'] : ''; |
|
| 84 | 84 | |
| 85 | 85 | switch ($this->_req_data['export']) { |
| 86 | 86 | case 'report': |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | break; |
| 95 | 95 | |
| 96 | 96 | case 'registrations_report_for_event': |
| 97 | - $this->report_registrations_for_event( $this->_req_data['EVT_ID'] ); |
|
| 97 | + $this->report_registrations_for_event($this->_req_data['EVT_ID']); |
|
| 98 | 98 | break; |
| 99 | 99 | |
| 100 | 100 | case 'attendees': |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | break; |
| 107 | 107 | |
| 108 | 108 | default: |
| 109 | - EE_Error::add_error(__('An error occurred! The requested export report could not be found.','event_espresso'), __FILE__, __FUNCTION__, __LINE__ ) ; |
|
| 109 | + EE_Error::add_error(__('An error occurred! The requested export report could not be found.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 110 | 110 | return FALSE; |
| 111 | 111 | break; |
| 112 | 112 | |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | * Downloads a CSV file with all the columns, but no data. This should be used for importing |
| 125 | 125 | * @return null kills execution |
| 126 | 126 | */ |
| 127 | - function export_sample(){ |
|
| 127 | + function export_sample() { |
|
| 128 | 128 | $event = EEM_Event::instance()->get_one(); |
| 129 | 129 | $this->_req_data['EVT_ID'] = $event->ID(); |
| 130 | 130 | $this->export_all_event_data(); |
@@ -150,23 +150,23 @@ discard block |
||
| 150 | 150 | $state_country_query_params = array(); |
| 151 | 151 | $question_group_query_params = array(); |
| 152 | 152 | $question_query_params = array(); |
| 153 | - if ( isset( $this->_req_data['EVT_ID'] )) { |
|
| 153 | + if (isset($this->_req_data['EVT_ID'])) { |
|
| 154 | 154 | // do we have an array of IDs ? |
| 155 | 155 | |
| 156 | - if ( is_array( $this->_req_data['EVT_ID'] )) { |
|
| 157 | - $EVT_IDs = array_map( 'sanitize_text_field', $this->_req_data['EVT_ID'] ); |
|
| 158 | - $value_to_equal = array('IN',$EVT_IDs); |
|
| 156 | + if (is_array($this->_req_data['EVT_ID'])) { |
|
| 157 | + $EVT_IDs = array_map('sanitize_text_field', $this->_req_data['EVT_ID']); |
|
| 158 | + $value_to_equal = array('IN', $EVT_IDs); |
|
| 159 | 159 | $filename = 'events'; |
| 160 | 160 | } else { |
| 161 | 161 | // generate regular where = clause |
| 162 | - $EVT_ID = absint( $this->_req_data['EVT_ID'] ); |
|
| 162 | + $EVT_ID = absint($this->_req_data['EVT_ID']); |
|
| 163 | 163 | $value_to_equal = $EVT_ID; |
| 164 | 164 | $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($EVT_ID); |
| 165 | 165 | |
| 166 | - $filename = 'event-' . ( $event instanceof EE_Event ? $event->slug() : __( 'unknown', 'event_espresso' ) ); |
|
| 166 | + $filename = 'event-'.($event instanceof EE_Event ? $event->slug() : __('unknown', 'event_espresso')); |
|
| 167 | 167 | |
| 168 | 168 | } |
| 169 | - $event_query_params[0]['EVT_ID'] =$value_to_equal; |
|
| 169 | + $event_query_params[0]['EVT_ID'] = $value_to_equal; |
|
| 170 | 170 | $related_models_query_params[0]['Event.EVT_ID'] = $value_to_equal; |
| 171 | 171 | $related_through_reg_query_params[0]['Registration.EVT_ID'] = $value_to_equal; |
| 172 | 172 | $datetime_ticket_query_params[0]['Datetime.EVT_ID'] = $value_to_equal; |
@@ -210,42 +210,42 @@ discard block |
||
| 210 | 210 | |
| 211 | 211 | ); |
| 212 | 212 | |
| 213 | - $model_data = $this->_get_export_data_for_models( $models_to_export ); |
|
| 213 | + $model_data = $this->_get_export_data_for_models($models_to_export); |
|
| 214 | 214 | |
| 215 | - $filename = $this->generate_filename ( $filename ); |
|
| 215 | + $filename = $this->generate_filename($filename); |
|
| 216 | 216 | |
| 217 | - if ( ! $this->EE_CSV->export_multiple_model_data_to_csv( $filename, $model_data )) { |
|
| 218 | - EE_Error::add_error(__("'An error occurred and the Event details could not be exported from the database.'", "event_espresso"), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 217 | + if ( ! $this->EE_CSV->export_multiple_model_data_to_csv($filename, $model_data)) { |
|
| 218 | + EE_Error::add_error(__("'An error occurred and the Event details could not be exported from the database.'", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
|
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - function report_attendees(){ |
|
| 222 | + function report_attendees() { |
|
| 223 | 223 | $attendee_rows = EEM_Attendee::instance()->get_all_wpdb_results( |
| 224 | 224 | array( |
| 225 | - 'force_join' => array( 'State', 'Country' ), |
|
| 225 | + 'force_join' => array('State', 'Country'), |
|
| 226 | 226 | 'caps' => EEM_Base::caps_read_admin |
| 227 | 227 | ) |
| 228 | 228 | ); |
| 229 | 229 | $csv_data = array(); |
| 230 | - foreach( $attendee_rows as $attendee_row ){ |
|
| 230 | + foreach ($attendee_rows as $attendee_row) { |
|
| 231 | 231 | $csv_row = array(); |
| 232 | - foreach( EEM_Attendee::instance()->field_settings() as $field_name => $field_obj ){ |
|
| 233 | - if( $field_name == 'STA_ID' ){ |
|
| 234 | - $state_name_field = EEM_State::instance()->field_settings_for( 'STA_name' ); |
|
| 235 | - $csv_row[ __( 'State', 'event_espresso' ) ] = $attendee_row[ $state_name_field->get_qualified_column() ]; |
|
| 236 | - }elseif( $field_name == 'CNT_ISO' ){ |
|
| 237 | - $country_name_field = EEM_Country::instance()->field_settings_for( 'CNT_name' ); |
|
| 238 | - $csv_row[ __( 'Country', 'event_espresso' ) ] = $attendee_row[ $country_name_field->get_qualified_column() ]; |
|
| 239 | - }else{ |
|
| 240 | - $csv_row[ $field_obj->get_nicename() ] = $attendee_row[ $field_obj->get_qualified_column() ]; |
|
| 232 | + foreach (EEM_Attendee::instance()->field_settings() as $field_name => $field_obj) { |
|
| 233 | + if ($field_name == 'STA_ID') { |
|
| 234 | + $state_name_field = EEM_State::instance()->field_settings_for('STA_name'); |
|
| 235 | + $csv_row[__('State', 'event_espresso')] = $attendee_row[$state_name_field->get_qualified_column()]; |
|
| 236 | + }elseif ($field_name == 'CNT_ISO') { |
|
| 237 | + $country_name_field = EEM_Country::instance()->field_settings_for('CNT_name'); |
|
| 238 | + $csv_row[__('Country', 'event_espresso')] = $attendee_row[$country_name_field->get_qualified_column()]; |
|
| 239 | + } else { |
|
| 240 | + $csv_row[$field_obj->get_nicename()] = $attendee_row[$field_obj->get_qualified_column()]; |
|
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | 243 | $csv_data[] = $csv_row; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - $filename = $this->generate_filename ( 'contact-list-report' ); |
|
| 246 | + $filename = $this->generate_filename('contact-list-report'); |
|
| 247 | 247 | |
| 248 | - $handle = $this->EE_CSV->begin_sending_csv( $filename); |
|
| 248 | + $handle = $this->EE_CSV->begin_sending_csv($filename); |
|
| 249 | 249 | $this->EE_CSV->write_data_array_to_csv($handle, $csv_data); |
| 250 | 250 | $this->EE_CSV->end_sending_csv($handle); |
| 251 | 251 | } |
@@ -262,18 +262,18 @@ discard block |
||
| 262 | 262 | $countries_that_have_an_attendee = EEM_Country::instance()->get_all(array(0=>array('Attendee.ATT_ID'=>array('IS NOT NULL')))); |
| 263 | 263 | // $states_to_export_query_params |
| 264 | 264 | $models_to_export = array( |
| 265 | - 'Country'=>array(array('CNT_ISO'=>array('IN',array_keys($countries_that_have_an_attendee)))), |
|
| 266 | - 'State'=>array(array('STA_ID'=>array('IN',array_keys($states_that_have_an_attendee)))), |
|
| 265 | + 'Country'=>array(array('CNT_ISO'=>array('IN', array_keys($countries_that_have_an_attendee)))), |
|
| 266 | + 'State'=>array(array('STA_ID'=>array('IN', array_keys($states_that_have_an_attendee)))), |
|
| 267 | 267 | 'Attendee'=>array(), |
| 268 | 268 | ); |
| 269 | 269 | |
| 270 | 270 | |
| 271 | 271 | |
| 272 | - $model_data = $this->_get_export_data_for_models( $models_to_export ); |
|
| 273 | - $filename = $this->generate_filename ( 'all-attendees' ); |
|
| 272 | + $model_data = $this->_get_export_data_for_models($models_to_export); |
|
| 273 | + $filename = $this->generate_filename('all-attendees'); |
|
| 274 | 274 | |
| 275 | - if ( ! $this->EE_CSV->export_multiple_model_data_to_csv( $filename, $model_data )) { |
|
| 276 | - EE_Error::add_error(__('An error occurred and the Attendee data could not be exported from the database.','event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 275 | + if ( ! $this->EE_CSV->export_multiple_model_data_to_csv($filename, $model_data)) { |
|
| 276 | + EE_Error::add_error(__('An error occurred and the Attendee data could not be exported from the database.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | 279 | |
@@ -285,19 +285,19 @@ discard block |
||
| 285 | 285 | * @param boolean|string $pretty_schema true to display pretty, a string to use a specific "Schema", or false to NOT display pretty |
| 286 | 286 | * @return string |
| 287 | 287 | */ |
| 288 | - protected function _prepare_value_from_db_for_display( $model, $field_name, $raw_db_value, $pretty_schema = true ) { |
|
| 289 | - $field_obj = $model->field_settings_for( $field_name ); |
|
| 290 | - $value_on_model_obj = $field_obj->prepare_for_set_from_db( $raw_db_value ); |
|
| 291 | - if( $field_obj instanceof EE_Datetime_Field ) { |
|
| 292 | - $field_obj->set_date_format( EE_CSV::instance()->get_date_format_for_csv( $field_obj->get_date_format( $pretty_schema ) ), $pretty_schema ); |
|
| 293 | - $field_obj->set_time_format( EE_CSV::instance()->get_time_format_for_csv( $field_obj->get_time_format( $pretty_schema ) ), $pretty_schema ); |
|
| 288 | + protected function _prepare_value_from_db_for_display($model, $field_name, $raw_db_value, $pretty_schema = true) { |
|
| 289 | + $field_obj = $model->field_settings_for($field_name); |
|
| 290 | + $value_on_model_obj = $field_obj->prepare_for_set_from_db($raw_db_value); |
|
| 291 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
| 292 | + $field_obj->set_date_format(EE_CSV::instance()->get_date_format_for_csv($field_obj->get_date_format($pretty_schema)), $pretty_schema); |
|
| 293 | + $field_obj->set_time_format(EE_CSV::instance()->get_time_format_for_csv($field_obj->get_time_format($pretty_schema)), $pretty_schema); |
|
| 294 | 294 | } |
| 295 | - if( $pretty_schema === true){ |
|
| 296 | - return $field_obj->prepare_for_pretty_echoing( $value_on_model_obj ); |
|
| 297 | - }elseif( is_string( $pretty_schema ) ) { |
|
| 298 | - return $field_obj->prepare_for_pretty_echoing($value_on_model_obj, $pretty_schema ); |
|
| 299 | - }else{ |
|
| 300 | - return $field_obj->prepare_for_get( $value_on_model_obj ); |
|
| 295 | + if ($pretty_schema === true) { |
|
| 296 | + return $field_obj->prepare_for_pretty_echoing($value_on_model_obj); |
|
| 297 | + }elseif (is_string($pretty_schema)) { |
|
| 298 | + return $field_obj->prepare_for_pretty_echoing($value_on_model_obj, $pretty_schema); |
|
| 299 | + } else { |
|
| 300 | + return $field_obj->prepare_for_get($value_on_model_obj); |
|
| 301 | 301 | } |
| 302 | 302 | } |
| 303 | 303 | |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | * and the questions associated with the registrations |
| 307 | 307 | * @param int $event_id |
| 308 | 308 | */ |
| 309 | - function report_registrations_for_event( $event_id = NULL ){ |
|
| 309 | + function report_registrations_for_event($event_id = NULL) { |
|
| 310 | 310 | $reg_fields_to_include = array( |
| 311 | 311 | 'TXN_ID', |
| 312 | 312 | 'ATT_ID', |
@@ -338,126 +338,126 @@ discard block |
||
| 338 | 338 | array( |
| 339 | 339 | 'OR' => array( |
| 340 | 340 | //don't include registrations from failed or abandoned transactions... |
| 341 | - 'Transaction.STS_ID' => array( 'NOT IN', array( EEM_Transaction::failed_status_code, EEM_Transaction::abandoned_status_code ) ), |
|
| 341 | + 'Transaction.STS_ID' => array('NOT IN', array(EEM_Transaction::failed_status_code, EEM_Transaction::abandoned_status_code)), |
|
| 342 | 342 | //unless the registration is approved, in which case include it regardless of transaction status |
| 343 | 343 | 'STS_ID' => EEM_Registration::status_id_approved |
| 344 | 344 | ), |
| 345 | - 'Ticket.TKT_deleted' => array( 'IN', array( true, false ) ) |
|
| 345 | + 'Ticket.TKT_deleted' => array('IN', array(true, false)) |
|
| 346 | 346 | ), |
| 347 | - 'order_by' => array('Transaction.TXN_ID'=>'asc','REG_count'=>'asc'), |
|
| 348 | - 'force_join' => array( 'Transaction', 'Ticket', 'Attendee' ), |
|
| 347 | + 'order_by' => array('Transaction.TXN_ID'=>'asc', 'REG_count'=>'asc'), |
|
| 348 | + 'force_join' => array('Transaction', 'Ticket', 'Attendee'), |
|
| 349 | 349 | 'caps' => EEM_Base::caps_read_admin |
| 350 | 350 | ), |
| 351 | 351 | $event_id |
| 352 | 352 | ); |
| 353 | - if( $event_id ){ |
|
| 354 | - $query_params[0]['EVT_ID'] = $event_id; |
|
| 355 | - }else{ |
|
| 356 | - $query_params[ 'force_join' ][] = 'Event'; |
|
| 353 | + if ($event_id) { |
|
| 354 | + $query_params[0]['EVT_ID'] = $event_id; |
|
| 355 | + } else { |
|
| 356 | + $query_params['force_join'][] = 'Event'; |
|
| 357 | 357 | } |
| 358 | - $registration_rows = $reg_model->get_all_wpdb_results( $query_params ); |
|
| 358 | + $registration_rows = $reg_model->get_all_wpdb_results($query_params); |
|
| 359 | 359 | //get all questions which relate to someone in this group |
| 360 | 360 | $registration_ids = array(); |
| 361 | - foreach( $registration_rows as $reg_row ) { |
|
| 362 | - $registration_ids[] = intval( $reg_row[ 'Registration.REG_ID'] ); |
|
| 361 | + foreach ($registration_rows as $reg_row) { |
|
| 362 | + $registration_ids[] = intval($reg_row['Registration.REG_ID']); |
|
| 363 | 363 | } |
| 364 | 364 | // EEM_Question::instance()->show_next_x_db_queries(); |
| 365 | - $questions_for_these_regs_rows = EEM_Question::instance()->get_all_wpdb_results(array(array('Answer.REG_ID'=>array('IN',$registration_ids)))); |
|
| 366 | - foreach($registration_rows as $reg_row){ |
|
| 367 | - if ( is_array( $reg_row ) ) { |
|
| 365 | + $questions_for_these_regs_rows = EEM_Question::instance()->get_all_wpdb_results(array(array('Answer.REG_ID'=>array('IN', $registration_ids)))); |
|
| 366 | + foreach ($registration_rows as $reg_row) { |
|
| 367 | + if (is_array($reg_row)) { |
|
| 368 | 368 | $reg_csv_array = array(); |
| 369 | - if( ! $event_id ){ |
|
| 369 | + if ( ! $event_id) { |
|
| 370 | 370 | //get the event's name and Id |
| 371 | - $reg_csv_array[ __( 'Event', 'event_espresso' ) ] = sprintf( __( '%1$s (%2$s)', 'event_espresso' ), $this->_prepare_value_from_db_for_display( EEM_Event::instance(), 'EVT_name', $reg_row[ 'Event_CPT.post_title'] ), $reg_row[ 'Event_CPT.ID' ] ); |
|
| 371 | + $reg_csv_array[__('Event', 'event_espresso')] = sprintf(__('%1$s (%2$s)', 'event_espresso'), $this->_prepare_value_from_db_for_display(EEM_Event::instance(), 'EVT_name', $reg_row['Event_CPT.post_title']), $reg_row['Event_CPT.ID']); |
|
| 372 | 372 | } |
| 373 | - $is_primary_reg = $reg_row[ 'Registration.REG_count' ] == '1' ? true : false; |
|
| 373 | + $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false; |
|
| 374 | 374 | /*@var $reg_row EE_Registration */ |
| 375 | - foreach($reg_fields_to_include as $field_name){ |
|
| 375 | + foreach ($reg_fields_to_include as $field_name) { |
|
| 376 | 376 | $field = $reg_model->field_settings_for($field_name); |
| 377 | - if($field_name == 'REG_final_price'){ |
|
| 378 | - $value = $this->_prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_final_price'], 'localized_float' ); |
|
| 379 | - }elseif( $field_name == 'REG_count' ){ |
|
| 380 | - $value = sprintf( __( '%s of %s', 'event_espresso' ), $this->_prepare_value_from_db_for_display( $reg_model, 'REG_count', $reg_row['Registration.REG_count'] ), $this->_prepare_value_from_db_for_display( $reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size' ] ) ); |
|
| 381 | - }elseif( $field_name == 'REG_date' ) { |
|
| 382 | - $value = $this->_prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_date'], 'no_html' ); |
|
| 383 | - }else{ |
|
| 384 | - $value = $this->_prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ $field->get_qualified_column() ] ); |
|
| 377 | + if ($field_name == 'REG_final_price') { |
|
| 378 | + $value = $this->_prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_final_price'], 'localized_float'); |
|
| 379 | + }elseif ($field_name == 'REG_count') { |
|
| 380 | + $value = sprintf(__('%s of %s', 'event_espresso'), $this->_prepare_value_from_db_for_display($reg_model, 'REG_count', $reg_row['Registration.REG_count']), $this->_prepare_value_from_db_for_display($reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size'])); |
|
| 381 | + }elseif ($field_name == 'REG_date') { |
|
| 382 | + $value = $this->_prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_date'], 'no_html'); |
|
| 383 | + } else { |
|
| 384 | + $value = $this->_prepare_value_from_db_for_display($reg_model, $field_name, $reg_row[$field->get_qualified_column()]); |
|
| 385 | 385 | } |
| 386 | 386 | $reg_csv_array[$this->_get_column_name_for_field($field)] = $value; |
| 387 | - if($field_name == 'REG_final_price'){ |
|
| 387 | + if ($field_name == 'REG_final_price') { |
|
| 388 | 388 | //add a column named Currency after the final price |
| 389 | 389 | $reg_csv_array[__("Currency", "event_espresso")] = EE_Config::instance()->currency->code; |
| 390 | 390 | } |
| 391 | 391 | } |
| 392 | 392 | //get pretty status |
| 393 | - $stati = EEM_Status::instance()->localized_status( array( |
|
| 394 | - $reg_row[ 'Registration.STS_ID' ] => __( 'unknown', 'event_espresso' ), |
|
| 395 | - $reg_row[ 'Transaction.STS_ID' ] => __( 'unknown', 'event_espresso' ) ), |
|
| 393 | + $stati = EEM_Status::instance()->localized_status(array( |
|
| 394 | + $reg_row['Registration.STS_ID'] => __('unknown', 'event_espresso'), |
|
| 395 | + $reg_row['Transaction.STS_ID'] => __('unknown', 'event_espresso') ), |
|
| 396 | 396 | FALSE, |
| 397 | - 'sentence' ); |
|
| 398 | - $reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[ $reg_row[ 'Registration.STS_ID' ] ]; |
|
| 397 | + 'sentence'); |
|
| 398 | + $reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']]; |
|
| 399 | 399 | //get pretty trnasaction status |
| 400 | - $reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[ $reg_row[ 'Transaction.STS_ID' ] ]; |
|
| 401 | - $reg_csv_array[ __( 'Transaction Amount Due', 'event_espresso' ) ] = $is_primary_reg ? $this->_prepare_value_from_db_for_display( EEM_Transaction::instance(), 'TXN_total', $reg_row[ 'Transaction.TXN_total' ], 'localized_float' ) : '0.00'; |
|
| 402 | - $reg_csv_array[ __( 'Amount Paid', 'event_espresso' )] = $is_primary_reg ? $this->_prepare_value_from_db_for_display( EEM_Transaction::instance(), 'TXN_paid', $reg_row[ 'Transaction.TXN_paid' ], 'localized_float' ) : '0.00'; |
|
| 400 | + $reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[$reg_row['Transaction.STS_ID']]; |
|
| 401 | + $reg_csv_array[__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg ? $this->_prepare_value_from_db_for_display(EEM_Transaction::instance(), 'TXN_total', $reg_row['Transaction.TXN_total'], 'localized_float') : '0.00'; |
|
| 402 | + $reg_csv_array[__('Amount Paid', 'event_espresso')] = $is_primary_reg ? $this->_prepare_value_from_db_for_display(EEM_Transaction::instance(), 'TXN_paid', $reg_row['Transaction.TXN_paid'], 'localized_float') : '0.00'; |
|
| 403 | 403 | $payment_methods = array(); |
| 404 | 404 | $gateway_txn_ids_etc = array(); |
| 405 | 405 | $payment_times = array(); |
| 406 | - if( $is_primary_reg && $reg_row[ 'Transaction.TXN_ID' ] ){ |
|
| 406 | + if ($is_primary_reg && $reg_row['Transaction.TXN_ID']) { |
|
| 407 | 407 | $payments_info = EEM_Payment::instance()->get_all_wpdb_results( |
| 408 | 408 | array( |
| 409 | 409 | array( |
| 410 | - 'TXN_ID' => $reg_row[ 'Transaction.TXN_ID' ], |
|
| 410 | + 'TXN_ID' => $reg_row['Transaction.TXN_ID'], |
|
| 411 | 411 | 'STS_ID' => EEM_Payment::status_id_approved |
| 412 | 412 | ), |
| 413 | - 'force_join' => array( 'Payment_Method' ), |
|
| 413 | + 'force_join' => array('Payment_Method'), |
|
| 414 | 414 | |
| 415 | 415 | ), |
| 416 | 416 | ARRAY_A, |
| 417 | 417 | 'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time' ); |
| 418 | 418 | |
| 419 | - foreach( $payments_info as $payment_method_and_gateway_txn_id ){ |
|
| 420 | - $payment_methods[] = isset( $payment_method_and_gateway_txn_id[ 'name' ] ) ? $payment_method_and_gateway_txn_id[ 'name' ] : __( 'Unknown', 'event_espresso' ); |
|
| 421 | - $gateway_txn_ids_etc[] = isset( $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] ) ? $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] : ''; |
|
| 422 | - $payment_times[] = isset( $payment_method_and_gateway_txn_id[ 'payment_time' ] ) ? $payment_method_and_gateway_txn_id[ 'payment_time' ] : ''; |
|
| 419 | + foreach ($payments_info as $payment_method_and_gateway_txn_id) { |
|
| 420 | + $payment_methods[] = isset($payment_method_and_gateway_txn_id['name']) ? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso'); |
|
| 421 | + $gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id']) ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : ''; |
|
| 422 | + $payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time']) ? $payment_method_and_gateway_txn_id['payment_time'] : ''; |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | } |
| 426 | - $reg_csv_array[ __( 'Payment Date(s)', 'event_espresso' ) ] = implode( ',', $payment_times ); |
|
| 427 | - $reg_csv_array[ __( 'Payment Method(s)', 'event_espresso' ) ] = implode( ",", $payment_methods ); |
|
| 428 | - $reg_csv_array[ __( 'Gateway Transaction ID(s)', 'event_espresso' )] = implode( ',', $gateway_txn_ids_etc ); |
|
| 426 | + $reg_csv_array[__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times); |
|
| 427 | + $reg_csv_array[__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods); |
|
| 428 | + $reg_csv_array[__('Gateway Transaction ID(s)', 'event_espresso')] = implode(',', $gateway_txn_ids_etc); |
|
| 429 | 429 | |
| 430 | 430 | //get whether or not the user has checked in |
| 431 | - $reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related( $reg_row[ 'Registration.REG_ID'] , 'Checkin' ); |
|
| 431 | + $reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related($reg_row['Registration.REG_ID'], 'Checkin'); |
|
| 432 | 432 | //get ticket of registration and its price |
| 433 | 433 | $ticket_model = EE_Registry::instance()->load_model('Ticket'); |
| 434 | - if( $reg_row[ 'Ticket.TKT_ID'] ) { |
|
| 435 | - $ticket_name = $this->_prepare_value_from_db_for_display( $ticket_model, 'TKT_name', $reg_row[ 'Ticket.TKT_name' ] ); |
|
| 434 | + if ($reg_row['Ticket.TKT_ID']) { |
|
| 435 | + $ticket_name = $this->_prepare_value_from_db_for_display($ticket_model, 'TKT_name', $reg_row['Ticket.TKT_name']); |
|
| 436 | 436 | $datetimes_strings = array(); |
| 437 | - foreach( EEM_Datetime::instance()->get_all_wpdb_results( array( array( 'Ticket.TKT_ID' => $reg_row[ 'Ticket.TKT_ID' ] ), 'order_by' => array( 'DTT_EVT_start' => 'ASC' ), 'default_where_conditions' => 'none' ) ) as $datetime){ |
|
| 438 | - $datetimes_strings[] = $this->_prepare_value_from_db_for_display( EEM_Datetime::instance(), 'DTT_EVT_start', $datetime[ 'Datetime.DTT_EVT_start'] ); |
|
| 437 | + foreach (EEM_Datetime::instance()->get_all_wpdb_results(array(array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']), 'order_by' => array('DTT_EVT_start' => 'ASC'), 'default_where_conditions' => 'none')) as $datetime) { |
|
| 438 | + $datetimes_strings[] = $this->_prepare_value_from_db_for_display(EEM_Datetime::instance(), 'DTT_EVT_start', $datetime['Datetime.DTT_EVT_start']); |
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | } else { |
| 442 | - $ticket_name = __( 'Unknown', 'event_espresso' ); |
|
| 443 | - $datetimes_strings = array( __( 'Unknown', 'event_espresso' ) ); |
|
| 442 | + $ticket_name = __('Unknown', 'event_espresso'); |
|
| 443 | + $datetimes_strings = array(__('Unknown', 'event_espresso')); |
|
| 444 | 444 | } |
| 445 | 445 | $reg_csv_array[$ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name; |
| 446 | 446 | $reg_csv_array[__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings); |
| 447 | 447 | //get datetime(s) of registration |
| 448 | 448 | |
| 449 | 449 | //add attendee columns |
| 450 | - foreach($att_fields_to_include as $att_field_name){ |
|
| 450 | + foreach ($att_fields_to_include as $att_field_name) { |
|
| 451 | 451 | $field_obj = EEM_Attendee::instance()->field_settings_for($att_field_name); |
| 452 | - if( $reg_row[ 'Attendee_CPT.ID' ]){ |
|
| 453 | - if($att_field_name == 'STA_ID'){ |
|
| 454 | - $value = EEM_State::instance()->get_var( array( array( 'STA_ID' => $reg_row[ 'Attendee_Meta.STA_ID' ] ) ), 'STA_name' ); |
|
| 455 | - }elseif($att_field_name == 'CNT_ISO'){ |
|
| 456 | - $value = EEM_Country::instance()->get_var( array( array( 'CNT_ISO' => $reg_row[ 'Attendee_Meta.CNT_ISO' ] ) ), 'CNT_name' ); |
|
| 457 | - }else{ |
|
| 458 | - $value = $this->_prepare_value_from_db_for_display( EEM_Attendee::instance(), $att_field_name, $reg_row[ $field_obj->get_qualified_column() ] ); |
|
| 452 | + if ($reg_row['Attendee_CPT.ID']) { |
|
| 453 | + if ($att_field_name == 'STA_ID') { |
|
| 454 | + $value = EEM_State::instance()->get_var(array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])), 'STA_name'); |
|
| 455 | + }elseif ($att_field_name == 'CNT_ISO') { |
|
| 456 | + $value = EEM_Country::instance()->get_var(array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])), 'CNT_name'); |
|
| 457 | + } else { |
|
| 458 | + $value = $this->_prepare_value_from_db_for_display(EEM_Attendee::instance(), $att_field_name, $reg_row[$field_obj->get_qualified_column()]); |
|
| 459 | 459 | } |
| 460 | - }else{ |
|
| 460 | + } else { |
|
| 461 | 461 | $value = ''; |
| 462 | 462 | } |
| 463 | 463 | |
@@ -465,56 +465,56 @@ discard block |
||
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | //make sure each registration has the same questions in the same order |
| 468 | - foreach($questions_for_these_regs_rows as $question_row){ |
|
| 469 | - if( ! isset($reg_csv_array[$question_row[ 'Question.QST_admin_label']])){ |
|
| 470 | - $reg_csv_array[$question_row[ 'Question.QST_admin_label' ] ] = null; |
|
| 468 | + foreach ($questions_for_these_regs_rows as $question_row) { |
|
| 469 | + if ( ! isset($reg_csv_array[$question_row['Question.QST_admin_label']])) { |
|
| 470 | + $reg_csv_array[$question_row['Question.QST_admin_label']] = null; |
|
| 471 | 471 | } |
| 472 | 472 | } |
| 473 | 473 | //now fill out the questions THEY answered |
| 474 | - foreach( EEM_Answer::instance()->get_all_wpdb_results( array( array( 'REG_ID' => $reg_row[ 'Registration.REG_ID' ] ), 'force_join' => array( 'Question' ) ) ) as $answer_row){ |
|
| 474 | + foreach (EEM_Answer::instance()->get_all_wpdb_results(array(array('REG_ID' => $reg_row['Registration.REG_ID']), 'force_join' => array('Question'))) as $answer_row) { |
|
| 475 | 475 | /* @var $answer EE_Answer */ |
| 476 | - if( $answer_row[ 'Question.QST_ID' ] ){ |
|
| 477 | - $question_label = $this->_prepare_value_from_db_for_display( EEM_Question::instance(), 'QST_admin_label', $answer_row[ 'Question.QST_admin_label' ] ); |
|
| 478 | - }else{ |
|
| 479 | - $question_label = sprintf( __( 'Question $s', 'event_espresso' ), $answer_row[ 'Answer.QST_ID' ] ); |
|
| 476 | + if ($answer_row['Question.QST_ID']) { |
|
| 477 | + $question_label = $this->_prepare_value_from_db_for_display(EEM_Question::instance(), 'QST_admin_label', $answer_row['Question.QST_admin_label']); |
|
| 478 | + } else { |
|
| 479 | + $question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']); |
|
| 480 | 480 | } |
| 481 | - if( isset( $answer_row[ 'Question.QST_type'] ) && $answer_row[ 'Question.QST_type' ] == EEM_Question::QST_type_state ) { |
|
| 482 | - $reg_csv_array[ $question_label ] = EEM_State::instance()->get_state_name_by_ID( $answer_row[ 'Answer.ANS_value' ] ); |
|
| 481 | + if (isset($answer_row['Question.QST_type']) && $answer_row['Question.QST_type'] == EEM_Question::QST_type_state) { |
|
| 482 | + $reg_csv_array[$question_label] = EEM_State::instance()->get_state_name_by_ID($answer_row['Answer.ANS_value']); |
|
| 483 | 483 | } else { |
| 484 | - $reg_csv_array[ $question_label ] = $this->_prepare_value_from_db_for_display( EEM_Answer::instance(), 'ANS_value', $answer_row[ 'Answer.ANS_value' ] ); |
|
| 484 | + $reg_csv_array[$question_label] = $this->_prepare_value_from_db_for_display(EEM_Answer::instance(), 'ANS_value', $answer_row['Answer.ANS_value']); |
|
| 485 | 485 | } |
| 486 | 486 | } |
| 487 | - $registrations_csv_ready_array[] = apply_filters( 'FHEE__EE_Export__report_registrations__reg_csv_array', $reg_csv_array, $reg_row ); |
|
| 487 | + $registrations_csv_ready_array[] = apply_filters('FHEE__EE_Export__report_registrations__reg_csv_array', $reg_csv_array, $reg_row); |
|
| 488 | 488 | } |
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | //if we couldn't export anything, we want to at least show the column headers |
| 492 | - if(empty($registrations_csv_ready_array)){ |
|
| 492 | + if (empty($registrations_csv_ready_array)) { |
|
| 493 | 493 | $reg_csv_array = array(); |
| 494 | 494 | $model_and_fields_to_include = array( |
| 495 | 495 | 'Registration' => $reg_fields_to_include, |
| 496 | 496 | 'Attendee' => $att_fields_to_include |
| 497 | 497 | ); |
| 498 | - foreach($model_and_fields_to_include as $model_name => $field_list){ |
|
| 498 | + foreach ($model_and_fields_to_include as $model_name => $field_list) { |
|
| 499 | 499 | $model = EE_Registry::instance()->load_model($model_name); |
| 500 | - foreach($field_list as $field_name){ |
|
| 500 | + foreach ($field_list as $field_name) { |
|
| 501 | 501 | $field = $model->field_settings_for($field_name); |
| 502 | - $reg_csv_array[$this->_get_column_name_for_field($field)] = null;//$registration->get($field->get_name()); |
|
| 502 | + $reg_csv_array[$this->_get_column_name_for_field($field)] = null; //$registration->get($field->get_name()); |
|
| 503 | 503 | } |
| 504 | 504 | } |
| 505 | 505 | $registrations_csv_ready_array [] = $reg_csv_array; |
| 506 | 506 | } |
| 507 | - if( $event_id ){ |
|
| 508 | - $event_slug = EEM_Event::instance()->get_var( array( array( 'EVT_ID' => $event_id ) ), 'EVT_slug' ); |
|
| 509 | - if( ! $event_slug ) { |
|
| 510 | - $event_slug = __( 'unknown', 'event_espresso' ); |
|
| 507 | + if ($event_id) { |
|
| 508 | + $event_slug = EEM_Event::instance()->get_var(array(array('EVT_ID' => $event_id)), 'EVT_slug'); |
|
| 509 | + if ( ! $event_slug) { |
|
| 510 | + $event_slug = __('unknown', 'event_espresso'); |
|
| 511 | 511 | } |
| 512 | - }else{ |
|
| 513 | - $event_slug = __( 'all', 'event_espresso' ); |
|
| 512 | + } else { |
|
| 513 | + $event_slug = __('all', 'event_espresso'); |
|
| 514 | 514 | } |
| 515 | - $filename = sprintf( "registrations-for-%s", $event_slug ); |
|
| 515 | + $filename = sprintf("registrations-for-%s", $event_slug); |
|
| 516 | 516 | |
| 517 | - $handle = $this->EE_CSV->begin_sending_csv( $filename); |
|
| 517 | + $handle = $this->EE_CSV->begin_sending_csv($filename); |
|
| 518 | 518 | $this->EE_CSV->write_data_array_to_csv($handle, $registrations_csv_ready_array); |
| 519 | 519 | $this->EE_CSV->end_sending_csv($handle); |
| 520 | 520 | } |
@@ -524,7 +524,7 @@ discard block |
||
| 524 | 524 | * @param EE_Model_Field_Base $field |
| 525 | 525 | * @return string |
| 526 | 526 | */ |
| 527 | - protected function _get_column_name_for_field(EE_Model_Field_Base $field){ |
|
| 527 | + protected function _get_column_name_for_field(EE_Model_Field_Base $field) { |
|
| 528 | 528 | return $field->get_nicename()."[".$field->get_name()."]"; |
| 529 | 529 | } |
| 530 | 530 | |
@@ -537,17 +537,17 @@ discard block |
||
| 537 | 537 | function export_categories() { |
| 538 | 538 | // are any Event IDs set? |
| 539 | 539 | $query_params = array(); |
| 540 | - if ( isset( $this->_req_data['EVT_CAT_ID'] )) { |
|
| 540 | + if (isset($this->_req_data['EVT_CAT_ID'])) { |
|
| 541 | 541 | // do we have an array of IDs ? |
| 542 | - if ( is_array( $this->_req_data['EVT_CAT_ID'] )) { |
|
| 542 | + if (is_array($this->_req_data['EVT_CAT_ID'])) { |
|
| 543 | 543 | // generate an "IN (CSV)" where clause |
| 544 | - $EVT_CAT_IDs = array_map( 'sanitize_text_field', $this->_req_data['EVT_CAT_ID'] ); |
|
| 544 | + $EVT_CAT_IDs = array_map('sanitize_text_field', $this->_req_data['EVT_CAT_ID']); |
|
| 545 | 545 | $filename = 'event-categories'; |
| 546 | - $query_params[0]['term_taxonomy_id'] = array('IN',$EVT_CAT_IDs); |
|
| 546 | + $query_params[0]['term_taxonomy_id'] = array('IN', $EVT_CAT_IDs); |
|
| 547 | 547 | } else { |
| 548 | 548 | // generate regular where = clause |
| 549 | - $EVT_CAT_ID = absint( $this->_req_data['EVT_CAT_ID'] ); |
|
| 550 | - $filename = 'event-category#' . $EVT_CAT_ID; |
|
| 549 | + $EVT_CAT_ID = absint($this->_req_data['EVT_CAT_ID']); |
|
| 550 | + $filename = 'event-category#'.$EVT_CAT_ID; |
|
| 551 | 551 | $query_params[0]['term_taxonomy_id'] = $EVT_CAT_ID; |
| 552 | 552 | } |
| 553 | 553 | } else { |
@@ -559,11 +559,11 @@ discard block |
||
| 559 | 559 | 'Term_Taxonomy' => $query_params |
| 560 | 560 | ); |
| 561 | 561 | |
| 562 | - $table_data = $this->_get_export_data_for_models( $tables_to_export ); |
|
| 563 | - $filename = $this->generate_filename ( $filename ); |
|
| 562 | + $table_data = $this->_get_export_data_for_models($tables_to_export); |
|
| 563 | + $filename = $this->generate_filename($filename); |
|
| 564 | 564 | |
| 565 | - if ( ! $this->EE_CSV->export_multiple_model_data_to_csv( $filename, $table_data )) { |
|
| 566 | - EE_Error::add_error(__('An error occurred and the Category details could not be exported from the database.','event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 565 | + if ( ! $this->EE_CSV->export_multiple_model_data_to_csv($filename, $table_data)) { |
|
| 566 | + EE_Error::add_error(__('An error occurred and the Category details could not be exported from the database.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 567 | 567 | } |
| 568 | 568 | } |
| 569 | 569 | |
@@ -574,13 +574,13 @@ discard block |
||
| 574 | 574 | * @param string - export_name |
| 575 | 575 | * @return string on success, FALSE on fail |
| 576 | 576 | */ |
| 577 | - private function generate_filename ( $export_name = '' ) { |
|
| 578 | - if ( $export_name != '' ) { |
|
| 579 | - $filename = get_bloginfo('name') . '-' . $export_name; |
|
| 580 | - $filename = sanitize_key( $filename ) . '-' . $this->today; |
|
| 577 | + private function generate_filename($export_name = '') { |
|
| 578 | + if ($export_name != '') { |
|
| 579 | + $filename = get_bloginfo('name').'-'.$export_name; |
|
| 580 | + $filename = sanitize_key($filename).'-'.$this->today; |
|
| 581 | 581 | return $filename; |
| 582 | - } else { |
|
| 583 | - EE_Error::add_error(__("No filename was provided", "event_espresso"), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 582 | + } else { |
|
| 583 | + EE_Error::add_error(__("No filename was provided", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
|
| 584 | 584 | } |
| 585 | 585 | return false; |
| 586 | 586 | } |
@@ -593,12 +593,12 @@ discard block |
||
| 593 | 593 | * @param array $models_to_export keys are model names (eg 'Event', 'Attendee', etc.) and values are arrays of query params like on EEM_Base::get_all |
| 594 | 594 | * @return array on success, FALSE on fail |
| 595 | 595 | */ |
| 596 | - private function _get_export_data_for_models( $models_to_export = array() ) { |
|
| 596 | + private function _get_export_data_for_models($models_to_export = array()) { |
|
| 597 | 597 | $table_data = FALSE; |
| 598 | - if ( is_array( $models_to_export ) ) { |
|
| 599 | - foreach ( $models_to_export as $model_name => $query_params ) { |
|
| 598 | + if (is_array($models_to_export)) { |
|
| 599 | + foreach ($models_to_export as $model_name => $query_params) { |
|
| 600 | 600 | //check for a numerically-indexed array. in that case, $model_name is the value!! |
| 601 | - if(is_int($model_name)){ |
|
| 601 | + if (is_int($model_name)) { |
|
| 602 | 602 | $model_name = $query_params; |
| 603 | 603 | $query_params = array(); |
| 604 | 604 | } |
@@ -606,17 +606,17 @@ discard block |
||
| 606 | 606 | $model_objects = $model->get_all($query_params); |
| 607 | 607 | |
| 608 | 608 | $table_data[$model_name] = array(); |
| 609 | - foreach($model_objects as $model_object){ |
|
| 609 | + foreach ($model_objects as $model_object) { |
|
| 610 | 610 | $model_data_array = array(); |
| 611 | 611 | $fields = $model->field_settings(); |
| 612 | - foreach($fields as $field){ |
|
| 612 | + foreach ($fields as $field) { |
|
| 613 | 613 | $column_name = $field->get_nicename()."[".$field->get_name()."]"; |
| 614 | - if($field instanceof EE_Datetime_Field){ |
|
| 614 | + if ($field instanceof EE_Datetime_Field) { |
|
| 615 | 615 | // $field->set_date_format('Y-m-d'); |
| 616 | 616 | // $field->set_time_format('H:i:s'); |
| 617 | - $model_data_array[$column_name] = $model_object->get_datetime($field->get_name(),'Y-m-d','H:i:s'); |
|
| 617 | + $model_data_array[$column_name] = $model_object->get_datetime($field->get_name(), 'Y-m-d', 'H:i:s'); |
|
| 618 | 618 | } |
| 619 | - else{ |
|
| 619 | + else { |
|
| 620 | 620 | $model_data_array[$column_name] = $model_object->get($field->get_name()); |
| 621 | 621 | } |
| 622 | 622 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | use EventEspressoBatchRequest\Helpers\JobParameters; |
| 19 | 19 | use EventEspressoBatchRequest\Helpers\JobStepResponse; |
| 20 | 20 | |
| 21 | -if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
| 21 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 22 | 22 | exit('No direct script access allowed'); |
| 23 | 23 | } |
| 24 | 24 | |
@@ -27,86 +27,86 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | public function create_job(JobParameters $job_parameters) { |
| 30 | - if( ! \EE_Capabilities::instance()->current_user_can( 'ee_read_contacts', 'generating_report' ) ) { |
|
| 30 | + if ( ! \EE_Capabilities::instance()->current_user_can('ee_read_contacts', 'generating_report')) { |
|
| 31 | 31 | throw new BatchRequestException( |
| 32 | - __( 'You do not have permission to view contacts', 'event_espresso') |
|
| 32 | + __('You do not have permission to view contacts', 'event_espresso') |
|
| 33 | 33 | ); |
| 34 | 34 | } |
| 35 | 35 | $filepath = $this->create_file_from_job_with_name( |
| 36 | 36 | $job_parameters->job_id(), |
| 37 | 37 | __('contact-list-report.csv', 'event_espresso') |
| 38 | 38 | ); |
| 39 | - $job_parameters->add_extra_data( 'filepath', $filepath ); |
|
| 40 | - $job_parameters->set_job_size( $this->count_units_to_process() ); |
|
| 39 | + $job_parameters->add_extra_data('filepath', $filepath); |
|
| 40 | + $job_parameters->set_job_size($this->count_units_to_process()); |
|
| 41 | 41 | //we should also set the header columns |
| 42 | - $csv_data_for_row = $this->get_csv_data( 0, 1 ); |
|
| 43 | - \EE_Registry::instance()->load_helper( 'Export' ); |
|
| 44 | - \EEH_Export::write_data_array_to_csv( $filepath, $csv_data_for_row, true ); |
|
| 42 | + $csv_data_for_row = $this->get_csv_data(0, 1); |
|
| 43 | + \EE_Registry::instance()->load_helper('Export'); |
|
| 44 | + \EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true); |
|
| 45 | 45 | //if we actually processed a row there, record it |
| 46 | - if( $job_parameters->job_size() ) { |
|
| 47 | - $job_parameters->mark_processed( 1 ); |
|
| 46 | + if ($job_parameters->job_size()) { |
|
| 47 | + $job_parameters->mark_processed(1); |
|
| 48 | 48 | } |
| 49 | 49 | return new JobStepResponse( |
| 50 | 50 | $job_parameters, |
| 51 | - __( 'Contacts report started successfully...', 'event_espresso' ) |
|
| 51 | + __('Contacts report started successfully...', 'event_espresso') |
|
| 52 | 52 | ); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | |
| 56 | 56 | public function continue_job(JobParameters $job_parameters, $batch_size = 50) { |
| 57 | - $csv_data = $this->get_csv_data( $job_parameters->units_processed(), $batch_size ); |
|
| 58 | - \EE_Registry::instance()->load_helper( 'Export' ); |
|
| 59 | - \EEH_Export::write_data_array_to_csv( $job_parameters->extra_datum( 'filepath' ), $csv_data, false ); |
|
| 60 | - $units_processed = count( $csv_data ); |
|
| 61 | - $job_parameters->mark_processed( $units_processed ); |
|
| 57 | + $csv_data = $this->get_csv_data($job_parameters->units_processed(), $batch_size); |
|
| 58 | + \EE_Registry::instance()->load_helper('Export'); |
|
| 59 | + \EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false); |
|
| 60 | + $units_processed = count($csv_data); |
|
| 61 | + $job_parameters->mark_processed($units_processed); |
|
| 62 | 62 | $extra_response_data = array( |
| 63 | 63 | 'file_url' => '' |
| 64 | 64 | ); |
| 65 | - if( $units_processed < $batch_size ) { |
|
| 66 | - $job_parameters->set_status( JobParameters::status_complete ); |
|
| 67 | - $extra_response_data[ 'file_url' ] = $this->get_url_to_file( $job_parameters->extra_datum( 'filepath' ) ); |
|
| 65 | + if ($units_processed < $batch_size) { |
|
| 66 | + $job_parameters->set_status(JobParameters::status_complete); |
|
| 67 | + $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath')); |
|
| 68 | 68 | } |
| 69 | 69 | return new JobStepResponse( |
| 70 | 70 | $job_parameters, |
| 71 | 71 | sprintf( |
| 72 | - __( 'Wrote %1$s rows to report CSV file...', 'event_espresso' ), |
|
| 73 | - count( $csv_data ) ), |
|
| 72 | + __('Wrote %1$s rows to report CSV file...', 'event_espresso'), |
|
| 73 | + count($csv_data) ), |
|
| 74 | 74 | $extra_response_data ); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | |
| 78 | 78 | public function cleanup_job(JobParameters $job_parameters) { |
| 79 | 79 | $this->_file_helper->delete( |
| 80 | - \EEH_File::remove_filename_from_filepath( $job_parameters->extra_datum( 'filepath' ) ), |
|
| 80 | + \EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')), |
|
| 81 | 81 | true, |
| 82 | 82 | 'd' |
| 83 | 83 | ); |
| 84 | - return new JobStepResponse( $job_parameters, __( 'Cleaned up temporary file', 'event_espresso' ) ); |
|
| 84 | + return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso')); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | public function count_units_to_process() { |
| 88 | - return \EEM_Attendee::instance()->count( array( 'caps' => \EEM_Base::caps_read_admin )); |
|
| 88 | + return \EEM_Attendee::instance()->count(array('caps' => \EEM_Base::caps_read_admin)); |
|
| 89 | 89 | } |
| 90 | - public function get_csv_data( $offset, $limit ) { |
|
| 90 | + public function get_csv_data($offset, $limit) { |
|
| 91 | 91 | $attendee_rows = \EEM_Attendee::instance()->get_all_wpdb_results( |
| 92 | 92 | array( |
| 93 | - 'limit' => array( $offset, $limit ), |
|
| 94 | - 'force_join' => array( 'State', 'Country' ), |
|
| 93 | + 'limit' => array($offset, $limit), |
|
| 94 | + 'force_join' => array('State', 'Country'), |
|
| 95 | 95 | 'caps' => \EEM_Base::caps_read_admin |
| 96 | 96 | ) |
| 97 | 97 | ); |
| 98 | 98 | $csv_data = array(); |
| 99 | - foreach( $attendee_rows as $attendee_row ){ |
|
| 99 | + foreach ($attendee_rows as $attendee_row) { |
|
| 100 | 100 | $csv_row = array(); |
| 101 | - foreach( \EEM_Attendee::instance()->field_settings() as $field_name => $field_obj ){ |
|
| 102 | - if( $field_name == 'STA_ID' ){ |
|
| 103 | - $state_name_field = \EEM_State::instance()->field_settings_for( 'STA_name' ); |
|
| 104 | - $csv_row[ __( 'State', 'event_espresso' ) ] = $attendee_row[ $state_name_field->get_qualified_column() ]; |
|
| 105 | - }elseif( $field_name == 'CNT_ISO' ){ |
|
| 106 | - $country_name_field = \EEM_Country::instance()->field_settings_for( 'CNT_name' ); |
|
| 107 | - $csv_row[ __( 'Country', 'event_espresso' ) ] = $attendee_row[ $country_name_field->get_qualified_column() ]; |
|
| 108 | - }else{ |
|
| 109 | - $csv_row[ $field_obj->get_nicename() ] = $attendee_row[ $field_obj->get_qualified_column() ]; |
|
| 101 | + foreach (\EEM_Attendee::instance()->field_settings() as $field_name => $field_obj) { |
|
| 102 | + if ($field_name == 'STA_ID') { |
|
| 103 | + $state_name_field = \EEM_State::instance()->field_settings_for('STA_name'); |
|
| 104 | + $csv_row[__('State', 'event_espresso')] = $attendee_row[$state_name_field->get_qualified_column()]; |
|
| 105 | + }elseif ($field_name == 'CNT_ISO') { |
|
| 106 | + $country_name_field = \EEM_Country::instance()->field_settings_for('CNT_name'); |
|
| 107 | + $csv_row[__('Country', 'event_espresso')] = $attendee_row[$country_name_field->get_qualified_column()]; |
|
| 108 | + } else { |
|
| 109 | + $csv_row[$field_obj->get_nicename()] = $attendee_row[$field_obj->get_qualified_column()]; |
|
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | $csv_data[] = $csv_row; |
@@ -19,8 +19,8 @@ discard block |
||
| 19 | 19 | use EventEspressoBatchRequest\Helpers\JobParameters; |
| 20 | 20 | use EventEspressoBatchRequest\Helpers\JobStepResponse; |
| 21 | 21 | |
| 22 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 23 | - exit( 'No direct script access allowed' ); |
|
| 22 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 23 | + exit('No direct script access allowed'); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | |
@@ -35,36 +35,36 @@ discard block |
||
| 35 | 35 | * @throws BatchRequestException |
| 36 | 36 | * @return JobStepResponse |
| 37 | 37 | */ |
| 38 | - public function create_job( JobParameters $job_parameters ) { |
|
| 39 | - $event_id = intval( $job_parameters->request_datum( 'EVT_ID', '0' ) ); |
|
| 40 | - if( ! \EE_Capabilities::instance()->current_user_can( 'ee_read_registrations', 'generating_report' ) ) { |
|
| 38 | + public function create_job(JobParameters $job_parameters) { |
|
| 39 | + $event_id = intval($job_parameters->request_datum('EVT_ID', '0')); |
|
| 40 | + if ( ! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) { |
|
| 41 | 41 | throw new BatchRequestException( |
| 42 | - __( 'You do not have permission to view registrations', 'event_espresso') |
|
| 42 | + __('You do not have permission to view registrations', 'event_espresso') |
|
| 43 | 43 | ); |
| 44 | 44 | } |
| 45 | 45 | $filepath = $this->create_file_from_job_with_name( |
| 46 | 46 | $job_parameters->job_id(), |
| 47 | - $this->get_filename_from_event( $event_id ) |
|
| 47 | + $this->get_filename_from_event($event_id) |
|
| 48 | 48 | ); |
| 49 | - $job_parameters->add_extra_data( 'filepath', $filepath ); |
|
| 50 | - $question_data_for_columns = $this->_get_questions_for_report( $event_id ); |
|
| 51 | - $job_parameters->add_extra_data( 'questions_data', $question_data_for_columns ); |
|
| 52 | - $job_parameters->set_job_size( $this->count_units_to_process( $event_id ) ); |
|
| 49 | + $job_parameters->add_extra_data('filepath', $filepath); |
|
| 50 | + $question_data_for_columns = $this->_get_questions_for_report($event_id); |
|
| 51 | + $job_parameters->add_extra_data('questions_data', $question_data_for_columns); |
|
| 52 | + $job_parameters->set_job_size($this->count_units_to_process($event_id)); |
|
| 53 | 53 | //we should also set the header columns |
| 54 | 54 | $csv_data_for_row = $this->get_csv_data_for( |
| 55 | 55 | $event_id, |
| 56 | 56 | 0, |
| 57 | 57 | 1, |
| 58 | - $job_parameters->extra_datum( 'questions_data' ) ); |
|
| 59 | - \EE_Registry::instance()->load_helper( 'Export' ); |
|
| 60 | - \EEH_Export::write_data_array_to_csv( $filepath, $csv_data_for_row, true ); |
|
| 58 | + $job_parameters->extra_datum('questions_data') ); |
|
| 59 | + \EE_Registry::instance()->load_helper('Export'); |
|
| 60 | + \EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true); |
|
| 61 | 61 | //if we actually processed a row there, record it |
| 62 | - if( $job_parameters->job_size() ) { |
|
| 63 | - $job_parameters->mark_processed( 1 ); |
|
| 62 | + if ($job_parameters->job_size()) { |
|
| 63 | + $job_parameters->mark_processed(1); |
|
| 64 | 64 | } |
| 65 | 65 | return new JobStepResponse( |
| 66 | 66 | $job_parameters, |
| 67 | - __( 'Registrations report started successfully...', 'event_espresso' ) |
|
| 67 | + __('Registrations report started successfully...', 'event_espresso') |
|
| 68 | 68 | ); |
| 69 | 69 | } |
| 70 | 70 | |
@@ -75,16 +75,16 @@ discard block |
||
| 75 | 75 | * @param int $event_id |
| 76 | 76 | * @return string |
| 77 | 77 | */ |
| 78 | - protected function get_filename_from_event( $event_id ) { |
|
| 79 | - if( $event_id ){ |
|
| 80 | - $event_slug = \EEM_Event::instance()->get_var( array( array( 'EVT_ID' => $event_id ) ), 'EVT_slug' ); |
|
| 81 | - if( ! $event_slug ) { |
|
| 82 | - $event_slug = __( 'unknown', 'event_espresso' ); |
|
| 78 | + protected function get_filename_from_event($event_id) { |
|
| 79 | + if ($event_id) { |
|
| 80 | + $event_slug = \EEM_Event::instance()->get_var(array(array('EVT_ID' => $event_id)), 'EVT_slug'); |
|
| 81 | + if ( ! $event_slug) { |
|
| 82 | + $event_slug = __('unknown', 'event_espresso'); |
|
| 83 | 83 | } |
| 84 | - }else{ |
|
| 85 | - $event_slug = __( 'all', 'event_espresso' ); |
|
| 84 | + } else { |
|
| 85 | + $event_slug = __('all', 'event_espresso'); |
|
| 86 | 86 | } |
| 87 | - return sprintf( "registrations-for-%s.csv", $event_slug ); |
|
| 87 | + return sprintf("registrations-for-%s.csv", $event_slug); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -93,17 +93,17 @@ discard block |
||
| 93 | 93 | * @param int|null $event_id |
| 94 | 94 | * @return array of wpdb results for questions which are to be used for this report |
| 95 | 95 | */ |
| 96 | - protected function _get_questions_for_report( $event_id ) { |
|
| 96 | + protected function _get_questions_for_report($event_id) { |
|
| 97 | 97 | $question_query_params = array( |
| 98 | 98 | array( |
| 99 | - 'Answer.ANS_ID' => array( 'IS_NOT_NULL' ), |
|
| 99 | + 'Answer.ANS_ID' => array('IS_NOT_NULL'), |
|
| 100 | 100 | ), |
| 101 | - 'group_by' => array( 'QST_ID' ) |
|
| 101 | + 'group_by' => array('QST_ID') |
|
| 102 | 102 | ); |
| 103 | - if( $event_id ) { |
|
| 103 | + if ($event_id) { |
|
| 104 | 104 | $question_query_params[0]['Answer.Registration.EVT_ID'] = $event_id; |
| 105 | 105 | } |
| 106 | - return \EEM_Question::instance()->get_all_wpdb_results( $question_query_params ); |
|
| 106 | + return \EEM_Question::instance()->get_all_wpdb_results($question_query_params); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | |
@@ -116,28 +116,28 @@ discard block |
||
| 116 | 116 | * @return JobStepResponse |
| 117 | 117 | * @throws \EE_Error |
| 118 | 118 | */ |
| 119 | - public function continue_job( JobParameters $job_parameters, $batch_size = 50 ) { |
|
| 119 | + public function continue_job(JobParameters $job_parameters, $batch_size = 50) { |
|
| 120 | 120 | $csv_data = $this->get_csv_data_for( |
| 121 | - $job_parameters->request_datum( 'EVT_ID', '0'), |
|
| 121 | + $job_parameters->request_datum('EVT_ID', '0'), |
|
| 122 | 122 | $job_parameters->units_processed(), |
| 123 | 123 | $batch_size, |
| 124 | - $job_parameters->extra_datum( 'questions_data' ) ); |
|
| 125 | - \EE_Registry::instance()->load_helper( 'Export' ); |
|
| 126 | - \EEH_Export::write_data_array_to_csv( $job_parameters->extra_datum( 'filepath' ), $csv_data, false ); |
|
| 127 | - $units_processed = count( $csv_data ); |
|
| 128 | - $job_parameters->mark_processed( $units_processed ); |
|
| 124 | + $job_parameters->extra_datum('questions_data') ); |
|
| 125 | + \EE_Registry::instance()->load_helper('Export'); |
|
| 126 | + \EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false); |
|
| 127 | + $units_processed = count($csv_data); |
|
| 128 | + $job_parameters->mark_processed($units_processed); |
|
| 129 | 129 | $extra_response_data = array( |
| 130 | 130 | 'file_url' => '' |
| 131 | 131 | ); |
| 132 | - if( $units_processed < $batch_size ) { |
|
| 133 | - $job_parameters->set_status( JobParameters::status_complete ); |
|
| 134 | - $extra_response_data[ 'file_url' ] = $this->get_url_to_file( $job_parameters->extra_datum( 'filepath' ) ); |
|
| 132 | + if ($units_processed < $batch_size) { |
|
| 133 | + $job_parameters->set_status(JobParameters::status_complete); |
|
| 134 | + $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath')); |
|
| 135 | 135 | } |
| 136 | 136 | return new JobStepResponse( |
| 137 | 137 | $job_parameters, |
| 138 | 138 | sprintf( |
| 139 | - __( 'Wrote %1$s rows to report CSV file...', 'event_espresso' ), |
|
| 140 | - count( $csv_data ) ), |
|
| 139 | + __('Wrote %1$s rows to report CSV file...', 'event_espresso'), |
|
| 140 | + count($csv_data) ), |
|
| 141 | 141 | $extra_response_data ); |
| 142 | 142 | } |
| 143 | 143 | |
@@ -150,8 +150,8 @@ discard block |
||
| 150 | 150 | * @return array top-level keys are numeric, next-level keys are column headers |
| 151 | 151 | * |
| 152 | 152 | */ |
| 153 | - function get_csv_data_for( $event_id, $offset, $limit, $questions_for_these_regs_rows ) { |
|
| 154 | - \EE_Registry::instance()->load_helper( 'Export' ); |
|
| 153 | + function get_csv_data_for($event_id, $offset, $limit, $questions_for_these_regs_rows) { |
|
| 154 | + \EE_Registry::instance()->load_helper('Export'); |
|
| 155 | 155 | $reg_fields_to_include = array( |
| 156 | 156 | 'TXN_ID', |
| 157 | 157 | 'ATT_ID', |
@@ -182,166 +182,166 @@ discard block |
||
| 182 | 182 | array( |
| 183 | 183 | 'OR' => array( |
| 184 | 184 | //don't include registrations from failed or abandoned transactions... |
| 185 | - 'Transaction.STS_ID' => array( 'NOT IN', array( \EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code ) ), |
|
| 185 | + 'Transaction.STS_ID' => array('NOT IN', array(\EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code)), |
|
| 186 | 186 | //unless the registration is approved, in which case include it regardless of transaction status |
| 187 | 187 | 'STS_ID' => \EEM_Registration::status_id_approved |
| 188 | 188 | ), |
| 189 | - 'Ticket.TKT_deleted' => array( 'IN', array( true, false ) ) |
|
| 189 | + 'Ticket.TKT_deleted' => array('IN', array(true, false)) |
|
| 190 | 190 | ), |
| 191 | - 'order_by' => array('Transaction.TXN_ID'=>'asc','REG_count'=>'asc'), |
|
| 192 | - 'force_join' => array( 'Transaction', 'Ticket', 'Attendee' ), |
|
| 193 | - 'limit' => array( $offset, $limit ), |
|
| 191 | + 'order_by' => array('Transaction.TXN_ID'=>'asc', 'REG_count'=>'asc'), |
|
| 192 | + 'force_join' => array('Transaction', 'Ticket', 'Attendee'), |
|
| 193 | + 'limit' => array($offset, $limit), |
|
| 194 | 194 | 'caps' => \EEM_Base::caps_read_admin |
| 195 | 195 | ), |
| 196 | 196 | $event_id |
| 197 | 197 | ); |
| 198 | - if( $event_id ){ |
|
| 199 | - $query_params[0]['EVT_ID'] = $event_id; |
|
| 200 | - }else{ |
|
| 201 | - $query_params[ 'force_join' ][] = 'Event'; |
|
| 198 | + if ($event_id) { |
|
| 199 | + $query_params[0]['EVT_ID'] = $event_id; |
|
| 200 | + } else { |
|
| 201 | + $query_params['force_join'][] = 'Event'; |
|
| 202 | 202 | } |
| 203 | - $registration_rows = $reg_model->get_all_wpdb_results( $query_params ); |
|
| 203 | + $registration_rows = $reg_model->get_all_wpdb_results($query_params); |
|
| 204 | 204 | //get all questions which relate to someone in this group |
| 205 | 205 | $registration_ids = array(); |
| 206 | - foreach( $registration_rows as $reg_row ) { |
|
| 207 | - $registration_ids[] = intval( $reg_row[ 'Registration.REG_ID'] ); |
|
| 206 | + foreach ($registration_rows as $reg_row) { |
|
| 207 | + $registration_ids[] = intval($reg_row['Registration.REG_ID']); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - foreach($registration_rows as $reg_row){ |
|
| 211 | - if ( is_array( $reg_row ) ) { |
|
| 210 | + foreach ($registration_rows as $reg_row) { |
|
| 211 | + if (is_array($reg_row)) { |
|
| 212 | 212 | $reg_csv_array = array(); |
| 213 | - if( ! $event_id ){ |
|
| 213 | + if ( ! $event_id) { |
|
| 214 | 214 | //get the event's name and Id |
| 215 | - $reg_csv_array[ __( 'Event', 'event_espresso' ) ] = sprintf( __( '%1$s (%2$s)', 'event_espresso' ), \EEH_Export::prepare_value_from_db_for_display( \EEM_Event::instance(), 'EVT_name', $reg_row[ 'Event_CPT.post_title'] ), $reg_row[ 'Event_CPT.ID' ] ); |
|
| 215 | + $reg_csv_array[__('Event', 'event_espresso')] = sprintf(__('%1$s (%2$s)', 'event_espresso'), \EEH_Export::prepare_value_from_db_for_display(\EEM_Event::instance(), 'EVT_name', $reg_row['Event_CPT.post_title']), $reg_row['Event_CPT.ID']); |
|
| 216 | 216 | } |
| 217 | - $is_primary_reg = $reg_row[ 'Registration.REG_count' ] == '1' ? true : false; |
|
| 217 | + $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false; |
|
| 218 | 218 | /*@var $reg_row EE_Registration */ |
| 219 | - foreach($reg_fields_to_include as $field_name){ |
|
| 219 | + foreach ($reg_fields_to_include as $field_name) { |
|
| 220 | 220 | $field = $reg_model->field_settings_for($field_name); |
| 221 | - if($field_name == 'REG_final_price'){ |
|
| 222 | - $value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_final_price'], 'localized_float' ); |
|
| 223 | - }elseif( $field_name == 'REG_count' ){ |
|
| 224 | - $value = sprintf( __( '%s of %s', 'event_espresso' ), \EEH_Export::prepare_value_from_db_for_display( $reg_model, 'REG_count', $reg_row['Registration.REG_count'] ), \EEH_Export::prepare_value_from_db_for_display( $reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size' ] ) ); |
|
| 225 | - }elseif( $field_name == 'REG_date' ) { |
|
| 226 | - $value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_date'], 'no_html' ); |
|
| 227 | - }else{ |
|
| 228 | - $value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ $field->get_qualified_column() ] ); |
|
| 221 | + if ($field_name == 'REG_final_price') { |
|
| 222 | + $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_final_price'], 'localized_float'); |
|
| 223 | + }elseif ($field_name == 'REG_count') { |
|
| 224 | + $value = sprintf(__('%s of %s', 'event_espresso'), \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_count', $reg_row['Registration.REG_count']), \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size'])); |
|
| 225 | + }elseif ($field_name == 'REG_date') { |
|
| 226 | + $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_date'], 'no_html'); |
|
| 227 | + } else { |
|
| 228 | + $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, $reg_row[$field->get_qualified_column()]); |
|
| 229 | 229 | } |
| 230 | 230 | $reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = $value; |
| 231 | - if($field_name == 'REG_final_price'){ |
|
| 231 | + if ($field_name == 'REG_final_price') { |
|
| 232 | 232 | //add a column named Currency after the final price |
| 233 | 233 | $reg_csv_array[__("Currency", "event_espresso")] = \EE_Config::instance()->currency->code; |
| 234 | 234 | } |
| 235 | 235 | } |
| 236 | 236 | //get pretty status |
| 237 | - $stati = \EEM_Status::instance()->localized_status( array( |
|
| 238 | - $reg_row[ 'Registration.STS_ID' ] => __( 'unknown', 'event_espresso' ), |
|
| 239 | - $reg_row[ 'Transaction.STS_ID' ] => __( 'unknown', 'event_espresso' ) ), |
|
| 237 | + $stati = \EEM_Status::instance()->localized_status(array( |
|
| 238 | + $reg_row['Registration.STS_ID'] => __('unknown', 'event_espresso'), |
|
| 239 | + $reg_row['Transaction.STS_ID'] => __('unknown', 'event_espresso') ), |
|
| 240 | 240 | FALSE, |
| 241 | - 'sentence' ); |
|
| 242 | - $reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[ $reg_row[ 'Registration.STS_ID' ] ]; |
|
| 241 | + 'sentence'); |
|
| 242 | + $reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']]; |
|
| 243 | 243 | //get pretty transaction status |
| 244 | - $reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[ $reg_row[ 'Transaction.STS_ID' ] ]; |
|
| 245 | - $reg_csv_array[ __( 'Transaction Amount Due', 'event_espresso' ) ] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display( \EEM_Transaction::instance(), 'TXN_total', $reg_row[ 'Transaction.TXN_total' ], 'localized_float' ) : '0.00'; |
|
| 246 | - $reg_csv_array[ __( 'Amount Paid', 'event_espresso' )] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display( \EEM_Transaction::instance(), 'TXN_paid', $reg_row[ 'Transaction.TXN_paid' ], 'localized_float' ) : '0.00'; |
|
| 244 | + $reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[$reg_row['Transaction.STS_ID']]; |
|
| 245 | + $reg_csv_array[__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_total', $reg_row['Transaction.TXN_total'], 'localized_float') : '0.00'; |
|
| 246 | + $reg_csv_array[__('Amount Paid', 'event_espresso')] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_paid', $reg_row['Transaction.TXN_paid'], 'localized_float') : '0.00'; |
|
| 247 | 247 | $payment_methods = array(); |
| 248 | 248 | $gateway_txn_ids_etc = array(); |
| 249 | 249 | $payment_times = array(); |
| 250 | - if( $is_primary_reg && $reg_row[ 'Transaction.TXN_ID' ] ){ |
|
| 250 | + if ($is_primary_reg && $reg_row['Transaction.TXN_ID']) { |
|
| 251 | 251 | $payments_info = \EEM_Payment::instance()->get_all_wpdb_results( |
| 252 | 252 | array( |
| 253 | 253 | array( |
| 254 | - 'TXN_ID' => $reg_row[ 'Transaction.TXN_ID' ], |
|
| 254 | + 'TXN_ID' => $reg_row['Transaction.TXN_ID'], |
|
| 255 | 255 | 'STS_ID' => \EEM_Payment::status_id_approved |
| 256 | 256 | ), |
| 257 | - 'force_join' => array( 'Payment_Method' ), |
|
| 257 | + 'force_join' => array('Payment_Method'), |
|
| 258 | 258 | |
| 259 | 259 | ), |
| 260 | 260 | ARRAY_A, |
| 261 | 261 | 'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time' ); |
| 262 | 262 | |
| 263 | - foreach( $payments_info as $payment_method_and_gateway_txn_id ){ |
|
| 264 | - $payment_methods[] = isset( $payment_method_and_gateway_txn_id[ 'name' ] ) ? $payment_method_and_gateway_txn_id[ 'name' ] : __( 'Unknown', 'event_espresso' ); |
|
| 265 | - $gateway_txn_ids_etc[] = isset( $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] ) ? $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] : ''; |
|
| 266 | - $payment_times[] = isset( $payment_method_and_gateway_txn_id[ 'payment_time' ] ) ? $payment_method_and_gateway_txn_id[ 'payment_time' ] : ''; |
|
| 263 | + foreach ($payments_info as $payment_method_and_gateway_txn_id) { |
|
| 264 | + $payment_methods[] = isset($payment_method_and_gateway_txn_id['name']) ? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso'); |
|
| 265 | + $gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id']) ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : ''; |
|
| 266 | + $payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time']) ? $payment_method_and_gateway_txn_id['payment_time'] : ''; |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | } |
| 270 | - $reg_csv_array[ __( 'Payment Date(s)', 'event_espresso' ) ] = implode( ',', $payment_times ); |
|
| 271 | - $reg_csv_array[ __( 'Payment Method(s)', 'event_espresso' ) ] = implode( ",", $payment_methods ); |
|
| 272 | - $reg_csv_array[ __( 'Gateway Transaction ID(s)', 'event_espresso' )] = implode( ',', $gateway_txn_ids_etc ); |
|
| 270 | + $reg_csv_array[__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times); |
|
| 271 | + $reg_csv_array[__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods); |
|
| 272 | + $reg_csv_array[__('Gateway Transaction ID(s)', 'event_espresso')] = implode(',', $gateway_txn_ids_etc); |
|
| 273 | 273 | |
| 274 | 274 | //get whether or not the user has checked in |
| 275 | - $reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related( $reg_row[ 'Registration.REG_ID'] , 'Checkin' ); |
|
| 275 | + $reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related($reg_row['Registration.REG_ID'], 'Checkin'); |
|
| 276 | 276 | //get ticket of registration and its price |
| 277 | 277 | $ticket_model = \EE_Registry::instance()->load_model('Ticket'); |
| 278 | - if( $reg_row[ 'Ticket.TKT_ID'] ) { |
|
| 279 | - $ticket_name = \EEH_Export::prepare_value_from_db_for_display( $ticket_model, 'TKT_name', $reg_row[ 'Ticket.TKT_name' ] ); |
|
| 278 | + if ($reg_row['Ticket.TKT_ID']) { |
|
| 279 | + $ticket_name = \EEH_Export::prepare_value_from_db_for_display($ticket_model, 'TKT_name', $reg_row['Ticket.TKT_name']); |
|
| 280 | 280 | $datetimes_strings = array(); |
| 281 | - foreach( \EEM_Datetime::instance()->get_all_wpdb_results( array( array( 'Ticket.TKT_ID' => $reg_row[ 'Ticket.TKT_ID' ] ), 'order_by' => array( 'DTT_EVT_start' => 'ASC' ), 'default_where_conditions' => 'none' ) ) as $datetime){ |
|
| 282 | - $datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display( \EEM_Datetime::instance(), 'DTT_EVT_start', $datetime[ 'Datetime.DTT_EVT_start'] ); |
|
| 281 | + foreach (\EEM_Datetime::instance()->get_all_wpdb_results(array(array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']), 'order_by' => array('DTT_EVT_start' => 'ASC'), 'default_where_conditions' => 'none')) as $datetime) { |
|
| 282 | + $datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display(\EEM_Datetime::instance(), 'DTT_EVT_start', $datetime['Datetime.DTT_EVT_start']); |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | } else { |
| 286 | - $ticket_name = __( 'Unknown', 'event_espresso' ); |
|
| 287 | - $datetimes_strings = array( __( 'Unknown', 'event_espresso' ) ); |
|
| 286 | + $ticket_name = __('Unknown', 'event_espresso'); |
|
| 287 | + $datetimes_strings = array(__('Unknown', 'event_espresso')); |
|
| 288 | 288 | } |
| 289 | 289 | $reg_csv_array[$ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name; |
| 290 | 290 | $reg_csv_array[__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings); |
| 291 | 291 | //get datetime(s) of registration |
| 292 | 292 | |
| 293 | 293 | //add attendee columns |
| 294 | - foreach($att_fields_to_include as $att_field_name){ |
|
| 294 | + foreach ($att_fields_to_include as $att_field_name) { |
|
| 295 | 295 | $field_obj = \EEM_Attendee::instance()->field_settings_for($att_field_name); |
| 296 | - if( $reg_row[ 'Attendee_CPT.ID' ]){ |
|
| 297 | - if($att_field_name == 'STA_ID'){ |
|
| 298 | - $value = \EEM_State::instance()->get_var( array( array( 'STA_ID' => $reg_row[ 'Attendee_Meta.STA_ID' ] ) ), 'STA_name' ); |
|
| 299 | - }elseif($att_field_name == 'CNT_ISO'){ |
|
| 300 | - $value = \EEM_Country::instance()->get_var( array( array( 'CNT_ISO' => $reg_row[ 'Attendee_Meta.CNT_ISO' ] ) ), 'CNT_name' ); |
|
| 301 | - }else{ |
|
| 302 | - $value = \EEH_Export::prepare_value_from_db_for_display( \EEM_Attendee::instance(), $att_field_name, $reg_row[ $field_obj->get_qualified_column() ] ); |
|
| 296 | + if ($reg_row['Attendee_CPT.ID']) { |
|
| 297 | + if ($att_field_name == 'STA_ID') { |
|
| 298 | + $value = \EEM_State::instance()->get_var(array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])), 'STA_name'); |
|
| 299 | + }elseif ($att_field_name == 'CNT_ISO') { |
|
| 300 | + $value = \EEM_Country::instance()->get_var(array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])), 'CNT_name'); |
|
| 301 | + } else { |
|
| 302 | + $value = \EEH_Export::prepare_value_from_db_for_display(\EEM_Attendee::instance(), $att_field_name, $reg_row[$field_obj->get_qualified_column()]); |
|
| 303 | 303 | } |
| 304 | - }else{ |
|
| 304 | + } else { |
|
| 305 | 305 | $value = ''; |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - $reg_csv_array[ \EEH_Export::get_column_name_for_field($field_obj) ] = $value; |
|
| 308 | + $reg_csv_array[\EEH_Export::get_column_name_for_field($field_obj)] = $value; |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | //make sure each registration has the same questions in the same order |
| 312 | - foreach($questions_for_these_regs_rows as $question_row){ |
|
| 313 | - if( ! isset($reg_csv_array[$question_row[ 'Question.QST_admin_label']])){ |
|
| 314 | - $reg_csv_array[$question_row[ 'Question.QST_admin_label' ] ] = null; |
|
| 312 | + foreach ($questions_for_these_regs_rows as $question_row) { |
|
| 313 | + if ( ! isset($reg_csv_array[$question_row['Question.QST_admin_label']])) { |
|
| 314 | + $reg_csv_array[$question_row['Question.QST_admin_label']] = null; |
|
| 315 | 315 | } |
| 316 | 316 | } |
| 317 | 317 | $answers = \EEM_Answer::instance()->get_all_wpdb_results( |
| 318 | 318 | array( |
| 319 | - array( 'REG_ID' => $reg_row[ 'Registration.REG_ID' ] ), |
|
| 320 | - 'force_join' => array( 'Question' ) |
|
| 319 | + array('REG_ID' => $reg_row['Registration.REG_ID']), |
|
| 320 | + 'force_join' => array('Question') |
|
| 321 | 321 | ) |
| 322 | 322 | ); |
| 323 | 323 | //now fill out the questions THEY answered |
| 324 | - foreach( $answers as $answer_row ){ |
|
| 325 | - if( $answer_row[ 'Question.QST_ID' ] ){ |
|
| 324 | + foreach ($answers as $answer_row) { |
|
| 325 | + if ($answer_row['Question.QST_ID']) { |
|
| 326 | 326 | $question_label = \EEH_Export::prepare_value_from_db_for_display( |
| 327 | 327 | \EEM_Question::instance(), |
| 328 | 328 | 'QST_admin_label', |
| 329 | - $answer_row[ 'Question.QST_admin_label' ] |
|
| 329 | + $answer_row['Question.QST_admin_label'] |
|
| 330 | 330 | ); |
| 331 | 331 | } else { |
| 332 | - $question_label = sprintf( __( 'Question $s', 'event_espresso' ), $answer_row[ 'Answer.QST_ID' ] ); |
|
| 332 | + $question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']); |
|
| 333 | 333 | } |
| 334 | - if ( isset( $answer_row[ 'Question.QST_type' ] ) |
|
| 335 | - && $answer_row[ 'Question.QST_type' ] == \EEM_Question::QST_type_state |
|
| 334 | + if (isset($answer_row['Question.QST_type']) |
|
| 335 | + && $answer_row['Question.QST_type'] == \EEM_Question::QST_type_state |
|
| 336 | 336 | ) { |
| 337 | - $reg_csv_array[ $question_label ] = \EEM_State::instance()->get_state_name_by_ID( |
|
| 338 | - $answer_row[ 'Answer.ANS_value' ] |
|
| 337 | + $reg_csv_array[$question_label] = \EEM_State::instance()->get_state_name_by_ID( |
|
| 338 | + $answer_row['Answer.ANS_value'] |
|
| 339 | 339 | ); |
| 340 | 340 | } else { |
| 341 | - $reg_csv_array[ $question_label ] = \EEH_Export::prepare_value_from_db_for_display( |
|
| 341 | + $reg_csv_array[$question_label] = \EEH_Export::prepare_value_from_db_for_display( |
|
| 342 | 342 | \EEM_Answer::instance(), |
| 343 | 343 | 'ANS_value', |
| 344 | - $answer_row[ 'Answer.ANS_value' ] |
|
| 344 | + $answer_row['Answer.ANS_value'] |
|
| 345 | 345 | ); |
| 346 | 346 | } |
| 347 | 347 | } |
@@ -352,17 +352,17 @@ discard block |
||
| 352 | 352 | } |
| 353 | 353 | } |
| 354 | 354 | //if we couldn't export anything, we want to at least show the column headers |
| 355 | - if ( empty( $registrations_csv_ready_array ) ) { |
|
| 355 | + if (empty($registrations_csv_ready_array)) { |
|
| 356 | 356 | $reg_csv_array = array(); |
| 357 | 357 | $model_and_fields_to_include = array( |
| 358 | 358 | 'Registration' => $reg_fields_to_include, |
| 359 | 359 | 'Attendee' => $att_fields_to_include |
| 360 | 360 | ); |
| 361 | - foreach ( $model_and_fields_to_include as $model_name => $field_list ) { |
|
| 362 | - $model = \EE_Registry::instance()->load_model( $model_name ); |
|
| 363 | - foreach ( $field_list as $field_name ) { |
|
| 364 | - $field = $model->field_settings_for( $field_name ); |
|
| 365 | - $reg_csv_array[ \EEH_Export::get_column_name_for_field( $field ) ] = null; |
|
| 361 | + foreach ($model_and_fields_to_include as $model_name => $field_list) { |
|
| 362 | + $model = \EE_Registry::instance()->load_model($model_name); |
|
| 363 | + foreach ($field_list as $field_name) { |
|
| 364 | + $field = $model->field_settings_for($field_name); |
|
| 365 | + $reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = null; |
|
| 366 | 366 | } |
| 367 | 367 | } |
| 368 | 368 | $registrations_csv_ready_array[] = $reg_csv_array; |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | * @param int $event_id |
| 379 | 379 | * @return int |
| 380 | 380 | */ |
| 381 | - public function count_units_to_process( $event_id ) { |
|
| 381 | + public function count_units_to_process($event_id) { |
|
| 382 | 382 | //use the legacy filter |
| 383 | 383 | $query_params = apply_filters( |
| 384 | 384 | 'FHEE__EE_Export__report_registration_for_event', |
@@ -386,24 +386,24 @@ discard block |
||
| 386 | 386 | array( |
| 387 | 387 | 'OR' => array( |
| 388 | 388 | //don't include registrations from failed or abandoned transactions... |
| 389 | - 'Transaction.STS_ID' => array( 'NOT IN', array( \EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code ) ), |
|
| 389 | + 'Transaction.STS_ID' => array('NOT IN', array(\EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code)), |
|
| 390 | 390 | //unless the registration is approved, in which case include it regardless of transaction status |
| 391 | 391 | 'STS_ID' => \EEM_Registration::status_id_approved |
| 392 | 392 | ), |
| 393 | - 'Ticket.TKT_deleted' => array( 'IN', array( true, false ) ) |
|
| 393 | + 'Ticket.TKT_deleted' => array('IN', array(true, false)) |
|
| 394 | 394 | ), |
| 395 | - 'order_by' => array('Transaction.TXN_ID'=>'asc','REG_count'=>'asc'), |
|
| 396 | - 'force_join' => array( 'Transaction', 'Ticket', 'Attendee' ), |
|
| 395 | + 'order_by' => array('Transaction.TXN_ID'=>'asc', 'REG_count'=>'asc'), |
|
| 396 | + 'force_join' => array('Transaction', 'Ticket', 'Attendee'), |
|
| 397 | 397 | 'caps' => \EEM_Base::caps_read_admin |
| 398 | 398 | ), |
| 399 | 399 | $event_id |
| 400 | 400 | ); |
| 401 | - if( $event_id ){ |
|
| 402 | - $query_params[0]['EVT_ID'] = $event_id; |
|
| 401 | + if ($event_id) { |
|
| 402 | + $query_params[0]['EVT_ID'] = $event_id; |
|
| 403 | 403 | } else { |
| 404 | - $query_params[ 'force_join' ][] = 'Event'; |
|
| 404 | + $query_params['force_join'][] = 'Event'; |
|
| 405 | 405 | } |
| 406 | - return \EEM_Registration::instance()->count( $query_params ); |
|
| 406 | + return \EEM_Registration::instance()->count($query_params); |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | |
@@ -414,13 +414,13 @@ discard block |
||
| 414 | 414 | * @param JobParameters $job_parameters |
| 415 | 415 | * @return boolean |
| 416 | 416 | */ |
| 417 | - public function cleanup_job( JobParameters $job_parameters ){ |
|
| 417 | + public function cleanup_job(JobParameters $job_parameters) { |
|
| 418 | 418 | $this->_file_helper->delete( |
| 419 | - \EEH_File::remove_filename_from_filepath( $job_parameters->extra_datum( 'filepath' ) ), |
|
| 419 | + \EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')), |
|
| 420 | 420 | true, |
| 421 | 421 | 'd' |
| 422 | 422 | ); |
| 423 | - return new JobStepResponse( $job_parameters, __( 'Cleaned up temporary file', 'event_espresso' ) ); |
|
| 423 | + return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso')); |
|
| 424 | 424 | } |
| 425 | 425 | } |
| 426 | 426 | |
@@ -24,14 +24,14 @@ discard block |
||
| 24 | 24 | * But either way, the string or the array's values can ONLY contain simple HTML tags. |
| 25 | 25 | * If you want to allow Full HTML in the value, use EE_Maybe_Serialized_Text_Field |
| 26 | 26 | */ |
| 27 | -class EE_Maybe_Serialized_Simple_HTML_Field extends EE_Maybe_Serialized_Text_Field{ |
|
| 27 | +class EE_Maybe_Serialized_Simple_HTML_Field extends EE_Maybe_Serialized_Text_Field { |
|
| 28 | 28 | /** |
| 29 | 29 | * removes all non-basic tags when setting |
| 30 | 30 | * @param string $value_inputted_for_field_on_model_object |
| 31 | 31 | * @return string |
| 32 | 32 | */ |
| 33 | 33 | function prepare_for_set($value_inputted_for_field_on_model_object) { |
| 34 | - return parent::prepare_for_set( $this->_remove_tags( $value_inputted_for_field_on_model_object ) ); |
|
| 34 | + return parent::prepare_for_set($this->_remove_tags($value_inputted_for_field_on_model_object)); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -39,13 +39,13 @@ discard block |
||
| 39 | 39 | * @param array|string $value |
| 40 | 40 | * @return array|string |
| 41 | 41 | */ |
| 42 | - protected function _remove_tags( $value ) { |
|
| 43 | - if( is_array( $value ) ) { |
|
| 44 | - foreach( $value as $key => $v ) { |
|
| 45 | - $value[ $key ] = $this->_remove_tags( $v ); |
|
| 42 | + protected function _remove_tags($value) { |
|
| 43 | + if (is_array($value)) { |
|
| 44 | + foreach ($value as $key => $v) { |
|
| 45 | + $value[$key] = $this->_remove_tags($v); |
|
| 46 | 46 | } |
| 47 | - }elseif( is_string( $value ) ) { |
|
| 48 | - $value = wp_kses("$value", $this->_get_allowed_tags() ); |
|
| 47 | + }elseif (is_string($value)) { |
|
| 48 | + $value = wp_kses("$value", $this->_get_allowed_tags()); |
|
| 49 | 49 | } |
| 50 | 50 | return $value; |
| 51 | 51 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * @return array|string |
| 57 | 57 | */ |
| 58 | 58 | function prepare_for_set_from_db($value_found_in_db_for_model_object) { |
| 59 | - return $this->_remove_tags( parent::prepare_for_set_from_db( $value_found_in_db_for_model_object ) ); |
|
| 59 | + return $this->_remove_tags(parent::prepare_for_set_from_db($value_found_in_db_for_model_object)); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * @global array $allowedtags |
| 66 | 66 | * @return array |
| 67 | 67 | */ |
| 68 | - function _get_allowed_tags(){ |
|
| 69 | - return apply_filters( 'FHEE__EE_Maybe_Serialized_Simple_HTML_Field___get_allowed_tags', EEH_HTML::get_simple_tags(), $this ); |
|
| 68 | + function _get_allowed_tags() { |
|
| 69 | + return apply_filters('FHEE__EE_Maybe_Serialized_Simple_HTML_Field___get_allowed_tags', EEH_HTML::get_simple_tags(), $this); |
|
| 70 | 70 | } |
| 71 | 71 | } |
@@ -1,18 +1,18 @@ |
||
| 1 | 1 | <?php |
| 2 | -require_once( EE_MODELS . 'fields/EE_Text_Field_Base.php' ); |
|
| 2 | +require_once(EE_MODELS.'fields/EE_Text_Field_Base.php'); |
|
| 3 | 3 | /** |
| 4 | 4 | * Only allows a select, small number of html tags: a,abbr,acronym,b,blockquote,cite,code,del,em,i,q,strike,strong,ol,ul,li |
| 5 | 5 | * If you want more use EE_Post_Content_Field, or if you want to allow ALL, use EE_Full_HTML_Field. |
| 6 | 6 | * If you want NONE, use EE_Plain_Text_Field. |
| 7 | 7 | */ |
| 8 | -class EE_Simple_HTML_Field extends EE_Text_Field_Base{ |
|
| 8 | +class EE_Simple_HTML_Field extends EE_Text_Field_Base { |
|
| 9 | 9 | /** |
| 10 | 10 | * removes all tags when setting |
| 11 | 11 | * @param string $value_inputted_for_field_on_model_object |
| 12 | 12 | * @return string |
| 13 | 13 | */ |
| 14 | 14 | function prepare_for_set($value_inputted_for_field_on_model_object) { |
| 15 | - $value_with_select_tags = wp_kses("$value_inputted_for_field_on_model_object", EEH_HTML::get_simple_tags() ); |
|
| 15 | + $value_with_select_tags = wp_kses("$value_inputted_for_field_on_model_object", EEH_HTML::get_simple_tags()); |
|
| 16 | 16 | return parent::prepare_for_set($value_with_select_tags); |
| 17 | 17 | } |
| 18 | 18 | |
@@ -10,17 +10,17 @@ discard block |
||
| 10 | 10 | * @since 4.6 |
| 11 | 11 | * |
| 12 | 12 | */ |
| 13 | -class EE_Simple_HTML_Validation_Strategy extends EE_Validation_Strategy_Base{ |
|
| 13 | +class EE_Simple_HTML_Validation_Strategy extends EE_Validation_Strategy_Base { |
|
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * @param null $validation_error_message |
| 17 | 17 | */ |
| 18 | - public function __construct( $validation_error_message = NULL ) { |
|
| 19 | - if( ! $validation_error_message ){ |
|
| 18 | + public function __construct($validation_error_message = NULL) { |
|
| 19 | + if ( ! $validation_error_message) { |
|
| 20 | 20 | $allowedtags = $this->_get_allowed_tags(); |
| 21 | - $validation_error_message = sprintf( __( "Only simple HTML tags are allowed. Eg, %s", "event_espresso" ), implode( ",", array_keys( $allowedtags ) ) ); |
|
| 21 | + $validation_error_message = sprintf(__("Only simple HTML tags are allowed. Eg, %s", "event_espresso"), implode(",", array_keys($allowedtags))); |
|
| 22 | 22 | } |
| 23 | - parent::__construct( $validation_error_message ); |
|
| 23 | + parent::__construct($validation_error_message); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | |
@@ -40,10 +40,10 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | public function validate($normalized_value) { |
| 42 | 42 | $allowedtags = $this->_get_allowed_tags(); |
| 43 | - parent::validate( $normalized_value ); |
|
| 44 | - $normalized_value_sans_tags = wp_kses( "$normalized_value",$allowedtags ); |
|
| 45 | - if ( strlen( $normalized_value ) > strlen( $normalized_value_sans_tags ) ) { |
|
| 46 | - throw new EE_Validation_Error( $this->get_validation_error_message(), 'complex_html_tags' ); |
|
| 43 | + parent::validate($normalized_value); |
|
| 44 | + $normalized_value_sans_tags = wp_kses("$normalized_value", $allowedtags); |
|
| 45 | + if (strlen($normalized_value) > strlen($normalized_value_sans_tags)) { |
|
| 46 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'complex_html_tags'); |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | \ No newline at end of file |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | public static function instance() { |
| 43 | 43 | // check if class object is instantiated, and instantiated properly |
| 44 | - if ( ! self::$_instance instanceof EEH_HTML ) { |
|
| 44 | + if ( ! self::$_instance instanceof EEH_HTML) { |
|
| 45 | 45 | self::$_instance = new EEH_HTML(); |
| 46 | 46 | } |
| 47 | 47 | return self::$_instance; |
@@ -102,14 +102,14 @@ discard block |
||
| 102 | 102 | $other_attributes = '', |
| 103 | 103 | $force_close = false |
| 104 | 104 | ) { |
| 105 | - $attributes = ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : ''; |
|
| 106 | - $attributes .= ! empty( $class ) ? ' class="' . $class . '"' : ''; |
|
| 107 | - $attributes .= ! empty( $style ) ? ' style="' . $style . '"' : ''; |
|
| 108 | - $attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : ''; |
|
| 109 | - $html = EEH_HTML::nl( 0, $tag ) . '<' . $tag . $attributes . '>'; |
|
| 110 | - $html .= ! empty( $content ) ? EEH_HTML::nl( 1, $tag ) . $content : ''; |
|
| 111 | - $indent = ! empty( $content ) || $force_close ? TRUE : FALSE; |
|
| 112 | - $html .= ! empty( $content ) || $force_close ? EEH_HTML::_close_tag( $tag, $id, $class, $indent ) : ''; |
|
| 105 | + $attributes = ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : ''; |
|
| 106 | + $attributes .= ! empty($class) ? ' class="'.$class.'"' : ''; |
|
| 107 | + $attributes .= ! empty($style) ? ' style="'.$style.'"' : ''; |
|
| 108 | + $attributes .= ! empty($other_attributes) ? ' '.$other_attributes : ''; |
|
| 109 | + $html = EEH_HTML::nl(0, $tag).'<'.$tag.$attributes.'>'; |
|
| 110 | + $html .= ! empty($content) ? EEH_HTML::nl(1, $tag).$content : ''; |
|
| 111 | + $indent = ! empty($content) || $force_close ? TRUE : FALSE; |
|
| 112 | + $html .= ! empty($content) || $force_close ? EEH_HTML::_close_tag($tag, $id, $class, $indent) : ''; |
|
| 113 | 113 | return $html; |
| 114 | 114 | } |
| 115 | 115 | |
@@ -126,15 +126,15 @@ discard block |
||
| 126 | 126 | * @param bool $indent |
| 127 | 127 | * @return string |
| 128 | 128 | */ |
| 129 | - protected static function _close_tag( $tag = 'div', $id = '', $class = '', $indent = TRUE ) { |
|
| 129 | + protected static function _close_tag($tag = 'div', $id = '', $class = '', $indent = TRUE) { |
|
| 130 | 130 | $comment = ''; |
| 131 | - if ( $id ) { |
|
| 132 | - $comment = EEH_HTML::comment( 'close ' . $id ) . EEH_HTML::nl( 0, $tag ); |
|
| 133 | - } else if ( $class ) { |
|
| 134 | - $comment = EEH_HTML::comment( 'close ' . $class ) . EEH_HTML::nl( 0, $tag ); |
|
| 131 | + if ($id) { |
|
| 132 | + $comment = EEH_HTML::comment('close '.$id).EEH_HTML::nl(0, $tag); |
|
| 133 | + } else if ($class) { |
|
| 134 | + $comment = EEH_HTML::comment('close '.$class).EEH_HTML::nl(0, $tag); |
|
| 135 | 135 | } |
| 136 | 136 | $html = $indent ? EEH_HTML::nl( -1, $tag ) : ''; |
| 137 | - $html .= '</' . $tag . '>' . $comment; |
|
| 137 | + $html .= '</'.$tag.'>'.$comment; |
|
| 138 | 138 | return $html; |
| 139 | 139 | } |
| 140 | 140 | |
@@ -153,8 +153,8 @@ discard block |
||
| 153 | 153 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
| 154 | 154 | * @return string |
| 155 | 155 | */ |
| 156 | - public static function div( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
| 157 | - return EEH_HTML::_open_tag( 'div', $content, $id, $class, $style, $other_attributes ); |
|
| 156 | + public static function div($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
| 157 | + return EEH_HTML::_open_tag('div', $content, $id, $class, $style, $other_attributes); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | |
@@ -167,8 +167,8 @@ discard block |
||
| 167 | 167 | * @param string $class - html class attribute |
| 168 | 168 | * @return string |
| 169 | 169 | */ |
| 170 | - public static function divx( $id = '', $class = '' ) { |
|
| 171 | - return EEH_HTML::_close_tag( 'div', $id, $class ); |
|
| 170 | + public static function divx($id = '', $class = '') { |
|
| 171 | + return EEH_HTML::_close_tag('div', $id, $class); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | |
@@ -184,8 +184,8 @@ discard block |
||
| 184 | 184 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
| 185 | 185 | * @return string |
| 186 | 186 | */ |
| 187 | - public static function h1( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
| 188 | - return EEH_HTML::_open_tag( 'h1', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
| 187 | + public static function h1($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
| 188 | + return EEH_HTML::_open_tag('h1', $content, $id, $class, $style, $other_attributes, TRUE); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | |
@@ -201,8 +201,8 @@ discard block |
||
| 201 | 201 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
| 202 | 202 | * @return string |
| 203 | 203 | */ |
| 204 | - public static function h2( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
| 205 | - return EEH_HTML::_open_tag( 'h2', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
| 204 | + public static function h2($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
| 205 | + return EEH_HTML::_open_tag('h2', $content, $id, $class, $style, $other_attributes, TRUE); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | |
@@ -218,8 +218,8 @@ discard block |
||
| 218 | 218 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
| 219 | 219 | * @return string |
| 220 | 220 | */ |
| 221 | - public static function h3( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
| 222 | - return EEH_HTML::_open_tag( 'h3', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
| 221 | + public static function h3($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
| 222 | + return EEH_HTML::_open_tag('h3', $content, $id, $class, $style, $other_attributes, TRUE); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | |
@@ -235,8 +235,8 @@ discard block |
||
| 235 | 235 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
| 236 | 236 | * @return string |
| 237 | 237 | */ |
| 238 | - public static function h4( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
| 239 | - return EEH_HTML::_open_tag( 'h4', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
| 238 | + public static function h4($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
| 239 | + return EEH_HTML::_open_tag('h4', $content, $id, $class, $style, $other_attributes, TRUE); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | |
@@ -252,8 +252,8 @@ discard block |
||
| 252 | 252 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
| 253 | 253 | * @return string |
| 254 | 254 | */ |
| 255 | - public static function h5( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
| 256 | - return EEH_HTML::_open_tag( 'h5', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
| 255 | + public static function h5($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
| 256 | + return EEH_HTML::_open_tag('h5', $content, $id, $class, $style, $other_attributes, TRUE); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | |
@@ -269,8 +269,8 @@ discard block |
||
| 269 | 269 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
| 270 | 270 | * @return string |
| 271 | 271 | */ |
| 272 | - public static function h6( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
| 273 | - return EEH_HTML::_open_tag( 'h6', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
| 272 | + public static function h6($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
| 273 | + return EEH_HTML::_open_tag('h6', $content, $id, $class, $style, $other_attributes, TRUE); |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | |
@@ -286,8 +286,8 @@ discard block |
||
| 286 | 286 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
| 287 | 287 | * @return string |
| 288 | 288 | */ |
| 289 | - public static function p( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
| 290 | - return EEH_HTML::_open_tag( 'p', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
| 289 | + public static function p($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
| 290 | + return EEH_HTML::_open_tag('p', $content, $id, $class, $style, $other_attributes, TRUE); |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | |
@@ -302,8 +302,8 @@ discard block |
||
| 302 | 302 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
| 303 | 303 | * @return string |
| 304 | 304 | */ |
| 305 | - public static function ul( $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
| 306 | - return EEH_HTML::_open_tag( 'ul', '', $id, $class, $style, $other_attributes ); |
|
| 305 | + public static function ul($id = '', $class = '', $style = '', $other_attributes = '') { |
|
| 306 | + return EEH_HTML::_open_tag('ul', '', $id, $class, $style, $other_attributes); |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | |
@@ -316,8 +316,8 @@ discard block |
||
| 316 | 316 | * @param string $class - html class attribute |
| 317 | 317 | * @return string |
| 318 | 318 | */ |
| 319 | - public static function ulx( $id = '', $class = '' ) { |
|
| 320 | - return EEH_HTML::_close_tag( 'ul', $id, $class ); |
|
| 319 | + public static function ulx($id = '', $class = '') { |
|
| 320 | + return EEH_HTML::_close_tag('ul', $id, $class); |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | |
@@ -334,8 +334,8 @@ discard block |
||
| 334 | 334 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
| 335 | 335 | * @return string |
| 336 | 336 | */ |
| 337 | - public static function li( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
| 338 | - return EEH_HTML::_open_tag( 'li', $content, $id, $class, $style, $other_attributes ); |
|
| 337 | + public static function li($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
| 338 | + return EEH_HTML::_open_tag('li', $content, $id, $class, $style, $other_attributes); |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | |
@@ -348,8 +348,8 @@ discard block |
||
| 348 | 348 | * @param string $class - html class attribute |
| 349 | 349 | * @return string |
| 350 | 350 | */ |
| 351 | - public static function lix( $id = '', $class = '' ) { |
|
| 352 | - return EEH_HTML::_close_tag( 'li', $id, $class ); |
|
| 351 | + public static function lix($id = '', $class = '') { |
|
| 352 | + return EEH_HTML::_close_tag('li', $id, $class); |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | |
@@ -365,8 +365,8 @@ discard block |
||
| 365 | 365 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
| 366 | 366 | * @return string |
| 367 | 367 | */ |
| 368 | - public static function table( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
| 369 | - return EEH_HTML::_open_tag( 'table', $content, $id, $class, $style, $other_attributes ); |
|
| 368 | + public static function table($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
| 369 | + return EEH_HTML::_open_tag('table', $content, $id, $class, $style, $other_attributes); |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | |
@@ -378,8 +378,8 @@ discard block |
||
| 378 | 378 | * @param string $class - html class attribute |
| 379 | 379 | * @return string |
| 380 | 380 | */ |
| 381 | - public static function tablex( $id = '', $class = '' ) { |
|
| 382 | - return EEH_HTML::_close_tag( 'table', $id, $class ); |
|
| 381 | + public static function tablex($id = '', $class = '') { |
|
| 382 | + return EEH_HTML::_close_tag('table', $id, $class); |
|
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | |
@@ -395,8 +395,8 @@ discard block |
||
| 395 | 395 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
| 396 | 396 | * @return string |
| 397 | 397 | */ |
| 398 | - public static function thead( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
| 399 | - return EEH_HTML::_open_tag( 'thead', $content, $id, $class, $style, $other_attributes ); |
|
| 398 | + public static function thead($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
| 399 | + return EEH_HTML::_open_tag('thead', $content, $id, $class, $style, $other_attributes); |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | |
@@ -408,8 +408,8 @@ discard block |
||
| 408 | 408 | * @param string $class - html class attribute |
| 409 | 409 | * @return string |
| 410 | 410 | */ |
| 411 | - public static function theadx( $id = '', $class = '' ) { |
|
| 412 | - return EEH_HTML::_close_tag( 'thead', $id, $class ); |
|
| 411 | + public static function theadx($id = '', $class = '') { |
|
| 412 | + return EEH_HTML::_close_tag('thead', $id, $class); |
|
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | |
@@ -425,8 +425,8 @@ discard block |
||
| 425 | 425 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
| 426 | 426 | * @return string |
| 427 | 427 | */ |
| 428 | - public static function tbody( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
| 429 | - return EEH_HTML::_open_tag( 'tbody', $content, $id, $class, $style, $other_attributes ); |
|
| 428 | + public static function tbody($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
| 429 | + return EEH_HTML::_open_tag('tbody', $content, $id, $class, $style, $other_attributes); |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | |
@@ -438,8 +438,8 @@ discard block |
||
| 438 | 438 | * @param string $class - html class attribute |
| 439 | 439 | * @return string |
| 440 | 440 | */ |
| 441 | - public static function tbodyx( $id = '', $class = '' ) { |
|
| 442 | - return EEH_HTML::_close_tag( 'tbody', $id, $class ); |
|
| 441 | + public static function tbodyx($id = '', $class = '') { |
|
| 442 | + return EEH_HTML::_close_tag('tbody', $id, $class); |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | |
@@ -455,8 +455,8 @@ discard block |
||
| 455 | 455 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
| 456 | 456 | * @return string |
| 457 | 457 | */ |
| 458 | - public static function tr( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
| 459 | - return EEH_HTML::_open_tag( 'tr', $content, $id, $class, $style, $other_attributes ); |
|
| 458 | + public static function tr($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
| 459 | + return EEH_HTML::_open_tag('tr', $content, $id, $class, $style, $other_attributes); |
|
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | |
@@ -468,8 +468,8 @@ discard block |
||
| 468 | 468 | * @param string $class - html class attribute |
| 469 | 469 | * @return string |
| 470 | 470 | */ |
| 471 | - public static function trx( $id = '', $class = '' ) { |
|
| 472 | - return EEH_HTML::_close_tag( 'tr', $id, $class ); |
|
| 471 | + public static function trx($id = '', $class = '') { |
|
| 472 | + return EEH_HTML::_close_tag('tr', $id, $class); |
|
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | |
@@ -485,8 +485,8 @@ discard block |
||
| 485 | 485 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
| 486 | 486 | * @return string |
| 487 | 487 | */ |
| 488 | - public static function th( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
| 489 | - return EEH_HTML::_open_tag( 'th', $content, $id, $class, $style, $other_attributes ); |
|
| 488 | + public static function th($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
| 489 | + return EEH_HTML::_open_tag('th', $content, $id, $class, $style, $other_attributes); |
|
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | |
@@ -498,8 +498,8 @@ discard block |
||
| 498 | 498 | * @param string $class - html class attribute |
| 499 | 499 | * @return string |
| 500 | 500 | */ |
| 501 | - public static function thx( $id = '', $class = '' ) { |
|
| 502 | - return EEH_HTML::_close_tag( 'th', $id, $class ); |
|
| 501 | + public static function thx($id = '', $class = '') { |
|
| 502 | + return EEH_HTML::_close_tag('th', $id, $class); |
|
| 503 | 503 | } |
| 504 | 504 | |
| 505 | 505 | |
@@ -515,8 +515,8 @@ discard block |
||
| 515 | 515 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
| 516 | 516 | * @return string |
| 517 | 517 | */ |
| 518 | - public static function td( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
| 519 | - return EEH_HTML::_open_tag( 'td', $content, $id, $class, $style, $other_attributes ); |
|
| 518 | + public static function td($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
| 519 | + return EEH_HTML::_open_tag('td', $content, $id, $class, $style, $other_attributes); |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | |
@@ -528,8 +528,8 @@ discard block |
||
| 528 | 528 | * @param string $class - html class attribute |
| 529 | 529 | * @return string |
| 530 | 530 | */ |
| 531 | - public static function tdx( $id = '', $class = '' ) { |
|
| 532 | - return EEH_HTML::_close_tag( 'td', $id, $class ); |
|
| 531 | + public static function tdx($id = '', $class = '') { |
|
| 532 | + return EEH_HTML::_close_tag('td', $id, $class); |
|
| 533 | 533 | } |
| 534 | 534 | |
| 535 | 535 | |
@@ -543,10 +543,10 @@ discard block |
||
| 543 | 543 | * @param int $colspan |
| 544 | 544 | * @return string |
| 545 | 545 | */ |
| 546 | - public static function no_row( $content = '', $colspan = 2 ) { |
|
| 546 | + public static function no_row($content = '', $colspan = 2) { |
|
| 547 | 547 | return EEH_HTML::tr( |
| 548 | - EEH_HTML::td( $content, '', '', 'padding:0; border:none;', 'colspan="' . $colspan . '"' ), |
|
| 549 | - '', '', 'padding:0; border:none;' |
|
| 548 | + EEH_HTML::td($content, '', '', 'padding:0; border:none;', 'colspan="'.$colspan.'"'), |
|
| 549 | + '', '', 'padding:0; border:none;' |
|
| 550 | 550 | ); |
| 551 | 551 | } |
| 552 | 552 | |
@@ -566,14 +566,14 @@ discard block |
||
| 566 | 566 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
| 567 | 567 | * @return string |
| 568 | 568 | */ |
| 569 | - public static function link( $href = '', $link_text = '', $title = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
| 570 | - $link_text = ! empty( $link_text ) ? $link_text : $href; |
|
| 571 | - $attributes = ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : ''; |
|
| 572 | - $attributes .= ! empty( $class ) ? ' class="' . $class . '"' : ''; |
|
| 573 | - $attributes .= ! empty( $style ) ? ' style="' . $style . '"' : ''; |
|
| 574 | - $attributes .= ! empty( $title ) ? ' title="' . esc_attr( $title ) . '"' : ''; |
|
| 575 | - $attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : ''; |
|
| 576 | - return '<a href="' . $href . '" ' . $attributes . '>' . $link_text . '</a>'; |
|
| 569 | + public static function link($href = '', $link_text = '', $title = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
| 570 | + $link_text = ! empty($link_text) ? $link_text : $href; |
|
| 571 | + $attributes = ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : ''; |
|
| 572 | + $attributes .= ! empty($class) ? ' class="'.$class.'"' : ''; |
|
| 573 | + $attributes .= ! empty($style) ? ' style="'.$style.'"' : ''; |
|
| 574 | + $attributes .= ! empty($title) ? ' title="'.esc_attr($title).'"' : ''; |
|
| 575 | + $attributes .= ! empty($other_attributes) ? ' '.$other_attributes : ''; |
|
| 576 | + return '<a href="'.$href.'" '.$attributes.'>'.$link_text.'</a>'; |
|
| 577 | 577 | } |
| 578 | 578 | |
| 579 | 579 | |
@@ -590,14 +590,14 @@ discard block |
||
| 590 | 590 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
| 591 | 591 | * @return string |
| 592 | 592 | */ |
| 593 | - public static function img( $src = '', $alt = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
| 594 | - $attributes = ! empty( $src ) ? ' src="' . esc_url_raw( $src ) . '"' : ''; |
|
| 595 | - $attributes .= ! empty( $alt ) ? ' alt="' . esc_attr( $alt ) . '"' : ''; |
|
| 596 | - $attributes .= ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : ''; |
|
| 597 | - $attributes .= ! empty( $class ) ? ' class="' . $class . '"' : ''; |
|
| 598 | - $attributes .= ! empty( $style ) ? ' style="' . $style . '"' : ''; |
|
| 599 | - $attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : ''; |
|
| 600 | - return '<img' . $attributes . '/>'; |
|
| 593 | + public static function img($src = '', $alt = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
| 594 | + $attributes = ! empty($src) ? ' src="'.esc_url_raw($src).'"' : ''; |
|
| 595 | + $attributes .= ! empty($alt) ? ' alt="'.esc_attr($alt).'"' : ''; |
|
| 596 | + $attributes .= ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : ''; |
|
| 597 | + $attributes .= ! empty($class) ? ' class="'.$class.'"' : ''; |
|
| 598 | + $attributes .= ! empty($style) ? ' style="'.$style.'"' : ''; |
|
| 599 | + $attributes .= ! empty($other_attributes) ? ' '.$other_attributes : ''; |
|
| 600 | + return '<img'.$attributes.'/>'; |
|
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | |
@@ -615,12 +615,12 @@ discard block |
||
| 615 | 615 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
| 616 | 616 | * @return string |
| 617 | 617 | */ |
| 618 | - protected static function _inline_tag( $tag = 'span', $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
| 619 | - $attributes = ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : ''; |
|
| 620 | - $attributes .= ! empty( $class ) ? ' class="' . $class . '"' : ''; |
|
| 621 | - $attributes .= ! empty( $style ) ? ' style="' . $style . '"' : ''; |
|
| 622 | - $attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : ''; |
|
| 623 | - return '<' . $tag . ' ' . $attributes . '>' . $content . '</' . $tag . '>'; |
|
| 618 | + protected static function _inline_tag($tag = 'span', $content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
| 619 | + $attributes = ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : ''; |
|
| 620 | + $attributes .= ! empty($class) ? ' class="'.$class.'"' : ''; |
|
| 621 | + $attributes .= ! empty($style) ? ' style="'.$style.'"' : ''; |
|
| 622 | + $attributes .= ! empty($other_attributes) ? ' '.$other_attributes : ''; |
|
| 623 | + return '<'.$tag.' '.$attributes.'>'.$content.'</'.$tag.'>'; |
|
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | |
@@ -636,8 +636,8 @@ discard block |
||
| 636 | 636 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
| 637 | 637 | * @return string |
| 638 | 638 | */ |
| 639 | - public static function label( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
| 640 | - return EEH_HTML::_inline_tag( 'label', $content, $id, $class, $style, $other_attributes ); |
|
| 639 | + public static function label($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
| 640 | + return EEH_HTML::_inline_tag('label', $content, $id, $class, $style, $other_attributes); |
|
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | |
@@ -653,8 +653,8 @@ discard block |
||
| 653 | 653 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
| 654 | 654 | * @return string |
| 655 | 655 | */ |
| 656 | - public static function span( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
| 657 | - return EEH_HTML::_inline_tag( 'span', $content, $id, $class, $style, $other_attributes ); |
|
| 656 | + public static function span($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
| 657 | + return EEH_HTML::_inline_tag('span', $content, $id, $class, $style, $other_attributes); |
|
| 658 | 658 | } |
| 659 | 659 | |
| 660 | 660 | |
@@ -670,8 +670,8 @@ discard block |
||
| 670 | 670 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
| 671 | 671 | * @return string |
| 672 | 672 | */ |
| 673 | - public static function strong( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
| 674 | - return EEH_HTML::_inline_tag( 'strong', $content, $id, $class, $style, $other_attributes ); |
|
| 673 | + public static function strong($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
| 674 | + return EEH_HTML::_inline_tag('strong', $content, $id, $class, $style, $other_attributes); |
|
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | |
@@ -683,8 +683,8 @@ discard block |
||
| 683 | 683 | * @param string $comment |
| 684 | 684 | * @return string |
| 685 | 685 | */ |
| 686 | - public static function comment( $comment = '' ) { |
|
| 687 | - return ! empty( $comment ) ? EEH_HTML::nl() . '<!-- ' . $comment . ' -->' : ''; |
|
| 686 | + public static function comment($comment = '') { |
|
| 687 | + return ! empty($comment) ? EEH_HTML::nl().'<!-- '.$comment.' -->' : ''; |
|
| 688 | 688 | } |
| 689 | 689 | |
| 690 | 690 | |
@@ -695,8 +695,8 @@ discard block |
||
| 695 | 695 | * @param int $nmbr - the number of line breaks to return |
| 696 | 696 | * @return string |
| 697 | 697 | */ |
| 698 | - public static function br( $nmbr = 1 ) { |
|
| 699 | - return str_repeat( '<br />', $nmbr ); |
|
| 698 | + public static function br($nmbr = 1) { |
|
| 699 | + return str_repeat('<br />', $nmbr); |
|
| 700 | 700 | } |
| 701 | 701 | |
| 702 | 702 | |
@@ -707,8 +707,8 @@ discard block |
||
| 707 | 707 | * @param int $nmbr - the number of non-breaking spaces to return |
| 708 | 708 | * @return string |
| 709 | 709 | */ |
| 710 | - public static function nbsp( $nmbr = 1 ) { |
|
| 711 | - return str_repeat( ' ', $nmbr ); |
|
| 710 | + public static function nbsp($nmbr = 1) { |
|
| 711 | + return str_repeat(' ', $nmbr); |
|
| 712 | 712 | } |
| 713 | 713 | |
| 714 | 714 | |
@@ -722,9 +722,9 @@ discard block |
||
| 722 | 722 | * @param string $id |
| 723 | 723 | * @return string |
| 724 | 724 | */ |
| 725 | - public static function sanitize_id( $id = '' ) { |
|
| 726 | - $key = str_replace( ' ', '-', trim( $id ) ); |
|
| 727 | - return preg_replace( '/[^a-zA-Z0-9_\-]/', '', $key ); |
|
| 725 | + public static function sanitize_id($id = '') { |
|
| 726 | + $key = str_replace(' ', '-', trim($id)); |
|
| 727 | + return preg_replace('/[^a-zA-Z0-9_\-]/', '', $key); |
|
| 728 | 728 | } |
| 729 | 729 | |
| 730 | 730 | |
@@ -736,10 +736,10 @@ discard block |
||
| 736 | 736 | * @param string $tag |
| 737 | 737 | * @return string - newline character plus # of indents passed (can be + or -) |
| 738 | 738 | */ |
| 739 | - public static function nl( $indent = 0, $tag = 'none' ) { |
|
| 739 | + public static function nl($indent = 0, $tag = 'none') { |
|
| 740 | 740 | $html = "\n"; |
| 741 | - EEH_HTML::indent( $indent, $tag ); |
|
| 742 | - for ( $x = 0; $x < EEH_HTML::$_indent[ $tag ]; $x++ ) { |
|
| 741 | + EEH_HTML::indent($indent, $tag); |
|
| 742 | + for ($x = 0; $x < EEH_HTML::$_indent[$tag]; $x++) { |
|
| 743 | 743 | $html .= "\t"; |
| 744 | 744 | } |
| 745 | 745 | return $html; |
@@ -754,17 +754,17 @@ discard block |
||
| 754 | 754 | * @param int $indent can be negative to decrease the indentation level |
| 755 | 755 | * @param string $tag |
| 756 | 756 | */ |
| 757 | - public static function indent( $indent, $tag = 'none' ){ |
|
| 757 | + public static function indent($indent, $tag = 'none') { |
|
| 758 | 758 | static $default_indentation = FALSE; |
| 759 | - if ( ! $default_indentation ) { |
|
| 759 | + if ( ! $default_indentation) { |
|
| 760 | 760 | EEH_HTML::_set_default_indentation(); |
| 761 | 761 | $default_indentation = TRUE; |
| 762 | 762 | } |
| 763 | - if ( ! isset( EEH_HTML::$_indent[ $tag ] )) { |
|
| 764 | - EEH_HTML::$_indent[ $tag ] = 0; |
|
| 763 | + if ( ! isset(EEH_HTML::$_indent[$tag])) { |
|
| 764 | + EEH_HTML::$_indent[$tag] = 0; |
|
| 765 | 765 | } |
| 766 | - EEH_HTML::$_indent[ $tag ] += (int)$indent; |
|
| 767 | - EEH_HTML::$_indent[ $tag ] = EEH_HTML::$_indent[ $tag ] >= 0 ? EEH_HTML::$_indent[ $tag ] : 0; |
|
| 766 | + EEH_HTML::$_indent[$tag] += (int) $indent; |
|
| 767 | + EEH_HTML::$_indent[$tag] = EEH_HTML::$_indent[$tag] >= 0 ? EEH_HTML::$_indent[$tag] : 0; |
|
| 768 | 768 | } |
| 769 | 769 | |
| 770 | 770 | |
@@ -810,15 +810,15 @@ discard block |
||
| 810 | 810 | * @global array $allowedtags |
| 811 | 811 | * @return array |
| 812 | 812 | */ |
| 813 | - public static function get_simple_tags(){ |
|
| 813 | + public static function get_simple_tags() { |
|
| 814 | 814 | global $allowedtags; |
| 815 | 815 | $tags_we_allow = $allowedtags; |
| 816 | - $tags_we_allow['ol']=array(); |
|
| 817 | - $tags_we_allow['ul']=array(); |
|
| 818 | - $tags_we_allow['li']=array(); |
|
| 819 | - $tags_we_allow['br']=array(); |
|
| 820 | - $tags_we_allow['p']=array(); |
|
| 821 | - return apply_filters( 'FHEE__EEH_HTML__get_simple_tags', $tags_we_allow ); |
|
| 816 | + $tags_we_allow['ol'] = array(); |
|
| 817 | + $tags_we_allow['ul'] = array(); |
|
| 818 | + $tags_we_allow['li'] = array(); |
|
| 819 | + $tags_we_allow['br'] = array(); |
|
| 820 | + $tags_we_allow['p'] = array(); |
|
| 821 | + return apply_filters('FHEE__EEH_HTML__get_simple_tags', $tags_we_allow); |
|
| 822 | 822 | } |
| 823 | 823 | |
| 824 | 824 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
| 3 | 3 | exit('No direct script access allowed'); |
| 4 | 4 | |
| 5 | 5 | /** |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * ------------------------------------------------------------------------ |
| 26 | 26 | */ |
| 27 | -class EE_Credit_Card_Month_Input extends EE_Month_Input{ |
|
| 27 | +class EE_Credit_Card_Month_Input extends EE_Month_Input { |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * @param bool $leading_zero |
@@ -35,8 +35,8 @@ discard block |
||
| 35 | 35 | $leading_zero = false, |
| 36 | 36 | $input_settings = array(), |
| 37 | 37 | $january_is_month_1 = true |
| 38 | - ){ |
|
| 39 | - $this->set_sensitive_data_removal_strategy( new EE_All_Sensitive_Data_Removal() ); |
|
| 38 | + ) { |
|
| 39 | + $this->set_sensitive_data_removal_strategy(new EE_All_Sensitive_Data_Removal()); |
|
| 40 | 40 | parent::__construct( |
| 41 | 41 | $leading_zero, |
| 42 | 42 | $input_settings, |
@@ -6,21 +6,21 @@ discard block |
||
| 6 | 6 | * @subpackage |
| 7 | 7 | * @author Mike Nelson |
| 8 | 8 | */ |
| 9 | -class EE_Month_Input extends EE_Select_Input{ |
|
| 9 | +class EE_Month_Input extends EE_Select_Input { |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * @param bool $leading_zero |
| 13 | 13 | * @param array $input_settings |
| 14 | 14 | * @param bool $january_is_month_1 whether january should have value of 1; or it should be month 0 |
| 15 | 15 | */ |
| 16 | - function __construct( $leading_zero = false, $input_settings = array(), $january_is_month_1 = true){ |
|
| 16 | + function __construct($leading_zero = false, $input_settings = array(), $january_is_month_1 = true) { |
|
| 17 | 17 | $key_begin_range = $january_is_month_1 ? 1 : 0; |
| 18 | - $key_range = range($key_begin_range, $key_begin_range + 11 ); |
|
| 19 | - if($leading_zero){ |
|
| 20 | - array_walk( $key_range, array( $this, '_zero_pad' ) ); |
|
| 18 | + $key_range = range($key_begin_range, $key_begin_range + 11); |
|
| 19 | + if ($leading_zero) { |
|
| 20 | + array_walk($key_range, array($this, '_zero_pad')); |
|
| 21 | 21 | } |
| 22 | - $value_range = range( 1, 12 ); |
|
| 23 | - array_walk( $value_range, array( $this, '_zero_pad' ) ); |
|
| 22 | + $value_range = range(1, 12); |
|
| 23 | + array_walk($value_range, array($this, '_zero_pad')); |
|
| 24 | 24 | parent::__construct( |
| 25 | 25 | array_combine( |
| 26 | 26 | $key_range, |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * @param int $input |
| 36 | 36 | * @param mixed $key |
| 37 | 37 | */ |
| 38 | - protected function _zero_pad( &$input, $key ) { |
|
| 39 | - $input = str_pad( $input, 2, '0', STR_PAD_LEFT ); |
|
| 38 | + protected function _zero_pad(&$input, $key) { |
|
| 39 | + $input = str_pad($input, 2, '0', STR_PAD_LEFT); |
|
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | \ No newline at end of file |