本文整理汇总了PHP中Num::format方法的典型用法代码示例。如果您正苦于以下问题:PHP Num::format方法的具体用法?PHP Num::format怎么用?PHP Num::format使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Num
的用法示例。
在下文中一共展示了Num::format方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_browse
/**
* Action: browse tracks
*/
public function action_browse()
{
$type = $this->request->param('music') == 'mixtapes' ? Model_Music_Track::TYPE_MIX : Model_Music_Track::TYPE_TRACK;
$genre = $this->request->param('genre');
// Load requested music
$limit = 25;
$music = Model_Music_Track::factory();
$count = $music->count_by_type($type, $genre);
// Build page
$this->view = View_Page::factory($type == Model_Music_Track::TYPE_MIX ? __('Mixtapes') : __('Tracks'));
// Set actions
$this->_set_page_actions();
$this->view->tab = $this->request->param('music');
// Filters
$this->view->add(View_Page::COLUMN_CENTER, $this->section_filters($this->request->param('music'), $genre));
// Pagination
$this->view->add(View_Page::COLUMN_CENTER, $pagination = $this->section_pagination($limit, $count));
$this->view->subtitle = __($pagination->total_pages == 1 ? ':pages page' : ':pages pages', array(':pages' => Num::format($pagination->total_pages, 0)));
// Browse
$tracks = $music->find_by_type($type, $genre, $limit, $pagination->offset);
$this->view->add(View_Page::COLUMN_CENTER, $this->section_browse($tracks));
// Pagination
$this->view->add(View_Page::COLUMN_CENTER, $pagination);
// New
$this->view->add(View_Page::COLUMN_RIGHT, $this->section_list($music->find_new(Model_Music_Track::TYPE_MIX, 10), __('New mixtapes')));
$this->view->add(View_Page::COLUMN_RIGHT, $this->section_list($music->find_new(Model_Music_Track::TYPE_TRACK, 10), __('New tracks')));
}
示例2: verbose
public function verbose($value)
{
$value = $this->value($value);
if ($this->decimals) {
$value = Num::format($value, $this->decimals);
}
return (string) $value;
}
示例3: test_format
/**
* @see Num::format
*/
public function test_format()
{
$output = Num::format('1234567890', '(000) 000-0000');
$expected = '(123) 456-7890';
$this->assertEquals($expected, $output);
$output = Num::format(null, '(000) 000-0000');
$this->assertNull($output);
$output = Num::format('1234567890', null);
$expected = '1234567890';
$this->assertEquals($expected, $output);
}
示例4: currency
/**
* Get currency based on date. Used for currency chances such as Euro.
*
* @static
* @param float $amount
* @param integer $date
* @return string
*/
public static function currency($amount, $date = null)
{
static $change;
// Show decimals only if required
$amount = $amount == (int) $amount ? (int) $amount : Num::format($amount, 2, true);
// Finland switched to Euro on January 1st, 2002
if (!$change) {
$change = mktime(0, 0, 0, 1, 1, 2002);
}
$currency = !$date || $date >= $change ? '€' : 'mk';
return $amount . $currency;
}
示例5: content
/**
* Render view.
*
* @return string
*/
public function content()
{
ob_start();
// Title
if ($this->area->description) {
echo $this->area->description . '<hr>';
}
if ($this->area->topic_count) {
// Area has topics
$last_topic = $this->area->last_topic();
$last_poster = $last_topic->last_post()->author();
?>
<div class="media">
<div class="pull-left">
<?php
echo HTML::avatar($last_poster ? $last_poster['avatar'] : null, $last_poster ? $last_poster['username'] : null, false);
?>
</div>
<div class="media-body">
<small class="ago"><?php
echo HTML::time(Date::short_span($last_topic->last_posted, true, true), $last_topic->last_posted);
?>
</small>
<?php
echo $last_poster ? HTML::user($last_poster) : HTML::chars($last_topic->last_poster);
?>
<br>
<?php
echo HTML::anchor(Route::model($last_topic, '?page=last#last'), Forum::topic($last_topic), array('title' => HTML::chars($last_topic->name)));
?>
<br />
</div>
</div>
<small class="stats muted">
<i class="icon-comments"></i> <?php
echo Num::format($this->area->topic_count, 0);
?>
<i class="icon-comment"></i> <?php
echo Num::format($this->area->post_count, 0);
?>
</small>
<?php
} else {
// Empty area
echo __('No topics yet.');
}
return ob_get_clean();
}
示例6: rules
public function rules()
{
return ['amount' => function ($value) {
if ($value <= 0) {
return 'Еще нет средств на расход';
}
$amount = $this->model('Salary')->getReady();
$amount = intval($amount);
$value = intval($value);
if ($amount !== $value) {
return 'Сумма изменилась должно быть:' . \Num::format($amount);
}
}];
}
示例7: rules
public function rules()
{
return ['out' => function ($value) {
$salary = $this->salary;
$out = $salary['out'] + $salary['balance'];
// должно быть всего выдано
$_balance = $this->getData('balance', 0);
if (!empty($value)) {
if ($value > $out) {
return 'нельзя выдать больше чем должно быть ' . \Num::format($out);
}
}
/*$summa = $value + $_balance;
if($summa != $out){
return 'Сумма Выдано + Осталось выдать НЕ Совпадает ('.\Num::format($out-$_balance).'), должно быть '.\Num::format($out);
}*/
}];
}
示例8: pretty_format
static function pretty_format($price, $valute = NULL, $discount = NULL)
{
if ($valute === 'LVL' or $valute === NULL) {
if ($discount !== NULL) {
return Num::format($price / 100 - $price / 100 * ($discount / 100), 2) . ' ls';
}
return Num::format($price / 100, 2) . ' Ls';
} elseif ($valute === 'EUR') {
if ($discount !== NULL) {
return '€' . Num::format(($price / 100 - $price / 100 * ($discount / 100)) / 0.7, 2);
}
return '€' . Num::format($price / 100 / 0.7, 2);
} elseif ($valute === 'USD') {
if ($discount !== NULL) {
return Num::format(($price / 100 - $price / 100 * ($discount / 100)) / 0.57, 2);
}
return '$ ' . Num::format($price / 100 / 0.57, 2);
}
}
示例9: topic
/**
* Get prefixed forum title.
*
* @static
* @param Model_Forum_Topic $topic
* @return string
*/
public static function topic(Model_Forum_Topic $topic)
{
$prefix = array();
// Private topic
if ($topic->recipient_count) {
$prefix[] = $topic->recipient_count > 2 ? '<i class="fa fa-group text-muted" title="' . __(':recipients recipients', array(':recipients' => Num::format($topic->recipient_count, 0))) . '"></i>' : '<i class="fa fa-envelope text-muted" title="' . __('Personal message') . '"></i>';
}
// Stickyness
if ($topic->sticky) {
$prefix[] = '<i class="fa fa-thumb-tack text-warning" title="' . __('Pinned') . '"></i>';
}
// Status
switch ($topic->status) {
case Model_Forum_Topic::STATUS_LOCKED:
$prefix[] = '<i class="fa fa-lock text-muted" title="' . __('Locked') . '"></i>';
break;
case Model_Forum_Topic::STATUS_SINK:
$prefix[] = '<i class="fa fa-unlock text-muted" title="' . __('Sink') . '"></i>';
break;
}
return implode(' ', $prefix) . ' ' . HTML::chars($topic->name);
}
示例10: render
/**
* Render view.
*
* @return string
*/
public function render()
{
ob_start();
$rating = $this->count ? $this->total / $this->count : 0;
?>
<span class="rating">
<?php
for ($r = 1; $r <= 5; $r++) {
?>
<i class="<?php
echo $rating >= $r - 0.5 ? 'icon-star' : 'icon-star-empty';
?>
icon-white" title="<?php
echo $r;
?>
"></i>
<?php
}
?>
<?php
if ($this->score) {
?>
<var title="<?php
echo __($this->count == 1 ? ':rates rating' : ':rates ratings', array(':rates' => $this->count));
?>
"><?php
echo Num::format($rating, 2);
?>
</var>
<?php
}
?>
</span>
<?php
return ob_get_clean();
}
示例11: foreach
$i = 1;
foreach ($products as $product) {
?>
<tr>
<td><?php
echo $product->title;
?>
</td>
<td><strong class="text-highlighted"><?php
echo $products_data[$product->id_product]['customers'];
?>
</strong></td>
<td>
<strong class="text-highlighted">
<?php
echo $num_format == 'MONEY' ? i18n::format_currency($products_data[$product->id_product]['total']) : Num::format($products_data[$product->id_product]['total'], 0);
?>
</strong>
</td>
<td class="col-xs-2">
<div class="progress">
<div class="progress-bar" style="width: <?php
echo $current_total > 0 ? number_format($products_data[$product->id_product]['total'] / $current_total * 100, 2) : 0;
?>
%;">
</div>
</div>
</td>
</tr>
<?php
}
示例12: action_index
/**
* Action: index
*/
public function action_index()
{
// Go to post?
$topic_id = (int) $this->request->param('topic_id');
if ($topic_id) {
$post_id = (int) $this->request->param('id');
} else {
$topic_id = (int) $this->request->param('id');
}
// Load topic
/** @var Model_Forum_Private_Topic|Model_Forum_Topic $topic */
$topic = $this->private ? Model_Forum_Private_Topic::factory($topic_id) : Model_Forum_Topic::factory($topic_id);
if (!$topic->loaded()) {
throw new Model_Exception($topic, $topic_id);
}
Permission::required($topic, Model_Forum_Topic::PERMISSION_READ, self::$user);
// Did we request single post with ajax?
if (($this->ajax || $this->internal) && isset($post_id)) {
$this->history = false;
$post = $this->private ? Model_Forum_Private_Post::factory($post_id) : Model_Forum_Post::factory($post_id);
if (!$post->loaded()) {
throw new Model_Exception($topic, $topic_id);
}
// Permission is already checked by the topic, no need to check for post
$this->response->body($this->section_post($topic, $post));
return;
}
// Update counts
if ($this->private) {
$topic->mark_as_read(self::$user);
}
if (!self::$user || $topic->author_id != self::$user->id) {
$topic->read_count++;
$topic->save();
}
// Build page
$this->view = new View_Page();
$this->view->title_html = Forum::topic($topic);
$this->view->subtitle = __($topic->post_count == 1 ? ':posts post' : ':posts posts', array(':posts' => Num::format($topic->post_count, 0)));
$this->view->tab = 'topic';
$this->page_actions['topic'] = array('link' => Route::model($topic), 'text' => '<i class="icon-comment icon-white"></i> ' . __('Topic'));
// Public topic extras
if (!$this->private) {
// Quotes are supported only in public forum as we get notifications anyway in private
if (self::$user) {
$quotes = Model_Forum_Quote::factory()->find_by_user(self::$user);
if (count($quotes)) {
foreach ($quotes as $quote) {
if ($topic->id == $quote->forum_topic_id) {
$quote->delete();
break;
}
}
}
}
// Facebook
if (Kohana::$config->load('site.facebook')) {
Anqh::open_graph('title', $topic->name);
Anqh::open_graph('url', URL::site(Route::url('forum_topic', array('id' => $topic->id, 'action' => '')), true));
}
Anqh::share(true);
// Model binding
$area = $topic->area();
if ($area->type == Model_Forum_Area::TYPE_BIND && $topic->bind_id) {
if ($bind = Model_Forum_Area::get_binds($area->bind)) {
$model = AutoModeler::factory($bind['model'], $topic->bind_id);
if ($model->loaded()) {
// Set actions
$this->page_actions[] = array('link' => Route::model($model), 'text' => $bind['link']);
// Set views
foreach ((array) $bind['view'] as $view) {
$this->view->add(View_Page::COLUMN_SIDE, View_Module::factory($view, array($bind['model'] => $model)), Widget::TOP);
}
}
}
}
}
// Public topic extras
// Set actions
if (Permission::has($topic, Model_Forum_Topic::PERMISSION_POST, self::$user)) {
$this->view->actions[] = array('link' => Request::current_uri() . '#reply', 'text' => '<i class="icon-comment icon-white"></i> ' . __('Reply to topic'), 'class' => 'btn btn-primary topic-post');
}
if (Permission::has($topic, Model_Forum_Topic::PERMISSION_UPDATE, self::$user)) {
$this->view->actions[] = array('link' => Route::model($topic, 'edit'), 'text' => '<i class="icon-edit icon-white"></i> ' . __('Edit topic'));
}
// Breadcrumbs
$this->page_breadcrumbs[] = HTML::anchor(Route::url('forum_group'), __('Forum'));
$this->page_breadcrumbs[] = HTML::anchor(Route::model($topic->area()), $topic->area()->name);
// Pagination
$this->view->add(View_Page::COLUMN_MAIN, $pagination = $this->section_pagination($topic));
$this->view->subtitle .= ', ' . __($pagination->total_pages == 1 ? ':pages page' : ':pages pages', array(':pages' => Num::format($pagination->total_pages, 0)));
$this->view->subtitle .= ', ' . __($topic->read_count == 1 ? ':views view' : ':views views', array(':views' => Num::format($topic->read_count, 0)));
// Go to post?
if (isset($post_id)) {
$pagination->item($topic->get_post_number($post_id) + 1);
// We need to set pagination urls manually if jumped to a post
$pagination->base_url = Route::model($topic);
//.........这里部分代码省略.........
示例13: test_format
/**
* @todo test locales
* @test
* @dataProvider provider_format
* @param integer $number
* @param integer $places
* @param boolean $monetary
* @param string $expected
*/
public function test_format($number, $places, $monetary, $expected)
{
$this->assertSame($expected, Num::format($number, $places, $monetary));
}
示例14: array
<div class="statcard statcard-success">
<a href="<?php
echo Route::url('oc-panel', array('controller' => Request::current()->controller(), 'action' => 'tickets_closed'));
?>
?<?php
echo http_build_query(['rel' => ''] + Request::current()->query());
?>
" class="display-block">
<div class="p-a">
<span class="statcard-desc"><?php
echo __('Tickets Closed');
?>
</span>
<h2 class="statcard-number">
<?php
echo Num::format($tickets_closed_total, 0);
?>
<small class="delta-indicator <?php
echo Num::percent_change($tickets_closed_total, $tickets_closed_total_past) < 0 ? 'delta-negative' : 'delta-positive';
?>
"><?php
echo Num::percent_change($tickets_closed_total, $tickets_closed_total_past);
?>
</small>
<small class="ago"><?php
echo sprintf(__('%s days ago'), $days_ago);
?>
</small>
</h2>
<hr class="statcard-hr">
</div>
示例15:
<form action="<?php
echo URL::site('acp/products/item/' . $product->id . '/' . Security::token());
?>
" method="post">
<table>
<tr>
<th>Nosaukums</th>
<td><input type="text" name="name" value="<?php
echo $product->name;
?>
" /></td>
</tr>
<tr>
<th>Cena (Bez atlaides)</th>
<td><input type="text" name="price" value="<?php
echo Num::format($product->price / 100, 2);
?>
" /></td>
</tr>
<?php
if ($product->is_discount == 1) {
?>
<tr>
<th>Cena (Ar atlaidi)</th>
<td><?php
echo Currency::pretty_format($product->price, $product->discount);
?>
</td>
</tr>
<tr>
<th>Atlaide <input checked="checked" type="checkbox" name="is_discount" /></th>