/**
  * Convert country code to name
  *
  * @param string $code
  * @return string
  */
 public static function convertCountryCodeToName($code)
 {
     if (!$code) {
         return;
     }
     return Zend_Locale::getTranslation($code, 'territory', i18n::get_locale());
 }
 /**
  * Process the form
  * 
  * @param type $data
  * @param type $form
  * @return type
  */
 public function McDoSubscribeForm($data, Form $form)
 {
     $country = Zend_Locale::getTranslation($data['Country'], "country", 'en_US');
     $topicsArr = Config::inst()->get('MailChimpController', 'topicsArr');
     $interest = array();
     $interestTxt = '';
     $i = 0;
     foreach ($data['Topics'] as $id) {
         array_push($interest, $topicsArr[$id]);
         $interestTxt .= $topicsArr[$id];
         if (++$i < count($data['Topics'])) {
             $interestTxt .= ',';
         }
     }
     $email = $data['Email'];
     $merge_vars = array('FNAME' => '', 'LNAME' => '', 'OTHERINT' => $data['Other'], 'COUNTRY' => $country, 'GROUPINGS' => array(array('name' => 'Areas of Interest', 'groups' => $interestTxt)));
     $regOk = self::McSubscribe($email, $merge_vars);
     if ($regOk) {
         // Pulisco la sessione
         Session::clear('MAILCHIMP_ERRCODE');
         Session::clear('MAILCHIMP_ERRMSG');
         if (Config::inst()->get('MailChimpController', 'redirect')) {
             // Redireziono alla pagina di avvenuta registrazione
             return $this->redirect(Config::inst()->get('MailChimpController', 'redirect_ok'));
         } else {
             // Se non è definita una pagina di redirezione, rimando indietro
             return $this->redirectBack();
         }
     } else {
         // Pagina di errore
         return $this->redirect(Config::inst()->get('MailChimpController', 'redirect_ko'));
     }
 }
Esempio n. 3
0
 public function getDefaultLangName($lang = null)
 {
     if ($lang == null) {
         $do = BizSystem::getObject("myaccount.do.PreferenceDO", 1);
         $rec = $do->fetchOne("[user_id]='0' AND [name]='language'");
         if ($rec) {
             $lang = $rec['value'];
         } else {
             $lang = DEFAULT_LANGUAGE;
         }
     }
     $current_locale = I18n::getCurrentLangCode();
     require_once 'Zend/Locale.php';
     $locale = new Zend_Locale($current_locale);
     $display_name = Zend_Locale::getTranslation($lang, 'language', $locale);
     if ($display_name) {
         return $display_name;
     } else {
         if ($lang) {
             return $lang;
         } else {
             return DEFAULT_LANGUAGE;
         }
     }
 }
Esempio n. 4
0
 public function indexAction()
 {
     $this->view->navigation = $navigation = Engine_Api::_()->getApi('menus', 'core')->getNavigation('core_footer');
     // Languages
     $translate = Zend_Registry::get('Zend_Translate');
     $languageList = $translate->getList();
     //$currentLocale = Zend_Registry::get('Locale')->__toString();
     // Prepare default langauge
     $defaultLanguage = Engine_Api::_()->getApi('settings', 'core')->getSetting('core.locale.locale', 'en');
     if (!in_array($defaultLanguage, $languageList)) {
         if ($defaultLanguage == 'auto' && isset($languageList['en'])) {
             $defaultLanguage = 'en';
         } else {
             $defaultLanguage = null;
         }
     }
     // Prepare language name list
     $languageNameList = array();
     $languageDataList = Zend_Locale_Data::getList(null, 'language');
     $territoryDataList = Zend_Locale_Data::getList(null, 'territory');
     foreach ($languageList as $localeCode) {
         $languageNameList[$localeCode] = Zend_Locale::getTranslation($localeCode, 'language', $localeCode);
         if (empty($languageNameList[$localeCode])) {
             list($locale, $territory) = explode('_', $localeCode);
             $languageNameList[$localeCode] = "{$territoryDataList[$territory]} {$languageDataList[$locale]}";
         }
     }
     $languageNameList = array_merge(array($defaultLanguage => $defaultLanguage), $languageNameList);
     $this->view->languageNameList = $languageNameList;
 }
Esempio n. 5
0
 private function storeLanguage()
 {
     if ($this->mySessionSite->Locale) {
         \Zend_Registry::set("Zend_Locale", $this->mySessionSite->Locale);
     }
     if ($this->_getParam("lg")) {
         $locale = new \Zend_Locale($this->_getParam("lg"));
         \Zend_Registry::set("Zend_Locale", $locale);
     }
     if (\Zend_Registry::isRegistered("Zend_Locale") and $this->mySessionSite->Locale) {
         //init forcée à french à reprendre
         $locale = \Zend_Registry::get("Zend_Locale");
     } else {
         $locale = new \Zend_Locale("fr_FR");
         \Zend_Registry::set("Zend_Locale", $locale);
     }
     $this->mySessionSite->Locale = $locale;
     $this->view->language = $this->language = $locale->getLanguage();
     $languages = \Pimcore\Tool::getValidLanguages();
     $languageOptions = array();
     foreach ($languages as $short) {
         if (!empty($short)) {
             $languageOptions[] = array("language" => $short, "display" => \Zend_Locale::getTranslation($short == "fr_FR" ? "fr" : $short, 'Language', $locale));
             $validLanguages[] = $short;
         }
     }
     $this->view->languageOptions = $languageOptions;
     $this->view->isAjax = $this->isAjax();
 }
Esempio n. 6
0
 public function importAction()
 {
     $this->checkPermission("translations");
     $admin = $this->getParam("admin");
     $merge = $this->getParam("merge");
     $tmpFile = $_FILES["Filedata"]["tmp_name"];
     $overwrite = $merge ? false : true;
     if ($admin) {
         $delta = Translation\Admin::importTranslationsFromFile($tmpFile, $overwrite, Tool\Admin::getLanguages());
     } else {
         $delta = Translation\Website::importTranslationsFromFile($tmpFile, $overwrite);
     }
     $result = array("success" => true);
     if ($merge) {
         $enrichedDelta = array();
         foreach ($delta as $item) {
             $lg = $item["lg"];
             $item["lgname"] = \Zend_Locale::getTranslation($lg, "language");
             $item["icon"] = "/admin/misc/get-language-flag?language=" . $lg;
             $item["current"] = $item["text"];
             $enrichedDelta[] = $item;
         }
         $result["delta"] = base64_encode(json_encode($enrichedDelta));
     }
     $this->_helper->json($result, false);
     // set content-type to text/html, otherwise (when application/json is sent) chrome will complain in
     // Ext.form.Action.Submit and mark the submission as failed
     $this->getResponse()->setHeader("Content-Type", "text/html");
 }
 public function on_start()
 {
     $this->error = Loader::helper('validation/error');
     if (USER_REGISTRATION_WITH_EMAIL_ADDRESS == true) {
         $this->set('uNameLabel', t('Email Address'));
     } else {
         $this->set('uNameLabel', t('Username'));
     }
     $txt = Loader::helper('text');
     if (strlen($_GET['uName'])) {
         // pre-populate the username if supplied, if its an email address with special characters the email needs to be urlencoded first,
         $this->set("uName", trim($txt->email($_GET['uName'])));
     }
     $languages = array();
     $locales = array();
     if (Config::get('LANGUAGE_CHOOSE_ON_LOGIN')) {
         Loader::library('3rdparty/Zend/Locale');
         Loader::library('3rdparty/Zend/Locale/Data');
         $languages = Localization::getAvailableInterfaceLanguages();
         if (count($languages) > 0) {
             array_unshift($languages, 'en_US');
         }
         $locales = array('' => t('** Default'));
         Zend_Locale_Data::setCache(Cache::getLibrary());
         foreach ($languages as $lang) {
             $loc = new Zend_Locale($lang);
             $locales[$lang] = Zend_Locale::getTranslation($loc->getLanguage(), 'language', ACTIVE_LOCALE);
         }
     }
     $this->locales = $locales;
     $this->set('locales', $locales);
     $this->openIDReturnTo = BASE_URL . View::url("/login", "complete_openid");
 }
