public function getFromList(&$list)
 {
     $current_locale = I18n::getCurrentLangCode();
     $country = Openbiz::$app->getClientProxy()->getFormInputs("fld_region");
     $country = strtoupper($country);
     if (!$country) {
         $locale = explode('_', $current_locale);
         $country = strtoupper($locale[0]);
     }
     //require_once('Zend/Locale.php');
     $locale = new \Zend_Locale($current_locale);
     $code2name = $locale->getTranslationList('territorytolanguage', $locale);
     $list = array();
     $i = 0;
     foreach ($code2name as $key => $value) {
         if (preg_match('/' . $country . '/', $value) || strtoupper($key) == $country) {
             $lang_list = explode(" ", $value);
             foreach ($lang_list as $lang) {
                 $list[$i]['txt'] = strtolower($key) . "_" . strtoupper($lang);
                 $list[$i]['val'] = strtolower($key) . "_" . strtoupper($lang);
                 $i++;
             }
         }
     }
     return $list;
 }
 public function getDefaultLangName($lang = null)
 {
     if ($lang == null) {
         $do = Openbiz::getObject("myaccount.do.PreferenceDO", 1);
         $rec = $do->fetchOne("[user_id]='0' AND [name]='language'");
         if ($rec) {
             $lang = $rec['value'];
         } else {
             $lang = OPENBIZ_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 OPENBIZ_DEFAULT_LANGUAGE;
         }
     }
 }
 public function fetchData()
 {
     $this->activeRecord = null;
     $resultRaw = parent::fetchData();
     foreach ($resultRaw as $key => $value) {
         if (substr($key, 0, 1) == '_') {
             $key = substr($key, 1);
         }
         $result[$key] = $value;
     }
     $lang = Openbiz::$app->getClientProxy()->getFormInputs("fld_lang");
     $lang ? $lang : ($lang = I18n::getCurrentLangCode());
     $record_id = $result["Id"];
     $transDO = Openbiz::getObject($this->translateDO, 1);
     $currentRecord = $transDO->fetchOne("[lang]='{$lang}'");
     if ($currentRecord) {
         $currentRecord = $currentRecord->toArray();
         foreach ($currentRecord as $field => $value) {
             $result['_' . $field] = $value;
         }
     } else {
         $result['_repo_name'] = "";
         $result['_repo_desc'] = "";
     }
     return $result;
 }
