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


PHP CRM_Core_I18n::getLocale方法代码示例

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


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

示例1: smarty_function_crmNavigationMenu

/**
 * Output navigation script tag
 *
 * @param array $params
 *   - is_default: bool, true if this is normal/default instance of the menu (which may be subject to CIVICRM_DISABLE_DEFAULT_MENU)
 * @param CRM_Core_Smarty $smarty
 *   The Smarty object.
 *
 * @return string
 *   HTML
 */
function smarty_function_crmNavigationMenu($params, &$smarty)
{
    $config = CRM_Core_Config::singleton();
    //check if logged in user has access CiviCRM permission and build menu
    $buildNavigation = !CRM_Core_Config::isUpgradeMode() && CRM_Core_Permission::check('access CiviCRM');
    if (defined('CIVICRM_DISABLE_DEFAULT_MENU') && CRM_Utils_Array::value('is_default', $params, FALSE)) {
        $buildNavigation = FALSE;
    }
    if ($config->userFrameworkFrontend) {
        $buildNavigation = FALSE;
    }
    if ($buildNavigation) {
        $session = CRM_Core_Session::singleton();
        $contactID = $session->get('userID');
        if ($contactID) {
            // These params force the browser to refresh the js file when switching user, domain, or language
            // We don't put them as a query string because some browsers will refuse to cache a page with a ? in the url
            // @see CRM_Admin_Page_AJAX::getNavigationMenu
            $lang = CRM_Core_I18n::getLocale();
            $domain = CRM_Core_Config::domainID();
            $key = CRM_Core_BAO_Navigation::getCacheKey($contactID);
            $src = CRM_Utils_System::url("civicrm/ajax/menujs/{$contactID}/{$lang}/{$domain}/{$key}");
            // CRM-15493 QFkey needed for quicksearch bar - must be unique on each page refresh so adding it directly to markup
            $qfKey = CRM_Core_Key::get('CRM_Contact_Controller_Search', TRUE);
            return '<script id="civicrm-navigation-menu" type="text/javascript" src="' . $src . '" data-qfkey=' . json_encode($qfKey) . '></script>';
        }
    }
    return '';
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:40,代码来源:function.crmNavigationMenu.php

示例2: buildQuickForm

 public function buildQuickForm()
 {
     $config = CRM_Core_Config::singleton();
     $tsLocale = CRM_Core_I18n::getLocale();
     $this->_locales = array_keys($config->languageLimit);
     // get the part of the database we want to edit and validate it
     $table = CRM_Utils_Request::retrieve('table', 'String', $this);
     $field = CRM_Utils_Request::retrieve('field', 'String', $this);
     $id = CRM_Utils_Request::retrieve('id', 'Int', $this);
     $this->_structure = CRM_Core_I18n_SchemaStructure::columns();
     if (!isset($this->_structure[$table][$field])) {
         CRM_Core_Error::fatal("{$table}.{$field} is not internationalized.");
     }
     $this->addElement('hidden', 'table', $table);
     $this->addElement('hidden', 'field', $field);
     $this->addElement('hidden', 'id', $id);
     $cols = array();
     foreach ($this->_locales as $locale) {
         $cols[] = "{$field}_{$locale} {$locale}";
     }
     $query = 'SELECT ' . implode(', ', $cols) . " FROM {$table} WHERE id = {$id}";
     $dao = new CRM_Core_DAO();
     $dao->query($query, FALSE);
     $dao->fetch();
     // get html type and attributes for this field
     $widgets = CRM_Core_I18n_SchemaStructure::widgets();
     $widget = $widgets[$table][$field];
     // attributes
     $attributes = array('class' => '');
     if (isset($widget['rows'])) {
         $attributes['rows'] = $widget['rows'];
     }
     if (isset($widget['cols'])) {
         $attributes['cols'] = $widget['cols'];
     }
     $required = !empty($widget['required']);
     if ($widget['type'] == 'RichTextEditor') {
         $widget['type'] = 'wysiwyg';
         $attributes['class'] .= ' collapsed';
     }
     $languages = CRM_Core_I18n::languages(TRUE);
     foreach ($this->_locales as $locale) {
         $attr = $attributes;
         $name = "{$field}_{$locale}";
         if ($locale == $tsLocale) {
             $attr['class'] .= ' default-lang';
         }
         $this->add($widget['type'], $name, $languages[$locale], $attr, $required);
         $this->_defaults[$name] = $dao->{$locale};
     }
     $this->addDefaultButtons(ts('Save'), 'next', NULL);
     CRM_Utils_System::setTitle(ts('Languages'));
     $this->assign('locales', $this->_locales);
     $this->assign('field', $field);
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:55,代码来源:Form.php

示例3: formatModuleData

 /**
  * Get or Set honor/on_behalf params for processing module_data or setting default values.
  *
  * @param array $params :
  * @param bool $setDefault : If yes then returns array to used for setting default value afterward
  * @param string $module : processing module_data for which module? e.g. soft_credit, on_behalf
  *
  * @return array|string
  */
 public static function formatModuleData($params, $setDefault = FALSE, $module)
 {
     $tsLocale = CRM_Core_I18n::getLocale();
     $config = CRM_Core_Config::singleton();
     $json = $jsonDecode = NULL;
     $domain = new CRM_Core_DAO_Domain();
     $domain->find(TRUE);
     $moduleDataFormat = array('soft_credit' => array(1 => 'soft_credit_types', 'multilingual' => array('honor_block_title', 'honor_block_text')), 'on_behalf' => array(1 => 'is_for_organization', 'multilingual' => array('for_organization')));
     //When we are fetching the honor params respecting both multi and mono lingual state
     //and setting it to default param of Contribution Page's Main and Setting form
     if ($setDefault) {
         $jsonDecode = json_decode($params);
         $jsonDecode = (array) $jsonDecode->{$module};
         if (!$domain->locales && !empty($jsonDecode['default'])) {
             //monolingual state
             $jsonDecode += (array) $jsonDecode['default'];
             unset($jsonDecode['default']);
         } elseif (!empty($jsonDecode[$tsLocale])) {
             //multilingual state
             foreach ($jsonDecode[$tsLocale] as $column => $value) {
                 $jsonDecode[$column] = $value;
             }
             unset($jsonDecode[$tsLocale]);
         }
         return $jsonDecode;
     }
     //check and handle multilingual honoree params
     if (!$domain->locales) {
         //if in singlelingual state simply return the array format
         $json = array($module => NULL);
         foreach ($moduleDataFormat[$module] as $key => $attribute) {
             if ($key === 'multilingual') {
                 $json[$module]['default'] = array();
                 foreach ($attribute as $attr) {
                     $json[$module]['default'][$attr] = $params[$attr];
                 }
             } else {
                 $json[$module][$attribute] = $params[$attribute];
             }
         }
         $json = json_encode($json);
     } else {
         //if in multilingual state then retrieve the module_data against this contribution and
         //merge with earlier module_data json data to current so not to lose earlier multilingual module_data information
         $json = array($module => NULL);
         foreach ($moduleDataFormat[$module] as $key => $attribute) {
             if ($key === 'multilingual') {
                 $json[$module][$config->lcMessages] = array();
                 foreach ($attribute as $attr) {
                     $json[$module][$config->lcMessages][$attr] = $params[$attr];
                 }
             } else {
                 $json[$module][$attribute] = $params[$attribute];
             }
         }
         $ufJoinDAO = new CRM_Core_DAO_UFJoin();
         $ufJoinDAO->module = $module;
         $ufJoinDAO->entity_id = $params['id'];
         $ufJoinDAO->find(TRUE);
         $jsonData = json_decode($ufJoinDAO->module_data);
         if ($jsonData) {
             $json[$module] = array_merge((array) $jsonData->{$module}, $json[$module]);
         }
         $json = json_encode($json);
     }
     return $json;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:76,代码来源:ContributionPage.php

示例4: array

 /**
  * @param int $countryID
  * @param string $field
  *
  * @return array
  */
 public static function &stateProvinceForCountry($countryID, $field = 'name')
 {
     static $_cache = NULL;
     $cacheKey = "{$countryID}_{$field}";
     if (!$_cache) {
         $_cache = array();
     }
     if (!empty($_cache[$cacheKey])) {
         return $_cache[$cacheKey];
     }
     $query = "\nSELECT civicrm_state_province.{$field} name, civicrm_state_province.id id\n  FROM civicrm_state_province\nWHERE country_id = %1\nORDER BY name";
     $params = array(1 => array($countryID, 'Integer'));
     $dao = CRM_Core_DAO::executeQuery($query, $params);
     $result = array();
     while ($dao->fetch()) {
         $result[$dao->id] = $dao->name;
     }
     // localise the stateProvince names if in an non-en_US locale
     $config = CRM_Core_Config::singleton();
     $tsLocale = CRM_Core_I18n::getLocale();
     if ($tsLocale != '' and $tsLocale != 'en_US') {
         $i18n = CRM_Core_I18n::singleton();
         $i18n->localizeArray($result, array('context' => 'province'));
         $result = CRM_Utils_Array::asort($result);
     }
     $_cache[$cacheKey] = $result;
     CRM_Utils_Hook::buildStateProvinceForCountry($countryID, $result);
     return $result;
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:35,代码来源:PseudoConstant.php

示例5: setCommunicationLanguage

 /**
  * @param $communication_language
  * @param $preferred_language
  */
 public static function setCommunicationLanguage($communication_language, $preferred_language)
 {
     $currentLocale = CRM_Core_I18n::getLocale();
     $language = $currentLocale;
     // prepare the language for the email
     if ($communication_language == CRM_Core_I18n::AUTO) {
         if (!empty($preferred_language)) {
             $language = $preferred_language;
         }
     } else {
         $language = $communication_language;
     }
     // language not in the existing language, use default
     $languages = CRM_Core_I18n::languages(TRUE);
     if (!array_key_exists($language, $languages)) {
         $language = $currentLocale;
     }
     // change the language
     $i18n = CRM_Core_I18n::singleton();
     $i18n->setLocale($language);
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:25,代码来源:ActionSchedule.php

示例6: getContactDefaultLanguage

 /**
  * Get the default language for contacts where no language is provided.
  *
  * Note that NULL is a valid option so be careful with checking for empty etc.
  *
  * NULL would mean 'we don't know & we don't want to hazard a guess'.
  *
  * @return string
  */
 public static function getContactDefaultLanguage()
 {
     $language = Civi::settings()->get('contact_default_language');
     if ($language == 'undefined') {
         return NULL;
     }
     if (empty($language) || $language === '*default*') {
         $language = civicrm_api3('setting', 'getvalue', array('name' => 'lcMessages', 'group' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME));
     } elseif ($language == 'current_site_language') {
         return CRM_Core_I18n::getLocale();
     }
     return $language;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:22,代码来源:I18n.php

示例7: coreResourceList

 /**
  * List of core resources we add to every CiviCRM page.
  *
  * Note: non-compressed versions of .min files will be used in debug mode
  *
  * @param string $region
  * @return array
  */
 public function coreResourceList($region)
 {
     $config = CRM_Core_Config::singleton();
     // Scripts needed by everyone, everywhere
     // FIXME: This is too long; list needs finer-grained segmentation
     $items = array("bower_components/jquery/dist/jquery.min.js", "bower_components/jquery-ui/jquery-ui.min.js", "bower_components/jquery-ui/themes/smoothness/jquery-ui.min.css", "bower_components/lodash-compat/lodash.min.js", "packages/jquery/plugins/jquery.mousewheel.min.js", "bower_components/select2/select2.min.js", "bower_components/select2/select2.min.css", "bower_components/font-awesome/css/font-awesome.min.css", "packages/jquery/plugins/jquery.tableHeader.js", "packages/jquery/plugins/jquery.form.min.js", "packages/jquery/plugins/jquery.timeentry.min.js", "packages/jquery/plugins/jquery.blockUI.min.js", "bower_components/datatables/media/js/jquery.dataTables.min.js", "bower_components/datatables/media/css/jquery.dataTables.min.css", "bower_components/jquery-validation/dist/jquery.validate.min.js", "packages/jquery/plugins/jquery.ui.datepicker.validation.min.js", "js/Common.js", "js/crm.ajax.js", "js/wysiwyg/crm.wysiwyg.js");
     // add wysiwyg editor
     $editor = Civi::settings()->get('editor_id');
     if ($editor == "CKEditor") {
         $items[] = "js/wysiwyg/crm.ckeditor.js";
         $ckConfig = CRM_Admin_Page_CKEditorConfig::getConfigUrl();
         if ($ckConfig) {
             $items[] = array('config' => array('CKEditorCustomConfig' => $ckConfig));
         }
     }
     // These scripts are only needed by back-office users
     if (CRM_Core_Permission::check('access CiviCRM')) {
         $items[] = "packages/jquery/plugins/jquery.menu.min.js";
         $items[] = "css/civicrmNavigation.css";
         $items[] = "packages/jquery/plugins/jquery.jeditable.min.js";
         $items[] = "packages/jquery/plugins/jquery.notify.min.js";
         $items[] = "js/jquery/jquery.crmeditable.js";
     }
     // JS for multilingual installations
     if (!empty($config->languageLimit) && count($config->languageLimit) > 1 && CRM_Core_Permission::check('translate CiviCRM')) {
         $items[] = "js/crm.multilingual.js";
     }
     // Enable administrators to edit option lists in a dialog
     if (CRM_Core_Permission::check('administer CiviCRM') && $this->ajaxPopupsEnabled) {
         $items[] = "js/crm.optionEdit.js";
     }
     $tsLocale = CRM_Core_I18n::getLocale();
     // Add localized jQuery UI files
     if ($tsLocale && $tsLocale != 'en_US') {
         // Search for i18n file in order of specificity (try fr-CA, then fr)
         list($lang) = explode('_', $tsLocale);
         $path = "bower_components/jquery-ui/ui/i18n";
         foreach (array(str_replace('_', '-', $tsLocale), $lang) as $language) {
             $localizationFile = "{$path}/datepicker-{$language}.js";
             if ($this->getPath('civicrm', $localizationFile)) {
                 $items[] = $localizationFile;
                 break;
             }
         }
     }
     // Allow hooks to modify this list
     CRM_Utils_Hook::coreResourceList($items, $region);
     return $items;
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:57,代码来源:Resources.php

示例8: getLocale

 private function getLocale()
 {
     $tsLocale = CRM_Core_I18n::getLocale();
     if (!empty($tsLocale)) {
         return $tsLocale;
     }
     $config = CRM_Core_Config::singleton();
     if (!empty($config->lcMessages)) {
         return $config->lcMessages;
     }
     return 'en_US';
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:12,代码来源:Smarty.php


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