Esempio n. 8
0
 public function indexAction()
 {
     if (Engine_Api::_()->user()->getViewer()->getIdentity()) {
         return $this->_helper->redirector->gotoRoute(array('action' => 'home'), 'user_general', true);
     }
     /*
     		if (isset($_SESSION['skip_registration'])) {
     			return $this -> _helper -> redirector -> gotoRoute(array(), 'user_home', true);
     		}
     */
     // Languages
     $translate = Zend_Registry::get('Zend_Translate');
     $languageList = $translate->getList();
     // Prepare default langauge
     $defaultLanguage = Engine_Api::_()->getApi('settings', 'core')->getSetting('core.locale.locale', 'en');
     if (!in_array($defaultLanguage, $languageList)) {
         if ($defaultLanguage == 'auto' && isset($languageList['en'])) {
             $defaultLanguage = 'en';
         } else {
             $defaultLanguage = null;
         }
     }
     // Prepare language name list
     $languageNameList = array();
     $languageDataList = Zend_Locale_Data::getList(null, 'language');
     $territoryDataList = Zend_Locale_Data::getList(null, 'territory');
     foreach ($languageList as $localeCode) {
         $languageNameList[$localeCode] = Engine_String::ucfirst(Zend_Locale::getTranslation($localeCode, 'language', $localeCode));
         if (empty($languageNameList[$localeCode])) {
             if (false !== strpos($localeCode, '_')) {
                 list($locale, $territory) = explode('_', $localeCode);
             } else {
                 $locale = $localeCode;
                 $territory = null;
             }
             if (isset($territoryDataList[$territory]) && isset($languageDataList[$locale])) {
                 $languageNameList[$localeCode] = $territoryDataList[$territory] . ' ' . $languageDataList[$locale];
             } else {
                 if (isset($territoryDataList[$territory])) {
                     $languageNameList[$localeCode] = $territoryDataList[$territory];
                 } else {
                     if (isset($languageDataList[$locale])) {
                         $languageNameList[$localeCode] = $languageDataList[$locale];
                     } else {
                         continue;
                     }
                 }
             }
         }
     }
     $languageNameList = array_merge(array($defaultLanguage => $defaultLanguage), $languageNameList);
     ksort($languageNameList);
     $this->view->languageNameList = $languageNameList;
     $this->_helper->layout->disableLayout();
     // Render
     //$this -> _helper -> content
     //-> setNoRender()
     //	-> setEnabled();
 }
 /**
  * Returns available language options determined by translation resources.
  *
  * @return array
  * @throws Zend_Exception
  */
 public function getLanguageOptions()
 {
     $translator = Zend_Registry::get('Zend_Translate');
     $currentLocale = new Zend_Locale($translator->getLocale());
     $translations = $translator->getList();
     $options = array();
     foreach ($translations as $language) {
         $options[$language] = $currentLocale->getTranslation($language, 'language', $currentLocale->getLanguage());
     }
     return $options;
 }
Esempio n. 10
0
	protected function getLocales() {
		Loader::library('3rdparty/Zend/Locale');
		$languages = Localization::getAvailableInterfaceLanguages();
		if (count($languages) > 0) { 
			array_unshift($languages, 'en_US');
		}
		$locales = array();
		foreach($languages as $lang) {
			$loc = new Zend_Locale($lang);
			$locales[$lang] = Zend_Locale::getTranslation($loc->getLanguage(), 'language', $lang);
		}
		return $locales;
	}
Esempio n. 11
0
 public function getExportData($entityType, $collectionItem)
 {
     // Set return array
     $returnArray = array();
     // Fetch fields to export
     $order = $collectionItem->getOrder();
     if ($this->fieldLoadingRequired('pakjegemak_address')) {
         try {
             $this->_writeArray =& $returnArray['pakjegemak_address'];
             $pakjeGemakAddress = Mage::helper('postnl')->getPakjeGemakAddressForOrder($order);
             if ($pakjeGemakAddress && $pakjeGemakAddress->getId()) {
                 $pakjeGemakAddress->explodeStreetAddress();
                 foreach ($pakjeGemakAddress->getData() as $key => $value) {
                     $this->writeValue($key, $value);
                 }
                 // Region Code
                 if ($pakjeGemakAddress->getRegionId() !== NULL && $this->fieldLoadingRequired('region_code')) {
                     $this->writeValue('region_code', $pakjeGemakAddress->getRegionModel()->getCode());
                 }
                 // Country - ISO3, Full Name
                 if ($pakjeGemakAddress->getCountryId() !== NULL) {
                     if ($this->fieldLoadingRequired('country_name')) {
                         $this->writeValue('country_name', Zend_Locale::getTranslation($pakjeGemakAddress->getCountryId(), 'country', 'en_US'));
                     }
                     if ($this->fieldLoadingRequired('country_iso3')) {
                         $this->writeValue('country_iso3', $pakjeGemakAddress->getCountryModel()->getIso3Code());
                     }
                 }
             }
         } catch (Exception $e) {
         }
     }
     if ($this->fieldLoadingRequired('pakjegemak_order')) {
         try {
             $this->_writeArray =& $returnArray['pakjegemak_order'];
             $dataCollection = Mage::getModel('postnl_core/order')->getCollection();
             $dataCollection->addFieldToFilter('order_id', $order->getId());
             if ($dataCollection->count()) {
                 foreach ($dataCollection as $dataRow) {
                     foreach ($dataRow->getData() as $key => $value) {
                         $this->writeValue($key, $value);
                     }
                 }
             }
         } catch (Exception $e) {
         }
     }
     // Done
     return $returnArray;
 }
 public function indexAction()
 {
     $this->view->navigation = $navigation = Engine_Api::_()->getApi('menus', 'core')->getNavigation('core_footer');
     // Languages
     $translate = Zend_Registry::get('Zend_Translate');
     $languageList = $translate->getList();
     //$currentLocale = Zend_Registry::get('Locale')->__toString();
     // Prepare default langauge
     $defaultLanguage = Engine_Api::_()->getApi('settings', 'core')->getSetting('core.locale.locale', 'en');
     if (!in_array($defaultLanguage, $languageList)) {
         if ($defaultLanguage == 'auto' && isset($languageList['en'])) {
             $defaultLanguage = 'en';
         } else {
             $defaultLanguage = null;
         }
     }
     // Prepare language name list
     $languageNameList = array();
     $languageDataList = Zend_Locale_Data::getList(null, 'language');
     $territoryDataList = Zend_Locale_Data::getList(null, 'territory');
     foreach ($languageList as $localeCode) {
         $languageNameList[$localeCode] = Engine_String::ucfirst(Zend_Locale::getTranslation($localeCode, 'language', $localeCode));
         if (empty($languageNameList[$localeCode])) {
             if (false !== strpos($localeCode, '_')) {
                 list($locale, $territory) = explode('_', $localeCode);
             } else {
                 $locale = $localeCode;
                 $territory = null;
             }
             if (isset($territoryDataList[$territory]) && isset($languageDataList[$locale])) {
                 $languageNameList[$localeCode] = $territoryDataList[$territory] . ' ' . $languageDataList[$locale];
             } else {
                 if (isset($territoryDataList[$territory])) {
                     $languageNameList[$localeCode] = $territoryDataList[$territory];
                 } else {
                     if (isset($languageDataList[$locale])) {
                         $languageNameList[$localeCode] = $languageDataList[$locale];
                     } else {
                         continue;
                     }
                 }
             }
         }
     }
     $languageNameList = array_merge(array($defaultLanguage => $defaultLanguage), $languageNameList);
     $this->view->languageNameList = $languageNameList;
     // Get affiliate code
     $this->view->affiliateCode = Engine_Api::_()->getDbtable('settings', 'core')->core_affiliate_code;
 }
 /**
  *
  * @return array Containing all the languages used in this project
  */
 public function getLanguages()
 {
     if (isset($this->project->locales)) {
         $locales = $this->project->locales;
     } elseif (isset($this->project->locale['default'])) {
         $locales = array($this->project->locale['default']);
     } else {
         $locales = array('en');
     }
     foreach ($locales as $locale) {
         $languages[$locale] = \Zend_Locale::getTranslation($locale, 'Language', $this->locale);
     }
     asort($languages);
     return $languages;
 }
