4
4
*
5
5
* (c) 2005-2009 Christian Technology Ministries International Inc.
6
6
* All rights reserved
7
- * (c) 2011-2013 Jan Bartels, j.bartels@arcor.de, Google API V3
7
+ * (c) 2011-2015 Jan Bartels, j.bartels@arcor.de, Google API V3
8
8
*
9
9
* parts from static_info_tables:
10
10
* (c) 2013 Stanislas Rolland <typo3(arobas)sjbr.ca>
36
36
* @author j.bartels
37
37
*/
38
38
39
-
40
- #require_once(PATH_t3lib.'class.t3lib_svbase.php');
41
- #require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('wec_map').'class.tx_wecmap_domainmgr.php');
39
+ namespace JBartels \WecMap \GeocodeService ;
42
40
43
41
/**
44
42
* Service providing lat/long lookup via the Google Maps web service.
47
45
* @package TYPO3
48
46
* @subpackage tx_wecmap
49
47
*/
50
- class tx_wecmap_geocode_google extends t3lib_svbase {
51
- var $ prefixId = 'tx_wecmap_geocode_google ' ; // Same as class name
52
- var $ scriptRelPath = 'geocode_service/class.tx_wecmap_geocode_google.php ' ; // Path to this script relative to the extension dir.
53
- var $ extKey = 'wec_map ' ; // The extension key.
48
+ class Google extends \TYPO3 \CMS \Core \Service \AbstractService {
49
+ var $ prefixId = 'WecMapGeocodeGoogle ' ; // for temporary files
54
50
55
51
/**
56
52
* Returns the type of an iso code: nr, 2, 3
@@ -137,9 +133,6 @@ function lookup($street, $city, $state, $zip, $country, $key='') {
137
133
{
138
134
// format address for Google search based on local address-format for given $country
139
135
140
- // load and init Static Info Tables
141
- #require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('static_info_tables').'class.tx_staticinfotables_div.php');
142
-
143
136
// convert $country to ISO3
144
137
$ countryCodeType = self ::isoCodeType ($ country );
145
138
if ($ countryCodeType == 'nr ' ) {
@@ -198,9 +191,6 @@ function lookup($street, $city, $state, $zip, $country, $key='') {
198
191
199
192
// build URL
200
193
$ lookupstr = trim ( $ addressString );
201
- # Google requires utf-8; convert query if neccessary
202
- // if ( $GLOBALS['TSFE']->renderCharset != 'utf-8' )
203
- // $lookupstr = utf8_encode( $lookupstr );
204
194
205
195
$ url = 'http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address= ' . urlencode ( $ lookupstr );
206
196
if ( $ region )
@@ -299,57 +289,20 @@ function lookup($street, $city, $state, $zip, $country, $key='') {
299
289
* @return string The formated address using the country address format (cn_address_format)
300
290
*/
301
291
function formatAddress ($ delim , $ streetAddress , $ city , $ zip , $ subdivisionCode ='' , $ countryCode ='' ) {
302
-
303
- if (TYPO3_MODE == 'FE ' )
304
- {
305
- #require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('static_info_tables').'pi1/class.tx_staticinfotables_pi1.php');
306
- $ staticInfoObj = \TYPO3 \CMS \Core \Utility \GeneralUtility::makeInstance ('SJBR \\StaticInfoTables \\PiBaseApi ' );
307
- if ($ staticInfoObj ->needsInit ()) {
292
+ /** @var \SJBR\StaticInfoTables\PiBaseApi $staticInfoObj */
293
+ $ staticInfoObj = \TYPO3 \CMS \Core \Utility \GeneralUtility::makeInstance (\SJBR \StaticInfoTables \PiBaseApi::class);
294
+ if ($ staticInfoObj ->needsInit ()) {
295
+ if (TYPO3_MODE == 'FE ' )
296
+ {
308
297
$ staticInfoObj ->init ();
309
298
}
310
- return $ staticInfoObj ->formatAddress ($ delim , $ streetAddress , $ city , $ zip , $ subdivisionCode , $ countryCode );
311
- }
312
-
313
- $ conf = $ this ->loadTypoScriptForBEModule ('tx_staticinfotables_pi1 ' );
314
-
315
- global $ TYPO3_DB ;
316
-
317
- $ formatedAddress = '' ;
318
- $ countryCode = ($ countryCode ? trim ($ countryCode ) : $ this ->defaultCountry );
319
- $ subdivisionCode = ($ subdivisionCode ? trim ($ subdivisionCode ) : ($ countryCode == $ this ->defaultCountry ? $ this ->defaultCountryZone : '' ));
320
-
321
- // Get country name
322
- // $countryName = $this->getStaticInfoName('COUNTRIES', $countryCode);
323
- $ countryName = tx_staticinfotables_div::getTitleFromIsoCode ('static_countries ' , $ countryCode , '' , FALSE );
324
- if (!$ countryName ) {
325
- return $ formatedAddress ;
299
+ else
300
+ {
301
+ $ conf = $ this ->loadTypoScriptForBEModule ('tx_staticinfotables_pi1 ' );
302
+ $ staticInfoObj ->init ( $ conf );
303
+ }
326
304
}
327
-
328
- // Get address format
329
- $ res = $ TYPO3_DB ->exec_SELECTquery (
330
- 'cn_address_format ' ,
331
- 'static_countries ' ,
332
- 'cn_iso_3= ' .$ TYPO3_DB ->fullQuoteStr ($ countryCode ,'static_countries ' )
333
- );
334
- $ row = $ TYPO3_DB ->sql_fetch_assoc ($ res );
335
- $ TYPO3_DB ->sql_free_result ($ res );
336
- $ addressFormat = $ row ['cn_address_format ' ];
337
-
338
- // Get country subdivision name
339
- // $countrySubdivisionName = $this->getStaticInfoName('SUBDIVISIONS', $subdivisionCode, $countryCode);
340
- // $countrySubdivisionName = tx_staticinfotables_div::getTitleFromIsoCode('static_country_zones', $subdivisionCode, $countryCode, FALSE);
341
-
342
- // Format the address
343
- $ formatedAddress = $ conf ['addressFormat. ' ][$ addressFormat ];
344
- $ formatedAddress = str_replace ('%street ' , $ streetAddress , $ formatedAddress );
345
- $ formatedAddress = str_replace ('%city ' , $ city , $ formatedAddress );
346
- $ formatedAddress = str_replace ('%zip ' , $ zip , $ formatedAddress );
347
- $ formatedAddress = str_replace ('%countrySubdivisionCode ' , $ subdivisionCode , $ formatedAddress );
348
- $ formatedAddress = str_replace ('%countrySubdivisionName ' , $ subdivisionCode , $ formatedAddress );
349
- $ formatedAddress = str_replace ('%countryName ' , strtoupper ($ countryName ), $ formatedAddress );
350
- $ formatedAddress = implode ($ delim , \TYPO3 \CMS \Core \Utility \GeneralUtility::trimExplode ('; ' , $ formatedAddress , 1 ));
351
-
352
- return $ formatedAddress ;
305
+ return $ staticInfoObj ->formatAddress ($ delim , $ streetAddress , $ city , $ zip , $ subdivisionCode , $ countryCode );
353
306
}
354
307
355
308
@@ -360,14 +313,13 @@ function formatAddress ($delim, $streetAddress, $city, $zip, $subdivisionCode=''
360
313
* @return array
361
314
*/
362
315
function loadTypoScriptForBEModule ($ extKey ) {
363
- #require_once(PATH_t3lib . 'class.t3lib_page.php');
364
- #require_once(PATH_t3lib . 'class.t3lib_tstemplate.php');
365
- #require_once(PATH_t3lib . 'class.t3lib_tsparser_ext.php');
366
316
list ($ page ) = \TYPO3 \CMS \Backend \Utility \BackendUtility::getRecordsByField ('pages ' , 'pid ' , 0 );
367
317
$ pageUid = intval ($ page ['uid ' ]);
368
- $ sysPageObj = \TYPO3 \CMS \Core \Utility \GeneralUtility::makeInstance ('t3lib_pageSelect ' );
318
+ /** @var \TYPO3\CMS\Frontend\Page\PageRepository $sysPageObj */
319
+ $ sysPageObj = \TYPO3 \CMS \Core \Utility \GeneralUtility::makeInstance (\TYPO3 \CMS \Frontend \Page \PageRepository::class);
369
320
$ rootLine = $ sysPageObj ->getRootLine ($ pageUid );
370
- $ TSObj = \TYPO3 \CMS \Core \Utility \GeneralUtility::makeInstance ('t3lib_tsparser_ext ' );
321
+ /** @var \TYPO3\CMS\Core\TypoScript\ExtendedTemplateService $TSObj */
322
+ $ TSObj = \TYPO3 \CMS \Core \Utility \GeneralUtility::makeInstance (\TYPO3 \CMS \Core \TypoScript \ExtendedTemplateService::class);
371
323
$ TSObj ->tt_track = 0 ;
372
324
$ TSObj ->init ();
373
325
$ TSObj ->runThroughTemplates ($ rootLine );
0 commit comments