Example #1
0
 public function run()
 {
     $conf_cache = Bd_Global::getConfCache();
     $domains = $conf_cache['domains'];
     $operationDomains = $conf_cache['operation_domains'];
     $domain = strtolower($_SERVER['SERVER_NAME']);
     $filteredLocales = array();
     foreach (array($domains, $operationDomains) as $domains) {
         if ($domains) {
             foreach ($domains as $do) {
                 if (false != Bd_Global::validDomain($domain, $do['domain'])) {
                     $filteredLocales[] = $do['locale'];
                 }
             }
         }
     }
     $locale_cnt = count($filteredLocales);
     if ($locale_cnt == 1) {
         self::setLocale($filteredLocales[0]);
         return true;
     } else {
         if ($locale_cnt > 1) {
             self::$_valid_locale = $filteredLocales;
             self::setLocale($filteredLocales[0]);
             return false;
         }
     }
     return false;
 }
Example #2
0
 public static function convertName($clusterName, $extra = array())
 {
     if (empty(self::$_dbPreArr)) {
         $conf = Bd_Conf::getConf('/i18n/interface/db');
         self::$_dbPreArr = $conf['pre'];
     }
     if (self::$_dbPreArr && in_array($clusterName, self::$_dbPreArr)) {
         $clusterName .= '_' . Bd_Global::getInstance();
     }
     return $clusterName;
 }
Example #3
0
 protected function _input_converter($method, $param, $extra)
 {
     if (!is_array($param)) {
         $this->_add_error("input parameter is not array!");
         return null;
     }
     if (isset($extra['region'])) {
         $global_file = dirname(__FILE__) . "/../../bd/Global.php";
         $conf_file = dirname(__FILE__) . "/../../bd/Conf.php";
         if (file_exists($global_file) && file_exists($conf_file)) {
             require_once $global_file;
             require_once $conf_file;
             $region = $this->_extra['region'];
             $region_index = Bd_Global::getRegionIndex($region);
             for ($i = 0; $i < count($param); $i++) {
                 $param[$i]['groupid'] = $region_index * 10 + $param[$i]['groupid'];
             }
         }
     }
     return array('reqs' => json_encode($param));
 }
Example #4
0
 public function __construct()
 {
     if (empty(self::$_valid_locale)) {
         self::$_valid_locale = Bd_Global::getSupportLocale();
     }
 }
Example #5
0
 /**
  * @brief  数据访问接口初始化,须在语言识别(checkLocale)之后调用 or $param 
  * @param $param
  *            1) 默认不传,使用识别后的instance,locale;
  *            2) array('instance' => xx, //必须
  *                     'locale' => xx //必须
  *                )
  * @return bool 
  */
 public function initDataInterface($param = null)
 {
     if (null == $param) {
         $instance = Bd_Global::getInstance();
         $locale = Bd_Global::getLocale();
     } else {
         $instance = $param['instance'];
         $locale = $param['locale'];
         if (empty($param['instance'])) {
             Bd_Log::warning(" initDataInterface input param \"instance\"  can't be empty! param:" . var_export($param, true));
             return false;
         }
     }
     if (empty($instance)) {
         Bd_Log::warning(" initDataInterface \"instance\"  can't be empty! ");
         return false;
     }
     Bd_Conf::setLevel("/i18n/instance/{$instance}/");
     if (!class_exists('Bd_RalRpc')) {
         require_once dirname(__FILE__) . '/RalRpc.php';
     }
     require_once dirname(__FILE__) . '/global/strategy/Base.php';
     Bd_RalRpc::add_extra(array('instance' => $instance, 'region' => $instance, 'locale' => $locale));
     Bd_Log::addNotice('instance', $instance);
     Bd_Log::addNotice('locale', $locale);
     Bd_Log::addNotice('strategy', self::$_cur_strategy);
     return true;
 }