Example #4
0
 /**
  * Constructor of TypeManager, set locale with $localCode parameter
  *
  * @param string $localeCode
  * @return void
  **/
 public function __construct($localeCode = "")
 {
     //try to set correct locale for current language as defined in app.inc section I18n
     $currentLanguage = I18n::getCurrentLangCode();
     $localeCode = $GLOBALS["local"][$currentLanguage];
     setlocale(LC_ALL, $localeCode);
     $this->_localeInfo = localeconv();
     if ($this->_localeInfo['frac_digits'] > 10) {
         $this->_localeInfo = null;
     }
 }
 public function getFromList(&$list)
 {
     //require_once('Zend/Locale.php');
     $locale = new \Zend_Locale(I18n::getCurrentLangCode());
     $code2name = $locale->getTranslationList('territory', $locale, 2);
     $list = array();
     $i = 0;
     foreach ($code2name as $key => $value) {
         if ((int) $key == 0) {
             $list[$i]['val'] = $key;
             $list[$i]['txt'] = $value;
             $i++;
         }
     }
     return $list;
 }
 public function fetchData()
 {
     preg_match("/\\[([\\S]*?)\\]=\\'file_(.*?)\\'/si", $this->fixSearchRule, $match);
     $Id = $match[2];
     $resultArr = $this->fetchDataSet();
     $record = $resultArr[$Id];
     //require_once('Zend/Locale.php');
     $locale = new \Zend_Locale(I18n::getCurrentLangCode());
     $code2name = $locale->getTranslationList('language', $locale);
     $lang_code = $this->getLang();
     $locale = explode('_', $lang_code);
     $lang = $code2name[$locale[0]];
     $image_path = OPENBIZ_APP_URL . "/images/nations/22x14/" . strtolower($locale[1]) . '.png';
     $image = "<image  style=\"float:left;display:block;margin-right:5px;padding-top:2px;\" src=\"{$image_path}\" />";
     $record['lang'] = "<div>" . $image . " <span style=\"float:left;display:block;\">{$lang} ( {$lang_code} )</span></div>";
     $record['translation'] = file_get_contents($record['path']);
     $this->recordId = "file_" . $Id;
     return $record;
 }
 public function getFormatCurrency($amount, $prefix = '')
 {
     $current_locale = I18n::getCurrentLangCode();
     /*
     switch($current_locale)
     {
     	case "zh_CN":
     		$display_amount = "¥ ";
     		break;
     	case "en_US":
     	default:
     		$display_amount = "$ ";
     		break;
     }
     $display_amount.= number_format(floatval($amount));
     return $prefix.$display_amount;
     */
     setlocale(LC_MONETARY, $current_locale . '.utf8');
     if (function_exists("money_format") && false) {
         $display_amount = money_format('%n', (double) $amount);
     } else {
         $locale_info = localeconv();
         if (!$locale_info[currency_symbol]) {
             setlocale(LC_MONETARY, $current_locale);
             $locale_info = localeconv();
         }
         $display_amount = $locale_info[currency_symbol] . ' ' . sprintf("%.2f", (double) $amount);
     }
     return $prefix . $display_amount;
     /*
     //Zend Currency is crazy slow
     require_once('Zend/Currency.php');
     $current_currency = CUBI_DEFAULT_CURRENCY;		
     if(!$current_currency){
     	$current_currency = "USD";
     }				
     $currency = new \Zend_Currency($current_currency,$current_locale);	
     $amount = floatval($amount);
     $display_name = $currency->toCurrency($prefix.$amount);
     return $display_name;
     */
 }
 public function fetchData()
 {
     $this->activeRecord = null;
     $result = parent::fetchData();
     $lang = Openbiz::$app->getClientProxy()->getFormInputs("fld_lang");
     $lang ? $lang : ($lang = I18n::getCurrentLangCode());
     $record_id = $result["Id"];
     $transDO = Openbiz::getObject($this->translateDO, 1);
     $currentRecord = $transDO->fetchOne("[{$this->recordFKField}]='{$record_id}' AND [lang]='{$lang}'");
     if ($currentRecord) {
         $currentRecord = $currentRecord->toArray();
         foreach ($currentRecord as $field => $value) {
             $result['_' . $field] = $value;
         }
     } else {
         $result['_name'] = "";
         $result['_description'] = "";
     }
     return $result;
 }
 function getFromList(&$list)
 {
     $current_locale = I18n::getCurrentLangCode();
     //require_once('Zend/Locale.php');
     $locale = new \Zend_Locale($current_locale);
     $current_currency = CUBI_DEFAULT_CURRENCY;
     if (!$current_currency) {
         $current_currency = "USD";
     }
     //require_once('Zend/Currency.php');
     $currency = new \Zend_Currency($current_currency, $current_locale);
     $currencyList = $currency->getCurrencyList();
     foreach ($currencyList as $currency_code => $country) {
         $display_name = $currency->getName($currency_code, $current_locale);
         if ($display_name) {
             array_push($list, array("val" => $currency_code, "txt" => "{$currency_code} - {$display_name}"));
         }
     }
     return $list;
 }
 function getList()
 {
     $list = array();
     $lang_dir = OPENBIZ_APP_PATH . DIRECTORY_SEPARATOR . "languages" . DIRECTORY_SEPARATOR . $lang;
     if (!is_dir($lang_dir)) {
         return array();
     }
     $current_locale = I18n::getCurrentLangCode();
     //require_once('Zend/Locale.php');
     $locale = new \Zend_Locale($current_locale);
     $code2name = $locale->getTranslationList('language', $locale);
     foreach (glob($lang_dir . DIRECTORY_SEPARATOR . "*") as $dir) {
         $lang_code = basename($dir);
         if ($lang_code == 'dictionary') {
             continue;
         }
         $locale = explode('_', $lang_code);
         $lang_name = $code2name[strtolower($locale[0])];
         array_push($list, array("val" => $lang_code, "txt" => $lang_name . " ( {$lang_code} )", "pic" => OPENBIZ_APP_URL . "/images/nations/22x14/" . strtolower($locale[1]) . ".png"));
     }
     return $list;
 }
 public function translateElemArr($elemArr, $setting_id)
 {
     $lang = I18n::getCurrentLangCode();
     if (!$lang) {
         return $elemArr;
     }
     $setting_id = (int) $setting_id;
     $transDO = Openbiz::getObject($this->extendSettingTranslationDO, 1);
     $transRec = $transDO->fetchOne("[setting_id]='{$setting_id}' AND [lang]='{$lang}'");
     if (!$transRec) {
         return $elemArr;
     }
     $elemArr['LABEL'] = $transRec['label'];
     $elemArr['DESCRIPTION'] = $transRec['description'];
     $elemArr['DEFAULTVALUE'] = $transRec['defaultvalue'];
     if ($elemArr['SELECTFROM']) {
         $transOptDO = Openbiz::getObject($this->extendSettingOptionDO, 1);
         $opts = $transOptDO->directfetch("[setting_id]='" . $setting_id . "' AND [lang]='{$lang}'");
         if ($opts && $opts->count() > 0) {
             $elemArr['SELECTFROM'] = $this->extendSettingOptionDO . "[text:value],[setting_id]='" . $setting_id . "' AND [lang]='{$lang}' ";
         }
     }
     return $elemArr;
 }
