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


PHP CRM_Core_I18n::singleton方法代码示例

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


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

示例1: 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

示例2: 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

示例3: init

 /**
  * Perform general setup
  *
  * @param array $args list of path parts
  * @void
  */
 public static function init($args)
 {
     // first fire up IDS and check for bad stuff
     $config = CRM_Core_Config::singleton();
     if (!CRM_Core_Permission::check('skip IDS check')) {
         $ids = new CRM_Core_IDS();
         $ids->check($args);
     }
     // also initialize the i18n framework
     require_once 'CRM/Core/I18n.php';
     $i18n = CRM_Core_I18n::singleton();
 }
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:18,代码来源:Invoke.php

示例4: isset

$uf = isset($installTypeToUF[$installType]) ? $installTypeToUF[$installType] : 'Drupal';
define('CIVICRM_UF', $uf);
global $tsLocale;
$tsLocale = 'en_US';
$seedLanguage = 'en_US';
// CRM-16801 This validates that seedLanguage is valid by looking in $langs.
// NB: the variable is initial a $_REQUEST for the initial page reload,
// then becomes a $_POST when the installation form is submitted.
if (isset($_REQUEST['seedLanguage']) and isset($langs[$_REQUEST['seedLanguage']])) {
    $seedLanguage = $_REQUEST['seedLanguage'];
    $tsLocale = $_REQUEST['seedLanguage'];
}
$config = CRM_Core_Config::singleton(FALSE);
$GLOBALS['civicrm_default_error_scope'] = NULL;
// The translation files are in the parent directory (l10n)
$i18n = CRM_Core_I18n::singleton();
// Support for Arabic, Hebrew, Farsi, etc.
// Used in the template.html
$short_lang_code = CRM_Core_I18n_PseudoConstant::shortForLong($tsLocale);
$text_direction = CRM_Core_I18n::isLanguageRTL($tsLocale) ? 'rtl' : 'ltr';
global $cmsPath;
if ($installType == 'drupal') {
    //CRM-6840 -don't force to install in sites/all/modules/
    $object = new CRM_Utils_System_Drupal();
    $cmsPath = $object->cmsRootPath();
    $siteDir = getSiteDir($cmsPath, $_SERVER['SCRIPT_FILENAME']);
    $alreadyInstalled = file_exists($cmsPath . CIVICRM_DIRECTORY_SEPARATOR . 'sites' . CIVICRM_DIRECTORY_SEPARATOR . $siteDir . CIVICRM_DIRECTORY_SEPARATOR . 'civicrm.settings.php');
} elseif ($installType == 'wordpress') {
    $cmsPath = WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'civicrm';
    $upload_dir = wp_upload_dir();
    $files_dirname = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'civicrm';
开发者ID:andrew-cormick-dockery,项目名称:civicrm-core,代码行数:31,代码来源:index.php

示例5: 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('&', '&', $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

示例6: 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

示例7: getMenuName

 /**
  * Get Menu name
  *
  * @param $value
  * @param $skipMenuItems
  * @return bool|string
  */
 static 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'], array('context' => 'menu'));
     $url = $value['attributes']['url'];
     $permission = $value['attributes']['permission'];
     $operator = $value['attributes']['operator'];
     $parentID = $value['attributes']['parentID'];
     $navID = $value['attributes']['navID'];
     $active = $value['attributes']['active'];
     $menuName = $value['attributes']['name'];
     $target = CRM_Utils_Array::value('target', $value['attributes']);
     if (in_array($parentID, $skipMenuItems) || !$active) {
         $skipMenuItems[] = $navID;
         return FALSE;
     }
     //we need to check core view/edit or supported acls.
     if (in_array($menuName, array('Search...', 'Contacts'))) {
         if (!CRM_Core_Permission::giveMeAllACLs()) {
             $skipMenuItems[] = $navID;
             return FALSE;
         }
     }
     $config = CRM_Core_Config::singleton();
     $makeLink = FALSE;
     if (isset($url) && $url) {
         if (substr($url, 0, 4) === 'http') {
             $url = $url;
         } else {
             //CRM-7656 --make sure to separate out url path from url params,
             //as we'r going to validate url path across cross-site scripting.
             $urlParam = CRM_Utils_System::explode('&', str_replace('?', '&', $url), 2);
             $url = CRM_Utils_System::url($urlParam[0], $urlParam[1], FALSE, NULL, TRUE);
         }
         $makeLink = TRUE;
     }
     static $allComponents;
     if (!$allComponents) {
         $allComponents = CRM_Core_Component::getNames();
     }
     if (isset($permission) && $permission) {
         $permissions = explode(',', $permission);
         $hasPermission = FALSE;
         foreach ($permissions as $key) {
             $key = trim($key);
             $showItem = TRUE;
             //get the component name from permission.
             $componentName = CRM_Core_Permission::getComponentName($key);
             if ($componentName) {
                 if (!in_array($componentName, $config->enableComponents) || !CRM_Core_Permission::check($key)) {
                     $showItem = FALSE;
                     if ($operator == 'AND') {
                         $skipMenuItems[] = $navID;
                         return $showItem;
                     }
                 } else {
                     $hasPermission = TRUE;
                 }
             } elseif (!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) {
         if ($target) {
             $name = "<a href=\"{$url}\" target=\"{$target}\">{$name}</a>";
         } else {
             $name = "<a href=\"{$url}\">{$name}</a>";
         }
     }
     return $name;
 }
开发者ID:hguru,项目名称:224Civi,代码行数:91,代码来源:Navigation.php

示例8: 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 ($path == 'civicrm/upgrade' && !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";
     }
     require_once "CRM/Core/DAO/Menu.php";
     $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];
             }
         }
     }
     // *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');
     }
     $i18n =& CRM_Core_I18n::singleton();
     $i18n->localizeTitles($menuPath);
     return $menuPath;
 }