Esempio n. 14
0
 /**
  * returns list of all available translations
  * 
  * NOTE available are those, having a Tinebase translation
  * 
  * @return array list of all available translation
  *
  * @todo add test
  */
 public static function getAvailableTranslations()
 {
     $availableTranslations = array();
     // look for po files in Tinebase
     $officialTranslationsDir = dirname(__FILE__) . '/translations';
     foreach (scandir($officialTranslationsDir) as $poFile) {
         list($localestring, $suffix) = explode('.', $poFile);
         if ($suffix == 'po') {
             $availableTranslations[$localestring] = array('path' => "{$officialTranslationsDir}/{$poFile}");
         }
     }
     // lookup/merge custom translations
     if (Tinebase_Config::isReady() === TRUE) {
         $customTranslationsDir = Tinebase_Config::getInstance()->translations;
         if ($customTranslationsDir) {
             foreach ((array) scandir($customTranslationsDir) as $dir) {
                 $poFile = "{$customTranslationsDir}/{$dir}/Tinebase/translations/{$dir}.po";
                 if (is_readable($poFile)) {
                     $availableTranslations[$dir] = array('path' => $poFile);
                 }
             }
         }
     }
     // compute information
     foreach ($availableTranslations as $localestring => $info) {
         if (!Zend_Locale::isLocale($localestring, TRUE, FALSE)) {
             $logger = Tinebase_Core::getLogger();
             if ($logger) {
                 $logger->WARN(__METHOD__ . '::' . __LINE__ . " {$localestring} is not supported, removing translation form list");
             }
             unset($availableTranslations[$localestring]);
             continue;
         }
         // fetch header grep for X-Poedit-Language, X-Poedit-Country
         $fh = fopen($info['path'], 'r');
         $header = fread($fh, 1024);
         fclose($fh);
         preg_match('/X-Tine20-Language: (.+)(?:\\\\n?)(?:"?)/', $header, $language);
         preg_match('/X-Tine20-Country: (.+)(?:\\\\n?)(?:"?)/', $header, $region);
         $locale = new Zend_Locale($localestring);
         $availableTranslations[$localestring]['locale'] = $localestring;
         $availableTranslations[$localestring]['language'] = isset($language[1]) ? $language[1] : Zend_Locale::getTranslation($locale->getLanguage(), 'language', $locale);
         $availableTranslations[$localestring]['region'] = isset($region[1]) ? $region[1] : Zend_Locale::getTranslation($locale->getRegion(), 'country', $locale);
     }
     ksort($availableTranslations);
     return $availableTranslations;
 }
 public function createcountriesAction()
 {
     $language = $this->_getParam("language");
     $locale = new Zend_Locale($language);
     $regions = Zend_Locale::getTranslationList('RegionToTerritory');
     $countryGroup = array();
     foreach ($regions as $region => $countriesString) {
         $countries = explode(' ', $countriesString);
         foreach ($countries as $country) {
             $countryGroup[$country] = $locale->getTranslation($region, 'territory', $locale);
         }
     }
     $countries = Country::getCountries();
     foreach ($countries as $iso => $name) {
         $currencyCode = Country::getCurrencyCodeForCountry($iso);
         $currencyDetail = Country::getCurrencyDetail($currencyCode);
         if (!$currencyCode || !$currencyDetail) {
             continue;
         }
         $currencyName = $currencyDetail['name'];
         $currencySymbol = $currencyDetail['symbol'];
         $currencyIsoNumber = $currencyDetail['isocode'];
         //Check if currency Object already exists
         $currencyObject = Model\Currency::getByName($currencyName);
         if (!$currencyObject instanceof Model\Currency) {
             $currencyObject = new Model\Currency();
             $currencyObject->setSymbol($currencySymbol);
             $currencyObject->setNumericIsoCode($currencyIsoNumber);
             $currencyObject->setIsoCode($currencyCode);
             $currencyObject->setExchangeRate(1);
         }
         $currencyObject->setName($currencyName);
         $currencyObject->save();
         //Check if country Object already exists
         $countryObject = Model\Country::getByIsoCode($iso);
         if (!$countryObject instanceof Model\Country) {
             $countryObject = new Model\Country();
         }
         $countryObject->setName($name);
         $countryObject->setIsoCode($iso);
         $countryObject->setActive(false);
         $countryObject->setCurrency($currencyObject);
         $countryObject->save();
     }
     $this->_helper->json(array("success" => true));
 }
Esempio n. 16
0
 public function view()
 {
     Loader::library('3rdparty/Zend/Locale');
     $languages = Localization::getAvailableInterfaceLanguages();
     if (count($languages) > 0) {
         array_unshift($languages, 'en_US');
     }
     $locales = array();
     foreach ($languages as $lang) {
         $loc = new Zend_Locale($lang);
         $locales[$lang] = Zend_Locale::getTranslation($loc->getLanguage(), 'language', ACTIVE_LOCALE);
     }
     $this->set('LANGUAGE_CHOOSE_ON_LOGIN', Config::get('LANGUAGE_CHOOSE_ON_LOGIN'));
     $this->set('LANGUAGE_MULTILINGUAL_CONTENT_ENABLED', Config::get('LANGUAGE_MULTILINGUAL_CONTENT_ENABLED'));
     $this->set('interfacelocales', $locales);
     $this->set('languages', $languages);
 }
Esempio n. 17
0
 /**
  * Get an instance of the view helper.
  *
  * @return Opus_View_Helper_LanguageSelector
  */
 public function languageSelector()
 {
     if (isset($this->view->languageSelectorDisabled) && $this->view->languageSelectorDisabled === true) {
         return null;
     }
     $returnParams = Zend_Controller_Action_HelperBroker::getStaticHelper('ReturnParams');
     $translations = Zend_Registry::get('Zend_Translate')->getList();
     $currentLocale = new Zend_Locale(Zend_Registry::get('Zend_Translate')->getLocale());
     $result = array();
     foreach ($translations as $translation) {
         if ($currentLocale->getLanguage() !== $translation) {
             $languageName = $currentLocale->getTranslation($translation, 'language', $translation);
             $languageUrl = $this->view->url(array_merge(array('action' => 'language', 'controller' => 'index', 'module' => 'home', 'language' => $translation), $returnParams->getReturnParameters()), null, true);
             array_push($result, array('name' => htmlspecialchars($languageName), 'url' => $languageUrl));
         }
     }
     return $result;
 }
Esempio n. 18
0
 /**
  * Returns a list of available translation languages
  * @param $detailed boolean Fetch additional info for translation
  * @return array List of translations
  */
 public function getLanguages($detailed = true)
 {
     $websiteConfigHelper = Zend_Controller_Action_HelperBroker::getExistingHelper('website');
     $languageIcons = Tools_Filesystem_Tools::findFilesByExtension($websiteConfigHelper->getPath() . $this->_langFlagsDir, 'png', false, true, false);
     $this->_languages = array();
     $loadedList = Zend_Registry::get('Zend_Translate')->getAdapter()->getList();
     foreach ($languageIcons as $country => $imgFile) {
         $locale = new Zend_Locale(Zend_Locale::getLocaleToTerritory($country));
         $lang = $locale->getLanguage();
         $langTitle = Zend_Locale::getTranslation($lang, 'language');
         if (!in_array($locale->getLanguage(), $loadedList)) {
             continue;
         }
         if ($detailed) {
             $this->_languages[$country] = array('locale' => $locale->toString(), 'language' => $langTitle, 'name' => $country, 'flag' => $this->_langFlagsDir . $imgFile);
         } else {
             $this->_languages[$country] = $langTitle;
         }
         unset($locale);
     }
     return $this->_languages;
 }
Esempio n. 19
0
 /**
  * Sets the locale to use
  *
  * @param string|Zend_Locale $locale
  * @throws Zend_Validate_Exception On unrecognised region
  * @throws Zend_Validate_Exception On not detected format
  * @return Zend_Validate_PostCode  Provides fluid interface
  */
 public function setLocale($locale = null)
 {
     #require_once 'Zend/Locale.php';
     $this->_locale = Zend_Locale::findLocale($locale);
     $locale = new Zend_Locale($this->_locale);
     $region = $locale->getRegion();
     if (empty($region)) {
         #require_once 'Zend/Validate/Exception.php';
         throw new Zend_Validate_Exception("Unable to detect a region for the locale '{$locale}'");
     }
     $format = Zend_Locale::getTranslation($locale->getRegion(), 'postaltoterritory', $this->_locale);
     if (empty($format)) {
         #require_once 'Zend/Validate/Exception.php';
         throw new Zend_Validate_Exception("Unable to detect a postcode format for the region '{$locale->getRegion()}'");
     }
     $this->setFormat($format);
     return $this;
 }
