• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP CRM_Core_I18n类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了CRM_Core_I18n类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()
 {
     $parent = $this->controller->getParent();
     $nameTextLabel = $parent->_sms ? ts('SMS Name') : ts('Mailing Name');
     $this->add('text', 'mailing_name', $nameTextLabel, CRM_Core_DAO::getAttribute('CRM_Mailing_DAO_Mailing', 'title'));
     CRM_Core_Form_Date::buildDateRange($this, 'mailing', 1, '_from', '_to', ts('From'), FALSE);
     $this->add('text', 'sort_name', ts('Created or Sent by'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($this);
     // CRM-15434 - Fix mailing search by status in non-English languages
     $statusVals = CRM_Core_SelectValues::getMailingJobStatus();
     foreach ($statusVals as $statusId => $statusName) {
         $this->addElement('checkbox', "mailing_status[{$statusId}]", NULL, $statusName);
     }
     $this->addElement('checkbox', 'status_unscheduled', NULL, ts('Draft / Unscheduled'));
     $this->addYesNo('is_archived', ts('Mailing is Archived'), TRUE);
     // Search by language, if multi-lingual
     $enabledLanguages = CRM_Core_I18n::languages(TRUE);
     if (count($enabledLanguages) > 1) {
         $this->addElement('select', 'language', ts('Language'), array('' => ts('- all languages -')) + $enabledLanguages, array('class' => 'crm-select2'));
     }
     if ($parent->_sms) {
         $this->addElement('hidden', 'sms', $parent->_sms);
     }
     $this->add('hidden', 'hidden_find_mailings', 1);
     $this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => TRUE)));
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:26,代码来源:Search.php


示例3: invoke

 /**
  * This is the main function that is called on every click action and based on the argument
  * respective functions are called
  *
  * @param $args array this array contains the arguments of the url 
  * 
  * @static
  * @access public
  */
 function invoke($args)
 {
     require_once 'CRM/Core/I18n.php';
     require_once 'CRM/Utils/Wrapper.php';
     require_once 'CRM/Core/Action.php';
     require_once 'CRM/Utils/Request.php';
     if ($args[0] !== 'civicrm') {
         return;
     }
     $config =& CRM_Core_Config::singleton();
     // also initialize the i18n framework
     $i18n =& CRM_Core_I18n::singleton();
     if ($config->userFramework == 'Mambo') {
         require_once 'CRM/Core/Mambo.php';
         CRM_Core_Mambo::sidebarLeft();
     }
     switch ($args[1]) {
         case 'contact':
             CRM_Core_Invoke::contact($args);
             break;
         case 'admin':
             CRM_Core_Invoke::admin($args);
             break;
         case 'history':
             CRM_Core_Invoke::history($args);
             break;
         case 'group':
             CRM_Core_Invoke::group($args);
             break;
         case 'import':
             CRM_Core_Invoke::import($args);
             break;
         case 'export':
             CRM_Core_Invoke::export($args);
             break;
         case 'activity':
             CRM_Core_Invoke::activity($args);
             break;
         case 'profile':
             CRM_Core_Invoke::profile($args);
             break;
         case 'server':
             CRM_Core_Invoke::server($args);
             break;
         case 'mailing':
             require_once 'CRM/Mailing/Invoke.php';
             CRM_Mailing_Invoke::main($args);
             break;
         case 'contribute':
             require_once 'CRM/Contribute/Invoke.php';
             CRM_Contribute_Invoke::main($args);
             break;
         default:
             CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/search/basic', 'reset=1'));
             break;
     }
     return;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:67,代码来源:Invoke.php


示例4: buildQuickForm

 public function buildQuickForm()
 {
     $config = CRM_Core_Config::singleton();
     global $tsLocale;
     $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:FundingWorks,项目名称:civicrm-core,代码行数:55,代码来源:Form.php


示例5: buildQuickForm

 function buildQuickForm()
 {
     $config = CRM_Core_Config::singleton();
     $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();
     // we want TEXTAREAs for long fields and INPUTs for short ones
     $this->_structure[$table][$field] == 'text' ? $type = 'textarea' : ($type = 'text');
     $languages = CRM_Core_I18n::languages(TRUE);
     foreach ($this->_locales as $locale) {
         $this->addElement($type, "{$field}_{$locale}", $languages[$locale], array('cols' => 60, 'rows' => 3));
         $this->_defaults["{$field}_{$locale}"] = $dao->{$locale};
     }
     $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE)));
     global $tsLocale;
     $this->assign('tsLocale', $tsLocale);
     $this->assign('locales', $this->_locales);
     $this->assign('field', $field);
     $this->assign('context', CRM_Utils_Request::retrieve('context', 'String', $this));
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:37,代码来源:Form.php


