1 | <?php |
||
10 | class GoogleAddressField extends TextField |
||
11 | { |
||
12 | private static $google_map_api_location = '//maps.googleapis.com/maps/api/js'; |
||
13 | |||
14 | private static $field_js_location = 'google_address_field/javascript/GoogleAddressField.js'; |
||
15 | |||
16 | |||
17 | //when autocomplete returns a place we check if the type is an allowed type and if not |
||
18 | //provide the user an alert to let them know their address may not have been correctly autocompleted |
||
19 | private static $allowed_types = ['street_address']; |
||
20 | |||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | private static $api_key = ""; |
||
25 | |||
26 | /** |
||
27 | * return a list of requirements |
||
28 | * @return [type] [description] |
||
|
|||
29 | */ |
||
30 | public static function js_requirements() |
||
47 | |||
48 | /** |
||
49 | * |
||
50 | * @var bool |
||
51 | */ |
||
52 | protected $useSensor = false; |
||
53 | |||
54 | /** |
||
55 | * Do you want this annoying ... |
||
56 | * this website wants to know exactly where you are |
||
57 | * and what you are wearing thing ... |
||
58 | * then this is your VAR. |
||
59 | * |
||
60 | * @param bool |
||
61 | */ |
||
62 | public function setUseSensor($b) |
||
67 | |||
68 | protected $alwaysShowFields = false; |
||
69 | |||
70 | /** |
||
71 | * @param bool |
||
72 | */ |
||
73 | public function setAlwaysShowFields($b) |
||
78 | |||
79 | /** |
||
80 | * Link to the static map. Set to an empty string to have no static image appear. |
||
81 | * Use the [ADDRESS] tag to insert the address... |
||
82 | * user the [MAXWIDTH] tag to set it automatically to the width of the container. |
||
83 | * |
||
84 | * @var string |
||
85 | */ |
||
86 | protected $googleStaticMapLink = '//maps.googleapis.com/maps/api/staticmap?center=[ADDRESS]&zoom=17&scale=false&size=[MAXWIDTH]x[MAXHEIGHT]&maptype=roadmap&format=png&visual_refresh=true&markers=size:mid%7Ccolor:red%7Clabel:%7C[ADDRESS]'; |
||
87 | |||
88 | /** |
||
89 | * set to empty string to NOT show a static map. |
||
90 | * |
||
91 | * @param string |
||
92 | */ |
||
93 | public function setGoogleStaticMapLink($s) |
||
98 | |||
99 | /** |
||
100 | * get to empty string to NOT show a static map. |
||
101 | * |
||
102 | * @return string |
||
103 | */ |
||
104 | public function getGoogleStaticMapLink() |
||
108 | |||
109 | /** |
||
110 | * CSS file used in this field (can be themed!). |
||
111 | * |
||
112 | * @var string |
||
113 | */ |
||
114 | protected $cssLocation = 'GoogleAddressField'; |
||
115 | |||
116 | /** |
||
117 | * @param string |
||
118 | */ |
||
119 | public function setCssLocation($s) |
||
124 | |||
125 | /** |
||
126 | * list of links between |
||
127 | * form fields in the current field (e.g. TextField with name City) |
||
128 | * and the result XML. |
||
129 | * When the results are returned this field will fill the form |
||
130 | * fields with XML data from the results using this array |
||
131 | * Format is: |
||
132 | * [formFieldName] => array( |
||
133 | * resultType1 => 'long_name', |
||
134 | * resultType2 => 'long_name', |
||
135 | * resultType2 => 'short_name', |
||
136 | * etc... |
||
137 | * ) |
||
138 | * e.g. |
||
139 | * <code php> |
||
140 | * "BillingRegion" => array("administrative_area_level_1" => "long_name", "country" => "short_name") |
||
141 | * </code>. |
||
142 | * |
||
143 | * @var array |
||
144 | */ |
||
145 | protected $fieldMap = array(); |
||
146 | |||
147 | /** |
||
148 | * @param array |
||
149 | */ |
||
150 | public function setFieldMap($a) |
||
155 | |||
156 | /** |
||
157 | * @param string $formField |
||
158 | * @param array $arrayOfGeoData |
||
159 | */ |
||
160 | public function addFieldMapEntry($formField, $arrayOfGeoData) |
||
165 | |||
166 | /** |
||
167 | * @param string $formField |
||
168 | */ |
||
169 | public function removeFieldMapEntry($formField) |
||
173 | |||
174 | /** |
||
175 | * @return array |
||
176 | */ |
||
177 | public function getFieldMap() |
||
181 | |||
182 | |||
183 | protected $typeToBeReturned = 'address'; |
||
184 | |||
185 | /** |
||
186 | * @param string $code - e.g. address |
||
187 | */ |
||
188 | public function setTypeToBeReturned($ype) |
||
194 | |||
195 | |||
196 | protected $restrictToCountryCode = ''; |
||
197 | |||
198 | /** |
||
199 | * @param string $code - e.g. NZ |
||
200 | */ |
||
201 | public function setRestrictToCountryCode($code) |
||
207 | |||
208 | /** |
||
209 | * @return string |
||
210 | */ |
||
211 | public function getRestrictToCountryCode() |
||
215 | |||
216 | |||
217 | |||
218 | /** |
||
219 | * @return bool |
||
220 | */ |
||
221 | public function hasData() |
||
225 | |||
226 | /** |
||
227 | * @return string |
||
228 | */ |
||
229 | public function Field($properties = array()) |
||
264 | |||
265 | /** |
||
266 | * retuns the customised Javascript for the form field. |
||
267 | * |
||
268 | * @return string |
||
269 | */ |
||
270 | protected function getJavascript() |
||
285 | /** |
||
286 | * @return string |
||
287 | */ |
||
288 | public function RightTitle() |
||
295 | } |
||
296 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.