@@ -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 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $this->_wp_post_stati = $wp_post_statuses; |
81 | 81 | |
82 | 82 | foreach ($this->_wp_post_stati as $post_status => $args_object) { |
83 | - $this->_allowed_enum_values[ $post_status ] = $args_object->label; |
|
83 | + $this->_allowed_enum_values[$post_status] = $args_object->label; |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
@@ -111,6 +111,6 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function get_status_object($status) |
113 | 113 | { |
114 | - return isset($this->_wp_post_stati[ $status ]) ? $this->_wp_post_stati[ $status ] : false; |
|
114 | + return isset($this->_wp_post_stati[$status]) ? $this->_wp_post_stati[$status] : false; |
|
115 | 115 | } |
116 | 116 | } |
@@ -3,114 +3,114 @@ |
||
3 | 3 | class EE_WP_Post_Status_Field extends EE_Enum_Text_Field |
4 | 4 | { |
5 | 5 | |
6 | - protected $_wp_post_stati; |
|
6 | + protected $_wp_post_stati; |
|
7 | 7 | |
8 | 8 | |
9 | - /** |
|
10 | - * constructor |
|
11 | - * |
|
12 | - * @param string $table_column column on table |
|
13 | - * @param string $nicename nice name for column(field) |
|
14 | - * @param bool $nullable is this field nullable |
|
15 | - * @param string $default_value default status |
|
16 | - * @param array $new_stati If additional stati are to be used other than the default WP statuses then |
|
17 | - * they can be registered via this property. The format of the array should be |
|
18 | - * as follows: array( |
|
19 | - * 'status_reference' => array( |
|
20 | - * 'label' => esc_html__('Status Reference Label', 'event_espresso') |
|
21 | - * 'public' => true, //'Whether posts of this status should be shown on the |
|
22 | - * frontend of the site' |
|
23 | - * 'exclude_from_search' => false, //'Whether posts of this status should be |
|
24 | - * excluded from wp searches' |
|
25 | - * 'show_in_admin_all_list' => true, //whether posts of this status are included |
|
26 | - * in queries for the admin "all" view in list table views. |
|
27 | - * 'show_in_admin_status_list' => true, //Show in the list of statuses with post |
|
28 | - * counts at the top of the admin list tables (i.e. Status Reference(2) ) |
|
29 | - * 'label_count' => _n_noop( 'Status Reference <span class="count">(%s)</span>', |
|
30 | - * 'Status References <span class="count">(%s)</span>' ), //the text to display |
|
31 | - * on the admin screen( or you won't see your status count ). |
|
32 | - * ) |
|
33 | - * ) |
|
34 | - * @link http://codex.wordpress.org/Function_Reference/register_post_status for more info |
|
35 | - * @param boolean $store_in_db_as_int By default, enums are stored as STRINGS in the DB. However, if this var is |
|
36 | - * set to true, it will be stored as an INT |
|
37 | - */ |
|
38 | - public function __construct($table_column, $nicename, $nullable, $default_value, $new_stati = array()) |
|
39 | - { |
|
40 | - $this->_register_new_stati($new_stati); |
|
41 | - $this->_set_allowed_enum_values(); |
|
42 | - parent::__construct($table_column, $nicename, $nullable, $default_value, $this->_allowed_enum_values); |
|
43 | - } |
|
9 | + /** |
|
10 | + * constructor |
|
11 | + * |
|
12 | + * @param string $table_column column on table |
|
13 | + * @param string $nicename nice name for column(field) |
|
14 | + * @param bool $nullable is this field nullable |
|
15 | + * @param string $default_value default status |
|
16 | + * @param array $new_stati If additional stati are to be used other than the default WP statuses then |
|
17 | + * they can be registered via this property. The format of the array should be |
|
18 | + * as follows: array( |
|
19 | + * 'status_reference' => array( |
|
20 | + * 'label' => esc_html__('Status Reference Label', 'event_espresso') |
|
21 | + * 'public' => true, //'Whether posts of this status should be shown on the |
|
22 | + * frontend of the site' |
|
23 | + * 'exclude_from_search' => false, //'Whether posts of this status should be |
|
24 | + * excluded from wp searches' |
|
25 | + * 'show_in_admin_all_list' => true, //whether posts of this status are included |
|
26 | + * in queries for the admin "all" view in list table views. |
|
27 | + * 'show_in_admin_status_list' => true, //Show in the list of statuses with post |
|
28 | + * counts at the top of the admin list tables (i.e. Status Reference(2) ) |
|
29 | + * 'label_count' => _n_noop( 'Status Reference <span class="count">(%s)</span>', |
|
30 | + * 'Status References <span class="count">(%s)</span>' ), //the text to display |
|
31 | + * on the admin screen( or you won't see your status count ). |
|
32 | + * ) |
|
33 | + * ) |
|
34 | + * @link http://codex.wordpress.org/Function_Reference/register_post_status for more info |
|
35 | + * @param boolean $store_in_db_as_int By default, enums are stored as STRINGS in the DB. However, if this var is |
|
36 | + * set to true, it will be stored as an INT |
|
37 | + */ |
|
38 | + public function __construct($table_column, $nicename, $nullable, $default_value, $new_stati = array()) |
|
39 | + { |
|
40 | + $this->_register_new_stati($new_stati); |
|
41 | + $this->_set_allowed_enum_values(); |
|
42 | + parent::__construct($table_column, $nicename, $nullable, $default_value, $this->_allowed_enum_values); |
|
43 | + } |
|
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * This registers any new statuses sent via the $new_stati array on construct |
|
48 | - * |
|
49 | - * @access protected |
|
50 | - * @param array $new_stati statuses |
|
51 | - * @return void |
|
52 | - */ |
|
53 | - protected function _register_new_stati($new_stati) |
|
54 | - { |
|
46 | + /** |
|
47 | + * This registers any new statuses sent via the $new_stati array on construct |
|
48 | + * |
|
49 | + * @access protected |
|
50 | + * @param array $new_stati statuses |
|
51 | + * @return void |
|
52 | + */ |
|
53 | + protected function _register_new_stati($new_stati) |
|
54 | + { |
|
55 | 55 | |
56 | - foreach ((array) $new_stati as $status_key => $status_args) { |
|
57 | - $args = array( |
|
58 | - 'label' => isset($status_args['label']) ? $status_args['label'] : $status_key, |
|
59 | - 'public' => isset($status_args['public']) && is_bool($status_args['public']) ? $status_args['public'] : true, |
|
60 | - 'exclude_from_search' => isset($status_args['exclude_from_search']) && is_bool($status_args['exclude_from_search']) ? $status_args['exclude_from_search'] : false, |
|
61 | - '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, |
|
62 | - '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, |
|
63 | - 'label_count' => isset($status_args['label_count']) ? $status_args['label_count'] : '', |
|
64 | - ); |
|
65 | - register_post_status($status_key, $status_args); |
|
66 | - } |
|
67 | - } |
|
56 | + foreach ((array) $new_stati as $status_key => $status_args) { |
|
57 | + $args = array( |
|
58 | + 'label' => isset($status_args['label']) ? $status_args['label'] : $status_key, |
|
59 | + 'public' => isset($status_args['public']) && is_bool($status_args['public']) ? $status_args['public'] : true, |
|
60 | + 'exclude_from_search' => isset($status_args['exclude_from_search']) && is_bool($status_args['exclude_from_search']) ? $status_args['exclude_from_search'] : false, |
|
61 | + '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, |
|
62 | + '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, |
|
63 | + 'label_count' => isset($status_args['label_count']) ? $status_args['label_count'] : '', |
|
64 | + ); |
|
65 | + register_post_status($status_key, $status_args); |
|
66 | + } |
|
67 | + } |
|
68 | 68 | |
69 | 69 | |
70 | - /** |
|
71 | - * This sets the _allowed_enum_values property using the $wp_post_stati array |
|
72 | - * |
|
73 | - * @access protected |
|
74 | - * @regurn void |
|
75 | - */ |
|
76 | - protected function _set_allowed_enum_values() |
|
77 | - { |
|
78 | - // first let's get the post_statuses |
|
79 | - global $wp_post_statuses; |
|
80 | - $this->_wp_post_stati = $wp_post_statuses; |
|
70 | + /** |
|
71 | + * This sets the _allowed_enum_values property using the $wp_post_stati array |
|
72 | + * |
|
73 | + * @access protected |
|
74 | + * @regurn void |
|
75 | + */ |
|
76 | + protected function _set_allowed_enum_values() |
|
77 | + { |
|
78 | + // first let's get the post_statuses |
|
79 | + global $wp_post_statuses; |
|
80 | + $this->_wp_post_stati = $wp_post_statuses; |
|
81 | 81 | |
82 | - foreach ($this->_wp_post_stati as $post_status => $args_object) { |
|
83 | - $this->_allowed_enum_values[ $post_status ] = $args_object->label; |
|
84 | - } |
|
85 | - } |
|
82 | + foreach ($this->_wp_post_stati as $post_status => $args_object) { |
|
83 | + $this->_allowed_enum_values[ $post_status ] = $args_object->label; |
|
84 | + } |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * Before calling parent, first double-checks our list of acceptable post |
|
89 | - * types is up-to-date |
|
90 | - * |
|
91 | - * @param string $value_inputted_for_field_on_model_object |
|
92 | - * @return string |
|
93 | - */ |
|
94 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
95 | - { |
|
96 | - $this->_set_allowed_enum_values(); |
|
97 | - return parent::prepare_for_set($value_inputted_for_field_on_model_object); |
|
98 | - } |
|
87 | + /** |
|
88 | + * Before calling parent, first double-checks our list of acceptable post |
|
89 | + * types is up-to-date |
|
90 | + * |
|
91 | + * @param string $value_inputted_for_field_on_model_object |
|
92 | + * @return string |
|
93 | + */ |
|
94 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
95 | + { |
|
96 | + $this->_set_allowed_enum_values(); |
|
97 | + return parent::prepare_for_set($value_inputted_for_field_on_model_object); |
|
98 | + } |
|
99 | 99 | |
100 | 100 | |
101 | 101 | |
102 | - // helper methods for getting various $wp_post_statuses stuff. |
|
102 | + // helper methods for getting various $wp_post_statuses stuff. |
|
103 | 103 | |
104 | - /** |
|
105 | - * This just returns the status object for the given status |
|
106 | - * |
|
107 | - * @access public |
|
108 | - * @see wp_register_post_status in wp-includes/post.php for a list of properties of the status object |
|
109 | - * @param string $status What status object you want |
|
110 | - * @return std_object the status object or FALSE if it doesn't exist. |
|
111 | - */ |
|
112 | - public function get_status_object($status) |
|
113 | - { |
|
114 | - return isset($this->_wp_post_stati[ $status ]) ? $this->_wp_post_stati[ $status ] : false; |
|
115 | - } |
|
104 | + /** |
|
105 | + * This just returns the status object for the given status |
|
106 | + * |
|
107 | + * @access public |
|
108 | + * @see wp_register_post_status in wp-includes/post.php for a list of properties of the status object |
|
109 | + * @param string $status What status object you want |
|
110 | + * @return std_object the status object or FALSE if it doesn't exist. |
|
111 | + */ |
|
112 | + public function get_status_object($status) |
|
113 | + { |
|
114 | + return isset($this->_wp_post_stati[ $status ]) ? $this->_wp_post_stati[ $status ] : false; |
|
115 | + } |
|
116 | 116 | } |
@@ -2,6 +2,6 @@ |
||
2 | 2 | |
3 | 3 | class EE_Trashed_Flag_Field extends EE_Boolean_Field |
4 | 4 | { |
5 | - // note: some client code simply checks if a field IS an EE_Trashed_Flag_Field |
|
6 | - // ...otherwise, these fields are mostly the same as boolean fields |
|
5 | + // note: some client code simply checks if a field IS an EE_Trashed_Flag_Field |
|
6 | + // ...otherwise, these fields are mostly the same as boolean fields |
|
7 | 7 | } |
@@ -6,26 +6,26 @@ |
||
6 | 6 | */ |
7 | 7 | class EE_Integer_Field extends EE_Model_Field_Base |
8 | 8 | { |
9 | - /** |
|
10 | - * @param string $table_column |
|
11 | - * @param string $nicename |
|
12 | - * @param bool $nullable |
|
13 | - * @param null $default_value |
|
14 | - */ |
|
15 | - public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
16 | - { |
|
17 | - parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
18 | - $this->setSchemaType('integer'); |
|
19 | - } |
|
9 | + /** |
|
10 | + * @param string $table_column |
|
11 | + * @param string $nicename |
|
12 | + * @param bool $nullable |
|
13 | + * @param null $default_value |
|
14 | + */ |
|
15 | + public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
16 | + { |
|
17 | + parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
18 | + $this->setSchemaType('integer'); |
|
19 | + } |
|
20 | 20 | |
21 | 21 | |
22 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
23 | - { |
|
24 | - return intval($value_inputted_for_field_on_model_object); |
|
25 | - } |
|
22 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
23 | + { |
|
24 | + return intval($value_inputted_for_field_on_model_object); |
|
25 | + } |
|
26 | 26 | |
27 | - public function prepare_for_set_from_db($value_inputted_for_field_on_model_object) |
|
28 | - { |
|
29 | - return intval($value_inputted_for_field_on_model_object); |
|
30 | - } |
|
27 | + public function prepare_for_set_from_db($value_inputted_for_field_on_model_object) |
|
28 | + { |
|
29 | + return intval($value_inputted_for_field_on_model_object); |
|
30 | + } |
|
31 | 31 | } |
@@ -2,15 +2,15 @@ |
||
2 | 2 | |
3 | 3 | class EE_DB_Only_Int_Field extends EE_DB_Only_Field_Base |
4 | 4 | { |
5 | - /** |
|
6 | - * @param string $table_column |
|
7 | - * @param string $nicename |
|
8 | - * @param bool $nullable |
|
9 | - * @param null $default_value |
|
10 | - */ |
|
11 | - public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
12 | - { |
|
13 | - parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
14 | - $this->setSchemaType('integer'); |
|
15 | - } |
|
5 | + /** |
|
6 | + * @param string $table_column |
|
7 | + * @param string $nicename |
|
8 | + * @param bool $nullable |
|
9 | + * @param null $default_value |
|
10 | + */ |
|
11 | + public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
12 | + { |
|
13 | + parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
14 | + $this->setSchemaType('integer'); |
|
15 | + } |
|
16 | 16 | } |
@@ -11,59 +11,59 @@ |
||
11 | 11 | */ |
12 | 12 | class EE_Maybe_Serialized_Simple_HTML_Field extends EE_Maybe_Serialized_Text_Field |
13 | 13 | { |
14 | - /** |
|
15 | - * removes all non-basic tags when setting |
|
16 | - * |
|
17 | - * @param string $value_inputted_for_field_on_model_object |
|
18 | - * @return string |
|
19 | - */ |
|
20 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
21 | - { |
|
22 | - return parent::prepare_for_set($this->_remove_tags($value_inputted_for_field_on_model_object)); |
|
23 | - } |
|
14 | + /** |
|
15 | + * removes all non-basic tags when setting |
|
16 | + * |
|
17 | + * @param string $value_inputted_for_field_on_model_object |
|
18 | + * @return string |
|
19 | + */ |
|
20 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
21 | + { |
|
22 | + return parent::prepare_for_set($this->_remove_tags($value_inputted_for_field_on_model_object)); |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * Remove any non-"simple" html tags. @see EE_Simple_HTML_Field |
|
27 | - * |
|
28 | - * @param array|string $value |
|
29 | - * @return array|string |
|
30 | - */ |
|
31 | - protected function _remove_tags($value) |
|
32 | - { |
|
33 | - if (is_array($value)) { |
|
34 | - foreach ($value as $key => $v) { |
|
35 | - $value[ $key ] = $this->_remove_tags($v); |
|
36 | - } |
|
37 | - } elseif (is_string($value)) { |
|
38 | - $value = wp_kses("$value", $this->_get_allowed_tags()); |
|
39 | - } |
|
40 | - return $value; |
|
41 | - } |
|
25 | + /** |
|
26 | + * Remove any non-"simple" html tags. @see EE_Simple_HTML_Field |
|
27 | + * |
|
28 | + * @param array|string $value |
|
29 | + * @return array|string |
|
30 | + */ |
|
31 | + protected function _remove_tags($value) |
|
32 | + { |
|
33 | + if (is_array($value)) { |
|
34 | + foreach ($value as $key => $v) { |
|
35 | + $value[ $key ] = $this->_remove_tags($v); |
|
36 | + } |
|
37 | + } elseif (is_string($value)) { |
|
38 | + $value = wp_kses("$value", $this->_get_allowed_tags()); |
|
39 | + } |
|
40 | + return $value; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * In case unsafe data somehow got inserted into the database, we want to remove tags again |
|
45 | - * |
|
46 | - * @param array|string $value_found_in_db_for_model_object |
|
47 | - * @return array|string |
|
48 | - */ |
|
49 | - public function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
50 | - { |
|
51 | - return $this->_remove_tags(parent::prepare_for_set_from_db($value_found_in_db_for_model_object)); |
|
52 | - } |
|
43 | + /** |
|
44 | + * In case unsafe data somehow got inserted into the database, we want to remove tags again |
|
45 | + * |
|
46 | + * @param array|string $value_found_in_db_for_model_object |
|
47 | + * @return array|string |
|
48 | + */ |
|
49 | + public function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
50 | + { |
|
51 | + return $this->_remove_tags(parent::prepare_for_set_from_db($value_found_in_db_for_model_object)); |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * Determines what tags to allow in this model field |
|
57 | - * |
|
58 | - * @global array $allowedtags |
|
59 | - * @return array |
|
60 | - */ |
|
61 | - public function _get_allowed_tags() |
|
62 | - { |
|
63 | - return apply_filters( |
|
64 | - 'FHEE__EE_Maybe_Serialized_Simple_HTML_Field___get_allowed_tags', |
|
65 | - EEH_HTML::get_simple_tags(), |
|
66 | - $this |
|
67 | - ); |
|
68 | - } |
|
55 | + /** |
|
56 | + * Determines what tags to allow in this model field |
|
57 | + * |
|
58 | + * @global array $allowedtags |
|
59 | + * @return array |
|
60 | + */ |
|
61 | + public function _get_allowed_tags() |
|
62 | + { |
|
63 | + return apply_filters( |
|
64 | + 'FHEE__EE_Maybe_Serialized_Simple_HTML_Field___get_allowed_tags', |
|
65 | + EEH_HTML::get_simple_tags(), |
|
66 | + $this |
|
67 | + ); |
|
68 | + } |
|
69 | 69 | } |
@@ -32,7 +32,7 @@ |
||
32 | 32 | { |
33 | 33 | if (is_array($value)) { |
34 | 34 | foreach ($value as $key => $v) { |
35 | - $value[ $key ] = $this->_remove_tags($v); |
|
35 | + $value[$key] = $this->_remove_tags($v); |
|
36 | 36 | } |
37 | 37 | } elseif (is_string($value)) { |
38 | 38 | $value = wp_kses("$value", $this->_get_allowed_tags()); |
@@ -6,5 +6,5 @@ |
||
6 | 6 | */ |
7 | 7 | class EE_Unique_Index extends EE_Index |
8 | 8 | { |
9 | - // yep, actually the same as index right now |
|
9 | + // yep, actually the same as index right now |
|
10 | 10 | } |
@@ -6,5 +6,5 @@ |
||
6 | 6 | */ |
7 | 7 | class EE_Primary_Key_Index extends EE_Unique_Index |
8 | 8 | { |
9 | - // yep, actually the same as unique index right now |
|
9 | + // yep, actually the same as unique index right now |
|
10 | 10 | } |
@@ -14,141 +14,141 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * @var string SQL for performing joins (Eg, "INNER JOIN blah ON blah=blah INNER JOIN FOO ON foo=foo...") |
16 | 16 | */ |
17 | - private $_join_sql; |
|
17 | + private $_join_sql; |
|
18 | 18 | /** |
19 | 19 | * |
20 | 20 | * @var array stating all the models that have been included thus far,so we don't get duplicates. |
21 | 21 | * Keys are the model relation chains to them from the queried model |
22 | 22 | * (eg, "Registration.Transaction.Payment"), and valuesare model names (eg "Payment") |
23 | 23 | */ |
24 | - private $_models_included; |
|
24 | + private $_models_included; |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * After we've acquired all the data types, we can create this sql. |
28 | 28 | * @var string |
29 | 29 | */ |
30 | - private $_where_sql; |
|
30 | + private $_where_sql; |
|
31 | 31 | /** |
32 | 32 | * Full join sql. Eg, in a select query, that's everything after the "FROM", and before the "WHERE", so it includes |
33 | 33 | * the declaration of the main model's tables, and then appends all the joining sql to other models |
34 | 34 | * @var string |
35 | 35 | */ |
36 | - private $_main_join_sql; |
|
36 | + private $_main_join_sql; |
|
37 | 37 | |
38 | 38 | |
39 | - private $_limit_sql; |
|
39 | + private $_limit_sql; |
|
40 | 40 | |
41 | - private $_order_by_sql; |
|
41 | + private $_order_by_sql; |
|
42 | 42 | |
43 | - private $_having_sql; |
|
43 | + private $_having_sql; |
|
44 | 44 | |
45 | - private $_group_by_sql; |
|
45 | + private $_group_by_sql; |
|
46 | 46 | |
47 | - public function set_limit_sql($limit_sql) |
|
48 | - { |
|
49 | - $this->_limit_sql = $limit_sql; |
|
50 | - } |
|
47 | + public function set_limit_sql($limit_sql) |
|
48 | + { |
|
49 | + $this->_limit_sql = $limit_sql; |
|
50 | + } |
|
51 | 51 | |
52 | - public function set_order_by_sql($order_by_sql) |
|
53 | - { |
|
54 | - $this->_order_by_sql = $order_by_sql; |
|
55 | - } |
|
56 | - public function set_group_by_sql($group_by_sql) |
|
57 | - { |
|
58 | - $this->_group_by_sql = $group_by_sql; |
|
59 | - } |
|
60 | - public function set_having_sql($having_sql) |
|
61 | - { |
|
62 | - $this->_having_sql = $having_sql; |
|
63 | - } |
|
64 | - public function get_limit_sql() |
|
65 | - { |
|
66 | - return $this->_limit_sql; |
|
67 | - } |
|
68 | - public function get_order_by_sql() |
|
69 | - { |
|
70 | - return $this->_order_by_sql; |
|
71 | - } |
|
72 | - public function get_group_by_sql() |
|
73 | - { |
|
74 | - return $this->_group_by_sql; |
|
75 | - } |
|
76 | - public function get_having_sql() |
|
77 | - { |
|
78 | - return $this->_having_sql; |
|
79 | - } |
|
52 | + public function set_order_by_sql($order_by_sql) |
|
53 | + { |
|
54 | + $this->_order_by_sql = $order_by_sql; |
|
55 | + } |
|
56 | + public function set_group_by_sql($group_by_sql) |
|
57 | + { |
|
58 | + $this->_group_by_sql = $group_by_sql; |
|
59 | + } |
|
60 | + public function set_having_sql($having_sql) |
|
61 | + { |
|
62 | + $this->_having_sql = $having_sql; |
|
63 | + } |
|
64 | + public function get_limit_sql() |
|
65 | + { |
|
66 | + return $this->_limit_sql; |
|
67 | + } |
|
68 | + public function get_order_by_sql() |
|
69 | + { |
|
70 | + return $this->_order_by_sql; |
|
71 | + } |
|
72 | + public function get_group_by_sql() |
|
73 | + { |
|
74 | + return $this->_group_by_sql; |
|
75 | + } |
|
76 | + public function get_having_sql() |
|
77 | + { |
|
78 | + return $this->_having_sql; |
|
79 | + } |
|
80 | 80 | /** |
81 | 81 | * |
82 | 82 | * @param type $model_included_name |
83 | 83 | * @param type $join_sql |
84 | 84 | * @param type $data_types |
85 | 85 | */ |
86 | - public function __construct($model_included_name = array(), $join_sql = '') |
|
87 | - { |
|
88 | - $this->_models_included = $model_included_name; |
|
89 | - $this->_join_sql = $join_sql; |
|
90 | - } |
|
86 | + public function __construct($model_included_name = array(), $join_sql = '') |
|
87 | + { |
|
88 | + $this->_models_included = $model_included_name; |
|
89 | + $this->_join_sql = $join_sql; |
|
90 | + } |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * Merges info from the other EEM_Related_Model_Info_Carrier into this one. |
94 | 94 | * @param EE_Model_Query_Info_Carrier $other_model_query_info_carrier |
95 | 95 | */ |
96 | - public function merge($other_model_query_info_carrier) |
|
97 | - { |
|
98 | - if ($other_model_query_info_carrier && ! $this->_have_already_included_one_of_these_models($other_model_query_info_carrier->get_model_names_included())) { |
|
99 | - $model_included_on_other_join_sql_and_data_types_carrier = $other_model_query_info_carrier->get_model_names_included(); |
|
100 | - $this->_models_included = array_merge($this->_models_included, $model_included_on_other_join_sql_and_data_types_carrier); |
|
101 | - $this->_join_sql .= $other_model_query_info_carrier->_join_sql; |
|
102 | - } |
|
103 | - // otherwise don't merge our data. |
|
104 | - // yes, this means that we must immediately merge any model data into our grand list |
|
105 | - // as soon as we get some from ONE model, or else we could reject a EEM_Related_Model_Info_Carrier |
|
106 | - // which is carrying info from two models WHERE one is already included but the other is NOT |
|
107 | - } |
|
96 | + public function merge($other_model_query_info_carrier) |
|
97 | + { |
|
98 | + if ($other_model_query_info_carrier && ! $this->_have_already_included_one_of_these_models($other_model_query_info_carrier->get_model_names_included())) { |
|
99 | + $model_included_on_other_join_sql_and_data_types_carrier = $other_model_query_info_carrier->get_model_names_included(); |
|
100 | + $this->_models_included = array_merge($this->_models_included, $model_included_on_other_join_sql_and_data_types_carrier); |
|
101 | + $this->_join_sql .= $other_model_query_info_carrier->_join_sql; |
|
102 | + } |
|
103 | + // otherwise don't merge our data. |
|
104 | + // yes, this means that we must immediately merge any model data into our grand list |
|
105 | + // as soon as we get some from ONE model, or else we could reject a EEM_Related_Model_Info_Carrier |
|
106 | + // which is carrying info from two models WHERE one is already included but the other is NOT |
|
107 | + } |
|
108 | 108 | /** |
109 | 109 | * Checks whether or not we have already included all the models mentione din $model_names on the query info varrier |
110 | 110 | * @param array $model_names just like EE_MOdel_QUery_Info_Carrier::_models_included: keys are model chain paths, values are the model names only |
111 | 111 | * @return boolean |
112 | 112 | */ |
113 | - protected function _have_already_included_one_of_these_models($model_names) |
|
114 | - { |
|
115 | - foreach ($this->_models_included as $model_relation_path => $model_included) { |
|
116 | - if (array_key_exists($model_relation_path, $model_names)) { |
|
117 | - return true; |
|
118 | - } |
|
119 | - } |
|
120 | - return false; |
|
121 | - } |
|
113 | + protected function _have_already_included_one_of_these_models($model_names) |
|
114 | + { |
|
115 | + foreach ($this->_models_included as $model_relation_path => $model_included) { |
|
116 | + if (array_key_exists($model_relation_path, $model_names)) { |
|
117 | + return true; |
|
118 | + } |
|
119 | + } |
|
120 | + return false; |
|
121 | + } |
|
122 | 122 | /** |
123 | 123 | * Array keys are model names, values are "model relation paths". See EE_Model_Query_Info_Carrier::_models_included for details |
124 | 124 | * @return array like EE_Model_Query_Info_Carrier::_models_included |
125 | 125 | */ |
126 | - public function get_model_names_included() |
|
127 | - { |
|
128 | - return $this->_models_included; |
|
129 | - } |
|
126 | + public function get_model_names_included() |
|
127 | + { |
|
128 | + return $this->_models_included; |
|
129 | + } |
|
130 | 130 | /** |
131 | 131 | * sets the $where_sql for later use from client code |
132 | 132 | * @param string $where_sql |
133 | 133 | */ |
134 | - public function set_where_sql($where_sql) |
|
135 | - { |
|
136 | - $this->_where_sql = $where_sql; |
|
137 | - } |
|
138 | - public function get_where_sql() |
|
139 | - { |
|
140 | - return $this->_where_sql; |
|
141 | - } |
|
134 | + public function set_where_sql($where_sql) |
|
135 | + { |
|
136 | + $this->_where_sql = $where_sql; |
|
137 | + } |
|
138 | + public function get_where_sql() |
|
139 | + { |
|
140 | + return $this->_where_sql; |
|
141 | + } |
|
142 | 142 | |
143 | 143 | /** |
144 | 144 | * Gets the SQL for joining the main model to other models involves in the query, which was set earlier on |
145 | 145 | * the EE_Model_Query_info_Carrier by calling set_main_model_join_sql() |
146 | 146 | * @return string |
147 | 147 | */ |
148 | - public function get_main_model_join_sql() |
|
149 | - { |
|
150 | - return $this->_main_join_sql; |
|
151 | - } |
|
148 | + public function get_main_model_join_sql() |
|
149 | + { |
|
150 | + return $this->_main_join_sql; |
|
151 | + } |
|
152 | 152 | |
153 | 153 | |
154 | 154 | /** |
@@ -158,12 +158,12 @@ discard block |
||
158 | 158 | * after the FROM and before the WHERE.) |
159 | 159 | * @param string $join_sql |
160 | 160 | */ |
161 | - public function set_main_model_join_sql($join_sql) |
|
162 | - { |
|
163 | - $this->_main_join_sql = $join_sql; |
|
164 | - } |
|
165 | - public function get_full_join_sql() |
|
166 | - { |
|
167 | - return $this->_main_join_sql . $this->_join_sql; |
|
168 | - } |
|
161 | + public function set_main_model_join_sql($join_sql) |
|
162 | + { |
|
163 | + $this->_main_join_sql = $join_sql; |
|
164 | + } |
|
165 | + public function get_full_join_sql() |
|
166 | + { |
|
167 | + return $this->_main_join_sql . $this->_join_sql; |
|
168 | + } |
|
169 | 169 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | public function merge($other_model_query_info_carrier) |
97 | 97 | { |
98 | 98 | if ($other_model_query_info_carrier && ! $this->_have_already_included_one_of_these_models($other_model_query_info_carrier->get_model_names_included())) { |
99 | - $model_included_on_other_join_sql_and_data_types_carrier = $other_model_query_info_carrier->get_model_names_included(); |
|
99 | + $model_included_on_other_join_sql_and_data_types_carrier = $other_model_query_info_carrier->get_model_names_included(); |
|
100 | 100 | $this->_models_included = array_merge($this->_models_included, $model_included_on_other_join_sql_and_data_types_carrier); |
101 | 101 | $this->_join_sql .= $other_model_query_info_carrier->_join_sql; |
102 | 102 | } |
@@ -164,6 +164,6 @@ discard block |
||
164 | 164 | } |
165 | 165 | public function get_full_join_sql() |
166 | 166 | { |
167 | - return $this->_main_join_sql . $this->_join_sql; |
|
167 | + return $this->_main_join_sql.$this->_join_sql; |
|
168 | 168 | } |
169 | 169 | } |