本文整理汇总了PHP中CakeNumber::defaultCurrency方法的典型用法代码示例。如果您正苦于以下问题:PHP CakeNumber::defaultCurrency方法的具体用法?PHP CakeNumber::defaultCurrency怎么用?PHP CakeNumber::defaultCurrency使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CakeNumber
的用法示例。
在下文中一共展示了CakeNumber::defaultCurrency方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: defaultCurrency
/**
* Getter/setter for default currency
*
* @param string $currency The currency to be used in the future.
* @return string Currency
* @see CakeNumber::defaultCurrency()
*/
public function defaultCurrency($currency)
{
return $this->_engine->defaultCurrency($currency);
}
示例2: _replaceCurrency
/**
* Replace by formatted currency string.
*
* Examples:
* - [currency]50[/currency]
* - [currency zero="$0.00"]0[/currency]
*
* @param string $str String to check and modify.
* @return string Modified string.
*/
protected function _replaceCurrency($str)
{
if (!preg_match_all('/\\[currency(.*?)\\](.*)\\[\\/currency\\]/i', $str, $matches)) {
// Fallback regex for when no options are passed.
if (!preg_match_all('/\\[currency(.*?)\\](.[^\\[]*)\\[\\/currency\\]/i', $str, $matches)) {
return $str;
}
}
foreach ($matches[0] as $i => $find) {
$opts = $this->_extractAttributes(trim($matches[1][$i]));
$currency = CakeNumber::defaultCurrency();
if (isset($opts['currency'])) {
$currency = $opts['currency'];
unset($opts['currency']);
}
$replace = empty($matches[2][$i]) || !is_numeric($matches[2][$i]) ? '' : CakeNumber::currency($matches[2][$i], $currency, $opts);
$str = str_replace($find, $replace, $str);
}
return $str;
}
示例3: define
* Configure routing default class.
*/
if (CakePlugin::loaded('I18n')) {
App::uses('I18nRoute', 'I18n.Routing/Route');
Router::defaultRouteClass('I18nRoute');
Configure::write('Config.language', Configure::read('L10n.language'));
Configure::write('Config.languages', Configure::read('L10n.languages'));
if (!defined('DEFAULT_LANGUAGE')) {
define('DEFAULT_LANGUAGE', Configure::read('L10n.language'));
}
}
/**
* Configure `CakeNumber` currencies.
*/
if (class_exists('CakeNumber')) {
CakeNumber::defaultCurrency(Common::read('L10n.currency', 'USD'));
foreach (Common::read('L10n.currencies', array()) as $currencyName => $currencyFormat) {
CakeNumber::addFormat($currencyName, $currencyFormat);
}
}
if (!function_exists('__t')) {
/**
* Translates different type of strings depending on the number of arguments it is passed and their types. Supports:
*
* - all of `__()`, `__n()`, `__d()`, `__dn()`
* - placeholders for `String::insert()`
*
* Examples:
*
* - __t('Hello world!')
* - __t('Hello :name!', array('name' => 'world'))
示例4: array
* array('callable' => $aFunction, 'on' => 'before', 'priority' => 9), // A valid PHP callback type to be called on beforeDispatch
* array('callable' => $anotherMethod, 'on' => 'after'), // A valid PHP callback type to be called on afterDispatch
*
* ));
*/
Configure::write('Dispatcher.filters', array('AssetDispatcher', 'CacheDispatcher'));
/**
* Configures default file logging options
*/
App::uses('CakeLog', 'Log');
CakeLog::config('debug', array('engine' => 'File', 'types' => array('notice', 'info', 'debug'), 'file' => 'debug'));
CakeLog::config('error', array('engine' => 'File', 'types' => array('warning', 'error', 'critical', 'alert', 'emergency'), 'file' => 'error'));
App::uses('CakeTime', 'Utility');
App::uses('CakeNumber', 'Utility');
CakeNumber::addFormat('EUR', array('wholeSymbol' => ' €', 'wholePosition' => 'after', 'fractionSymbol' => false, 'fractionPosition' => 'after', 'zero' => 0, 'places' => 0, 'thousands' => ' ', 'decimals' => ',', 'negative' => '-', 'escape' => false));
CakeNumber::defaultCurrency('USD');
/**
* All available languages in format (except the default which is defined in constants.php):
* ISO-639-1 => ISO-639-2
* napriklad 'sk' => 'slo'
*
* @see ISO link: http://www.loc.gov/standards/iso639-2/php/code_list.php
*/
function availableLocals()
{
return array();
}
/**
* Return local in format ISO-639-2.
*
* @param string $lang locale ISO-639-1