Completed
Branch BUG-10626-dst-unit-test (8d5d80)
by
unknown
14:30
created
core/db_models/EEM_Payment.model.php 2 patches
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @author				Michael Nelson, Brent Christensen
9 9
  *
10 10
  */
11
-class EEM_Payment extends EEM_Base implements EEMI_Payment{
11
+class EEM_Payment extends EEM_Base implements EEMI_Payment {
12 12
 
13 13
   	// private instance of the Payment object
14 14
 	protected static $_instance = NULL;
@@ -56,28 +56,28 @@  discard block
 block discarded – undo
56 56
 	 *		@param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
57 57
 	 *		@return EEM_Payment
58 58
 	 */
59
-	protected function __construct( $timezone ) {
59
+	protected function __construct($timezone) {
60 60
 
61
-		$this->singular_item = __('Payment','event_espresso');
62
-		$this->plural_item = __('Payments','event_espresso');
61
+		$this->singular_item = __('Payment', 'event_espresso');
62
+		$this->plural_item = __('Payments', 'event_espresso');
63 63
 
64 64
 		$this->_tables = array(
65
-			'Payment'=>new EE_Primary_Table('esp_payment','PAY_ID')
65
+			'Payment'=>new EE_Primary_Table('esp_payment', 'PAY_ID')
66 66
 		);
67 67
 		$this->_fields = array(
68 68
 			'Payment'=>array(
69
-				'PAY_ID'=>new EE_Primary_Key_Int_Field('PAY_ID', __('Payment ID','event_espresso')),
70
-				'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID','event_espresso'), false, 0, 'Transaction'),
71
-				'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID','event_espresso'), false, EEM_Payment::status_id_failed, 'Status'),
72
-				'PAY_timestamp'=> new EE_Datetime_Field('PAY_timestamp', __('Timestamp of when payment was attempted','event_espresso'), false, EE_Datetime_Field::now, $timezone ),
73
-				'PAY_source'=>new EE_All_Caps_Text_Field('PAY_source', __('User-friendly description of payment','event_espresso'), false, 'CART'),
74
-				'PAY_amount'=>new EE_Money_Field('PAY_amount', __('Amount Payment should be for','event_espresso'), false, 0),
69
+				'PAY_ID'=>new EE_Primary_Key_Int_Field('PAY_ID', __('Payment ID', 'event_espresso')),
70
+				'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'), false, 0, 'Transaction'),
71
+				'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Payment::status_id_failed, 'Status'),
72
+				'PAY_timestamp'=> new EE_Datetime_Field('PAY_timestamp', __('Timestamp of when payment was attempted', 'event_espresso'), false, EE_Datetime_Field::now, $timezone),
73
+				'PAY_source'=>new EE_All_Caps_Text_Field('PAY_source', __('User-friendly description of payment', 'event_espresso'), false, 'CART'),
74
+				'PAY_amount'=>new EE_Money_Field('PAY_amount', __('Amount Payment should be for', 'event_espresso'), false, 0),
75 75
 				'PMD_ID'=>new EE_Foreign_Key_Int_Field('PMD_ID', __("Payment Method ID", 'event_espresso'), false, NULL, 'Payment_Method'),
76
-				'PAY_gateway_response'=>new EE_Plain_Text_Field('PAY_gateway_response', __('Response from Gateway about the payment','event_espresso'), false, ''),
77
-				'PAY_txn_id_chq_nmbr'=>new EE_Plain_Text_Field('PAY_txn_id_chq_nmbr', __('Gateway Transaction ID or Cheque Number','event_espresso'), true, ''),
78
-				'PAY_po_number'=>new EE_Plain_Text_Field('PAY_po_number', __('Purchase or Sales Number','event_espresso'), true, ''),
79
-				'PAY_extra_accntng'=>new EE_Simple_HTML_Field('PAY_extra_accntng', __('Extra Account Info','event_espresso'), true, ''),
80
-				'PAY_details'=>new EE_Serialized_Text_Field('PAY_details', __('Full Gateway response about payment','event_espresso'), true, ''),
76
+				'PAY_gateway_response'=>new EE_Plain_Text_Field('PAY_gateway_response', __('Response from Gateway about the payment', 'event_espresso'), false, ''),
77
+				'PAY_txn_id_chq_nmbr'=>new EE_Plain_Text_Field('PAY_txn_id_chq_nmbr', __('Gateway Transaction ID or Cheque Number', 'event_espresso'), true, ''),
78
+				'PAY_po_number'=>new EE_Plain_Text_Field('PAY_po_number', __('Purchase or Sales Number', 'event_espresso'), true, ''),
79
+				'PAY_extra_accntng'=>new EE_Simple_HTML_Field('PAY_extra_accntng', __('Extra Account Info', 'event_espresso'), true, ''),
80
+				'PAY_details'=>new EE_Serialized_Text_Field('PAY_details', __('Full Gateway response about payment', 'event_espresso'), true, ''),
81 81
 				'PAY_redirect_url'=>new EE_Plain_Text_Field('PAY_redirect_url', __("Redirect URL", 'event_espresso'), true),
82 82
 				'PAY_redirect_args'=>new EE_Serialized_Text_Field('PAY_redirect_args', __("Key-Value POST vars to send along with redirect", 'event_espresso'), true)
83 83
 			)
@@ -87,11 +87,11 @@  discard block
 block discarded – undo
87 87
 			'Status'=> new EE_Belongs_To_Relation(),
88 88
 			'Payment_Method'=>new EE_Belongs_To_Relation(),
89 89
 			'Registration_Payment' => new EE_Has_Many_Relation(),
90
-			'Registration' => new EE_HABTM_Relation( 'Registration_Payment' ),
90
+			'Registration' => new EE_HABTM_Relation('Registration_Payment'),
91 91
 		);
92 92
 		$this->_model_chain_to_wp_user = 'Payment_Method';
93 93
 		$this->_caps_slug = 'transactions';
94
-		parent::__construct( $timezone );
94
+		parent::__construct($timezone);
95 95
 	}
96 96
 
97 97
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	 * @param string $PAY_txn_id_chq_nmbr
104 104
 	 * @return EE_Payment
105 105
 	 */
106
-	public function get_payment_by_txn_id_chq_nmbr( $PAY_txn_id_chq_nmbr ){
106
+	public function get_payment_by_txn_id_chq_nmbr($PAY_txn_id_chq_nmbr) {
107 107
 		return $this->get_one(array(array('PAY_txn_id_chq_nmbr'=>$PAY_txn_id_chq_nmbr)));
108 108
 	}
109 109
 
@@ -119,15 +119,15 @@  discard block
 block discarded – undo
119 119
 	 *		@param	string	$status_of_payment one of EEM_Payment::status_id_*, like 'PAP','PCN',etc. If none is provided, gets payments with any status
120 120
 	*		@return		EE_Payment[]
121 121
 	*/
122
-	public function get_payments_for_transaction( $TXN_ID = FALSE, $status_of_payment = null ) {
122
+	public function get_payments_for_transaction($TXN_ID = FALSE, $status_of_payment = null) {
123 123
 		// all payments for a TXN ordered chronologically
124
-		$query_params = array( array( 'TXN_ID' => $TXN_ID ), 'order_by' => array( 'PAY_timestamp' => 'ASC' ));
124
+		$query_params = array(array('TXN_ID' => $TXN_ID), 'order_by' => array('PAY_timestamp' => 'ASC'));
125 125
 		// if provided with a status, search specifically for that status. Otherwise get them all
126
-		if ( $status_of_payment ){
126
+		if ($status_of_payment) {
127 127
 			$query_params[0]['STS_ID'] = $status_of_payment;
128 128
 		}
129 129
 		// retrieve payments
130
-		return $this->get_all ( $query_params );
130
+		return $this->get_all($query_params);
131 131
 	}
132 132
 
133 133
 
@@ -137,8 +137,8 @@  discard block
 block discarded – undo
137 137
 	 * @param int $TXN_ID
138 138
 	 * @return EE_Payment[]
139 139
 	 */
140
-	public function get_approved_payments_for_transaction( $TXN_ID = 0 ) {
141
-		return $this->get_payments_for_transaction( $TXN_ID, EEM_Payment::status_id_approved );
140
+	public function get_approved_payments_for_transaction($TXN_ID = 0) {
141
+		return $this->get_payments_for_transaction($TXN_ID, EEM_Payment::status_id_approved);
142 142
 
143 143
 	}
144 144
 
@@ -159,36 +159,36 @@  discard block
 block discarded – undo
159 159
 	 *
160 160
 	 * @return EE_Payment[]
161 161
 	 */
162
-	public function get_payments_made_between_dates( $start_date = '', $end_date = '', $format = '', $timezone = '' ) {
163
-		$timezone = empty( $timezone ) ? EEH_DTT_Helper::get_timezone() : $timezone;
162
+	public function get_payments_made_between_dates($start_date = '', $end_date = '', $format = '', $timezone = '') {
163
+		$timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone;
164 164
 		//if $start_date or $end date, verify $format is included.
165
-		if ( ( ! empty( $start_date ) || ! empty( $end_date ) ) && empty( $format ) ) {
166
-			throw new EE_Error( __('You included a start date and/or a end date for this method but did not include a format string.  The format string is needed for setting up the query', 'event_espresso' ) );
165
+		if (( ! empty($start_date) || ! empty($end_date)) && empty($format)) {
166
+			throw new EE_Error(__('You included a start date and/or a end date for this method but did not include a format string.  The format string is needed for setting up the query', 'event_espresso'));
167 167
 		}
168
-		$now = new DateTime( 'now' );
168
+		$now = new DateTime('now');
169 169
 		// setup timezone objects once
170
-		$modelDateTimeZone = new DateTimeZone( $this->_timezone );
171
-		$passedDateTimeZone = new DateTimeZone( $timezone );
170
+		$modelDateTimeZone = new DateTimeZone($this->_timezone);
171
+		$passedDateTimeZone = new DateTimeZone($timezone);
172 172
 		// setup start date
173
-		$start_date = ! empty( $start_date ) ? date_create_from_format( $format, $start_date, $passedDateTimeZone ) : $now;
174
-		$start_date->setTimeZone( $modelDateTimeZone );
175
-		$start_date = $start_date->format( 'Y-m-d' ) . ' 00:00:00';
176
-		$start_date = strtotime( $start_date );
173
+		$start_date = ! empty($start_date) ? date_create_from_format($format, $start_date, $passedDateTimeZone) : $now;
174
+		$start_date->setTimeZone($modelDateTimeZone);
175
+		$start_date = $start_date->format('Y-m-d').' 00:00:00';
176
+		$start_date = strtotime($start_date);
177 177
 		// setup end date
178
-		$end_date = ! empty( $end_date ) ? date_create_from_format( $format, $end_date, $passedDateTimeZone ) : $now;
179
-		$end_date->setTimeZone( $modelDateTimeZone );
180
-		$end_date = $end_date->format('Y-m-d') . ' 23:59:59';
181
-		$end_date = strtotime( $end_date );
178
+		$end_date = ! empty($end_date) ? date_create_from_format($format, $end_date, $passedDateTimeZone) : $now;
179
+		$end_date->setTimeZone($modelDateTimeZone);
180
+		$end_date = $end_date->format('Y-m-d').' 23:59:59';
181
+		$end_date = strtotime($end_date);
182 182
 
183 183
 		// make sure our start date is the lowest value and vice versa
184
-		$start = min( $start_date, $end_date );
185
-		$end = max( $start_date, $end_date );
184
+		$start = min($start_date, $end_date);
185
+		$end = max($start_date, $end_date);
186 186
 
187 187
 		//yes we generated the date and time string in utc but we WANT this start date and time used in the set timezone on the model.
188
-		$start_date = $this->convert_datetime_for_query( 'PAY_timestamp', date( 'Y-m-d', $start ) . ' 00:00:00', 'Y-m-d H:i:s', $this->get_timezone() );
189
-		$end_date = $this->convert_datetime_for_query( 'PAY_timestamp', date( 'Y-m-d', $end) . ' 23:59:59' , 'Y-m-d H:i:s', $this->get_timezone() );
188
+		$start_date = $this->convert_datetime_for_query('PAY_timestamp', date('Y-m-d', $start).' 00:00:00', 'Y-m-d H:i:s', $this->get_timezone());
189
+		$end_date = $this->convert_datetime_for_query('PAY_timestamp', date('Y-m-d', $end).' 23:59:59', 'Y-m-d H:i:s', $this->get_timezone());
190 190
 
191
-		return $this->get_all(array(array('PAY_timestamp'=>array('>=',$start_date),'PAY_timestamp*'=>array('<=',$end_date))));
191
+		return $this->get_all(array(array('PAY_timestamp'=>array('>=', $start_date), 'PAY_timestamp*'=>array('<=', $end_date))));
192 192
 	}
193 193
 
194 194
 	/**
@@ -198,35 +198,35 @@  discard block
 block discarded – undo
198 198
 	 * returns a string for the approved status
199 199
 	 * @return 	string
200 200
 	 */
201
-	function approved_status(){
201
+	function approved_status() {
202 202
 		return self::status_id_approved;
203 203
 	}
204 204
 	/**
205 205
 	 * returns a string for the pending status
206 206
 	 * @return 	string
207 207
 	 */
208
-	function pending_status(){
208
+	function pending_status() {
209 209
 		return self::status_id_pending;
210 210
 	}
211 211
 	/**
212 212
 	 * returns a string for the cancelled status
213 213
 	 * @return 	string
214 214
 	 */
215
-	function cancelled_status(){
215
+	function cancelled_status() {
216 216
 		return self::status_id_cancelled;
217 217
 	}
218 218
 	/**
219 219
 	 * returns a string for the failed status
220 220
 	 * @return 	string
221 221
 	 */
222
-	function failed_status(){
222
+	function failed_status() {
223 223
 		return self::status_id_failed;
224 224
 	}
225 225
 	/**
226 226
 	 * returns a string for the declined status
227 227
 	 * @return 	string
228 228
 	 */
229
-	function declined_status(){
229
+	function declined_status() {
230 230
 		return self::status_id_declined;
231 231
 	}
232 232
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  *
4 6
  * Payment Model
Please login to merge, or discard this patch.
core/EE_Bootstrap.core.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -29,17 +29,17 @@  discard block
 block discarded – undo
29 29
 
30 30
 class EE_Bootstrap {
31 31
 
32
-    /**
33
-     * @var EE_Request $request
34
-     */
35
-    protected $request;
32
+	/**
33
+	 * @var EE_Request $request
34
+	 */
35
+	protected $request;
36 36
 
37
-    /**
38
-     * @var EE_Response $response
39
-     */
40
-    protected $response;
37
+	/**
38
+	 * @var EE_Response $response
39
+	 */
40
+	protected $response;
41 41
 
42
-    /**
42
+	/**
43 43
 	 * @var EE_Request_Stack_Builder $request_stack_builder
44 44
 	 */
45 45
 	protected $request_stack_builder = null;
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 
53 53
 
54 54
 	public function __construct(EE_Request $request, EE_Response $response) {
55
-        $this->request = $request;
56
-        $this->response = $response;
57
-        // construct request stack and run middleware apps as soon as all WP plugins are loaded
55
+		$this->request = $request;
56
+		$this->response = $response;
57
+		// construct request stack and run middleware apps as soon as all WP plugins are loaded
58 58
 		add_action( 'plugins_loaded', array( $this, 'run_request_stack' ), 0 );
59 59
 		// set framework for the rest of EE to hook into when loading
60 60
 		add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'load_espresso_addons' ), 1 );
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
 		$this->set_autoloaders_for_required_files();
76 76
 		$this->request_stack_builder = $this->build_request_stack();
77 77
 		$this->request_stack = $this->request_stack_builder->resolve(
78
-		    new EE_Load_Espresso_Core()
79
-        );
78
+			new EE_Load_Espresso_Core()
79
+		);
80 80
 		$this->request_stack->handle_request($this->request, $this->response);
81 81
 		$this->request_stack->handle_response();
82 82
 	}
@@ -94,21 +94,21 @@  discard block
 block discarded – undo
94 94
 
95 95
 
96 96
 
97
-    /**
98
-     * load_required_files
99
-     *
100
-     * @throws \EE_Error
101
-     */
97
+	/**
98
+	 * load_required_files
99
+	 *
100
+	 * @throws \EE_Error
101
+	 */
102 102
 	protected function set_autoloaders_for_required_files() {
103 103
 		// load interfaces
104
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true);
105
-        // load helpers
104
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true);
105
+		// load helpers
106 106
 		EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_HELPERS );
107 107
 		// load request stack
108 108
 		EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CORE . 'request_stack' . DS );
109 109
 		// load middleware
110 110
 		EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CORE . 'middleware' . DS );
111
-    }
111
+	}
112 112
 
113 113
 
114 114
 
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -55,13 +55,13 @@  discard block
 block discarded – undo
55 55
         $this->request = $request;
56 56
         $this->response = $response;
57 57
         // construct request stack and run middleware apps as soon as all WP plugins are loaded
58
-		add_action( 'plugins_loaded', array( $this, 'run_request_stack' ), 0 );
58
+		add_action('plugins_loaded', array($this, 'run_request_stack'), 0);
59 59
 		// set framework for the rest of EE to hook into when loading
60
-		add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'load_espresso_addons' ), 1 );
61
-		add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'detect_activations_or_upgrades' ), 3 );
62
-		add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'load_core_configuration' ), 5 );
63
-		add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'register_shortcodes_modules_and_widgets' ), 7 );
64
-		add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'brew_espresso' ), 9 );
60
+		add_action('plugins_loaded', array('EE_Bootstrap', 'load_espresso_addons'), 1);
61
+		add_action('plugins_loaded', array('EE_Bootstrap', 'detect_activations_or_upgrades'), 3);
62
+		add_action('plugins_loaded', array('EE_Bootstrap', 'load_core_configuration'), 5);
63
+		add_action('plugins_loaded', array('EE_Bootstrap', 'register_shortcodes_modules_and_widgets'), 7);
64
+		add_action('plugins_loaded', array('EE_Bootstrap', 'brew_espresso'), 9);
65 65
 	}
