@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | public function set_notice($key, $value) |
| 73 | 73 | { |
| 74 | - $this->_notice[ $key ] = $value; |
|
| 74 | + $this->_notice[$key] = $value; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | public function get_notice($key) |
| 84 | 84 | { |
| 85 | - return isset($this->_notice[ $key ]) ? $this->_notice[ $key ] : null; |
|
| 85 | + return isset($this->_notice[$key]) ? $this->_notice[$key] : null; |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | public function add_output($string, $append = true) |
| 105 | 105 | { |
| 106 | - $this->_output = $append ? $this->_output . $string : $string . $this->_output; |
|
| 106 | + $this->_output = $append ? $this->_output.$string : $string.$this->_output; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | |
@@ -12,146 +12,146 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class EE_Response |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * @access protected |
|
| 17 | - * @type array $_notice |
|
| 18 | - */ |
|
| 19 | - protected $_notice = array(); |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * rendered output to be returned to WP |
|
| 23 | - * |
|
| 24 | - * @access protected |
|
| 25 | - * @type string |
|
| 26 | - */ |
|
| 27 | - protected $_output = ''; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * @access protected |
|
| 31 | - * @type bool |
|
| 32 | - */ |
|
| 33 | - protected $request_terminated = false; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * @access protected |
|
| 37 | - * @type bool |
|
| 38 | - */ |
|
| 39 | - protected $deactivate_plugin = false; |
|
| 40 | - |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * @deprecated 4.9.53 |
|
| 44 | - * @return \EE_Response |
|
| 45 | - */ |
|
| 46 | - public function __construct() |
|
| 47 | - { |
|
| 48 | - $this->terminate_request(false); |
|
| 49 | - EE_Error::doing_it_wrong( |
|
| 50 | - __METHOD__, |
|
| 51 | - sprintf( |
|
| 52 | - esc_html__( |
|
| 53 | - 'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
| 54 | - 'event_espresso' |
|
| 55 | - ), |
|
| 56 | - 'EventEspresso\core\services\request\Response', |
|
| 57 | - '\core\services\request', |
|
| 58 | - 'EventEspresso\core\services\request' |
|
| 59 | - ), |
|
| 60 | - '4.9.53' |
|
| 61 | - ); |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * @deprecated 4.9.53 |
|
| 67 | - * @param $key |
|
| 68 | - * @param $value |
|
| 69 | - * @return void |
|
| 70 | - */ |
|
| 71 | - public function set_notice($key, $value) |
|
| 72 | - { |
|
| 73 | - $this->_notice[ $key ] = $value; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * @deprecated 4.9.53 |
|
| 79 | - * @param $key |
|
| 80 | - * @return mixed |
|
| 81 | - */ |
|
| 82 | - public function get_notice($key) |
|
| 83 | - { |
|
| 84 | - return isset($this->_notice[ $key ]) ? $this->_notice[ $key ] : null; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * @deprecated 4.9.53 |
|
| 90 | - * @return array |
|
| 91 | - */ |
|
| 92 | - public function get_notices() |
|
| 93 | - { |
|
| 94 | - return $this->_notice; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * @deprecated 4.9.53 |
|
| 100 | - * @param $string |
|
| 101 | - * @param bool $append |
|
| 102 | - */ |
|
| 103 | - public function add_output($string, $append = true) |
|
| 104 | - { |
|
| 105 | - $this->_output = $append ? $this->_output . $string : $string . $this->_output; |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * @deprecated 4.9.53 |
|
| 111 | - * @return string |
|
| 112 | - */ |
|
| 113 | - public function get_output() |
|
| 114 | - { |
|
| 115 | - return $this->_output; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * @deprecated 4.9.53 |
|
| 121 | - * @return boolean |
|
| 122 | - */ |
|
| 123 | - public function request_terminated() |
|
| 124 | - { |
|
| 125 | - return $this->request_terminated; |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - |
|
| 129 | - /** |
|
| 130 | - * @deprecated 4.9.53 |
|
| 131 | - * @param boolean $request_terminated |
|
| 132 | - */ |
|
| 133 | - public function terminate_request($request_terminated = true) |
|
| 134 | - { |
|
| 135 | - $this->request_terminated = filter_var($request_terminated, FILTER_VALIDATE_BOOLEAN); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * @deprecated 4.9.53 |
|
| 141 | - * @return boolean |
|
| 142 | - */ |
|
| 143 | - public function plugin_deactivated() |
|
| 144 | - { |
|
| 145 | - return $this->deactivate_plugin; |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * @deprecated 4.9.53 |
|
| 151 | - * sets $deactivate_plugin to true |
|
| 152 | - */ |
|
| 153 | - public function deactivate_plugin() |
|
| 154 | - { |
|
| 155 | - $this->deactivate_plugin = true; |
|
| 156 | - } |
|
| 15 | + /** |
|
| 16 | + * @access protected |
|
| 17 | + * @type array $_notice |
|
| 18 | + */ |
|
| 19 | + protected $_notice = array(); |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * rendered output to be returned to WP |
|
| 23 | + * |
|
| 24 | + * @access protected |
|
| 25 | + * @type string |
|
| 26 | + */ |
|
| 27 | + protected $_output = ''; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * @access protected |
|
| 31 | + * @type bool |
|
| 32 | + */ |
|
| 33 | + protected $request_terminated = false; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * @access protected |
|
| 37 | + * @type bool |
|
| 38 | + */ |
|
| 39 | + protected $deactivate_plugin = false; |
|
| 40 | + |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @deprecated 4.9.53 |
|
| 44 | + * @return \EE_Response |
|
| 45 | + */ |
|
| 46 | + public function __construct() |
|
| 47 | + { |
|
| 48 | + $this->terminate_request(false); |
|
| 49 | + EE_Error::doing_it_wrong( |
|
| 50 | + __METHOD__, |
|
| 51 | + sprintf( |
|
| 52 | + esc_html__( |
|
| 53 | + 'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
| 54 | + 'event_espresso' |
|
| 55 | + ), |
|
| 56 | + 'EventEspresso\core\services\request\Response', |
|
| 57 | + '\core\services\request', |
|
| 58 | + 'EventEspresso\core\services\request' |
|
| 59 | + ), |
|
| 60 | + '4.9.53' |
|
| 61 | + ); |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * @deprecated 4.9.53 |
|
| 67 | + * @param $key |
|
| 68 | + * @param $value |
|
| 69 | + * @return void |
|
| 70 | + */ |
|
| 71 | + public function set_notice($key, $value) |
|
| 72 | + { |
|
| 73 | + $this->_notice[ $key ] = $value; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * @deprecated 4.9.53 |
|
| 79 | + * @param $key |
|
| 80 | + * @return mixed |
|
| 81 | + */ |
|
| 82 | + public function get_notice($key) |
|
| 83 | + { |
|
| 84 | + return isset($this->_notice[ $key ]) ? $this->_notice[ $key ] : null; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * @deprecated 4.9.53 |
|
| 90 | + * @return array |
|
| 91 | + */ |
|
| 92 | + public function get_notices() |
|
| 93 | + { |
|
| 94 | + return $this->_notice; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * @deprecated 4.9.53 |
|
| 100 | + * @param $string |
|
| 101 | + * @param bool $append |
|
| 102 | + */ |
|
| 103 | + public function add_output($string, $append = true) |
|
| 104 | + { |
|
| 105 | + $this->_output = $append ? $this->_output . $string : $string . $this->_output; |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * @deprecated 4.9.53 |
|
| 111 | + * @return string |
|
| 112 | + */ |
|
| 113 | + public function get_output() |
|
| 114 | + { |
|
| 115 | + return $this->_output; |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * @deprecated 4.9.53 |
|
| 121 | + * @return boolean |
|
| 122 | + */ |
|
| 123 | + public function request_terminated() |
|
| 124 | + { |
|
| 125 | + return $this->request_terminated; |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * @deprecated 4.9.53 |
|
| 131 | + * @param boolean $request_terminated |
|
| 132 | + */ |
|
| 133 | + public function terminate_request($request_terminated = true) |
|
| 134 | + { |
|
| 135 | + $this->request_terminated = filter_var($request_terminated, FILTER_VALIDATE_BOOLEAN); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * @deprecated 4.9.53 |
|
| 141 | + * @return boolean |
|
| 142 | + */ |
|
| 143 | + public function plugin_deactivated() |
|
| 144 | + { |
|
| 145 | + return $this->deactivate_plugin; |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * @deprecated 4.9.53 |
|
| 151 | + * sets $deactivate_plugin to true |
|
| 152 | + */ |
|
| 153 | + public function deactivate_plugin() |
|
| 154 | + { |
|
| 155 | + $this->deactivate_plugin = true; |
|
| 156 | + } |
|
| 157 | 157 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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()); |
@@ -46,12 +46,12 @@ discard block |
||
| 46 | 46 | $pk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
| 47 | 47 | $model_relation_chain, |
| 48 | 48 | $this->get_this_model()->get_this_model_name() |
| 49 | - ) . $this_table_pk_field->get_table_alias(); |
|
| 50 | - $fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
|
| 49 | + ).$this_table_pk_field->get_table_alias(); |
|
| 50 | + $fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
|
| 51 | 51 | $model_relation_chain, |
| 52 | 52 | $this->get_other_model()->get_this_model_name() |
| 53 | - ) . $other_table_fk_field->get_table_alias(); |
|
| 54 | - $fk_table = $this->get_other_model()->get_table_for_alias($fk_table_alias); |
|
| 53 | + ).$other_table_fk_field->get_table_alias(); |
|
| 54 | + $fk_table = $this->get_other_model()->get_table_for_alias($fk_table_alias); |
|
| 55 | 55 | |
| 56 | 56 | return $this->_left_join( |
| 57 | 57 | $fk_table, |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $other_table_fk_field->get_table_column(), |
| 60 | 60 | $pk_table_alias, |
| 61 | 61 | $this_table_pk_field->get_table_column() |
| 62 | - ) . $this->get_other_model()->_construct_internal_join_to_table_with_alias($fk_table_alias); |
|
| 62 | + ).$this->get_other_model()->_construct_internal_join_to_table_with_alias($fk_table_alias); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | |
@@ -10,113 +10,113 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | class EE_Has_Many_Relation extends EE_Model_Relation_Base |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * Object representing the relationship between two models. Has_Many_Relations are where the OTHER model has the |
|
| 15 | - * foreign key this model. IE, there can be many other model objects related to one of this model's objects (but |
|
| 16 | - * NOT through a JOIN table, which is the case for EE_HABTM_Relations). This knows how to join the models, get |
|
| 17 | - * related models across the relation, and add-and-remove the relationships. |
|
| 18 | - * |
|
| 19 | - * @param bool $block_deletes For this type of r elation, we block by default. If there are |
|
| 20 | - * related models across this relation, block (prevent and add an |
|
| 21 | - * error) the deletion of this model |
|
| 22 | - * @param string $blocking_delete_error_message a customized error message on blocking deletes instead of the |
|
| 23 | - * default |
|
| 24 | - */ |
|
| 25 | - public function __construct(bool $block_deletes = true, string $blocking_delete_error_message = '') |
|
| 26 | - { |
|
| 27 | - parent::__construct($block_deletes, $blocking_delete_error_message); |
|
| 28 | - } |
|
| 13 | + /** |
|
| 14 | + * Object representing the relationship between two models. Has_Many_Relations are where the OTHER model has the |
|
| 15 | + * foreign key this model. IE, there can be many other model objects related to one of this model's objects (but |
|
| 16 | + * NOT through a JOIN table, which is the case for EE_HABTM_Relations). This knows how to join the models, get |
|
| 17 | + * related models across the relation, and add-and-remove the relationships. |
|
| 18 | + * |
|
| 19 | + * @param bool $block_deletes For this type of r elation, we block by default. If there are |
|
| 20 | + * related models across this relation, block (prevent and add an |
|
| 21 | + * error) the deletion of this model |
|
| 22 | + * @param string $blocking_delete_error_message a customized error message on blocking deletes instead of the |
|
| 23 | + * default |
|
| 24 | + */ |
|
| 25 | + public function __construct(bool $block_deletes = true, string $blocking_delete_error_message = '') |
|
| 26 | + { |
|
| 27 | + parent::__construct($block_deletes, $blocking_delete_error_message); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Gets the SQL string for performing the join between this model and the other model. |
|
| 33 | - * |
|
| 34 | - * @param string $model_relation_chain like 'Event.Event_Venue.Venue' |
|
| 35 | - * @return string of SQL, eg "LEFT JOIN table_name AS table_alias ON this_model_primary_table.pk = |
|
| 36 | - * other_model_primary_table.fk" etc |
|
| 37 | - * @throws EE_Error |
|
| 38 | - * @throws Exception |
|
| 39 | - */ |
|
| 40 | - public function get_join_statement(string $model_relation_chain): string |
|
| 41 | - { |
|
| 42 | - // create the sql string like |
|
| 43 | - // LEFT JOIN other_table AS table_alias ON this_table_alias.pk = other_table_alias.fk extra_join_conditions |
|
| 44 | - $this_table_pk_field = $this->get_this_model()->get_primary_key_field(); |
|
| 45 | - $other_table_fk_field = |
|
| 46 | - $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
| 47 | - $pk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
|
| 48 | - $model_relation_chain, |
|
| 49 | - $this->get_this_model()->get_this_model_name() |
|
| 50 | - ) . $this_table_pk_field->get_table_alias(); |
|
| 51 | - $fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
|
| 52 | - $model_relation_chain, |
|
| 53 | - $this->get_other_model()->get_this_model_name() |
|
| 54 | - ) . $other_table_fk_field->get_table_alias(); |
|
| 55 | - $fk_table = $this->get_other_model()->get_table_for_alias($fk_table_alias); |
|
| 31 | + /** |
|
| 32 | + * Gets the SQL string for performing the join between this model and the other model. |
|
| 33 | + * |
|
| 34 | + * @param string $model_relation_chain like 'Event.Event_Venue.Venue' |
|
| 35 | + * @return string of SQL, eg "LEFT JOIN table_name AS table_alias ON this_model_primary_table.pk = |
|
| 36 | + * other_model_primary_table.fk" etc |
|
| 37 | + * @throws EE_Error |
|
| 38 | + * @throws Exception |
|
| 39 | + */ |
|
| 40 | + public function get_join_statement(string $model_relation_chain): string |
|
| 41 | + { |
|
| 42 | + // create the sql string like |
|
| 43 | + // LEFT JOIN other_table AS table_alias ON this_table_alias.pk = other_table_alias.fk extra_join_conditions |
|
| 44 | + $this_table_pk_field = $this->get_this_model()->get_primary_key_field(); |
|
| 45 | + $other_table_fk_field = |
|
| 46 | + $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
|
| 47 | + $pk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
|
| 48 | + $model_relation_chain, |
|
| 49 | + $this->get_this_model()->get_this_model_name() |
|
| 50 | + ) . $this_table_pk_field->get_table_alias(); |
|
| 51 | + $fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix( |
|
| 52 | + $model_relation_chain, |
|
| 53 | + $this->get_other_model()->get_this_model_name() |
|
| 54 | + ) . $other_table_fk_field->get_table_alias(); |
|
| 55 | + $fk_table = $this->get_other_model()->get_table_for_alias($fk_table_alias); |
|
| 56 | 56 | |
| 57 | - return $this->_left_join( |
|
| 58 | - $fk_table, |
|
| 59 | - $fk_table_alias, |
|
| 60 | - $other_table_fk_field->get_table_column(), |
|
| 61 | - $pk_table_alias, |
|
| 62 | - $this_table_pk_field->get_table_column() |
|
| 63 | - ) . $this->get_other_model()->_construct_internal_join_to_table_with_alias($fk_table_alias); |
|
| 64 | - } |
|
| 57 | + return $this->_left_join( |
|
| 58 | + $fk_table, |
|
| 59 | + $fk_table_alias, |
|
| 60 | + $other_table_fk_field->get_table_column(), |
|
| 61 | + $pk_table_alias, |
|
| 62 | + $this_table_pk_field->get_table_column() |
|
| 63 | + ) . $this->get_other_model()->_construct_internal_join_to_table_with_alias($fk_table_alias); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * Sets the other model object's foreign key to this model object's primary key. Feel free to do this manually if |
|
| 69 | - * you like. |
|
| 70 | - * |
|
| 71 | - * @param EE_Base_Class|int $this_obj_or_id |
|
| 72 | - * @param EE_Base_Class|int $other_obj_or_id |
|
| 73 | - * @param array $extra_join_model_fields_n_values |
|
| 74 | - * @return EE_Base_Class |
|
| 75 | - * @throws EE_Error |
|
| 76 | - * @throws Exception |
|
| 77 | - */ |
|
| 78 | - public function add_relation_to( |
|
| 79 | - $this_obj_or_id, |
|
| 80 | - $other_obj_or_id, |
|
| 81 | - array $extra_join_model_fields_n_values = [] |
|
| 82 | - ): EE_Base_Class { |
|
| 83 | - $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
|
| 84 | - $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
|
| 67 | + /** |
|
| 68 | + * Sets the other model object's foreign key to this model object's primary key. Feel free to do this manually if |
|
| 69 | + * you like. |
|
| 70 | + * |
|
| 71 | + * @param EE_Base_Class|int $this_obj_or_id |
|
| 72 | + * @param EE_Base_Class|int $other_obj_or_id |
|
| 73 | + * @param array $extra_join_model_fields_n_values |
|
| 74 | + * @return EE_Base_Class |
|
| 75 | + * @throws EE_Error |
|
| 76 | + * @throws Exception |
|
| 77 | + */ |
|
| 78 | + public function add_relation_to( |
|
| 79 | + $this_obj_or_id, |
|
| 80 | + $other_obj_or_id, |
|
| 81 | + array $extra_join_model_fields_n_values = [] |
|
| 82 | + ): EE_Base_Class { |
|
| 83 | + $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
|
| 84 | + $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
|
| 85 | 85 | |
| 86 | - // find the field on the other model which is a foreign key to this model |
|
| 87 | - $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to( |
|
| 88 | - $this->get_this_model()->get_this_model_name() |
|
| 89 | - ); |
|
| 90 | - if ($other_model_obj->get($fk_field_on_other_model->get_name()) != $this_model_obj->ID()) { |
|
| 91 | - // set that field on the other model to this model's ID |
|
| 92 | - $other_model_obj->set($fk_field_on_other_model->get_name(), $this_model_obj->ID()); |
|
| 93 | - $other_model_obj->save(); |
|
| 94 | - } |
|
| 95 | - return $other_model_obj; |
|
| 96 | - } |
|
| 86 | + // find the field on the other model which is a foreign key to this model |
|
| 87 | + $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to( |
|
| 88 | + $this->get_this_model()->get_this_model_name() |
|
| 89 | + ); |
|
| 90 | + if ($other_model_obj->get($fk_field_on_other_model->get_name()) != $this_model_obj->ID()) { |
|
| 91 | + // set that field on the other model to this model's ID |
|
| 92 | + $other_model_obj->set($fk_field_on_other_model->get_name(), $this_model_obj->ID()); |
|
| 93 | + $other_model_obj->save(); |
|
| 94 | + } |
|
| 95 | + return $other_model_obj; |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * Sets the other model object's foreign key to its default, instead of pointing to this model object. |
|
| 101 | - * If $other_obj_or_id doesn't have any other relations, this function is essentially orphaning it |
|
| 102 | - * |
|
| 103 | - * @param EE_Base_Class|int $this_obj_or_id |
|
| 104 | - * @param EE_Base_Class|int $other_obj_or_id |
|
| 105 | - * @param array $where_query |
|
| 106 | - * @return EE_Base_Class |
|
| 107 | - * @throws EE_Error |
|
| 108 | - * @throws Exception |
|
| 109 | - */ |
|
| 110 | - public function remove_relation_to($this_obj_or_id, $other_obj_or_id, array $where_query = []): EE_Base_Class |
|
| 111 | - { |
|
| 112 | - $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
|
| 113 | - // find the field on the other model which is a foreign key to this model |
|
| 114 | - $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to( |
|
| 115 | - $this->get_this_model()->get_this_model_name() |
|
| 116 | - ); |
|
| 117 | - // set that field on the other model to this model's ID |
|
| 118 | - $other_model_obj->set($fk_field_on_other_model->get_name(), null, true); |
|
| 119 | - $other_model_obj->save(); |
|
| 120 | - return $other_model_obj; |
|
| 121 | - } |
|
| 99 | + /** |
|
| 100 | + * Sets the other model object's foreign key to its default, instead of pointing to this model object. |
|
| 101 | + * If $other_obj_or_id doesn't have any other relations, this function is essentially orphaning it |
|
| 102 | + * |
|
| 103 | + * @param EE_Base_Class|int $this_obj_or_id |
|
| 104 | + * @param EE_Base_Class|int $other_obj_or_id |
|
| 105 | + * @param array $where_query |
|
| 106 | + * @return EE_Base_Class |
|
| 107 | + * @throws EE_Error |
|
| 108 | + * @throws Exception |
|
| 109 | + */ |
|
| 110 | + public function remove_relation_to($this_obj_or_id, $other_obj_or_id, array $where_query = []): EE_Base_Class |
|
| 111 | + { |
|
| 112 | + $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
|
| 113 | + // find the field on the other model which is a foreign key to this model |
|
| 114 | + $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to( |
|
| 115 | + $this->get_this_model()->get_this_model_name() |
|
| 116 | + ); |
|
| 117 | + // set that field on the other model to this model's ID |
|
| 118 | + $other_model_obj->set($fk_field_on_other_model->get_name(), null, true); |
|
| 119 | + $other_model_obj->save(); |
|
| 120 | + return $other_model_obj; |
|
| 121 | + } |
|
| 122 | 122 | } |
@@ -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 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | return htmlspecialchars($string); |
| 47 | 47 | } else { |
| 48 | 48 | if ($translate === false) { |
| 49 | - return self::ee_tep_parse_input_field_data($string, array( '"' => '"' )); |
|
| 49 | + return self::ee_tep_parse_input_field_data($string, array('"' => '"')); |
|
| 50 | 50 | } else { |
| 51 | 51 | return self::ee_tep_parse_input_field_data($string, $translate); |
| 52 | 52 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | return false; |
| 85 | 85 | } |
| 86 | 86 | } else { |
| 87 | - if (( $value !== '' ) && ( strtolower($value) !== 'null' ) && ( strlen(trim($value)) > 0 )) { |
|
| 87 | + if (($value !== '') && (strtolower($value) !== 'null') && (strlen(trim($value)) > 0)) { |
|
| 88 | 88 | return true; |
| 89 | 89 | } else { |
| 90 | 90 | return false; |
@@ -10,108 +10,108 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | class EEH_Formatter |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * _admin_format_content |
|
| 15 | - * Text formatting function for wp_editor. |
|
| 16 | - * This should fix all of the formatting issues of text output from the database. |
|
| 17 | - * |
|
| 18 | - * @static |
|
| 19 | - * @access public |
|
| 20 | - * @param string $content content to format |
|
| 21 | - * @return string formatted content |
|
| 22 | - */ |
|
| 23 | - public static function admin_format_content($content = '') |
|
| 24 | - { |
|
| 25 | - return wpautop(stripslashes_deep(html_entity_decode($content, ENT_QUOTES, "UTF-8"))); |
|
| 26 | - } |
|
| 13 | + /** |
|
| 14 | + * _admin_format_content |
|
| 15 | + * Text formatting function for wp_editor. |
|
| 16 | + * This should fix all of the formatting issues of text output from the database. |
|
| 17 | + * |
|
| 18 | + * @static |
|
| 19 | + * @access public |
|
| 20 | + * @param string $content content to format |
|
| 21 | + * @return string formatted content |
|
| 22 | + */ |
|
| 23 | + public static function admin_format_content($content = '') |
|
| 24 | + { |
|
| 25 | + return wpautop(stripslashes_deep(html_entity_decode($content, ENT_QUOTES, "UTF-8"))); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * ee_tep_output_string |
|
| 32 | - * todo: we need a description for this. |
|
| 33 | - * |
|
| 34 | - * @static |
|
| 35 | - * @access public |
|
| 36 | - * @param string $string string to handle |
|
| 37 | - * @param boolean $translate //todo what is this for? |
|
| 38 | - * @param boolean $protected true then we run htmlspecialchars and return |
|
| 39 | - * @return string |
|
| 40 | - */ |
|
| 41 | - public static function ee_tep_output_string($string, $translate = false, $protected = false) |
|
| 42 | - { |
|
| 43 | - if ($protected === true) { |
|
| 44 | - return htmlspecialchars($string); |
|
| 45 | - } else { |
|
| 46 | - if ($translate === false) { |
|
| 47 | - return self::ee_tep_parse_input_field_data($string, array( '"' => '"' )); |
|
| 48 | - } else { |
|
| 49 | - return self::ee_tep_parse_input_field_data($string, $translate); |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - } |
|
| 30 | + /** |
|
| 31 | + * ee_tep_output_string |
|
| 32 | + * todo: we need a description for this. |
|
| 33 | + * |
|
| 34 | + * @static |
|
| 35 | + * @access public |
|
| 36 | + * @param string $string string to handle |
|
| 37 | + * @param boolean $translate //todo what is this for? |
|
| 38 | + * @param boolean $protected true then we run htmlspecialchars and return |
|
| 39 | + * @return string |
|
| 40 | + */ |
|
| 41 | + public static function ee_tep_output_string($string, $translate = false, $protected = false) |
|
| 42 | + { |
|
| 43 | + if ($protected === true) { |
|
| 44 | + return htmlspecialchars($string); |
|
| 45 | + } else { |
|
| 46 | + if ($translate === false) { |
|
| 47 | + return self::ee_tep_parse_input_field_data($string, array( '"' => '"' )); |
|
| 48 | + } else { |
|
| 49 | + return self::ee_tep_parse_input_field_data($string, $translate); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | 54 | |
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * ee_tep_parse_input_field_data |
|
| 58 | - * |
|
| 59 | - * @param string $data string to be "translated" |
|
| 60 | - * @param array ] $parse array in the form array( 'from' => 'to', ... ) |
|
| 61 | - * @return string |
|
| 62 | - */ |
|
| 63 | - public static function ee_tep_parse_input_field_data($data, $parse) |
|
| 64 | - { |
|
| 65 | - return strtr(trim($data), $parse); |
|
| 66 | - } |
|
| 56 | + /** |
|
| 57 | + * ee_tep_parse_input_field_data |
|
| 58 | + * |
|
| 59 | + * @param string $data string to be "translated" |
|
| 60 | + * @param array ] $parse array in the form array( 'from' => 'to', ... ) |
|
| 61 | + * @return string |
|
| 62 | + */ |
|
| 63 | + public static function ee_tep_parse_input_field_data($data, $parse) |
|
| 64 | + { |
|
| 65 | + return strtr(trim($data), $parse); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | 68 | |
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * [ee_tep_not_null description] |
|
| 72 | - * |
|
| 73 | - * @param string | array $value [description] |
|
| 74 | - * @return bool [description] |
|
| 75 | - */ |
|
| 76 | - public static function ee_tep_not_null($value) |
|
| 77 | - { |
|
| 78 | - if (is_array($value)) { |
|
| 79 | - if (count($value) > 0) { |
|
| 80 | - return true; |
|
| 81 | - } else { |
|
| 82 | - return false; |
|
| 83 | - } |
|
| 84 | - } else { |
|
| 85 | - if (( $value !== '' ) && ( strtolower($value) !== 'null' ) && ( strlen(trim($value)) > 0 )) { |
|
| 86 | - return true; |
|
| 87 | - } else { |
|
| 88 | - return false; |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - } |
|
| 70 | + /** |
|
| 71 | + * [ee_tep_not_null description] |
|
| 72 | + * |
|
| 73 | + * @param string | array $value [description] |
|
| 74 | + * @return bool [description] |
|
| 75 | + */ |
|
| 76 | + public static function ee_tep_not_null($value) |
|
| 77 | + { |
|
| 78 | + if (is_array($value)) { |
|
| 79 | + if (count($value) > 0) { |
|
| 80 | + return true; |
|
| 81 | + } else { |
|
| 82 | + return false; |
|
| 83 | + } |
|
| 84 | + } else { |
|
| 85 | + if (( $value !== '' ) && ( strtolower($value) !== 'null' ) && ( strlen(trim($value)) > 0 )) { |
|
| 86 | + return true; |
|
| 87 | + } else { |
|
| 88 | + return false; |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | 93 | |
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * Formats a date |
|
| 97 | - * |
|
| 98 | - * @param string $date |
|
| 99 | - * @param string $format - format for the date |
|
| 100 | - * @deprecated 4.6.12 Note, a search revealed this was not used anywhere in core or in our |
|
| 101 | - * addons at time of writing this. So just deprecated in case of third party use. |
|
| 102 | - * @return string |
|
| 103 | - * @deprecated v4.6.21 |
|
| 104 | - */ |
|
| 105 | - public static function event_date_display($date, $format = '') |
|
| 106 | - { |
|
| 107 | - EE_Error::doing_it_wrong( |
|
| 108 | - __METHOD__, |
|
| 109 | - esc_html__( |
|
| 110 | - 'This method is deprecated as of EE 4.6.12. Currently it does not reformat as with prior behaviour but just returns the incoming string. Please use the EE_Datetime helpers for Datetime on the event to display as desired.', |
|
| 111 | - 'event_espresso' |
|
| 112 | - ), |
|
| 113 | - '4.6.21' |
|
| 114 | - ); |
|
| 115 | - return $date; |
|
| 116 | - } |
|
| 95 | + /** |
|
| 96 | + * Formats a date |
|
| 97 | + * |
|
| 98 | + * @param string $date |
|
| 99 | + * @param string $format - format for the date |
|
| 100 | + * @deprecated 4.6.12 Note, a search revealed this was not used anywhere in core or in our |
|
| 101 | + * addons at time of writing this. So just deprecated in case of third party use. |
|
| 102 | + * @return string |
|
| 103 | + * @deprecated v4.6.21 |
|
| 104 | + */ |
|
| 105 | + public static function event_date_display($date, $format = '') |
|
| 106 | + { |
|
| 107 | + EE_Error::doing_it_wrong( |
|
| 108 | + __METHOD__, |
|
| 109 | + esc_html__( |
|
| 110 | + 'This method is deprecated as of EE 4.6.12. Currently it does not reformat as with prior behaviour but just returns the incoming string. Please use the EE_Datetime helpers for Datetime on the event to display as desired.', |
|
| 111 | + 'event_espresso' |
|
| 112 | + ), |
|
| 113 | + '4.6.21' |
|
| 114 | + ); |
|
| 115 | + return $date; |
|
| 116 | + } |
|
| 117 | 117 | } |