Esempio n. 20
0
 /**
  * Returns registry data of tinebase.
  * @see Tinebase_Application_Json_Abstract
  *
  * @return mixed array 'variable name' => 'data'
  */
 public function getRegistryData()
 {
     $locale = Tinebase_Core::get('locale');
     $tbFrontendHttp = new Tinebase_Frontend_Http();
     // default credentials
     if (isset(Tinebase_Core::getConfig()->login)) {
         $loginConfig = Tinebase_Core::getConfig()->login;
         $defaultUsername = isset($loginConfig->username) ? $loginConfig->username : '';
         $defaultPassword = isset($loginConfig->password) ? $loginConfig->password : '';
     } else {
         $defaultUsername = '';
         $defaultPassword = '';
     }
     $registryData = array('serviceMap' => $tbFrontendHttp->getServiceMap(), 'timeZone' => Tinebase_Core::get(Tinebase_Core::USERTIMEZONE), 'locale' => array('locale' => $locale->toString(), 'language' => Zend_Locale::getTranslation($locale->getLanguage(), 'language', $locale), 'region' => Zend_Locale::getTranslation($locale->getRegion(), 'country', $locale)), 'version' => array('buildType' => TINE20_BUILDTYPE, 'codeName' => TINE20_CODENAME, 'packageString' => TINE20_PACKAGESTRING, 'releaseTime' => TINE20_RELEASETIME, 'filesHash' => TINE20_BUILDTYPE != 'DEVELOPMENT' ? $tbFrontendHttp->getJsCssHash() : null), 'defaultUsername' => $defaultUsername, 'defaultPassword' => $defaultPassword, 'denySurveys' => Tinebase_Core::getConfig()->denySurveys, 'titlePostfix' => Tinebase_Config::getInstance()->getConfig(Tinebase_Model_Config::PAGETITLEPOSTFIX, NULL, '')->value, 'redirectUrl' => Tinebase_Config::getInstance()->getConfig(Tinebase_Model_Config::REDIRECTURL, NULL, '')->value, 'maxFileUploadSize' => convertToBytes(ini_get('upload_max_filesize')), 'maxPostSize' => convertToBytes(ini_get('post_max_size')));
     if (Tinebase_Core::isRegistered(Tinebase_Core::USER)) {
         $user = Tinebase_Core::getUser();
         $userContactArray = array();
         if (Tinebase_Application::getInstance()->isInstalled('Addressbook') === true) {
             try {
                 $userContactArray = Addressbook_Controller_Contact::getInstance()->getContactByUserId($user->getId(), TRUE)->toArray();
             } catch (Addressbook_Exception_NotFound $aenf) {
                 if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
                     Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' User not found in Addressbook: ' . $user->accountDisplayName);
                 }
             }
         }
         $registryData += array('currentAccount' => $user->toArray(), 'userContact' => $userContactArray, 'accountBackend' => Tinebase_User::getConfiguredBackend(), 'jsonKey' => Tinebase_Core::get('jsonKey'), 'userApplications' => $user->getApplications()->toArray(), 'NoteTypes' => $this->getNoteTypes(), 'stateInfo' => Tinebase_State::getInstance()->loadStateInfo(), 'changepw' => Tinebase_User::getBackendConfiguration('changepw', true), 'mustchangepw' => $user->mustChangePassword(), 'mapPanel' => Tinebase_Config::getInstance()->getConfig(Tinebase_Config::MAPPANEL, NULL, TRUE)->value, 'confirmLogout' => Tinebase_Core::getPreference()->getValue(Tinebase_Preference::CONFIRM_LOGOUT, 1), 'persistentFilters' => Tinebase_Frontend_Json_PersistentFilter::getAllPersistentFilters(), 'messenger' => $this->getMessengerConfig());
     }
     return $registryData;
 }
 /**
  * Determine the value of a localized string, and compare it to a given value
  *
  * @param  string $value
  * @param  boolean $yes
  * @param  array $locale
  * @return boolean
  */
 protected function _getLocalizedQuestion($value, $yes, $locale)
 {
     if ($yes == true) {
         $question = 'yes';
         $return = true;
     } else {
         $question = 'no';
         $return = false;
     }
     $str = Zend_Locale::getTranslation($question, 'question', $locale);
     $str = explode(':', $str);
     if (!empty($str)) {
         foreach ($str as $no) {
             if ($no == $value || strtolower($no) == strtolower($value)) {
                 return $return;
             }
         }
     }
 }