示例6: array

 /**
  * @param CRM_Core_DAO $dao
  * @param bool $flip
  * @param bool $grouping
  * @param bool $localize
  * @param string $valueColumnName
  *
  * @return array
  */
 public static function &valuesCommon($dao, $flip = FALSE, $grouping = FALSE, $localize = FALSE, $valueColumnName = 'label')
 {
     self::$_values = array();
     while ($dao->fetch()) {
         if ($flip) {
             if ($grouping) {
                 self::$_values[$dao->value] = $dao->grouping;
             } else {
                 self::$_values[$dao->{$valueColumnName}] = $dao->value;
             }
         } else {
             if ($grouping) {
                 self::$_values[$dao->{$valueColumnName}] = $dao->grouping;
             } else {
                 self::$_values[$dao->value] = $dao->{$valueColumnName};
             }
         }
     }
     if ($localize) {
         $i18n = CRM_Core_I18n::singleton();
         $i18n->localizeArray(self::$_values);
     }
     return self::$_values;
 }
开发者ID:kidaa30,项目名称:yes,代码行数:33,代码来源:OptionGroup.php


示例7: initialize

 private function initialize()
 {
     $config = CRM_Core_Config::singleton();
     if (isset($config->customTemplateDir) && $config->customTemplateDir) {
         $this->template_dir = array_merge(array($config->customTemplateDir), $config->templateDir);
     } else {
         $this->template_dir = $config->templateDir;
     }
     $this->compile_dir = CRM_Utils_File::addTrailingSlash(CRM_Utils_File::addTrailingSlash($config->templateCompileDir) . $this->getLocale());
     CRM_Utils_File::createDir($this->compile_dir);
     CRM_Utils_File::restrictAccess($this->compile_dir);
     // check and ensure it is writable
     // else we sometime suppress errors quietly and this results
     // in blank emails etc
     if (!is_writable($this->compile_dir)) {
         echo "CiviCRM does not have permission to write temp files in {$this->compile_dir}, Exiting";
         exit;
     }
     //Check for safe mode CRM-2207
     if (ini_get('safe_mode')) {
         $this->use_sub_dirs = FALSE;
     } else {
         $this->use_sub_dirs = TRUE;
     }
     $customPluginsDir = NULL;
     if (isset($config->customPHPPathDir)) {
         $customPluginsDir = $config->customPHPPathDir . DIRECTORY_SEPARATOR . 'CRM' . DIRECTORY_SEPARATOR . 'Core' . DIRECTORY_SEPARATOR . 'Smarty' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR;
         if (!file_exists($customPluginsDir)) {
             $customPluginsDir = NULL;
         }
     }
     $smartyDir = dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'packages' . DIRECTORY_SEPARATOR . 'Smarty' . DIRECTORY_SEPARATOR;
     $pluginsDir = __DIR__ . DIRECTORY_SEPARATOR . 'Smarty' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR;
     if ($customPluginsDir) {
         $this->plugins_dir = array($customPluginsDir, $smartyDir . 'plugins', $pluginsDir);
     } else {
         $this->plugins_dir = array($smartyDir . 'plugins', $pluginsDir);
     }
     // add the session and the config here
     $session = CRM_Core_Session::singleton();
     $this->assign_by_ref('config', $config);
     $this->assign_by_ref('session', $session);
     global $tsLocale;
     $this->assign('tsLocale', $tsLocale);
     // CRM-7163 hack: we don’t display langSwitch on upgrades anyway
     if (!CRM_Core_Config::isUpgradeMode()) {
         $this->assign('langSwitch', CRM_Core_I18n::languages(TRUE));
     }
     $this->register_function('crmURL', array('CRM_Utils_System', 'crmURL'));
     $this->load_filter('pre', 'resetExtScope');
     $this->assign('crmPermissions', new CRM_Core_Smarty_Permissions());
 }
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:52,代码来源:Smarty.php


