/**
  * Fetches short title from an iso code
  *
  * @deprecated since 6.0, will be removed two versions later - Use \SJBR\StaticInfoTables\Utility\LocalizationUtility::getLabelFieldValue or, better, \SJBR\StaticInfoTables\Utility\LocalizationUtility::translate instead
  * @param string $tableName: table name
  * @param string $isoCode: iso code
  * @param string $language: language code - if not set current default language is used
  * @param boolean $local: local name only - if set local title is returned
  * @return string short title
  */
 public static function getTitleFromIsoCode($tableName, $isoCode, $language = '', $local = FALSE)
 {
     \TYPO3\CMS\Core\Utility\GeneralUtility::logDeprecatedFunction();
     $indentifiers = array();
     $indentifiers['iso'] = $isoCode;
     return parent::getLabelFieldValue($identifiers, $tableName, $language, $local);
 }
 /**
  * Formatting an address in the format specified
  *
  * @param	string	$delim	A delimiter for the fields of the returned address
  * @param	string	$streetAddress	A street address
  * @param	string	$city	A city
  * @param	string	$zip	A zip code
  * @param	string	$subdivisionCode	A ISO alpha-3 country code (cn_iso_3)
  * @param	string	$countryCode	A zip code	A country subdivision code (zn_code)
  * @return	string		The formated address using the country address format (cn_address_format)
  */
 function formatAddress($delim, $streetAddress, $city, $zip, $subdivisionCode = '', $countryCode = '')
 {
     if (TYPO3_MODE == 'FE') {
         /** @var \SJBR\StaticInfoTables\PiBaseApi $staticInfoObj */
         $staticInfoObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\SJBR\StaticInfoTables\PiBaseApi::class);
         if ($staticInfoObj->needsInit()) {
             $staticInfoObj->init();
         }
         return $staticInfoObj->formatAddress($delim, $streetAddress, $city, $zip, $subdivisionCode, $countryCode);
     }
     $conf = $this->loadTypoScriptForBEModule('tx_staticinfotables_pi1');
     global $TYPO3_DB;
     $formatedAddress = '';
     $countryCode = $countryCode ? trim($countryCode) : $this->defaultCountry;
     $subdivisionCode = $subdivisionCode ? trim($subdivisionCode) : ($countryCode == $this->defaultCountry ? $this->defaultCountryZone : '');
     // Get country name
     $countryName = \SJBR\StaticInfoTables\Utility\LocalizationUtility::getLabelFieldValue($countryCode, 'static_countries', '', FALSE);
     if (!$countryName) {
         return $formatedAddress;
     }
     // Get address format
     $res = $TYPO3_DB->exec_SELECTquery('cn_address_format', 'static_countries', 'cn_iso_3=' . $TYPO3_DB->fullQuoteStr($countryCode, 'static_countries'));
     $row = $TYPO3_DB->sql_fetch_assoc($res);
     $TYPO3_DB->sql_free_result($res);
     $addressFormat = $row['cn_address_format'];
     // Format the address
     $formatedAddress = $conf['addressFormat.'][$addressFormat];
     $formatedAddress = str_replace('%street', $streetAddress, $formatedAddress);
     $formatedAddress = str_replace('%city', $city, $formatedAddress);
     $formatedAddress = str_replace('%zip', $zip, $formatedAddress);
     $formatedAddress = str_replace('%countrySubdivisionCode', $subdivisionCode, $formatedAddress);
     $formatedAddress = str_replace('%countrySubdivisionName', $subdivisionCode, $formatedAddress);
     $formatedAddress = str_replace('%countryName', strtoupper($countryName), $formatedAddress);
     $formatedAddress = implode($delim, \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(';', $formatedAddress, 1));
     return $formatedAddress;
 }
예제 #3
0
 /**
  * Returns the default country as localized string.
  *
  * @return string the default country's localized name, will be empty if there is no default country
  */
 private function getDefaultCountry()
 {
     $defaultCountryCode = tx_oelib_ConfigurationRegistry::get('plugin.tx_staticinfotables_pi1')->getAsString('countryCode');
     if ($defaultCountryCode === '') {
         return '';
     }
     $this->initStaticInfo();
     if (class_exists('SJBR\\StaticInfoTables\\Utility\\LocalizationUtility', TRUE)) {
         $currentLanguageCode = Tx_Oelib_ConfigurationRegistry::get('config')->getAsString('language');
         $identifiers = array('iso' => $defaultCountryCode);
         $result = \SJBR\StaticInfoTables\Utility\LocalizationUtility::getLabelFieldValue($identifiers, 'static_countries', $currentLanguageCode, TRUE);
     } else {
         $result = tx_staticinfotables_div::getTitleFromIsoCode('static_countries', $defaultCountryCode, $this->staticInfo->getCurrentLanguage(), TRUE);
     }
     return $result;
 }