Esempio n. 22
0
 /**
  * test getTranslation
  * expected true
  */
 public function testgetTranslation()
 {
     $value = new Zend_Locale('de_DE');
     try {
         $temp = $value->getTranslation('xx');
         $this->fail();
     } catch (Zend_Locale_Exception $e) {
         $this->assertContains('Unknown detail (', $e->getMessage());
     }
     $this->assertEquals('Deutsch', $value->getTranslation('de', 'language'));
     $this->assertEquals('German', $value->getTranslation('de', 'language', 'en'));
     $this->assertFalse($value->getTranslation('xx', 'language'));
     $this->assertEquals('Lateinisch', $value->getTranslation('Latn', 'script'));
     $this->assertEquals('Latin', $value->getTranslation('Latn', 'script', 'en'));
     $this->assertFalse($value->getTranslation('xyxy', 'script'));
     $this->assertEquals('Österreich', $value->getTranslation('AT', 'country'));
     $this->assertEquals('Austria', $value->getTranslation('AT', 'country', 'en'));
     $this->assertFalse($value->getTranslation('xx', 'country'));
     $this->assertEquals('Afrika', $value->getTranslation('002', 'territory'));
     $this->assertEquals('Africa', $value->getTranslation('002', 'territory', 'en'));
     $this->assertFalse($value->getTranslation('xxx', 'territory'));
     $this->assertEquals('Januar', $value->getTranslation('1', 'month'));
     $this->assertEquals('January', $value->getTranslation('1', 'month', 'en'));
     $this->assertFalse($value->getTranslation('x', 'month'));
     $this->assertEquals('Jan', $value->getTranslation(array('gregorian', 'format', 'abbreviated', '1'), 'month'));
     $this->assertEquals('Jan', $value->getTranslation(array('gregorian', 'format', 'abbreviated', '1'), 'month', 'en'));
     $this->assertFalse($value->getTranslation(array('gregorian', 'format', 'abbreviated', 'x'), 'month'));
     $this->assertEquals('J', $value->getTranslation(array('gregorian', 'stand-alone', 'narrow', '1'), 'month'));
     $this->assertEquals('J', $value->getTranslation(array('gregorian', 'stand-alone', 'narrow', '1'), 'month', 'en'));
     $this->assertFalse($value->getTranslation(array('gregorian', 'stand-alone', 'narrow', 'x'), 'month'));
     $this->assertEquals('Sonntag', $value->getTranslation('sun', 'day'));
     $this->assertEquals('Sunday', $value->getTranslation('sun', 'day', 'en'));
     $this->assertFalse($value->getTranslation('xxx', 'day'));
     $this->assertEquals('So', $value->getTranslation(array('gregorian', 'format', 'abbreviated', 'sun'), 'day'));
     $this->assertEquals('Sun', $value->getTranslation(array('gregorian', 'format', 'abbreviated', 'sun'), 'day', 'en'));
     $this->assertFalse($value->getTranslation(array('gregorian', 'format', 'abbreviated', 'xxx'), 'day'));
     $this->assertEquals('S', $value->getTranslation(array('gregorian', 'stand-alone', 'narrow', 'sun'), 'day'));
     $this->assertEquals('S', $value->getTranslation(array('gregorian', 'stand-alone', 'narrow', 'sun'), 'day', 'en'));
     $this->assertFalse($value->getTranslation(array('gregorian', 'stand-alone', 'narrow', 'xxx'), 'day'));
     $this->assertEquals('EEEE, d. MMMM yyyy', $value->getTranslation('full', 'date'));
     $this->assertEquals('EEEE, MMMM d, yyyy', $value->getTranslation('full', 'date', 'en'));
     $this->assertFalse($value->getTranslation('xxxx', 'date'));
     $this->assertEquals("HH:mm:ss v", $value->getTranslation('full', 'time'));
     $this->assertEquals('h:mm:ss a v', $value->getTranslation('full', 'time', 'en'));
     $this->assertFalse($value->getTranslation('xxxx', 'time'));
     $this->assertEquals('Wien', $value->getTranslation('Europe/Vienna', 'citytotimezone'));
     $this->assertEquals('St. John’s', $value->getTranslation('America/St_Johns', 'citytotimezone', 'en'));
     $this->assertFalse($value->getTranslation('xxxx', 'citytotimezone'));
     $this->assertEquals('Euro', $value->getTranslation('EUR', 'nametocurrency'));
     $this->assertEquals('Euro', $value->getTranslation('EUR', 'nametocurrency', 'en'));
     $this->assertFalse($value->getTranslation('xxx', 'nametocurrency'));
     $this->assertEquals('EUR', $value->getTranslation('Euro', 'currencytoname'));
     $this->assertEquals('EUR', $value->getTranslation('Euro', 'currencytoname', 'en'));
     $this->assertFalse($value->getTranslation('xxx', 'currencytoname'));
     $this->assertEquals('SFr.', $value->getTranslation('CHF', 'currencysymbol'));
     $this->assertEquals('SwF', $value->getTranslation('CHF', 'currencysymbol', 'en'));
     $this->assertFalse($value->getTranslation('xxx', 'currencysymbol'));
     $this->assertEquals('EUR', $value->getTranslation('AT', 'currencytoregion'));
     $this->assertEquals('EUR', $value->getTranslation('AT', 'currencytoregion', 'en'));
     $this->assertFalse($value->getTranslation('xxx', 'currencytoregion'));
     $this->assertEquals('011 014 015 017 018', $value->getTranslation('002', 'regiontoterritory'));
     $this->assertEquals('011 014 015 017 018', $value->getTranslation('002', 'regiontoterritory', 'en'));
     $this->assertFalse($value->getTranslation('xxx', 'regiontoterritory'));
     $this->assertEquals('AT BE CH DE LI LU', $value->getTranslation('de', 'territorytolanguage'));
     $this->assertEquals('AT BE CH DE LI LU', $value->getTranslation('de', 'territorytolanguage', 'en'));
     $this->assertFalse($value->getTranslation('xxx', 'territorytolanguage'));
 }
 public function editAction()
 {
     $this->view->locale = $locale = $this->_getParam('locale');
     $this->view->page = $page = $this->_getParam('page');
     $translate = Zend_Registry::get('Zend_Translate');
     try {
         if (!$locale || !Zend_Locale::findLocale($locale)) {
             throw new Exception('missing locale ' . $locale);
         }
     } catch (Exception $e) {
         return $this->_helper->redirector->gotoRoute(array('action' => 'index', 'controller' => 'language'), 'admin_default', true);
     }
     // Process filter form
     $this->view->filterForm = $filterForm = new Core_Form_Admin_Language_Filter();
     $filterForm->isValid($this->_getAllParams());
     $filterValues = $filterForm->getValues();
     extract($filterValues);
     // search, show
     // Make query
     $filterValues = array_filter($filterValues);
     $this->view->values = $filterValues;
     $this->view->query = empty($filterValues) ? '' : '?' . http_build_query($filterValues);
     // Assign basic locale info
     $this->view->localeObject = $localeObject = new Zend_Locale($locale);
     $this->view->locale = $locale = $localeObject->toString();
     // Get locale translation info
     $localeLanguage = $localeObject->getLanguage();
     $localeRegion = $localeObject->getRegion();
     $this->view->localeLanguageTranslation = $localeLanguageTranslation = Zend_Locale::getTranslation($localeLanguage, 'language', Zend_Registry::get('Locale'));
     $this->view->localeRegionTranslation = $localeRegionTranslation = Zend_Locale::getTranslation($localeRegion, 'territory', Zend_Registry::get('Locale'));
     $translate = Zend_Registry::get('Zend_Translate');
     if ($localeLanguageTranslation && $localeRegionTranslation) {
         $this->view->localeTranslation = $localeLanguageTranslation . ' ' . sprintf($translate->translate('(%s)'), $localeRegionTranslation) . ' ' . sprintf($translate->translate('[%s]'), $locale);
     } else {
         if ($localeLanguageTranslation) {
             $this->view->localeTranslation = $localeLanguageTranslation . ' ' . sprintf($translate->translate('[%s]'), $locale);
         } else {
             $this->view->localeTranslation = sprintf($translate->translate('[%s]'), $locale);
         }
     }
     // Query plural system for max and sample space
     $sample = array();
     $max = 0;
     for ($i = 0; $i <= 1000; $i++) {
         $form = Zend_Translate_Plural::getPlural($i, $locale);
         $max = max($max, $form);
         if (@count($sample[$form]) < 3) {
             $sample[$form][] = $i;
         }
     }
     $this->view->pluralFormCount = $max + 1;
     $this->view->pluralFormSample = $sample;
     // Get initial and default values
     $baseMessages = $translate->getMessages('en');
     if ($translate->isAvailable($locale)) {
         $currentMessages = $translate->getMessages($locale);
     } else {
         $currentMessages = array();
         // @todo this should redirect or smth
     }
     // Get phrases that are not in the english pack?
     if (!empty($currentMessages) && $locale != 'en') {
         $missingBasePhrases = array_diff_key($currentMessages, $baseMessages);
         $missingBasePhrases = array_combine(array_keys($missingBasePhrases), array_keys($missingBasePhrases));
         $baseMessages = array_merge($baseMessages, $missingBasePhrases);
     }
     // Build the fancy array
     $resultantMessages = array();
     $missing = 0;
     $index = 0;
     foreach ($baseMessages as $key => $value) {
         // Build
         $composite = array('uid' => ++$index, 'key' => $key, 'original' => $value, 'plural' => (bool) is_array($value));
         // filters, plurals, and missing, oh my.
         if (isset($currentMessages[$key])) {
             if ('missing' == $show) {
                 continue;
             }
             if (is_array($value) && !is_array($currentMessages[$key])) {
                 $composite['current'] = array($currentMessages[$key]);
             } else {
                 if (!is_array($value) && is_array($currentMessages[$key])) {
                     $composite['current'] = current($currentMessages[$key]);
                 } else {
                     $composite['current'] = $currentMessages[$key];
                 }
             }
         } else {
             if ('translated' == $show) {
                 continue;
             }
             if (is_array($value)) {
                 $composite['current'] = array();
             } else {
                 $composite['current'] = '';
             }
             $missing++;
         }
         // Do search
         if ($search && !$this->_searchArrayRecursive($search, $composite)) {
             continue;
         }
         // Add
         $resultantMessages[] = $composite;
     }
     // Build the paginator
     $this->view->paginator = $paginator = Zend_Paginator::factory($resultantMessages);
     $paginator->setItemCountPerPage(50);
     $paginator->setCurrentPageNumber($page);
     // Process form POST
     if ($this->getRequest()->isPost()) {
         $keys = $this->_getParam('keys');
         $values = $this->_getParam('values');
         // Try to combine the values and keys arrays
         $combined = array();
         foreach ($values as $index => $value) {
             if (is_string($value)) {
                 if (empty($value)) {
                     continue;
                 }
                 $key = $keys[$index];
                 $combined[$key] = $value;
             } else {
                 if (is_array($value)) {
                     if (empty($value) || array_filter($value) === array()) {
                         continue;
                     }
                     $key = $keys[$index][0];
                     $combined[$key] = $value;
                 }
             }
         }
         // Try to write to a file
         $targetFile = APPLICATION_PATH . '/application/languages/' . $locale . '/custom.csv';
         if (!file_exists($targetFile)) {
             touch($targetFile);
             chmod($targetFile, 0777);
         }
         $writer = new Engine_Translate_Writer_Csv($targetFile);
         $writer->setTranslations($combined);
         $writer->write();
         // flush cached language vars
         @Zend_Registry::get('Zend_Cache')->clean();
         // redirect to this same page to get the new values
         return $this->_redirect($_SERVER['REQUEST_URI'], array('prependBase' => false));
     }
 }
Esempio n. 24
0
        echo sprintf('<h4>%1$s</h4>', nl2br($order->getDeliveryCompany()));
    }
    if ($order->getDeliveryName()) {
        echo sprintf('%1$s<br/>', $order->getDeliveryName());
    }
    ?>
                                <?php 
    echo $order->getDeliveryStreet();
    ?>
<br/>
                                <?php 
    echo $order->getDeliveryZip() . ' - ' . $order->getDeliveryCity();
    ?>
<br/>
                                <?php 
    echo strtoupper(Zend_Locale::getTranslation($order->getDeliveryCountry(), 'territory'));
    ?>
