本文整理汇总了PHP中CakeNumber类的典型用法代码示例。如果您正苦于以下问题:PHP CakeNumber类的具体用法?PHP CakeNumber怎么用?PHP CakeNumber使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CakeNumber类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: standardFormat
/**
* Transforms $number into a standard format.
*
* 12345.67 = 12,346
*
* @param integer $number The number to format.
* @param string $before The text to put in front of the number Default is ''.
* @param integer $places The number to decimal places to show. Default is 0.
* @return string The formated number.
* @access public
* @static
*/
public static function standardFormat($number, $before = '', $places = 0)
{
if ($places === 0) {
$number = round($number);
}
return CakeNumber::format($number, array('before' => $before, 'places' => $places));
}
开发者ID:quentinhill,项目名称:bedrock,代码行数:19,代码来源:BedrockNumber.php
示例2: unzip
/**
* キャビネットファイルのUnzip
*
* @param Model $model CabinetFile
* @param array $cabinetFile CabinetFileデータ
* @return bool
* @throws InternalErrorException
*/
public function unzip(Model $model, $cabinetFile)
{
$model->begin();
try {
// テンポラリフォルダにunzip
$zipPath = WWW_ROOT . $cabinetFile['UploadFile']['file']['path'] . $cabinetFile['UploadFile']['file']['id'] . DS . $cabinetFile['UploadFile']['file']['real_file_name'];
//debug($zipPath);
App::uses('UnZip', 'Files.Utility');
$unzip = new UnZip($zipPath);
$tmpFolder = $unzip->extract();
if ($tmpFolder === false) {
throw new InternalErrorException('UnZip Failed.');
}
$parentCabinetFolder = $model->find('first', ['conditions' => ['CabinetFileTree.id' => $cabinetFile['CabinetFileTree']['parent_id']]]);
// unzipされたファイル拡張子のバリデーション
// unzipされたファイルのファイルサイズバリデーション
$files = $tmpFolder->findRecursive();
$unzipTotalSize = 0;
foreach ($files as $file) {
//
$unzipTotalSize += filesize($file);
// ここでは拡張子だけチェックする
$extension = pathinfo($file, PATHINFO_EXTENSION);
if (!$model->isAllowUploadFileExtension($extension)) {
// NG
$model->validationErrors = [__d('cabinets', 'Unzip failed. Contains does not allow file format.')];
return false;
}
}
// ルームファイルサイズ制限
$maxRoomDiskSize = Current::read('Space.room_disk_size');
if ($maxRoomDiskSize !== null) {
// nullだったらディスクサイズ制限なし。null以外ならディスクサイズ制限あり
// 解凍後の合計
// 現在のルームファイルサイズ
$roomId = Current::read('Room.id');
$roomFileSize = $model->getTotalSizeByRoomId($roomId);
if ($roomFileSize + $unzipTotalSize > $maxRoomDiskSize) {
$model->validationErrors[] = __d('cabinets', 'Failed to expand. The total size exceeds the limit.<br />' . 'The total size limit is %s (%s left).', CakeNumber::toReadableSize($roomFileSize + $unzipTotalSize), CakeNumber::toReadableSize($maxRoomDiskSize));
return false;
}
}
// 再帰ループで登録処理
list($folders, $files) = $tmpFolder->read(true, false, true);
foreach ($files as $file) {
$this->_addFileFromPath($model, $parentCabinetFolder, $file);
}
foreach ($folders as $folder) {
$this->_addFolderFromPath($model, $parentCabinetFolder, $folder);
}
} catch (Exception $e) {
return $model->rollback($e);
}
$model->commit();
return true;
}
开发者ID:NetCommons3,项目名称:Cabinets,代码行数:64,代码来源:CabinetUnzipBehavior.php
示例3: startup
/**
* Called after the Controller::beforeFilter() and before the controller action
*
* @param Controller $controller Controller with components to startup
* @return void
*/
public function startup(Controller $controller)
{
// ファイルアップロード等で post_max_size を超えると $_POSTが空っぽになるため、このタイミングでエラー表示
$contentLength = Hash::get($_SERVER, 'CONTENT_LENGTH');
if ($contentLength > CakeNumber::fromReadableSize(ini_get('post_max_size'))) {
$message = __d('files', 'FileUpload.post_max_size.over');
$controller->NetCommons->setFlashNotification($message, array('class' => 'danger', 'interval' => NetCommonsComponent::ALERT_VALIDATE_ERROR_INTERVAL));
$controller->redirect($controller->referer());
}
}
开发者ID:s-nakajima,项目名称:files,代码行数:16,代码来源:FileUploadComponent.php
示例4: numberCurrency
/**
* Number format by market with currency code
*
* @param $market_id
* @param $number
* @param bool $no_symbol
* @return string
*/
public function numberCurrency($market_id, $number, $no_symbol = false)
{
if ($market_id == 5) {
$currency = 'GBP';
} elseif ($market_id == 7 || $market_id == 8 || $market_id == 9) {
$currency = 'EUR';
} else {
$currency = 'USD';
}
if ($no_symbol) {
$options = ['before' => false, 'after' => false, 'places' => 2];
} else {
$options = ['places' => 2];
}
return CakeNumber::currency($number, $currency, $options);
}
开发者ID:kameshwariv,项目名称:testexample,代码行数:24,代码来源:AppHelper.php
示例5: addMedia
/**
* Add media file
*
* @param array $requestData Array of POST data. Will contain form data as well as uploaded files.
*
* @return bool
* @throws CakeException
*/
public function addMedia(array $requestData)
{
if (CakeNumber::fromReadableSize(ini_get('post_max_size')) < env('CONTENT_LENGTH')) {
throw new CakeException(__d('hurad', 'File could not be uploaded. please increase "post_max_size" in php.ini'));
}
$this->set($requestData);
if ($this->validates()) {
$prefix = uniqid() . '_';
$uploadInfo = $requestData['Media']['media_file'];
$path = date('Y') . DS . date('m');
if ($uploadInfo['error']) {
throw new CakeException($this->getUploadErrorMessages($uploadInfo['error']));
}
$folder = new Folder(WWW_ROOT . 'files' . DS . $path, true, 0755);
if (!is_writable(WWW_ROOT . 'files')) {
throw new CakeException(__d('hurad', '%s is not writable', WWW_ROOT . 'files'));
}
if (!move_uploaded_file($uploadInfo['tmp_name'], $folder->pwd() . DS . $prefix . $uploadInfo['name'])) {
throw new CakeException(__d('hurad', 'File could not be uploaded. Please, try again.'));
}
$file = new File($folder->pwd() . DS . $prefix . $uploadInfo['name']);
$requestData['Media']['user_id'] = CakeSession::read('Auth.User.id');
$requestData['Media']['name'] = $prefix . $uploadInfo['name'];
$requestData['Media']['original_name'] = $uploadInfo['name'];
$requestData['Media']['mime_type'] = $file->mime();
$requestData['Media']['size'] = $file->size();
$requestData['Media']['extension'] = $file->ext();
$requestData['Media']['path'] = $path;
$requestData['Media']['web_path'] = Configure::read('General.site_url') . '/' . 'files' . '/' . $path . '/' . $prefix . $uploadInfo['name'];
$this->create();
if ($this->save($requestData)) {
return true;
} else {
return false;
}
} else {
return false;
}
}
开发者ID:hurad,项目名称:hurad,代码行数:47,代码来源:Media.php
示例6: __construct
/**
* Sets protected properties based on config provided
*
* @param array $config Configuration array
*/
public function __construct(array $config = [])
{
parent::__construct($config);
if (!empty($this->_config['path'])) {
$this->_path = $this->_config['path'];
}
if (Configure::read('debug') && !is_dir($this->_path)) {
mkdir($this->_path, 0775, true);
}
if (!empty($this->_config['file'])) {
$this->_file = $this->_config['file'];
if (substr($this->_file, -4) !== '.log') {
$this->_file .= '.log';
}
}
if (!empty($this->_config['size'])) {
if (is_numeric($this->_config['size'])) {
$this->_size = (int) $this->_config['size'];
} else {
$this->_size = CakeNumber::fromReadableSize($this->_config['size']);
}
}
}
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:28,代码来源:FileLog.php
示例7: currency
function currency($number, $currency = null, $options = array()) {
// App::uses('BakewellNumber', 'Utility');
// return BakewellNumber::currency($number, $currency, $options);
App::uses('CakeNumber', 'Utility');
return CakeNumber::currency($number, $currency, $options);
}
开发者ID:ayurved,项目名称:AdyaAyurveda,代码行数:6,代码来源:AppModel.php
示例8: beforeValidate
/**
* Called during validation operations, before validation. Please note that custom
* validation rules can be defined in $validate.
*
* @param array $options Options passed from Model::save().
* @return bool True if validate operation should continue, false to abort
* @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforevalidate
* @see Model::save()
*/
public function beforeValidate($options = array())
{
$postMaxSize = CakeNumber::fromReadableSize(ini_get('post_max_size'));
$uploadMaxFilesize = CakeNumber::fromReadableSize(ini_get('upload_max_filesize'));
$maxUploadSize = CakeNumber::toReadableSize($postMaxSize > $uploadMaxFilesize ? $uploadMaxFilesize : $postMaxSize);
$this->validate = Hash::merge($this->validate, array(self::INPUT_NAME => array('uploadError' => array('rule' => array('uploadError'), 'message' => array('Error uploading file'))), 'name' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'required' => true)), 'slug' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'required' => true)), 'path' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'on' => 'create')), 'extension' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'required' => true)), 'mimetype' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false)), 'size' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false)), 'role_type' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'required' => true)), 'number_of_downloads' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.'))), 'status' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.')))));
return parent::beforeValidate($options);
}
开发者ID:s-nakajima,项目名称:FileDevs,代码行数:17,代码来源:FileModel_bk.php
示例9: addFormat
/**
* @see: CakeNumber::addFormat()
*
* @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 NumberHelper::currency()
* @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);
}
开发者ID:gilyaev,项目名称:framework-bench,代码行数:13,代码来源:NumberHelper.php
示例10: 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'))
开发者ID:gourmet,项目名称:common,代码行数:31,代码来源:bootstrap.php
示例11: 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:
开发者ID:lucassmacedo,项目名称:Controle-Caixa-CakePHP,代码行数:31,代码来源:bootstrap.php
示例12: 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
开发者ID:magooemp,项目名称:eramba,代码行数:31,代码来源:bootstrap.php
示例13: testMultibyteFormat
/**
* testMultibyteFormat
*
* @return void
*/
public function testMultibyteFormat()
{
$value = '5199100.0006';
$result = $this->Number->format($value, array('thousands' => ' ', 'decimals' => '&', 'places' => 3, 'escape' => false, 'before' => ''));
$expected = '5 199 100&001';
$this->assertEquals($expected, $result);
$value = 1000.45;
$result = $this->Number->format($value, array('thousands' => ',,', 'decimals' => '.a', 'escape' => false));
$expected = '$1,,000.a45';
$this->assertEquals($expected, $result);
$value = 519919827593784.0;
$this->Number->addFormat('RUR', array('thousands' => 'ø€ƒ‡™', 'decimals' => '(§.§)', 'escape' => false, 'wholeSymbol' => '€', 'wholePosition' => 'after'));
$result = $this->Number->currency($value, 'RUR');
$expected = '519ø€ƒ‡™919ø€ƒ‡™827ø€ƒ‡™593ø€ƒ‡™784(§.§)00€';
$this->assertEquals($expected, $result);
$value = '13371337.1337';
$result = CakeNumber::format($value, array('thousands' => '- |-| /-\\ >< () |2 -', 'decimals' => '- £€€† -', 'before' => ''));
$expected = '13- |-| /-\\ >< () |2 -371- |-| /-\\ >< () |2 -337- £€€† -13';
$this->assertEquals($expected, $result);
}
开发者ID:beyondkeysystem,项目名称:testone,代码行数:25,代码来源:CakeNumberTest.php
示例14: main
/**
* Override main() for help message hook
*
* @access public
*/
public function main()
{
$path = $this->path;
$Folder = new Folder($path, true);
$fileSufix = date('Ymd\\_His') . '.sql';
$file = $path . $fileSufix;
if (!is_writable($path)) {
trigger_error('The path "' . $path . '" isn\'t writable!', E_USER_ERROR);
}
$this->out("Backing up...\n");
$File = new File($file);
$db = ConnectionManager::getDataSource($this->dataSourceName);
$config = $db->config;
$this->connection = "default";
foreach ($db->listSources() as $table) {
$table = str_replace($config['prefix'], '', $table);
// $table = str_replace($config['prefix'], '', 'dinings');
$ModelName = Inflector::classify($table);
if (in_array($ModelName, $this->excluidos)) {
continue;
}
$Model = ClassRegistry::init($ModelName);
$Model->virtualFields = array();
$DataSource = $Model->getDataSource();
$this->Schema = new CakeSchema(array('connection' => $this->connection));
$cakeSchema = $db->describe($table);
// $CakeSchema = new CakeSchema();
$this->Schema->tables = array($table => $cakeSchema);
$File->write("\n/* Drop statement for {$table} */\n");
$File->write("\nSET foreign_key_checks = 0;\n\n");
#$File->write($DataSource->dropSchema($this->Schema, $table) . "\n");
$File->write($DataSource->dropSchema($this->Schema, $table));
$File->write("SET foreign_key_checks = 1;\n");
$File->write("\n/* Backuping table schema {$table} */\n");
$File->write($DataSource->createSchema($this->Schema, $table) . "\n");
$File->write("/* Backuping table data {$table} */\n");
unset($valueInsert, $fieldInsert);
$rows = $Model->find('all', array('recursive' => -1));
$quantity = 0;
$File->write($this->separador . "\n");
if (count($rows) > 0) {
$fields = array_keys($rows[0][$ModelName]);
$values = array_values($rows);
$count = count($fields);
for ($i = 0; $i < $count; $i++) {
$fieldInsert[] = $DataSource->name($fields[$i]);
}
$fieldsInsertComma = implode(', ', $fieldInsert);
foreach ($rows as $k => $row) {
unset($valueInsert);
for ($i = 0; $i < $count; $i++) {
$valueInsert[] = $DataSource->value(utf8_encode($row[$ModelName][$fields[$i]]), $Model->getColumnType($fields[$i]), false);
}
$query = array('table' => $DataSource->fullTableName($table), 'fields' => $fieldsInsertComma, 'values' => implode(', ', $valueInsert));
$File->write($DataSource->renderStatement('create', $query) . ";\n");
$quantity++;
}
}
$this->out('Model "' . $ModelName . '" (' . $quantity . ')');
}
$this->out("Backup: " . $file);
$this->out("Peso:: " . CakeNumber::toReadableSize(filesize($file)));
$File->close();
if (class_exists('ZipArchive') && filesize($file) > 100) {
$zipear = $this->in('Deseas zipear este backup', null, 's');
$zipear = strtolower($zipear);
if ($zipear === 's') {
$this->hr();
$this->out('Zipping...');
$zip = new ZipArchive();
$zip->open($file . '.zip', ZIPARCHIVE::CREATE);
$zip->addFile($file, $fileSufix);
$zip->close();
$this->out("Peso comprimido: " . CakeNumber::toReadableSize(filesize($file . '.zip')));
$this->out("Listo!");
if (file_exists($file . '.zip') && filesize($file) > 10) {
unlink($file);
}
$this->out("Database Backup Successful.\n");
}
}
}
开发者ID:oxicode,项目名称:cakephp-modo-mantenimiento,代码行数:87,代码来源:BackupShell.php
示例15: validateRoomFileSizeLimit
/**
* NetCommons3のシステム管理→一般設定で許可されているルーム容量内かをチェックするバリデータ
*
* @param Model $model Model
* @param array $check バリデートする値
* @return bool|string 容量内: true, 容量オーバー: string エラーメッセージ
*/
public function validateRoomFileSizeLimit(Model $model, $check)
{
$field = $this->_getField($check);
$roomId = Current::read('Room.id');
$maxRoomDiskSize = Current::read('Space.room_disk_size');
if ($maxRoomDiskSize === null) {
return true;
}
$size = $check[$field]['size'];
$roomTotalSize = $this->getTotalSizeByRoomId($model, $roomId);
if ($roomTotalSize + $size < $maxRoomDiskSize) {
return true;
} else {
$roomsLanguage = ClassRegistry::init('Room.RoomsLanguage');
$data = $roomsLanguage->find('first', ['conditions' => ['room_id' => $roomId, 'language_id' => Current::read('Language.id')]]);
$roomName = $data['RoomsLanguage']['name'];
// ファイルサイズをMBとかkb表示に
$message = __d('files', 'Total file size uploaded to the %s, exceeded the limit. The limit is %s(%s left).', $roomName, CakeNumber::toReadableSize($maxRoomDiskSize), CakeNumber::toReadableSize($maxRoomDiskSize - $roomTotalSize));
return $message;
}
}
开发者ID:s-nakajima,项目名称:files,代码行数:28,代码来源:UploadFileValidateBehavior.php
示例16: 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()
{
开发者ID:ealves,项目名称:sistema-avaliacao,代码行数:31,代码来源:AppController.php
示例17: _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;
}
开发者ID:gourmet,项目名称:common,代码行数:30,代码来源:TableHelper.php
示例18: exportToExcel
public function exportToExcel($data = array(), $filename = null)
{
/*
* Export to excel - php
*/
//http://w3lessons.info/2015/07/13/export-html-table-to-excel-csv-json-pdf-png-using-jquery/
//html contain export in excel(upper link)
// http://www.codexworld.com/export-data-to-excel-in-php/
$preparedArray = array();
if (!empty($data)) {
$payment_total = 0;
$receipt_total = 0;
foreach ($data as $signleTransaction) {
$recordArray = array();
if ($signleTransaction["Transaction"]["transaction_type"] == "Payment") {
$amount = $signleTransaction["Transaction"]["amount"];
$recordArray["Payment Amount"] = CakeNumber::currency($amount, "");
$recordArray["Payment Particulars"] = $this->getParticulars($signleTransaction);
$payment_total += $amount;
} else {
$recordArray["Payment Amount"] = null;
$recordArray["Payment Particulars"] = null;
}
if ($signleTransaction["Transaction"]["transaction_type"] == "Receipt") {
$amount = $signleTransaction["Transaction"]["amount"];
$recordArray["Receipt Amount"] = CakeNumber::currency($amount, "");
$recordArray["Receipt Particulars"] = $this->getParticulars($signleTransaction);
$receipt_total += $amount;
} else {
$recordArray["Receipt Amount"] = null;
$recordArray["Receipt Particulars"] = null;
}
$preparedArray[] = $recordArray;
}
$recordArray = array();
$recordArray["Payment Amount"] = null;
$recordArray["Payment Particulars"] = null;
$recordArray["Receipt Amount"] = null;
$recordArray["Receipt Particulars"] = null;
$preparedArray[] = $recordArray;
$recordArray = array();
$recordArray["Payment Amount"] = "Total Payment";
$recordArray["Payment Particulars"] = null;
$recordArray["Receipt Amount"] = "Total Receipt";
$recordArray["Receipt Particulars"] = null;
$preparedArray[] = $recordArray;
$recordArray["Payment Amount"] = CakeNumber::currency($payment_total, "");
$recordArray["Payment Particulars"] = null;
$recordArray["Receipt Amount"] = CakeNumber::currency($receipt_total, "");
$recordArray["Receipt Particulars"] = null;
$preparedArray[] = $recordArray;
}
// $preparedArray = array();
// if (!empty($data)) {
// foreach ($data as $signleTransaction) {
// $recordArray = array();
// $recordArray["Amount"] = $signleTransaction["Transaction"]["amount"];
// $recordArray["Transaction Type"] = $signleTransaction["Transaction"]["transaction_type"];
// $recordArray["Is Interest Entry"] = $signleTransaction["Transaction"]["is_interest"];
// $recordArray["Remarks"] = $signleTransaction["Transaction"]["remarks"];
// $recordArray["Transaction Date"] = $signleTransaction["Transaction"]["transaction_date"];
// $recordArray["Created Date"] = $signleTransaction["Transaction"]["created"];
// $recordArray["Modified Date"] = $signleTransaction["Transaction"]["modified"];
// $preparedArray[] = $recordArray;
// }
// }
if (empty($filename)) {
// file name for download
$filename = "export_data" . date('Ymd') . ".xls";
}
$columnHeadings = array("Amount", "Particulars(Payment)", "Amount", "Particulars(Receipt)");
// headers for download
header("Content-Disposition: attachment; filename=\"{$filename}\"");
header("Content-Type: application/vnd.ms-excel");
$flag = false;
foreach ($preparedArray as $row) {
if (!$flag) {
// display column names as first row
//echo implode("\t", array_keys($row)) . "\n";
echo implode("\t", $columnHeadings) . "\n";
$flag = true;
}
// filter data
array_walk($row, array($this, 'filterData'));
echo implode("\t", array_values($row)) . "\n";
}
exit;
}
开发者ID:apa-narola,项目名称:cakephpaccount,代码行数:88,代码来源:TransactionsController.php
示例19: 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('/À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ/' => 'A', '/È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě/' => 'E', '/Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ/' => 'I', '/Ò|Ó|Ô|Õ|Ö|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ/' => 'O', '/Ù|Ú|Û|Ü|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ/' => 'U', '/Ç|Ć|Ĉ|Ċ|Č/' => 'C', '/Ð|Ď|Đ/' => 'D', '/Ĝ|Ğ|Ġ|Ģ/' => 'G', '/Ĥ|Ħ/' => 'H', '/Ĵ/' => 'J', '/Ķ/' => 'K', '/Ĺ|Ļ|Ľ|Ŀ|Ł/' => 'L', '/Ñ|Ń|Ņ|Ň/' => 'N', '/Ŕ|Ŗ|Ř/' => 'R', '/Ś|Ŝ|Ş|Š/' => 'S', '/Ţ|Ť|Ŧ/' => 'T', '/Ý|Ÿ|Ŷ/' => 'Y', '/Ź|Ż|Ž/' => 'Z', '/Ŵ/' => 'W', '/Æ|Ǽ/' => 'AE', '/ß/' => 'ss', '/IJ/' => 'IJ', '/Œ/' => 'OE', '/à|á|â|ã|ä|å|ǻ|ā|ă|ą|ǎ|ª/' => 'a', '/è|é|ê|ë|ē|ĕ|ė|ę|ě|&/' => 'e', '/ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı/' => 'i', '/ò|ó|ô|õ|ö|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º/' => 'o', '/ù|ú|û|ü|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ/' => 'u', '/ç|ć|ĉ|ċ|č/' => 'c', '/ð|ď|đ/' => 'd', '/ĝ|ğ|ġ|ģ/' => 'g', '/ĥ|ħ/' => 'h', '/ĵ/' => 'j', '/ķ/' => 'k', '/ĺ|ļ|ľ|ŀ|ł/' => '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');
开发者ID:TerrasAppSolutions,项目名称:seeg-mapbiomas-workspace,代码行数:31,代码来源:bootstrap.php
示例20: config
/**
* Sets protected properties based on config provided
*
* @param array $config Engine configuration
*
* @return array
*/
public function config($config = array())
{
parent::config($config);
if (!empty($config['path'])) {
$this->_path = $config['path'];
}
if (Configure::read('debug') && !is_dir($this->_path)) {
mkdir($this->_path, 0775, TRUE);
}
if (!empty($config['file'])) {
$this->_file = $config['file'];
if (substr($this->_file, -4) !== '.log') {
$this->_file .= '.log';
}
}
if (!empty($config['size'])) {
if (is_numeric($config['size'])) {
$this->_size = (int) $config['size'];
} else {
$this->_size = CakeNumber::fromReadableSize($config['size']);
}
}
return $this->_config;
}
开发者ID:mrbadao,项目名称:api-official,代码行数:31,代码来源:FileLog.php
注:本文中的CakeNumber类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论