66 66
 
67 67
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 */
89 89
 	protected function load_autoloader() {
90 90
 		// load interfaces
91
-		espresso_load_required( 'EEH_Autoloader', EE_CORE . 'helpers' . DS . 'EEH_Autoloader.helper.php' );
91
+		espresso_load_required('EEH_Autoloader', EE_CORE.'helpers'.DS.'EEH_Autoloader.helper.php');
92 92
 		EEH_Autoloader::instance();
93 93
 	}
94 94
 
@@ -101,13 +101,13 @@  discard block
 block discarded – undo
101 101
      */
102 102
 	protected function set_autoloaders_for_required_files() {
103 103
 		// load interfaces
104
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true);
104
+        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'interfaces', true);
105 105
         // load helpers
106
-		EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_HELPERS );
106
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS);
107 107
 		// load request stack
108
-		EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CORE . 'request_stack' . DS );
108
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'request_stack'.DS);
109 109
 		// load middleware
110
-		EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CORE . 'middleware' . DS );
110
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'middleware'.DS);
111 111
     }
112 112
 
113 113
 
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
 			)
129 129
 		);
130 130
 		// load middleware onto stack : FILO (First In Last Out)
131
-		foreach ( (array)$stack_apps as $stack_app ) {
131
+		foreach ((array) $stack_apps as $stack_app) {
132 132
 			//$request_stack_builder->push( $stack_app );
133
-			$request_stack_builder->unshift( $stack_app );
133
+			$request_stack_builder->unshift($stack_app);
134 134
 		}
135 135
 		return apply_filters(
136 136
 			'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder',
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 * no other logic should be performed at this point
148 148
 	 */
149 149
 	public static function load_espresso_addons() {
150
-		do_action( 'AHEE__EE_Bootstrap__load_espresso_addons' );
150
+		do_action('AHEE__EE_Bootstrap__load_espresso_addons');
151 151
 	}
152 152
 
153 153
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 	 * we can determine if anything needs activating or upgrading
160 160
 	 */
161 161
 	public static function detect_activations_or_upgrades() {
162
-		do_action( 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' );
162
+		do_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades');
163 163
 	}
164 164
 
165 165
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 	 * we can load and set all of the system configurations
172 172
 	 */
173 173
 	public static function load_core_configuration() {
174
-		do_action( 'AHEE__EE_Bootstrap__load_core_configuration' );
174
+		do_action('AHEE__EE_Bootstrap__load_core_configuration');
175 175
 	}
176 176
 
177 177
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	 * so that they are ready to be used throughout the system
184 184
 	 */
185 185
 	public static function register_shortcodes_modules_and_widgets() {
186
-		do_action( 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' );
186
+		do_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets');
187 187
 	}
188 188
 
189 189
 
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 	 * so let the fun begin...
196 196
 	 */
197 197
 	public static function brew_espresso() {
198
-		do_action( 'AHEE__EE_Bootstrap__brew_espresso' );
198
+		do_action('AHEE__EE_Bootstrap__brew_espresso');
199 199
 	}
200 200
 
201 201
 
Please login to merge, or discard this patch.
core/espresso_definitions.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -11,16 +11,16 @@  discard block
 block discarded – undo
11 11
 define('EE_SUPPORT_EMAIL', '[email protected]');
12 12
 //used to be DIRECTORY_SEPARATOR, but that caused issues on windows
13 13
 if ( ! defined('DS')) {
14
-    define('DS', '/');
14
+	define('DS', '/');
15 15
 }
16 16
 if ( ! defined('PS')) {
17
-    define('PS', PATH_SEPARATOR);
17
+	define('PS', PATH_SEPARATOR);
18 18
 }
19 19
 if ( ! defined('SP')) {
20
-    define('SP', ' ');
20
+	define('SP', ' ');
21 21
 }
22 22
 if ( ! defined('EENL')) {
23
-    define('EENL', "\n");
23
+	define('EENL', "\n");
24 24
 }
25 25
 // main root folder paths
26 26
 define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
@@ -70,16 +70,16 @@  discard block
 block discarded – undo
70 70
 define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
71 71
 //check for dompdf fonts in uploads
72 72
 if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
73
-    define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
73
+	define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
74 74
 }
75 75
 //ajax constants
76 76
 define(
77
-    'EE_FRONT_AJAX',
78
-    isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
77
+	'EE_FRONT_AJAX',
78
+	isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
79 79
 );
80 80
 define(
81
-    'EE_ADMIN_AJAX',
82
-    isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
81
+	'EE_ADMIN_AJAX',
82
+	isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
83 83
 );
84 84
 //just a handy constant occasionally needed for finding values representing infinity in the DB
85 85
 //you're better to use this than its straight value (currently -1) in case you ever
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 define('EE_DEBUG', false);
90 90
 // for older WP versions
91 91
 if ( ! defined('MONTH_IN_SECONDS')) {
92
-    define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
92
+	define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
93 93
 }
94 94
 
95 95
 // End of file espresso_definitions.php
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -23,54 +23,54 @@  discard block
 block discarded – undo
23 23
     define('EENL', "\n");
24 24
 }
25 25
 // main root folder paths
26
-define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
27
-define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
28
-define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
29
-define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
30
-define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
31
-define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
32
-define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
33
-define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
26
+define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH.'admin_pages'.DS);
27
+define('EE_CORE', EE_PLUGIN_DIR_PATH.'core'.DS);
28
+define('EE_MODULES', EE_PLUGIN_DIR_PATH.'modules'.DS);
29
+define('EE_PUBLIC', EE_PLUGIN_DIR_PATH.'public'.DS);
30
+define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH.'shortcodes'.DS);
31
+define('EE_WIDGETS', EE_PLUGIN_DIR_PATH.'widgets'.DS);
32
+define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH.'payment_methods'.DS);
33
+define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH.'caffeinated'.DS);
34 34
 // core system paths