<br/>
                            </address>
                        </div>

                        <?php 
    echo $this->geoAddressDelivery ? $printMap($this->geoAddressDelivery) : '';
    ?>
                    </div>
                </div>
                <?php 
}
?>

                <?php 
 /**
  * get anonymous registry
  * 
  * @return array
  */
 protected function _getAnonymousRegistryData()
 {
     $locale = Tinebase_Core::get('locale');
     $tbFrontendHttp = new Tinebase_Frontend_Http();
     // default credentials
     if (isset(Tinebase_Core::getConfig()->login)) {
         $loginConfig = Tinebase_Core::getConfig()->login;
         $defaultUsername = isset($loginConfig->username) ? $loginConfig->username : '';
         $defaultPassword = isset($loginConfig->password) ? $loginConfig->password : '';
     } else {
         $defaultUsername = '';
         $defaultPassword = '';
     }
     $symbols = Zend_Locale::getTranslationList('symbols', $locale);
     $registryData = array('modSsl' => Tinebase_Auth::getConfiguredBackend() == Tinebase_Auth::MODSSL, 'serviceMap' => $tbFrontendHttp->getServiceMap(), 'locale' => array('locale' => $locale->toString(), 'language' => Zend_Locale::getTranslation($locale->getLanguage(), 'language', $locale), 'region' => Zend_Locale::getTranslation($locale->getRegion(), 'country', $locale)), 'version' => array('buildType' => TINE20_BUILDTYPE, 'codeName' => TINE20_CODENAME, 'packageString' => TINE20_PACKAGESTRING, 'releaseTime' => TINE20_RELEASETIME, 'filesHash' => TINE20_BUILDTYPE != 'DEVELOPMENT' ? $tbFrontendHttp->getJsCssHash() : null), 'defaultUsername' => $defaultUsername, 'defaultPassword' => $defaultPassword, 'denySurveys' => Tinebase_Core::getConfig()->denySurveys, 'titlePostfix' => Tinebase_Config::getInstance()->get(Tinebase_Config::PAGETITLEPOSTFIX), 'redirectUrl' => Tinebase_Config::getInstance()->get(Tinebase_Config::REDIRECTURL), 'helpUrl' => Tinebase_Core::getConfig()->helpUrl, 'maxFileUploadSize' => Tinebase_Helper::convertToBytes(ini_get('upload_max_filesize')), 'maxPostSize' => Tinebase_Helper::convertToBytes(ini_get('post_max_size')), 'thousandSeparator' => $symbols['group'], 'decimalSeparator' => $symbols['decimal'], 'filesystemAvailable' => Tinebase_Core::isFilesystemAvailable());
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Anonymous registry: ' . print_r($registryData, TRUE));
     }
     return $registryData;
 }
Esempio n. 26
0
 /**
  * Retrieve Date value for store
  *
  * @param int $storeId
  * @param string $date
  * @return string
  */
 protected function _getStoreDate($storeId, $date = null)
 {
     if (!isset($this->_dates[$storeId])) {
         $timezone = Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE, $storeId);
         $locale = Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE, $storeId);
         $locale = new Zend_Locale($locale);
         $dateObj = new Zend_Date(null, null, $locale);
         $dateObj->setTimezone($timezone);
         $this->_dates[$storeId] = array($dateObj, $locale->getTranslation(null, 'date', $locale));
     }
     if (!is_empty_date($date)) {
         list($dateObj, $format) = $this->_dates[$storeId];
         $dateObj->setDate($date, Varien_Date::DATETIME_INTERNAL_FORMAT);
         return $dateObj->toString($format);
     }
     return null;
 }
Esempio n. 27
0
        print caNavLink($this->request, _t("Logout"), "", "", "LoginReg", "logout");
    } else {
        print caNavLink($this->request, _t("Login/Register"), "", "", "LoginReg", "form");
    }
}
# Locale selection
global $g_ui_locale;
$vs_base_url = $this->request->getRequestUrl();
$vs_base_url = substr($vs_base_url, 0, 1) == '/' ? $vs_base_url : '/' . $vs_base_url;
$vs_base_url = str_replace("/lang/[A-Za-z_]+", "", $vs_base_url);
if (is_array($va_ui_locales = $this->request->config->getList('ui_locales')) && sizeof($va_ui_locales) > 1) {
    print caFormTag($this->request, $this->request->getAction(), 'caLocaleSelectorForm', null, 'get', 'multipart/form-data', '_top', array('disableUnsavedChangesWarning' => true));
    $va_locale_options = array();
    foreach ($va_ui_locales as $vs_locale) {
        $va_parts = explode('_', $vs_locale);
        $vs_lang_name = Zend_Locale::getTranslation(strtolower($va_parts[0]), 'language', strtolower($va_parts[0]));
        $va_locale_options[$vs_lang_name] = $vs_locale;
    }
    print caHTMLSelect('lang', $va_locale_options, array('id' => 'caLocaleSelectorSelect', 'onchange' => 'window.location = \'' . caNavUrl($this->request, $this->request->getModulePath(), $this->request->getController(), $this->request->getAction(), array('lang' => '')) . '\' + jQuery(\'#caLocaleSelectorSelect\').val();'), array('value' => $g_ui_locale, 'dontConvertAttributeQuotesToEntities' => true));
    print "</form>\n";
}
?>
		
		</div><!-- end topbar -->
		<div id="pageArea">
			<div id="header">
<?php 
print caNavLink($this->request, "<img src='" . $this->request->getThemeUrlPath() . "/graphics/" . $this->request->config->get('header_img') . "' border='0'>", "", "", "", "");
?>
				
			
Esempio n. 28
0
 /**
  * Retrieve Date value for store
  *
  * @param int $storeId
  * @param string $date
  * @return string|null
  */
 protected function getStoreDate($storeId, $date = null)
 {
     if (!isset($this->dates[$storeId])) {
         $timezone = $this->scopeConfig->getValue($this->localeDate->getDefaultTimezonePath(), \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
         $locale = $this->scopeConfig->getValue($this->localeResolver->getDefaultLocalePath(), \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
         $locale = new \Zend_Locale($locale);
         $dateObj = new \Magento\Framework\Stdlib\DateTime\Date(null, null, $locale);
         $dateObj->setTimezone($timezone);
         $this->dates[$storeId] = [$dateObj, $locale->getTranslation(null, 'date', $locale)];
     }
     if (!$this->dateTime->isEmptyDate($date)) {
         list($dateObj, $format) = $this->dates[$storeId];
         $dateObj->setDate($date, \Magento\Framework\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT);
         return $dateObj->toString($format);
     }
     return null;
 }
 /**
  * Transforms specified date to basic YYYY-MM-dd format.
  *
  * @param int    $storeId
  * @param string $date
  * @return null|string
  */
 protected function _addStoreDateFormat($storeId, $date = null)
 {
     if (!isset($this->_dateFormats[$storeId])) {
         $timezone = Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE, $storeId);
         $locale = Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE, $storeId);
         $locale = new Zend_Locale($locale);
         $dateObj = new Zend_Date(null, null, $locale);
         $dateObj->setTimezone($timezone);
         $this->_dateFormats[$storeId] = array($dateObj, $locale->getTranslation(null, 'date', $locale));
     }
     if (is_empty_date($date)) {
         return null;
     }
     list($dateObj, $localeDateFormat) = $this->_dateFormats[$storeId];
     $dateObj->setDate($date, $localeDateFormat);
     return $dateObj->toString('YYYY-MM-dd');
 }
