本文整理汇总了PHP中CakeNumber::addFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP CakeNumber::addFormat方法的具体用法?PHP CakeNumber::addFormat怎么用?PHP CakeNumber::addFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CakeNumber
的用法示例。
在下文中一共展示了CakeNumber::addFormat方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addFormat
/**
* Add a currency format to the Number helper. Makes reusing
* currency formats easier.
*
* ``` $this->Number->addFormat('NOK', array('before' => 'Kr. ')); ```
*
* You can now use `NOK` as a shortform when formatting currency amounts.
*
* ``` $this->Number->currency($value, 'NOK'); ```
*
* Added formats are merged with the defaults defined in Cake\Utility\Number::$_currencyDefaults
* See Cake\Utility\Number::currency() for more information on the various options and their function.
*
* @param string $formatName The format name to be used in the future.
* @param array $options The array of options for this format.
* @return void
* @see CakeNumber::addFormat()
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/number.html#NumberHelper::addFormat
*/
public function addFormat($formatName, $options)
{
return $this->_engine->addFormat($formatName, $options);
}
示例2: array
<?php
Cache::config('default', array('engine' => 'File'));
// load all Plugins
CakePlugin::loadAll();
//Configuring Filters
Configure::write('Dispatcher.filters', array('AssetDispatcher', 'CacheDispatcher'));
// config the log
App::uses('CakeLog', 'Log');
CakeLog::config('debug', array('engine' => 'FileLog', 'types' => array('notice', 'info', 'debug'), 'file' => 'debug'));
CakeLog::config('error', array('engine' => 'FileLog', 'types' => array('warning', 'error', 'critical', 'alert', 'emergency'), 'file' => 'error'));
// Configure currency for BRAZIL
App::uses('CakeNumber', 'Utility');
CakeNumber::addFormat('BRR', array('before' => 'R$ ', 'thousands' => '.', 'decimals' => ',', 'zero' => 'R$ 0,00', 'after' => false));
CakeNumber::addFormat('BR', array('before' => null, 'thousands' => '.', 'decimals' => ',', 'after' => false));
/* function check route
ex: if (checkRoute('pages#home')) {} */
function checkRoute($route = null)
{
list($controller, $action) = explode('#', $route);
$params = Router::getParams();
return $params['controller'] == $controller && $params['action'] == $action;
}
function mostraMes($m)
{
switch ($m) {
case 01:
case 1:
$mes = "Janeiro";
break;
case 02:
示例3: array
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package app.Controller
* @since CakePHP(tm) v 0.2.9
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
App::uses('Controller', 'Controller');
App::uses('CakeNumber', 'Utility');
App::uses('CakeTime', 'Utility');
$options = array('before' => false, 'fractionPosition' => 'after', 'zero' => 0, 'places' => 2, 'thousands' => '.', 'decimals' => ',', 'negative' => '-', 'escape' => true);
CakeNumber::addFormat('BR', $options);
/**
* Application Controller
*
* Add your application-wide methods in the class below, your controllers
* will inherit them.
*
* @package app.Controller
* @link http://book.cakephp.org/2.0/en/controllers.html#the-app-controller
*/
class AppController extends Controller
{
public $components = array('RequestHandler', 'Session', 'Acl', 'Auth' => array('authorize' => array('Actions' => array('actionPath' => 'controllers'))));
public $helpers = array('Html', 'Form', 'Session', 'Js');
public function beforeRender()
{
示例4: define
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'))
* - __t('Hello mate!', 'Hello mates!', 2)
* - __t(':salutation mate!', ':salutation mates!', 2, array('salutation' => 'Hello'))
示例5: array
* 'MyPlugin.MyFilter', // will use MyFilter class from the Routing/Filter package in MyPlugin plugin.
* 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.
*
示例6: array
/**
* 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'));
/* == */
// Definindo idioma da aplicação
Configure::write('Config.language', 'pt-br');
// Adicionando o caminho do locale
App::build(array('locales' => dirname(dirname(__FILE__)) . DS . 'locale' . DS));
// Alteração do inflector
$_uninflected = array('atlas', 'lapis', 'onibus', 'pires', 'virus', '.*x');
$_pluralIrregular = array('abdomens' => 'abdomen', 'alemao' => 'alemaes', 'artesa' => 'artesaos', 'as' => 'ases', 'bencao' => 'bencaos', 'cao' => 'caes', 'capelao' => 'capelaes', 'capitao' => 'capitaes', 'chao' => 'chaos', 'charlatao' => 'charlataes', 'cidadao' => 'cidadaos', 'consul' => 'consules', 'cristao' => 'cristaos', 'dificil' => 'dificeis', 'email' => 'emails', 'escrivao' => 'escrivaes', 'fossel' => 'fosseis', 'germens' => 'germen', 'grao' => 'graos', 'hifens' => 'hifen', 'irmao' => 'irmaos', 'liquens' => 'liquen', 'mal' => 'males', 'mao' => 'maos', 'orfao' => 'orfaos', 'pais' => 'paises', 'pai' => 'pais', 'pao' => 'paes', 'perfil' => 'perfis', 'projetil' => 'projeteis', 'reptil' => 'repteis', 'sacristao' => 'sacristaes', 'sotao' => 'sotaos', 'tabeliao' => 'tabeliaes', 'banner' => 'banners', 'newsletter' => 'newsletters', 'status' => 'status');
Inflector::rules('singular', array('rules' => array('/^(.*)(oes|aes|aos)$/i' => '\\1ao', '/^(.*)(a|e|o|u)is$/i' => '\\1\\2l', '/^(.*)e?is$/i' => '\\1il', '/^(.*)(r|s|z)es$/i' => '\\1\\2', '/^(.*)ns$/i' => '\\1m', '/^(.*)s$/i' => '\\1'), 'uninflected' => $_uninflected, 'irregular' => array_flip($_pluralIrregular)), true);
Inflector::rules('plural', array('rules' => array('/^(.*)ao$/i' => '\\1oes', '/^(.*)(r|s|z)$/i' => '\\1\\2es', '/^(.*)(a|e|o|u)l$/i' => '\\1\\2is', '/^(.*)il$/i' => '\\1is', '/^(.*)(m|n)$/i' => '\\1ns', '/^(.*)$/i' => '\\1s'), 'uninflected' => $_uninflected, 'irregular' => $_pluralIrregular), true);
Inflector::rules('transliteration', array('/À|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ľ|ŀ|ł/' => 'l', '/ñ|ń|ņ|ň|ʼn/' => 'n', '/ŕ|ŗ|ř/' => 'r', '/ś|ŝ|ş|š|ſ/' => 's', '/ţ|ť|ŧ/' => 't', '/ý|ÿ|ŷ/' => 'y', '/ŵ/' => 'w', '/ź|ż|ž/' => 'z', '/æ|ǽ/' => 'ae', '/ij/' => 'ij', '/œ/' => 'oe', '/ƒ/' => 'f'));
unset($_uninflected, $_pluralIrregular);
Cache::config('appCache', array('engine' => 'File', 'duration' => '+10 years', 'path' => CACHE . DS . 'app'));
Cache::config('pdfCache', array('engine' => 'File', 'duration' => '+10 years', 'path' => CACHE . DS . 'pdf'));
App::uses('IniReader', 'Configure');
// Read config files from app/Config
Configure::config('CONFIG', new IniReader());
Configure::load('CONFIG', 'CONFIG');
App::uses('CakeNumber', 'Utility');
CakeNumber::addFormat('BRL', array('before' => 'R$', 'thousands' => '.', 'decimals' => ','));
define('APP_BASE_PATH', ROOT . DS . APP_DIR);
define('APP_WEBROOT_BASE_PATH', ROOT . DS . APP_DIR . DS . WEBROOT_DIR);
CakePlugin::load('Mapbiomas');
CakePlugin::load('Export');
CakePlugin::load('Dashboard');