@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | 24 | |
25 | -require_once ( EE_CLASSES . 'EE_Ticket_Price.class.php' ); |
|
26 | -require_once ( EE_MODELS . 'EEM_Base.model.php' ); |
|
25 | +require_once (EE_CLASSES.'EE_Ticket_Price.class.php'); |
|
26 | +require_once (EE_MODELS.'EEM_Base.model.php'); |
|
27 | 27 | |
28 | 28 | class EEM_Ticket_Price extends EEM_Base { |
29 | 29 | |
@@ -37,12 +37,12 @@ discard block |
||
37 | 37 | * @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) |
38 | 38 | * @return void |
39 | 39 | */ |
40 | - protected function __construct( $timezone ) { |
|
41 | - $this->singular_item = __('Ticket Price','event_espresso'); |
|
42 | - $this->plural_item = __('Ticket Prices','event_espresso'); |
|
40 | + protected function __construct($timezone) { |
|
41 | + $this->singular_item = __('Ticket Price', 'event_espresso'); |
|
42 | + $this->plural_item = __('Ticket Prices', 'event_espresso'); |
|
43 | 43 | |
44 | 44 | $this->_tables = array( |
45 | - 'Ticket_Price'=>new EE_Primary_Table('esp_ticket_price','TKP_ID') |
|
45 | + 'Ticket_Price'=>new EE_Primary_Table('esp_ticket_price', 'TKP_ID') |
|
46 | 46 | ); |
47 | 47 | $this->_fields = array( |
48 | 48 | 'Ticket_Price'=> array( |
@@ -56,14 +56,14 @@ discard block |
||
56 | 56 | 'Price'=>new EE_Belongs_To_Relation() |
57 | 57 | ); |
58 | 58 | $this->_model_chain_to_wp_user = 'Ticket'; |
59 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public('Ticket.TKT_is_default', 'Ticket.Datetime.Event' ); |
|
59 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Default_Public('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
60 | 60 | //account for default tickets in the caps |
61 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected( 'Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
62 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected( 'Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
63 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected( 'Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
61 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
62 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
63 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
64 | 64 | //follow the caps of the ticket |
65 | 65 | $this->_caps_slug = 'tickets'; |
66 | - parent::__construct( $timezone ); |
|
66 | + parent::__construct($timezone); |
|
67 | 67 | |
68 | 68 | } |
69 | 69 |
@@ -1,4 +1,6 @@ |
||
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 | * Event Espresso |
4 | 6 | * |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -require_once ( EE_MODELS . 'EEM_Base.model.php' ); |
|
25 | -require_once ( EE_CLASSES . 'EE_Ticket_Template.class.php' ); |
|
24 | +require_once (EE_MODELS.'EEM_Base.model.php'); |
|
25 | +require_once (EE_CLASSES.'EE_Ticket_Template.class.php'); |
|
26 | 26 | |
27 | 27 | class EEM_Ticket_Template extends EEM_Base { |
28 | 28 | |
@@ -38,29 +38,29 @@ discard block |
||
38 | 38 | * @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) |
39 | 39 | * @return void |
40 | 40 | */ |
41 | - protected function __construct( $timezone ) { |
|
42 | - $this->singular_item = __('Ticket Template','event_espresso'); |
|
43 | - $this->plural_item = __('Ticket Templates','event_espresso'); |
|
41 | + protected function __construct($timezone) { |
|
42 | + $this->singular_item = __('Ticket Template', 'event_espresso'); |
|
43 | + $this->plural_item = __('Ticket Templates', 'event_espresso'); |
|
44 | 44 | |
45 | 45 | $this->_tables = array( |
46 | 46 | 'Ticket_Template'=> new EE_Primary_Table('esp_ticket_template', 'TTM_ID') |
47 | 47 | ); |
48 | 48 | $this->_fields = array( |
49 | 49 | 'Ticket_Template'=>array( |
50 | - 'TTM_ID'=>new EE_Primary_Key_Int_Field('TTM_ID', __('Ticket Template ID','event_espresso')), |
|
51 | - 'TTM_name'=>new EE_Plain_Text_Field('TTM_name', __('The name of the ticket template','event_espresso'), false, '' ), |
|
52 | - 'TTM_description'=>new EE_Plain_Text_Field('TTM_description', __('The description for the ticket template','event_espresso'), true, '' ), |
|
53 | - 'TTM_file'=>new EE_Plain_Text_Field('TTM_file', __('The file name for the actual template file saved on disk','event_espresso'), true, '' ), |
|
50 | + 'TTM_ID'=>new EE_Primary_Key_Int_Field('TTM_ID', __('Ticket Template ID', 'event_espresso')), |
|
51 | + 'TTM_name'=>new EE_Plain_Text_Field('TTM_name', __('The name of the ticket template', 'event_espresso'), false, ''), |
|
52 | + 'TTM_description'=>new EE_Plain_Text_Field('TTM_description', __('The description for the ticket template', 'event_espresso'), true, ''), |
|
53 | + 'TTM_file'=>new EE_Plain_Text_Field('TTM_file', __('The file name for the actual template file saved on disk', 'event_espresso'), true, ''), |
|
54 | 54 | )); |
55 | 55 | $this->_model_relations = array( |
56 | 56 | 'Ticket'=>new EE_Has_Many_Relation() |
57 | 57 | ); |
58 | 58 | $this->_model_chain_to_wp_user = 'Ticket'; |
59 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public('Ticket.TKT_is_default', 'Ticket.Datetime.Event' ); |
|
59 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Default_Public('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
60 | 60 | //account for default tickets in the caps |
61 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected( 'Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
62 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected( 'Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
63 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected( 'Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
64 | - parent::__construct( $timezone ); |
|
61 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
62 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
63 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event'); |
|
64 | + parent::__construct($timezone); |
|
65 | 65 | } |
66 | 66 | } //end EEM_Ticket_Template class |
67 | 67 | \ No newline at end of file |
@@ -1,4 +1,6 @@ |
||
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 | * Event Espresso |
4 | 6 | * |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | /** |
3 | 3 | * Text_Fields is a base class for any fields which are have text value. (Exception: foreign and private key fields. Wish PHP had multiple-inheritance for this...) |
4 | 4 | */ |
5 | -class EE_All_Caps_Text_Field extends EE_Text_Field_Base{ |
|
6 | - function get_wpdb_data_type(){ |
|
5 | +class EE_All_Caps_Text_Field extends EE_Text_Field_Base { |
|
6 | + function get_wpdb_data_type() { |
|
7 | 7 | return '%s'; |
8 | 8 | } |
9 | 9 | |
@@ -13,6 +13,6 @@ discard block |
||
13 | 13 | * @return string |
14 | 14 | */ |
15 | 15 | function prepare_for_set($value_inputted_for_field_on_model_object) { |
16 | - return strtoupper( sanitize_key($value_inputted_for_field_on_model_object)); |
|
16 | + return strtoupper(sanitize_key($value_inputted_for_field_on_model_object)); |
|
17 | 17 | } |
18 | 18 | } |
19 | 19 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -require_once( EE_MODELS . 'fields/EE_DB_Only_Field_Base.php'); |
|
2 | +require_once(EE_MODELS.'fields/EE_DB_Only_Field_Base.php'); |
|
3 | 3 | /** |
4 | 4 | * Used by EE_Belongs_To_Any_Relations and EE_Has_Many_Any_Relations to identify the model the foreign key points to. |
5 | 5 | * Note: the array of model names on this field should match the array of model names on the |
@@ -8,8 +8,8 @@ discard block |
||
8 | 8 | * 'obj_id'=>new EE_Foreign_Key_Int_Field('obj_id_column',__('Related Object ID'),false,0,array('Registration','Transaction')), |
9 | 9 | * 'obj_type'=>new EE_Any_Foreign_Model_Name_Field('obj_type_column',__('Related Object type'),false,null,array('Registration','Transaction'))); |
10 | 10 | */ |
11 | -class EE_Any_Foreign_Model_Name_Field extends EE_Field_With_Model_Name{ |
|
12 | - function get_wpdb_data_type(){ |
|
11 | +class EE_Any_Foreign_Model_Name_Field extends EE_Field_With_Model_Name { |
|
12 | + function get_wpdb_data_type() { |
|
13 | 13 | return '%s'; |
14 | 14 | } |
15 | 15 | } |
16 | 16 | \ No newline at end of file |
@@ -7,7 +7,7 @@ |
||
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 |
@@ -1,7 +1,7 @@ |
||
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 | } |
@@ -1,8 +1,8 @@ |
||
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 |
@@ -1,7 +1,7 @@ |
||
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 |
@@ -459,7 +459,7 @@ |
||
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 { |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | * This prepares the datetime for internal usage as a PHP DateTime object OR null (if nullable is |
503 | 503 | * allowed) |
504 | 504 | * @param string $datetime_string mysql timestamp in UTC |
505 | - * @return mixed null | DateTime |
|
505 | + * @return null|DateTime null | DateTime |
|
506 | 506 | */ |
507 | 507 | public function prepare_for_set_from_db( $datetime_string ) { |
508 | 508 | //if $datetime_value is empty, and ! $this->_nullable, just use time() |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | * |
620 | 620 | * @param \DateTimeZone $DateTimeZone |
621 | 621 | * @param null $time |
622 | - * @return mixed |
|
622 | + * @return string |
|
623 | 623 | */ |
624 | 624 | public function get_timezone_offset( DateTimeZone $DateTimeZone, $time = null ) { |
625 | 625 | $time = preg_match( EE_Datetime_Field::unix_timestamp_regex, $time ) ? $time : time(); |
@@ -1,5 +1,5 @@ discard block |
||
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 |
@@ -118,15 +118,15 @@ discard block |
||
118 | 118 | * @param string $pretty_date_format |
119 | 119 | * @param string $pretty_time_format |
120 | 120 | */ |
121 | - public function __construct( $table_column, $nice_name, $nullable, $default_value, $timezone_string = '', $date_format = '', $time_format = '', $pretty_date_format = '', $pretty_time_format = '' ){ |
|
121 | + public function __construct($table_column, $nice_name, $nullable, $default_value, $timezone_string = '', $date_format = '', $time_format = '', $pretty_date_format = '', $pretty_time_format = '') { |
|
122 | 122 | |
123 | - $this->_date_format = ! empty( $date_format ) ? $date_format : get_option('date_format'); |
|
124 | - $this->_time_format = ! empty( $time_format ) ? $time_format : get_option('time_format'); |
|
125 | - $this->_pretty_date_format = ! empty( $pretty_date_format ) ? $pretty_date_format : get_option('date_format'); |
|
126 | - $this->_pretty_time_format = ! empty( $pretty_time_format ) ? $pretty_time_format : get_option('time_format'); |
|
123 | + $this->_date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
124 | + $this->_time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
125 | + $this->_pretty_date_format = ! empty($pretty_date_format) ? $pretty_date_format : get_option('date_format'); |
|
126 | + $this->_pretty_time_format = ! empty($pretty_time_format) ? $pretty_time_format : get_option('time_format'); |
|
127 | 127 | |
128 | - parent::__construct( $table_column, $nice_name, $nullable, $default_value ); |
|
129 | - $this->set_timezone( $timezone_string ); |
|
128 | + parent::__construct($table_column, $nice_name, $nullable, $default_value); |
|
129 | + $this->set_timezone($timezone_string); |
|
130 | 130 | |
131 | 131 | } |
132 | 132 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * @return DateTimeZone |
146 | 146 | */ |
147 | 147 | public function get_UTC_DateTimeZone() { |
148 | - return $this->_UTC_DateTimeZone instanceof DateTimeZone ? $this->_UTC_DateTimeZone : $this->_create_timezone_object_from_timezone_string( 'UTC' ); |
|
148 | + return $this->_UTC_DateTimeZone instanceof DateTimeZone ? $this->_UTC_DateTimeZone : $this->_create_timezone_object_from_timezone_string('UTC'); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * @return DateTimeZone |
155 | 155 | */ |
156 | 156 | public function get_blog_DateTimeZone() { |
157 | - return $this->_blog_DateTimeZone instanceof DateTimeZone ? $this->_blog_DateTimeZone : $this->_create_timezone_object_from_timezone_string( '' ); |
|
157 | + return $this->_blog_DateTimeZone instanceof DateTimeZone ? $this->_blog_DateTimeZone : $this->_create_timezone_object_from_timezone_string(''); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | * @param string|int $value_inputted_for_field_on_model_object could be a string formatted date time or int unix timestamp |
165 | 165 | * @return DateTime |
166 | 166 | */ |
167 | - public function prepare_for_set( $value_inputted_for_field_on_model_object ) { |
|
168 | - return $this->_get_date_object( $value_inputted_for_field_on_model_object ); |
|
167 | + public function prepare_for_set($value_inputted_for_field_on_model_object) { |
|
168 | + return $this->_get_date_object($value_inputted_for_field_on_model_object); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | |
@@ -181,9 +181,9 @@ discard block |
||
181 | 181 | * @param bool $pretty If we're returning the pretty formats or standard format string. |
182 | 182 | * @return string The final assembled format string. |
183 | 183 | */ |
184 | - protected function _get_date_time_output( $pretty = FALSE ) { |
|
184 | + protected function _get_date_time_output($pretty = FALSE) { |
|
185 | 185 | |
186 | - switch ( $this->_date_time_output ) { |
|
186 | + switch ($this->_date_time_output) { |
|
187 | 187 | case 'time' : |
188 | 188 | return $pretty ? $this->_pretty_time_format : $this->_time_format; |
189 | 189 | break; |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | break; |
194 | 194 | |
195 | 195 | default : |
196 | - return $pretty ? $this->_pretty_date_format . ' ' . $this->_pretty_time_format : $this->_date_format . ' ' . $this->_time_format; |
|
196 | + return $pretty ? $this->_pretty_date_format.' '.$this->_pretty_time_format : $this->_date_format.' '.$this->_time_format; |
|
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * @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. |
208 | 208 | * @return void |
209 | 209 | */ |
210 | - public function set_date_time_output( $what = NULL ) { |
|
210 | + public function set_date_time_output($what = NULL) { |
|
211 | 211 | $this->_date_time_output = $what; |
212 | 212 | } |
213 | 213 | |
@@ -223,15 +223,15 @@ discard block |
||
223 | 223 | * @param string $timezone_string A valid timezone string as described by @link http://www.php.net/manual/en/timezones.php |
224 | 224 | * @return void |
225 | 225 | */ |
226 | - public function set_timezone( $timezone_string ) { |
|
227 | - if( empty( $timezone_string ) && $this->_timezone_string != NULL ){ |
|
226 | + public function set_timezone($timezone_string) { |
|
227 | + if (empty($timezone_string) && $this->_timezone_string != NULL) { |
|
228 | 228 | // leave the timezone AS-IS if we already have one and |
229 | 229 | // the function arg didn't provide one |
230 | 230 | return; |
231 | 231 | } |
232 | - $timezone_string = EEH_DTT_Helper::get_valid_timezone_string( $timezone_string ); |
|
233 | - $this->_timezone_string = ! empty( $timezone_string ) ? $timezone_string : 'UTC'; |
|
234 | - $this->_DateTimeZone = $this->_create_timezone_object_from_timezone_string( $this->_timezone_string ); |
|
232 | + $timezone_string = EEH_DTT_Helper::get_valid_timezone_string($timezone_string); |
|
233 | + $this->_timezone_string = ! empty($timezone_string) ? $timezone_string : 'UTC'; |
|
234 | + $this->_DateTimeZone = $this->_create_timezone_object_from_timezone_string($this->_timezone_string); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | |
@@ -243,8 +243,8 @@ discard block |
||
243 | 243 | * @param string $timezone_string |
244 | 244 | * @return \DateTimeZone |
245 | 245 | */ |
246 | - protected function _create_timezone_object_from_timezone_string( $timezone_string = '' ) { |
|
247 | - return new DateTimeZone( EEH_DTT_Helper::get_valid_timezone_string( $timezone_string ) ); |
|
246 | + protected function _create_timezone_object_from_timezone_string($timezone_string = '') { |
|
247 | + return new DateTimeZone(EEH_DTT_Helper::get_valid_timezone_string($timezone_string)); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | |
@@ -269,8 +269,8 @@ discard block |
||
269 | 269 | * @param bool $pretty Whether to set pretty format or not. |
270 | 270 | * @return void |
271 | 271 | */ |
272 | - public function set_date_format( $format, $pretty = false ) { |
|
273 | - if ( $pretty ) { |
|
272 | + public function set_date_format($format, $pretty = false) { |
|
273 | + if ($pretty) { |
|
274 | 274 | $this->_pretty_date_format = $format; |
275 | 275 | } else { |
276 | 276 | $this->_date_format = $format; |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | * @param bool $pretty Whether to get pretty format or not. |
286 | 286 | * @return string |
287 | 287 | */ |
288 | - public function get_date_format( $pretty = false ) { |
|
288 | + public function get_date_format($pretty = false) { |
|
289 | 289 | return $pretty ? $this->_pretty_date_format : $this->_date_format; |
290 | 290 | } |
291 | 291 | |
@@ -300,8 +300,8 @@ discard block |
||
300 | 300 | * @param bool $pretty Whether to set pretty format or not. |
301 | 301 | * @return void |
302 | 302 | */ |
303 | - public function set_time_format( $format, $pretty = false ) { |
|
304 | - if ( $pretty ) { |
|
303 | + public function set_time_format($format, $pretty = false) { |
|
304 | + if ($pretty) { |
|
305 | 305 | $this->_pretty_time_format = $format; |
306 | 306 | } else { |
307 | 307 | $this->_time_format = $format; |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | * @param bool $pretty Whether to get pretty format or not. |
317 | 317 | * @return string |
318 | 318 | */ |
319 | - public function get_time_format( $pretty = false ) { |
|
319 | + public function get_time_format($pretty = false) { |
|
320 | 320 | return $pretty ? $this->_pretty_time_format : $this->_time_format; |
321 | 321 | } |
322 | 322 | |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | * @param string $format a new pretty date format (corresponding to formats accepted by PHP date() function) |
332 | 332 | * @return void |
333 | 333 | */ |
334 | - public function set_pretty_date_format( $format ) { |
|
334 | + public function set_pretty_date_format($format) { |
|
335 | 335 | $this->_pretty_date_format = $format; |
336 | 336 | } |
337 | 337 | |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | * @param string $format a new pretty time format (corresponding to formats accepted by PHP date() function) |
349 | 349 | * @return void |
350 | 350 | */ |
351 | - public function set_pretty_time_format( $format ) { |
|
351 | + public function set_pretty_time_format($format) { |
|
352 | 352 | $this->_pretty_time_format = $format; |
353 | 353 | } |
354 | 354 | |
@@ -360,9 +360,9 @@ discard block |
||
360 | 360 | * @param DateTime $current current DateTime object for the datetime field |
361 | 361 | * @return DateTime |
362 | 362 | */ |
363 | - public function prepare_for_set_with_new_time( $time_to_set_string, DateTime $current ){ |
|
363 | + public function prepare_for_set_with_new_time($time_to_set_string, DateTime $current) { |
|
364 | 364 | //if $time_to_set_string is datetime object, then let's use it to set the parse array. Otherwise parse the string. |
365 | - if ( $time_to_set_string instanceof DateTime ) { |
|
365 | + if ($time_to_set_string instanceof DateTime) { |
|
366 | 366 | $parsed = array( |
367 | 367 | 'hour' => $time_to_set_string->format('H'), |
368 | 368 | 'minute' => $time_to_set_string->format('i'), |
@@ -370,12 +370,12 @@ discard block |
||
370 | 370 | ); |
371 | 371 | } else { |
372 | 372 | //parse incoming string |
373 | - $parsed = date_parse_from_format( $this->_time_format, $time_to_set_string ); |
|
373 | + $parsed = date_parse_from_format($this->_time_format, $time_to_set_string); |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | //make sure $current is in the correct timezone. |
377 | - $current->setTimezone( $this->_DateTimeZone ); |
|
378 | - return $current->setTime( $parsed['hour'], $parsed['minute'], $parsed['second'] ); |
|
377 | + $current->setTimezone($this->_DateTimeZone); |
|
378 | + return $current->setTime($parsed['hour'], $parsed['minute'], $parsed['second']); |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | |
@@ -386,9 +386,9 @@ discard block |
||
386 | 386 | * @param DateTime $current current DateTime object for the datetime field |
387 | 387 | * @return DateTime |
388 | 388 | */ |
389 | - public function prepare_for_set_with_new_date( $date_to_set_string, DateTime $current ){ |
|
389 | + public function prepare_for_set_with_new_date($date_to_set_string, DateTime $current) { |
|
390 | 390 | //if $time_to_set_string is datetime object, then let's use it to set the parse array. Otherwise parse the string. |
391 | - if ( $date_to_set_string instanceof DateTime ) { |
|
391 | + if ($date_to_set_string instanceof DateTime) { |
|
392 | 392 | $parsed = array( |
393 | 393 | 'year' => $date_to_set_string->format('Y'), |
394 | 394 | 'month' => $date_to_set_string->format('m'), |
@@ -396,12 +396,12 @@ discard block |
||
396 | 396 | ); |
397 | 397 | } else { |
398 | 398 | //parse incoming string |
399 | - $parsed = date_parse_from_format( $this->_date_format, $date_to_set_string ); |
|
399 | + $parsed = date_parse_from_format($this->_date_format, $date_to_set_string); |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | //make sure $current is in the correct timezone |
403 | - $current->setTimezone( $this->_DateTimeZone ); |
|
404 | - return $current->setDate( $parsed['year'], $parsed['month'], $parsed['day'] ); |
|
403 | + $current->setTimezone($this->_DateTimeZone); |
|
404 | + return $current->setDate($parsed['year'], $parsed['month'], $parsed['day']); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | |
@@ -413,8 +413,8 @@ discard block |
||
413 | 413 | * @param DateTime $DateTime |
414 | 414 | * @return string formatted date time for given timezone |
415 | 415 | */ |
416 | - public function prepare_for_get( $DateTime ) { |
|
417 | - return $this->_prepare_for_display( $DateTime ); |
|
416 | + public function prepare_for_get($DateTime) { |
|
417 | + return $this->_prepare_for_display($DateTime); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | |
@@ -429,8 +429,8 @@ discard block |
||
429 | 429 | * @param null $schema |
430 | 430 | * @return string |
431 | 431 | */ |
432 | - public function prepare_for_pretty_echoing( $DateTime, $schema = null ) { |
|
433 | - return $this->_prepare_for_display( $DateTime, $schema ? $schema : true ); |
|
432 | + public function prepare_for_pretty_echoing($DateTime, $schema = null) { |
|
433 | + return $this->_prepare_for_display($DateTime, $schema ? $schema : true); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | |
@@ -444,36 +444,36 @@ discard block |
||
444 | 444 | * @return string |
445 | 445 | * @throws \EE_Error |
446 | 446 | */ |
447 | - protected function _prepare_for_display( $DateTime, $schema = false ) { |
|
448 | - if ( ! $DateTime instanceof DateTime ) { |
|
449 | - if ( $this->_nullable ) { |
|
447 | + protected function _prepare_for_display($DateTime, $schema = false) { |
|
448 | + if ( ! $DateTime instanceof DateTime) { |
|
449 | + if ($this->_nullable) { |
|
450 | 450 | return ''; |
451 | 451 | } else { |
452 | - if ( WP_DEBUG ) { |
|
453 | - 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 ) ); |
|
452 | + if (WP_DEBUG) { |
|
453 | + 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)); |
|
454 | 454 | } else { |
455 | - $DateTime = new DateTime( "now" ); |
|
456 | - 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 ) ); |
|
455 | + $DateTime = new DateTime("now"); |
|
456 | + 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)); |
|
457 | 457 | } |
458 | 458 | } |
459 | 459 | } |
460 | - $format_string = $this->_get_date_time_output( $schema ); |
|
460 | + $format_string = $this->_get_date_time_output($schema); |
|
461 | 461 | //make sure datetime_value is in the correct timezone (in case that's been updated). |
462 | - $DateTime->setTimezone( $this->_DateTimeZone ); |
|
463 | - if ( $schema ) { |
|
464 | - if( $this->_display_timezone() ) { |
|
462 | + $DateTime->setTimezone($this->_DateTimeZone); |
|
463 | + if ($schema) { |
|
464 | + if ($this->_display_timezone()) { |
|
465 | 465 | //must be explicit because schema could equal true. |
466 | - if( $schema === 'no_html' ){ |
|
467 | - $timezone_string = ' (' . $DateTime->format( 'T' ) . ')'; |
|
468 | - }else{ |
|
469 | - $timezone_string = ' <span class="ee_dtt_timezone_string">(' . $DateTime->format( 'T' ) . ')</span>'; |
|
466 | + if ($schema === 'no_html') { |
|
467 | + $timezone_string = ' ('.$DateTime->format('T').')'; |
|
468 | + } else { |
|
469 | + $timezone_string = ' <span class="ee_dtt_timezone_string">('.$DateTime->format('T').')</span>'; |
|
470 | 470 | } |
471 | 471 | } else { |
472 | 472 | $timezone_string = ''; |
473 | 473 | } |
474 | - return $DateTime->format( $format_string ) . $timezone_string; |
|
474 | + return $DateTime->format($format_string).$timezone_string; |
|
475 | 475 | } else { |
476 | - return $DateTime->format( $format_string ); |
|
476 | + return $DateTime->format($format_string); |
|
477 | 477 | } |
478 | 478 | } |
479 | 479 | |
@@ -487,18 +487,18 @@ discard block |
||
487 | 487 | * @return string mysql timestamp in UTC |
488 | 488 | * @throws \EE_Error |
489 | 489 | */ |
490 | - public function prepare_for_use_in_db( $datetime_value ) { |
|
490 | + public function prepare_for_use_in_db($datetime_value) { |
|
491 | 491 | //we allow an empty value or DateTime object, but nothing else. |
492 | - if ( ! empty( $datetime_value ) && ! $datetime_value instanceof DateTime ) { |
|
493 | - 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' ) ); |
|
492 | + if ( ! empty($datetime_value) && ! $datetime_value instanceof DateTime) { |
|
493 | + 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')); |
|
494 | 494 | } |
495 | 495 | |
496 | - if ( $datetime_value instanceof DateTime ) { |
|
497 | - return $datetime_value->setTimezone( $this->get_UTC_DateTimeZone() )->format( EE_Datetime_Field::mysql_timestamp_format ); |
|
496 | + if ($datetime_value instanceof DateTime) { |
|
497 | + return $datetime_value->setTimezone($this->get_UTC_DateTimeZone())->format(EE_Datetime_Field::mysql_timestamp_format); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | // if $datetime_value is empty, and ! $this->_nullable, use current_time() but set the GMT flag to true |
501 | - return ! $this->_nullable && empty( $datetime_value ) ? current_time( 'mysql', true ) : null; |
|
501 | + return ! $this->_nullable && empty($datetime_value) ? current_time('mysql', true) : null; |
|
502 | 502 | } |
503 | 503 | |
504 | 504 | |
@@ -511,20 +511,20 @@ discard block |
||
511 | 511 | * @param string $datetime_string mysql timestamp in UTC |
512 | 512 | * @return mixed null | DateTime |
513 | 513 | */ |
514 | - public function prepare_for_set_from_db( $datetime_string ) { |
|
514 | + public function prepare_for_set_from_db($datetime_string) { |
|
515 | 515 | //if $datetime_value is empty, and ! $this->_nullable, just use time() |
516 | - if ( empty( $datetime_string) && $this->_nullable ) { |
|
516 | + if (empty($datetime_string) && $this->_nullable) { |
|
517 | 517 | return null; |
518 | 518 | } |
519 | 519 | // datetime strings from the db should ALWAYS be in UTC+0, so use UTC_DateTimeZone when creating |
520 | - $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() ); |
|
520 | + $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()); |
|
521 | 521 | |
522 | - if ( ! $DateTime instanceof DateTime ) { |
|
522 | + if ( ! $DateTime instanceof DateTime) { |
|
523 | 523 | //if still no datetime object, then let's just use now |
524 | - $DateTime = new DateTime( 'now', $this->get_UTC_DateTimeZone() ); |
|
524 | + $DateTime = new DateTime('now', $this->get_UTC_DateTimeZone()); |
|
525 | 525 | } |
526 | 526 | // THEN apply the field's set DateTimeZone |
527 | - $DateTime->setTimezone( $this->_DateTimeZone ); |
|
527 | + $DateTime->setTimezone($this->_DateTimeZone); |
|
528 | 528 | return $DateTime; |
529 | 529 | } |
530 | 530 | |
@@ -541,15 +541,15 @@ discard block |
||
541 | 541 | protected function _display_timezone() { |
542 | 542 | |
543 | 543 | // first let's do a comparison of timezone strings. If they match then we can get out without any further calculations |
544 | - $blog_string = get_option( 'timezone_string' ); |
|
545 | - if ( $blog_string == $this->_timezone_string ) { |
|
544 | + $blog_string = get_option('timezone_string'); |
|
545 | + if ($blog_string == $this->_timezone_string) { |
|
546 | 546 | return FALSE; |
547 | 547 | } |
548 | 548 | // now we need to calc the offset for the timezone string so we can compare with the blog offset. |
549 | - $this_offset = $this->get_timezone_offset( $this->_DateTimeZone ); |
|
550 | - $blog_offset = $this->get_timezone_offset( $this->get_blog_DateTimeZone() ); |
|
549 | + $this_offset = $this->get_timezone_offset($this->_DateTimeZone); |
|
550 | + $blog_offset = $this->get_timezone_offset($this->get_blog_DateTimeZone()); |
|
551 | 551 | // now compare |
552 | - if ( $blog_offset === $this_offset ) { |
|
552 | + if ($blog_offset === $this_offset) { |
|
553 | 553 | return FALSE; |
554 | 554 | } |
555 | 555 | return TRUE; |
@@ -567,24 +567,24 @@ discard block |
||
567 | 567 | * |
568 | 568 | * @return DateTime |
569 | 569 | */ |
570 | - protected function _get_date_object( $date_string ) { |
|
570 | + protected function _get_date_object($date_string) { |
|
571 | 571 | //first if this is an empty date_string and nullable is allowed, just return null. |
572 | - if ( $this->_nullable && empty( $date_string ) ) { |
|
572 | + if ($this->_nullable && empty($date_string)) { |
|
573 | 573 | return null; |
574 | 574 | } |
575 | 575 | |
576 | 576 | // if incoming date |
577 | - if ( $date_string instanceof DateTime ) { |
|
578 | - $date_string->setTimezone( $this->_DateTimeZone ); |
|
577 | + if ($date_string instanceof DateTime) { |
|
578 | + $date_string->setTimezone($this->_DateTimeZone); |
|
579 | 579 | return $date_string; |
580 | 580 | } |
581 | 581 | // if empty date_string and made it here. |
582 | 582 | // Return a datetime object for now in the given timezone. |
583 | - if ( empty( $date_string ) ) { |
|
584 | - return new DateTime( "now", $this->_DateTimeZone ); |
|
583 | + if (empty($date_string)) { |
|
584 | + return new DateTime("now", $this->_DateTimeZone); |
|
585 | 585 | } |
586 | 586 | // if $date_string is matches something that looks like a Unix timestamp let's just use it. |
587 | - if ( preg_match( EE_Datetime_Field::unix_timestamp_regex, $date_string ) ) { |
|
587 | + if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $date_string)) { |
|
588 | 588 | try { |
589 | 589 | /** |
590 | 590 | * This is operating under the assumption that the incoming Unix timestamp is |
@@ -592,29 +592,29 @@ discard block |
||
592 | 592 | * current_time('timestamp'); |
593 | 593 | * |
594 | 594 | */ |
595 | - $DateTime = new DateTime( "now", $this->_DateTimeZone ); |
|
596 | - return $DateTime->setTimestamp( $date_string ); |
|
597 | - } catch ( Exception $e ) { |
|
595 | + $DateTime = new DateTime("now", $this->_DateTimeZone); |
|
596 | + return $DateTime->setTimestamp($date_string); |
|
597 | + } catch (Exception $e) { |
|
598 | 598 | // should be rare, but if things got fooled then let's just continue |
599 | 599 | } |
600 | 600 | } |
601 | 601 | //not a unix timestamp. So we will use the set format on this object and set timezone to |
602 | 602 | //create the DateTime object. |
603 | - $format = $this->_date_format . ' ' . $this->_time_format; |
|
603 | + $format = $this->_date_format.' '.$this->_time_format; |
|
604 | 604 | try { |
605 | - $DateTime = DateTime::createFromFormat( $format, $date_string, $this->_DateTimeZone ); |
|
606 | - if ( ! $DateTime instanceof DateTime ) { |
|
605 | + $DateTime = DateTime::createFromFormat($format, $date_string, $this->_DateTimeZone); |
|
606 | + if ( ! $DateTime instanceof DateTime) { |
|
607 | 607 | throw new EE_Error( |
608 | 608 | sprintf( |
609 | - __( '"%1$s" does not represent a valid Date Time in the format "%2$s".', 'event_espresso' ), |
|
609 | + __('"%1$s" does not represent a valid Date Time in the format "%2$s".', 'event_espresso'), |
|
610 | 610 | $date_string, |
611 | 611 | $format |
612 | 612 | ) |
613 | 613 | ); |
614 | 614 | } |
615 | - } catch ( Exception $e ) { |
|
615 | + } catch (Exception $e) { |
|
616 | 616 | // 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. |
617 | - $DateTime = new DateTime( "now", $this->_DateTimeZone ); |
|
617 | + $DateTime = new DateTime("now", $this->_DateTimeZone); |
|
618 | 618 | } |
619 | 619 | return $DateTime; |
620 | 620 | } |
@@ -628,9 +628,9 @@ discard block |
||
628 | 628 | * @param null $time |
629 | 629 | * @return mixed |
630 | 630 | */ |
631 | - public function get_timezone_offset( DateTimeZone $DateTimeZone, $time = null ) { |
|
632 | - $time = preg_match( EE_Datetime_Field::unix_timestamp_regex, $time ) ? $time : time(); |
|
633 | - $transitions = $DateTimeZone->getTransitions( $time ); |
|
631 | + public function get_timezone_offset(DateTimeZone $DateTimeZone, $time = null) { |
|
632 | + $time = preg_match(EE_Datetime_Field::unix_timestamp_regex, $time) ? $time : time(); |
|
633 | + $transitions = $DateTimeZone->getTransitions($time); |
|
634 | 634 | return $transitions[0]['offset']; |
635 | 635 | } |
636 | 636 | |
@@ -642,10 +642,10 @@ discard block |
||
642 | 642 | * @param string $timezone_string |
643 | 643 | * @return string abbreviation |
644 | 644 | */ |
645 | - public function get_timezone_abbrev( $timezone_string ) { |
|
646 | - $timezone_string = EEH_DTT_Helper::get_valid_timezone_string( $timezone_string ); |
|
647 | - $dateTime = new DateTime( 'now', new DateTimeZone( $timezone_string ) ); |
|
648 | - return $dateTime->format( 'T' ); |
|
645 | + public function get_timezone_abbrev($timezone_string) { |
|
646 | + $timezone_string = EEH_DTT_Helper::get_valid_timezone_string($timezone_string); |
|
647 | + $dateTime = new DateTime('now', new DateTimeZone($timezone_string)); |
|
648 | + return $dateTime->format('T'); |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | /** |
@@ -653,7 +653,7 @@ discard block |
||
653 | 653 | * @return |
654 | 654 | */ |
655 | 655 | public function get_default_value() { |
656 | - if( $this->_default_value === EE_Datetime_Field::now ) { |
|
656 | + if ($this->_default_value === EE_Datetime_Field::now) { |
|
657 | 657 | return time(); |
658 | 658 | } else { |
659 | 659 | return parent::get_default_value(); |