@@ -4,17 +4,17 @@ discard block |
||
4 | 4 | /** |
5 | 5 | * For a db text column, which can either be an array in PHP code or a string. |
6 | 6 | */ |
7 | -require_once( EE_MODELS . 'fields/EE_Text_Field_Base.php' ); |
|
8 | -class EE_Maybe_Serialized_Text_Field extends EE_Serialized_Text_Field{ |
|
7 | +require_once(EE_MODELS.'fields/EE_Text_Field_Base.php'); |
|
8 | +class EE_Maybe_Serialized_Text_Field extends EE_Serialized_Text_Field { |
|
9 | 9 | /** |
10 | 10 | * Value could be an array or a string. If its an array, serialize it. Otherwise, leave it as a string |
11 | 11 | * @param array|string $value_of_field_on_model_object |
12 | 12 | * @return string (possibly serialized) |
13 | 13 | */ |
14 | 14 | function prepare_for_use_in_db($value_of_field_on_model_object) { |
15 | - if(is_array($value_of_field_on_model_object)){ |
|
15 | + if (is_array($value_of_field_on_model_object)) { |
|
16 | 16 | return parent::prepare_for_use_in_db($value_of_field_on_model_object); |
17 | - }else{ |
|
17 | + } else { |
|
18 | 18 | return $value_of_field_on_model_object; |
19 | 19 | } |
20 | 20 | } |
@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | */ |
27 | 27 | function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) { |
28 | 28 | $pretty_value = null; |
29 | - if(is_array($value_on_field_to_be_outputted)){ |
|
29 | + if (is_array($value_on_field_to_be_outputted)) { |
|
30 | 30 | $pretty_value = parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema); |
31 | - }else{ |
|
31 | + } else { |
|
32 | 32 | $pretty_value = $value_on_field_to_be_outputted; |
33 | 33 | } |
34 | 34 | return $pretty_value; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $validation_error_message = $default_validation_strategy->get_validation_error_message(); |
43 | 43 | } |
44 | 44 | throw new EE_Validation_Error( $validation_error_message, 'float_only' ); |
45 | - }else{ |
|
45 | + } else{ |
|
46 | 46 | return floatval($normalized_value); |
47 | 47 | } |
48 | 48 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | public function unnormalize($normalized_value) { |
56 | 56 | if( empty( $normalized_value ) ){ |
57 | 57 | return '0.00'; |
58 | - }else{ |
|
58 | + } else{ |
|
59 | 59 | return "$normalized_value"; |
60 | 60 | } |
61 | 61 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | -require_once( EE_MODELS . 'fields/EE_Text_Field_Base.php' ); |
|
3 | -class EE_Plain_Text_Field extends EE_Text_Field_Base{ |
|
2 | +require_once(EE_MODELS.'fields/EE_Text_Field_Base.php'); |
|
3 | +class EE_Plain_Text_Field extends EE_Text_Field_Base { |
|
4 | 4 | /** |
5 | 5 | * removes all tags when setting |
6 | 6 | * @param string $value_inputted_for_field_on_model_object |
@@ -1,14 +1,14 @@ |
||
1 | 1 | <?php |
2 | -require_once( EE_MODELS . 'fields/EE_Primary_Key_Field_Base.php'); |
|
3 | -class EE_Primary_Key_Int_Field extends EE_Primary_Key_Field_Base{ |
|
4 | - function get_wpdb_data_type(){ |
|
2 | +require_once(EE_MODELS.'fields/EE_Primary_Key_Field_Base.php'); |
|
3 | +class EE_Primary_Key_Int_Field extends EE_Primary_Key_Field_Base { |
|
4 | + function get_wpdb_data_type() { |
|
5 | 5 | return '%d'; |
6 | 6 | } |
7 | 7 | public function __construct($table_column, $nicename) { |
8 | 8 | parent::__construct($table_column, $nicename, 0); |
9 | 9 | } |
10 | 10 | function prepare_for_set($value_inputted_for_field_on_model_object) { |
11 | - if($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)){ |
|
11 | + if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
12 | 12 | $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
13 | 13 | } |
14 | 14 | return absint($value_inputted_for_field_on_model_object); |
@@ -4,6 +4,10 @@ |
||
4 | 4 | function get_wpdb_data_type(){ |
5 | 5 | return '%s'; |
6 | 6 | } |
7 | + |
|
8 | + /** |
|
9 | + * @param string $table_column |
|
10 | + */ |
|
7 | 11 | public function __construct($table_column, $nicename) { |
8 | 12 | parent::__construct($table_column, $nicename, NULL); |
9 | 13 | } |
@@ -20,9 +20,9 @@ |
||
20 | 20 | function prepare_for_set($value_inputted_for_field_on_model_object) { |
21 | 21 | if(is_string($value_inputted_for_field_on_model_object)){ |
22 | 22 | return parent::prepare_for_set($value_inputted_for_field_on_model_object); |
23 | - }elseif(is_array($value_inputted_for_field_on_model_object)){ |
|
23 | + } elseif(is_array($value_inputted_for_field_on_model_object)){ |
|
24 | 24 | return array_map(array($this,'prepare_for_set'), $value_inputted_for_field_on_model_object); |
25 | - }else{//so they passed NULL or an INT or something wack |
|
25 | + } else{//so they passed NULL or an INT or something wack |
|
26 | 26 | return $value_inputted_for_field_on_model_object; |
27 | 27 | } |
28 | 28 | } |
@@ -7,8 +7,8 @@ discard block |
||
7 | 7 | * However, when inserting into the DB, it should be serialized. |
8 | 8 | * Upon retrieval from the DB, it should be unserialized back into an array. |
9 | 9 | */ |
10 | -require_once( EE_MODELS . 'fields/EE_Text_Field_Base.php' ); |
|
11 | -class EE_Serialized_Text_Field extends EE_Text_Field_Base{ |
|
10 | +require_once(EE_MODELS.'fields/EE_Text_Field_Base.php'); |
|
11 | +class EE_Serialized_Text_Field extends EE_Text_Field_Base { |
|
12 | 12 | /** |
13 | 13 | * Value SHOULD be an array, and we want to now convert it to a serialized string |
14 | 14 | * @param array $value_of_field_on_model_object |
@@ -18,12 +18,12 @@ discard block |
||
18 | 18 | return maybe_serialize($value_of_field_on_model_object); |
19 | 19 | } |
20 | 20 | function prepare_for_set($value_inputted_for_field_on_model_object) { |
21 | - $value_inputted_for_field_on_model_object = EEH_Array::maybe_unserialize( $value_inputted_for_field_on_model_object ); |
|
22 | - if(is_string($value_inputted_for_field_on_model_object)){ |
|
21 | + $value_inputted_for_field_on_model_object = EEH_Array::maybe_unserialize($value_inputted_for_field_on_model_object); |
|
22 | + if (is_string($value_inputted_for_field_on_model_object)) { |
|
23 | 23 | return parent::prepare_for_set($value_inputted_for_field_on_model_object); |
24 | - }elseif(is_array($value_inputted_for_field_on_model_object)){ |
|
25 | - return array_map(array($this,'prepare_for_set'), $value_inputted_for_field_on_model_object); |
|
26 | - }else{//so they passed NULL or an INT or something wack |
|
24 | + }elseif (is_array($value_inputted_for_field_on_model_object)) { |
|
25 | + return array_map(array($this, 'prepare_for_set'), $value_inputted_for_field_on_model_object); |
|
26 | + } else {//so they passed NULL or an INT or something wack |
|
27 | 27 | return $value_inputted_for_field_on_model_object; |
28 | 28 | } |
29 | 29 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @return array |
34 | 34 | */ |
35 | 35 | function prepare_for_set_from_db($value_found_in_db_for_model_object) { |
36 | - return EEH_Array::maybe_unserialize( $value_found_in_db_for_model_object ); |
|
36 | + return EEH_Array::maybe_unserialize($value_found_in_db_for_model_object); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | * @return string |
44 | 44 | */ |
45 | 45 | function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) { |
46 | - switch($schema){ |
|
46 | + switch ($schema) { |
|
47 | 47 | case 'print_r': |
48 | - $pretty_value = print_r($value_on_field_to_be_outputted,true); |
|
48 | + $pretty_value = print_r($value_on_field_to_be_outputted, true); |
|
49 | 49 | break; |
50 | 50 | case 'as_table': |
51 | 51 | $pretty_value = EEH_Template::layout_array_as_table($value_on_field_to_be_outputted); |
52 | 52 | break; |
53 | 53 | default: |
54 | - $pretty_value = implode(", ",$value_on_field_to_be_outputted); |
|
54 | + $pretty_value = implode(", ", $value_on_field_to_be_outputted); |
|
55 | 55 | } |
56 | 56 | return $pretty_value; |
57 | 57 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | -require_once( EE_MODELS . 'fields/EE_Text_Field_Base.php' ); |
|
3 | -class EE_Slug_Field extends EE_Text_Field_Base{ |
|
2 | +require_once(EE_MODELS.'fields/EE_Text_Field_Base.php'); |
|
3 | +class EE_Slug_Field extends EE_Text_Field_Base { |
|
4 | 4 | /** |
5 | 5 | * ensures string is usable in URLs |
6 | 6 | * @param string $value_inputted_for_field_on_model_object |
@@ -2,13 +2,13 @@ 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 | -abstract class EE_Text_Field_Base extends EE_Model_Field_Base{ |
|
6 | - function get_wpdb_data_type(){ |
|
5 | +abstract class EE_Text_Field_Base extends EE_Model_Field_Base { |
|
6 | + function get_wpdb_data_type() { |
|
7 | 7 | return '%s'; |
8 | 8 | } |
9 | 9 | |
10 | - function prepare_for_get( $value_of_field_on_model_object ) { |
|
11 | - return is_string($value_of_field_on_model_object) ? stripslashes( $value_of_field_on_model_object ) : $value_of_field_on_model_object; |
|
10 | + function prepare_for_get($value_of_field_on_model_object) { |
|
11 | + return is_string($value_of_field_on_model_object) ? stripslashes($value_of_field_on_model_object) : $value_of_field_on_model_object; |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @return string |
19 | 19 | */ |
20 | 20 | function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) { |
21 | - if($schema=='form_input'){ |
|
21 | + if ($schema == 'form_input') { |
|
22 | 22 | $value_on_field_to_be_outputted = htmlentities($value_on_field_to_be_outputted, ENT_QUOTES, 'UTF-8'); |
23 | 23 | } |
24 | 24 | return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema); |
@@ -30,6 +30,6 @@ discard block |
||
30 | 30 | * @return string |
31 | 31 | */ |
32 | 32 | function prepare_for_set($value_inputted_for_field_on_model_object) { |
33 | - return stripslashes(html_entity_decode(parent::prepare_for_set($value_inputted_for_field_on_model_object),ENT_QUOTES,'UTF-8')); |
|
33 | + return stripslashes(html_entity_decode(parent::prepare_for_set($value_inputted_for_field_on_model_object), ENT_QUOTES, 'UTF-8')); |
|
34 | 34 | } |
35 | 35 | } |
36 | 36 | \ No newline at end of file |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | -require_once( EE_MODELS . 'fields/EE_Boolean_Field.php'); |
|
3 | -class EE_Trashed_Flag_Field extends EE_Boolean_Field{ |
|
2 | +require_once(EE_MODELS.'fields/EE_Boolean_Field.php'); |
|
3 | +class EE_Trashed_Flag_Field extends EE_Boolean_Field { |
|
4 | 4 | //note: some client code simply checks if a field IS an EE_Trashed_Flag_Field |
5 | 5 | //...otherwise, these fields are mostly the same as boolean fields |
6 | 6 | } |
@@ -2,13 +2,13 @@ |
||
2 | 2 | /** |
3 | 3 | * For CPT models who have a post type field |
4 | 4 | */ |
5 | -class EE_WP_Post_Type_Field extends EE_DB_Only_Text_Field{ |
|
5 | +class EE_WP_Post_Type_Field extends EE_DB_Only_Text_Field { |
|
6 | 6 | /** |
7 | 7 | * |
8 | 8 | * @param string $post_type the exact string to be used for the post type |
9 | 9 | * of all these post type model objects/rows |
10 | 10 | */ |
11 | - function __construct($post_type){ |
|
11 | + function __construct($post_type) { |
|
12 | 12 | parent::__construct('post_type', __("Post Type", 'event_espresso'), false, $post_type); |
13 | 13 | } |
14 | 14 | } |
15 | 15 | \ No newline at end of file |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * |
26 | 26 | * ------------------------------------------------------------------------ |
27 | 27 | */ |
28 | -class EE_WP_User_Field extends EE_Foreign_Key_Int_Field{ |
|
28 | +class EE_WP_User_Field extends EE_Foreign_Key_Int_Field { |
|
29 | 29 | /** |
30 | 30 | * No need to provide a default or the model pointed to- the default is |
31 | 31 | * always get_current_user_id() and the model pointed to is always WP_User |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | * @param string $nicename should eb internationalized with __('blah','event_espresso') |
34 | 34 | * @param boolean $nullable |
35 | 35 | */ |
36 | - function __construct($table_column, $nicename, $nullable){ |
|
37 | - parent::__construct($table_column, $nicename, $nullable, null, 'WP_User' ); |
|
36 | + function __construct($table_column, $nicename, $nullable) { |
|
37 | + parent::__construct($table_column, $nicename, $nullable, null, 'WP_User'); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | * constructing the model field because that's done before $current_user is set |
43 | 43 | * @return mixed |
44 | 44 | */ |
45 | - function get_default_value(){ |
|
46 | - if( did_action( 'init' ) ) { |
|
45 | + function get_default_value() { |
|
46 | + if (did_action('init')) { |
|
47 | 47 | return get_current_user_id(); |
48 | - }else{ |
|
49 | - EE_Error::doing_it_wrong('EE_WP_User_Field::get_default_value', __( 'You cant get a default value for a wp_User_Field because the "init" action is called, because current_user global hasnt yet been setup. Consider doing your business logic on the "init" hook or later.', 'event_espresso' ), '4.6.20' ); |
|
48 | + } else { |
|
49 | + EE_Error::doing_it_wrong('EE_WP_User_Field::get_default_value', __('You cant get a default value for a wp_User_Field because the "init" action is called, because current_user global hasnt yet been setup. Consider doing your business logic on the "init" hook or later.', 'event_espresso'), '4.6.20'); |
|
50 | 50 | return 1; |
51 | 51 | } |
52 | 52 | } |
@@ -1,4 +1,6 @@ discard block |
||
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 | * EEH_URL helper |
4 | 6 | * Helper class for URL-related PHP functions |
@@ -62,7 +64,7 @@ discard block |
||
62 | 64 | isset($results['response']['code']) && |
63 | 65 | $results['response']['code'] == '200'){ |
64 | 66 | return true; |
65 | - }else{ |
|
67 | + } else{ |
|
66 | 68 | return false; |
67 | 69 | } |
68 | 70 | } |