/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk

« back to all changes in this revision

Viewing changes to codeigniter/system/helpers/number_helper.php

  • Committer: galaxyAbstractor
  • Date: 2013-04-10 15:49:32 UTC
  • mto: (19.1.5 lenasys)
  • mto: This revision was merged to the branch mainline in revision 23.
  • Revision ID: galaxyabstractor@gmail.com-20130410154932-4vizlzk0ar5gykvi
* Added an simple admin panel to the codeviewer-cmssy stuff
* Redesigned a bit like the mockups - still stuff to come
* Implemented the codeviewer + admin panel again using the Framework CodeIgniter instead 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
2
/**
 
3
 * CodeIgniter
 
4
 *
 
5
 * An open source application development framework for PHP 5.1.6 or newer
 
6
 *
 
7
 * @package             CodeIgniter
 
8
 * @author              ExpressionEngine Dev Team
 
9
 * @copyright   Copyright (c) 2008 - 2011, EllisLab, Inc.
 
10
 * @license             http://codeigniter.com/user_guide/license.html
 
11
 * @link                http://codeigniter.com
 
12
 * @since               Version 1.0
 
13
 * @filesource
 
14
 */
 
15
 
 
16
// ------------------------------------------------------------------------
 
17
 
 
18
/**
 
19
 * CodeIgniter Number Helpers
 
20
 *
 
21
 * @package             CodeIgniter
 
22
 * @subpackage  Helpers
 
23
 * @category    Helpers
 
24
 * @author              ExpressionEngine Dev Team
 
25
 * @link                http://codeigniter.com/user_guide/helpers/number_helper.html
 
26
 */
 
27
 
 
28
// ------------------------------------------------------------------------
 
29
 
 
30
/**
 
31
 * Formats a numbers as bytes, based on size, and adds the appropriate suffix
 
32
 *
 
33
 * @access      public
 
34
 * @param       mixed   // will be cast as int
 
35
 * @return      string
 
36
 */
 
37
if ( ! function_exists('byte_format'))
 
38
{
 
39
        function byte_format($num, $precision = 1)
 
40
        {
 
41
                $CI =& get_instance();
 
42
                $CI->lang->load('number');
 
43
 
 
44
                if ($num >= 1000000000000)
 
45
                {
 
46
                        $num = round($num / 1099511627776, $precision);
 
47
                        $unit = $CI->lang->line('terabyte_abbr');
 
48
                }
 
49
                elseif ($num >= 1000000000)
 
50
                {
 
51
                        $num = round($num / 1073741824, $precision);
 
52
                        $unit = $CI->lang->line('gigabyte_abbr');
 
53
                }
 
54
                elseif ($num >= 1000000)
 
55
                {
 
56
                        $num = round($num / 1048576, $precision);
 
57
                        $unit = $CI->lang->line('megabyte_abbr');
 
58
                }
 
59
                elseif ($num >= 1000)
 
60
                {
 
61
                        $num = round($num / 1024, $precision);
 
62
                        $unit = $CI->lang->line('kilobyte_abbr');
 
63
                }
 
64
                else
 
65
                {
 
66
                        $unit = $CI->lang->line('bytes');
 
67
                        return number_format($num).' '.$unit;
 
68
                }
 
69
 
 
70
                return number_format($num, $precision).' '.$unit;
 
71
        }
 
72
}
 
73
 
 
74
 
 
75
/* End of file number_helper.php */
 
76
/* Location: ./system/helpers/number_helper.php */
 
 
b'\\ No newline at end of file'