Esempio n. 30
0
 /**
  * Generates HTML form element widget for preference based upon settings in preference definition file.
  * By calling this method for a series of preference names, one can quickly create an HTML-based configuration form.
  *
  * @access public
  * @param string $ps_pref Name of user preference
  * @param string $ps_format Format string containing simple tags to be replaced with preference information. Tags supported are:
  *		^LABEL = name of preference
  *		^ELEMENT = HTML code to generate form widget
  * 		If you omit $ps_format, the element code alone (content of ^ELEMENT) is returned.
  * @param array $pa_options Array of options. Support options are:
  *		field_errors = array of error messages to display on preference element
  *		useTable = if true and displayType for element in DT_CHECKBOXES checkboxes will be formatted in a table with numTableColumns columns
  *		numTableColumns = Number of columns to use when formatting checkboxes as a table. Default, if omitted, is 3
  *		genericUIList = forces FT_*_EDITOR_UI to return single UI list for table rather than by type
  *		classname = class to assign to form element
  * @return string HTML code to generate form widget
  */
 public function preferenceHtmlFormElement($ps_pref, $ps_format = null, $pa_options = null)
 {
     if ($this->isValidPreference($ps_pref)) {
         if (!is_array($pa_options)) {
             $pa_options = array();
         }
         $o_db = $this->getDb();
         $va_pref_info = $this->getPreferenceInfo($ps_pref);
         if (is_null($vs_current_value = $this->getPreference($ps_pref))) {
             $vs_current_value = $this->getPreferenceDefault($ps_pref);
         }
         $vs_output = "";
         $vs_class = "";
         $vs_classname = "";
         if (isset($pa_options['classname']) && $pa_options['classname']) {
             $vs_classname = $pa_options['classname'];
             $vs_class = " class='" . $pa_options['classname'] . "'";
         }
         foreach (array('displayType', 'displayWidth', 'displayHeight', 'length', 'formatType', 'choiceList', 'label', 'description') as $vs_k) {
             if (!isset($va_pref_info[$vs_k])) {
                 $va_pref_info[$vs_k] = null;
             }
         }
         switch ($va_pref_info["displayType"]) {
             # ---------------------------------
             case 'DT_FIELD':
                 if (($vn_display_width = $va_pref_info["displayWidth"]) < 1) {
                     $vn_display_width = 20;
                 }
                 if (($vn_display_height = $va_pref_info["displayHeight"]) < 1) {
                     $vn_display_height = 1;
                 }
                 if (isset($va_pref_info["length"]["maximum"])) {
                     $vn_max_input_length = $va_pref_info["length"]["maximum"];
                 } else {
                     $vn_max_input_length = $vn_display_width;
                 }
                 if ($vn_display_height > 1) {
                     $vs_output = "<textarea name='pref_{$ps_pref}' rows='" . $vn_display_height . "' cols='" . $vn_display_width . "'>" . htmlspecialchars($vs_current_value, ENT_QUOTES, 'UTF-8') . "</textarea>\n";
                 } else {
                     $vs_output = "<input type='text' name='pref_{$ps_pref}' size='{$vn_display_width}' maxlength='{$vn_max_input_length}'" . $vs_class . " value='" . htmlspecialchars($vs_current_value, ENT_QUOTES, 'UTF-8') . "'/>\n";
                 }
                 break;
                 # ---------------------------------
             # ---------------------------------
             case 'DT_SELECT':
                 switch ($va_pref_info['formatType']) {
                     case 'FT_UI_LOCALE':
                         $va_locales = array();
                         if ($r_dir = opendir(__CA_APP_DIR__ . '/locale/')) {
                             while (($vs_locale_dir = readdir($r_dir)) !== false) {
                                 if ($vs_locale_dir[0] == '.') {
                                     continue;
                                 }
                                 if (sizeof($va_tmp = explode('_', $vs_locale_dir)) == 2) {
                                     $va_locales[$vs_locale_dir] = $va_tmp;
                                 }
                             }
                         }
                         $va_opts = array();
                         $t_locale = new ca_locales();
                         foreach ($va_locales as $vs_code => $va_parts) {
                             try {
                                 $vs_lang_name = Zend_Locale::getTranslation(strtolower($va_parts[0]), 'language', strtolower($va_parts[0]));
                                 $vs_country_name = Zend_Locale::getTranslation($va_parts[1], 'Country', $vs_code);
                             } catch (Exception $e) {
                                 $vs_lang_name = strtolower($va_parts[0]);
                                 $vs_country_name = $vs_code;
                             }
                             $va_opts[($vs_lang_name ? $vs_lang_name : $vs_code) . ($vs_country_name ? ' (' . $vs_country_name . ')' : '')] = $vs_code;
                         }
                         break;
                     case 'FT_LOCALE':
                         $qr_locales = $o_db->query("\n\t\t\t\t\t\t\t\tSELECT *\n\t\t\t\t\t\t\t\tFROM ca_locales\n\t\t\t\t\t\t\t\tORDER BY \n\t\t\t\t\t\t\t\t\tname\n\t\t\t\t\t\t\t");
                         $va_opts = array();
                         while ($qr_locales->nextRow()) {
                             $va_opts[$qr_locales->get('name')] = $qr_locales->get('language') . '_' . $qr_locales->get('country');
                         }
                         break;
                     case 'FT_THEME':
                         if ($r_dir = opendir($this->_CONFIG->get('themes_directory'))) {
                             $va_opts = array();
                             while (($vs_theme_dir = readdir($r_dir)) !== false) {
                                 if ($vs_theme_dir[0] == '.') {
                                     continue;
                                 }
                                 $o_theme_info = Configuration::load($this->_CONFIG->get('themes_directory') . '/' . $vs_theme_dir . '/themeInfo.conf');
                                 $va_opts[$o_theme_info->get('name')] = $vs_theme_dir;
                             }
                         }
                         break;
                     case 'FT_OBJECT_EDITOR_UI':
                     case 'FT_OBJECT_LOT_EDITOR_UI':
                     case 'FT_ENTITY_EDITOR_UI':
                     case 'FT_PLACE_EDITOR_UI':
                     case 'FT_OCCURRENCE_EDITOR_UI':
                     case 'FT_COLLECTION_EDITOR_UI':
                     case 'FT_STORAGE_LOCATION_EDITOR_UI':
                     case 'FT_OBJECT_REPRESENTATION_EDITOR_UI':
                     case 'FT_REPRESENTATION_ANNOTATION_EDITOR_UI':
                     case 'FT_SET_EDITOR_UI':
                     case 'FT_SET_ITEM_EDITOR_UI':
                     case 'FT_LIST_EDITOR_UI':
                     case 'FT_LIST_ITEM_EDITOR_UI':
                     case 'FT_LOAN_EDITOR_UI':
                     case 'FT_MOVEMENT_EDITOR_UI':
                     case 'FT_TOUR_EDITOR_UI':
                     case 'FT_TOUR_STOP_EDITOR_UI':
                     case 'FT_SEARCH_FORM_EDITOR_UI':
                     case 'FT_BUNDLE_DISPLAY_EDITOR_UI':
                     case 'FT_RELATIONSHIP_TYPE_EDITOR_UI':
                     case 'FT_USER_INTERFACE_EDITOR_UI':
                     case 'FT_USER_INTERFACE_SCREEN_EDITOR_UI':
                     case 'FT_IMPORT_EXPORT_MAPPING_EDITOR_UI':
                     case 'FT_IMPORT_EXPORT_MAPPING_GROUP_EDITOR_UI':
                         $vn_table_num = $this->_editorPrefFormatTypeToTableNum($va_pref_info['formatType']);
                         $t_instance = $this->getAppDatamodel()->getInstanceByTableNum($vn_table_num, true);
                         $va_values = $this->getPreference($ps_pref);
                         if (!is_array($va_values)) {
                             $va_values = array();
                         }
                         if (method_exists($t_instance, 'getTypeFieldName') && $t_instance->getTypeFieldName() && (!isset($pa_options['genericUIList']) || !$pa_options['genericUIList'])) {
                             $vs_output = '';
                             $va_ui_list_by_type = $this->_getUIListByType($vn_table_num);
                             $va_types = array();
                             if ((bool) $t_instance->getFieldInfo($t_instance->getTypeFieldName(), 'IS_NULL')) {
                                 $va_types['_NONE_'] = array('LEVEL' => 0, 'name_singular' => _t('NONE'), 'name_plural' => _t('NONE'));
                             }
                             $va_types += $t_instance->getTypeList(array('returnHierarchyLevels' => true));
                             if (!is_array($va_types) || !sizeof($va_types)) {
                                 $va_types = array(1 => array());
                             }
                             // force ones with no types to get processed for __all__
                             foreach ($va_types as $vn_type_id => $va_type) {
                                 $va_opts = array();
                                 // print out type-specific
                                 if (is_array($va_ui_list_by_type[$vn_type_id])) {
                                     foreach (caExtractValuesByUserLocale($va_ui_list_by_type[$vn_type_id]) as $vn_ui_id => $vs_label) {
                                         $va_opts[$vn_ui_id] = $vs_label;
                                     }
                                 }
                                 // print out generic
                                 if (is_array($va_ui_list_by_type['__all__'])) {
                                     foreach (caExtractValuesByUserLocale($va_ui_list_by_type['__all__']) as $vn_ui_id => $vs_label) {
                                         $va_opts[$vn_ui_id] = $vs_label;
                                     }
                                 }
                                 if (!is_array($va_opts) || sizeof($va_opts) == 0) {
                                     continue;
                                 }
                                 $vs_output .= "<tr><td>" . str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", (int) $va_type['LEVEL']) . $va_type['name_singular'] . "</td><td><select name='pref_{$ps_pref}_{$vn_type_id}'>\n";
                                 foreach ($va_opts as $vs_val => $vs_opt) {
                                     $vs_selected = $vs_val == $va_values[$vn_type_id] ? "SELECTED" : "";
                                     $vs_output .= "<option value='" . htmlspecialchars($vs_val, ENT_QUOTES, 'UTF-8') . "' {$vs_selected}>{$vs_opt}</option>\n";
                                 }
                                 $vs_output .= "</select></td></tr>\n";
                             }
                         } else {
                             $va_opts = $this->_getUIList($vn_table_num);
                             if (!is_array($va_opts) || sizeof($va_opts) == 0) {
                                 $vs_output = '';
                                 break 2;
                             }
                             $vs_output = "<tr><td> </td><td><select name='pref_{$ps_pref}'>\n";
                             foreach ($va_opts as $vs_val => $vs_opt) {
                                 $vs_selected = $vs_val == $vs_current_value ? "SELECTED" : "";
                                 $vs_output .= "<option value='" . htmlspecialchars($vs_val, ENT_QUOTES, 'UTF-8') . "' {$vs_selected}>" . $vs_opt . "</option>\n";
                             }
                             $vs_output .= "</select></td></tr>\n";
                         }
                         break 2;
                     default:
                         $va_opts = $va_pref_info["choiceList"];
                         break;
                 }
                 if (!is_array($va_opts) || sizeof($va_opts) == 0) {
                     $vs_output = '';
                     break;
                 }
                 $vs_output = "<select name='pref_{$ps_pref}'" . $vs_class . ">\n";
                 foreach ($va_opts as $vs_opt => $vs_val) {
                     $vs_selected = $vs_val == $vs_current_value ? "selected='1'" : "";
                     $vs_output .= "<option value='" . htmlspecialchars($vs_val, ENT_QUOTES, 'UTF-8') . "' {$vs_selected}>" . $vs_opt . "</option>\n";
                 }
                 $vs_output .= "</select>\n";
                 break;
                 # ---------------------------------
             # ---------------------------------
             case 'DT_CHECKBOXES':
                 if ($va_pref_info["formatType"] == 'FT_BIT') {
                     $vs_selected = $vs_current_value ? "CHECKED" : "";
                     $vs_output .= "<input type='checkbox' name='pref_{$ps_pref}' value='1'" . $vs_class . " {$vs_selected}>\n";
                 } else {
                     if ($vb_use_table = isset($pa_options['useTable']) && (bool) $pa_options['useTable']) {
                         $vs_output .= "<table width='100%'>";
                     }
                     $vn_num_table_columns = isset($pa_options['numTableColumns']) && (int) $pa_options['numTableColumns'] > 0 ? (int) $pa_options['numTableColumns'] : 3;
                     $vn_c = 0;
                     foreach ($va_pref_info["choiceList"] as $vs_opt => $vs_val) {
                         if (is_array($vs_current_value)) {
                             $vs_selected = in_array($vs_val, $vs_current_value) ? "CHECKED" : "";
                         } else {
                             $vs_selected = '';
                         }
                         if ($vb_use_table && $vn_c == 0) {
                             $vs_output .= "<tr>";
                         }
                         if ($vb_use_table) {
                             $vs_output .= "<td width='" . floor(100 / $vn_num_table_columns) . "%'>";
                         }
                         $vs_output .= "<input type='checkbox' name='pref_" . $ps_pref . "[]' value='" . htmlspecialchars($vs_val, ENT_QUOTES, 'UTF-8') . "'" . $vs_class . " {$vs_selected}> " . $vs_opt . " \n";
                         if ($vb_use_table) {
                             $vs_output .= "</td>";
                         }
                         $vn_c++;
                         if ($vb_use_table && !($vn_c % $vn_num_table_columns)) {
                             $vs_output .= "</tr>\n";
                             $vn_c = 0;
                         }
                     }
                     if ($vb_use_table) {
                         $vs_output .= "</table>";
                     }
                 }
                 break;
                 # ---------------------------------
             # ---------------------------------
             case 'DT_STATEPROV_LIST':
                 $vs_output .= caHTMLSelect("pref_{$ps_pref}_select", array(), array('id' => "pref_{$ps_pref}_select", 'class' => $vs_classname), array('value' => $vs_current_value));
                 $vs_output .= caHTMLTextInput("pref_{$ps_pref}_name", array('id' => "pref_{$ps_pref}_text", 'value' => $vs_current_value, 'class' => $vs_classname));
                 break;
                 # ---------------------------------
             # ---------------------------------
             case 'DT_COUNTRY_LIST':
                 $vs_output .= caHTMLSelect("pref_{$ps_pref}", caGetCountryList(), array('id' => "pref_{$ps_pref}", 'class' => $vs_classname), array('value' => $vs_current_value));
                 if ($va_pref_info['stateProvPref']) {
                     $vs_output .= "<script type='text/javascript'>\n";
                     $vs_output .= "var caStatesByCountryList = " . json_encode(caGetStateList()) . ";\n";
                     $vs_output .= "\n\t\t\t\t\t\t\tjQuery('#pref_{$ps_pref}').click({countryID: 'pref_{$ps_pref}', stateProvID: 'pref_" . $va_pref_info['stateProvPref'] . "', value: '" . addslashes($this->getPreference($va_pref_info['stateProvPref'])) . "', statesByCountryList: caStatesByCountryList}, caUI.utils.updateStateProvinceForCountry);\n\t\t\t\t\t\t\tjQuery(document).ready(function() {\n\t\t\t\t\t\t\t\tcaUI.utils.updateStateProvinceForCountry({data: {countryID: 'pref_{$ps_pref}', stateProvID: 'pref_" . $va_pref_info['stateProvPref'] . "', value: '" . addslashes($this->getPreference($va_pref_info['stateProvPref'])) . "', statesByCountryList: caStatesByCountryList}});\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t";
                     $vs_output .= "</script>\n";
                 }
                 break;
                 # ---------------------------------
             # ---------------------------------
             case 'DT_CURRENCIES':
                 $vs_output .= caHTMLSelect("pref_{$ps_pref}", caAvailableCurrenciesForConversion(), array('id' => "pref_{$ps_pref}", 'class' => $vs_classname), array('value' => $vs_current_value));
                 break;
                 # ---------------------------------
             # ---------------------------------
             case 'DT_RADIO_BUTTONS':
                 foreach ($va_pref_info["choiceList"] as $vs_opt => $vs_val) {
                     $vs_selected = $vs_val == $vs_current_value ? "CHECKED" : "";
                     $vs_output .= "<input type='radio' name='pref_{$ps_pref}'" . $vs_class . " value='" . htmlspecialchars($vs_val, ENT_QUOTES, 'UTF-8') . "' {$vs_selected}> " . $vs_opt . " \n";
                 }
                 break;
                 # ---------------------------------
             # ---------------------------------
             case 'DT_PASSWORD':
                 if (($vn_display_width = $va_pref_info["displayWidth"]) < 1) {
                     $vn_display_width = 20;
                 }
                 if (isset($va_pref_info["length"]["maximum"])) {
                     $vn_max_input_length = $va_pref_info["length"]["maximum"];
                 } else {
                     $vn_max_input_length = $vn_display_width;
                 }
                 $vs_output = "<input type='password' name='pref_{$ps_pref}' size='{$vn_display_width}' maxlength='{$vn_max_input_length}'" . $vs_class . " value='" . htmlspecialchars($vs_current_value, ENT_QUOTES, 'UTF-8') . "'/>\n";
                 break;
                 # ---------------------------------
             # ---------------------------------
             default:
                 return "Configuration error: Invalid display type for {$ps_pref}";
                 # ---------------------------------
         }
         if (is_null($ps_format)) {
             if (isset($pa_options['field_errors']) && is_array($pa_options['field_errors']) && sizeof($pa_options['field_errors'])) {
                 $ps_format = $this->_CONFIG->get('form_element_error_display_format');
                 $va_field_errors = array();
                 foreach ($pa_options['field_errors'] as $o_e) {
                     $va_field_errors[] = $o_e->getErrorDescription();
                 }
                 $vs_errors = join('; ', $va_field_errors);
             } else {
                 $ps_format = $this->_CONFIG->get('form_element_display_format');
                 $vs_errors = '';
             }
         }
         if ($ps_format && $vs_output) {
             $vs_format = $ps_format;
             $vs_format = str_replace("^ELEMENT", $vs_output, $vs_format);
         } else {
             $vs_format = $vs_output;
         }
         $vs_format = str_replace("^EXTRA", '', $vs_format);
         if (preg_match("/\\^DESCRIPTION/", $vs_format)) {
             $vs_format = str_replace("^LABEL", _t($va_pref_info["label"]), $vs_format);
             $vs_format = str_replace("^DESCRIPTION", _t($va_pref_info["description"]), $vs_format);
         } else {
             // no explicit placement of description text, so...
             $vs_field_id = "pref_{$ps_pref}_container";
             $vs_format = str_replace("^LABEL", '<span id="' . $vs_field_id . '">' . _t($va_pref_info["label"]) . '</span>', $vs_format);
             TooltipManager::add('#' . $vs_field_id, "<h3>" . $va_pref_info["label"] . "</h3>" . $va_pref_info["description"]);
         }
         return $vs_format;
     } else {
         return "";
     }
 }