Example #12
0
 public static function addLangData($from_module, $to_module = null)
 {
     if ($to_module == null) {
         $to_module = $from_module;
     }
     $langCode = I18n::getCurrentLangCode();
     $filename = "mod.{$from_module}.ini";
     $langFile = OPENBIZ_LANGUAGE_PATH . "/{$langCode}/{$filename}";
     if (!file_exists($langFile)) {
         return false;
     }
     $inidata = parse_ini_file($langFile, false);
     if (is_array(I18n::$_langData[$to_module])) {
         I18n::$_langData[$to_module] = array_merge(I18n::$_langData[$to_module], $inidata);
     } else {
         I18n::$_langData[$to_module] = $inidata;
     }
     return true;
 }
Example #13
0
 /**
  * Get appended styles
  *
  * @return string
  */
 public function getAppendedStyles($comb = 0)
 {
     $extraStyles = implode("", $this->_extraStyles);
     $extraStyle_array = explode("type=\"text/css\">", $extraStyles);
     if (defined("OPENBIZ_RESOURCE_PHP") && $comb) {
         $css_scripts = OPENBIZ_RESOURCE_PHP . "?f=";
         $matches = array();
         foreach ($extraStyle_array as $style) {
             // extract href part from each line
             if (preg_match('/.+href="([^"]+)".+/', $style, $matches) > 0 && !empty($matches[1])) {
                 if (substr($css_scripts, -2) == 'f=') {
                     $css_scripts .= $matches[1];
                 } else {
                     $css_scripts .= ',' . $matches[1];
                 }
             }
         }
         return "<link rel=\"stylesheet\" href=\"" . $css_scripts . "\" type=\"text/css\"/>";
     }
     $cleanStyle_array = array();
     foreach ($extraStyle_array as $style) {
         if (in_array($style . "type=\"text/css\">", $cleanStyle_array) == FALSE and strlen($style) != 0) {
             $cleanStyle_array[] = $style . "type=\"text/css\">";
         }
     }
     $lang = I18n::getCurrentLangCode();
     $localization_css_file = OPENBIZ_APP_PATH . DIRECTORY_SEPARATOR . "languages" . DIRECTORY_SEPARATOR . $lang . DIRECTORY_SEPARATOR . "localization.css";
     if (is_file($localization_css_file)) {
         $cleanStyle_array[] = "<link rel=\"stylesheet\" href=\"" . OPENBIZ_APP_URL . "/languages/{$lang}/localization.css\" type=\"text/css\">";
     }
     return implode("\n", $cleanStyle_array);
 }
 /**
  * Get \Zend Template
  * @return \Zend_View zend view template object
  */
 public static function getZendTemplate()
 {
     $view = new \Zend_View();
     if (defined('SMARTY_TPL_PATH')) {
         $view->setScriptPath(SMARTY_TPL_PATH);
     }
     $theme = Openbiz::$app->getCurrentTheme();
     // load the config file which has the images and css url defined
     $view->app_url = OPENBIZ_APP_URL;
     $view->app_index = OPENBIZ_APP_INDEX_URL;
     $view->js_url = OPENBIZ_JS_URL;
     $view->css_url = OPENBIZ_THEME_URL . "/" . $theme . "/css";
     $view->resource_url = OPENBIZ_RESOURCE_URL;
     $view->theme_js_url = OPENBIZ_THEME_URL . "/" . $theme . "/js";
     $view->theme_url = OPENBIZ_THEME_URL . "/" . $theme;
     $view->image_url = OPENBIZ_THEME_URL . "/" . $theme . "/images";
     $view->lang = strtolower(I18n::getCurrentLangCode());
     return $view;
 }
Example #15
0
 public function Code2Region($code, $locale = null)
 {
     $code = strtoupper($code);
     //require_once('Zend/Locale.php');
     $locale = new \Zend_Locale(I18n::getCurrentLangCode());
     $code2name = $locale->getTranslationList('territory', $locale);
     $result = $code2name[$code];
     $locale = null;
     $code2name = null;
     return $result;
 }
 protected function _remoteCall($uri, $method, $params = null)
 {
     $cache_id = md5($this->objectName . $uri . $method . serialize($params));
     $cacheSvc = Openbiz::getService(CACHE_SERVICE, 1);
     $cacheSvc->init($this->objectName, $this->cacheLifeTime);
     if (substr($uri, strlen($uri) - 1, 1) != '/') {
         $uri .= '/';
     }
     $uri .= "ws.php/repository/RepositoryService";
     if ($cacheSvc->test($cache_id) && (int) $this->cacheLifeTime > 0) {
         $resultSetArray = $cacheSvc->load($cache_id);
     } else {
         try {
             $argsJson = urlencode(json_encode($params));
             $lang = I18n::getCurrentLangCode();
             $query = array("method={$method}", "format=json", "argsJson={$argsJson}", "lang={$lang}");
             $httpClient = new HttpClient('POST');
             foreach ($query as $q) {
                 $httpClient->addQuery($q);
             }
             $headerList = array();
             $out = $httpClient->fetchContents($uri, $headerList);
             $cats = json_decode($out, true);
             $resultSetArray = $cats['data'];
             $cacheSvc->save($resultSetArray, $cache_id);
         } catch (Exception $e) {
             $resultSetArray = array();
         }
     }
     return $resultSetArray;
 }