Completed
Branch BUG-7527-answer-question-group (0815fc)
by
unknown
25:10 queued 12:57
created
core/db_models/fields/EE_DB_Only_Field_Base.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
  * special default values for them, or some other column-specific functionality. So we can add them as fields,
8 8
  * but db-only ones
9 9
  */
10
-abstract class EE_DB_Only_Field_Base extends EE_Model_Field_Base{
10
+abstract class EE_DB_Only_Field_Base extends EE_Model_Field_Base {
11 11
 	/**
12 12
 	 * All these children classes are for the db-only (meaning, we should select them
13 13
 	 * on get_all queries, update, delete, and will still want to set their default value
Please login to merge, or discard this patch.
core/db_models/fields/EE_DB_Only_Float_Field.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-require_once( EE_MODELS . 'fields/EE_DB_Only_Field_Base.php');
3
-class EE_DB_Only_Float_Field extends EE_DB_Only_Field_Base{
4
-	function get_wpdb_data_type(){
2
+require_once(EE_MODELS.'fields/EE_DB_Only_Field_Base.php');
3
+class EE_DB_Only_Float_Field extends EE_DB_Only_Field_Base {
4
+	function get_wpdb_data_type() {
5 5
 		return '%f';
6 6
 	}
7 7
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_DB_Only_Int_Field.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-require_once( EE_MODELS . 'fields/EE_DB_Only_Field_Base.php');
4
-class EE_DB_Only_Int_Field extends EE_DB_Only_Field_Base{
5
-	function get_wpdb_data_type(){
3
+require_once(EE_MODELS.'fields/EE_DB_Only_Field_Base.php');
4
+class EE_DB_Only_Int_Field extends EE_DB_Only_Field_Base {
5
+	function get_wpdb_data_type() {
6 6
 		return '%d';
7 7
 	}
8 8
 }
9 9
\ No newline at end of file
Please login to merge, or discard this patch.
core/db_models/fields/EE_DB_Only_Text_Field.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-require_once( EE_MODELS . 'fields/EE_DB_Only_Field_Base.php');
3
-class EE_DB_Only_Text_Field extends EE_DB_Only_Field_Base{
4
-	function get_wpdb_data_type(){
2
+require_once(EE_MODELS.'fields/EE_DB_Only_Field_Base.php');
3
+class EE_DB_Only_Text_Field extends EE_DB_Only_Field_Base {
4
+	function get_wpdb_data_type() {
5 5
 		return '%s';
6 6
 	}
7 7
 }
8 8
\ No newline at end of file
Please login to merge, or discard this patch.
core/db_models/fields/EE_Datetime_Field.php 2 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -459,7 +459,7 @@
 block discarded – undo
459 459
 				//must be explicit because schema could equal true.
460 460
 				if( $schema === 'no_html' ){
461 461
 					$timezone_string = ' (' . $DateTime->format( 'T' )  . ')';
462
-				}else{
462
+				} else{
463 463
 					$timezone_string = ' <span class="ee_dtt_timezone_string">(' . $DateTime->format( 'T' ) . ')</span>';
464 464
 				}
465 465
 			} else {
Please login to merge, or discard this patch.
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * EE_Datetime_Field
@@ -111,16 +111,16 @@  discard block
 block discarded – undo
111 111
 	 * @param string 	$pretty_date_format
112 112
 	 * @param string 	$pretty_time_format
113 113
 	 */
114
-	public function __construct( $table_column, $nice_name, $nullable, $default_value, $timezone_string = '', $date_format = '', $time_format = '', $pretty_date_format = '', $pretty_time_format = '' ){
114
+	public function __construct($table_column, $nice_name, $nullable, $default_value, $timezone_string = '', $date_format = '', $time_format = '', $pretty_date_format = '', $pretty_time_format = '') {
115 115
 
116
-		$this->_date_format = ! empty( $date_format ) ? $date_format : get_option('date_format');
117
-		$this->_time_format = ! empty( $time_format ) ? $time_format : get_option('time_format');
118
-		$this->_pretty_date_format = ! empty( $pretty_date_format ) ? $pretty_date_format : get_option('date_format');
119
-		$this->_pretty_time_format = ! empty( $pretty_time_format ) ? $pretty_time_format : get_option('time_format');
116
+		$this->_date_format = ! empty($date_format) ? $date_format : get_option('date_format');
117
+		$this->_time_format = ! empty($time_format) ? $time_format : get_option('time_format');
118
+		$this->_pretty_date_format = ! empty($pretty_date_format) ? $pretty_date_format : get_option('date_format');
119
+		$this->_pretty_time_format = ! empty($pretty_time_format) ? $pretty_time_format : get_option('time_format');
120 120
 
121
-		parent::__construct( $table_column, $nice_name, $nullable, $default_value );
121
+		parent::__construct($table_column, $nice_name, $nullable, $default_value);
122 122
 		EE_Registry::instance()->load_helper('DTT_Helper');
123
-		$this->set_timezone( $timezone_string );
123
+		$this->set_timezone($timezone_string);
124 124
 
125 125
 	}
126 126
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 	 * @return DateTimeZone
140 140
 	 */
141 141
 	public function get_UTC_DateTimeZone() {
142
-		return $this->_UTC_DateTimeZone instanceof DateTimeZone ? $this->_UTC_DateTimeZone : $this->_create_timezone_object_from_timezone_string( 'UTC' );
142
+		return $this->_UTC_DateTimeZone instanceof DateTimeZone ? $this->_UTC_DateTimeZone : $this->_create_timezone_object_from_timezone_string('UTC');
143 143
 	}
144 144
 
145 145
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	 * @return DateTimeZone
149 149
 	 */
150 150
 	public function get_blog_DateTimeZone() {
151
-		return $this->_blog_DateTimeZone instanceof DateTimeZone ? $this->_blog_DateTimeZone : $this->_create_timezone_object_from_timezone_string( '' );
151
+		return $this->_blog_DateTimeZone instanceof DateTimeZone ? $this->_blog_DateTimeZone : $this->_create_timezone_object_from_timezone_string('');
152 152
 	}
153 153
 
154 154
 
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 	 * @param  string|int $value_inputted_for_field_on_model_object could be a string formatted date time or int unix timestamp
159 159
 	 * @return DateTime
160 160
 	 */
161
-	public function prepare_for_set( $value_inputted_for_field_on_model_object ) {
162
-		return $this->_get_date_object( $value_inputted_for_field_on_model_object );
161
+	public function prepare_for_set($value_inputted_for_field_on_model_object) {
162
+		return $this->_get_date_object($value_inputted_for_field_on_model_object);
163 163
 	}
164 164
 
165 165
 
@@ -175,9 +175,9 @@  discard block
 block discarded – undo
175 175
 	 * @param bool $pretty If we're returning the pretty formats or standard format string.
176 176
 	 * @return string    The final assembled format string.
177 177
 	 */
178
-	protected function _get_date_time_output( $pretty = FALSE ) {
178
+	protected function _get_date_time_output($pretty = FALSE) {
179 179
 
180
-		switch ( $this->_date_time_output ) {
180
+		switch ($this->_date_time_output) {
181 181
 			case 'time' :
182 182
 				return $pretty ? $this->_pretty_time_format : $this->_time_format;
183 183
 				break;
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 				break;
188 188
 
189 189
 			default :
190
-				return $pretty ? $this->_pretty_date_format . ' ' . $this->_pretty_time_format : $this->_date_format . ' ' . $this->_time_format;
190
+				return $pretty ? $this->_pretty_date_format.' '.$this->_pretty_time_format : $this->_date_format.' '.$this->_time_format;
191 191
 		}
192 192
 	}
193 193
 
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 	 * @param string $what acceptable values are 'time' or 'date'.  Any other value will be set but will always result in both 'date' and 'time' being returned.
202 202
 	 * @return void
203 203
 	 */
204
-	public function set_date_time_output( $what = NULL ) {
204
+	public function set_date_time_output($what = NULL) {
205 205
 		$this->_date_time_output = $what;
206 206
 	}
207 207
 
@@ -217,15 +217,15 @@  discard block
 block discarded – undo
217 217
 	 * @param string $timezone_string A valid timezone string as described by @link http://www.php.net/manual/en/timezones.php
218 218
 	 * @return void
219 219
 	 */
220
-	public function set_timezone( $timezone_string ) {
221
-		if( empty( $timezone_string ) && $this->_timezone_string != NULL ){
220
+	public function set_timezone($timezone_string) {
221
+		if (empty($timezone_string) && $this->_timezone_string != NULL) {
222 222
 			// leave the timezone AS-IS if we already have one and
223 223
 			// the function arg didn't provide one
224 224
 			return;
225 225
 		}
226
-		$timezone_string = EEH_DTT_Helper::get_valid_timezone_string( $timezone_string );
227
-		$this->_timezone_string = ! empty( $timezone_string ) ? $timezone_string : 'UTC';
228
-		$this->_DateTimeZone = $this->_create_timezone_object_from_timezone_string( $this->_timezone_string );
226
+		$timezone_string = EEH_DTT_Helper::get_valid_timezone_string($timezone_string);
227
+		$this->_timezone_string = ! empty($timezone_string) ? $timezone_string : 'UTC';
228
+		$this->_DateTimeZone = $this->_create_timezone_object_from_timezone_string($this->_timezone_string);
229 229
 	}
230 230
 
231 231
 
@@ -237,8 +237,8 @@  discard block
 block discarded – undo
237 237
 	 * @param string $timezone_string
238 238
 	 * @return \DateTimeZone
239 239
 	 */
240
-	protected function _create_timezone_object_from_timezone_string( $timezone_string = '' ) {
241
-		return new DateTimeZone( EEH_DTT_Helper::get_valid_timezone_string( $timezone_string ) );
240
+	protected function _create_timezone_object_from_timezone_string($timezone_string = '') {
241
+		return new DateTimeZone(EEH_DTT_Helper::get_valid_timezone_string($timezone_string));
242 242
 	}
243 243
 
244 244
 
@@ -263,8 +263,8 @@  discard block
 block discarded – undo
263 263
 	 * @param bool   $pretty Whether to set pretty format or not.
264 264
 	 * @return void
265 265
 	 */
266
-	public function set_date_format( $format, $pretty = false ) {
267
-		if ( $pretty ) {
266
+	public function set_date_format($format, $pretty = false) {
267
+		if ($pretty) {
268 268
 			$this->_pretty_date_format = $format;
269 269
 		} else {
270 270
 			$this->_date_format = $format;
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	 * @param bool   $pretty Whether to get pretty format or not.
280 280
 	 * @return string
281 281
 	 */
282
-	public function get_date_format( $pretty = false ) {
282
+	public function get_date_format($pretty = false) {
283 283
 		return $pretty ? $this->_pretty_date_format : $this->_date_format;
284 284
 	}
285 285
 
@@ -294,8 +294,8 @@  discard block
 block discarded – undo
294 294
 	 * @param bool   $pretty Whether to set pretty format or not.
295 295
 	 * @return void
296 296
 	 */
297
-	public function set_time_format( $format, $pretty = false ) {
298
-		if ( $pretty ) {
297
+	public function set_time_format($format, $pretty = false) {
298
+		if ($pretty) {
299 299
 			$this->_pretty_time_format = $format;
300 300
 		} else {
301 301
 			$this->_time_format = $format;
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 	 * @param bool   $pretty Whether to get pretty format or not.
311 311
 	 * @return string
312 312
 	 */
313
-	public function get_time_format( $pretty = false ) {
313
+	public function get_time_format($pretty = false) {
314 314
 		return $pretty ? $this->_pretty_time_format : $this->_time_format;
315 315
 	}
316 316
 
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 	 * @param string $format a new pretty date format (corresponding to formats accepted by PHP date() function)
326 326
 	 * @return void
327 327
 	 */
328
-	public function set_pretty_date_format( $format ) {
328
+	public function set_pretty_date_format($format) {
329 329
 		$this->_pretty_date_format = $format;
330 330
 	}
331 331
 
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 	 * @param string $format a new pretty time format (corresponding to formats accepted by PHP date() function)
343 343
 	 * @return void
344 344
 	 */
345
-	public function set_pretty_time_format( $format ) {
345
+	public function set_pretty_time_format($format) {
346 346
 		$this->_pretty_time_format = $format;
347 347
 	}
348 348
 
@@ -354,9 +354,9 @@  discard block
 block discarded – undo
354 354
 	 * @param DateTime    $current current DateTime object for the datetime field
355 355
 	 * @return DateTime
356 356
 	 */
357
-	public function prepare_for_set_with_new_time( $time_to_set_string, DateTime $current ){
357
+	public function prepare_for_set_with_new_time($time_to_set_string, DateTime $current) {
358 358
 		//if $time_to_set_string is datetime object, then let's use it to set the parse array.  Otherwise parse the string.
359
-		if ( $time_to_set_string instanceof DateTime ) {
359
+		if ($time_to_set_string instanceof DateTime) {
360 360
 			$parsed = array(
361 361
 				'hour' => $time_to_set_string->format('H'),
362 362
 				'minute' => $time_to_set_string->format('i'),
@@ -364,12 +364,12 @@  discard block
 block discarded – undo
364 364
 				);
365 365
 		} else {
366 366
 			//parse incoming string
367
-			$parsed = date_parse_from_format( $this->_time_format, $time_to_set_string );
367
+			$parsed = date_parse_from_format($this->_time_format, $time_to_set_string);
368 368
 		}
369 369
 
370 370
 		//make sure $current is in the correct timezone.
371
-		$current->setTimezone( $this->_DateTimeZone );
372
-		return $current->setTime( $parsed['hour'], $parsed['minute'], $parsed['second'] );
371
+		$current->setTimezone($this->_DateTimeZone);
372
+		return $current->setTime($parsed['hour'], $parsed['minute'], $parsed['second']);
373 373
 	}
374 374
 
375 375
 
@@ -380,9 +380,9 @@  discard block
 block discarded – undo
380 380
 	 * @param DateTime    $current current DateTime object for the datetime field
381 381
 	 * @return DateTime
382 382
 	 */
383
-	public function prepare_for_set_with_new_date( $date_to_set_string, DateTime $current ){
383
+	public function prepare_for_set_with_new_date($date_to_set_string, DateTime $current) {
384 384
 		//if $time_to_set_string is datetime object, then let's use it to set the parse array.  Otherwise parse the string.
385
-		if ( $date_to_set_string instanceof DateTime ) {
385
+		if ($date_to_set_string instanceof DateTime) {
386 386
 			$parsed = array(
387 387
 				'year' => $date_to_set_string->format('Y'),
388 388
 				'month' => $date_to_set_string->format('m'),
@@ -390,12 +390,12 @@  discard block
 block discarded – undo
390 390
 				);
391 391
 		} else {
392 392
 			//parse incoming string
393
-			$parsed = date_parse_from_format( $this->_date_format, $date_to_set_string );
393
+			$parsed = date_parse_from_format($this->_date_format, $date_to_set_string);
394 394
 		}
395 395
 
396 396
 		//make sure $current is in the correct timezone
397
-		$current->setTimezone( $this->_DateTimeZone );
398
-		return $current->setDate( $parsed['year'], $parsed['month'], $parsed['day'] );
397
+		$current->setTimezone($this->_DateTimeZone);
398
+		return $current->setDate($parsed['year'], $parsed['month'], $parsed['day']);
399 399
 	}
400 400
 
401 401
 
@@ -407,8 +407,8 @@  discard block
 block discarded – undo
407 407
 	 * @param  DateTime $DateTime
408 408
 	 * @return string formatted date time for given timezone
409 409
 	 */
410
-	public function prepare_for_get( $DateTime ) {
411
-		return $this->_prepare_for_display( $DateTime  );
410
+	public function prepare_for_get($DateTime) {
411
+		return $this->_prepare_for_display($DateTime);
412 412
 	}
413 413
 
414 414
 
@@ -423,8 +423,8 @@  discard block
 block discarded – undo
423 423
 	 * @param null     $schema
424 424
 	 * @return string
425 425
 	 */
426
-	public function prepare_for_pretty_echoing( $DateTime, $schema = null ) {
427
-		return $this->_prepare_for_display( $DateTime, $schema ? $schema : true );
426
+	public function prepare_for_pretty_echoing($DateTime, $schema = null) {
427
+		return $this->_prepare_for_display($DateTime, $schema ? $schema : true);
428 428
 	}
429 429
 
430 430
 
@@ -438,36 +438,36 @@  discard block
 block discarded – undo
438 438
 	 * @return string
439 439
 	 * @throws \EE_Error
440 440
 	 */
441
-	protected function _prepare_for_display( $DateTime, $schema = false ) {
442
-		if ( ! $DateTime instanceof DateTime  ) {
443
-			if ( $this->_nullable ) {
441
+	protected function _prepare_for_display($DateTime, $schema = false) {
442
+		if ( ! $DateTime instanceof DateTime) {
443
+			if ($this->_nullable) {
444 444
 				return '';
445 445
 			} else {
446
-				if ( WP_DEBUG ) {
447
-					throw new EE_Error( sprintf( __('EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.', 'event_espresso' ), $this->_nicename ) );
446
+				if (WP_DEBUG) {
447
+					throw new EE_Error(sprintf(__('EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.', 'event_espresso'), $this->_nicename));
448 448
 				} else {
449
-					$DateTime = new DateTime( "now" );
450
-					EE_Error::add_error( sprintf( __('EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.  When WP_DEBUG is false, the value is set to "now" instead of throwing an exception.', 'event_espresso' ), $this->_nicename ) );
449
+					$DateTime = new DateTime("now");
450
+					EE_Error::add_error(sprintf(__('EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.  When WP_DEBUG is false, the value is set to "now" instead of throwing an exception.', 'event_espresso'), $this->_nicename));
451 451
 				}
452 452
 			}
453 453
 		}
454
-		$format_string = $this->_get_date_time_output( $schema );
454
+		$format_string = $this->_get_date_time_output($schema);
455 455
 		//make sure datetime_value is in the correct timezone (in case that's been updated).
456
-		$DateTime->setTimezone( $this->_DateTimeZone );
457
-		if ( $schema ) {
458
-			if( $this->_display_timezone() ) {
456
+		$DateTime->setTimezone($this->_DateTimeZone);
457
+		if ($schema) {
458
+			if ($this->_display_timezone()) {
459 459
 				//must be explicit because schema could equal true.
460
-				if( $schema === 'no_html' ){
461
-					$timezone_string = ' (' . $DateTime->format( 'T' )  . ')';
462
-				}else{
463
-					$timezone_string = ' <span class="ee_dtt_timezone_string">(' . $DateTime->format( 'T' ) . ')</span>';
460
+				if ($schema === 'no_html') {
461
+					$timezone_string = ' ('.$DateTime->format('T').')';
462
+				} else {
463
+					$timezone_string = ' <span class="ee_dtt_timezone_string">('.$DateTime->format('T').')</span>';
464 464
 				}
465 465
 			} else {
466 466
 				$timezone_string = '';
467 467
 			}
468
-			return $DateTime->format( $format_string ) . $timezone_string;
468
+			return $DateTime->format($format_string).$timezone_string;
469 469
 		} else {
470
-			return $DateTime->format( $format_string );
470
+			return $DateTime->format($format_string);
471 471
 		}
472 472
 	}
473 473
 
@@ -481,18 +481,18 @@  discard block
 block discarded – undo
481 481
 	 * @return string mysql timestamp in UTC
482 482
 	 * @throws \EE_Error
483 483
 	 */
484
-	public function prepare_for_use_in_db( $datetime_value ) {
484
+	public function prepare_for_use_in_db($datetime_value) {
485 485
 		//we allow an empty value or DateTime object, but nothing else.
486
-		if ( ! empty( $datetime_value ) && ! $datetime_value instanceof DateTime ) {
487
-			throw new EE_Error( __('The incoming value being prepared for setting in the database must either be empty or a php DateTime object', 'event_espresso' ) );
486
+		if ( ! empty($datetime_value) && ! $datetime_value instanceof DateTime) {
487
+			throw new EE_Error(__('The incoming value being prepared for setting in the database must either be empty or a php DateTime object', 'event_espresso'));
488 488
 		}
489 489
 
490
-		if ( $datetime_value instanceof DateTime ) {
491
-			return $datetime_value->setTimezone( $this->get_UTC_DateTimeZone() )->format( EE_Datetime_Field::mysql_timestamp_format );
490
+		if ($datetime_value instanceof DateTime) {
491
+			return $datetime_value->setTimezone($this->get_UTC_DateTimeZone())->format(EE_Datetime_Field::mysql_timestamp_format);
492 492
 		}
493 493
 
494 494
 		// if $datetime_value is empty, and ! $this->_nullable, use current_time() but set the GMT flag to true
495
-		return ! $this->_nullable && empty( $datetime_value ) ? current_time( 'mysql', true ) : null;
495
+		return ! $this->_nullable && empty($datetime_value) ? current_time('mysql', true) : null;
496 496
 	}
497 497
 
498 498
 
@@ -505,20 +505,20 @@  discard block
 block discarded – undo
505 505
 	 * @param string $datetime_string mysql timestamp in UTC
506 506
 	 * @return  mixed null | DateTime
507 507
 	 */
508
-	public function prepare_for_set_from_db( $datetime_string ) {
508
+	public function prepare_for_set_from_db($datetime_string) {
509 509
 		//if $datetime_value is empty, and ! $this->_nullable, just use time()
510
-		if ( empty( $datetime_string) && $this->_nullable ) {
510
+		if (empty($datetime_string) && $this->_nullable) {
511 511
 			return null;
512 512
 		}
513 513
 		// datetime strings from the db should ALWAYS be in UTC+0, so use UTC_DateTimeZone when creating
514
-		$DateTime = empty( $datetime_string ) ? new DateTime( 'now', $this->get_UTC_DateTimeZone() ) : DateTime::createFromFormat( EE_Datetime_Field::mysql_timestamp_format, $datetime_string, $this->get_UTC_DateTimeZone() );
514
+		$DateTime = empty($datetime_string) ? new DateTime('now', $this->get_UTC_DateTimeZone()) : DateTime::createFromFormat(EE_Datetime_Field::mysql_timestamp_format, $datetime_string, $this->get_UTC_DateTimeZone());
515 515
 
516
-		if ( ! $DateTime instanceof DateTime ) {
516
+		if ( ! $DateTime instanceof DateTime) {
517 517
 			//if still no datetime object, then let's just use now
518
-			$DateTime = new DateTime( 'now', $this->get_UTC_DateTimeZone() );
518
+			$DateTime = new DateTime('now', $this->get_UTC_DateTimeZone());
519 519
 		}
520 520
 		// THEN apply the field's set DateTimeZone
521
-		$DateTime->setTimezone( $this->_DateTimeZone );
521
+		$DateTime->setTimezone($this->_DateTimeZone);
522 522
 		return $DateTime;
523 523
 	}
524 524
 
@@ -535,15 +535,15 @@  discard block
 block discarded – undo
535 535
 	protected function _display_timezone() {
536 536
 
537 537
 		// first let's do a comparison of timezone strings.  If they match then we can get out without any further calculations
538
-		$blog_string = get_option( 'timezone_string' );
539
-		if ( $blog_string == $this->_timezone_string ) {
538
+		$blog_string = get_option('timezone_string');
539
+		if ($blog_string == $this->_timezone_string) {
540 540
 			return FALSE;
541 541
 		}
542 542
 		// now we need to calc the offset for the timezone string so we can compare with the blog offset.
543
-		$this_offset = $this->get_timezone_offset( $this->_DateTimeZone );
544
-		$blog_offset = $this->get_timezone_offset( $this->get_blog_DateTimeZone() );
543
+		$this_offset = $this->get_timezone_offset($this->_DateTimeZone);
544
+		$blog_offset = $this->get_timezone_offset($this->get_blog_DateTimeZone());
545 545
 		// now compare
546
-		if ( $blog_offset === $this_offset ) {
546
+		if ($blog_offset === $this_offset) {
547 547
 			return FALSE;
548 548
 		}
549 549
 		return TRUE;
@@ -561,24 +561,24 @@  discard block
 block discarded – undo
561 561
 	 *
562 562
 	 * @return DateTime
563 563
 	 */
564
-	protected function _get_date_object( $date_string ) {
564
+	protected function _get_date_object($date_string) {
565 565
 		//first if this is an empty date_string and nullable is allowed, just return null.
566
-		if ( $this->_nullable && empty( $date_string ) ) {
566
+		if ($this->_nullable && empty($date_string)) {
567 567
 			return null;
568 568
 		}
569 569
 
570 570
 		// if incoming date
571
-		if ( $date_string instanceof DateTime ) {
572
-			$date_string->setTimezone( $this->_DateTimeZone );
571
+		if ($date_string instanceof DateTime) {
572
+			$date_string->setTimezone($this->_DateTimeZone);
573 573
 			return $date_string;
574 574
 		}
575 575
 		// if empty date_string and made it here.
576 576
 		// Return a datetime object for now in the given timezone.
577
-		if ( empty( $date_string ) ) {
578
-			return new DateTime( "now", $this->_DateTimeZone );
577
+		if (empty($date_string)) {
578
+			return new DateTime("now", $this->_DateTimeZone);
579 579
 		}
580 580
 		// if $date_string is matches something that looks like a Unix timestamp let's just use it.
581
-		if ( preg_match( EE_Datetime_Field::unix_timestamp_regex, $date_string ) ) {
581
+		if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $date_string)) {
582 582
 			try {
583 583
 				/**
584 584
 				 * This is operating under the assumption that the incoming Unix timestamp is
@@ -586,29 +586,29 @@  discard block
 block discarded – undo
586 586
 				 * current_time('timestamp');
587 587
 				 *
588 588
 				 */
589
-				$DateTime = new DateTime( "now", $this->_DateTimeZone );
590
-				return $DateTime->setTimestamp( $date_string );
591
-			 } catch ( Exception $e )  {
589
+				$DateTime = new DateTime("now", $this->_DateTimeZone);
590
+				return $DateTime->setTimestamp($date_string);
591
+			 } catch (Exception $e) {
592 592
 			 	// should be rare, but if things got fooled then let's just continue
593 593
 			 }
594 594
 		}
595 595
 		//not a unix timestamp.  So we will use the set format on this object and set timezone to
596 596
 		//create the DateTime object.
597
-		$format = $this->_date_format . ' ' . $this->_time_format;
597
+		$format = $this->_date_format.' '.$this->_time_format;
598 598
 		try {
599
-			$DateTime = DateTime::createFromFormat( $format, $date_string, $this->_DateTimeZone );
600
-			if ( ! $DateTime instanceof DateTime ) {
599
+			$DateTime = DateTime::createFromFormat($format, $date_string, $this->_DateTimeZone);
600
+			if ( ! $DateTime instanceof DateTime) {
601 601
 				throw new EE_Error(
602 602
 					sprintf(
603
-						__( '"%1$s" does not represent a valid Date Time in the format "%2$s".', 'event_espresso' ),
603
+						__('"%1$s" does not represent a valid Date Time in the format "%2$s".', 'event_espresso'),
604 604
 						$date_string,
605 605
 						$format
606 606
 					)
607 607
 				);
608 608
 			}
609
-		} catch ( Exception $e ) {
609
+		} catch (Exception $e) {
610 610
 			// if we made it here then likely then something went really wrong.  Instead of throwing an exception, let's just return a DateTime object for now, in the set timezone.
611
-			$DateTime = new DateTime( "now", $this->_DateTimeZone );
611
+			$DateTime = new DateTime("now", $this->_DateTimeZone);
612 612
 		}
613 613
 		return $DateTime;
614 614
 	}
@@ -622,9 +622,9 @@  discard block
 block discarded – undo
622 622
 	 * @param null          $time
623 623
 	 * @return mixed
624 624
 	 */
625
-	public function get_timezone_offset( DateTimeZone $DateTimeZone, $time = null ) {
626
-		$time = preg_match( EE_Datetime_Field::unix_timestamp_regex, $time ) ? $time : time();
627
-		$transitions = $DateTimeZone->getTransitions( $time );
625
+	public function get_timezone_offset(DateTimeZone $DateTimeZone, $time = null) {
626
+		$time = preg_match(EE_Datetime_Field::unix_timestamp_regex, $time) ? $time : time();
627
+		$transitions = $DateTimeZone->getTransitions($time);
628 628
 		return $transitions[0]['offset'];
629 629
 	}
630 630
 
@@ -636,10 +636,10 @@  discard block
 block discarded – undo
636 636
 	 * @param  string $timezone_string
637 637
 	 * @return string           abbreviation
638 638
 	 */
639
-	public function get_timezone_abbrev( $timezone_string ) {
640
-		$timezone_string = EEH_DTT_Helper::get_valid_timezone_string( $timezone_string );
641
-		$dateTime = new DateTime( 'now', new DateTimeZone( $timezone_string ) );
642
-		return $dateTime->format( 'T' );
639
+	public function get_timezone_abbrev($timezone_string) {
640
+		$timezone_string = EEH_DTT_Helper::get_valid_timezone_string($timezone_string);
641
+		$dateTime = new DateTime('now', new DateTimeZone($timezone_string));
642
+		return $dateTime->format('T');
643 643
 	}
644 644
 
645 645
 
Please login to merge, or discard this patch.
core/db_models/fields/EE_Email_Field.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-class EE_Email_Field extends EE_Text_Field_Base{
2
+class EE_Email_Field extends EE_Text_Field_Base {
3 3
 	function prepare_for_set($value_inputted_for_field_on_model_object) {
4 4
 		return sanitize_email($value_inputted_for_field_on_model_object);
5 5
 	}
Please login to merge, or discard this patch.
core/db_models/fields/EE_Enum_Integer_Field.php 2 patches
Spacing   +10 added lines, -10 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
-require_once( EE_MODELS . 'fields/EE_Integer_Field.php' );
2
+require_once(EE_MODELS.'fields/EE_Integer_Field.php');
3 3
 /**
4 4
  * Class EE_Enum_Integer_Field
5 5
  *
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @author				Mike Nelson
9 9
  *
10 10
  */
11
-class EE_Enum_Integer_Field extends EE_Integer_Field{
11
+class EE_Enum_Integer_Field extends EE_Integer_Field {
12 12
 
13 13
 	var $_allowed_enum_values;
14 14
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 * @param int $default_value
21 21
 	 * @param array $allowed_enum_values  keys are values to be used in the DB, values are how they should be displayed
22 22
 	 */
23
-	function __construct($table_column, $nicename, $nullable, $default_value, $allowed_enum_values){
23
+	function __construct($table_column, $nicename, $nullable, $default_value, $allowed_enum_values) {
24 24
 		$this->_allowed_enum_values = $allowed_enum_values;
25 25
 		parent::__construct($table_column, $nicename, $nullable, $default_value);
26 26
 	}
@@ -32,20 +32,20 @@  discard block
 block discarded – undo
32 32
 	 * @throws EE_Error
33 33
 	 */
34 34
 	function prepare_for_set($value_inputted_for_field_on_model_object) {
35
-		if( $value_inputted_for_field_on_model_object !== NULL && ! array_key_exists( $value_inputted_for_field_on_model_object, $this->_allowed_enum_values )){
36
-			if( defined( 'WP_DEBUG' ) && WP_DEBUG ){
35
+		if ($value_inputted_for_field_on_model_object !== NULL && ! array_key_exists($value_inputted_for_field_on_model_object, $this->_allowed_enum_values)) {
36
+			if (defined('WP_DEBUG') && WP_DEBUG) {
37 37
 				$msg = sprintf(
38
-					__('System is assigning incompatible value "%1$s" to field "%2$s"','event_espresso'),
38
+					__('System is assigning incompatible value "%1$s" to field "%2$s"', 'event_espresso'),
39 39
 					$value_inputted_for_field_on_model_object,
40 40
 					$this->_name
41 41
 				);
42 42
 				$msg2 = sprintf(
43
-					__('Allowed values for "%1$s" are "%2$s". You provided "%3$s"','event_espresso'),
43
+					__('Allowed values for "%1$s" are "%2$s". You provided "%3$s"', 'event_espresso'),
44 44
 					$this->_name,
45
-					implode( ', ', array_keys( $this->_allowed_enum_values )),
45
+					implode(', ', array_keys($this->_allowed_enum_values)),
46 46
 					$value_inputted_for_field_on_model_object
47 47
 				);
48
-				 EE_Error::add_error("$msg||$msg2", __FILE__, __FUNCTION__, __LINE__ );
48
+				 EE_Error::add_error("$msg||$msg2", __FILE__, __FUNCTION__, __LINE__);
49 49
 			}
50 50
 			return $this->get_default_value();
51 51
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 * @param null         $schema
63 63
 	 * @return string
64 64
 	 */
65
-	function prepare_for_pretty_echoing( $value_on_field_to_be_outputted, $schema = NULL ) {
65
+	function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = NULL) {
66 66
 		return $this->_allowed_enum_values[$value_on_field_to_be_outputted];
67 67
 	}
68 68
 }
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
 require_once( EE_MODELS . 'fields/EE_Integer_Field.php' );
3 5
 /**
4 6
  * Class EE_Enum_Integer_Field
Please login to merge, or discard this patch.
core/db_models/fields/EE_Field_With_Model_Name.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * with the EE_Foreign_Key_Field to create a relation between any two models)
6 6
  * also required basically the exact same functionality, except NOT be a foreign key.
7 7
  */
8
-abstract class EE_Field_With_Model_Name extends EE_Model_Field_Base{
8
+abstract class EE_Field_With_Model_Name extends EE_Model_Field_Base {
9 9
 	/**
10 10
 	 * Usually the name of a single model. However, as in the case for custom post types,
11 11
 	 * it can actually be an array of models
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 * @param mixed $default_value if this is a integer field, it shoudl be an int. if it's a string field, it shoul dbe a string
21 21
 	 * @param string $model_name eg 'Event','Answer','Term', etc. Basically its the model class's name without the "EEM_"
22 22
 	 */
23
-	function __construct($table_column, $nicename, $nullable, $default_value,$model_name){
23
+	function __construct($table_column, $nicename, $nullable, $default_value, $model_name) {
24 24
 		$this->_model_name_pointed_to = $model_name;
25 25
 		parent::__construct($table_column, $nicename, $nullable, $default_value);
26 26
 	}
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
 	 * @deprecated since version 4.6.7
30 30
 	 * @return mixed string or array of strings
31 31
 	 */
32
-	function get_model_name_pointed_to(){
33
-		EE_Error::doing_it_wrong( 'get_model_name_pointed_to', __( 'This method has been deprecated in favour of instead using get_model_names_pointed_to, which consistently returns an array', 'event_espresso' ), '4.6.7' );
32
+	function get_model_name_pointed_to() {
33
+		EE_Error::doing_it_wrong('get_model_name_pointed_to', __('This method has been deprecated in favour of instead using get_model_names_pointed_to, which consistently returns an array', 'event_espresso'), '4.6.7');
34 34
 		return $this->_model_name_pointed_to;
35 35
 	}
36 36
 	/**
@@ -39,31 +39,31 @@  discard block
 block discarded – undo
39 39
 	 * @return array of model names pointed to by this field
40 40
 	 */
41 41
 	function get_model_names_pointed_to() {
42
-		if( is_array( $this->_model_name_pointed_to ) ) {
42
+		if (is_array($this->_model_name_pointed_to)) {
43 43
 			return $this->_model_name_pointed_to;
44
-		}else{
45
-			return array( $this->_model_name_pointed_to );
44
+		} else {
45
+			return array($this->_model_name_pointed_to);
46 46
 		}
47 47
 	}
48 48
 	/**
49 49
 	 * Returns the model's classname (eg EE_Event instead of just Event)
50 50
 	 * @return array
51 51
 	 */
52
-	function get_model_class_names_pointed_to(){
52
+	function get_model_class_names_pointed_to() {
53 53
 		$model_names = array();
54
-		if(is_array($this->_model_name_pointed_to)){
55
-			foreach($this->_model_name_pointed_to as $model_name){
54
+		if (is_array($this->_model_name_pointed_to)) {
55
+			foreach ($this->_model_name_pointed_to as $model_name) {
56 56
 				$model_names[] = "EE_".$model_name;
57 57
 			}
58
-		}else{
58
+		} else {
59 59
 			$model_names = array("EE_".$this->_model_name_pointed_to);
60 60
 		}
61 61
 		return $model_names;
62 62
 	}
63 63
 
64
-	function is_model_obj_of_type_pointed_to($model_obj_or_ID){
65
-		foreach($this->get_model_class_names_pointed_to() as $model_obj_classname){
66
-			if($model_obj_or_ID instanceof $model_obj_classname){
64
+	function is_model_obj_of_type_pointed_to($model_obj_or_ID) {
65
+		foreach ($this->get_model_class_names_pointed_to() as $model_obj_classname) {
66
+			if ($model_obj_or_ID instanceof $model_obj_classname) {
67 67
 				return true;
68 68
 			}
69 69
 		}
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	function get_model_names_pointed_to() {
42 42
 		if( is_array( $this->_model_name_pointed_to ) ) {
43 43
 			return $this->_model_name_pointed_to;
44
-		}else{
44
+		} else{
45 45
 			return array( $this->_model_name_pointed_to );
46 46
 		}
47 47
 	}
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 			foreach($this->_model_name_pointed_to as $model_name){
56 56
 				$model_names[] = "EE_".$model_name;
57 57
 			}
58
-		}else{
58
+		} else{
59 59
 			$model_names = array("EE_".$this->_model_name_pointed_to);
60 60
 		}
61 61
 		return $model_names;
Please login to merge, or discard this patch.
core/db_models/fields/EE_Float_Field.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
2 2
 /**
3 3
  * Text_Fields is a base class for any fields which are have float value. (Exception: foreign and private key fields. Wish PHP had multiple-inheritance for this...)
4 4
  */
5
-class EE_Float_Field extends EE_Model_Field_Base{
6
-	function get_wpdb_data_type(){
5
+class EE_Float_Field extends EE_Model_Field_Base {
6
+	function get_wpdb_data_type() {
7 7
 		return '%f';
8 8
 	}
9 9
 	/**
@@ -17,26 +17,26 @@  discard block
 block discarded – undo
17 17
 	function prepare_for_set($value_inputted_for_field_on_model_object) {
18 18
 //		echo __LINE__."$value_inputted_for_field_on_model_object<br>";
19 19
 		//remove whitespaces and thousands separators
20
-		if(is_string($value_inputted_for_field_on_model_object)){
21
-			$value_inputted_for_field_on_model_object = str_replace(array(" ",EE_Config::instance()->currency->thsnds),"",$value_inputted_for_field_on_model_object);
20
+		if (is_string($value_inputted_for_field_on_model_object)) {
21
+			$value_inputted_for_field_on_model_object = str_replace(array(" ", EE_Config::instance()->currency->thsnds), "", $value_inputted_for_field_on_model_object);
22 22
 //echo __LINE__."$value_inputted_for_field_on_model_object<br>";
23 23
 //normalize it so periods are decimal marks (we don't care where you're from: we're talking PHP now)
24
-			$value_inputted_for_field_on_model_object = str_replace( EE_Config::instance()->currency->dec_mrk, ".", $value_inputted_for_field_on_model_object) ;
24
+			$value_inputted_for_field_on_model_object = str_replace(EE_Config::instance()->currency->dec_mrk, ".", $value_inputted_for_field_on_model_object);
25 25
 //echo __LINE__."$value_inputted_for_field_on_model_object<br>";
26 26
 //double-check there's absolutely nothing left on this string besides numbers
27
-			$value_inputted_for_field_on_model_object = preg_replace( "/[^0-9,.]/", "", $value_inputted_for_field_on_model_object);
27
+			$value_inputted_for_field_on_model_object = preg_replace("/[^0-9,.]/", "", $value_inputted_for_field_on_model_object);
28 28
 		}
29 29
 //		echo __LINE__."$value_inputted_for_field_on_model_object<br>";
30
-		return floatval( $value_inputted_for_field_on_model_object );
30
+		return floatval($value_inputted_for_field_on_model_object);
31 31
 	}
32 32
 	/**
33 33
 	 * Returns the number formatted according to local custom (set by the country of the blog).
34 34
 	 * @param float $value_on_field_to_be_outputted
35 35
 	 * @return string
36 36
 	 */
37
-	function prepare_for_pretty_echoing($value_on_field_to_be_outputted,$schema = null){
37
+	function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) {
38 38
 		$EE = EE_Registry::instance();
39
-		return number_format( $value_on_field_to_be_outputted, $EE->CFG->currency->dec_plc, $EE->CFG->currency->dec_mrk, $EE->CFG->currency->thsnds) ;
39
+		return number_format($value_on_field_to_be_outputted, $EE->CFG->currency->dec_plc, $EE->CFG->currency->dec_mrk, $EE->CFG->currency->thsnds);
40 40
 	}
41 41
 
42 42
 	function prepare_for_set_from_db($value_found_in_db_for_model_object) {
Please login to merge, or discard this patch.