@@ -1,5 +1,5 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -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 | require_once( EE_MODELS . 'fields/EE_Integer_Field.php' ); |
3 | 5 | /** |
4 | 6 | * Class EE_Enum_Integer_Field |
@@ -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)); |
@@ -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 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * but you want to have an exceptional case where users can directly submit content |
12 | 12 | * for this field, then you should first run the content through `wp_kses( $content, 'post' )` |
13 | 13 | */ |
14 | -class EE_Full_HTML_Field extends EE_Text_Field_Base{ |
|
14 | +class EE_Full_HTML_Field extends EE_Text_Field_Base { |
|
15 | 15 | |
16 | 16 | |
17 | 17 | /** |
@@ -21,11 +21,11 @@ discard block |
||
21 | 21 | * @return string |
22 | 22 | */ |
23 | 23 | function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) { |
24 | - if($schema =='form_input'){ |
|
24 | + if ($schema == 'form_input') { |
|
25 | 25 | return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema); |
26 | - }elseif($schema == 'no_wpautop'){ |
|
26 | + }elseif ($schema == 'no_wpautop') { |
|
27 | 27 | return do_shortcode(parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema)); |
28 | - }else{ |
|
28 | + } else { |
|
29 | 29 | return wpautop(do_shortcode(parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema))); |
30 | 30 | } |
31 | 31 | } |
@@ -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) { |
@@ -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; |
@@ -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 $this->_remove_tags( parent::prepare_for_set_from_db( $value_found_in_db_for_model_object ) ); |
|
59 | + return $this->_remove_tags(parent::prepare_for_set_from_db($value_found_in_db_for_model_object)); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @global array $allowedtags |
66 | 66 | * @return array |
67 | 67 | */ |
68 | - function _get_allowed_tags(){ |
|
69 | - return apply_filters( 'FHEE__EE_Maybe_Serialized_Simple_HTML_Field___get_allowed_tags', EEH_HTML::get_simple_tags(), $this ); |
|
68 | + function _get_allowed_tags() { |
|
69 | + return apply_filters('FHEE__EE_Maybe_Serialized_Simple_HTML_Field___get_allowed_tags', EEH_HTML::get_simple_tags(), $this); |
|
70 | 70 | } |
71 | 71 | } |
@@ -19,7 +19,6 @@ |
||
19 | 19 | * @package Event Espresso |
20 | 20 | * @subpackage includes/models/ |
21 | 21 | * @author Michael Nelson |
22 | - |
|
23 | 22 | * Model field for representing a column that CAN contain serialized text, or a regular string. |
24 | 23 | * But either way, the string or the array's values can ONLY contain simple HTML tags. |
25 | 24 | * If you want to allow Full HTML in the value, use EE_Maybe_Serialized_Text_Field |
@@ -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; |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | function prepare_for_use_in_db($value_of_field_on_model_object) { |
15 | 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 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $pretty_value = null; |
29 | 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; |