Skip to content
This repository has been archived by the owner on Dec 4, 2019. It is now read-only.

Commit

Permalink
Implement HTML::number_format macro
Browse files Browse the repository at this point in the history
  • Loading branch information
daris committed Aug 9, 2012
1 parent 485d525 commit 04ef97a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
8 changes: 8 additions & 0 deletions helpers/html.php
Expand Up @@ -99,3 +99,11 @@
return $date.' '.gmdate($time_format, $timestamp);
}
});

//
// A wrapper for PHP's number_format function
//
HTML::macro('number_format', function($number, $decimals = 0)
{
return is_numeric($number) ? number_format($number, $decimals, __('fluxbb::common.lang_decimal_point'), __('fluxbb::common.lang_thousands_sep')) : $number;
});
4 changes: 4 additions & 0 deletions language/en/common.php
Expand Up @@ -2,6 +2,10 @@

return array(

// Number formatting
'lang_decimal_point' => '.',
'lang_thousands_sep' => ',',

'index' => 'Index',
'user_list' => 'User list',
'rules' => 'Rules',
Expand Down
8 changes: 4 additions & 4 deletions views/index.blade.php
Expand Up @@ -42,7 +42,7 @@
?>
<tr class="row{{ HTML::oddeven() }}">
<td class="tcl">
<div class="{{ $icon_type }}"><div class="nosize">{{ number_format($forum_count) }}</div></div><!-- forum_number_format -->
<div class="{{ $icon_type }}"><div class="nosize">{{ HTML::number_format($forum_count) }}</div></div>
<div class="tclcon">
<div>
<?php
Expand Down Expand Up @@ -70,8 +70,8 @@
</div>
</div>
</td>
<td class="tc2">{{ number_format($forum->num_topics()) }}</td><!-- forum_number_format -->
<td class="tc3">{{ number_format($forum->num_posts()) }}</td><!-- here too -->
<td class="tc2">{{ HTML::number_format($forum->num_topics()) }}</td>
<td class="tc3">{{ HTML::number_format($forum->num_posts()) }}</td>
<td class="tcr">{{ $last_post }}</td>
</tr>
@endforeach
Expand All @@ -81,4 +81,4 @@
</div>
</div>
@endforeach
@endsection
@endsection
4 changes: 2 additions & 2 deletions views/viewforum.blade.php
Expand Up @@ -31,7 +31,7 @@
?>
<tr class="row{{ HTML::oddeven() }}">
<td class="tcl">
<div class="{{ $icon_type }}"><div class="nosize">{{ number_format($topic_count + $start_from) }}</div></div><!-- TODO: forum_number_format() -->
<div class="{{ $icon_type }}"><div class="nosize">{{ HTML::number_format($topic_count + $start_from) }}</div></div>
<div class="tclcon">
<div>
<a href="{{ URL::to_action('fluxbb::home@topic', array($topic->id)) }}">{{ e($topic->subject) }}</a> <span class="byuser">{{ __('fluxbb::common.by', array('author' => e($topic->poster))) }}</span>
Expand All @@ -54,4 +54,4 @@
</div>
</div>

@endsection
@endsection
4 changes: 2 additions & 2 deletions views/viewtopic.blade.php
Expand Up @@ -29,7 +29,7 @@
<dd><span>{{ __('fluxbb::topic.from', array('name' => e($post->poster->location))) }}</span></dd>
@endif
<dd><span>{{ __('fluxbb::topic.registered', array('time' => HTML::format_time($post->poster->registered, true))) }}</span></dd>
<dd><span>{{ __('fluxbb::topic.posts', array('count' => number_format($post->poster->num_posts))) }}</span></dd> <!-- TODO: forum_number_format -->
<dd><span>{{ __('fluxbb::topic.posts', array('count' => HTML::number_format($post->poster->num_posts))) }}</span></dd>
<dd><span><a href="{{ URL::to_action('fluxbb::moderate@host', array($post->id)) }}" title="{{ $post->poster->ip }}">{{ __('fluxbb::topic.ip') }}</a></span></dd>
@if ($post->poster->has_admin_note())
<dd><span>{{ __('fluxbb::topic.note') }} <strong>{{ e($post->poster->admin_note) }}</strong></span></dd>
Expand Down Expand Up @@ -87,4 +87,4 @@
</div>
@endforeach

@endsection
@endsection

1 comment on commit 04ef97a

@franzliedke
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. Thank you for doing that.

Please sign in to comment.