本文整理汇总了PHP中CRM_Core_PseudoConstant::currencySymbols方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_PseudoConstant::currencySymbols方法的具体用法?PHP CRM_Core_PseudoConstant::currencySymbols怎么用?PHP CRM_Core_PseudoConstant::currencySymbols使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_PseudoConstant
的用法示例。
在下文中一共展示了CRM_Core_PseudoConstant::currencySymbols方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: format
/**
* format a monetary string
*
* Format a monetary string basing on the amount provided,
* ISO currency code provided and a format string consisting of:
*
* %a - the formatted amount
* %C - the currency ISO code (e.g., 'USD') if provided
* %c - the currency symbol (e.g., '$') if available
*
* @param float $amount the monetary amount to display (1234.56)
* @param string $currency the three-letter ISO currency code ('USD')
* @param string $format the desired currency format
*
* @return string formatted monetary string
*
* @static
*/
static function format($amount, $currency = null, $format = null)
{
if (CRM_Utils_System::isNull($amount)) {
return '';
}
$config =& CRM_Core_Config::singleton();
if (!self::$_currencySymbols) {
require_once "CRM/Core/PseudoConstant.php";
$currencySymbolName = CRM_Core_PseudoConstant::currencySymbols('name');
$currencySymbol = CRM_Core_PseudoConstant::currencySymbols();
self::$_currencySymbols = array_combine($currencySymbolName, $currencySymbol);
}
if (!$currency) {
$currency = $config->defaultCurrency;
}
if (!$format) {
$format = $config->moneyformat;
}
// money_format() exists only in certain PHP install (CRM-650)
if (is_numeric($amount) and function_exists('money_format')) {
$amount = money_format($config->moneyvalueformat, $amount);
}
$replacements = array('%a' => $amount, '%C' => $currency, '%c' => CRM_Utils_Array::value($currency, self::$_currencySymbols, $currency));
return strtr($format, $replacements);
}
示例2: format
/**
* format a monetary string
*
* Format a monetary string basing on the amount provided,
* ISO currency code provided and a format string consisting of:
*
* %a - the formatted amount
* %C - the currency ISO code (e.g., 'USD') if provided
* %c - the currency symbol (e.g., '$') if available
*
* @param float $amount the monetary amount to display (1234.56)
* @param string $currency the three-letter ISO currency code ('USD')
* @param string $format the desired currency format
*
* @return string formatted monetary string
*
* @static
*/
static function format($amount, $currency = NULL, $format = NULL, $onlyNumber = FALSE)
{
if (CRM_Utils_System::isNull($amount)) {
return '';
}
$config = CRM_Core_Config::singleton();
if (!$format) {
$format = $config->moneyformat;
}
if ($onlyNumber) {
// money_format() exists only in certain PHP install (CRM-650)
if (is_numeric($amount) and function_exists('money_format')) {
$amount = money_format($config->moneyvalueformat, $amount);
}
return $amount;
}
if (!self::$_currencySymbols) {
$currencySymbolName = CRM_Core_PseudoConstant::currencySymbols('name');
$currencySymbol = CRM_Core_PseudoConstant::currencySymbols();
self::$_currencySymbols = array_combine($currencySymbolName, $currencySymbol);
}
if (!$currency) {
$currency = $config->defaultCurrency;
}
if (!$format) {
$format = $config->moneyformat;
}
// money_format() exists only in certain PHP install (CRM-650)
// setlocale() affects native gettext (CRM-11054, CRM-9976)
if (is_numeric($amount) && function_exists('money_format')) {
$lc = setlocale(LC_MONETARY, 0);
setlocale(LC_MONETARY, 'en_US.utf8', 'en_US', 'en_US.utf8', 'en_US', 'C');
$amount = money_format($config->moneyvalueformat, $amount);
setlocale(LC_MONETARY, $lc);
}
$rep = array(',' => $config->monetaryThousandSeparator, '.' => $config->monetaryDecimalPoint);
// If it contains tags, means that HTML was passed and the
// amount is already converted properly,
// so don't mess with it again.
if (strip_tags($amount) === $amount) {
$money = strtr($amount, $rep);
} else {
$money = $amount;
}
$replacements = array('%a' => $money, '%C' => $currency, '%c' => CRM_Utils_Array::value($currency, self::$_currencySymbols, $currency));
return strtr($format, $replacements);
}
示例3: buildSearchForm
/**
* add all the elements shared between contribute search and advnaced search
*
* @access public
*
* @return void
* @static
*/
static function buildSearchForm(&$form)
{
//added contribution source
$form->addElement('text', 'contribution_source', ts('Contribution Source'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution', 'source'));
CRM_Core_Form_Date::buildDateRange($form, 'contribution_date', 1, '_low', '_high', ts('From'), FALSE, FALSE);
$form->add('text', 'contribution_amount_low', ts('From'), array('size' => 8, 'maxlength' => 8));
$form->addRule('contribution_amount_low', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('9.99', ' '))), 'money');
$form->add('text', 'contribution_amount_high', ts('To'), array('size' => 8, 'maxlength' => 8));
$form->addRule('contribution_amount_high', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money');
//adding select option for curreny type -- CRM-4711
$form->add('select', 'contribution_currency_type', ts('Currency Type'), array('' => ts('- select -')) + CRM_Core_PseudoConstant::currencySymbols('name'));
$form->add('select', 'contribution_type_id', ts('Contribution Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType());
$form->add('select', 'contribution_page_id', ts('Contribution Page'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionPage());
$form->add('select', 'contribution_payment_instrument_id', ts('Payment Instrument'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument());
$form->add('select', 'contribution_pcp_made_through_id', ts('Personal Campaign Page'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::pcPage());
$status = array();
$statusValues = CRM_Core_OptionGroup::values("contribution_status");
// Remove status values that are only used for recurring contributions or pledges (In Progress, Overdue).
unset($statusValues['5']);
unset($statusValues['6']);
foreach ($statusValues as $key => $val) {
$status[] = $form->createElement('advcheckbox', $key, NULL, $val);
}
$form->addGroup($status, 'contribution_status_id', ts('Contribution Status'));
// add null checkboxes for thank you and receipt
$form->addElement('checkbox', 'contribution_thankyou_date_isnull', ts('Thank-you date not set?'));
$form->addElement('checkbox', 'contribution_receipt_date_isnull', ts('Receipt not sent?'));
//add fields for honor search
$form->addElement('text', 'contribution_in_honor_of', ts("In Honor Of"));
$form->addElement('checkbox', 'contribution_test', ts('Find Test Contributions?'));
$form->addElement('checkbox', 'contribution_pay_later', ts('Find Pay Later Contributions?'));
//add field for transaction ID search
$form->addElement('text', 'contribution_transaction_id', ts("Transaction ID"));
$form->addElement('checkbox', 'contribution_recurring', ts('Find Recurring Contributions?'));
$form->addElement('checkbox', 'contribution_recurring_isnull', ts('Find Non Recurring Contributions?'));
$form->addElement('text', 'contribution_check_number', ts('Check Number'));
//add field for pcp display in roll search
$form->addYesNo('contribution_pcp_display_in_roll', ts('Personal Campaign Page Honor Roll?'));
// add all the custom searchable fields
$contribution = array('Contribution');
$groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $contribution);
if ($groupDetails) {
$form->assign('contributeGroupTree', $groupDetails);
foreach ($groupDetails as $group) {
foreach ($group['fields'] as $field) {
$fieldId = $field['id'];
$elementName = 'custom_' . $fieldId;
CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, FALSE, TRUE);
}
}
}
CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'contribution_campaign_id');
// add batch select
$batches = CRM_Core_BAO_Batch::getBatches();
if (!empty($batches)) {
$form->add('select', 'contribution_batch_id', ts('Batch Name'), array('' => ts('- select -')) + $batches);
}
$form->assign('validCiviContribute', TRUE);
}
示例4: defaultCurrencySymbol
/**
* Provide cached default currency symbol
*
* @param
*
* @return string
*/
public function defaultCurrencySymbol($defaultCurrency = NULL)
{
static $cachedSymbol = NULL;
if (!$cachedSymbol || $defaultCurrency) {
if ($this->defaultCurrency || $defaultCurrency) {
$currencySymbolName = CRM_Core_PseudoConstant::currencySymbols('name');
$currencySymbol = CRM_Core_PseudoConstant::currencySymbols();
$this->currencySymbols = array_combine($currencySymbolName, $currencySymbol);
$currency = $defaultCurrency ? $defaultCurrency : $this->defaultCurrency;
$cachedSymbol = CRM_Utils_Array::value($currency, $this->currencySymbols, '');
} else {
$cachedSymbol = '$';
}
}
return $cachedSymbol;
}
示例5: defaultCurrencySymbol
/**
* Provide cached default currency symbol
*
* @param
* @return string
*/
public function defaultCurrencySymbol()
{
static $cachedSymbol = null;
if (!$cachedSymbol) {
if ($this->defaultCurrency) {
require_once "CRM/Core/PseudoConstant.php";
$currencySymbolName = CRM_Core_PseudoConstant::currencySymbols('name');
$currencySymbol = CRM_Core_PseudoConstant::currencySymbols();
$this->currencySymbols = array_combine($currencySymbolName, $currencySymbol);
$cachedSymbol = CRM_Utils_Array::value($this->defaultCurrency, $this->currencySymbols, '');
} else {
$cachedSymbol = '$';
}
}
return $cachedSymbol;
}