@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -require_once( EE_MODELS . 'fields/EE_Text_Field_Base.php' ); |
|
2 | +require_once(EE_MODELS.'fields/EE_Text_Field_Base.php'); |
|
3 | 3 | /** |
4 | 4 | * |
5 | 5 | * Class EE_Enum_Text_Field |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @param mixed $default_value |
24 | 24 | * @param array $allowed_enum_values keys are values to be used in the DB, values are how they should be displayed |
25 | 25 | */ |
26 | - function __construct($table_column, $nice_name, $nullable, $default_value, $allowed_enum_values){ |
|
26 | + function __construct($table_column, $nice_name, $nullable, $default_value, $allowed_enum_values) { |
|
27 | 27 | $this->_allowed_enum_values = $allowed_enum_values; |
28 | 28 | parent::__construct($table_column, $nice_name, $nullable, $default_value); |
29 | 29 | } |
@@ -38,11 +38,11 @@ discard block |
||
38 | 38 | * @throws EE_Error |
39 | 39 | */ |
40 | 40 | function prepare_for_set($value_inputted_for_field_on_model_object) { |
41 | - if($value_inputted_for_field_on_model_object!==null && !array_key_exists($value_inputted_for_field_on_model_object,$this->_allowed_enum_values)){ |
|
42 | - if( defined( 'WP_DEBUG' ) && WP_DEBUG ){ |
|
43 | - $msg = sprintf(__("System is assigning incompatible value '%s' to field '%s'",'event_espresso'),$value_inputted_for_field_on_model_object,$this->_name); |
|
44 | - $msg2 = sprintf(__("Allowed values for '%s' are %s. You provided %s",'event_espresso'),$this->_name,implode(", ",array_keys($this->_allowed_enum_values)),$value_inputted_for_field_on_model_object); |
|
45 | - EE_Error::add_error( "$msg||$msg2", __FILE__, __FUNCTION__, __LINE__ ); |
|
41 | + if ($value_inputted_for_field_on_model_object !== null && ! array_key_exists($value_inputted_for_field_on_model_object, $this->_allowed_enum_values)) { |
|
42 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
43 | + $msg = sprintf(__("System is assigning incompatible value '%s' to field '%s'", 'event_espresso'), $value_inputted_for_field_on_model_object, $this->_name); |
|
44 | + $msg2 = sprintf(__("Allowed values for '%s' are %s. You provided %s", 'event_espresso'), $this->_name, implode(", ", array_keys($this->_allowed_enum_values)), $value_inputted_for_field_on_model_object); |
|
45 | + EE_Error::add_error("$msg||$msg2", __FILE__, __FUNCTION__, __LINE__); |
|
46 | 46 | } |
47 | 47 | return $this->get_default_value(); |
48 | 48 |
@@ -2,8 +2,8 @@ discard block |
||
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 |
||
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) { |
@@ -4,6 +4,6 @@ |
||
4 | 4 | * needed functions from its parent, but because all foreign key fields inherit from |
5 | 5 | * this one, its easy ot check if a field is a foreign key. |
6 | 6 | */ |
7 | -abstract class EE_Foreign_Key_Field_Base extends EE_Field_With_Model_Name{ |
|
7 | +abstract class EE_Foreign_Key_Field_Base extends EE_Field_With_Model_Name { |
|
8 | 8 | //all needed functionality inherited from parent |
9 | 9 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -require_once( EE_MODELS . 'fields/EE_Foreign_Key_Field_Base.php'); |
|
3 | -class EE_Foreign_Key_Int_Field extends EE_Foreign_Key_Field_Base{ |
|
4 | - function get_wpdb_data_type(){ |
|
2 | +require_once(EE_MODELS.'fields/EE_Foreign_Key_Field_Base.php'); |
|
3 | +class EE_Foreign_Key_Int_Field extends EE_Foreign_Key_Field_Base { |
|
4 | + function get_wpdb_data_type() { |
|
5 | 5 | return '%d'; |
6 | 6 | } |
7 | 7 | /** |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @return int |
11 | 11 | */ |
12 | 12 | function prepare_for_set($value_inputted_for_field_on_model_object) { |
13 | - if($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)){ |
|
13 | + if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
14 | 14 | $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
15 | 15 | } |
16 | 16 | return absint($value_inputted_for_field_on_model_object); |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -require_once( EE_MODELS . 'fields/EE_Foreign_Key_Field_Base.php'); |
|
3 | -class EE_Foreign_Key_String_Field extends EE_Foreign_Key_Field_Base{ |
|
4 | - function get_wpdb_data_type(){ |
|
2 | +require_once(EE_MODELS.'fields/EE_Foreign_Key_Field_Base.php'); |
|
3 | +class EE_Foreign_Key_String_Field extends EE_Foreign_Key_Field_Base { |
|
4 | + function get_wpdb_data_type() { |
|
5 | 5 | return '%s'; |
6 | 6 | } |
7 | 7 | /** |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @return string |
11 | 11 | */ |
12 | 12 | function prepare_for_set($value_inputted_for_field_on_model_object) { |
13 | - if($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)){ |
|
13 | + if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
14 | 14 | $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
15 | 15 | } |
16 | 16 | return strtoupper(wp_strip_all_tags($value_inputted_for_field_on_model_object)); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -require_once( EE_MODELS . 'fields/EE_Text_Field_Base.php' ); |
|
3 | -class EE_Full_HTML_Field extends EE_Text_Field_Base{ |
|
2 | +require_once(EE_MODELS.'fields/EE_Text_Field_Base.php'); |
|
3 | +class EE_Full_HTML_Field extends EE_Text_Field_Base { |
|
4 | 4 | |
5 | 5 | |
6 | 6 | /** |
@@ -10,11 +10,11 @@ discard block |
||
10 | 10 | * @return string |
11 | 11 | */ |
12 | 12 | function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) { |
13 | - if($schema =='form_input'){ |
|
13 | + if ($schema == 'form_input') { |
|
14 | 14 | return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema); |
15 | - }elseif($schema == 'no_wpautop'){ |
|
15 | + }elseif ($schema == 'no_wpautop') { |
|
16 | 16 | return do_shortcode(parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema)); |
17 | - }else{ |
|
17 | + } else { |
|
18 | 18 | return wpautop(do_shortcode(parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema))); |
19 | 19 | } |
20 | 20 | } |
@@ -12,9 +12,9 @@ |
||
12 | 12 | function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) { |
13 | 13 | if($schema =='form_input'){ |
14 | 14 | return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema); |
15 | - }elseif($schema == 'no_wpautop'){ |
|
15 | + } elseif($schema == 'no_wpautop'){ |
|
16 | 16 | return do_shortcode(parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema)); |
17 | - }else{ |
|
17 | + } else{ |
|
18 | 18 | return wpautop(do_shortcode(parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema))); |
19 | 19 | } |
20 | 20 | } |
@@ -7,32 +7,32 @@ discard block |
||
7 | 7 | * other than explicitly setting it to INF. |
8 | 8 | * Makes use of constant EE_INF_IN_DB set in espresso.php, and INF, which is a PHP constant definedin the ether |
9 | 9 | */ |
10 | -class EE_Infinite_Integer_Field extends EE_Model_Field_Base{ |
|
11 | - function get_wpdb_data_type(){ |
|
10 | +class EE_Infinite_Integer_Field extends EE_Model_Field_Base { |
|
11 | + function get_wpdb_data_type() { |
|
12 | 12 | return '%d'; |
13 | 13 | } |
14 | 14 | function prepare_for_use_in_db($value_of_field_on_model_object) { |
15 | - if($value_of_field_on_model_object === INF){ |
|
15 | + if ($value_of_field_on_model_object === INF) { |
|
16 | 16 | return EE_INF_IN_DB; |
17 | - }else{ |
|
17 | + } else { |
|
18 | 18 | return intval($value_of_field_on_model_object); |
19 | 19 | } |
20 | 20 | } |
21 | 21 | function prepare_for_set($value_inputted_for_field_on_model_object) { |
22 | - if($value_inputted_for_field_on_model_object === EE_INF_IN_DB || |
|
22 | + if ($value_inputted_for_field_on_model_object === EE_INF_IN_DB || |
|
23 | 23 | $value_inputted_for_field_on_model_object === INF || |
24 | 24 | $value_inputted_for_field_on_model_object === "INF" |
25 | - ){ |
|
25 | + ) { |
|
26 | 26 | return INF; |
27 | - }else{ |
|
27 | + } else { |
|
28 | 28 | return intval($value_inputted_for_field_on_model_object); |
29 | 29 | } |
30 | 30 | } |
31 | 31 | function prepare_for_set_from_db($value_inputted_for_field_on_model_object) { |
32 | 32 | $intval = intval($value_inputted_for_field_on_model_object); |
33 | - if($intval == EE_INF_IN_DB){ |
|
33 | + if ($intval == EE_INF_IN_DB) { |
|
34 | 34 | return INF; |
35 | - }else{ |
|
35 | + } else { |
|
36 | 36 | return $intval; |
37 | 37 | } |
38 | 38 | } |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | * @param string $schema input, symbol, text; or any string you want to show if the value equals INF |
46 | 46 | * @return string |
47 | 47 | */ |
48 | - function prepare_for_pretty_echoing( $value_on_field_to_be_outputted, $schema = null ) { |
|
49 | - if( $value_on_field_to_be_outputted === INF ){ |
|
50 | - switch($schema){ |
|
48 | + function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) { |
|
49 | + if ($value_on_field_to_be_outputted === INF) { |
|
50 | + switch ($schema) { |
|
51 | 51 | case 'input': |
52 | 52 | return ''; |
53 | 53 | case 'symbol': |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | public function construction_finalized(){ |
93 | 93 | if( $this->_model instanceof EEM_Base && $this->_action ){ |
94 | 94 | return true; |
95 | - }else{ |
|
95 | + } else{ |
|
96 | 96 | return false; |
97 | 97 | } |
98 | 98 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | public function has_generated_cap_restrictions(){ |
126 | 126 | if( $this->_cap_restrictions_generated === false ){ |
127 | 127 | return false; |
128 | - }else{ |
|
128 | + } else{ |
|
129 | 129 | return true; |
130 | 130 | } |
131 | 131 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | $caps_for_admin = EE_Registry::instance()->CAP->get_ee_capabilities( 'administrator' ); |
154 | 154 | if( in_array( self::get_cap_name( $model, $action ), $caps_for_admin ) ) { |
155 | 155 | return true; |
156 | - }else{ |
|
156 | + } else{ |
|
157 | 157 | return false; |
158 | 158 | } |
159 | 159 | } |
@@ -3,8 +3,8 @@ |
||
3 | 3 | /** |
4 | 4 | * Text_Fields is a base class for any fields which are have integer value. (Exception: foreign and private key fields. Wish PHP had multiple-inheritance for this...) |
5 | 5 | */ |
6 | -class EE_Integer_Field extends EE_Model_Field_Base{ |
|
7 | - function get_wpdb_data_type(){ |
|
6 | +class EE_Integer_Field extends EE_Model_Field_Base { |
|
7 | + function get_wpdb_data_type() { |
|
8 | 8 | return '%d'; |
9 | 9 | } |
10 | 10 | function prepare_for_set($value_inputted_for_field_on_model_object) { |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | * But either way, the string or the array's values can ONLY contain simple HTML tags. |
25 | 25 | * If you want to allow Full HTML in the value, use EE_Maybe_Serialized_Text_Field |
26 | 26 | */ |
27 | -class EE_Maybe_Serialized_Simple_HTML_Field extends EE_Maybe_Serialized_Text_Field{ |
|
27 | +class EE_Maybe_Serialized_Simple_HTML_Field extends EE_Maybe_Serialized_Text_Field { |
|
28 | 28 | /** |
29 | 29 | * removes all non-basic tags when setting |
30 | 30 | * @param string $value_inputted_for_field_on_model_object |
31 | 31 | * @return string |
32 | 32 | */ |
33 | 33 | function prepare_for_set($value_inputted_for_field_on_model_object) { |
34 | - return parent::prepare_for_set( $this->_remove_tags( $value_inputted_for_field_on_model_object ) ); |
|
34 | + return parent::prepare_for_set($this->_remove_tags($value_inputted_for_field_on_model_object)); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | * @param array|string $value |
40 | 40 | * @return array|string |
41 | 41 | */ |
42 | - protected function _remove_tags( $value ) { |
|
43 | - if( is_array( $value ) ) { |
|
44 | - foreach( $value as $key => $v ) { |
|
45 | - $value[ $key ] = $this->_remove_tags( $v ); |
|
42 | + protected function _remove_tags($value) { |
|
43 | + if (is_array($value)) { |
|
44 | + foreach ($value as $key => $v) { |
|
45 | + $value[$key] = $this->_remove_tags($v); |
|
46 | 46 | } |
47 | - }elseif( is_string( $value ) ) { |
|
48 | - $value = wp_kses("$value", $this->_get_allowed_tags() ); |
|
47 | + }elseif (is_string($value)) { |
|
48 | + $value = wp_kses("$value", $this->_get_allowed_tags()); |
|
49 | 49 | } |
50 | 50 | return $value; |
51 | 51 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @return array|string |
57 | 57 | */ |
58 | 58 | function prepare_for_set_from_db($value_found_in_db_for_model_object) { |
59 | - return parent::prepare_for_set_from_db( $this->_remove_tags( $value_found_in_db_for_model_object ) ); |
|
59 | + return parent::prepare_for_set_from_db($this->_remove_tags($value_found_in_db_for_model_object)); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | * @global array $allowedtags |
66 | 66 | * @return array |
67 | 67 | */ |
68 | - function _get_allowed_tags(){ |
|
68 | + function _get_allowed_tags() { |
|
69 | 69 | global $allowedtags; |
70 | 70 | $tags_we_allow = $allowedtags; |
71 | - $tags_we_allow['ol']=array(); |
|
72 | - $tags_we_allow['ul']=array(); |
|
73 | - $tags_we_allow['li']=array(); |
|
74 | - return apply_filters( 'FHEE__EE_Maybe_Serialized_Simple_HTML_Field___get_allowed_tags', $tags_we_allow, $this ); |
|
71 | + $tags_we_allow['ol'] = array(); |
|
72 | + $tags_we_allow['ul'] = array(); |
|
73 | + $tags_we_allow['li'] = array(); |
|
74 | + return apply_filters('FHEE__EE_Maybe_Serialized_Simple_HTML_Field___get_allowed_tags', $tags_we_allow, $this); |
|
75 | 75 | } |
76 | 76 | } |
@@ -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 | * Event Espresso |
4 | 6 | * |
@@ -44,7 +46,7 @@ discard block |
||
44 | 46 | foreach( $value as $key => $v ) { |
45 | 47 | $value[ $key ] = $this->_remove_tags( $v ); |
46 | 48 | } |
47 | - }elseif( is_string( $value ) ) { |
|
49 | + } elseif( is_string( $value ) ) { |
|
48 | 50 | $value = wp_kses("$value", $this->_get_allowed_tags() ); |
49 | 51 | } |
50 | 52 | return $value; |
@@ -799,7 +799,6 @@ |
||
799 | 799 | |
800 | 800 | |
801 | 801 | /** |
802 | - |
|
803 | 802 | * |
804 | 803 | * If the the first date starts at midnight on one day, and the next date ends at midnight on the |
805 | 804 | * very next day then this method will return true. |