35
-define('EE_ADMIN', EE_CORE . 'admin' . DS);
36
-define('EE_CPTS', EE_CORE . 'CPTs' . DS);
37
-define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
38
-define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
39
-define('EE_BUSINESS', EE_CORE . 'business' . DS);
40
-define('EE_MODELS', EE_CORE . 'db_models' . DS);
41
-define('EE_HELPERS', EE_CORE . 'helpers' . DS);
42
-define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
43
-define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
44
-define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
45
-define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
46
-define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
35
+define('EE_ADMIN', EE_CORE.'admin'.DS);
36
+define('EE_CPTS', EE_CORE.'CPTs'.DS);
37
+define('EE_CLASSES', EE_CORE.'db_classes'.DS);
38
+define('EE_INTERFACES', EE_CORE.'interfaces'.DS);
39
+define('EE_BUSINESS', EE_CORE.'business'.DS);
40
+define('EE_MODELS', EE_CORE.'db_models'.DS);
41
+define('EE_HELPERS', EE_CORE.'helpers'.DS);
42
+define('EE_LIBRARIES', EE_CORE.'libraries'.DS);
43
+define('EE_TEMPLATES', EE_CORE.'templates'.DS);
44
+define('EE_THIRD_PARTY', EE_CORE.'third_party_libs'.DS);
45
+define('EE_GLOBAL_ASSETS', EE_TEMPLATES.'global_assets'.DS);
46
+define('EE_FORM_SECTIONS', EE_LIBRARIES.'form_sections'.DS);
47 47
 // gateways
48
-define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
49
-define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
48
+define('EE_GATEWAYS', EE_MODULES.'gateways'.DS);
49
+define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL.'modules'.DS.'gateways'.DS);
50 50
 // asset URL paths
51
-define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
52
-define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
53
-define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
54
-define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
55
-define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
56
-define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
51
+define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL.'core'.DS.'templates'.DS);
52
+define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL.'global_assets'.DS);
53
+define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL.'images'.DS);
54
+define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL.'core'.DS.'third_party_libs'.DS);
55
+define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL.'core/helpers/assets/');
56
+define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL.'core/libraries/');
57 57
 // define upload paths
58 58
 $uploads = wp_upload_dir();
59 59
 // define the uploads directory and URL
60
-define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
61
-define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
60
+define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'].DS.'espresso'.DS);
61
+define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'].DS.'espresso'.DS);
62 62
 // define the templates directory and URL
63
-define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
64
-define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
63
+define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'].DS.'espresso'.DS.'templates'.DS);
64
+define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'].DS.'espresso'.DS.'templates'.DS);
65 65
 // define the gateway directory and URL
66
-define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
67
-define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
66
+define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'].DS.'espresso'.DS.'gateways'.DS);
67
+define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'].DS.'espresso'.DS.'gateways'.DS);
68 68
 // languages folder/path
69
-define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
70
-define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
69
+define('EE_LANGUAGES_SAFE_LOC', '..'.DS.'uploads'.DS.'espresso'.DS.'languages'.DS);
70
+define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'languages'.DS);
71 71
 //check for dompdf fonts in uploads
72
-if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
73
-    define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
72
+if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS)) {
73
+    define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS);
74 74
 }
75 75
 //ajax constants