开发者ID:bhirsch,项目名称:civicrm,代码行数:51,代码来源:Menu.php

示例9: buildQuickForm

 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 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();
     $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('WARNING: 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);
         $this->addElement('checkbox', 'makeSinglelingual', ts('Return to Single Language'), null, array('onChange' => "if (this.checked) alert('{$warning}')"));
     } else {
         // for single-lingual sites, populate default language drop-down with all languages
         $this->addElement('select', 'lcMessages', ts('Default Language'), $locales);
         $warning = ts('WARNING: As of CiviCRM 3.0, this is still an experimental functionality. Enabling multiple languages irreversibly 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);
         // test for create view and trigger permissions and if allowed, add the option to go multilingual
         CRM_Core_Error::ignoreException();
         $dao = new CRM_Core_DAO();
         $dao->query('CREATE OR REPLACE VIEW civicrm_domain_view AS SELECT * FROM civicrm_domain');
         $dao->query('CREATE TRIGGER civicrm_domain_trigger BEFORE INSERT ON civicrm_domain FOR EACH ROW BEGIN END');
         $dao->query('DROP TRIGGER IF EXISTS civicrm_domain_trigger');
         $dao->query('DROP VIEW IF EXISTS civicrm_domain_view');
         CRM_Core_Error::setCallback();
         if (!$dao->_lastError) {
             $this->addElement('checkbox', 'makeMultilingual', ts('Enable Multiple Languages'), null, array('onChange' => "if (this.checked) alert('{$warning}')"));
         }
     }
     $this->addElement('select', 'lcMonetary', ts('Monetary Locale'), $locales);
     $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);
     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);
     // we do this only to initialize currencySymbols, kinda hackish but works!
     $config->defaultCurrencySymbol();
     $symbol = $config->currencySymbols;
     foreach ($symbol as $key => $value) {
         $currencySymbols[$key] = "{$key}";
         if ($value) {
             $currencySymbols[$key] .= " ({$value})";
         }
     }
     $this->addElement('select', 'defaultCurrency', ts('Default Currency'), $currencySymbols);
     $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:ksecor,项目名称:civicrm,代码行数:77,代码来源:Localization.php

示例10: 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