示例8: strftime

 /**
  * Return full month names according to the locale.
  *
  * @return array
  *   1-based array with full month names
  *
  */
 public static function &getFullMonthNames()
 {
     static $fullMonthNames;
     if (!isset($fullMonthNames)) {
         // set LC_TIME and build the arrays from locale-provided names
         CRM_Core_I18n::setLcTime();
         for ($i = 1; $i <= 12; $i++) {
             $fullMonthNames[$i] = strftime('%B', mktime(0, 0, 0, $i, 10, 1970));
         }
     }
     return $fullMonthNames;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:19,代码来源:Date.php


示例9: getMenuName

 /**
  *  Get Menu name
  */
 function getMenuName(&$value, &$skipMenuItems)
 {
     // we need to localise the menu labels (CRM-5456) and don’t
     // want to use ts() as it would throw the ts-extractor off
     $i18n =& CRM_Core_I18n::singleton();
     $name = $i18n->crm_translate($value['attributes']['label']);
     $url = str_replace('&', '&amp;', $value['attributes']['url']);
     $permission = $value['attributes']['permission'];
     $operator = $value['attributes']['operator'];
     $parentID = $value['attributes']['parentID'];
     $navID = $value['attributes']['navID'];
     $active = $value['attributes']['active'];
     if (in_array($parentID, $skipMenuItems) || !$active) {
         $skipMenuItems[] = $navID;
         return false;
     }
     $makeLink = false;
     if (isset($url) && $url) {
         if (substr($url, 0, 4) === 'http') {
             $url = $url;
         } else {
             $url = CRM_Utils_System::url($url);
         }
         $makeLink = true;
     }
     if (isset($permission) && $permission) {
         $permissions = explode(',', $permission);
         $config =& CRM_Core_Config::singleton();
         $hasPermission = false;
         foreach ($permissions as $key) {
             $showItem = true;
             //hack to determine if it's a component related permission
             if ($key != 'access CiviCRM' && substr($key, 0, 6) === 'access') {
                 $componentName = trim(substr($key, 6));
                 if (!in_array($componentName, $config->enableComponents) || !CRM_Core_Permission::check($key)) {
                     $showItem = false;
                     if ($operator == 'AND') {
                         $skipMenuItems[] = $navID;
                         return $showItem;
                     }
                 } else {
                     $hasPermission = true;
                 }
             } else {
                 if (!CRM_Core_Permission::check($key)) {
                     $showItem = false;
                     if ($operator == 'AND') {
                         $skipMenuItems[] = $navID;
                         return $showItem;
                     }
                 } else {
                     $hasPermission = true;
                 }
             }
         }
         if (!$showItem && !$hasPermission) {
             $skipMenuItems[] = $navID;
             return false;
         }
     }
     if ($makeLink) {
         return $name = "<a href=\"{$url}\">{$name}</a>";
     }
     return $name;
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:68,代码来源:Navigation.php


示例10: array


//.........这里部分代码省略.........
                         continue;
                     }
                     $locationTypeName = str_replace(' ', '_', $locationTypeName);
                     if (in_array($fieldName, array('phone', 'im', 'email'))) {
                         if ($type) {
                             $names[] = "{$locationTypeName}-{$fieldName}-{$type}";
                         } else {
                             $names[] = "{$locationTypeName}-{$fieldName}";
                         }
                     } else {
                         $names[] = "{$locationTypeName}-{$fieldName}";
                     }
                 } else {
                     $names[] = "website-{$id}-{$fieldName}";
                 }
             } elseif ($field['name'] == 'id') {
                 $names[] = 'contact_id';
             } else {
                 $names[] = $field['name'];
             }
         }
     }
     $multipleSelectFields = array('preferred_communication_method' => 1);
     $multiRecordTableId = NULL;
     if ($this->_multiRecordTableName) {
         $multiRecordTableId = "{$this->_multiRecordTableName}_id";
     }
     // we need to determine of overlay profile should be shown
     $showProfileOverlay = CRM_Core_BAO_UFGroup::showOverlayProfile();
     while ($result->fetch()) {
         $this->_query->convertToPseudoNames($result);
         if (isset($result->country)) {
             // the query returns the untranslated country name
             $i18n = CRM_Core_I18n::singleton();
             $result->country = $i18n->translate($result->country);
         }
         $row = array();
         $empty = TRUE;
         $row[] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id, $showProfileOverlay);
         if ($result->sort_name) {
             $row[] = $result->sort_name;
             $empty = FALSE;
         } else {
             continue;
         }
         foreach ($names as $name) {
             if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name)) {
                 $row[] = CRM_Core_BAO_CustomField::getDisplayValue($result->{$name}, $cfID, $this->_options, $result->contact_id);
             } elseif (substr($name, -4) == '-url' && !empty($result->{$name})) {
                 $url = CRM_Utils_System::fixURL($result->{$name});
                 $typeId = substr($name, 0, -4) . "-website_type_id";
                 $typeName = CRM_Core_PseudoConstant::getLabel('CRM_Core_DAO_Website', 'website_type_id', $result->{$typeId});
                 if ($typeName) {
                     $row[] = "<a href=\"{$url}\">{$result->{$name}} ({$typeName})</a>";
                 } else {
                     $row[] = "<a href=\"{$url}\">{$result->{$name}}</a>";
                 }
             } elseif ($name == 'preferred_language') {
                 $row[] = CRM_Core_PseudoConstant::getLabel('CRM_Contact_DAO_Contact', 'preferred_language', $result->{$name});
             } elseif ($multipleSelectFields && array_key_exists($name, $multipleSelectFields)) {
                 $paramsNew = array($name => $result->{$name});
                 $name = array($name => array('newName' => $name, 'groupName' => $name));
                 CRM_Core_OptionGroup::lookupValues($paramsNew, $name, FALSE);
                 $row[] = $paramsNew[$key];
             } elseif (strpos($name, '-im')) {
                 if (!empty($result->{$name})) {
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:67,代码来源:Listings.php


示例11: get

 static function get($path)
 {
     // return null if menu rebuild
     $config = CRM_Core_Config::singleton();
     $params = array();
     $args = explode('/', $path);
     $elements = array();
     while (!empty($args)) {
         $string = implode('/', $args);
         $string = CRM_Core_DAO::escapeString($string);
         $elements[] = "'{$string}'";
         array_pop($args);
     }
     $queryString = implode(', ', $elements);
     $domainID = CRM_Core_Config::domainID();
     $domainWhereClause = " AND domain_id = {$domainID} ";
     if ($config->isUpgradeMode() && !CRM_Core_DAO::checkFieldExists('civicrm_menu', 'domain_id')) {
         //domain_id wouldn't be available for earlier version of
         //3.0 and therefore can't be used as part of query for
         //upgrade case
         $domainWhereClause = "";
     }
     $query = "\n(\n  SELECT *\n  FROM     civicrm_menu\n  WHERE    path in ( {$queryString} )\n           {$domainWhereClause}\n  ORDER BY length(path) DESC\n  LIMIT    1\n)\n";
     if ($path != 'navigation') {
         $query .= "\nUNION (\n  SELECT *\n  FROM   civicrm_menu\n  WHERE  path IN ( 'navigation' )\n         {$domainWhereClause}\n)\n";
     }
     $menu = new CRM_Core_DAO_Menu();
     $menu->query($query);
     self::$_menuCache = array();
     $menuPath = NULL;
     while ($menu->fetch()) {
         self::$_menuCache[$menu->path] = array();
         CRM_Core_DAO::storeValues($menu, self::$_menuCache[$menu->path]);
         foreach (self::$_serializedElements as $element) {
             self::$_menuCache[$menu->path][$element] = unserialize($menu->{$element});
             if (strpos($path, $menu->path) !== FALSE) {
                 $menuPath =& self::$_menuCache[$menu->path];
             }
         }
     }
     if (strstr($path, 'report/instance')) {
         $args = explode('/', $path);
         if (is_numeric(end($args))) {
             $menuPath['path'] .= '/' . end($args);
         }
     }
     // *FIXME* : hack for 2.1 -> 2.2 upgrades.
     if ($path == 'civicrm/upgrade') {
         $menuPath['page_callback'] = 'CRM_Upgrade_Page_Upgrade';
         $menuPath['access_arguments'][0][] = 'administer CiviCRM';
         $menuPath['access_callback'] = array('CRM_Core_Permission', 'checkMenu');
     }
     // *FIXME* : hack for 4.1 -> 4.2 upgrades.
     if (preg_match('/^civicrm\\/(upgrade\\/)?queue\\//', $path)) {
         CRM_Queue_Menu::alter($path, $menuPath);
     }
     // Part of upgrade framework but not run inside main upgrade because it deletes data
     // Once we have another example of a 'cleanup' we should generalize the clause below so it grabs string
     // which follows upgrade/ and checks for existence of a function in Cleanup class.
     if ($path == 'civicrm/upgrade/cleanup425') {
         $menuPath['page_callback'] = array('CRM_Upgrade_Page_Cleanup', 'cleanup425');
         $menuPath['access_arguments'][0][] = 'administer CiviCRM';
         $menuPath['access_callback'] = array('CRM_Core_Permission', 'checkMenu');
     }
     if (!empty($menuPath)) {
         $i18n = CRM_Core_I18n::singleton();
         $i18n->localizeTitles($menuPath);
     }
     return $menuPath;
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:70,代码来源:Menu.php


示例12: buildQuickForm

 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     $config = CRM_Core_Config::singleton();
     $i18n = CRM_Core_I18n::singleton();
     CRM_Utils_System::setTitle(ts('Settings - Localization'));
     $locales = CRM_Core_I18n::languages();
     $warningTitle = json_encode(ts("Warning"));
     $domain = new CRM_Core_DAO_Domain();
     $domain->find(TRUE);
     if ($domain->locales) {
         // for multi-lingual sites, populate default language drop-down with available languages
         $lcMessages = array();
         foreach ($locales as $loc => $lang) {
             if (substr_count($domain->locales, $loc)) {
                 $lcMessages[$loc] = $lang;
             }
         }
         $this->addElement('select', 'lcMessages', ts('Default Language'), $lcMessages);
         // add language limiter and language adder
         $this->addCheckBox('languageLimit', ts('Available Languages'), array_flip($lcMessages), NULL, NULL, NULL, NULL, ' &nbsp; ');
         $this->addElement('select', 'addLanguage', ts('Add Language'), array_merge(array('' => ts('- select -')), array_diff($locales, $lcMessages)));
         // add the ability to return to single language
         $warning = ts('This will make your CiviCRM installation a single-language one again. THIS WILL DELETE ALL DATA RELATED TO LANGUAGES OTHER THAN THE DEFAULT ONE SELECTED ABOVE (and only that language will be preserved).');
         $this->assign('warning', $warning);
         $warning = json_encode($warning);
         $this->addElement('checkbox', 'makeSinglelingual', ts('Return to Single Language'), NULL, array('onChange' => "if (this.checked) CRM.alert({$warning}, {$warningTitle})"));
     } else {
         // for single-lingual sites, populate default language drop-down with all languages
         $this->addElement('select', 'lcMessages', ts('Default Language'), $locales);
         $warning = ts('Enabling multiple languages changes the schema of your database, so make sure you know what you are doing when enabling this function; making a database backup is strongly recommended.');
         $this->assign('warning', $warning);
         $warning = json_encode($warning);
         $validTriggerPermission = CRM_Core_DAO::checkTriggerViewPermission(TRUE);
         if ($validTriggerPermission && !$config->logging) {
             $this->addElement('checkbox', 'makeMultilingual', ts('Enable Multiple Languages'), NULL, array('onChange' => "if (this.checked) CRM.alert({$warning}, {$warningTitle})"));
         }
     }
     $this->addElement('checkbox', 'inheritLocale', ts('Inherit CMS Language'));
     $this->addElement('text', 'monetaryThousandSeparator', ts('Thousands Separator'), array('size' => 2));
     $this->addElement('text', 'monetaryDecimalPoint', ts('Decimal Delimiter'), array('size' => 2));
     $this->addElement('text', 'moneyformat', ts('Monetary Amount Display'));
     $this->addElement('text', 'moneyvalueformat', ts('Monetary Value Display'));
     $country = array();
     CRM_Core_PseudoConstant::populate($country, 'CRM_Core_DAO_Country', TRUE, 'name', 'is_active');
     $i18n->localizeArray($country, array('context' => 'country'));
     asort($country);
     $includeCountry =& $this->addElement('advmultiselect', 'countryLimit', ts('Available Countries') . ' ', $country, array('size' => 5, 'style' => 'width:150px', 'class' => 'advmultiselect'));
     $includeCountry->setButtonAttributes('add', array('value' => ts('Add >>')));
     $includeCountry->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     $includeState =& $this->addElement('advmultiselect', 'provinceLimit', ts('Available States and Provinces') . ' ', $country, array('size' => 5, 'style' => 'width:150px', 'class' => 'advmultiselect'));
     $includeState->setButtonAttributes('add', array('value' => ts('Add >>')));
     $includeState->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     $this->addElement('select', 'defaultContactCountry', ts('Default Country'), array('' => ts('- select -')) + $country);
     $this->addChainSelect('defaultContactStateProvince', array('label' => ts('Default State/Province')));
     // we do this only to initialize currencySymbols, kinda hackish but works!
     $config->defaultCurrencySymbol();
     $symbol = $config->currencySymbols;
     foreach ($symbol as $key => $value) {
         $this->_currencySymbols[$key] = "{$key}";
         if ($value) {
             $this->_currencySymbols[$key] .= " ({$value})";
         }
     }
     $this->addElement('select', 'defaultCurrency', ts('Default Currency'), $this->_currencySymbols);
     $includeCurrency =& $this->addElement('advmultiselect', 'currencyLimit', ts('Available Currencies') . ' ', $this->_currencySymbols, array('size' => 5, 'style' => 'width:150px', 'class' => 'advmultiselect'));
     $includeCurrency->setButtonAttributes('add', array('value' => ts('Add >>')));
     $includeCurrency->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     $this->addElement('text', 'legacyEncoding', ts('Legacy Encoding'));
     $this->addElement('text', 'customTranslateFunction', ts('Custom Translate Function'));
     $this->addElement('text', 'fieldSeparator', ts('Import / Export Field Separator'), array('size' => 2));
     $this->addFormRule(array('CRM_Admin_Form_Setting_Localization', 'formRule'));
     parent::buildQuickForm();
 }
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:78,代码来源:Localization.php


示例13: findLocales

 /**
  * @return array
  */
 public function findLocales()
 {
     require_once 'CRM/Core/Config.php';
     $config = CRM_Core_Config::singleton(FALSE);
     $locales = array();
     $localeDir = CRM_Core_I18n::getResourceDir();
     if (file_exists($localeDir)) {
         $locales = preg_grep('/^[a-z][a-z]_[A-Z][A-Z]$/', scandir($localeDir));
     }
     $localesMask = getenv('CIVICRM_LOCALES');
     if (!empty($localesMask)) {
         $mask = explode(',', $localesMask);
         $locales = array_intersect($locales, $mask);
     }
     if (!in_array('en_US', $locales)) {
         array_unshift($locales, 'en_US');
     }
     return $locales;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:22,代码来源:Schema.php


示例14: foreach

 /**
  * Create contact.
  *
  * takes an associative array and creates a contact object and all the associated
  * derived objects (i.e. individual, location, email, phone etc)
  *
  * This function is invoked from within the web form layer and also from the api layer
  *
  * @param array $params
  *   (reference ) an assoc array of name/value pairs.
  * @param bool $fixAddress
  *   If we need to fix address.
  * @param bool $invokeHooks
  *   If we need to invoke hooks.
  *
  * @param bool $skipDelete
  *   Unclear parameter, passed to website create
  *
  * @todo explain this parameter
  *
  * @throws Exception
  * @return CRM_Contact_BAO_Contact|CRM_Core_Error
  *   Created or updated contribution object. We are deprecating returning an error in
  *   favour of exceptions
  */
 public static function &create(&$params, $fixAddress = TRUE, $invokeHooks = TRUE, $skipDelete = FALSE)
 {
     $contact = NULL;
     if (empty($params['contact_type']) && empty($params['contact_id'])) {
         return $contact;
     }
     $isEdit = TRUE;
     if ($invokeHooks) {
         if (!empty($params['contact_id'])) {
             CRM_Utils_Hook::pre('edit', $params['contact_type'], $params['contact_id'], $params);
         } else {
             CRM_Utils_Hook::pre('create', $params['contact_type'], NULL, $params);
             $isEdit = FALSE;
         }
     }
     $config = CRM_Core_Config::singleton();
     // CRM-6942: set preferred language to the current language if it’s unset (and we’re creating a contact).
     if (empty($params['contact_id'])) {
         // A case could be made for checking isset rather than empty but this is more consistent with previous behaviour.
         if (empty($params['preferred_language']) && ($language = CRM_Core_I18n::getContactDefaultLanguage()) != FALSE) {
             $params['preferred_language'] = $language;
         }
         // CRM-9739: set greeting & addressee if unset and we’re creating a contact.
         foreach (self::$_greetingTypes as $greeting) {
             if (empty($params[$greeting . '_id'])) {
                 if ($defaultGreetingTypeId = CRM_Contact_BAO_Contact_Utils::defaultGreeting($params['contact_type'], $greeting)) {
                     $params[$greeting . '_id'] = $defaultGreetingTypeId;
                 }
             }
         }
     }
     $transaction = new CRM_Core_Transaction();
     $contact = self::add($params);
     if (!$contact) {
         // Not dying here is stupid, since we get into weird situation and into a bug that
         // is impossible to figure out for the user or for us
         // CRM-7925
         CRM_Core_Error::fatal();
     }
     $params['contact_id'] = $contact->id;
     if (Civi::settings()->get('is_enabled')) {
         // Enabling multisite causes the contact to be added to the domain group.
         $domainGroupID = CRM_Core_BAO_Domain::getGroupId();
         if (!empty($domainGroupID)) {
             if (!empty($params['group']) && is_array($params['group'])) {
                 $params['group'][$domainGroupID] = 1;
             } else {
                 $params['group'] = array($domainGroupID => 1);
             }
         }
     }
     if (array_key_exists('group', $params)) {
         $contactIds = array($params['contact_id']);
         foreach ($params['group'] as $groupId => $flag) {
             if ($flag == 1) {
                 CRM_Contact_BAO_GroupContact::addContactsToGroup($contactIds, $groupId);
             } elseif ($flag == -1) {
                 CRM_Contact_BAO_GroupContact::removeContactsFromGroup($contactIds, $groupId);
             }
         }
     }
     // Add location Block data.
     $blocks = CRM_Core_BAO_Location::create($params, $fixAddress);
     foreach ($blocks as $name => $value) {
         $contact->{$name} = $value;
     }
     if (!empty($params['updateBlankLocInfo'])) {
         $skipDelete = TRUE;
     }
     //add website
     CRM_Core_BAO_Website::create($params['website'], $contact->id, $skipDelete);
     //get userID from session
     $session = CRM_Core_Session::singleton();
     $userID = $session->get('userID');
     // add notes
//.........这里部分代码省略.........
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:101,代码来源:Contact.php


示例15: array

 public static function &stateProvinceForCountry($countryID)
 {
     $query = "\nSELECT civicrm_state_province.name 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();
     global $tsLocale;
     if ($tsLocale != '' and $tsLocale != 'en_US') {
         $i18n =& CRM_Core_I18n::singleton();
         $i18n->localizeArray($result);
         asort($result);
     }
     return $result;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:19,代码来源:PseudoConstant.php


示例16: languages

 /**
  * Return languages available in this instance of CiviCRM.
  *
  * @param bool $justEnabled
  *   whether to return all languages or just the enabled ones.
  *
  * @return array
  *   Array of code/language name mappings
  */
 public static function languages($justEnabled = FALSE)
 {
     static $all = NULL;
     static $enabled = NULL;
     if (!$all) {
         $all = CRM_Contact_BAO_Contact::buildOptions('preferred_language');
         // check which ones are available; add them to $all if not there already
         $codes = array();
         if (is_dir(CRM_Core_I18n::getResourceDir()) && ($dir = opendir(CRM_Core_I18n::getResourceDir()))) {
             while ($filename = readdir($dir)) {
                 if (preg_match('/^[a-z][a-z]_[A-Z][A-Z]$/', $filename)) {
                     $codes[] = $filename;
                     if (!isset($all[$filename])) {
                         $all[$filename] = $filename;
                     }
                 }
             }
             closedir($dir);
         }
         // drop the unavailable languages (except en_US)
         foreach (array_keys($all) as $code) {
             if ($code == 'en_US') {
                 continue;
             }
             if (!in_array($code, $codes)) {
                 unset($all[$code]);
             }
         }
     }
     if ($enabled === NULL) {
         $config = CRM_Core_Config::singleton();
         $enabled = array();
         if (isset($config->languageLimit) and $config->languageLimit) {
             foreach ($all as $code => $name) {
                 if (in_array($code, array_keys($config->languageLimit))) {
                     $enabled[$code] = $name;
                 }
             }
         }
     }
     return $justEnabled ? $enabled : $all;
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:51,代码来源:I18n.php


示例17: 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();
     global $tsLocale;
     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:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:29,代码来源:PseudoConstant.php


示例18: ts

/**
 * Short-named function for string translation, defined in global scope so it's available everywhere.
 * @param  $text   string  string for translating
 * @param  $params array   an array of additional parameters
 * @return         string  the translated string
 */
function ts($text, $params = array())
{
    static $config = null;
    static $locale = null;
    static $i18n = null;
    static $function = null;
    if ($text == '') {
        return '';
    }
    if (!$config) {
        $config = CRM_Core_Config::singleton();
    }
    global $tsLocale;
    if (!$i18n or $locale != $tsLocale) {
        $i18n =& CRM_Core_I18n::singleton();
        $locale = $tsLocale;
        if (isset($config->customTranslateFunction) and function_exists($config->customTranslateFunction)) {
            $function = $config->customTranslateFunction;
        }
    }
    if ($function) {
        return $function($text, $params);
    } else {
        return $i18n->crm_translate($text, $params);
    }
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:32,代码来源:I18n.php


示例19: array

<

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP CRM_Core_Key类代码示例发布时间:2022-05-20
下一篇:
PHP CRM_Core_Form_Tag类代码示例发布时间:2022-05-20
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap