@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | */ |
22 | 22 | |
23 | 23 | |
24 | -if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
25 | - exit( 'No direct script access allowed' ); |
|
24 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
25 | + exit('No direct script access allowed'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | class Model_Data_Translator { |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | * @param string $requested_version |
41 | 41 | * @return mixed |
42 | 42 | */ |
43 | - public static function prepare_field_values_from_json( $field_obj, $original_value_maybe_array, $requested_version ) { |
|
44 | - if( is_array( $original_value_maybe_array ) ) { |
|
43 | + public static function prepare_field_values_from_json($field_obj, $original_value_maybe_array, $requested_version) { |
|
44 | + if (is_array($original_value_maybe_array)) { |
|
45 | 45 | $new_value_maybe_array = array(); |
46 | - foreach( $original_value_maybe_array as $array_key => $array_item ) { |
|
47 | - $new_value_maybe_array[ $array_key ] = Model_Data_Translator::prepare_field_value_from_json( $field_obj, $array_item, $requested_version ); |
|
46 | + foreach ($original_value_maybe_array as $array_key => $array_item) { |
|
47 | + $new_value_maybe_array[$array_key] = Model_Data_Translator::prepare_field_value_from_json($field_obj, $array_item, $requested_version); |
|
48 | 48 | } |
49 | 49 | } else { |
50 | - $new_value_maybe_array = Model_Data_Translator::prepare_field_value_from_json( $field_obj, $original_value_maybe_array, $requested_version ); |
|
50 | + $new_value_maybe_array = Model_Data_Translator::prepare_field_value_from_json($field_obj, $original_value_maybe_array, $requested_version); |
|
51 | 51 | } |
52 | 52 | return $new_value_maybe_array; |
53 | 53 | } |
@@ -59,14 +59,14 @@ discard block |
||
59 | 59 | * @param string $request_version (eg 4.8.36) |
60 | 60 | * @return array |
61 | 61 | */ |
62 | - public static function prepare_field_values_for_json( $field_obj, $original_value_maybe_array, $request_version ){ |
|
63 | - if( is_array( $original_value_maybe_array ) ) { |
|
62 | + public static function prepare_field_values_for_json($field_obj, $original_value_maybe_array, $request_version) { |
|
63 | + if (is_array($original_value_maybe_array)) { |
|
64 | 64 | $new_value_maybe_array = array(); |
65 | - foreach( $original_value_maybe_array as $array_key => $array_item ) { |
|
66 | - $new_value_maybe_array[ $array_key ] = Model_Data_Translator::prepare_field_value_for_json( $field_obj, $array_item, $request_version ); |
|
65 | + foreach ($original_value_maybe_array as $array_key => $array_item) { |
|
66 | + $new_value_maybe_array[$array_key] = Model_Data_Translator::prepare_field_value_for_json($field_obj, $array_item, $request_version); |
|
67 | 67 | } |
68 | 68 | } else { |
69 | - $new_value_maybe_array = Model_Data_Translator::prepare_field_value_for_json( $field_obj, $original_value_maybe_array, $request_version ); |
|
69 | + $new_value_maybe_array = Model_Data_Translator::prepare_field_value_for_json($field_obj, $original_value_maybe_array, $request_version); |
|
70 | 70 | } |
71 | 71 | return $new_value_maybe_array; |
72 | 72 | } |
@@ -79,13 +79,13 @@ discard block |
||
79 | 79 | * @param string $requested_version |
80 | 80 | * @return mixed |
81 | 81 | */ |
82 | - public static function prepare_field_value_from_json( $field_obj, $original_value, $requested_version ) { |
|
82 | + public static function prepare_field_value_from_json($field_obj, $original_value, $requested_version) { |
|
83 | 83 | $new_value = null; |
84 | - if( $field_obj instanceof \EE_Infinite_Integer_Field |
|
85 | - && in_array( $original_value, array( null, '' ), true ) ) { |
|
84 | + if ($field_obj instanceof \EE_Infinite_Integer_Field |
|
85 | + && in_array($original_value, array(null, ''), true)) { |
|
86 | 86 | $new_value = EE_INF; |
87 | - } elseif( $field_obj instanceof \EE_Datetime_Field ) { |
|
88 | - $new_value = rest_parse_date( $original_value ); |
|
87 | + } elseif ($field_obj instanceof \EE_Datetime_Field) { |
|
88 | + $new_value = rest_parse_date($original_value); |
|
89 | 89 | } else { |
90 | 90 | $new_value = $original_value; |
91 | 91 | } |
@@ -98,22 +98,22 @@ discard block |
||
98 | 98 | * @param mixed $original_value |
99 | 99 | * @return mixed |
100 | 100 | */ |
101 | - public static function prepare_field_value_for_json( $field_obj, $original_value, $requested_version ) { |
|
102 | - if( $original_value === EE_INF ) { |
|
101 | + public static function prepare_field_value_for_json($field_obj, $original_value, $requested_version) { |
|
102 | + if ($original_value === EE_INF) { |
|
103 | 103 | $new_value = Model_Data_Translator::ee_inf_in_rest; |
104 | - } elseif( $field_obj instanceof \EE_Datetime_Field ) { |
|
105 | - if( $original_value instanceof \DateTime ) { |
|
106 | - $new_value = $original_value->format( 'Y-m-d H:i:s' ); |
|
107 | - } elseif( is_int( $original_value ) ) { |
|
108 | - $new_value = date( 'Y-m-d H:i:s', $original_value ); |
|
104 | + } elseif ($field_obj instanceof \EE_Datetime_Field) { |
|
105 | + if ($original_value instanceof \DateTime) { |
|
106 | + $new_value = $original_value->format('Y-m-d H:i:s'); |
|
107 | + } elseif (is_int($original_value)) { |
|
108 | + $new_value = date('Y-m-d H:i:s', $original_value); |
|
109 | 109 | } else { |
110 | 110 | $new_value = $original_value; |
111 | 111 | } |
112 | - $new_value = mysql_to_rfc3339( $new_value ); |
|
112 | + $new_value = mysql_to_rfc3339($new_value); |
|
113 | 113 | } else { |
114 | 114 | $new_value = $original_value; |
115 | 115 | } |
116 | - return apply_filters( 'FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_field_for_rest_api', |
|
116 | + return apply_filters('FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_field_for_rest_api', |
|
117 | 117 | $new_value, |
118 | 118 | $field_obj, |
119 | 119 | $original_value, |
@@ -129,29 +129,29 @@ discard block |
||
129 | 129 | * @param string $requested_version |
130 | 130 | * @return array |
131 | 131 | */ |
132 | - public static function prepare_conditions_query_params_for_models( $inputted_query_params_of_this_type, \EEM_Base $model, $requested_version ) { |
|
132 | + public static function prepare_conditions_query_params_for_models($inputted_query_params_of_this_type, \EEM_Base $model, $requested_version) { |
|
133 | 133 | $query_param_for_models = array(); |
134 | - foreach( $inputted_query_params_of_this_type as $query_param_key => $query_param_value ) { |
|
134 | + foreach ($inputted_query_params_of_this_type as $query_param_key => $query_param_value) { |
|
135 | 135 | $field = Model_Data_Translator::deduce_field_from_query_param( |
136 | - Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key( $query_param_key ), |
|
136 | + Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key($query_param_key), |
|
137 | 137 | $model |
138 | 138 | ); |
139 | - if( $field instanceof \EE_Model_Field_Base ) { |
|
139 | + if ($field instanceof \EE_Model_Field_Base) { |
|
140 | 140 | //did they specify an operator? |
141 | - if( is_array( $query_param_value ) ) { |
|
142 | - $op = $query_param_value[ 0 ]; |
|
143 | - $translated_value = array( $op ); |
|
144 | - if( isset( $query_param_value[ 1 ] ) ) { |
|
145 | - $value = $query_param_value[ 1 ]; |
|
146 | - $translated_value[1] = Model_Data_Translator::prepare_field_values_from_json( $field, $value, $requested_version ); |
|
141 | + if (is_array($query_param_value)) { |
|
142 | + $op = $query_param_value[0]; |
|
143 | + $translated_value = array($op); |
|
144 | + if (isset($query_param_value[1])) { |
|
145 | + $value = $query_param_value[1]; |
|
146 | + $translated_value[1] = Model_Data_Translator::prepare_field_values_from_json($field, $value, $requested_version); |
|
147 | 147 | } |
148 | 148 | } else { |
149 | - $translated_value = Model_Data_Translator::prepare_field_value_from_json( $field, $query_param_value, $requested_version ); |
|
149 | + $translated_value = Model_Data_Translator::prepare_field_value_from_json($field, $query_param_value, $requested_version); |
|
150 | 150 | } |
151 | - $query_param_for_models[ $query_param_key ] = $translated_value; |
|
151 | + $query_param_for_models[$query_param_key] = $translated_value; |
|
152 | 152 | } else { |
153 | 153 | //so it's not for a field, assume it's a logic query param key |
154 | - $query_param_for_models[ $query_param_key ] = Model_Data_Translator::prepare_conditions_query_params_for_models( $query_param_value, $model, $requested_version ); |
|
154 | + $query_param_for_models[$query_param_key] = Model_Data_Translator::prepare_conditions_query_params_for_models($query_param_value, $model, $requested_version); |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | return $query_param_for_models; |
@@ -164,27 +164,27 @@ discard block |
||
164 | 164 | * @param string $requested_version eg "4.8.36". If null is provided, defaults to the latest release of the EE4 REST API |
165 | 165 | * @return array which can be passed into the EE4 REST API when querying a model resource |
166 | 166 | */ |
167 | - public static function prepare_query_params_for_rest_api( $model_query_params, \EEM_Base $model, $requested_version = null ) { |
|
168 | - if( $requested_version === null ) { |
|
169 | - $requested_version = \EED_Core_Rest_Api::latest_rest_api_version() ; |
|
167 | + public static function prepare_query_params_for_rest_api($model_query_params, \EEM_Base $model, $requested_version = null) { |
|
168 | + if ($requested_version === null) { |
|
169 | + $requested_version = \EED_Core_Rest_Api::latest_rest_api_version(); |
|
170 | 170 | } |
171 | 171 | $rest_query_params = $model_query_params; |
172 | - if ( isset( $model_query_params[0] ) ) { |
|
173 | - $rest_query_params[ 'where' ] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api( |
|
174 | - $model_query_params[ 0 ], |
|
172 | + if (isset($model_query_params[0])) { |
|
173 | + $rest_query_params['where'] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api( |
|
174 | + $model_query_params[0], |
|
175 | 175 | $model, |
176 | 176 | $requested_version |
177 | 177 | ); |
178 | - unset( $rest_query_params[0] ); |
|
178 | + unset($rest_query_params[0]); |
|
179 | 179 | } |
180 | - if ( isset( $model_query_params[ 'having' ] ) ) { |
|
181 | - $rest_query_params[ 'having' ] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api( |
|
182 | - $model_query_params[ 'having' ], |
|
180 | + if (isset($model_query_params['having'])) { |
|
181 | + $rest_query_params['having'] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api( |
|
182 | + $model_query_params['having'], |
|
183 | 183 | $model, |
184 | 184 | $requested_version |
185 | 185 | ); |
186 | 186 | } |
187 | - return apply_filters( 'FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_query_params_for_rest_api', $rest_query_params, $model_query_params, $model, $requested_version ); |
|
187 | + return apply_filters('FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_query_params_for_rest_api', $rest_query_params, $model_query_params, $model, $requested_version); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
@@ -194,39 +194,39 @@ discard block |
||
194 | 194 | * @param string $requested_version eg "4.8.36" |
195 | 195 | * @return array ready for use in the rest api query params |
196 | 196 | */ |
197 | - public static function prepare_conditions_query_params_for_rest_api( $inputted_query_params_of_this_type, \EEM_Base $model, $requested_version ) { |
|
197 | + public static function prepare_conditions_query_params_for_rest_api($inputted_query_params_of_this_type, \EEM_Base $model, $requested_version) { |
|
198 | 198 | $query_param_for_models = array(); |
199 | - foreach( $inputted_query_params_of_this_type as $query_param_key => $query_param_value ) { |
|
199 | + foreach ($inputted_query_params_of_this_type as $query_param_key => $query_param_value) { |
|
200 | 200 | $field = Model_Data_Translator::deduce_field_from_query_param( |
201 | - Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key( $query_param_key ), |
|
201 | + Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key($query_param_key), |
|
202 | 202 | $model |
203 | 203 | ); |
204 | - if( $field instanceof \EE_Model_Field_Base ) { |
|
204 | + if ($field instanceof \EE_Model_Field_Base) { |
|
205 | 205 | //did they specify an operator? |
206 | - if( is_array( $query_param_value ) ) { |
|
207 | - $op = $query_param_value[ 0 ]; |
|
208 | - $translated_value = array( $op ); |
|
209 | - if( isset( $query_param_value[ 1 ] ) ) { |
|
210 | - $value = $query_param_value[ 1 ]; |
|
211 | - $translated_value[1] = Model_Data_Translator::prepare_field_values_for_json( $field, $value, $requested_version ); |
|
206 | + if (is_array($query_param_value)) { |
|
207 | + $op = $query_param_value[0]; |
|
208 | + $translated_value = array($op); |
|
209 | + if (isset($query_param_value[1])) { |
|
210 | + $value = $query_param_value[1]; |
|
211 | + $translated_value[1] = Model_Data_Translator::prepare_field_values_for_json($field, $value, $requested_version); |
|
212 | 212 | } |
213 | 213 | } else { |
214 | - $translated_value = Model_Data_Translator::prepare_field_value_for_json( $field, $query_param_value, $requested_version ); |
|
214 | + $translated_value = Model_Data_Translator::prepare_field_value_for_json($field, $query_param_value, $requested_version); |
|
215 | 215 | } |
216 | - $query_param_for_models[ $query_param_key ] = $translated_value; |
|
216 | + $query_param_for_models[$query_param_key] = $translated_value; |
|
217 | 217 | } else { |
218 | 218 | //so it's not for a field, assume it's a logic query param key |
219 | - $query_param_for_models[ $query_param_key ] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api( $query_param_value, $model, $requested_version ); |
|
219 | + $query_param_for_models[$query_param_key] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api($query_param_value, $model, $requested_version); |
|
220 | 220 | } |
221 | 221 | } |
222 | 222 | return $query_param_for_models; |
223 | 223 | } |
224 | 224 | |
225 | - public static function remove_stars_and_anything_after_from_condition_query_param_key( $condition_query_param_key ) { |
|
225 | + public static function remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key) { |
|
226 | 226 | $pos_of_star = strpos($condition_query_param_key, '*'); |
227 | - if($pos_of_star === FALSE){ |
|
227 | + if ($pos_of_star === FALSE) { |
|
228 | 228 | return $condition_query_param_key; |
229 | - }else{ |
|
229 | + } else { |
|
230 | 230 | $condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star); |
231 | 231 | return $condition_query_param_sans_star; |
232 | 232 | } |
@@ -238,26 +238,26 @@ discard block |
||
238 | 238 | * @throws EE_Error |
239 | 239 | * @return EE_Model_Field_Base |
240 | 240 | */ |
241 | - public static function deduce_field_from_query_param($query_param_name, \EEM_Base $model){ |
|
241 | + public static function deduce_field_from_query_param($query_param_name, \EEM_Base $model) { |
|
242 | 242 | //ok, now proceed with deducing which part is the model's name, and which is the field's name |
243 | 243 | //which will help us find the database table and column |
244 | 244 | |
245 | - $query_param_parts = explode(".",$query_param_name); |
|
246 | - if(empty($query_param_parts)){ |
|
247 | - throw new \EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s",'event_espresso'),$query_param_name)); |
|
245 | + $query_param_parts = explode(".", $query_param_name); |
|
246 | + if (empty($query_param_parts)) { |
|
247 | + throw new \EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s", 'event_espresso'), $query_param_name)); |
|
248 | 248 | } |
249 | 249 | $number_of_parts = count($query_param_parts); |
250 | - $last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ]; |
|
251 | - if($number_of_parts == 1){ |
|
250 | + $last_query_param_part = $query_param_parts[count($query_param_parts) - 1]; |
|
251 | + if ($number_of_parts == 1) { |
|
252 | 252 | $field_name = $last_query_param_part; |
253 | - }else{// $number_of_parts >= 2 |
|
253 | + } else {// $number_of_parts >= 2 |
|
254 | 254 | //the last part is the column name, and there are only 2parts. therefore... |
255 | 255 | $field_name = $last_query_param_part; |
256 | - $model = \EE_Registry::instance()->load_model( $query_param_parts[ $number_of_parts - 2 ]); |
|
256 | + $model = \EE_Registry::instance()->load_model($query_param_parts[$number_of_parts - 2]); |
|
257 | 257 | } |
258 | - try{ |
|
258 | + try { |
|
259 | 259 | return $model->field_settings_for($field_name); |
260 | - }catch(\EE_Error $e){ |
|
260 | + } catch (\EE_Error $e) { |
|
261 | 261 | return null; |
262 | 262 | } |
263 | 263 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @author Mike Nelson |
10 | 10 | */ |
11 | 11 | use EventEspresso\core\libraries\rest_api\Model_Data_Translator; |
12 | -class EE_Select_Ajax_Model_Rest_Input extends EE_Form_Input_With_Options_Base{ |
|
12 | +class EE_Select_Ajax_Model_Rest_Input extends EE_Form_Input_With_Options_Base { |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * @var string $_model_name |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * And the arguments accepted by EE_Form_Input_With_Options_Base |
44 | 44 | * @throws \EE_Error |
45 | 45 | */ |
46 | - public function __construct( $input_settings = array() ) { |
|
46 | + public function __construct($input_settings = array()) { |
|
47 | 47 | //needed input settings: |
48 | 48 | //select2_args |
49 | 49 | $this->_model_name = EEH_Array::is_set( |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | $query_params = EEH_Array::is_set( |
56 | 56 | $input_settings, |
57 | 57 | 'query_params', |
58 | - array( 'limit' => 10, 'caps' => EEM_Base::caps_read_admin ) |
|
58 | + array('limit' => 10, 'caps' => EEM_Base::caps_read_admin) |
|
59 | 59 | ); |
60 | 60 | $this->_value_field_name = EEH_Array::is_set( |
61 | 61 | $input_settings, |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $this->_display_field_name = EEH_Array::is_set( |
66 | 66 | $input_settings, |
67 | 67 | 'display_field_name', |
68 | - $model->get_a_field_of_type( 'EE_Text_Field_Base' )->get_name() |
|
68 | + $model->get_a_field_of_type('EE_Text_Field_Base')->get_name() |
|
69 | 69 | ); |
70 | 70 | $this->_add_validation_strategy( |
71 | 71 | new EE_Model_Matching_Query_Validation_Strategy( |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | ); |
78 | 78 | //get resource endpoint |
79 | 79 | $rest_controller = new EventEspresso\core\libraries\rest_api\controllers\model\Read(); |
80 | - $rest_controller->set_requested_version( EED_Core_Rest_Api::latest_rest_api_version() ); |
|
81 | - $url = $rest_controller->get_versioned_link_to( EEH_Inflector::pluralize_and_lower( $this->_model_name ) ); |
|
80 | + $rest_controller->set_requested_version(EED_Core_Rest_Api::latest_rest_api_version()); |
|
81 | + $url = $rest_controller->get_versioned_link_to(EEH_Inflector::pluralize_and_lower($this->_model_name)); |
|
82 | 82 | $default_select2_args = array( |
83 | 83 | 'ajax' => array( |
84 | 84 | 'url' => $url, |
@@ -86,13 +86,13 @@ discard block |
||
86 | 86 | 'delay' => '250', |
87 | 87 | 'data_interface' => 'EE_Select2_REST_API_Interface', |
88 | 88 | 'data_interface_args' => array( |
89 | - 'default_query_params' => (object)Model_Data_Translator::prepare_query_params_for_rest_api( |
|
89 | + 'default_query_params' => (object) Model_Data_Translator::prepare_query_params_for_rest_api( |
|
90 | 90 | $query_params, |
91 | 91 | $model |
92 | 92 | ), |
93 | 93 | 'display_field' => $this->_display_field_name, |
94 | 94 | 'value_field' => $this->_value_field_name, |
95 | - 'nonce' => wp_create_nonce( 'wp_rest' ) |
|
95 | + 'nonce' => wp_create_nonce('wp_rest') |
|
96 | 96 | ), |
97 | 97 | ), |
98 | 98 | 'cache' => true, |
@@ -100,10 +100,10 @@ discard block |
||
100 | 100 | ); |
101 | 101 | $select2_args = array_replace_recursive( |
102 | 102 | $default_select2_args, |
103 | - (array)EEH_Array::is_set( $input_settings, 'select2_args', array() ) |
|
103 | + (array) EEH_Array::is_set($input_settings, 'select2_args', array()) |
|
104 | 104 | ); |
105 | - $this->set_display_strategy( new EE_Select2_Display_Strategy( $select2_args ) ); |
|
106 | - parent::__construct( array(), $input_settings ); |
|
105 | + $this->set_display_strategy(new EE_Select2_Display_Strategy($select2_args)); |
|
106 | + parent::__construct(array(), $input_settings); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | |
@@ -116,33 +116,33 @@ discard block |
||
116 | 116 | * @return void |
117 | 117 | * @throws \EE_Error |
118 | 118 | */ |
119 | - public function set_default( $value ) { |
|
119 | + public function set_default($value) { |
|
120 | 120 | |
121 | - $values_for_options = (array)$value; |
|
122 | - $value_field = $this->_get_model()->field_settings_for( $this->_value_field_name ); |
|
123 | - $display_field = $this->_get_model()->field_settings_for( $this->_display_field_name ); |
|
121 | + $values_for_options = (array) $value; |
|
122 | + $value_field = $this->_get_model()->field_settings_for($this->_value_field_name); |
|
123 | + $display_field = $this->_get_model()->field_settings_for($this->_display_field_name); |
|
124 | 124 | $display_values = $this->_get_model()->get_all_wpdb_results( |
125 | 125 | array( |
126 | 126 | array( |
127 | - $this->_value_field_name => array( 'IN', $values_for_options ) |
|
127 | + $this->_value_field_name => array('IN', $values_for_options) |
|
128 | 128 | ) |
129 | 129 | ), |
130 | 130 | ARRAY_A, |
131 | 131 | implode( |
132 | 132 | ',', |
133 | 133 | array( |
134 | - $value_field->get_qualified_column() . ' AS ' . $this->_value_field_name, |
|
135 | - $display_field->get_qualified_column() . ' AS ' . $this->_display_field_name |
|
134 | + $value_field->get_qualified_column().' AS '.$this->_value_field_name, |
|
135 | + $display_field->get_qualified_column().' AS '.$this->_display_field_name |
|
136 | 136 | ) |
137 | 137 | ) |
138 | 138 | ); |
139 | 139 | $select_options = array(); |
140 | - foreach( $display_values as $db_rows ) { |
|
141 | - $db_rows = (array)$db_rows; |
|
142 | - $select_options[ $db_rows[ $this->_value_field_name ] ] = $db_rows[ $this->_display_field_name ]; |
|
140 | + foreach ($display_values as $db_rows) { |
|
141 | + $db_rows = (array) $db_rows; |
|
142 | + $select_options[$db_rows[$this->_value_field_name]] = $db_rows[$this->_display_field_name]; |
|
143 | 143 | } |
144 | - $this->set_select_options( $select_options ); |
|
145 | - parent::set_default( $value ); |
|
144 | + $this->set_select_options($select_options); |
|
145 | + parent::set_default($value); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * @throws EE_Error |
152 | 152 | */ |
153 | 153 | protected function _get_model() { |
154 | - if( ! EE_Registry::instance()->is_model_name( $this->_model_name ) ) { |
|
154 | + if ( ! EE_Registry::instance()->is_model_name($this->_model_name)) { |
|
155 | 155 | throw new EE_Error( |
156 | 156 | sprintf( |
157 | 157 | __( |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | ) |
163 | 163 | ); |
164 | 164 | } else { |
165 | - return EE_Registry::instance()->load_model( $this->_model_name ); |
|
165 | + return EE_Registry::instance()->load_model($this->_model_name); |
|
166 | 166 | } |
167 | 167 | } |
168 | 168 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @since 4.6 |
9 | 9 | * |
10 | 10 | */ |
11 | -abstract class EE_Display_Strategy_Base extends EE_Form_Input_Strategy_Base{ |
|
11 | +abstract class EE_Display_Strategy_Base extends EE_Form_Input_Strategy_Base { |
|
12 | 12 | /** |
13 | 13 | * returns HTML and javascript related to the displaying of this input |
14 | 14 | * @return string |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | * @param string $chars - exact string of characters to remove |
25 | 25 | * @return string |
26 | 26 | */ |
27 | - protected function _remove_chars( $string = '', $chars = '-' ) { |
|
28 | - $char_length = strlen( $chars ) * -1; |
|
27 | + protected function _remove_chars($string = '', $chars = '-') { |
|
28 | + $char_length = strlen($chars) * -1; |
|
29 | 29 | // if last three characters of string is " - ", then remove it |
30 | - return substr( $string, $char_length ) === $chars ? substr( $string, 0, $char_length ) : $string; |
|
30 | + return substr($string, $char_length) === $chars ? substr($string, 0, $char_length) : $string; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -39,16 +39,16 @@ discard block |
||
39 | 39 | * @param string $chars - exact string of characters to be added to end of string |
40 | 40 | * @return string |
41 | 41 | */ |
42 | - protected function _append_chars( $string = '', $chars = '-' ) { |
|
43 | - return $this->_remove_chars( $string, $chars ) . $chars; |
|
42 | + protected function _append_chars($string = '', $chars = '-') { |
|
43 | + return $this->_remove_chars($string, $chars).$chars; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
47 | 47 | * Gets the HTML IDs of all the inputs |
48 | 48 | * @return array |
49 | 49 | */ |
50 | - public function get_html_input_ids( $add_pound_sign = false ) { |
|
51 | - return array( $this->get_input()->html_id( $add_pound_sign ) ); |
|
50 | + public function get_html_input_ids($add_pound_sign = false) { |
|
51 | + return array($this->get_input()->html_id($add_pound_sign)); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @param array $other_js_data |
61 | 61 | * @return array |
62 | 62 | */ |
63 | - public function get_other_js_data( $other_js_data = array() ) { |
|
63 | + public function get_other_js_data($other_js_data = array()) { |
|
64 | 64 | return $other_js_data; |
65 | 65 | } |
66 | 66 |