@@ -18,56 +18,56 @@ |
||
18 | 18 | class EEM_Post_Meta extends EEM_Base |
19 | 19 | { |
20 | 20 | |
21 | - // private instance of the EE_Post_Meta object |
|
22 | - protected static $_instance = null; |
|
21 | + // private instance of the EE_Post_Meta object |
|
22 | + protected static $_instance = null; |
|
23 | 23 | |
24 | 24 | |
25 | 25 | |
26 | - protected function __construct($timezone = null) |
|
27 | - { |
|
28 | - $this->singular_item = __('Post Meta', 'event_espresso'); |
|
29 | - $this->plural_item = __('Post Metas', 'event_espresso'); |
|
30 | - $this->_tables = array( |
|
31 | - 'Post_Meta' => new EE_Primary_Table('postmeta', 'meta_id'), |
|
32 | - ); |
|
33 | - $models_this_can_attach_to = array_keys(EE_Registry::instance()->cpt_models()); |
|
34 | - $this->_fields = array( |
|
35 | - 'Post_Meta' => array( |
|
36 | - 'meta_id' => new EE_Primary_Key_Int_Field( |
|
37 | - 'meta_id', |
|
38 | - __("Meta ID", "event_espresso") |
|
39 | - ), |
|
40 | - 'post_id' => new EE_Foreign_Key_Int_Field( |
|
41 | - 'post_id', |
|
42 | - __("Primary Key of Post", "event_espresso"), |
|
43 | - false, |
|
44 | - 0, |
|
45 | - $models_this_can_attach_to |
|
46 | - ), |
|
47 | - 'meta_key' => new EE_Plain_Text_Field( |
|
48 | - 'meta_key', |
|
49 | - __("Meta Key", "event_espresso"), |
|
50 | - false, |
|
51 | - '' |
|
52 | - ), |
|
53 | - 'meta_value' => new EE_Maybe_Serialized_Text_Field( |
|
54 | - 'meta_value', |
|
55 | - __("Meta Value", "event_espresso"), |
|
56 | - true |
|
57 | - ), |
|
58 | - ), |
|
59 | - ); |
|
60 | - $this->_model_relations = array(); |
|
61 | - foreach ($models_this_can_attach_to as $model) { |
|
62 | - $this->_model_relations[ $model ] = new EE_Belongs_To_Relation(); |
|
63 | - } |
|
64 | - $this->_wp_core_model = true; |
|
65 | - foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) { |
|
66 | - $this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta( |
|
67 | - 'meta_key', |
|
68 | - 'meta_value' |
|
69 | - ); |
|
70 | - } |
|
71 | - parent::__construct($timezone); |
|
72 | - } |
|
26 | + protected function __construct($timezone = null) |
|
27 | + { |
|
28 | + $this->singular_item = __('Post Meta', 'event_espresso'); |
|
29 | + $this->plural_item = __('Post Metas', 'event_espresso'); |
|
30 | + $this->_tables = array( |
|
31 | + 'Post_Meta' => new EE_Primary_Table('postmeta', 'meta_id'), |
|
32 | + ); |
|
33 | + $models_this_can_attach_to = array_keys(EE_Registry::instance()->cpt_models()); |
|
34 | + $this->_fields = array( |
|
35 | + 'Post_Meta' => array( |
|
36 | + 'meta_id' => new EE_Primary_Key_Int_Field( |
|
37 | + 'meta_id', |
|
38 | + __("Meta ID", "event_espresso") |
|
39 | + ), |
|
40 | + 'post_id' => new EE_Foreign_Key_Int_Field( |
|
41 | + 'post_id', |
|
42 | + __("Primary Key of Post", "event_espresso"), |
|
43 | + false, |
|
44 | + 0, |
|
45 | + $models_this_can_attach_to |
|
46 | + ), |
|
47 | + 'meta_key' => new EE_Plain_Text_Field( |
|
48 | + 'meta_key', |
|
49 | + __("Meta Key", "event_espresso"), |
|
50 | + false, |
|
51 | + '' |
|
52 | + ), |
|
53 | + 'meta_value' => new EE_Maybe_Serialized_Text_Field( |
|
54 | + 'meta_value', |
|
55 | + __("Meta Value", "event_espresso"), |
|
56 | + true |
|
57 | + ), |
|
58 | + ), |
|
59 | + ); |
|
60 | + $this->_model_relations = array(); |
|
61 | + foreach ($models_this_can_attach_to as $model) { |
|
62 | + $this->_model_relations[ $model ] = new EE_Belongs_To_Relation(); |
|
63 | + } |
|
64 | + $this->_wp_core_model = true; |
|
65 | + foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) { |
|
66 | + $this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta( |
|
67 | + 'meta_key', |
|
68 | + 'meta_value' |
|
69 | + ); |
|
70 | + } |
|
71 | + parent::__construct($timezone); |
|
72 | + } |
|
73 | 73 | } |
@@ -59,11 +59,11 @@ |
||
59 | 59 | ); |
60 | 60 | $this->_model_relations = array(); |
61 | 61 | foreach ($models_this_can_attach_to as $model) { |
62 | - $this->_model_relations[ $model ] = new EE_Belongs_To_Relation(); |
|
62 | + $this->_model_relations[$model] = new EE_Belongs_To_Relation(); |
|
63 | 63 | } |
64 | 64 | $this->_wp_core_model = true; |
65 | 65 | foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) { |
66 | - $this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta( |
|
66 | + $this->_cap_restriction_generators[$cap_context] = new EE_Restriction_Generator_Meta( |
|
67 | 67 | 'meta_key', |
68 | 68 | 'meta_value' |
69 | 69 | ); |
@@ -7,77 +7,77 @@ |
||
7 | 7 | class EE_Float_Field extends EE_Model_Field_Base |
8 | 8 | { |
9 | 9 | |
10 | - /** |
|
11 | - * @param string $table_column |
|
12 | - * @param string $nicename |
|
13 | - * @param bool $nullable |
|
14 | - * @param null $default_value |
|
15 | - */ |
|
16 | - public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
17 | - { |
|
18 | - parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
19 | - $this->setSchemaType('number'); |
|
20 | - } |
|
10 | + /** |
|
11 | + * @param string $table_column |
|
12 | + * @param string $nicename |
|
13 | + * @param bool $nullable |
|
14 | + * @param null $default_value |
|
15 | + */ |
|
16 | + public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
17 | + { |
|
18 | + parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
19 | + $this->setSchemaType('number'); |
|
20 | + } |
|
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * If provided a string, strips out number-related formatting, like commas, periods, spaces, other junk, etc. |
|
25 | - * However, treats commas and periods as thousand-separators ro decimal marks, as indicate by the config's currency. |
|
26 | - * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first. |
|
27 | - * Returns a float |
|
28 | - * |
|
29 | - * @param type $value_inputted_for_field_on_model_object |
|
30 | - * @return float |
|
31 | - */ |
|
32 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
33 | - { |
|
23 | + /** |
|
24 | + * If provided a string, strips out number-related formatting, like commas, periods, spaces, other junk, etc. |
|
25 | + * However, treats commas and periods as thousand-separators ro decimal marks, as indicate by the config's currency. |
|
26 | + * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first. |
|
27 | + * Returns a float |
|
28 | + * |
|
29 | + * @param type $value_inputted_for_field_on_model_object |
|
30 | + * @return float |
|
31 | + */ |
|
32 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
33 | + { |
|
34 | 34 | // echo __LINE__."$value_inputted_for_field_on_model_object<br>"; |
35 | - // remove whitespaces and thousands separators |
|
36 | - if (is_string($value_inputted_for_field_on_model_object)) { |
|
37 | - $value_inputted_for_field_on_model_object = str_replace( |
|
38 | - array(" ", EE_Config::instance()->currency->thsnds), |
|
39 | - "", |
|
40 | - $value_inputted_for_field_on_model_object |
|
41 | - ); |
|
35 | + // remove whitespaces and thousands separators |
|
36 | + if (is_string($value_inputted_for_field_on_model_object)) { |
|
37 | + $value_inputted_for_field_on_model_object = str_replace( |
|
38 | + array(" ", EE_Config::instance()->currency->thsnds), |
|
39 | + "", |
|
40 | + $value_inputted_for_field_on_model_object |
|
41 | + ); |
|
42 | 42 | // echo __LINE__."$value_inputted_for_field_on_model_object<br>"; |
43 | 43 | // normalize it so periods are decimal marks (we don't care where you're from: we're talking PHP now) |
44 | - $value_inputted_for_field_on_model_object = str_replace( |
|
45 | - EE_Config::instance()->currency->dec_mrk, |
|
46 | - ".", |
|
47 | - $value_inputted_for_field_on_model_object |
|
48 | - ); |
|
44 | + $value_inputted_for_field_on_model_object = str_replace( |
|
45 | + EE_Config::instance()->currency->dec_mrk, |
|
46 | + ".", |
|
47 | + $value_inputted_for_field_on_model_object |
|
48 | + ); |
|
49 | 49 | // echo __LINE__."$value_inputted_for_field_on_model_object<br>"; |
50 | 50 | // double-check there's absolutely nothing left on this string besides numbers |
51 | - $value_inputted_for_field_on_model_object = preg_replace( |
|
52 | - "/[^0-9,.]/", |
|
53 | - "", |
|
54 | - $value_inputted_for_field_on_model_object |
|
55 | - ); |
|
56 | - } |
|
51 | + $value_inputted_for_field_on_model_object = preg_replace( |
|
52 | + "/[^0-9,.]/", |
|
53 | + "", |
|
54 | + $value_inputted_for_field_on_model_object |
|
55 | + ); |
|
56 | + } |
|
57 | 57 | // echo __LINE__."$value_inputted_for_field_on_model_object<br>"; |
58 | - return floatval($value_inputted_for_field_on_model_object); |
|
59 | - } |
|
58 | + return floatval($value_inputted_for_field_on_model_object); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * Returns the number formatted according to local custom (set by the country of the blog). |
|
63 | - * |
|
64 | - * @param float $value_on_field_to_be_outputted |
|
65 | - * @return string |
|
66 | - */ |
|
67 | - public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
68 | - { |
|
69 | - $EE = EE_Registry::instance(); |
|
70 | - return number_format( |
|
71 | - $value_on_field_to_be_outputted, |
|
72 | - $EE->CFG->currency->dec_plc, |
|
73 | - $EE->CFG->currency->dec_mrk, |
|
74 | - $EE->CFG->currency->thsnds |
|
75 | - ); |
|
76 | - } |
|
61 | + /** |
|
62 | + * Returns the number formatted according to local custom (set by the country of the blog). |
|
63 | + * |
|
64 | + * @param float $value_on_field_to_be_outputted |
|
65 | + * @return string |
|
66 | + */ |
|
67 | + public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
68 | + { |
|
69 | + $EE = EE_Registry::instance(); |
|
70 | + return number_format( |
|
71 | + $value_on_field_to_be_outputted, |
|
72 | + $EE->CFG->currency->dec_plc, |
|
73 | + $EE->CFG->currency->dec_mrk, |
|
74 | + $EE->CFG->currency->thsnds |
|
75 | + ); |
|
76 | + } |
|
77 | 77 | |
78 | - public function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
79 | - { |
|
78 | + public function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
79 | + { |
|
80 | 80 | // echo "prepare for set from db of ";d($value_found_in_db_for_model_object); |
81 | - return floatval($value_found_in_db_for_model_object); |
|
82 | - } |
|
81 | + return floatval($value_found_in_db_for_model_object); |
|
82 | + } |
|
83 | 83 | } |
@@ -6,14 +6,14 @@ |
||
6 | 6 | */ |
7 | 7 | class EE_All_Caps_Text_Field extends EE_Text_Field_Base |
8 | 8 | { |
9 | - /** |
|
10 | - * makes it all upper case, and key-like |
|
11 | - * |
|
12 | - * @param string $value_inputted_for_field_on_model_object |
|
13 | - * @return string |
|
14 | - */ |
|
15 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
16 | - { |
|
17 | - return strtoupper(sanitize_key($value_inputted_for_field_on_model_object)); |
|
18 | - } |
|
9 | + /** |
|
10 | + * makes it all upper case, and key-like |
|
11 | + * |
|
12 | + * @param string $value_inputted_for_field_on_model_object |
|
13 | + * @return string |
|
14 | + */ |
|
15 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
16 | + { |
|
17 | + return strtoupper(sanitize_key($value_inputted_for_field_on_model_object)); |
|
18 | + } |
|
19 | 19 | } |
@@ -7,49 +7,49 @@ |
||
7 | 7 | abstract class EE_Text_Field_Base extends EE_Model_Field_Base |
8 | 8 | { |
9 | 9 | |
10 | - /** |
|
11 | - * Gets the value in the format expected when being set. |
|
12 | - * For display on the front-end, usually you would use prepare_for_pretty_echoing() instead. |
|
13 | - * @param mixed $value_of_field_on_model_object |
|
14 | - * @return mixed|string |
|
15 | - */ |
|
16 | - public function prepare_for_get($value_of_field_on_model_object) |
|
17 | - { |
|
18 | - return $value_of_field_on_model_object; |
|
19 | - } |
|
10 | + /** |
|
11 | + * Gets the value in the format expected when being set. |
|
12 | + * For display on the front-end, usually you would use prepare_for_pretty_echoing() instead. |
|
13 | + * @param mixed $value_of_field_on_model_object |
|
14 | + * @return mixed|string |
|
15 | + */ |
|
16 | + public function prepare_for_get($value_of_field_on_model_object) |
|
17 | + { |
|
18 | + return $value_of_field_on_model_object; |
|
19 | + } |
|
20 | 20 | |
21 | - /** |
|
22 | - * Accepts schema of 'form_input' which formats the string for echoing in form input's value. |
|
23 | - * |
|
24 | - * @param string $value_on_field_to_be_outputted |
|
25 | - * @param string $schema |
|
26 | - * @return string |
|
27 | - */ |
|
28 | - public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
29 | - { |
|
30 | - if ($schema === 'form_input') { |
|
31 | - $value_on_field_to_be_outputted = (string) htmlentities( |
|
32 | - $value_on_field_to_be_outputted, |
|
33 | - ENT_QUOTES, |
|
34 | - 'UTF-8' |
|
35 | - ); |
|
36 | - } |
|
37 | - return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted); |
|
38 | - } |
|
21 | + /** |
|
22 | + * Accepts schema of 'form_input' which formats the string for echoing in form input's value. |
|
23 | + * |
|
24 | + * @param string $value_on_field_to_be_outputted |
|
25 | + * @param string $schema |
|
26 | + * @return string |
|
27 | + */ |
|
28 | + public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
29 | + { |
|
30 | + if ($schema === 'form_input') { |
|
31 | + $value_on_field_to_be_outputted = (string) htmlentities( |
|
32 | + $value_on_field_to_be_outputted, |
|
33 | + ENT_QUOTES, |
|
34 | + 'UTF-8' |
|
35 | + ); |
|
36 | + } |
|
37 | + return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted); |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Data received from the user should be exactly as they hope to save it in the DB, with the exception that |
|
42 | - * quotes need to have slashes added to it. This method takes care of removing the slashes added by WP |
|
43 | - * in magic-quotes fashion. We used to call html_entity_decode on the value here, |
|
44 | - * because we called htmlentities when in EE_Text_Field_Base::prepare_for_pretty_echoing, but that's not necessary |
|
45 | - * because web browsers always decode HTML entities in element attributes, like a form element's value attribute. |
|
46 | - * So if we do it again here, we'll be removing HTML entities the user intended to have.) |
|
47 | - * |
|
48 | - * @param string $value_inputted_for_field_on_model_object |
|
49 | - * @return string |
|
50 | - */ |
|
51 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
52 | - { |
|
53 | - return stripslashes(parent::prepare_for_set($value_inputted_for_field_on_model_object)); |
|
54 | - } |
|
40 | + /** |
|
41 | + * Data received from the user should be exactly as they hope to save it in the DB, with the exception that |
|
42 | + * quotes need to have slashes added to it. This method takes care of removing the slashes added by WP |
|
43 | + * in magic-quotes fashion. We used to call html_entity_decode on the value here, |
|
44 | + * because we called htmlentities when in EE_Text_Field_Base::prepare_for_pretty_echoing, but that's not necessary |
|
45 | + * because web browsers always decode HTML entities in element attributes, like a form element's value attribute. |
|
46 | + * So if we do it again here, we'll be removing HTML entities the user intended to have.) |
|
47 | + * |
|
48 | + * @param string $value_inputted_for_field_on_model_object |
|
49 | + * @return string |
|
50 | + */ |
|
51 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
52 | + { |
|
53 | + return stripslashes(parent::prepare_for_set($value_inputted_for_field_on_model_object)); |
|
54 | + } |
|
55 | 55 | } |
@@ -12,39 +12,39 @@ |
||
12 | 12 | */ |
13 | 13 | class EE_WP_User_Field extends EE_Foreign_Key_Int_Field |
14 | 14 | { |
15 | - /** |
|
16 | - * No need to provide a default or the model pointed to- the default is |
|
17 | - * always get_current_user_id() and the model pointed to is always WP_User |
|
18 | - * |
|
19 | - * @param string $table_column name fo column for field |
|
20 | - * @param string $nicename should eb internationalized with __('blah','event_espresso') |
|
21 | - * @param boolean $nullable |
|
22 | - */ |
|
23 | - public function __construct($table_column, $nicename, $nullable) |
|
24 | - { |
|
25 | - parent::__construct($table_column, $nicename, $nullable, null, 'WP_User'); |
|
26 | - } |
|
15 | + /** |
|
16 | + * No need to provide a default or the model pointed to- the default is |
|
17 | + * always get_current_user_id() and the model pointed to is always WP_User |
|
18 | + * |
|
19 | + * @param string $table_column name fo column for field |
|
20 | + * @param string $nicename should eb internationalized with __('blah','event_espresso') |
|
21 | + * @param boolean $nullable |
|
22 | + */ |
|
23 | + public function __construct($table_column, $nicename, $nullable) |
|
24 | + { |
|
25 | + parent::__construct($table_column, $nicename, $nullable, null, 'WP_User'); |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * Gets the default which is always the current user. This can't be set when initially |
|
30 | - * constructing the model field because that's done before $current_user is set |
|
31 | - * |
|
32 | - * @return mixed |
|
33 | - */ |
|
34 | - public function get_default_value() |
|
35 | - { |
|
36 | - if (did_action('init')) { |
|
37 | - return get_current_user_id(); |
|
38 | - } else { |
|
39 | - EE_Error::doing_it_wrong( |
|
40 | - 'EE_WP_User_Field::get_default_value', |
|
41 | - __( |
|
42 | - '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.', |
|
43 | - 'event_espresso' |
|
44 | - ), |
|
45 | - '4.6.20' |
|
46 | - ); |
|
47 | - return 1; |
|
48 | - } |
|
49 | - } |
|
28 | + /** |
|
29 | + * Gets the default which is always the current user. This can't be set when initially |
|
30 | + * constructing the model field because that's done before $current_user is set |
|
31 | + * |
|
32 | + * @return mixed |
|
33 | + */ |
|
34 | + public function get_default_value() |
|
35 | + { |
|
36 | + if (did_action('init')) { |
|
37 | + return get_current_user_id(); |
|
38 | + } else { |
|
39 | + EE_Error::doing_it_wrong( |
|
40 | + 'EE_WP_User_Field::get_default_value', |
|
41 | + __( |
|
42 | + '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.', |
|
43 | + 'event_espresso' |
|
44 | + ), |
|
45 | + '4.6.20' |
|
46 | + ); |
|
47 | + return 1; |
|
48 | + } |
|
49 | + } |
|
50 | 50 | } |
@@ -10,77 +10,77 @@ |
||
10 | 10 | class EE_Infinite_Integer_Field extends EE_Model_Field_Base |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * @param string $table_column |
|
15 | - * @param string $nicename |
|
16 | - * @param bool $nullable |
|
17 | - * @param null $default_value |
|
18 | - */ |
|
19 | - public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
20 | - { |
|
21 | - parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
22 | - $this->setSchemaType(array('integer', 'null')); |
|
23 | - } |
|
13 | + /** |
|
14 | + * @param string $table_column |
|
15 | + * @param string $nicename |
|
16 | + * @param bool $nullable |
|
17 | + * @param null $default_value |
|
18 | + */ |
|
19 | + public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
20 | + { |
|
21 | + parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
22 | + $this->setSchemaType(array('integer', 'null')); |
|
23 | + } |
|
24 | 24 | |
25 | 25 | |
26 | - public function prepare_for_use_in_db($value_of_field_on_model_object) |
|
27 | - { |
|
28 | - if ($value_of_field_on_model_object === EE_INF) { |
|
29 | - return EE_INF_IN_DB; |
|
30 | - } else { |
|
31 | - return intval($value_of_field_on_model_object); |
|
32 | - } |
|
33 | - } |
|
26 | + public function prepare_for_use_in_db($value_of_field_on_model_object) |
|
27 | + { |
|
28 | + if ($value_of_field_on_model_object === EE_INF) { |
|
29 | + return EE_INF_IN_DB; |
|
30 | + } else { |
|
31 | + return intval($value_of_field_on_model_object); |
|
32 | + } |
|
33 | + } |
|
34 | 34 | |
35 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
36 | - { |
|
37 | - if ($value_inputted_for_field_on_model_object === EE_INF_IN_DB || |
|
38 | - $value_inputted_for_field_on_model_object === EE_INF || |
|
39 | - $value_inputted_for_field_on_model_object === "EE_INF" || |
|
40 | - $value_inputted_for_field_on_model_object === "" |
|
41 | - ) { |
|
42 | - return EE_INF; |
|
43 | - } else { |
|
44 | - return intval($value_inputted_for_field_on_model_object); |
|
45 | - } |
|
46 | - } |
|
35 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
36 | + { |
|
37 | + if ($value_inputted_for_field_on_model_object === EE_INF_IN_DB || |
|
38 | + $value_inputted_for_field_on_model_object === EE_INF || |
|
39 | + $value_inputted_for_field_on_model_object === "EE_INF" || |
|
40 | + $value_inputted_for_field_on_model_object === "" |
|
41 | + ) { |
|
42 | + return EE_INF; |
|
43 | + } else { |
|
44 | + return intval($value_inputted_for_field_on_model_object); |
|
45 | + } |
|
46 | + } |
|
47 | 47 | |
48 | - public function prepare_for_set_from_db($value_inputted_for_field_on_model_object) |
|
49 | - { |
|
50 | - $intval = intval($value_inputted_for_field_on_model_object); |
|
51 | - if ($intval == EE_INF_IN_DB) { |
|
52 | - return EE_INF; |
|
53 | - } else { |
|
54 | - return $intval; |
|
55 | - } |
|
56 | - } |
|
48 | + public function prepare_for_set_from_db($value_inputted_for_field_on_model_object) |
|
49 | + { |
|
50 | + $intval = intval($value_inputted_for_field_on_model_object); |
|
51 | + if ($intval == EE_INF_IN_DB) { |
|
52 | + return EE_INF; |
|
53 | + } else { |
|
54 | + return $intval; |
|
55 | + } |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * For outputting this field's value. If you want to output it into an input or something, |
|
60 | - * use $schema=='input', as it will replace EE_INF with ''. If you want a readable version, use $schema=='text' |
|
61 | - * as it will replace EE_INF with i18n Infinite |
|
62 | - * |
|
63 | - * @param type $value_on_field_to_be_outputted |
|
64 | - * @param string $schema input, symbol, text; or any string you want to show if the value equals EE_INF |
|
65 | - * @return string |
|
66 | - */ |
|
67 | - public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
68 | - { |
|
69 | - if ($value_on_field_to_be_outputted === EE_INF) { |
|
70 | - switch ($schema) { |
|
71 | - case 'input': |
|
72 | - case 'form_input': |
|
73 | - return ''; |
|
74 | - case 'symbol': |
|
75 | - return "∞"; |
|
76 | - case 'text': |
|
77 | - case null: |
|
78 | - return __("Unlimited", "event_espresso"); |
|
79 | - default: |
|
80 | - return $schema; |
|
81 | - } |
|
82 | - } else { |
|
83 | - return $value_on_field_to_be_outputted; |
|
84 | - } |
|
85 | - } |
|
58 | + /** |
|
59 | + * For outputting this field's value. If you want to output it into an input or something, |
|
60 | + * use $schema=='input', as it will replace EE_INF with ''. If you want a readable version, use $schema=='text' |
|
61 | + * as it will replace EE_INF with i18n Infinite |
|
62 | + * |
|
63 | + * @param type $value_on_field_to_be_outputted |
|
64 | + * @param string $schema input, symbol, text; or any string you want to show if the value equals EE_INF |
|
65 | + * @return string |
|
66 | + */ |
|
67 | + public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
68 | + { |
|
69 | + if ($value_on_field_to_be_outputted === EE_INF) { |
|
70 | + switch ($schema) { |
|
71 | + case 'input': |
|
72 | + case 'form_input': |
|
73 | + return ''; |
|
74 | + case 'symbol': |
|
75 | + return "∞"; |
|
76 | + case 'text': |
|
77 | + case null: |
|
78 | + return __("Unlimited", "event_espresso"); |
|
79 | + default: |
|
80 | + return $schema; |
|
81 | + } |
|
82 | + } else { |
|
83 | + return $value_on_field_to_be_outputted; |
|
84 | + } |
|
85 | + } |
|
86 | 86 | } |
@@ -2,15 +2,15 @@ |
||
2 | 2 | |
3 | 3 | class EE_Slug_Field extends EE_Text_Field_Base |
4 | 4 | { |
5 | - /** |
|
6 | - * ensures string is usable in URLs |
|
7 | - * |
|
8 | - * @param string $value_inputted_for_field_on_model_object |
|
9 | - * @return string |
|
10 | - */ |
|
11 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
12 | - { |
|
13 | - // reminder: function prepares for use in URLs, not making human-readable. |
|
14 | - return sanitize_title($value_inputted_for_field_on_model_object); |
|
15 | - } |
|
5 | + /** |
|
6 | + * ensures string is usable in URLs |
|
7 | + * |
|
8 | + * @param string $value_inputted_for_field_on_model_object |
|
9 | + * @return string |
|
10 | + */ |
|
11 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
12 | + { |
|
13 | + // reminder: function prepares for use in URLs, not making human-readable. |
|
14 | + return sanitize_title($value_inputted_for_field_on_model_object); |
|
15 | + } |
|
16 | 16 | } |
@@ -3,27 +3,27 @@ |
||
3 | 3 | class EE_Primary_Key_Int_Field extends EE_Primary_Key_Field_Base |
4 | 4 | { |
5 | 5 | |
6 | - public function __construct($table_column, $nicename) |
|
7 | - { |
|
8 | - parent::__construct($table_column, $nicename, 0); |
|
9 | - $this->setSchemaType('integer'); |
|
10 | - } |
|
6 | + public function __construct($table_column, $nicename) |
|
7 | + { |
|
8 | + parent::__construct($table_column, $nicename, 0); |
|
9 | + $this->setSchemaType('integer'); |
|
10 | + } |
|
11 | 11 | |
12 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
13 | - { |
|
14 | - if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
15 | - $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
16 | - } |
|
17 | - return absint($value_inputted_for_field_on_model_object); |
|
18 | - } |
|
12 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
13 | + { |
|
14 | + if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
15 | + $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
16 | + } |
|
17 | + return absint($value_inputted_for_field_on_model_object); |
|
18 | + } |
|
19 | 19 | |
20 | - public function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
21 | - { |
|
22 | - return intval($value_found_in_db_for_model_object); |
|
23 | - } |
|
20 | + public function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
21 | + { |
|
22 | + return intval($value_found_in_db_for_model_object); |
|
23 | + } |
|
24 | 24 | |
25 | - public function is_auto_increment() |
|
26 | - { |
|
27 | - return true; |
|
28 | - } |
|
25 | + public function is_auto_increment() |
|
26 | + { |
|
27 | + return true; |
|
28 | + } |
|
29 | 29 | } |
@@ -5,12 +5,12 @@ |
||
5 | 5 | */ |
6 | 6 | class EE_WP_Post_Type_Field extends EE_DB_Only_Text_Field |
7 | 7 | { |
8 | - /** |
|
9 | - * @param string $post_type the exact string to be used for the post type |
|
10 | - * of all these post type model objects/rows |
|
11 | - */ |
|
12 | - public function __construct($post_type) |
|
13 | - { |
|
14 | - parent::__construct('post_type', __("Post Type", 'event_espresso'), false, $post_type); |
|
15 | - } |
|
8 | + /** |
|
9 | + * @param string $post_type the exact string to be used for the post type |
|
10 | + * of all these post type model objects/rows |
|
11 | + */ |
|
12 | + public function __construct($post_type) |
|
13 | + { |
|
14 | + parent::__construct('post_type', __("Post Type", 'event_espresso'), false, $post_type); |
|
15 | + } |
|
16 | 16 | } |