1 | <?php |
||
11 | class GravityView_Field_Address extends GravityView_Field { |
||
12 | |||
13 | var $name = 'address'; |
||
14 | |||
15 | var $group = 'advanced'; |
||
16 | |||
17 | var $is_numeric = false; |
||
18 | |||
19 | var $is_searchable = true; |
||
20 | |||
21 | var $search_operators = array( 'is', 'isnot', 'contains' ); |
||
22 | |||
23 | var $_gf_field_class_name = 'GF_Field_Address'; |
||
24 | |||
25 | public function __construct() { |
||
32 | |||
33 | /** |
||
34 | * Add filters for this field type |
||
35 | * |
||
36 | * @since 1.19.2 |
||
37 | * |
||
38 | * @return void |
||
39 | */ |
||
40 | private function add_hooks() { |
||
45 | |||
46 | /** |
||
47 | * Dynamically add choices to the address field dropdowns, if any |
||
48 | * |
||
49 | * @since 1.19.2 |
||
50 | * |
||
51 | * @param array $search_fields Array of search filters with `key`, `label`, `value`, `type` keys |
||
52 | * @param GravityView_Widget_Search $widget Current widget object |
||
53 | * @param array $widget_args Args passed to this method. {@since 1.8} |
||
54 | * |
||
55 | * @return array If the search field GF Field type is `address`, and there are choices to add, adds them and changes the input type. Otherwise, sets the input to text. |
||
56 | */ |
||
57 | 4 | public function search_field_filter( $search_fields, $widget, $widget_args ) { |
|
94 | |||
95 | /** |
||
96 | * Get array of countries to use for the search choices |
||
97 | * |
||
98 | * @since 1.19.2 |
||
99 | * |
||
100 | * @see GF_Field_Address::get_countries() |
||
101 | * |
||
102 | * @param GF_Field_Address $address_field |
||
103 | * |
||
104 | * @return array Array of countries with `value` and `text` keys as the name of the country |
||
105 | */ |
||
106 | private function get_choices_country( $address_field ) { |
||
121 | |||
122 | /** |
||
123 | * Get array of states to use for the search choices |
||
124 | * |
||
125 | * @since 1.19.2 |
||
126 | * |
||
127 | * @uses GF_Field_Address::get_us_states() |
||
128 | * @uses GF_Field_Address::get_us_state_code() |
||
129 | * @uses GF_Field_Address::get_canadian_provinces() |
||
130 | * |
||
131 | * @param GF_Field_Address $address_field |
||
132 | * @param array $form |
||
133 | * |
||
134 | * @return array Array of countries with `value` and `text` keys as the name of the country |
||
135 | */ |
||
136 | private function get_choices_state( $address_field, $form ) { |
||
181 | |||
182 | /** |
||
183 | * Add the input types available for each custom search field type |
||
184 | * |
||
185 | * @since 1.19.2 |
||
186 | * |
||
187 | * @param array $input_types Array of input types as the keys (`select`, `radio`, `multiselect`, `input_text`) with a string or array of supported inputs as values |
||
188 | * |
||
189 | * @return array $input_types array, but |
||
190 | */ |
||
191 | public function input_types( $input_types ) { |
||
206 | |||
207 | /** |
||
208 | * Converts the custom input type (address) into the selected type |
||
209 | * |
||
210 | * @since 1.19.2 |
||
211 | * |
||
212 | * @param string $input_type Assign an input type according to the form field type. Defaults: `boolean`, `multi`, `select`, `date`, `text` |
||
213 | * @param string $field_type Gravity Forms field type (also the `name` parameter of GravityView_Field classes) |
||
214 | * @param string|int|float $field_id ID of the field being processed |
||
215 | * |
||
216 | * @return string If the field ID matches an address field input, return those options {@see GravityView_Field_Address::input_types() }. Otherwise, original value is used. |
||
217 | */ |
||
218 | public function search_bar_input_type( $input_type, $field_type, $field_id ) { |
||
234 | |||
235 | /** |
||
236 | * Get a name for the input based on the input ID |
||
237 | * |
||
238 | * @since 1.19.2 |
||
239 | * |
||
240 | * @param int $input_id ID of the specific input for the address field |
||
241 | * |
||
242 | * @return false|string If the input ID matches a known address field input, returns a name for that input ("city", or "country"). Otherwise, returns false. |
||
243 | */ |
||
244 | private static function get_input_type_from_input_id( $input_id ) { |
||
272 | |||
273 | public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { |
||
296 | |||
297 | } |
||
298 | |||
300 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.