示例11: _invoke

 protected static function _invoke($args)
 {
     if ($args[0] !== 'civicrm') {
         return;
     }
     require_once 'CRM/Core/I18n.php';
     $config = CRM_Core_Config::singleton();
     if (isset($args[1]) and $args[1] == 'menu' and isset($args[2]) and $args[2] == 'rebuild') {
         // ensure that the user has a good privilege level
         if (CRM_Core_Permission::check('administer CiviCRM')) {
             self::rebuildMenuAndCaches();
             CRM_Core_Session::setStatus(ts('Menu has been rebuilt'));
             return CRM_Utils_System::redirect();
         } else {
             CRM_Core_Error::fatal('You do not have permission to execute this url');
         }
     }
     // first fire up IDS and check for bad stuff
     if ($config->useIDS) {
         $ids = new CRM_Core_IDS();
         $ids->check($args);
     }
     // also initialize the i18n framework
     $i18n = CRM_Core_I18n::singleton();
     if ($config->userFramework == 'Standalone') {
         $session = CRM_Core_Session::singleton();
         if ($session->get('new_install') !== TRUE) {
             CRM_Core_Standalone::sidebarLeft();
         } elseif ($args[1] == 'standalone' && $args[2] == 'register') {
             CRM_Core_Menu::store();
         }
     }
     // get the menu items
     $path = implode('/', $args);
     $item = CRM_Core_Menu::get($path);
     // we should try to compute menus, if item is empty and stay on the same page,
     // rather than compute and redirect to dashboard.
     if (!$item) {
         CRM_Core_Menu::store(FALSE);
         $item = CRM_Core_Menu::get($path);
     }
     if ($config->userFramework == 'Joomla' && $item) {
         $config->userFrameworkURLVar = 'task';
         // joomla 1.5RC1 seems to push this in the POST variable, which messes
         // QF and checkboxes
         unset($_POST['option']);
         CRM_Core_Joomla::sidebarLeft();
     }
     // set active Component
     $template = CRM_Core_Smarty::singleton();
     $template->assign('activeComponent', 'CiviCRM');
     $template->assign('formTpl', 'default');
     if ($item) {
         // CRM-7656 - make sure we send a clean sanitized path to create printer friendly url
         $printerFriendly = CRM_Utils_System::makeURL('snippet', FALSE, FALSE, CRM_Utils_Array::value('path', $item)) . '2';
         $template->assign('printerFriendly', $printerFriendly);
         if (!array_key_exists('page_callback', $item)) {
             CRM_Core_Error::debug('Bad item', $item);
             CRM_Core_Error::fatal(ts('Bad menu record in database'));
         }
         // check that we are permissioned to access this page
         if (!CRM_Core_Permission::checkMenuItem($item)) {
             CRM_Utils_System::permissionDenied();
             return;
         }
         // check if ssl is set
         if (CRM_Utils_Array::value('is_ssl', $item)) {
             CRM_Utils_System::redirectToSSL();
         }
         if (isset($item['title'])) {
             CRM_Utils_System::setTitle($item['title']);
         }
         if (isset($item['breadcrumb']) && !isset($item['is_public'])) {
             CRM_Utils_System::appendBreadCrumb($item['breadcrumb']);
         }
         $pageArgs = NULL;
         if (CRM_Utils_Array::value('page_arguments', $item)) {
             $pageArgs = CRM_Core_Menu::getArrayForPathArgs($item['page_arguments']);
         }
         $template = CRM_Core_Smarty::singleton();
         if (isset($item['is_public']) && $item['is_public']) {
             $template->assign('urlIsPublic', TRUE);
         } else {
             $template->assign('urlIsPublic', FALSE);
         }
         if (isset($item['return_url'])) {
             $session = CRM_Core_Session::singleton();
             $args = CRM_Utils_Array::value('return_url_args', $item, 'reset=1');
             $session->pushUserContext(CRM_Utils_System::url($item['return_url'], $args));
         }
         // CRM_Core_Error::debug( $item ); exit( );
         $result = NULL;
         if (is_array($item['page_callback'])) {
             $newArgs = explode('/', $_GET[$config->userFrameworkURLVar]);
             require_once str_replace('_', DIRECTORY_SEPARATOR, $item['page_callback'][0]) . '.php';
             $result = call_user_func($item['page_callback'], $newArgs);
         } elseif (strstr($item['page_callback'], '_Form')) {
             $wrapper = new CRM_Utils_Wrapper();
             $result = $wrapper->run(CRM_Utils_Array::value('page_callback', $item), CRM_Utils_Array::value('title', $item), isset($pageArgs) ? $pageArgs : NULL);
         } else {
//.........这里部分代码省略.........
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:Invoke.php

示例12: array

 /**
  * returns all the rows in the given offset and rowCount
  *
  * @param enum   $action   the action being performed
  * @param int    $offset   the row number to start from
  * @param int    $rowCount the number of rows to return
  * @param string $sort     the sql string that describes the sort order
  * @param enum   $output   what should the result set include (web/email/csv)
  *
  * @return int   the total number of rows for this action
  */
 function &getRows($action, $offset, $rowCount, $sort, $output = null)
 {
     //$sort object processing for location fields
     if ($sort) {
         $vars = $sort->_vars;
         $varArray = array();
         foreach ($vars as $key => $field) {
             $field = $vars[$key];
             $fieldArray = explode('-', $field['name']);
             if (is_numeric($fieldArray[1])) {
                 $locationType =& new CRM_Core_DAO_LocationType();
                 $locationType->id = $fieldArray[1];
                 $locationType->find(true);
                 if ($fieldArray[0] == 'email' || $fieldArray[0] == 'im' || $fieldArray[0] == 'phone') {
                     $field['name'] = "`" . $locationType->name . "-" . $fieldArray[0] . "-1`";
                 } else {
                     $field['name'] = "`" . $locationType->name . "-" . $fieldArray[0] . "`";
                 }
             }
             $varArray[$key] = $field;
         }
     }
     $sort->_vars = $varArray;
     $result = $this->_query->searchQuery($offset, $rowCount, $sort, null, null, null, null, null);
     // process the result of the query
     $rows = array();
     $mask = CRM_Core_Action::mask(CRM_Core_Permission::getPermission());
     require_once 'CRM/Core/PseudoConstant.php';
     $locationTypes = CRM_Core_PseudoConstant::locationType();
     $links =& CRM_Profile_Selector_Listings::links();
     $names = array();
     foreach ($this->_fields as $key => $field) {
         if ($field['in_selector'] && !in_array($key, $GLOBALS['_CRM_PROFILE_SELECTOR_LISTINGS']['skipFields'])) {
             if (strpos($key, '-') !== false) {
                 list($fieldName, $id, $type) = explode('-', $key);
                 $locationTypeName = CRM_Utils_Array::value($id, $locationTypes);
                 if (!$locationTypeName) {
                     continue;
                 }
                 if (in_array($fieldName, array('phone', 'im', 'email'))) {
                     if ($type) {
                         $names[] = "{$locationTypeName}-{$fieldName}-{$type}";
                     } else {
                         $names[] = "{$locationTypeName}-{$fieldName}-1";
                     }
                 } else {
                     $names[] = "{$locationTypeName}-{$fieldName}";
                 }
             } else {
                 $names[] = $field['name'];
             }
         }
     }
     while ($result->fetch()) {
         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::getImage($result->contact_type);
         $row['sort_name'] = $result->sort_name;
         foreach ($names as $name) {
             if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name)) {
                 $row[] = CRM_Core_BAO_CustomField::getDisplayValue($result->{$name}, $cfID, $this->_options);
             } else {
                 $row[] = $result->{$name};
             }
             if (!empty($result->{$name})) {
                 $empty = false;
             }
         }
         $row[] = CRM_Core_Action::formLink(CRM_Profile_Selector_Listings::links(), $mask, array('id' => $result->contact_id, 'gid' => $this->_gid));
         if (!$empty) {
             $rows[] = $row;
         }
     }
     return $rows;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:91,代码来源:Listings.php

示例13: ts

function ts($text, $params = array())
{
    $i18n =& CRM_Core_I18n::singleton();
    return $i18n->crm_translate($text, $params);
}
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:5,代码来源:I18n.php

示例14: exportComponents


//.........这里部分代码省略.........
         $field = trim($field);
         if (CRM_Utils_Array::value($field, $returnProperties)) {
             // $queryString .= " ORDER BY $order";
         }
     }
     //hack for student data
     require_once 'CRM/Core/OptionGroup.php';
     $multipleSelectFields = array('preferred_communication_method' => 1);
     if (CRM_Core_Permission::access('Quest')) {
         require_once 'CRM/Quest/BAO/Student.php';
         $studentFields = array();
         $studentFields = CRM_Quest_BAO_Student::$multipleSelectFields;
         $multipleSelectFields = array_merge($multipleSelectFields, $studentFields);
     }
     $header = $addPaymentHeader = false;
     if ($paymentFields) {
         //special return properties for event and members
         $paymentHeaders = array('total_amount' => ts('Total Amount'), 'contribution_status' => ts('Contribution Status'), 'received_date' => ts('Received Date'), 'payment_instrument' => ts('Payment Instrument'), 'transaction_id' => ts('Transaction ID'));
         // get payment related in for event and members
         require_once 'CRM/Contribute/BAO/Contribution.php';
         $paymentDetails = CRM_Contribute_BAO_Contribution::getContributionDetails($exportMode, $ids);
         if (!empty($paymentDetails)) {
             $addPaymentHeader = true;
         }
         $nullContributionDetails = array_fill_keys($paymentHeaders, null);
     }
     $componentDetails = $headerRows = $sqlColumns = array();
     $setHeader = true;
     $rowCount = self::EXPORT_ROW_COUNT;
     $offset = 0;
     $count = -1;
     // for CRM-3157 purposes
     require_once 'CRM/Core/I18n.php';
     $i18n =& CRM_Core_I18n::singleton();
     while (1) {
         $limitQuery = "{$queryString} LIMIT {$offset}, {$rowCount}";
         $dao = CRM_Core_DAO::executeQuery($limitQuery);
         if ($dao->N <= 0) {
             break;
         }
         while ($dao->fetch()) {
             $count++;
             $row = array();
             //first loop through returnproperties so that we return what is required, and in same order.
             $relationshipField = 0;
             foreach ($returnProperties as $field => $value) {
                 //we should set header only once
                 if ($setHeader) {
                     $sqlDone = false;
                     if (isset($query->_fields[$field]['title'])) {
                         $headerRows[] = $query->_fields[$field]['title'];
                     } else {
                         if ($field == 'phone_type_id') {
                             $headerRows[] = 'Phone Type';
                         } else {
                             if ($field == 'provider_id') {
                                 $headerRows[] = 'Im Service Provider';
                             } else {
                                 if (is_array($value) && $field == 'location') {
                                     // fix header for location type case
                                     foreach ($value as $ltype => $val) {
                                         foreach (array_keys($val) as $fld) {
                                             $type = explode('-', $fld);
                                             $hdr = "{$ltype}-" . $query->_fields[$type[0]]['title'];
                                             if (CRM_Utils_Array::value(1, $type)) {
                                                 if (CRM_Utils_Array::value(0, $type) == 'phone') {
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:67,代码来源:Export.php

示例15: 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'], array('context' => 'menu'));
     $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'];
     $menuName = $value['attributes']['name'];
     if (in_array($parentID, $skipMenuItems) || !$active) {
         $skipMenuItems[] = $navID;
         return false;
     }
     //we need to check core view/edit or supported acls.
     require_once 'CRM/Core/Permission.php';
     if (in_array($menuName, array('Search...', 'Contacts'))) {
         if (!CRM_Core_Permission::giveMeAllACLs()) {
             $skipMenuItems[] = $navID;
             return false;
         }
     }
     $config = CRM_Core_Config::singleton();
     $makeLink = false;
     if (isset($url) && $url) {
         if (substr($url, 0, 4) === 'http') {
             $url = $url;
         } else {
             $url = CRM_Utils_System::url($url);
         }
         $makeLink = true;
     }
     static $allComponents;
     if (!$allComponents) {
         $allComponents = CRM_Core_Component::getNames();
     }
     if (isset($permission) && $permission) {
         $permissions = explode(',', $permission);
         $hasPermission = false;
         foreach ($permissions as $key) {
             $key = trim($key);
             $showItem = true;
             //get the component name from permission.
             $componentName = CRM_Core_Permission::getComponentName($key);
             if ($componentName) {
                 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:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:82,代码来源:Navigation.php


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