@@ -7,6 +7,7 @@ |
||
7 | 7 | * |
8 | 8 | * @param string $table_column |
9 | 9 | * @param string $nicename |
10 | + * @param integer|null $default |
|
10 | 11 | */ |
11 | 12 | public function __construct($table_column, $nicename, $default) |
12 | 13 | { |
@@ -2,24 +2,24 @@ |
||
2 | 2 | |
3 | 3 | abstract class EE_Primary_Key_Field_Base extends EE_Field_With_Model_Name |
4 | 4 | { |
5 | - /** |
|
6 | - * Overrides parent so it doesn't need to provide so many non-applicable fields |
|
7 | - * |
|
8 | - * @param string $table_column |
|
9 | - * @param string $nicename |
|
10 | - */ |
|
11 | - public function __construct($table_column, $nicename, $default) |
|
12 | - { |
|
13 | - parent::__construct($table_column, $nicename, false, $default, null); |
|
14 | - } |
|
5 | + /** |
|
6 | + * Overrides parent so it doesn't need to provide so many non-applicable fields |
|
7 | + * |
|
8 | + * @param string $table_column |
|
9 | + * @param string $nicename |
|
10 | + */ |
|
11 | + public function __construct($table_column, $nicename, $default) |
|
12 | + { |
|
13 | + parent::__construct($table_column, $nicename, false, $default, null); |
|
14 | + } |
|
15 | 15 | |
16 | - /** |
|
17 | - * @param $table_alias |
|
18 | - * @param $name |
|
19 | - */ |
|
20 | - function _construct_finalize($table_alias, $name, $model_name) |
|
21 | - { |
|
22 | - $this->_model_name_pointed_to = $model_name; |
|
23 | - parent::_construct_finalize($table_alias, $name, $model_name); |
|
24 | - } |
|
16 | + /** |
|
17 | + * @param $table_alias |
|
18 | + * @param $name |
|
19 | + */ |
|
20 | + function _construct_finalize($table_alias, $name, $model_name) |
|
21 | + { |
|
22 | + $this->_model_name_pointed_to = $model_name; |
|
23 | + parent::_construct_finalize($table_alias, $name, $model_name); |
|
24 | + } |
|
25 | 25 | } |
@@ -8,6 +8,9 @@ |
||
8 | 8 | return '%s'; |
9 | 9 | } |
10 | 10 | |
11 | + /** |
|
12 | + * @param string $table_column |
|
13 | + */ |
|
11 | 14 | public function __construct($table_column, $nicename) |
12 | 15 | { |
13 | 16 | parent::__construct($table_column, $nicename, null); |
@@ -3,27 +3,27 @@ |
||
3 | 3 | |
4 | 4 | class EE_Primary_Key_String_Field extends EE_Primary_Key_Field_Base |
5 | 5 | { |
6 | - function get_wpdb_data_type() |
|
7 | - { |
|
8 | - return '%s'; |
|
9 | - } |
|
6 | + function get_wpdb_data_type() |
|
7 | + { |
|
8 | + return '%s'; |
|
9 | + } |
|
10 | 10 | |
11 | - public function __construct($table_column, $nicename) |
|
12 | - { |
|
13 | - parent::__construct($table_column, $nicename, null); |
|
14 | - } |
|
11 | + public function __construct($table_column, $nicename) |
|
12 | + { |
|
13 | + parent::__construct($table_column, $nicename, null); |
|
14 | + } |
|
15 | 15 | |
16 | - /** |
|
17 | - * removes all tags when setting |
|
18 | - * |
|
19 | - * @param string $value_inputted_for_field_on_model_object |
|
20 | - * @return string |
|
21 | - */ |
|
22 | - function prepare_for_set($value_inputted_for_field_on_model_object) |
|
23 | - { |
|
24 | - if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
25 | - $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
26 | - } |
|
27 | - return wp_strip_all_tags($value_inputted_for_field_on_model_object); |
|
28 | - } |
|
16 | + /** |
|
17 | + * removes all tags when setting |
|
18 | + * |
|
19 | + * @param string $value_inputted_for_field_on_model_object |
|
20 | + * @return string |
|
21 | + */ |
|
22 | + function prepare_for_set($value_inputted_for_field_on_model_object) |
|
23 | + { |
|
24 | + if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
25 | + $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
26 | + } |
|
27 | + return wp_strip_all_tags($value_inputted_for_field_on_model_object); |
|
28 | + } |
|
29 | 29 | } |
30 | 30 | \ No newline at end of file |
@@ -33,8 +33,6 @@ |
||
33 | 33 | * ) |
34 | 34 | * ) |
35 | 35 | * @link http://codex.wordpress.org/Function_Reference/register_post_status for more info |
36 | - * @param boolean $store_in_db_as_int By default, enums are stored as STRINGS in the DB. However, if this var is |
|
37 | - * set to true, it will be stored as an INT |
|
38 | 36 | */ |
39 | 37 | function __construct($table_column, $nicename, $nullable, $default_value, $new_stati = array()) |
40 | 38 | { |
@@ -4,116 +4,116 @@ |
||
4 | 4 | class EE_WP_Post_Status_Field extends EE_Enum_Text_Field |
5 | 5 | { |
6 | 6 | |
7 | - protected $_wp_post_stati; |
|
8 | - |
|
9 | - |
|
10 | - /** |
|
11 | - * constructor |
|
12 | - * |
|
13 | - * @param string $table_column column on table |
|
14 | - * @param string $nicename nice name for column(field) |
|
15 | - * @param bool $nullable is this field nullable |
|
16 | - * @param string $default_value default status |
|
17 | - * @param array $new_stati If additional stati are to be used other than the default WP statuses then |
|
18 | - * they can be registered via this property. The format of the array should be |
|
19 | - * as follows: array( |
|
20 | - * 'status_reference' => array( |
|
21 | - * 'label' => __('Status Reference Label', 'event_espresso') |
|
22 | - * 'public' => true, //'Whether posts of this status should be shown on the |
|
23 | - * frontend of the site' |
|
24 | - * 'exclude_from_search' => false, //'Whether posts of this status should be |
|
25 | - * excluded from wp searches' |
|
26 | - * 'show_in_admin_all_list' => true, //whether posts of this status are included |
|
27 | - * in queries for the admin "all" view in list table views. |
|
28 | - * 'show_in_admin_status_list' => true, //Show in the list of statuses with post |
|
29 | - * counts at the top of the admin list tables (i.e. Status Reference(2) ) |
|
30 | - * 'label_count' => _n_noop( 'Status Reference <span class="count">(%s)</span>', |
|
31 | - * 'Status References <span class="count">(%s)</span>' ), //the text to display |
|
32 | - * on the admin screen( or you won't see your status count ). |
|
33 | - * ) |
|
34 | - * ) |
|
35 | - * @link http://codex.wordpress.org/Function_Reference/register_post_status for more info |
|
36 | - * @param boolean $store_in_db_as_int By default, enums are stored as STRINGS in the DB. However, if this var is |
|
37 | - * set to true, it will be stored as an INT |
|
38 | - */ |
|
39 | - function __construct($table_column, $nicename, $nullable, $default_value, $new_stati = array()) |
|
40 | - { |
|
41 | - $this->_register_new_stati($new_stati); |
|
42 | - $this->_set_allowed_enum_values(); |
|
43 | - parent::__construct($table_column, $nicename, $nullable, $default_value, $this->_allowed_enum_values); |
|
44 | - } |
|
45 | - |
|
46 | - |
|
47 | - /** |
|
48 | - * This registers any new statuses sent via the $new_stati array on construct |
|
49 | - * |
|
50 | - * @access protected |
|
51 | - * @param array $new_stati statuses |
|
52 | - * @return void |
|
53 | - */ |
|
54 | - protected function _register_new_stati($new_stati) |
|
55 | - { |
|
56 | - |
|
57 | - foreach ((array)$new_stati as $status_key => $status_args) { |
|
58 | - $args = array( |
|
59 | - 'label' => isset($status_args['label']) ? $status_args['label'] : $status_key, |
|
60 | - 'public' => isset($status_args['public']) && is_bool($status_args['public']) ? $status_args['public'] : true, |
|
61 | - 'exclude_from_search' => isset($status_args['exclude_from_search']) && is_bool($status_args['exclude_from_search']) ? $status_args['exclude_from_search'] : false, |
|
62 | - 'show_in_admin_all_list' => isset($status_args['show_in_admin_all_list']) && is_bool($status_args['show_in_admin_all_list']) ? $status_args['show_in_admin_all_list'] : false, |
|
63 | - 'show_in_admin_status_list' => isset($status_args['show_in_admin_status_list']) && is_bool($status_args['show_in_admin_status_list']) ? $status_args['show_in_admin_status_list'] : true, |
|
64 | - 'label_count' => isset($status_args['label_count']) ? $status_args['label_count'] : '', |
|
65 | - ); |
|
66 | - register_post_status($status_key, $status_args); |
|
67 | - } |
|
68 | - |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * This sets the _allowed_enum_values property using the $wp_post_stati array |
|
74 | - * |
|
75 | - * @access protected |
|
76 | - * @regurn void |
|
77 | - */ |
|
78 | - protected function _set_allowed_enum_values() |
|
79 | - { |
|
80 | - //first let's get the post_statuses |
|
81 | - global $wp_post_statuses; |
|
82 | - $this->_wp_post_stati = $wp_post_statuses; |
|
83 | - |
|
84 | - foreach ($this->_wp_post_stati as $post_status => $args_object) { |
|
85 | - $this->_allowed_enum_values[$post_status] = $args_object->label; |
|
86 | - } |
|
87 | - |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * Before calling parent, first double-checks our list of acceptable post |
|
92 | - * types is up-to-date |
|
93 | - * |
|
94 | - * @param string $value_inputted_for_field_on_model_object |
|
95 | - * @return string |
|
96 | - */ |
|
97 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
98 | - { |
|
99 | - $this->_set_allowed_enum_values(); |
|
100 | - return parent::prepare_for_set($value_inputted_for_field_on_model_object); |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - |
|
105 | - //helper methods for getting various $wp_post_statuses stuff. |
|
106 | - |
|
107 | - /** |
|
108 | - * This just returns the status object for the given status |
|
109 | - * |
|
110 | - * @access public |
|
111 | - * @see wp_register_post_status in wp-includes/post.php for a list of properties of the status object |
|
112 | - * @param string $status What status object you want |
|
113 | - * @return std_object the status object or FALSE if it doesn't exist. |
|
114 | - */ |
|
115 | - public function get_status_object($status) |
|
116 | - { |
|
117 | - return isset($this->_wp_post_stati[$status]) ? $this->_wp_post_stati[$status] : false; |
|
118 | - } |
|
7 | + protected $_wp_post_stati; |
|
8 | + |
|
9 | + |
|
10 | + /** |
|
11 | + * constructor |
|
12 | + * |
|
13 | + * @param string $table_column column on table |
|
14 | + * @param string $nicename nice name for column(field) |
|
15 | + * @param bool $nullable is this field nullable |
|
16 | + * @param string $default_value default status |
|
17 | + * @param array $new_stati If additional stati are to be used other than the default WP statuses then |
|
18 | + * they can be registered via this property. The format of the array should be |
|
19 | + * as follows: array( |
|
20 | + * 'status_reference' => array( |
|
21 | + * 'label' => __('Status Reference Label', 'event_espresso') |
|
22 | + * 'public' => true, //'Whether posts of this status should be shown on the |
|
23 | + * frontend of the site' |
|
24 | + * 'exclude_from_search' => false, //'Whether posts of this status should be |
|
25 | + * excluded from wp searches' |
|
26 | + * 'show_in_admin_all_list' => true, //whether posts of this status are included |
|
27 | + * in queries for the admin "all" view in list table views. |
|
28 | + * 'show_in_admin_status_list' => true, //Show in the list of statuses with post |
|
29 | + * counts at the top of the admin list tables (i.e. Status Reference(2) ) |
|
30 | + * 'label_count' => _n_noop( 'Status Reference <span class="count">(%s)</span>', |
|
31 | + * 'Status References <span class="count">(%s)</span>' ), //the text to display |
|
32 | + * on the admin screen( or you won't see your status count ). |
|
33 | + * ) |
|
34 | + * ) |
|
35 | + * @link http://codex.wordpress.org/Function_Reference/register_post_status for more info |
|
36 | + * @param boolean $store_in_db_as_int By default, enums are stored as STRINGS in the DB. However, if this var is |
|
37 | + * set to true, it will be stored as an INT |
|
38 | + */ |
|
39 | + function __construct($table_column, $nicename, $nullable, $default_value, $new_stati = array()) |
|
40 | + { |
|
41 | + $this->_register_new_stati($new_stati); |
|
42 | + $this->_set_allowed_enum_values(); |
|
43 | + parent::__construct($table_column, $nicename, $nullable, $default_value, $this->_allowed_enum_values); |
|
44 | + } |
|
45 | + |
|
46 | + |
|
47 | + /** |
|
48 | + * This registers any new statuses sent via the $new_stati array on construct |
|
49 | + * |
|
50 | + * @access protected |
|
51 | + * @param array $new_stati statuses |
|
52 | + * @return void |
|
53 | + */ |
|
54 | + protected function _register_new_stati($new_stati) |
|
55 | + { |
|
56 | + |
|
57 | + foreach ((array)$new_stati as $status_key => $status_args) { |
|
58 | + $args = array( |
|
59 | + 'label' => isset($status_args['label']) ? $status_args['label'] : $status_key, |
|
60 | + 'public' => isset($status_args['public']) && is_bool($status_args['public']) ? $status_args['public'] : true, |
|
61 | + 'exclude_from_search' => isset($status_args['exclude_from_search']) && is_bool($status_args['exclude_from_search']) ? $status_args['exclude_from_search'] : false, |
|
62 | + 'show_in_admin_all_list' => isset($status_args['show_in_admin_all_list']) && is_bool($status_args['show_in_admin_all_list']) ? $status_args['show_in_admin_all_list'] : false, |
|
63 | + 'show_in_admin_status_list' => isset($status_args['show_in_admin_status_list']) && is_bool($status_args['show_in_admin_status_list']) ? $status_args['show_in_admin_status_list'] : true, |
|
64 | + 'label_count' => isset($status_args['label_count']) ? $status_args['label_count'] : '', |
|
65 | + ); |
|
66 | + register_post_status($status_key, $status_args); |
|
67 | + } |
|
68 | + |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * This sets the _allowed_enum_values property using the $wp_post_stati array |
|
74 | + * |
|
75 | + * @access protected |
|
76 | + * @regurn void |
|
77 | + */ |
|
78 | + protected function _set_allowed_enum_values() |
|
79 | + { |
|
80 | + //first let's get the post_statuses |
|
81 | + global $wp_post_statuses; |
|
82 | + $this->_wp_post_stati = $wp_post_statuses; |
|
83 | + |
|
84 | + foreach ($this->_wp_post_stati as $post_status => $args_object) { |
|
85 | + $this->_allowed_enum_values[$post_status] = $args_object->label; |
|
86 | + } |
|
87 | + |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * Before calling parent, first double-checks our list of acceptable post |
|
92 | + * types is up-to-date |
|
93 | + * |
|
94 | + * @param string $value_inputted_for_field_on_model_object |
|
95 | + * @return string |
|
96 | + */ |
|
97 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
98 | + { |
|
99 | + $this->_set_allowed_enum_values(); |
|
100 | + return parent::prepare_for_set($value_inputted_for_field_on_model_object); |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + |
|
105 | + //helper methods for getting various $wp_post_statuses stuff. |
|
106 | + |
|
107 | + /** |
|
108 | + * This just returns the status object for the given status |
|
109 | + * |
|
110 | + * @access public |
|
111 | + * @see wp_register_post_status in wp-includes/post.php for a list of properties of the status object |
|
112 | + * @param string $status What status object you want |
|
113 | + * @return std_object the status object or FALSE if it doesn't exist. |
|
114 | + */ |
|
115 | + public function get_status_object($status) |
|
116 | + { |
|
117 | + return isset($this->_wp_post_stati[$status]) ? $this->_wp_post_stati[$status] : false; |
|
118 | + } |
|
119 | 119 | } |
120 | 120 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -require_once(EE_MODELS . 'fields/EE_Enum_Text_Field.php'); |
|
2 | +require_once(EE_MODELS.'fields/EE_Enum_Text_Field.php'); |
|
3 | 3 | |
4 | 4 | class EE_WP_Post_Status_Field extends EE_Enum_Text_Field |
5 | 5 | { |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | protected function _register_new_stati($new_stati) |
55 | 55 | { |
56 | 56 | |
57 | - foreach ((array)$new_stati as $status_key => $status_args) { |
|
57 | + foreach ((array) $new_stati as $status_key => $status_args) { |
|
58 | 58 | $args = array( |
59 | 59 | 'label' => isset($status_args['label']) ? $status_args['label'] : $status_key, |
60 | 60 | 'public' => isset($status_args['public']) && is_bool($status_args['public']) ? $status_args['public'] : true, |
@@ -15,21 +15,21 @@ |
||
15 | 15 | { |
16 | 16 | |
17 | 17 | |
18 | - /** |
|
19 | - * Does shortcodes and auto-paragraphs the content (unless schema is 'no_wpautop') |
|
20 | - * |
|
21 | - * @param type $value_on_field_to_be_outputted |
|
22 | - * @param type $schema |
|
23 | - * @return string |
|
24 | - */ |
|
25 | - function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
26 | - { |
|
27 | - if ($schema == 'form_input') { |
|
28 | - return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema); |
|
29 | - } elseif ($schema == 'no_wpautop') { |
|
30 | - return do_shortcode(parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema)); |
|
31 | - } else { |
|
32 | - return wpautop(do_shortcode(parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema))); |
|
33 | - } |
|
34 | - } |
|
18 | + /** |
|
19 | + * Does shortcodes and auto-paragraphs the content (unless schema is 'no_wpautop') |
|
20 | + * |
|
21 | + * @param type $value_on_field_to_be_outputted |
|
22 | + * @param type $schema |
|
23 | + * @return string |
|
24 | + */ |
|
25 | + function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
26 | + { |
|
27 | + if ($schema == 'form_input') { |
|
28 | + return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema); |
|
29 | + } elseif ($schema == 'no_wpautop') { |
|
30 | + return do_shortcode(parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema)); |
|
31 | + } else { |
|
32 | + return wpautop(do_shortcode(parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema))); |
|
33 | + } |
|
34 | + } |
|
35 | 35 | } |
36 | 36 | \ No newline at end of file |
@@ -9,69 +9,69 @@ |
||
9 | 9 | */ |
10 | 10 | class EE_Infinite_Integer_Field extends EE_Model_Field_Base |
11 | 11 | { |
12 | - function get_wpdb_data_type() |
|
13 | - { |
|
14 | - return '%d'; |
|
15 | - } |
|
12 | + function get_wpdb_data_type() |
|
13 | + { |
|
14 | + return '%d'; |
|
15 | + } |
|
16 | 16 | |
17 | - function prepare_for_use_in_db($value_of_field_on_model_object) |
|
18 | - { |
|
19 | - if ($value_of_field_on_model_object === EE_INF) { |
|
20 | - return EE_INF_IN_DB; |
|
21 | - } else { |
|
22 | - return intval($value_of_field_on_model_object); |
|
23 | - } |
|
24 | - } |
|
17 | + function prepare_for_use_in_db($value_of_field_on_model_object) |
|
18 | + { |
|
19 | + if ($value_of_field_on_model_object === EE_INF) { |
|
20 | + return EE_INF_IN_DB; |
|
21 | + } else { |
|
22 | + return intval($value_of_field_on_model_object); |
|
23 | + } |
|
24 | + } |
|
25 | 25 | |
26 | - function prepare_for_set($value_inputted_for_field_on_model_object) |
|
27 | - { |
|
28 | - if ($value_inputted_for_field_on_model_object === EE_INF_IN_DB || |
|
29 | - $value_inputted_for_field_on_model_object === EE_INF || |
|
30 | - $value_inputted_for_field_on_model_object === "EE_INF" || |
|
31 | - $value_inputted_for_field_on_model_object === "" |
|
32 | - ) { |
|
33 | - return EE_INF; |
|
34 | - } else { |
|
35 | - return intval($value_inputted_for_field_on_model_object); |
|
36 | - } |
|
37 | - } |
|
26 | + function prepare_for_set($value_inputted_for_field_on_model_object) |
|
27 | + { |
|
28 | + if ($value_inputted_for_field_on_model_object === EE_INF_IN_DB || |
|
29 | + $value_inputted_for_field_on_model_object === EE_INF || |
|
30 | + $value_inputted_for_field_on_model_object === "EE_INF" || |
|
31 | + $value_inputted_for_field_on_model_object === "" |
|
32 | + ) { |
|
33 | + return EE_INF; |
|
34 | + } else { |
|
35 | + return intval($value_inputted_for_field_on_model_object); |
|
36 | + } |
|
37 | + } |
|
38 | 38 | |
39 | - function prepare_for_set_from_db($value_inputted_for_field_on_model_object) |
|
40 | - { |
|
41 | - $intval = intval($value_inputted_for_field_on_model_object); |
|
42 | - if ($intval == EE_INF_IN_DB) { |
|
43 | - return EE_INF; |
|
44 | - } else { |
|
45 | - return $intval; |
|
46 | - } |
|
47 | - } |
|
39 | + function prepare_for_set_from_db($value_inputted_for_field_on_model_object) |
|
40 | + { |
|
41 | + $intval = intval($value_inputted_for_field_on_model_object); |
|
42 | + if ($intval == EE_INF_IN_DB) { |
|
43 | + return EE_INF; |
|
44 | + } else { |
|
45 | + return $intval; |
|
46 | + } |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * For outputting this field's value. If you want to output it into an input or something, |
|
51 | - * use $schema=='input', as it will replace EE_INF with ''. If you want a readable version, use $schema=='text' |
|
52 | - * as it will replace EE_INF with i18n Infinite |
|
53 | - * |
|
54 | - * @param type $value_on_field_to_be_outputted |
|
55 | - * @param string $schema input, symbol, text; or any string you want to show if the value equals EE_INF |
|
56 | - * @return string |
|
57 | - */ |
|
58 | - function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
59 | - { |
|
60 | - if ($value_on_field_to_be_outputted === EE_INF) { |
|
61 | - switch ($schema) { |
|
62 | - case 'input': |
|
63 | - case 'form_input': |
|
64 | - return ''; |
|
65 | - case 'symbol': |
|
66 | - return "∞"; |
|
67 | - case 'text': |
|
68 | - case null: |
|
69 | - return __("Unlimited", "event_espresso"); |
|
70 | - default: |
|
71 | - return $schema; |
|
72 | - } |
|
73 | - } else { |
|
74 | - return $value_on_field_to_be_outputted; |
|
75 | - } |
|
76 | - } |
|
49 | + /** |
|
50 | + * For outputting this field's value. If you want to output it into an input or something, |
|
51 | + * use $schema=='input', as it will replace EE_INF with ''. If you want a readable version, use $schema=='text' |
|
52 | + * as it will replace EE_INF with i18n Infinite |
|
53 | + * |
|
54 | + * @param type $value_on_field_to_be_outputted |
|
55 | + * @param string $schema input, symbol, text; or any string you want to show if the value equals EE_INF |
|
56 | + * @return string |
|
57 | + */ |
|
58 | + function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
59 | + { |
|
60 | + if ($value_on_field_to_be_outputted === EE_INF) { |
|
61 | + switch ($schema) { |
|
62 | + case 'input': |
|
63 | + case 'form_input': |
|
64 | + return ''; |
|
65 | + case 'symbol': |
|
66 | + return "∞"; |
|
67 | + case 'text': |
|
68 | + case null: |
|
69 | + return __("Unlimited", "event_espresso"); |
|
70 | + default: |
|
71 | + return $schema; |
|
72 | + } |
|
73 | + } else { |
|
74 | + return $value_on_field_to_be_outputted; |
|
75 | + } |
|
76 | + } |
|
77 | 77 | } |
@@ -6,63 +6,63 @@ |
||
6 | 6 | */ |
7 | 7 | class EE_Money_Field extends EE_Float_Field |
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 | - * Schemas: |
|
16 | - * 'localized_float': "3,023.00" |
|
17 | - * 'no_currency_code': "$3,023.00" |
|
18 | - * null: "$3,023.00<span>USD</span>" |
|
19 | - * |
|
20 | - * @param type $value_on_field_to_be_outputted |
|
21 | - * @param type $schema |
|
22 | - * @return string |
|
23 | - */ |
|
24 | - function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
25 | - { |
|
26 | - $pretty_float = parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted); |
|
14 | + /** |
|
15 | + * Schemas: |
|
16 | + * 'localized_float': "3,023.00" |
|
17 | + * 'no_currency_code': "$3,023.00" |
|
18 | + * null: "$3,023.00<span>USD</span>" |
|
19 | + * |
|
20 | + * @param type $value_on_field_to_be_outputted |
|
21 | + * @param type $schema |
|
22 | + * @return string |
|
23 | + */ |
|
24 | + function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
25 | + { |
|
26 | + $pretty_float = parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted); |
|
27 | 27 | |
28 | - if ($schema == 'localized_float') { |
|
29 | - return $pretty_float; |
|
30 | - } |
|
31 | - if ($schema == 'no_currency_code') { |
|
28 | + if ($schema == 'localized_float') { |
|
29 | + return $pretty_float; |
|
30 | + } |
|
31 | + if ($schema == 'no_currency_code') { |
|
32 | 32 | // echo "schema no currency!"; |
33 | - $display_code = false; |
|
34 | - } else { |
|
35 | - $display_code = true; |
|
36 | - } |
|
37 | - //we don't use the $pretty_float because format_currency will take care of it. |
|
38 | - return EEH_Template::format_currency($value_on_field_to_be_outputted, false, $display_code); |
|
39 | - } |
|
33 | + $display_code = false; |
|
34 | + } else { |
|
35 | + $display_code = true; |
|
36 | + } |
|
37 | + //we don't use the $pretty_float because format_currency will take care of it. |
|
38 | + return EEH_Template::format_currency($value_on_field_to_be_outputted, false, $display_code); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * If provided witha string, strips out money-related formatting to turn it into a proper float. |
|
43 | - * Rounds the float to the correct number of decimal places for this country's currency. |
|
44 | - * Also, interprets periods and commas according to the country's currency settings. |
|
45 | - * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first. |
|
46 | - * |
|
47 | - * @param type $value_inputted_for_field_on_model_object |
|
48 | - * @return float |
|
49 | - */ |
|
50 | - function prepare_for_set($value_inputted_for_field_on_model_object) |
|
51 | - { |
|
52 | - //remove any currencies etc. |
|
41 | + /** |
|
42 | + * If provided witha string, strips out money-related formatting to turn it into a proper float. |
|
43 | + * Rounds the float to the correct number of decimal places for this country's currency. |
|
44 | + * Also, interprets periods and commas according to the country's currency settings. |
|
45 | + * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first. |
|
46 | + * |
|
47 | + * @param type $value_inputted_for_field_on_model_object |
|
48 | + * @return float |
|
49 | + */ |
|
50 | + function prepare_for_set($value_inputted_for_field_on_model_object) |
|
51 | + { |
|
52 | + //remove any currencies etc. |
|
53 | 53 | // if(is_string($value_inputted_for_field_on_model_object)){ |
54 | 54 | // $value_inputted_for_field_on_model_object = preg_replace("/[^0-9,.]/", "", $value_inputted_for_field_on_model_object); |
55 | 55 | // } |
56 | - //now it's a float-style string or number |
|
57 | - $float_val = parent::prepare_for_set($value_inputted_for_field_on_model_object); |
|
58 | - //round to the correctly number of decimal places for this currency |
|
59 | - $rounded_value = round($float_val, EE_Registry::instance()->CFG->currency->dec_plc); |
|
60 | - return $rounded_value; |
|
61 | - } |
|
56 | + //now it's a float-style string or number |
|
57 | + $float_val = parent::prepare_for_set($value_inputted_for_field_on_model_object); |
|
58 | + //round to the correctly number of decimal places for this currency |
|
59 | + $rounded_value = round($float_val, EE_Registry::instance()->CFG->currency->dec_plc); |
|
60 | + return $rounded_value; |
|
61 | + } |
|
62 | 62 | |
63 | - function prepare_for_get($value_of_field_on_model_object) |
|
64 | - { |
|
65 | - $c = EE_Registry::instance()->CFG->currency; |
|
66 | - return round(parent::prepare_for_get($value_of_field_on_model_object), $c->dec_plc); |
|
67 | - } |
|
63 | + function prepare_for_get($value_of_field_on_model_object) |
|
64 | + { |
|
65 | + $c = EE_Registry::instance()->CFG->currency; |
|
66 | + return round(parent::prepare_for_get($value_of_field_on_model_object), $c->dec_plc); |
|
67 | + } |
|
68 | 68 | } |
69 | 69 | \ No newline at end of file |
@@ -3,31 +3,31 @@ |
||
3 | 3 | |
4 | 4 | class EE_Primary_Key_Int_Field extends EE_Primary_Key_Field_Base |
5 | 5 | { |
6 | - function get_wpdb_data_type() |
|
7 | - { |
|
8 | - return '%d'; |
|
9 | - } |
|
6 | + function get_wpdb_data_type() |
|
7 | + { |
|
8 | + return '%d'; |
|
9 | + } |
|
10 | 10 | |
11 | - public function __construct($table_column, $nicename) |
|
12 | - { |
|
13 | - parent::__construct($table_column, $nicename, 0); |
|
14 | - } |
|
11 | + public function __construct($table_column, $nicename) |
|
12 | + { |
|
13 | + parent::__construct($table_column, $nicename, 0); |
|
14 | + } |
|
15 | 15 | |
16 | - function prepare_for_set($value_inputted_for_field_on_model_object) |
|
17 | - { |
|
18 | - if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
19 | - $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
20 | - } |
|
21 | - return absint($value_inputted_for_field_on_model_object); |
|
22 | - } |
|
16 | + function prepare_for_set($value_inputted_for_field_on_model_object) |
|
17 | + { |
|
18 | + if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
19 | + $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
20 | + } |
|
21 | + return absint($value_inputted_for_field_on_model_object); |
|
22 | + } |
|
23 | 23 | |
24 | - function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
25 | - { |
|
26 | - return intval($value_found_in_db_for_model_object); |
|
27 | - } |
|
24 | + function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
25 | + { |
|
26 | + return intval($value_found_in_db_for_model_object); |
|
27 | + } |
|
28 | 28 | |
29 | - function is_auto_increment() |
|
30 | - { |
|
31 | - return true; |
|
32 | - } |
|
29 | + function is_auto_increment() |
|
30 | + { |
|
31 | + return true; |
|
32 | + } |
|
33 | 33 | } |
34 | 34 | \ No newline at end of file |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -require_once(EE_MODELS . 'fields/EE_Primary_Key_Field_Base.php'); |
|
2 | +require_once(EE_MODELS.'fields/EE_Primary_Key_Field_Base.php'); |
|
3 | 3 | |
4 | 4 | class EE_Primary_Key_Int_Field extends EE_Primary_Key_Field_Base |
5 | 5 | { |
@@ -8,6 +8,9 @@ |
||
8 | 8 | return '%s'; |
9 | 9 | } |
10 | 10 | |
11 | + /** |
|
12 | + * @param string $table_column |
|
13 | + */ |
|
11 | 14 | public function __construct($table_column, $nicename) |
12 | 15 | { |
13 | 16 | parent::__construct($table_column, $nicename, null); |
@@ -3,22 +3,22 @@ |
||
3 | 3 | |
4 | 4 | class EE_Foreign_Key_String_Field extends EE_Foreign_Key_Field_Base |
5 | 5 | { |
6 | - function get_wpdb_data_type() |
|
7 | - { |
|
8 | - return '%s'; |
|
9 | - } |
|
6 | + function get_wpdb_data_type() |
|
7 | + { |
|
8 | + return '%s'; |
|
9 | + } |
|
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 | - if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
20 | - $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
21 | - } |
|
22 | - return strtoupper(wp_strip_all_tags($value_inputted_for_field_on_model_object)); |
|
23 | - } |
|
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 | + if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
20 | + $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
21 | + } |
|
22 | + return strtoupper(wp_strip_all_tags($value_inputted_for_field_on_model_object)); |
|
23 | + } |
|
24 | 24 | } |
25 | 25 | \ No newline at end of file |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -require_once(EE_MODELS . 'fields/EE_Foreign_Key_Field_Base.php'); |
|
2 | +require_once(EE_MODELS.'fields/EE_Foreign_Key_Field_Base.php'); |
|
3 | 3 | |
4 | 4 | class EE_Foreign_Key_Int_Field extends EE_Foreign_Key_Field_Base |
5 | 5 | { |
@@ -3,6 +3,6 @@ |
||
3 | 3 | |
4 | 4 | class EE_Trashed_Flag_Field extends EE_Boolean_Field |
5 | 5 | { |
6 | - //note: some client code simply checks if a field IS an EE_Trashed_Flag_Field |
|
7 | - //...otherwise, these fields are mostly the same as boolean fields |
|
6 | + //note: some client code simply checks if a field IS an EE_Trashed_Flag_Field |
|
7 | + //...otherwise, these fields are mostly the same as boolean fields |
|
8 | 8 | } |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -require_once(EE_MODELS . 'fields/EE_Boolean_Field.php'); |
|
2 | +require_once(EE_MODELS.'fields/EE_Boolean_Field.php'); |
|
3 | 3 | |
4 | 4 | class EE_Trashed_Flag_Field extends EE_Boolean_Field |
5 | 5 | { |