@@ -6,18 +6,18 @@ |
||
6 | 6 | */ |
7 | 7 | class EE_Integer_Field extends EE_Model_Field_Base |
8 | 8 | { |
9 | - function get_wpdb_data_type() |
|
10 | - { |
|
11 | - return '%d'; |
|
12 | - } |
|
9 | + function get_wpdb_data_type() |
|
10 | + { |
|
11 | + return '%d'; |
|
12 | + } |
|
13 | 13 | |
14 | - function prepare_for_set($value_inputted_for_field_on_model_object) |
|
15 | - { |
|
16 | - return intval($value_inputted_for_field_on_model_object); |
|
17 | - } |
|
14 | + function prepare_for_set($value_inputted_for_field_on_model_object) |
|
15 | + { |
|
16 | + return intval($value_inputted_for_field_on_model_object); |
|
17 | + } |
|
18 | 18 | |
19 | - function prepare_for_set_from_db($value_inputted_for_field_on_model_object) |
|
20 | - { |
|
21 | - return intval($value_inputted_for_field_on_model_object); |
|
22 | - } |
|
19 | + function prepare_for_set_from_db($value_inputted_for_field_on_model_object) |
|
20 | + { |
|
21 | + return intval($value_inputted_for_field_on_model_object); |
|
22 | + } |
|
23 | 23 | } |
@@ -6,19 +6,19 @@ |
||
6 | 6 | */ |
7 | 7 | class EE_All_Caps_Text_Field extends EE_Text_Field_Base |
8 | 8 | { |
9 | - function get_wpdb_data_type() |
|
10 | - { |
|
11 | - return '%s'; |
|
12 | - } |
|
9 | + function get_wpdb_data_type() |
|
10 | + { |
|
11 | + return '%s'; |
|
12 | + } |
|
13 | 13 | |
14 | - /** |
|
15 | - * makes it all upper case, and key-like |
|
16 | - * |
|
17 | - * @param string $value_inputted_for_field_on_model_object |
|
18 | - * @return string |
|
19 | - */ |
|
20 | - function prepare_for_set($value_inputted_for_field_on_model_object) |
|
21 | - { |
|
22 | - return strtoupper(sanitize_key($value_inputted_for_field_on_model_object)); |
|
23 | - } |
|
14 | + /** |
|
15 | + * makes it all upper case, and key-like |
|
16 | + * |
|
17 | + * @param string $value_inputted_for_field_on_model_object |
|
18 | + * @return string |
|
19 | + */ |
|
20 | + function prepare_for_set($value_inputted_for_field_on_model_object) |
|
21 | + { |
|
22 | + return strtoupper(sanitize_key($value_inputted_for_field_on_model_object)); |
|
23 | + } |
|
24 | 24 | } |
25 | 25 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | /** |
@@ -24,34 +24,34 @@ discard block |
||
24 | 24 | */ |
25 | 25 | class EE_WP_User_Field extends EE_Foreign_Key_Int_Field |
26 | 26 | { |
27 | - /** |
|
28 | - * No need to provide a default or the model pointed to- the default is |
|
29 | - * always get_current_user_id() and the model pointed to is always WP_User |
|
30 | - * |
|
31 | - * @param string $table_column name fo column for field |
|
32 | - * @param string $nicename should eb internationalized with __('blah','event_espresso') |
|
33 | - * @param boolean $nullable |
|
34 | - */ |
|
35 | - function __construct($table_column, $nicename, $nullable) |
|
36 | - { |
|
37 | - parent::__construct($table_column, $nicename, $nullable, null, 'WP_User'); |
|
38 | - } |
|
27 | + /** |
|
28 | + * No need to provide a default or the model pointed to- the default is |
|
29 | + * always get_current_user_id() and the model pointed to is always WP_User |
|
30 | + * |
|
31 | + * @param string $table_column name fo column for field |
|
32 | + * @param string $nicename should eb internationalized with __('blah','event_espresso') |
|
33 | + * @param boolean $nullable |
|
34 | + */ |
|
35 | + function __construct($table_column, $nicename, $nullable) |
|
36 | + { |
|
37 | + parent::__construct($table_column, $nicename, $nullable, null, 'WP_User'); |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Gets the default which is always the current user. This can't be set when initially |
|
42 | - * constructing the model field because that's done before $current_user is set |
|
43 | - * |
|
44 | - * @return mixed |
|
45 | - */ |
|
46 | - function get_default_value() |
|
47 | - { |
|
48 | - if (did_action('init')) { |
|
49 | - return get_current_user_id(); |
|
50 | - } else { |
|
51 | - EE_Error::doing_it_wrong('EE_WP_User_Field::get_default_value', |
|
52 | - __('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.', |
|
53 | - 'event_espresso'), '4.6.20'); |
|
54 | - return 1; |
|
55 | - } |
|
56 | - } |
|
40 | + /** |
|
41 | + * Gets the default which is always the current user. This can't be set when initially |
|
42 | + * constructing the model field because that's done before $current_user is set |
|
43 | + * |
|
44 | + * @return mixed |
|
45 | + */ |
|
46 | + function get_default_value() |
|
47 | + { |
|
48 | + if (did_action('init')) { |
|
49 | + return get_current_user_id(); |
|
50 | + } else { |
|
51 | + EE_Error::doing_it_wrong('EE_WP_User_Field::get_default_value', |
|
52 | + __('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.', |
|
53 | + 'event_espresso'), '4.6.20'); |
|
54 | + return 1; |
|
55 | + } |
|
56 | + } |
|
57 | 57 | } |
58 | 58 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | /** |
@@ -14,56 +14,56 @@ discard block |
||
14 | 14 | */ |
15 | 15 | class EE_Maybe_Serialized_Simple_HTML_Field extends EE_Maybe_Serialized_Text_Field |
16 | 16 | { |
17 | - /** |
|
18 | - * removes all non-basic tags when setting |
|
19 | - * |
|
20 | - * @param string $value_inputted_for_field_on_model_object |
|
21 | - * @return string |
|
22 | - */ |
|
23 | - function prepare_for_set($value_inputted_for_field_on_model_object) |
|
24 | - { |
|
25 | - return parent::prepare_for_set($this->_remove_tags($value_inputted_for_field_on_model_object)); |
|
26 | - } |
|
17 | + /** |
|
18 | + * removes all non-basic tags when setting |
|
19 | + * |
|
20 | + * @param string $value_inputted_for_field_on_model_object |
|
21 | + * @return string |
|
22 | + */ |
|
23 | + function prepare_for_set($value_inputted_for_field_on_model_object) |
|
24 | + { |
|
25 | + return parent::prepare_for_set($this->_remove_tags($value_inputted_for_field_on_model_object)); |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * Remove any non-"simple" html tags. @see EE_Simple_HTML_Field |
|
30 | - * |
|
31 | - * @param array|string $value |
|
32 | - * @return array|string |
|
33 | - */ |
|
34 | - protected function _remove_tags($value) |
|
35 | - { |
|
36 | - if (is_array($value)) { |
|
37 | - foreach ($value as $key => $v) { |
|
38 | - $value[$key] = $this->_remove_tags($v); |
|
39 | - } |
|
40 | - } elseif (is_string($value)) { |
|
41 | - $value = wp_kses("$value", $this->_get_allowed_tags()); |
|
42 | - } |
|
43 | - return $value; |
|
44 | - } |
|
28 | + /** |
|
29 | + * Remove any non-"simple" html tags. @see EE_Simple_HTML_Field |
|
30 | + * |
|
31 | + * @param array|string $value |
|
32 | + * @return array|string |
|
33 | + */ |
|
34 | + protected function _remove_tags($value) |
|
35 | + { |
|
36 | + if (is_array($value)) { |
|
37 | + foreach ($value as $key => $v) { |
|
38 | + $value[$key] = $this->_remove_tags($v); |
|
39 | + } |
|
40 | + } elseif (is_string($value)) { |
|
41 | + $value = wp_kses("$value", $this->_get_allowed_tags()); |
|
42 | + } |
|
43 | + return $value; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * In case unsafe data somehow got inserted into the database, we want to remove tags again |
|
48 | - * |
|
49 | - * @param array|string $value_found_in_db_for_model_object |
|
50 | - * @return array|string |
|
51 | - */ |
|
52 | - function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
53 | - { |
|
54 | - return $this->_remove_tags(parent::prepare_for_set_from_db($value_found_in_db_for_model_object)); |
|
55 | - } |
|
46 | + /** |
|
47 | + * In case unsafe data somehow got inserted into the database, we want to remove tags again |
|
48 | + * |
|
49 | + * @param array|string $value_found_in_db_for_model_object |
|
50 | + * @return array|string |
|
51 | + */ |
|
52 | + function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
53 | + { |
|
54 | + return $this->_remove_tags(parent::prepare_for_set_from_db($value_found_in_db_for_model_object)); |
|
55 | + } |
|
56 | 56 | |
57 | 57 | |
58 | - /** |
|
59 | - * Determines what tags to allow in this model field |
|
60 | - * |
|
61 | - * @global array $allowedtags |
|
62 | - * @return array |
|
63 | - */ |
|
64 | - function _get_allowed_tags() |
|
65 | - { |
|
66 | - return apply_filters('FHEE__EE_Maybe_Serialized_Simple_HTML_Field___get_allowed_tags', |
|
67 | - EEH_HTML::get_simple_tags(), $this); |
|
68 | - } |
|
58 | + /** |
|
59 | + * Determines what tags to allow in this model field |
|
60 | + * |
|
61 | + * @global array $allowedtags |
|
62 | + * @return array |
|
63 | + */ |
|
64 | + function _get_allowed_tags() |
|
65 | + { |
|
66 | + return apply_filters('FHEE__EE_Maybe_Serialized_Simple_HTML_Field___get_allowed_tags', |
|
67 | + EEH_HTML::get_simple_tags(), $this); |
|
68 | + } |
|
69 | 69 | } |
@@ -8,16 +8,16 @@ |
||
8 | 8 | */ |
9 | 9 | class EE_Simple_HTML_Field extends EE_Text_Field_Base |
10 | 10 | { |
11 | - /** |
|
12 | - * removes all tags when setting |
|
13 | - * |
|
14 | - * @param string $value_inputted_for_field_on_model_object |
|
15 | - * @return string |
|
16 | - */ |
|
17 | - function prepare_for_set($value_inputted_for_field_on_model_object) |
|
18 | - { |
|
19 | - $value_with_select_tags = wp_kses("$value_inputted_for_field_on_model_object", EEH_HTML::get_simple_tags()); |
|
20 | - return parent::prepare_for_set($value_with_select_tags); |
|
21 | - } |
|
11 | + /** |
|
12 | + * removes all tags when setting |
|
13 | + * |
|
14 | + * @param string $value_inputted_for_field_on_model_object |
|
15 | + * @return string |
|
16 | + */ |
|
17 | + function prepare_for_set($value_inputted_for_field_on_model_object) |
|
18 | + { |
|
19 | + $value_with_select_tags = wp_kses("$value_inputted_for_field_on_model_object", EEH_HTML::get_simple_tags()); |
|
20 | + return parent::prepare_for_set($value_with_select_tags); |
|
21 | + } |
|
22 | 22 | |
23 | 23 | } |
@@ -1,5 +1,5 @@ |
||
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 | class EE_Plain_Text_Field extends EE_Text_Field_Base |
5 | 5 | { |
@@ -3,15 +3,15 @@ |
||
3 | 3 | |
4 | 4 | class EE_Slug_Field extends EE_Text_Field_Base |
5 | 5 | { |
6 | - /** |
|
7 | - * ensures string is usable in URLs |
|
8 | - * |
|
9 | - * @param string $value_inputted_for_field_on_model_object |
|
10 | - * @return string |
|
11 | - */ |
|
12 | - function prepare_for_set($value_inputted_for_field_on_model_object) |
|
13 | - { |
|
14 | - //reminder: function prepares for use in URLs, not making human-readable. |
|
15 | - return sanitize_title($value_inputted_for_field_on_model_object); |
|
16 | - } |
|
6 | + /** |
|
7 | + * ensures string is usable in URLs |
|
8 | + * |
|
9 | + * @param string $value_inputted_for_field_on_model_object |
|
10 | + * @return string |
|
11 | + */ |
|
12 | + function prepare_for_set($value_inputted_for_field_on_model_object) |
|
13 | + { |
|
14 | + //reminder: function prepares for use in URLs, not making human-readable. |
|
15 | + return sanitize_title($value_inputted_for_field_on_model_object); |
|
16 | + } |
|
17 | 17 | } |
18 | 18 | \ No newline at end of file |
@@ -1,5 +1,5 @@ |
||
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 | class EE_Plain_Text_Field extends EE_Text_Field_Base |
5 | 5 | { |
@@ -6,22 +6,22 @@ |
||
6 | 6 | */ |
7 | 7 | class EE_Post_Content_Field extends EE_Text_Field_Base |
8 | 8 | { |
9 | - /** |
|
10 | - * removes all tags which a WP Post wouldn't allow in its content normally |
|
11 | - * |
|
12 | - * @param string $value |
|
13 | - * @return string |
|
14 | - */ |
|
15 | - function prepare_for_set($value) |
|
16 | - { |
|
17 | - if (! current_user_can('unfiltered_html')) { |
|
18 | - $value = wp_kses("$value", wp_kses_allowed_html('post')); |
|
19 | - } |
|
20 | - return parent::prepare_for_set($value); |
|
21 | - } |
|
9 | + /** |
|
10 | + * removes all tags which a WP Post wouldn't allow in its content normally |
|
11 | + * |
|
12 | + * @param string $value |
|
13 | + * @return string |
|
14 | + */ |
|
15 | + function prepare_for_set($value) |
|
16 | + { |
|
17 | + if (! current_user_can('unfiltered_html')) { |
|
18 | + $value = wp_kses("$value", wp_kses_allowed_html('post')); |
|
19 | + } |
|
20 | + return parent::prepare_for_set($value); |
|
21 | + } |
|
22 | 22 | |
23 | - function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
24 | - { |
|
25 | - return $value_found_in_db_for_model_object; |
|
26 | - } |
|
23 | + function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
24 | + { |
|
25 | + return $value_found_in_db_for_model_object; |
|
26 | + } |
|
27 | 27 | } |
28 | 28 | \ No newline at end of file |
@@ -14,7 +14,7 @@ |
||
14 | 14 | */ |
15 | 15 | function prepare_for_set($value) |
16 | 16 | { |
17 | - if (! current_user_can('unfiltered_html')) { |
|
17 | + if ( ! current_user_can('unfiltered_html')) { |
|
18 | 18 | $value = wp_kses("$value", wp_kses_allowed_html('post')); |
19 | 19 | } |
20 | 20 | return parent::prepare_for_set($value); |
@@ -3,8 +3,8 @@ |
||
3 | 3 | |
4 | 4 | class EE_DB_Only_Float_Field extends EE_DB_Only_Field_Base |
5 | 5 | { |
6 | - function get_wpdb_data_type() |
|
7 | - { |
|
8 | - return '%f'; |
|
9 | - } |
|
6 | + function get_wpdb_data_type() |
|
7 | + { |
|
8 | + return '%f'; |
|
9 | + } |
|
10 | 10 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -require_once(EE_MODELS . 'fields/EE_DB_Only_Field_Base.php'); |
|
3 | +require_once(EE_MODELS.'fields/EE_DB_Only_Field_Base.php'); |
|
4 | 4 | |
5 | 5 | class EE_DB_Only_Int_Field extends EE_DB_Only_Field_Base |
6 | 6 | { |
@@ -6,57 +6,57 @@ |
||
6 | 6 | */ |
7 | 7 | class EE_Float_Field extends EE_Model_Field_Base |
8 | 8 | { |
9 | - function get_wpdb_data_type() |
|
10 | - { |
|
11 | - return '%f'; |
|
12 | - } |
|
9 | + function get_wpdb_data_type() |
|
10 | + { |
|
11 | + return '%f'; |
|
12 | + } |
|
13 | 13 | |
14 | - /** |
|
15 | - * If provided a string, strips out number-related formatting, like commas, periods, spaces, other junk, etc. |
|
16 | - * However, treats commas and periods as thousand-separators ro decimal marks, as indicate by the config's currency. |
|
17 | - * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first. |
|
18 | - * Returns a float |
|
19 | - * |
|
20 | - * @param type $value_inputted_for_field_on_model_object |
|
21 | - * @return float |
|
22 | - */ |
|
23 | - function prepare_for_set($value_inputted_for_field_on_model_object) |
|
24 | - { |
|
14 | + /** |
|
15 | + * If provided a string, strips out number-related formatting, like commas, periods, spaces, other junk, etc. |
|
16 | + * However, treats commas and periods as thousand-separators ro decimal marks, as indicate by the config's currency. |
|
17 | + * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first. |
|
18 | + * Returns a float |
|
19 | + * |
|
20 | + * @param type $value_inputted_for_field_on_model_object |
|
21 | + * @return float |
|
22 | + */ |
|
23 | + function prepare_for_set($value_inputted_for_field_on_model_object) |
|
24 | + { |
|
25 | 25 | // echo __LINE__."$value_inputted_for_field_on_model_object<br>"; |
26 | - //remove whitespaces and thousands separators |
|
27 | - if (is_string($value_inputted_for_field_on_model_object)) { |
|
28 | - $value_inputted_for_field_on_model_object = str_replace(array(" ", EE_Config::instance()->currency->thsnds), |
|
29 | - "", $value_inputted_for_field_on_model_object); |
|
26 | + //remove whitespaces and thousands separators |
|
27 | + if (is_string($value_inputted_for_field_on_model_object)) { |
|
28 | + $value_inputted_for_field_on_model_object = str_replace(array(" ", EE_Config::instance()->currency->thsnds), |
|
29 | + "", $value_inputted_for_field_on_model_object); |
|
30 | 30 | //echo __LINE__."$value_inputted_for_field_on_model_object<br>"; |
31 | 31 | //normalize it so periods are decimal marks (we don't care where you're from: we're talking PHP now) |
32 | - $value_inputted_for_field_on_model_object = str_replace(EE_Config::instance()->currency->dec_mrk, ".", |
|
33 | - $value_inputted_for_field_on_model_object); |
|
32 | + $value_inputted_for_field_on_model_object = str_replace(EE_Config::instance()->currency->dec_mrk, ".", |
|
33 | + $value_inputted_for_field_on_model_object); |
|
34 | 34 | //echo __LINE__."$value_inputted_for_field_on_model_object<br>"; |
35 | 35 | //double-check there's absolutely nothing left on this string besides numbers |
36 | - $value_inputted_for_field_on_model_object = preg_replace("/[^0-9,.]/", "", |
|
37 | - $value_inputted_for_field_on_model_object); |
|
38 | - } |
|
36 | + $value_inputted_for_field_on_model_object = preg_replace("/[^0-9,.]/", "", |
|
37 | + $value_inputted_for_field_on_model_object); |
|
38 | + } |
|
39 | 39 | // echo __LINE__."$value_inputted_for_field_on_model_object<br>"; |
40 | - return floatval($value_inputted_for_field_on_model_object); |
|
41 | - } |
|
40 | + return floatval($value_inputted_for_field_on_model_object); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * Returns the number formatted according to local custom (set by the country of the blog). |
|
45 | - * |
|
46 | - * @param float $value_on_field_to_be_outputted |
|
47 | - * @return string |
|
48 | - */ |
|
49 | - function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
50 | - { |
|
51 | - $EE = EE_Registry::instance(); |
|
52 | - return number_format($value_on_field_to_be_outputted, $EE->CFG->currency->dec_plc, $EE->CFG->currency->dec_mrk, |
|
53 | - $EE->CFG->currency->thsnds); |
|
54 | - } |
|
43 | + /** |
|
44 | + * Returns the number formatted according to local custom (set by the country of the blog). |
|
45 | + * |
|
46 | + * @param float $value_on_field_to_be_outputted |
|
47 | + * @return string |
|
48 | + */ |
|
49 | + function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
50 | + { |
|
51 | + $EE = EE_Registry::instance(); |
|
52 | + return number_format($value_on_field_to_be_outputted, $EE->CFG->currency->dec_plc, $EE->CFG->currency->dec_mrk, |
|
53 | + $EE->CFG->currency->thsnds); |
|
54 | + } |
|
55 | 55 | |
56 | - function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
57 | - { |
|
56 | + function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
57 | + { |
|
58 | 58 | // echo "prepare for set from db of ";d($value_found_in_db_for_model_object); |
59 | - return floatval($value_found_in_db_for_model_object); |
|
60 | - } |
|
59 | + return floatval($value_found_in_db_for_model_object); |
|
60 | + } |
|
61 | 61 | |
62 | 62 | } |
63 | 63 | \ No newline at end of file |