当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Utils_System::getUFLocale方法代码示例

本文整理汇总了PHP中CRM_Utils_System::getUFLocale方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_System::getUFLocale方法的具体用法?PHP CRM_Utils_System::getUFLocale怎么用?PHP CRM_Utils_System::getUFLocale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Utils_System的用法示例。


在下文中一共展示了CRM_Utils_System::getUFLocale方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: asort

 /**
  *  Sort an array and maintain index association, use Collate from the
  *  PECL "intl" package, if available, for UTF-8 sorting (ex: list of countries).
  *  On Debian/Ubuntu: apt-get install php5-intl
  *
  *  @param array $array array of values
  *
  *  @return  array  Sorted array
  *  @static
  */
 static function asort($array = array())
 {
     $lcMessages = CRM_Utils_System::getUFLocale();
     if ($lcMessages && $lcMessages != 'en_US' && class_exists('Collator')) {
         $collator = new Collator($lcMessages . '.utf8');
         $collator->asort($array);
     } else {
         asort($array);
     }
     return $array;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:21,代码来源:Array.php

示例2: retrieve

 /**
  * Function to retrieve the settings values from db
  *
  * @return array $defaults  
  * @static
  */
 static function retrieve(&$defaults)
 {
     require_once "CRM/Core/DAO/Domain.php";
     $domain = new CRM_Core_DAO_Domain();
     $domain->selectAdd();
     if (CRM_Utils_Array::value('q', $_GET) == 'civicrm/upgrade') {
         $domain->selectAdd('config_backend');
     } else {
         $domain->selectAdd('config_backend, locales');
     }
     $domain->id = CRM_Core_Config::domainID();
     $domain->find(true);
     if ($domain->config_backend) {
         $defaults = unserialize($domain->config_backend);
         // calculate month var
         $defaults['dateformatMonthVar'] = strstr($defaults['dateformatQfDate'], '%m') ? 'm' : (strstr($defaults['dateformatQfDate'], '%b') ? 'M' : (strstr($defaults['dateformatQfDate'], '%B') ? 'F' : null));
         //calculate month var for Date Time
         $defaults['datetimeformatMonthVar'] = strstr($defaults['dateformatQfDatetime'], '%m') ? 'm' : (strstr($defaults['dateformatQfDatetime'], '%b') ? 'M' : (strstr($defaults['dateformatQfDatetime'], '%B') ? 'F' : null));
         //calculate hour var for Date Time
         $defaults['datetimeformatHourVar'] = strstr($defaults['dateformatQfDatetime'], '%I') ? 'h' : (strstr($defaults['dateformatQfDatetime'], '%l') ? 'g' : null);
         // set proper monetary formatting, falling back to en_US and C (CRM-2782)
         setlocale(LC_MONETARY, $defaults['lcMonetary'] . '.utf8', $defaults['lcMonetary'], 'en_US.utf8', 'en_US', 'C');
         $skipVars = array('dsn', 'templateCompileDir', 'userFrameworkDSN', 'userFrameworkBaseURL', 'userFrameworkClass', 'userHookClass', 'userPermissionClass', 'userFrameworkURLVar', 'qfKey', 'gettextResourceDir', 'cleanURL');
         foreach ($skipVars as $skip) {
             if (array_key_exists($skip, $defaults)) {
                 unset($defaults[$skip]);
             }
         }
         // since language field won't be present before upgrade.
         if (CRM_Utils_Array::value('q', $_GET) == 'civicrm/upgrade') {
             return;
         }
         // are we in a multi-language setup?
         $multiLang = $domain->locales ? true : false;
         // set the current language
         $lcMessages = null;
         $session =& CRM_Core_Session::singleton();
         // on multi-lang sites based on request and civicrm_uf_match
         if ($multiLang) {
             require_once 'CRM/Utils/Request.php';
             $lcMessagesRequest = CRM_Utils_Request::retrieve('lcMessages', 'String', $this);
             $languageLimit = array();
             if (array_key_exists('languageLimit', $defaults) && is_array($defaults['languageLimit'])) {
                 $languageLimit = $defaults['languageLimit'];
             }
             if (in_array($lcMessagesRequest, array_keys($languageLimit))) {
                 $lcMessages = $lcMessagesRequest;
             } else {
                 $lcMessagesRequest = null;
             }
             if (!$lcMessagesRequest) {
                 $lcMessagesSession = $session->get('lcMessages');
                 if (in_array($lcMessagesSession, array_keys($languageLimit))) {
                     $lcMessages = $lcMessagesSession;
                 } else {
                     $lcMessagesSession = null;
                 }
             }
             if ($lcMessagesRequest) {
                 require_once 'CRM/Core/DAO/UFMatch.php';
                 $ufm = new CRM_Core_DAO_UFMatch();
                 $ufm->contact_id = $session->get('userID');
                 if ($ufm->find(true)) {
                     $ufm->language = $lcMessages;
                     $ufm->save();
                 }
                 $session->set('lcMessages', $lcMessages);
             }
             if (!$lcMessages and $session->get('userID')) {
                 require_once 'CRM/Core/DAO/UFMatch.php';
                 $ufm = new CRM_Core_DAO_UFMatch();
                 $ufm->contact_id = $session->get('userID');
                 if ($ufm->find(true) && in_array($ufm->language, array_keys($languageLimit))) {
                     $lcMessages = $ufm->language;
                 }
                 $session->set('lcMessages', $lcMessages);
             }
         }
         // if unset, try to inherit the language from the hosting CMS
         if ($lcMessages === null) {
             require_once 'CRM/Utils/System.php';
             $lcMessages = CRM_Utils_System::getUFLocale();
             require_once 'CRM/Core/BAO/CustomOption.php';
             if ($domain->locales and !in_array($lcMessages, explode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, $domain->locales))) {
                 $lcMessages = null;
             }
         }
         if ($lcMessages) {
             // update config lcMessages - CRM-5027 fixed.
             $defaults['lcMessages'] = $lcMessages;
         } else {
             // if a single-lang site or the above didn't yield a result, use default
             $lcMessages = $defaults['lcMessages'];
         }
//.........这里部分代码省略.........
开发者ID:ksecor,项目名称:civicrm,代码行数:101,代码来源:Setting.php

示例3: applyLocale

 /**
  * Evaluate locale preferences and activate a chosen locale by
  * updating session+global variables.
  *
  * @param \Civi\Core\SettingsBag $settings
  * @param string $activatedLocales
  *   Imploded list of locales which are supported in the DB.
  */
 public static function applyLocale($settings, $activatedLocales)
 {
     // are we in a multi-language setup?
     $multiLang = $activatedLocales ? TRUE : FALSE;
     // set the current language
     $chosenLocale = NULL;
     $session = CRM_Core_Session::singleton();
     // on multi-lang sites based on request and civicrm_uf_match
     if ($multiLang) {
         $languageLimit = array();
         if (is_array($settings->get('languageLimit'))) {
             $languageLimit = $settings->get('languageLimit');
         }
         $requestLocale = CRM_Utils_Request::retrieve('lcMessages', 'String');
         if (in_array($requestLocale, array_keys($languageLimit))) {
             $chosenLocale = $requestLocale;
             //CRM-8559, cache navigation do not respect locale if it is changed, so reseting cache.
             // Ed: This doesn't sound good.
             CRM_Core_BAO_Cache::deleteGroup('navigation');
         } else {
             $requestLocale = NULL;
         }
         if (!$requestLocale) {
             $sessionLocale = $session->get('lcMessages');
             if (in_array($sessionLocale, array_keys($languageLimit))) {
                 $chosenLocale = $sessionLocale;
             } else {
                 $sessionLocale = NULL;
             }
         }
         if ($requestLocale) {
             $ufm = new CRM_Core_DAO_UFMatch();
             $ufm->contact_id = $session->get('userID');
             if ($ufm->find(TRUE)) {
                 $ufm->language = $chosenLocale;
                 $ufm->save();
             }
             $session->set('lcMessages', $chosenLocale);
         }
         if (!$chosenLocale and $session->get('userID')) {
             $ufm = new CRM_Core_DAO_UFMatch();
             $ufm->contact_id = $session->get('userID');
             if ($ufm->find(TRUE) && in_array($ufm->language, array_keys($languageLimit))) {
                 $chosenLocale = $ufm->language;
             }
             $session->set('lcMessages', $chosenLocale);
         }
     }
     global $dbLocale;
     // try to inherit the language from the hosting CMS
     if ($settings->get('inheritLocale')) {
         // FIXME: On multilanguage installs, CRM_Utils_System::getUFLocale() in many cases returns nothing if $dbLocale is not set
         $dbLocale = $multiLang ? "_" . $settings->get('lcMessages') : '';
         $chosenLocale = CRM_Utils_System::getUFLocale();
         if ($activatedLocales and !in_array($chosenLocale, explode(CRM_Core_DAO::VALUE_SEPARATOR, $activatedLocales))) {
             $chosenLocale = NULL;
         }
     }
     if (empty($chosenLocale)) {
         //CRM-11993 - if a single-lang site, use default
         $chosenLocale = $settings->get('lcMessages');
     }
     // set suffix for table names - use views if more than one language
     $dbLocale = $multiLang ? "_{$chosenLocale}" : '';
     // FIXME: an ugly hack to fix CRM-4041
     global $tsLocale;
     $tsLocale = $chosenLocale;
     // FIXME: as bad aplace as any to fix CRM-5428
     // (to be moved to a sane location along with the above)
     if (function_exists('mb_internal_encoding')) {
         mb_internal_encoding('UTF-8');
     }
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:81,代码来源:ConfigSetting.php

示例4: retrieve

 /**
  * Retrieve the settings values from db.
  *
  * @param $defaults
  *
  * @return array
  */
 public static function retrieve(&$defaults)
 {
     $domain = new CRM_Core_DAO_Domain();
     //we are initializing config, really can't use, CRM-7863
     $urlVar = 'q';
     if (defined('CIVICRM_UF') && CIVICRM_UF == 'Joomla') {
         $urlVar = 'task';
     }
     if (CRM_Core_Config::isUpgradeMode()) {
         $domain->selectAdd('config_backend');
     } elseif (CRM_Utils_Array::value($urlVar, $_GET) == 'admin/modules/list/confirm') {
         $domain->selectAdd('config_backend', 'locales');
     } else {
         $domain->selectAdd('config_backend, locales, locale_custom_strings');
     }
     $domain->id = CRM_Core_Config::domainID();
     $domain->find(TRUE);
     if ($domain->config_backend) {
         $defaults = unserialize($domain->config_backend);
         if ($defaults === FALSE || !is_array($defaults)) {
             $defaults = array();
             return FALSE;
         }
         $skipVars = self::skipVars();
         foreach ($skipVars as $skip) {
             if (array_key_exists($skip, $defaults)) {
                 unset($defaults[$skip]);
             }
         }
         // check if there are any locale strings
         if ($domain->locale_custom_strings) {
             $defaults['localeCustomStrings'] = unserialize($domain->locale_custom_strings);
         } else {
             $defaults['localeCustomStrings'] = NULL;
         }
         // are we in a multi-language setup?
         $multiLang = $domain->locales ? TRUE : FALSE;
         // set the current language
         $lcMessages = NULL;
         $session = CRM_Core_Session::singleton();
         // on multi-lang sites based on request and civicrm_uf_match
         if ($multiLang) {
             $lcMessagesRequest = CRM_Utils_Request::retrieve('lcMessages', 'String', $this);
             $languageLimit = array();
             if (array_key_exists('languageLimit', $defaults) && is_array($defaults['languageLimit'])) {
                 $languageLimit = $defaults['languageLimit'];
             }
             if (in_array($lcMessagesRequest, array_keys($languageLimit))) {
                 $lcMessages = $lcMessagesRequest;
                 //CRM-8559, cache navigation do not respect locale if it is changed, so reseting cache.
                 CRM_Core_BAO_Cache::deleteGroup('navigation');
             } else {
                 $lcMessagesRequest = NULL;
             }
             if (!$lcMessagesRequest) {
                 $lcMessagesSession = $session->get('lcMessages');
                 if (in_array($lcMessagesSession, array_keys($languageLimit))) {
                     $lcMessages = $lcMessagesSession;
                 } else {
                     $lcMessagesSession = NULL;
                 }
             }
             if ($lcMessagesRequest) {
                 $ufm = new CRM_Core_DAO_UFMatch();
                 $ufm->contact_id = $session->get('userID');
                 if ($ufm->find(TRUE)) {
                     $ufm->language = $lcMessages;
                     $ufm->save();
                 }
                 $session->set('lcMessages', $lcMessages);
             }
             if (!$lcMessages and $session->get('userID')) {
                 $ufm = new CRM_Core_DAO_UFMatch();
                 $ufm->contact_id = $session->get('userID');
                 if ($ufm->find(TRUE) && in_array($ufm->language, array_keys($languageLimit))) {
                     $lcMessages = $ufm->language;
                 }
                 $session->set('lcMessages', $lcMessages);
             }
         }
         global $dbLocale;
         // try to inherit the language from the hosting CMS
         if (!empty($defaults['inheritLocale'])) {
             // FIXME: On multilanguage installs, CRM_Utils_System::getUFLocale() in many cases returns nothing if $dbLocale is not set
             $dbLocale = $multiLang ? "_{$defaults['lcMessages']}" : '';
             $lcMessages = CRM_Utils_System::getUFLocale();
             if ($domain->locales and !in_array($lcMessages, explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales))) {
                 $lcMessages = NULL;
             }
         }
         if (empty($lcMessages)) {
             //CRM-11993 - if a single-lang site, use default
             $lcMessages = CRM_Utils_Array::value('lcMessages', $defaults);
//.........这里部分代码省略.........
开发者ID:riyadennis,项目名称:my_civicrm,代码行数:101,代码来源:ConfigSetting.php

示例5: retrieve

 /**
  * Function to retrieve the settings values from db
  *
  * @return array $defaults  
  * @static
  */
 static function retrieve(&$defaults)
 {
     require_once "CRM/Core/DAO/Domain.php";
     $domain = new CRM_Core_DAO_Domain();
     $domain->selectAdd();
     if (CRM_Utils_Array::value('q', $_GET) == 'civicrm/upgrade') {
         $domain->selectAdd('config_backend');
     } else {
         $domain->selectAdd('config_backend, locales, locale_custom_strings');
     }
     $domain->id = CRM_Core_Config::domainID();
     $domain->find(true);
     if ($domain->config_backend) {
         $defaults = unserialize($domain->config_backend);
         if ($defaults === false || !is_array($defaults)) {
             $defaults = array();
             return;
         }
         $skipVars = array('dsn', 'templateCompileDir', 'userFrameworkDSN', 'userFrameworkBaseURL', 'userFrameworkClass', 'userHookClass', 'userPermissionClass', 'userFrameworkURLVar', 'newBaseURL', 'newBaseDir', 'newSiteName', 'configAndLogDir', 'qfKey', 'gettextResourceDir', 'cleanURL', 'locale_custom_strings', 'localeCustomStrings');
         foreach ($skipVars as $skip) {
             if (array_key_exists($skip, $defaults)) {
                 unset($defaults[$skip]);
             }
         }
         // since language field won't be present before upgrade.
         if (CRM_Utils_Array::value('q', $_GET) == 'civicrm/upgrade') {
             return;
         }
         // check if there are any locale strings
         if ($domain->locale_custom_strings) {
             $defaults['localeCustomStrings'] = unserialize($domain->locale_custom_strings);
         } else {
             $defaults['localeCustomStrings'] = null;
         }
         // are we in a multi-language setup?
         $multiLang = $domain->locales ? true : false;
         // set the current language
         $lcMessages = null;
         $session = CRM_Core_Session::singleton();
         // for logging purposes, pass the userID to the db
         if ($session->get('userID')) {
             CRM_Core_DAO::executeQuery('SET @civicrm_user_id = %1', array(1 => array($session->get('userID'), 'Integer')));
         }
         // on multi-lang sites based on request and civicrm_uf_match
         if ($multiLang) {
             require_once 'CRM/Utils/Request.php';
             $lcMessagesRequest = CRM_Utils_Request::retrieve('lcMessages', 'String', $this);
             $languageLimit = array();
             if (array_key_exists('languageLimit', $defaults) && is_array($defaults['languageLimit'])) {
                 $languageLimit = $defaults['languageLimit'];
             }
             if (in_array($lcMessagesRequest, array_keys($languageLimit))) {
                 $lcMessages = $lcMessagesRequest;
             } else {
                 $lcMessagesRequest = null;
             }
             if (!$lcMessagesRequest) {
                 $lcMessagesSession = $session->get('lcMessages');
                 if (in_array($lcMessagesSession, array_keys($languageLimit))) {
                     $lcMessages = $lcMessagesSession;
                 } else {
                     $lcMessagesSession = null;
                 }
             }
             if ($lcMessagesRequest) {
                 require_once 'CRM/Core/DAO/UFMatch.php';
                 $ufm = new CRM_Core_DAO_UFMatch();
                 $ufm->contact_id = $session->get('userID');
                 if ($ufm->find(true)) {
                     $ufm->language = $lcMessages;
                     $ufm->save();
                 }
                 $session->set('lcMessages', $lcMessages);
             }
             if (!$lcMessages and $session->get('userID')) {
                 require_once 'CRM/Core/DAO/UFMatch.php';
                 $ufm = new CRM_Core_DAO_UFMatch();
                 $ufm->contact_id = $session->get('userID');
                 if ($ufm->find(true) && in_array($ufm->language, array_keys($languageLimit))) {
                     $lcMessages = $ufm->language;
                 }
                 $session->set('lcMessages', $lcMessages);
             }
         }
         global $dbLocale;
         // if unset and the install is so configured, try to inherit the language from the hosting CMS
         if ($lcMessages === null and CRM_Utils_Array::value('inheritLocale', $defaults)) {
             // FIXME: On multilanguage installs, CRM_Utils_System::getUFLocale() in many cases returns nothing if $dbLocale is not set
             $dbLocale = $multiLang ? "_{$defaults['lcMessages']}" : '';
             require_once 'CRM/Utils/System.php';
             $lcMessages = CRM_Utils_System::getUFLocale();
             require_once 'CRM/Core/BAO/CustomOption.php';
             if ($domain->locales and !in_array($lcMessages, explode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, $domain->locales))) {
                 $lcMessages = null;
//.........这里部分代码省略.........
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:Setting.php


注:本文中的CRM_Utils_System::getUFLocale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。