76 76
 define(
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 //you're better to use this than its straight value (currently -1) in case you ever
86 86
 //want to change its default value! or find when -1 means infinity
87 87
 define('EE_INF_IN_DB', -1);
88
-define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
88
+define('EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX);
89 89
 define('EE_DEBUG', false);
90 90
 // for older WP versions
91 91
 if ( ! defined('MONTH_IN_SECONDS')) {
Please login to merge, or discard this patch.
core/request_stack/EE_Request_Stack_Builder.core.php 2 patches
Indentation   +32 added lines, -34 removed lines patch added patch discarded remove patch
@@ -34,17 +34,16 @@  discard block
 block discarded – undo
34 34
 
35 35
 
36 36
 
37
-    /**
38
-     * Add an EE_Middleware class to the beginning of the middleware_stack
39
-     * First parameter is the middleware classname,
40
-     * any number of arguments can also be passed, and detected via func_get_args()
41
-
42
-     * @ param $class_name
43
-     * @ param $args
44
-     *
45
-     * @return EE_Request_Stack_Builder
46
-     * @throws \InvalidArgumentException
47
-     */
37
+	/**
38
+	 * Add an EE_Middleware class to the beginning of the middleware_stack
39
+	 * First parameter is the middleware classname,
40
+	 * any number of arguments can also be passed, and detected via func_get_args()
41
+	 * @ param $class_name
42
+	 * @ param $args
43
+	 *
44
+	 * @return EE_Request_Stack_Builder
45
+	 * @throws \InvalidArgumentException
46
+	 */
48 47
 	public function unshift( /*$class_name, $args*/ ) {
49 48
 		if ( func_num_args() === 0 ) {
50 49
 			throw new InvalidArgumentException( 'Missing argument(s) when calling unshift' );
@@ -56,35 +55,34 @@  discard block
 block discarded – undo
56 55
 
57 56
 
58 57
 
59
-    /**
60
-     * Add an EE_Middleware class to the end of the middleware_stack
61
-     * First parameter is the middleware classname,
62
-     * any number of arguments can also be passed, and detected via func_get_args()
63
-
64
-     * @ param $class_name
65
-     * @ param $args
66
-     *
67
-     * @return EE_Request_Stack_Builder
68
-     * @throws \InvalidArgumentException
69
-     */
58
+	/**
59
+	 * Add an EE_Middleware class to the end of the middleware_stack
60
+	 * First parameter is the middleware classname,
61
+	 * any number of arguments can also be passed, and detected via func_get_args()
62
+	 * @ param $class_name
63
+	 * @ param $args
64
+	 *
65
+	 * @return EE_Request_Stack_Builder
66
+	 * @throws \InvalidArgumentException
67
+	 */
70 68
 	public function push( /*$class_name, $args...*/ ) {
71 69
 		if ( func_num_args() === 0 ) {
72 70
 			throw new InvalidArgumentException( 'Missing argument(s) when calling push' );
73 71
 		}
74
-        $middleware = func_get_args();
75
-        $this->_middleware_stack[] = $middleware;
72
+		$middleware = func_get_args();
73
+		$this->_middleware_stack[] = $middleware;
76 74
 		return $this;
77 75
 	}
78 76
 
79 77
 
80 78
 
81
-    /**
82
-     * builds decorated middleware stack
83
-     * by continuously injecting previous middleware app into the next
84
-     *
85
-     * @param EEI_Request_Decorator $application
86
-     * @return EE_Request_Stack
87
-     */
79
+	/**
80
+	 * builds decorated middleware stack
81
+	 * by continuously injecting previous middleware app into the next
82
+	 *
83
+	 * @param EEI_Request_Decorator $application
84
+	 * @return EE_Request_Stack
85
+	 */
88 86
 	public function resolve( EEI_Request_Decorator $application ) {
89 87
 		$middlewares = array( $application );
90 88
 		foreach ( $this->_middleware_stack as $middleware_args ) {
@@ -93,9 +91,9 @@  discard block
 block discarded – undo
93 91
 				$application = $class_name( $application );
94 92
 			} else {
95 93
 				array_unshift( $middleware_args, $application );
96
-                $reflection = new ReflectionClass($class_name);
97
-                $application = $reflection->newInstanceArgs($middleware_args);
98
-            }
94
+				$reflection = new ReflectionClass($class_name);
95
+				$application = $reflection->newInstanceArgs($middleware_args);
96
+			}
99 97
 			array_unshift( $middlewares, $application );
100 98
 		}
101 99
 		return new EE_Request_Stack( $application, $middlewares );
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
      * @throws \InvalidArgumentException
47 47
      */
48 48
 	public function unshift( /*$class_name, $args*/ ) {
49
-		if ( func_num_args() === 0 ) {
50
-			throw new InvalidArgumentException( 'Missing argument(s) when calling unshift' );
49
+		if (func_num_args() === 0) {
50
+			throw new InvalidArgumentException('Missing argument(s) when calling unshift');
51 51
 		}
52 52
 		$middleware = func_get_args();
53
-		array_unshift( $this->_middleware_stack, $middleware );
53
+		array_unshift($this->_middleware_stack, $middleware);
54 54
 		return $this;
55 55
 	}
56 56
 
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
      * @throws \InvalidArgumentException
69 69
      */
70 70
 	public function push( /*$class_name, $args...*/ ) {
71
-		if ( func_num_args() === 0 ) {
72
-			throw new InvalidArgumentException( 'Missing argument(s) when calling push' );
71
+		if (func_num_args() === 0) {
72
+			throw new InvalidArgumentException('Missing argument(s) when calling push');
73 73
 		}
74 74
         $middleware = func_get_args();
75 75
         $this->_middleware_stack[] = $middleware;
@@ -85,20 +85,20 @@  discard block
 block discarded – undo
85 85
      * @param EEI_Request_Decorator $application
86 86
      * @return EE_Request_Stack
87 87
      */
88
-	public function resolve( EEI_Request_Decorator $application ) {
89
-		$middlewares = array( $application );
90
-		foreach ( $this->_middleware_stack as $middleware_args ) {
91
-			$class_name = array_shift( $middleware_args );
92
-			if ( is_callable( $class_name ) ) {
93
-				$application = $class_name( $application );
88
+	public function resolve(EEI_Request_Decorator $application) {
89
+		$middlewares = array($application);
90
+		foreach ($this->_middleware_stack as $middleware_args) {
91
+			$class_name = array_shift($middleware_args);
92
+			if (is_callable($class_name)) {
93
+				$application = $class_name($application);
94 94
 			} else {
95
-				array_unshift( $middleware_args, $application );
95
+				array_unshift($middleware_args, $application);
96 96
                 $reflection = new ReflectionClass($class_name);
97 97
                 $application = $reflection->newInstanceArgs($middleware_args);
98 98
             }
99
-			array_unshift( $middlewares, $application );
99
+			array_unshift($middlewares, $application);
100 100
 		}
101
-		return new EE_Request_Stack( $application, $middlewares );
101
+		return new EE_Request_Stack($application, $middlewares);
102 102
 	}
103 103
 
104 104
 
Please login to merge, or discard this patch.
espresso.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -127,13 +127,13 @@  discard block
 block discarded – undo
127 127
                 return;
128 128
             }
129 129
             // load debugging tools
130
-            if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
131
-                require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
130
+            if (WP_DEBUG === true && is_readable(EE_HELPERS.'EEH_Debug_Tools.helper.php')) {
131
+                require_once(EE_HELPERS.'EEH_Debug_Tools.helper.php');
132 132
                 \EEH_Debug_Tools::instance();
133 133
             }
134 134
             // load error handling
135
-            if (is_readable(EE_CORE . 'EE_Error.core.php')) {
136
-                require_once(EE_CORE . 'EE_Error.core.php');
135
+            if (is_readable(EE_CORE.'EE_Error.core.php')) {
136
+                require_once(EE_CORE.'EE_Error.core.php');
137 137
             } else {
138 138
                 wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
139 139
             }
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
             if (is_readable($full_path_to_file)) {
154 154
                 require_once($full_path_to_file);
155 155
             } else {
156
-                throw new \EE_Error (
156
+                throw new \EE_Error(
157 157
                     sprintf(
158 158
                         esc_html__(
159 159
                             'The %s class file could not be located or is not readable due to file permissions.',
@@ -180,20 +180,20 @@  discard block
 block discarded – undo
180 180
         function bootstrap_espresso()
181 181
         {
182 182
             try {
183
-                require_once(plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE) . 'core/espresso_definitions.php');
183
+                require_once(plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE).'core/espresso_definitions.php');
184 184
                 espresso_load_error_handling();
185
-                espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
186
-                espresso_load_required('EEH_File', EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php');
187
-                espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
188
-                espresso_load_required('EEH_Array', EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php');
185
+                espresso_load_required('EEH_Base', EE_CORE.'helpers'.DS.'EEH_Base.helper.php');
186
+                espresso_load_required('EEH_File', EE_CORE.'interfaces'.DS.'EEHI_File.interface.php');
187
+                espresso_load_required('EEH_File', EE_CORE.'helpers'.DS.'EEH_File.helper.php');
188
+                espresso_load_required('EEH_Array', EE_CORE.'helpers'.DS.'EEH_Array.helper.php');
189 189
                 // instantiate and configure PSR4 autoloader
190
-                espresso_load_required('Psr4Autoloader', EE_CORE . 'Psr4Autoloader.php');
191
-                espresso_load_required('EE_Psr4AutoloaderInit', EE_CORE . 'EE_Psr4AutoloaderInit.core.php');
190
+                espresso_load_required('Psr4Autoloader', EE_CORE.'Psr4Autoloader.php');
191
+                espresso_load_required('EE_Psr4AutoloaderInit', EE_CORE.'EE_Psr4AutoloaderInit.core.php');
192 192
                 $AutoloaderInit = new \EE_Psr4AutoloaderInit();
193 193
                 $AutoloaderInit->initializeAutoloader();
194
-                espresso_load_required('EE_Request', EE_CORE . 'request_stack' . DS . 'EE_Request.core.php');
195
-                espresso_load_required('EE_Response', EE_CORE . 'request_stack' . DS . 'EE_Response.core.php');
196
-                espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
194
+                espresso_load_required('EE_Request', EE_CORE.'request_stack'.DS.'EE_Request.core.php');
195
+                espresso_load_required('EE_Response', EE_CORE.'request_stack'.DS.'EE_Response.core.php');
196
+                espresso_load_required('EE_Bootstrap', EE_CORE.'EE_Bootstrap.core.php');
197 197
                 // bootstrap EE and the request stack
198 198
                 new EE_Bootstrap(
199 199
                     new EE_Request($_GET, $_POST, $_COOKIE),
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
     function espresso_deactivate_plugin($plugin_basename = '')
222 222
     {
223 223
         if ( ! function_exists('deactivate_plugins')) {
224
-            require_once(ABSPATH . 'wp-admin/includes/plugin.php');
224
+            require_once(ABSPATH.'wp-admin/includes/plugin.php');
225 225
         }
226 226
         unset($_GET['activate'], $_REQUEST['activate']);
227 227
         deactivate_plugins($plugin_basename);
Please login to merge, or discard this patch.
Indentation   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -38,192 +38,192 @@
 block discarded – undo
38 38
  * @since            4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    /**
42
-     *    espresso_duplicate_plugin_error
43
-     *    displays if more than one version of EE is activated at the same time
44
-     */
45
-    function espresso_duplicate_plugin_error()
46
-    {
47
-        ?>
41
+	/**
42
+	 *    espresso_duplicate_plugin_error
43
+	 *    displays if more than one version of EE is activated at the same time
44
+	 */
45
+	function espresso_duplicate_plugin_error()
46
+	{
47
+		?>
48 48
         <div class="error">
49 49
             <p>
50 50
                 <?php echo esc_html__(
51
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
52
-                        'event_espresso'
53
-                ); ?>
51
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
52
+						'event_espresso'
53
+				); ?>
54 54
             </p>
55 55
         </div>
56 56
         <?php
57
-        espresso_deactivate_plugin(plugin_basename(__FILE__));
58
-    }
57
+		espresso_deactivate_plugin(plugin_basename(__FILE__));
58
+	}
59 59
 
60
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
60
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
61 61
 } else {
62
-    define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
63
-    if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
64
-        /**
65
-         * espresso_minimum_php_version_error
66
-         *
67
-         * @return void
68
-         */
69
-        function espresso_minimum_php_version_error()
70
-        {
71
-            ?>
62
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
63
+	if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
64
+		/**
65
+		 * espresso_minimum_php_version_error
66
+		 *
67
+		 * @return void
68
+		 */
69
+		function espresso_minimum_php_version_error()
70
+		{
71
+			?>
72 72
             <div class="error">
73 73
                 <p>
74 74
                     <?php
75
-                    printf(
76
-                            esc_html__(
77
-                                    'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
78
-                                    'event_espresso'
79
-                            ),
80
-                            EE_MIN_PHP_VER_REQUIRED,
81
-                            PHP_VERSION,
82
-                            '<br/>',
83
-                            '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
84
-                    );
85
-                    ?>
75
+					printf(
76
+							esc_html__(
77
+									'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
78
+									'event_espresso'
79
+							),
80
+							EE_MIN_PHP_VER_REQUIRED,
81
+							PHP_VERSION,
82
+							'<br/>',
83
+							'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
84
+					);
85
+					?>
86 86
                 </p>
87 87
             </div>
88 88
             <?php
89
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
90
-        }
89
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
90
+		}
91 91
 
92
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
92
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
93 93
 
94
-    } else {
94
+	} else {
95 95
 
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97 97
 
98
-        /**
99
-         * espresso_version
100
-         * Returns the plugin version
101
-         *
102
-         * @return string
103
-         */
104
-        function espresso_version()
105
-        {
106
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.35.rc.017');
107
-        }
98
+		/**
99
+		 * espresso_version
100
+		 * Returns the plugin version
101
+		 *
102
+		 * @return string
103
+		 */
104
+		function espresso_version()
105
+		{
106
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.35.rc.017');
107
+		}
108 108
 
109
-        /**
110
-         * espresso_plugin_activation
111
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
112
-         */
113
-        function espresso_plugin_activation()
114
-        {
115
-            update_option('ee_espresso_activation', true);
116
-        }
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
109
+		/**
110
+		 * espresso_plugin_activation
111
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
112
+		 */
113
+		function espresso_plugin_activation()
114
+		{
115
+			update_option('ee_espresso_activation', true);
116
+		}
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        /**
120
-         *    espresso_load_error_handling
121
-         *    this function loads EE's class for handling exceptions and errors
122
-         */
123
-        function espresso_load_error_handling()
124
-        {
125
-            static $error_handling_loaded = false;
126
-            if ($error_handling_loaded) {
127
-                return;
128
-            }
129
-            // load debugging tools
130
-            if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
131
-                require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
132
-                \EEH_Debug_Tools::instance();
133
-            }
134
-            // load error handling
135
-            if (is_readable(EE_CORE . 'EE_Error.core.php')) {
136
-                require_once(EE_CORE . 'EE_Error.core.php');
137
-            } else {
138
-                wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
139
-            }
140
-            $error_handling_loaded = true;
141
-        }
119
+		/**
120
+		 *    espresso_load_error_handling
121
+		 *    this function loads EE's class for handling exceptions and errors
122
+		 */
123
+		function espresso_load_error_handling()
124
+		{
125
+			static $error_handling_loaded = false;
126
+			if ($error_handling_loaded) {
127
+				return;
128
+			}
129
+			// load debugging tools
130
+			if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
131
+				require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
132
+				\EEH_Debug_Tools::instance();
133
+			}
134
+			// load error handling
135
+			if (is_readable(EE_CORE . 'EE_Error.core.php')) {
136
+				require_once(EE_CORE . 'EE_Error.core.php');
137
+			} else {
138
+				wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
139
+			}
140
+			$error_handling_loaded = true;
141
+		}
142 142
 
143
-        /**
144
-         *    espresso_load_required
145
-         *    given a class name and path, this function will load that file or throw an exception
146
-         *
147
-         * @param    string $classname
148
-         * @param    string $full_path_to_file
149
-         * @throws    EE_Error
150
-         */
151
-        function espresso_load_required($classname, $full_path_to_file)
152
-        {
153
-            if (is_readable($full_path_to_file)) {
154
-                require_once($full_path_to_file);
155
-            } else {
156
-                throw new \EE_Error (
157
-                    sprintf(
158
-                        esc_html__(
159
-                            'The %s class file could not be located or is not readable due to file permissions.',
160
-                            'event_espresso'
161
-                        ),
162
-                        $classname
163
-                    )
164
-                );
165
-            }
166
-        }
143
+		/**
144
+		 *    espresso_load_required
145
+		 *    given a class name and path, this function will load that file or throw an exception
146
+		 *
147
+		 * @param    string $classname
148
+		 * @param    string $full_path_to_file
149
+		 * @throws    EE_Error
150
+		 */
151
+		function espresso_load_required($classname, $full_path_to_file)
152
+		{
153
+			if (is_readable($full_path_to_file)) {
154
+				require_once($full_path_to_file);
155
+			} else {
156
+				throw new \EE_Error (
157
+					sprintf(
158
+						esc_html__(
159
+							'The %s class file could not be located or is not readable due to file permissions.',
160
+							'event_espresso'
161
+						),
162
+						$classname
163
+					)
164
+				);
165
+			}
166
+		}
167 167
 
168
-        /**
169
-         * @since 4.9.27
170
-         * @throws \EE_Error
171
-         * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
172
-         * @throws \EventEspresso\core\exceptions\InvalidEntityException
173
-         * @throws \EventEspresso\core\exceptions\InvalidIdentifierException
174
-         * @throws \EventEspresso\core\exceptions\InvalidClassException
175
-         * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
176
-         * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException
177
-         * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException
178
-         * @throws \OutOfBoundsException
179
-         */
180
-        function bootstrap_espresso()
181
-        {
182
-            try {
183
-                require_once(plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE) . 'core/espresso_definitions.php');
184
-                espresso_load_error_handling();
185
-                espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
186
-                espresso_load_required('EEH_File', EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php');
187
-                espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
188
-                espresso_load_required('EEH_Array', EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php');
189
-                // instantiate and configure PSR4 autoloader
190
-                espresso_load_required('Psr4Autoloader', EE_CORE . 'Psr4Autoloader.php');
191
-                espresso_load_required('EE_Psr4AutoloaderInit', EE_CORE . 'EE_Psr4AutoloaderInit.core.php');
192
-                $AutoloaderInit = new \EE_Psr4AutoloaderInit();
193
-                $AutoloaderInit->initializeAutoloader();
194
-                espresso_load_required('EE_Request', EE_CORE . 'request_stack' . DS . 'EE_Request.core.php');
195
-                espresso_load_required('EE_Response', EE_CORE . 'request_stack' . DS . 'EE_Response.core.php');
196
-                espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
197
-                // bootstrap EE and the request stack
198
-                new EE_Bootstrap(
199
-                    new EE_Request($_GET, $_POST, $_COOKIE),
200
-                    new EE_Response()
201
-                );
202
-            } catch (Exception $e) {
203
-                new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e);
204
-            }
205
-        }
168
+		/**
169
+		 * @since 4.9.27
170
+		 * @throws \EE_Error
171
+		 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
172
+		 * @throws \EventEspresso\core\exceptions\InvalidEntityException
173
+		 * @throws \EventEspresso\core\exceptions\InvalidIdentifierException
174
+		 * @throws \EventEspresso\core\exceptions\InvalidClassException
175
+		 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
176
+		 * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException
177
+		 * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException
178
+		 * @throws \OutOfBoundsException
179
+		 */
180
+		function bootstrap_espresso()
181
+		{
182
+			try {
183
+				require_once(plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE) . 'core/espresso_definitions.php');
184
+				espresso_load_error_handling();
185
+				espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
186
+				espresso_load_required('EEH_File', EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php');
187
+				espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
188
+				espresso_load_required('EEH_Array', EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php');
189
+				// instantiate and configure PSR4 autoloader
190
+				espresso_load_required('Psr4Autoloader', EE_CORE . 'Psr4Autoloader.php');
191
+				espresso_load_required('EE_Psr4AutoloaderInit', EE_CORE . 'EE_Psr4AutoloaderInit.core.php');
192
+				$AutoloaderInit = new \EE_Psr4AutoloaderInit();
193
+				$AutoloaderInit->initializeAutoloader();
194
+				espresso_load_required('EE_Request', EE_CORE . 'request_stack' . DS . 'EE_Request.core.php');
195
+				espresso_load_required('EE_Response', EE_CORE . 'request_stack' . DS . 'EE_Response.core.php');
196
+				espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
197
+				// bootstrap EE and the request stack
198
+				new EE_Bootstrap(
199
+					new EE_Request($_GET, $_POST, $_COOKIE),
200
+					new EE_Response()
201
+				);
202
+			} catch (Exception $e) {
203
+				new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e);
204
+			}
205
+		}
206 206
 
207
-        bootstrap_espresso();
207
+		bootstrap_espresso();
208 208
 
209
-    }
209
+	}
210 210
 }
211 211
 
212 212
 if ( ! function_exists('espresso_deactivate_plugin')) {
213
-    /**
214
-     *    deactivate_plugin
215
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
216
-     *
217
-     * @access public
218
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
219
-     * @return    void
220
-     */
221
-    function espresso_deactivate_plugin($plugin_basename = '')
222
-    {
223
-        if ( ! function_exists('deactivate_plugins')) {
224
-            require_once(ABSPATH . 'wp-admin/includes/plugin.php');
225
-        }
226
-        unset($_GET['activate'], $_REQUEST['activate']);
227
-        deactivate_plugins($plugin_basename);
228
-    }
213
+	/**
214
+	 *    deactivate_plugin
215
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
216
+	 *
217
+	 * @access public
218
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
219
+	 * @return    void
220
+	 */
221
+	function espresso_deactivate_plugin($plugin_basename = '')
222
+	{
223
+		if ( ! function_exists('deactivate_plugins')) {
224
+			require_once(ABSPATH . 'wp-admin/includes/plugin.php');
225
+		}
226
+		unset($_GET['activate'], $_REQUEST['activate']);
227
+		deactivate_plugins($plugin_basename);
228
+	}
229 229
 }
230 230
\ No newline at end of file
Please login to merge, or discard this patch.
core/business/EE_Transaction_Payments.class.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -233,8 +233,8 @@
 block discarded – undo
233 233
 					if ( $registration instanceof EE_Registration ) {
234 234
 						$registration->set_paid( $registration->paid() - $amount_paid );
235 235
 						if ($registration->save() !== false) {
236
-						    $registration_payment->delete_permanently();
237
-                            $save_payment = true;
236
+							$registration_payment->delete_permanently();
237
+							$save_payment = true;
238 238
 						}
239 239
 					} else {
240 240
 						EE_Error::add_error(
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2
-EE_Registry::instance()->load_class( 'Processor_Base' );
2
+EE_Registry::instance()->load_class('Processor_Base');
3 3
 
4 4
 /**
5 5
  * Class EE_Transaction_Payments
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	 */
43 43
 	public static function instance() {
44 44
 		// check if class object is instantiated
45
-		if ( ! self::$_instance instanceof EE_Transaction_Payments ) {
45
+		if ( ! self::$_instance instanceof EE_Transaction_Payments) {
46 46
 			self::$_instance = new self();
47 47
 		}
48 48
 		return self::$_instance;
@@ -59,18 +59,18 @@  discard block
 block discarded – undo
59 59
 	 * @return bool true if TXN total was updated, false if not
60 60
 	 * @throws \EE_Error
61 61
 	 */
62
-	public function recalculate_transaction_total( EE_Transaction $transaction, $update_txn = true ) {
62
+	public function recalculate_transaction_total(EE_Transaction $transaction, $update_txn = true) {
63 63
 		$total_line_item = $transaction->total_line_item();
64
-		if ( ! $total_line_item instanceof EE_Line_Item ) {
64
+		if ( ! $total_line_item instanceof EE_Line_Item) {
65 65
 			EE_Error::add_error(
66
-				sprintf( __( 'The Total Line Item for Transaction %1$d\'s was not found or is invalid.', 'event_espresso' ), $transaction->ID() ),
66
+				sprintf(__('The Total Line Item for Transaction %1$d\'s was not found or is invalid.', 'event_espresso'), $transaction->ID()),
67 67
 				__FILE__, __FUNCTION__, __LINE__
68 68
 			);
69 69
 			return false;
70 70
 		}
71 71
 		$new_total = $total_line_item->recalculate_total_including_taxes();
72
-		$transaction->set_total( $new_total );
73
-		if ( $update_txn ) {
72
+		$transaction->set_total($new_total);
73
+		if ($update_txn) {
74 74
 			return $transaction->save() ? true : false;
75 75
 		}
76 76
 		return false;
@@ -93,20 +93,20 @@  discard block
 block discarded – undo
93 93
 	 * @return    boolean        whether the TXN was saved
94 94
 	 * @throws \EE_Error
95 95
 	 */
96
-	public function calculate_total_payments_and_update_status( EE_Transaction $transaction, $update_txn = true ){
96
+	public function calculate_total_payments_and_update_status(EE_Transaction $transaction, $update_txn = true) {
97 97
 		// verify transaction
98
-		if ( ! $transaction instanceof EE_Transaction ) {
99
-			EE_Error::add_error( __( 'Please provide a valid EE_Transaction object.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
98
+		if ( ! $transaction instanceof EE_Transaction) {
99
+			EE_Error::add_error(__('Please provide a valid EE_Transaction object.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
100 100
 			return false;
101 101
 		}
102 102
 		// calculate total paid
103
-		$total_paid = $this->recalculate_total_payments_for_transaction( $transaction );
103
+		$total_paid = $this->recalculate_total_payments_for_transaction($transaction);
104 104
 		// if total paid has changed
105
-		if ( $total_paid !== false && (float)$total_paid !== $transaction->paid() ) {
106
-			$transaction->set_paid( $total_paid );
105
+		if ($total_paid !== false && (float) $total_paid !== $transaction->paid()) {
106
+			$transaction->set_paid($total_paid);
107 107
 			// maybe update status, and make sure to save transaction if not done already
108
-			if ( ! $transaction->update_status_based_on_total_paid( $update_txn ) ) {
109
-				if ( $update_txn ) {
108
+			if ( ! $transaction->update_status_based_on_total_paid($update_txn)) {
109
+				if ($update_txn) {
110 110
 					return $transaction->save() ? true : false;
111 111
 				}
112 112
 			} else {
@@ -130,18 +130,18 @@  discard block
 block discarded – undo
130 130
 	 * @return float|false   float on success, false on fail
131 131
 	 * @throws \EE_Error
132 132
 	 */
133
-	public function recalculate_total_payments_for_transaction( EE_Transaction $transaction, $payment_status = EEM_Payment::status_id_approved ) {
133
+	public function recalculate_total_payments_for_transaction(EE_Transaction $transaction, $payment_status = EEM_Payment::status_id_approved) {
134 134
 		// verify transaction
135
-		if ( ! $transaction instanceof EE_Transaction ) {
136
-			EE_Error::add_error( __( 'Please provide a valid EE_Transaction object.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
135
+		if ( ! $transaction instanceof EE_Transaction) {
136
+			EE_Error::add_error(__('Please provide a valid EE_Transaction object.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
137 137
 			return false;
138 138
 		}
139 139
 		// ensure Payment model is loaded
140
-		EE_Registry::instance()->load_model( 'Payment' );
140
+		EE_Registry::instance()->load_model('Payment');
141 141
 		// calls EEM_Base::sum()
142 142
 		return EEM_Payment::instance()->sum(
143 143
 			// query params
144
-			array( array( 'TXN_ID' => $transaction->ID(), 'STS_ID' => $payment_status )),
144
+			array(array('TXN_ID' => $transaction->ID(), 'STS_ID' => $payment_status)),
145 145
 			// field to sum
146 146
 			'PAY_amount'
147 147
 		);
@@ -159,17 +159,17 @@  discard block
 block discarded – undo
159 159
 	 * @return boolean
160 160
 	 * @throws \EE_Error
161 161
 	 */
162
-	public function delete_payment_and_update_transaction( EE_Payment $payment ) {
162
+	public function delete_payment_and_update_transaction(EE_Payment $payment) {
163 163
 		// verify payment
164
-		if ( ! $payment instanceof EE_Payment ) {
165
-			EE_Error::add_error( __( 'A valid Payment object was not received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
164
+		if ( ! $payment instanceof EE_Payment) {
165
+			EE_Error::add_error(__('A valid Payment object was not received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
166 166
 			return false;
167 167
 		}
168
-		if ( ! $this->delete_registration_payments_and_update_registrations( $payment ) ) {
168
+		if ( ! $this->delete_registration_payments_and_update_registrations($payment)) {
169 169
 			return false;
170 170
 		}
171
-		if ( ! $payment->delete() ) {
172
-			EE_Error::add_error( __( 'The payment could not be deleted.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
171
+		if ( ! $payment->delete()) {
172
+			EE_Error::add_error(__('The payment could not be deleted.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
173 173
 			return false;
174 174
 		}
175 175
 
@@ -180,14 +180,14 @@  discard block
 block discarded – undo
180 180
 			|| $TXN_status === EEM_Transaction::failed_status_code
181 181
 			|| $payment->amount() === 0
182 182
 		) {
183
-			EE_Error::add_success( __( 'The Payment was successfully deleted.', 'event_espresso' ) );
183
+			EE_Error::add_success(__('The Payment was successfully deleted.', 'event_espresso'));
184 184
 			return true;
185 185
 		}
186 186
 
187 187
 
188 188
 		//if this fails, that just means that the transaction didn't get its status changed and/or updated.
189 189
 		//however the payment was still deleted.
190
-		if ( ! $this->calculate_total_payments_and_update_status( $transaction ) ) {
190
+		if ( ! $this->calculate_total_payments_and_update_status($transaction)) {
191 191
 
192 192
 			EE_Error::add_attention(
193 193
 				__(
@@ -221,17 +221,17 @@  discard block
 block discarded – undo
221 221
 	 * @return bool
222 222
 	 * @throws \EE_Error
223 223
 	 */
224
-	public function delete_registration_payments_and_update_registrations( EE_Payment $payment, $reg_payment_query_params = array() ) {
224
+	public function delete_registration_payments_and_update_registrations(EE_Payment $payment, $reg_payment_query_params = array()) {
225 225
 		$save_payment = false;
226
-		$reg_payment_query_params = ! empty( $reg_payment_query_params ) ? $reg_payment_query_params : array( array( 'PAY_ID' => $payment->ID() ) );
227
-		$registration_payments = EEM_Registration_Payment::instance()->get_all( $reg_payment_query_params );
228
-		if ( ! empty( $registration_payments )) {
229
-			foreach ( $registration_payments as $registration_payment ) {
230
-				if ( $registration_payment instanceof EE_Registration_Payment ) {
226
+		$reg_payment_query_params = ! empty($reg_payment_query_params) ? $reg_payment_query_params : array(array('PAY_ID' => $payment->ID()));
227
+		$registration_payments = EEM_Registration_Payment::instance()->get_all($reg_payment_query_params);
228
+		if ( ! empty($registration_payments)) {
229
+			foreach ($registration_payments as $registration_payment) {
230
+				if ($registration_payment instanceof EE_Registration_Payment) {
231 231
 					$amount_paid = $registration_payment->amount();
232 232
 					$registration = $registration_payment->registration();
233
-					if ( $registration instanceof EE_Registration ) {
234
-						$registration->set_paid( $registration->paid() - $amount_paid );
233
+					if ($registration instanceof EE_Registration) {
234
+						$registration->set_paid($registration->paid() - $amount_paid);
235 235
 						if ($registration->save() !== false) {
236 236
 						    $registration_payment->delete_permanently();
237 237
                             $save_payment = true;
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 					} else {
240 240
 						EE_Error::add_error(
241 241
 							sprintf(
242
-								__( 'An invalid Registration object was associated with Registration Payment ID# %1$d.', 'event_espresso' ),
242
+								__('An invalid Registration object was associated with Registration Payment ID# %1$d.', 'event_espresso'),
243 243
 								$registration_payment->ID()
244 244
 							),
245 245
 							__FILE__, __FUNCTION__, __LINE__
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 				} else {
250 250
 					EE_Error::add_error(
251 251
 						sprintf(
252
-							__( 'An invalid Registration Payment object was associated with payment ID# %1$d.', 'event_espresso' ),
252
+							__('An invalid Registration Payment object was associated with payment ID# %1$d.', 'event_espresso'),
253 253
 							$payment->ID()
254 254
 						),
255 255
 						__FILE__, __FUNCTION__, __LINE__
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 				}
259 259
 			}
260 260
 		}
261
-		if ( $save_payment ) {
261
+		if ($save_payment) {
262 262
 			$payment->save();
263 263
 		}
264 264
 		return true;
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	public function update_transaction_status_based_on_total_paid(EE_Transaction $transaction, $update_txn = true)
283 283
 	{
284 284
 		EE_Error::doing_it_wrong(
285
-			__CLASS__ . '::' . __FUNCTION__,
285
+			__CLASS__.'::'.__FUNCTION__,
286 286
 			sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
287 287
 				'EE_Transaction::update_status_based_on_total_paid()'),
288 288
 			'4.9.1',
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 	 * @deprecated 4.9.12
325 325
 	 * @param string $old_txn_status
326 326
 	 */
327
-	public function set_old_txn_status( $old_txn_status ) {
327
+	public function set_old_txn_status($old_txn_status) {
328 328
 		EE_Error::doing_it_wrong(
329 329
 			__METHOD__,
330 330
 			esc_html__(
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 			'4.9.12'
335 335
 		);
336 336
 		// only set the first time
337
-		if ( $this->_old_txn_status === null ) {
337
+		if ($this->_old_txn_status === null) {
338 338
 			$this->_old_txn_status = $old_txn_status;
339 339
 		}
340 340
 	}
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 	 * @deprecated 4.9.12
364 364
 	 * @param string $new_txn_status
365 365
 	 */
366
-	public function set_new_txn_status( $new_txn_status ) {
366
+	public function set_new_txn_status($new_txn_status) {
367 367
 		EE_Error::doing_it_wrong(
368 368
 			__METHOD__,
369 369
 			esc_html__(
Please login to merge, or discard this patch.
core/libraries/form_sections/strategies/filter/VsprintfFilter.php 2 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -23,49 +23,49 @@
 block discarded – undo
23 23
 class VsprintfFilter extends FormHtmlFilter
24 24
 {
25 25
 
26
-    /**
27
-     * @var string $format
28
-     */
29
-    protected $format = '';
30
-
31
-
32
-    /**
33
-     * @var array $args
34
-     */
35
-    protected $args = array();
36
-
37
-
38
-
39
-    /**
40
-     * SprintfFormHtmlParser constructor.
41
-     *
42
-     * @param string $format
43
-     * @param array  $args
44
-     */
45
-    public function __construct($format, array $args)
46
-    {
47
-        $this->format = $format;
48
-        $this->args = $args;
49
-    }
50
-
51
-
52
-
53
-    /**
54
-     * @param                        $html
55
-     * @param EE_Form_Section_Validatable $form_section
56
-     * @return string
57
-     */
58
-    public function filterHtml($html, EE_Form_Section_Validatable $form_section)
59
-    {
60
-        $this->args[] = $html;
61
-        if ($form_section instanceof EE_Form_Section_Proper) {
62
-            $subsections = $form_section->subsections();
63
-            foreach ((array)$subsections as $subsection) {
64
-                $this->args[] = $subsection->get_html();
65
-            }
66
-        }
67
-        return vsprintf($this->format, $this->args);
68
-    }
26
+	/**
27
+	 * @var string $format
28
+	 */
29
+	protected $format = '';
30
+
31
+
32
+	/**
33
+	 * @var array $args
34
+	 */
35
+	protected $args = array();
36
+
37
+
38
+
39
+	/**
40
+	 * SprintfFormHtmlParser constructor.
41
+	 *
42
+	 * @param string $format
43
+	 * @param array  $args
44
+	 */
45
+	public function __construct($format, array $args)
46
+	{
47
+		$this->format = $format;
48
+		$this->args = $args;
49
+	}
50
+
51
+
52
+
53
+	/**
54
+	 * @param                        $html
55
+	 * @param EE_Form_Section_Validatable $form_section
56
+	 * @return string
57
+	 */
58
+	public function filterHtml($html, EE_Form_Section_Validatable $form_section)
59
+	{
60
+		$this->args[] = $html;
61
+		if ($form_section instanceof EE_Form_Section_Proper) {
62
+			$subsections = $form_section->subsections();
63
+			foreach ((array)$subsections as $subsection) {
64
+				$this->args[] = $subsection->get_html();
65
+			}
66
+		}
67
+		return vsprintf($this->format, $this->args);
68
+	}
69 69
 
70 70
 
71 71
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@
 block discarded – undo
60 60
         $this->args[] = $html;
61 61
         if ($form_section instanceof EE_Form_Section_Proper) {
62 62
             $subsections = $form_section->subsections();
63
-            foreach ((array)$subsections as $subsection) {
63
+            foreach ((array) $subsections as $subsection) {
64 64
                 $this->args[] = $subsection->get_html();
65 65
             }
66 66
         }
Please login to merge, or discard this patch.
form_sections/strategies/display/EE_Select_Display_Strategy.strategy.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@
 block discarded – undo
84 84
 	 * Checks if that value is the one selected
85 85
 	 *
86 86
 	 * @param string|int $option_value unnormalized value option (string). How it will appear in the HTML.
87
-	 * @return string
87
+	 * @return boolean
88 88
 	 */
89 89
 	protected function _check_if_option_selected($option_value ){
90 90
 		return $option_value === $this->_input->raw_value();
Please login to merge, or discard this patch.
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -38,15 +38,15 @@  discard block
 block discarded – undo
38 38
 		if ( EEH_Array::is_multi_dimensional_array( $this->_input->options() )) {
39 39
 			EEH_HTML::indent( 1, 'optgroup' );
40 40
 			foreach( $this->_input->options() as $opt_group_label => $opt_group ){
41
-			    if ( ! empty($opt_group_label)) {
42
-                    $html .= EEH_HTML::nl(0, 'optgroup') . '<optgroup label="' . esc_attr($opt_group_label) . '">';
43
-                }
41
+				if ( ! empty($opt_group_label)) {
42
+					$html .= EEH_HTML::nl(0, 'optgroup') . '<optgroup label="' . esc_attr($opt_group_label) . '">';
43
+				}
44 44
 				EEH_HTML::indent( 1, 'option' );
45 45
 				$html .= $this->_display_options( $opt_group );
46 46
 				EEH_HTML::indent( -1, 'option' );
47
-                if ( ! empty($opt_group_label)) {
48
-                    $html .= EEH_HTML::nl( 0, 'optgroup' ) . '</optgroup>';
49
-			    }
47
+				if ( ! empty($opt_group_label)) {
48
+					$html .= EEH_HTML::nl( 0, 'optgroup' ) . '</optgroup>';
49
+				}
50 50
 			}
51 51
 			EEH_HTML::indent( -1, 'optgroup' );
52 52
 		} else {
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
 		$html = '';
69 69
 		EEH_HTML::indent( 1, 'option' );
70 70
 		foreach( $options as $value => $display_text ){
71
-		    //even if this input uses EE_Text_Normalization if one of the array keys is a numeric string, like "123",
72
-            //PHP will have converted it to a PHP integer (eg 123). So we need to make sure it's a string
73
-            $unnormalized_value = $this->_input->get_normalization_strategy()->unnormalize_one( $value );
74
-            $selected = $this->_check_if_option_selected($unnormalized_value ) ? ' selected="selected"' : '';
75
-            $html.= EEH_HTML::nl( 0, 'option' ) . '<option value="' . esc_attr($unnormalized_value ) . '"' . $selected . '>' . $display_text . '</option>';
71
+			//even if this input uses EE_Text_Normalization if one of the array keys is a numeric string, like "123",
72
+			//PHP will have converted it to a PHP integer (eg 123). So we need to make sure it's a string
73
+			$unnormalized_value = $this->_input->get_normalization_strategy()->unnormalize_one( $value );
74
+			$selected = $this->_check_if_option_selected($unnormalized_value ) ? ' selected="selected"' : '';
75
+			$html.= EEH_HTML::nl( 0, 'option' ) . '<option value="' . esc_attr($unnormalized_value ) . '"' . $selected . '>' . $display_text . '</option>';
76 76
 		}
77 77
 		EEH_HTML::indent( -1, 'option' );
78 78
 		return $html;
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -11,49 +11,49 @@  discard block
 block discarded – undo
11 11
  * @since 				$VID:$
12 12
  *
13 13
  */
14
-class EE_Select_Display_Strategy extends EE_Display_Strategy_Base{
14
+class EE_Select_Display_Strategy extends EE_Display_Strategy_Base {
15 15
 
16 16
 	/**
17 17
 	 *
18 18
 	 * @throws EE_Error
19 19
 	 * @return string of html to display the field
20 20
 	 */
21
-	function display(){
22
-		if( ! $this->_input instanceof EE_Form_Input_With_Options_Base){
23
-			throw new EE_Error( sprintf( __( 'Cannot use Select Display Strategy with an input that doesn\'t have options', 'event_espresso' )));
21
+	function display() {
22
+		if ( ! $this->_input instanceof EE_Form_Input_With_Options_Base) {
23
+			throw new EE_Error(sprintf(__('Cannot use Select Display Strategy with an input that doesn\'t have options', 'event_espresso')));
24 24
 		}
25 25
 
26
-		$html = EEH_HTML::nl( 0, 'select' );
26
+		$html = EEH_HTML::nl(0, 'select');
27 27
 		$html .= '<select';
28
-		$html .= ' id="' . $this->_input->html_id() . '"';
29
-		$html .= ' name="' . $this->_input->html_name() . '"';
30
-		$class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class();
31
-		$html .= ' class="' . $class . '"';
28
+		$html .= ' id="'.$this->_input->html_id().'"';
29
+		$html .= ' name="'.$this->_input->html_name().'"';
30
+		$class = $this->_input->required() ? $this->_input->required_css_class().' '.$this->_input->html_class() : $this->_input->html_class();
31
+		$html .= ' class="'.$class.'"';
32 32
 		// add html5 required
33 33
 		$html .= $this->_input->required() ? ' required' : '';
34
-		$html .= ' style="' . $this->_input->html_style() . '"';
35
-		$html .= ' ' . $this->_input->other_html_attributes();
34
+		$html .= ' style="'.$this->_input->html_style().'"';
35
+		$html .= ' '.$this->_input->other_html_attributes();
36 36
 		$html .= '>';
37 37
 
38
-		if ( EEH_Array::is_multi_dimensional_array( $this->_input->options() )) {
39
-			EEH_HTML::indent( 1, 'optgroup' );
40
-			foreach( $this->_input->options() as $opt_group_label => $opt_group ){
38
+		if (EEH_Array::is_multi_dimensional_array($this->_input->options())) {
39
+			EEH_HTML::indent(1, 'optgroup');
40
+			foreach ($this->_input->options() as $opt_group_label => $opt_group) {
41 41
 			    if ( ! empty($opt_group_label)) {
42
-                    $html .= EEH_HTML::nl(0, 'optgroup') . '<optgroup label="' . esc_attr($opt_group_label) . '">';
42
+                    $html .= EEH_HTML::nl(0, 'optgroup').'<optgroup label="'.esc_attr($opt_group_label).'">';
43 43
                 }
44
-				EEH_HTML::indent( 1, 'option' );
45
-				$html .= $this->_display_options( $opt_group );
44
+				EEH_HTML::indent(1, 'option');
45
+				$html .= $this->_display_options($opt_group);
46 46
 				EEH_HTML::indent( -1, 'option' );
47 47
                 if ( ! empty($opt_group_label)) {
48
-                    $html .= EEH_HTML::nl( 0, 'optgroup' ) . '</optgroup>';
48
+                    $html .= EEH_HTML::nl(0, 'optgroup').'</optgroup>';
49 49
 			    }
50 50
 			}
51 51
 			EEH_HTML::indent( -1, 'optgroup' );
52 52
 		} else {
53
-			$html.=$this->_display_options( $this->_input->options() );
53
+			$html .= $this->_display_options($this->_input->options());
54 54
 		}
55 55
 
56
-		$html.= EEH_HTML::nl( 0, 'select' ) . '</select>';
56
+		$html .= EEH_HTML::nl(0, 'select').'</select>';
57 57
 		return $html;
58 58
 	}
59 59
 
@@ -64,15 +64,15 @@  discard block
 block discarded – undo
64 64
 	 * @param array $options
65 65
 	 * @return string
66 66
 	 */
67
-	protected function _display_options($options){
67
+	protected function _display_options($options) {
68 68
 		$html = '';
69
-		EEH_HTML::indent( 1, 'option' );
70
-		foreach( $options as $value => $display_text ){
69
+		EEH_HTML::indent(1, 'option');
70
+		foreach ($options as $value => $display_text) {
71 71
 		    //even if this input uses EE_Text_Normalization if one of the array keys is a numeric string, like "123",
72 72
             //PHP will have converted it to a PHP integer (eg 123). So we need to make sure it's a string
73
-            $unnormalized_value = $this->_input->get_normalization_strategy()->unnormalize_one( $value );
74
-            $selected = $this->_check_if_option_selected($unnormalized_value ) ? ' selected="selected"' : '';
75
-            $html.= EEH_HTML::nl( 0, 'option' ) . '<option value="' . esc_attr($unnormalized_value ) . '"' . $selected . '>' . $display_text . '</option>';
73
+            $unnormalized_value = $this->_input->get_normalization_strategy()->unnormalize_one($value);
74
+            $selected = $this->_check_if_option_selected($unnormalized_value) ? ' selected="selected"' : '';
75
+            $html .= EEH_HTML::nl(0, 'option').'<option value="'.esc_attr($unnormalized_value).'"'.$selected.'>'.$display_text.'</option>';
76 76
 		}
77 77
 		EEH_HTML::indent( -1, 'option' );
78 78
 		return $html;
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 * @param string|int $option_value unnormalized value option (string). How it will appear in the HTML.
87 87
 	 * @return string
88 88
 	 */
89
-	protected function _check_if_option_selected($option_value ){
89
+	protected function _check_if_option_selected($option_value) {
90 90
 		return $option_value === $this->_input->raw_value();
91 91
 	}
92 92
 
Please login to merge, or discard this patch.
libraries/form_sections/inputs/EE_Form_Input_With_Options_Base.input.php 2 patches
Indentation   +315 added lines, -315 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -16,320 +16,320 @@  discard block
 block discarded – undo
16 16
 class EE_Form_Input_With_Options_Base extends EE_Form_Input_Base
17 17
 {
18 18
 
19
-    /**
20
-     * array of available options to choose as an answer
21
-     *
22
-     * @var array
23
-     */
24
-    protected $_options = array();
25
-
26
-    /**
27
-     * whether to display the html_label_text above the checkbox/radio button options
28
-     *
29
-     * @var boolean
30
-     */
31
-    protected $_display_html_label_text = true;
32
-
33
-    /**
34
-     * whether to display an question option description as part of the input label
35
-     *
36
-     * @var boolean
37
-     */
38
-    protected $_use_desc_in_label = true;
39
-
40
-    /**
41
-     * strlen() result for the longest input value (what gets displayed in the label)
42
-     * this is used to apply a css class to the input label
43
-     *
44
-     * @var int
45
-     */
46
-    protected $_label_size = 0;
47
-
48
-    /**
49
-     * whether to enforce the label size value passed in the constructor
50
-     *
51
-     * @var boolean
52
-     */
53
-    protected $_enforce_label_size = false;
54
-
55
-    /**
56
-     * whether to allow multiple selections (ie, the value of this input should be an array)
57
-     * or not (ie, the value should be a simple int, string, etc)
58
-     *
59
-     * @var boolean
60
-     */
61
-    protected $_multiple_selections = false;
62
-
63
-
64
-
65
-    /**
66
-     * @param array     $answer_options
67
-     * @param array     $input_settings {
68
-     * @type int|string $label_size
69
-     * @type boolean    $display_html_label_text
70
-     *                                  }
71
-     *                                  And all the options accepted by EE_Form_Input_Base
72
-     */
73
-    public function __construct($answer_options = array(), $input_settings = array())
74
-    {
75
-        if (isset($input_settings['label_size'])) {
76
-            $this->_set_label_size($input_settings['label_size']);
77
-            if (isset($input_settings['enforce_label_size']) && $input_settings['enforce_label_size']) {
78
-                $this->_enforce_label_size = true;
79
-            }
80
-        }
81
-        if (isset($input_settings['display_html_label_text'])) {
82
-            $this->set_display_html_label_text($input_settings['display_html_label_text']);
83
-        }
84
-        $this->set_select_options($answer_options);
85
-        parent::__construct($input_settings);
86
-    }
87
-
88
-
89
-
90
-    /**
91
-     * Sets the allowed options for this input. Also has the side-effect of
92
-     * updating the normalization strategy to match the keys provided in the array
93
-     *
94
-     * @param array $answer_options
95
-     * @return void  just has the side-effect of setting the options for this input
96
-     */
97
-    public function set_select_options($answer_options = array())
98
-    {
99
-        $answer_options = is_array($answer_options) ? $answer_options : array($answer_options);
100
-        //get the first item in the select options and check it's type
101
-        $this->_options = reset($answer_options) instanceof EE_Question_Option
102
-            ? $this->_process_question_options($answer_options)
103
-            : $answer_options;
104
-        //d( $this->_options );
105
-        $select_option_keys = array_keys($this->_options);
106
-        // attempt to determine data type for values in order to set normalization type
107
-        //purposefully only
108
-        if (
109
-            count($this->_options) === 2
110
-            && (
111
-                (in_array(true, $select_option_keys, true) && in_array(false, $select_option_keys, true))
112
-                || (in_array(1, $select_option_keys, true) && in_array(0, $select_option_keys, true))
113
-            )
114
-        ) {
115
-            // values appear to be boolean, like TRUE, FALSE, 1, 0
116
-            $normalization = new EE_Boolean_Normalization();
117
-        } else {
118
-            //are ALL the options ints (even if we're using a multi-dimensional array)? If so use int validation
119
-            $all_ints = true;
120
-            array_walk_recursive(
121
-                $this->_options,
122
-                function($value,$key) use (&$all_ints){
123
-                    //is this a top-level key? ignore it
124
-                    if(! is_array($value)
125
-                        && ! is_int($key)
126
-                       && $key !== ''
127
-                       && $key !== null){
128
-                        $all_ints = false;
129
-                    }
130
-                }
131
-            );
132
-            if ($all_ints) {
133
-                $normalization = new EE_Int_Normalization();
134
-            } else {
135
-                $normalization = new EE_Text_Normalization();
136
-            }
137
-        }
138
-        // does input type have multiple options ?
139
-        if ($this->_multiple_selections) {
140
-            $this->_set_normalization_strategy(new EE_Many_Valued_Normalization($normalization));
141
-        } else {
142
-            $this->_set_normalization_strategy($normalization);
143
-        }
144
-    }
145
-
146
-
147
-
148
-    /**
149
-     * @return array
150
-     */
151
-    public function options()
152
-    {
153
-        return $this->_options;
154
-    }
155
-
156
-
157
-
158
-    /**
159
-     * Returns an array which is guaranteed to not be multidimensional
160
-     *
161
-     * @return array
162
-     */
163
-    public function flat_options()
164
-    {
165
-        return $this->_flatten_select_options($this->options());
166
-    }
167
-
168
-
169
-
170
-    /**
171
-     * Makes sure $arr is a flat array, not a multidimensional one
172
-     *
173
-     * @param array $arr
174
-     * @return array
175
-     */
176
-    protected function _flatten_select_options($arr)
177
-    {
178
-        $flat_array = array();
179
-        if (EEH_Array::is_multi_dimensional_array($arr)) {
180
-            foreach ($arr as $sub_array) {
181
-                foreach ((array)$sub_array as $key => $value) {
182
-                    $flat_array[$key] = $value;
183
-                    $this->_set_label_size($value);
184
-                }
185
-            }
186
-        } else {
187
-            foreach ($arr as $key => $value) {
188
-                $flat_array[$key] = $value;
189
-                $this->_set_label_size($value);
190
-            }
191
-        }
192
-        return $flat_array;
193
-    }
194
-
195
-
196
-
197
-    /**
198
-     * @param EE_Question_Option[] $question_options_array
199
-     * @return array
200
-     */
201
-    protected function _process_question_options($question_options_array = array())
202
-    {
203
-        $flat_array = array();
204
-        foreach ($question_options_array as $question_option) {
205
-            if ($question_option instanceof EE_Question_Option) {
206
-                $desc = '';
207
-                if ($this->_use_desc_in_label) {
208
-                    $desc = $question_option->desc();
209
-                    $desc = ! empty($desc) ? '<span class="ee-question-option-desc">' . $desc . '</span>' : '';
210
-                }
211
-                $value = $question_option->value();
212
-                // add value even if it's empty
213
-                $flat_array[$value] = $value;
214
-                // if both value and desc are not empty, then separate with a dash
215
-                if ( ! empty($value) && ! empty($desc)) {
216
-                    $flat_array[$value] .= ' - ' . $desc;
217
-                } else {
218
-                    // otherwise, just add desc, since either or both of the vars is empty, and no dash is necessary
219
-                    $flat_array[$value] .= $desc;
220
-                }
221
-            } elseif (is_array($question_option)) {
222
-                $flat_array += $this->_flatten_select_options($question_option);
223
-            }
224
-        }
225
-        return $flat_array;
226
-    }
227
-
228
-
229
-
230
-    /**
231
-     *    set_label_sizes
232
-     *
233
-     * @return void
234
-     */
235
-    public function set_label_sizes()
236
-    {
237
-        // did the input settings specifically say to NOT set the label size dynamically ?
238
-        if ( ! $this->_enforce_label_size) {
239
-            foreach ($this->_options as $option) {
240
-                // calculate the strlen of the label
241
-                $this->_set_label_size($option);
242
-            }
243
-        }
244
-    }
245
-
246
-
247
-
248
-    /**
249
-     *    _set_label_size_class
250
-     *
251
-     * @param int|string $value
252
-     * @return void
253
-     */
254
-    private function _set_label_size($value = '')
255
-    {
256
-        // determine length of option value
257
-        $val_size = is_int($value) ? $value : strlen($value);
258
-        // use new value if bigger than existing
259
-        $this->_label_size = $val_size > $this->_label_size ? $val_size : $this->_label_size;
260
-    }
261
-
262
-
263
-
264
-    /**
265
-     *    get_label_size_class
266
-     *
267
-     * @return string
268
-     */
269
-    public function get_label_size_class()
270
-    {
271
-        $size = ' medium-lbl';
272
-        // use maximum option value length to determine label size
273
-        if ($this->_label_size < 3) {
274
-            $size = ' nano-lbl';
275
-        } else if ($this->_label_size < 6) {
276
-            $size = ' micro-lbl';
277
-        } else if ($this->_label_size < 12) {
278
-            $size = ' tiny-lbl';
279
-        } else if ($this->_label_size < 25) {
280
-            $size = ' small-lbl';
281
-        } else if ($this->_label_size < 50) {
282
-            $size = ' medium-lbl';
283
-        } else if ($this->_label_size >= 100) {
284
-            $size = ' big-lbl';
285
-        }
286
-        return $size;
287
-    }
288
-
289
-
290
-
291
-    /**
292
-     * Returns the pretty value for the normalized value
293
-     *
294
-     * @return string
295
-     */
296
-    public function pretty_value()
297
-    {
298
-        $options = $this->flat_options();
299
-        $unnormalized_value_choices = $this->get_normalization_strategy()->unnormalize($this->_normalized_value);
300
-        if ( ! $this->_multiple_selections) {
301
-            $unnormalized_value_choices = array($unnormalized_value_choices);
302
-        }
303
-        $pretty_strings = array();
304
-        foreach ((array)$unnormalized_value_choices as $unnormalized_value_choice) {
305
-            if (isset($options[$unnormalized_value_choice])) {
306
-                $pretty_strings[] = $options[$unnormalized_value_choice];
307
-            } else {
308
-                $pretty_strings[] = $this->normalized_value();
309
-            }
310
-        }
311
-        return implode(', ', $pretty_strings);
312
-    }
313
-
314
-
315
-
316
-    /**
317
-     * @return boolean
318
-     */
319
-    public function display_html_label_text()
320
-    {
321
-        return $this->_display_html_label_text;
322
-    }
323
-
324
-
325
-
326
-    /**
327
-     * @param boolean $display_html_label_text
328
-     */
329
-    public function set_display_html_label_text($display_html_label_text)
330
-    {
331
-        $this->_display_html_label_text = filter_var($display_html_label_text, FILTER_VALIDATE_BOOLEAN);
332
-    }
19
+	/**
20
+	 * array of available options to choose as an answer
21
+	 *
22
+	 * @var array
23
+	 */
24
+	protected $_options = array();
25
+
26
+	/**
27
+	 * whether to display the html_label_text above the checkbox/radio button options
28
+	 *
29
+	 * @var boolean
30
+	 */
31
+	protected $_display_html_label_text = true;
32
+
33
+	/**
34
+	 * whether to display an question option description as part of the input label
35
+	 *
36
+	 * @var boolean
37
+	 */
38
+	protected $_use_desc_in_label = true;
39
+
40
+	/**
41
+	 * strlen() result for the longest input value (what gets displayed in the label)
42
+	 * this is used to apply a css class to the input label
43
+	 *
44
+	 * @var int
45
+	 */
46
+	protected $_label_size = 0;
47
+
48
+	/**
49
+	 * whether to enforce the label size value passed in the constructor
50
+	 *
51
+	 * @var boolean
52
+	 */
53
+	protected $_enforce_label_size = false;
54
+
55
+	/**
56
+	 * whether to allow multiple selections (ie, the value of this input should be an array)
57
+	 * or not (ie, the value should be a simple int, string, etc)
58
+	 *
59
+	 * @var boolean
60
+	 */
61
+	protected $_multiple_selections = false;
62
+
63
+
64
+
65
+	/**
66
+	 * @param array     $answer_options
67
+	 * @param array     $input_settings {
68
+	 * @type int|string $label_size
69
+	 * @type boolean    $display_html_label_text
70
+	 *                                  }
71
+	 *                                  And all the options accepted by EE_Form_Input_Base
72
+	 */
73
+	public function __construct($answer_options = array(), $input_settings = array())
74
+	{
75
+		if (isset($input_settings['label_size'])) {
76
+			$this->_set_label_size($input_settings['label_size']);
77
+			if (isset($input_settings['enforce_label_size']) && $input_settings['enforce_label_size']) {
78
+				$this->_enforce_label_size = true;
79
+			}
80
+		}
81
+		if (isset($input_settings['display_html_label_text'])) {
82
+			$this->set_display_html_label_text($input_settings['display_html_label_text']);
83
+		}
84
+		$this->set_select_options($answer_options);
85
+		parent::__construct($input_settings);
86
+	}
87
+
88
+
89
+
90
+	/**
91
+	 * Sets the allowed options for this input. Also has the side-effect of
92
+	 * updating the normalization strategy to match the keys provided in the array
93
+	 *
94
+	 * @param array $answer_options
95
+	 * @return void  just has the side-effect of setting the options for this input
96
+	 */
97
+	public function set_select_options($answer_options = array())
98
+	{
99
+		$answer_options = is_array($answer_options) ? $answer_options : array($answer_options);
100
+		//get the first item in the select options and check it's type
101
+		$this->_options = reset($answer_options) instanceof EE_Question_Option
102
+			? $this->_process_question_options($answer_options)
103
+			: $answer_options;
104
+		//d( $this->_options );
105
+		$select_option_keys = array_keys($this->_options);
106
+		// attempt to determine data type for values in order to set normalization type
107
+		//purposefully only
108
+		if (
109
+			count($this->_options) === 2
110
+			&& (
111
+				(in_array(true, $select_option_keys, true) && in_array(false, $select_option_keys, true))
112
+				|| (in_array(1, $select_option_keys, true) && in_array(0, $select_option_keys, true))
113
+			)
114
+		) {
115
+			// values appear to be boolean, like TRUE, FALSE, 1, 0
116
+			$normalization = new EE_Boolean_Normalization();
117
+		} else {
118
+			//are ALL the options ints (even if we're using a multi-dimensional array)? If so use int validation
119
+			$all_ints = true;
120
+			array_walk_recursive(
121
+				$this->_options,
122
+				function($value,$key) use (&$all_ints){
123
+					//is this a top-level key? ignore it
124
+					if(! is_array($value)
125
+						&& ! is_int($key)
126
+					   && $key !== ''
127
+					   && $key !== null){
128
+						$all_ints = false;
129
+					}
130
+				}
131
+			);
132
+			if ($all_ints) {
133
+				$normalization = new EE_Int_Normalization();
134
+			} else {
135
+				$normalization = new EE_Text_Normalization();
136
+			}
137
+		}
138
+		// does input type have multiple options ?
139
+		if ($this->_multiple_selections) {
140
+			$this->_set_normalization_strategy(new EE_Many_Valued_Normalization($normalization));
141
+		} else {
142
+			$this->_set_normalization_strategy($normalization);
143
+		}
144
+	}
145
+
146
+
147
+
148
+	/**
149
+	 * @return array
150
+	 */
151
+	public function options()
152
+	{
153
+		return $this->_options;
154
+	}
155
+
156
+
157
+
158
+	/**
159
+	 * Returns an array which is guaranteed to not be multidimensional
160
+	 *
161
+	 * @return array
162
+	 */
163
+	public function flat_options()
164
+	{
165
+		return $this->_flatten_select_options($this->options());
166
+	}
167
+
168
+
169
+
170
+	/**
171
+	 * Makes sure $arr is a flat array, not a multidimensional one
172
+	 *
173
+	 * @param array $arr
174
+	 * @return array
175
+	 */
176
+	protected function _flatten_select_options($arr)
177
+	{
178
+		$flat_array = array();
179
+		if (EEH_Array::is_multi_dimensional_array($arr)) {
180
+			foreach ($arr as $sub_array) {
181
+				foreach ((array)$sub_array as $key => $value) {
182
+					$flat_array[$key] = $value;
183
+					$this->_set_label_size($value);
184
+				}
185
+			}
186
+		} else {
187
+			foreach ($arr as $key => $value) {
188
+				$flat_array[$key] = $value;
189
+				$this->_set_label_size($value);
190
+			}
191
+		}
192
+		return $flat_array;
193
+	}
194
+
195
+
196
+
197
+	/**
198
+	 * @param EE_Question_Option[] $question_options_array
199
+	 * @return array
200
+	 */
201
+	protected function _process_question_options($question_options_array = array())
202
+	{
203
+		$flat_array = array();
204
+		foreach ($question_options_array as $question_option) {
205
+			if ($question_option instanceof EE_Question_Option) {
206
+				$desc = '';
207
+				if ($this->_use_desc_in_label) {
208
+					$desc = $question_option->desc();
209
+					$desc = ! empty($desc) ? '<span class="ee-question-option-desc">' . $desc . '</span>' : '';
210
+				}
211
+				$value = $question_option->value();
212
+				// add value even if it's empty
213
+				$flat_array[$value] = $value;
214
+				// if both value and desc are not empty, then separate with a dash
215
+				if ( ! empty($value) && ! empty($desc)) {
216
+					$flat_array[$value] .= ' - ' . $desc;
217
+				} else {
218
+					// otherwise, just add desc, since either or both of the vars is empty, and no dash is necessary
219
+					$flat_array[$value] .= $desc;
220
+				}
221
+			} elseif (is_array($question_option)) {
222
+				$flat_array += $this->_flatten_select_options($question_option);
223
+			}
224
+		}
225
+		return $flat_array;
226
+	}
227
+
228
+
229
+
230
+	/**
231
+	 *    set_label_sizes
232
+	 *
233
+	 * @return void
234
+	 */
235
+	public function set_label_sizes()
236
+	{
237
+		// did the input settings specifically say to NOT set the label size dynamically ?
238
+		if ( ! $this->_enforce_label_size) {
239
+			foreach ($this->_options as $option) {
240
+				// calculate the strlen of the label
241
+				$this->_set_label_size($option);
242
+			}
243
+		}
244
+	}
245
+
246
+
247
+
248
+	/**
249
+	 *    _set_label_size_class
250
+	 *
251
+	 * @param int|string $value
252
+	 * @return void
253
+	 */
254
+	private function _set_label_size($value = '')
255
+	{
256
+		// determine length of option value
257
+		$val_size = is_int($value) ? $value : strlen($value);
258
+		// use new value if bigger than existing
259
+		$this->_label_size = $val_size > $this->_label_size ? $val_size : $this->_label_size;
260
+	}
261
+
262
+
263
+
264
+	/**
265
+	 *    get_label_size_class
266
+	 *
267
+	 * @return string
268
+	 */
269
+	public function get_label_size_class()
270
+	{
271
+		$size = ' medium-lbl';
272
+		// use maximum option value length to determine label size
273
+		if ($this->_label_size < 3) {
274
+			$size = ' nano-lbl';
275
+		} else if ($this->_label_size < 6) {
276
+			$size = ' micro-lbl';
277
+		} else if ($this->_label_size < 12) {
278
+			$size = ' tiny-lbl';
279
+		} else if ($this->_label_size < 25) {
280
+			$size = ' small-lbl';
281
+		} else if ($this->_label_size < 50) {
282
+			$size = ' medium-lbl';
283
+		} else if ($this->_label_size >= 100) {
284
+			$size = ' big-lbl';
285
+		}
286
+		return $size;
287
+	}
288
+
289
+
290
+
291
+	/**
292
+	 * Returns the pretty value for the normalized value
293
+	 *
294
+	 * @return string
295
+	 */
296
+	public function pretty_value()
297
+	{
298
+		$options = $this->flat_options();
299
+		$unnormalized_value_choices = $this->get_normalization_strategy()->unnormalize($this->_normalized_value);
300
+		if ( ! $this->_multiple_selections) {
301
+			$unnormalized_value_choices = array($unnormalized_value_choices);
302
+		}
303
+		$pretty_strings = array();
304
+		foreach ((array)$unnormalized_value_choices as $unnormalized_value_choice) {
305
+			if (isset($options[$unnormalized_value_choice])) {
306
+				$pretty_strings[] = $options[$unnormalized_value_choice];
307
+			} else {
308
+				$pretty_strings[] = $this->normalized_value();
309
+			}
310
+		}
311
+		return implode(', ', $pretty_strings);
312
+	}
313
+
314
+
315
+
316
+	/**
317
+	 * @return boolean
318
+	 */
319
+	public function display_html_label_text()
320
+	{
321
+		return $this->_display_html_label_text;
322
+	}
323
+
324
+
325
+
326
+	/**
327
+	 * @param boolean $display_html_label_text
328
+	 */
329
+	public function set_display_html_label_text($display_html_label_text)
330
+	{
331
+		$this->_display_html_label_text = filter_var($display_html_label_text, FILTER_VALIDATE_BOOLEAN);
332
+	}
333 333
 
334 334
 
335 335
 
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -119,12 +119,12 @@  discard block
 block discarded – undo
119 119
             $all_ints = true;
120 120
             array_walk_recursive(
121 121
                 $this->_options,
122
-                function($value,$key) use (&$all_ints){
122
+                function($value, $key) use (&$all_ints){
123 123
                     //is this a top-level key? ignore it
124
-                    if(! is_array($value)
124
+                    if ( ! is_array($value)
125 125
                         && ! is_int($key)
126 126
                        && $key !== ''
127
-                       && $key !== null){
127
+                       && $key !== null) {
128 128
                         $all_ints = false;
129 129
                     }
130 130
                 }
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
         $flat_array = array();
179 179
         if (EEH_Array::is_multi_dimensional_array($arr)) {
180 180
             foreach ($arr as $sub_array) {
181
-                foreach ((array)$sub_array as $key => $value) {
181
+                foreach ((array) $sub_array as $key => $value) {
182 182
                     $flat_array[$key] = $value;
183 183
                     $this->_set_label_size($value);
184 184
                 }
@@ -206,14 +206,14 @@  discard block
 block discarded – undo
206 206
                 $desc = '';
207 207
                 if ($this->_use_desc_in_label) {
208 208
                     $desc = $question_option->desc();
209
-                    $desc = ! empty($desc) ? '<span class="ee-question-option-desc">' . $desc . '</span>' : '';
209
+                    $desc = ! empty($desc) ? '<span class="ee-question-option-desc">'.$desc.'</span>' : '';
210 210
                 }
211 211
                 $value = $question_option->value();
212 212
                 // add value even if it's empty
213 213
                 $flat_array[$value] = $value;
214 214
                 // if both value and desc are not empty, then separate with a dash
215 215
                 if ( ! empty($value) && ! empty($desc)) {
216
-                    $flat_array[$value] .= ' - ' . $desc;
216
+                    $flat_array[$value] .= ' - '.$desc;
217 217
                 } else {
218 218
                     // otherwise, just add desc, since either or both of the vars is empty, and no dash is necessary
219 219
                     $flat_array[$value] .= $desc;
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
             $unnormalized_value_choices = array($unnormalized_value_choices);
302 302
         }
303 303
         $pretty_strings = array();
304
-        foreach ((array)$unnormalized_value_choices as $unnormalized_value_choice) {
304
+        foreach ((array) $unnormalized_value_choices as $unnormalized_value_choice) {
305 305
             if (isset($options[$unnormalized_value_choice])) {
306 306
                 $pretty_strings[] = $options[$unnormalized_value_choice];
307 307
             } else {
Please login to merge, or discard this patch.