Pluf Framework

Pluf Framework Commit Details


Date:2009-02-16 08:41:48 (16 years 2 months ago)
Author:Jürgen Hörmann
Branch:develop, master
Commit:87e1528eb760aefe24f77a0b498275fc21de8b03
Parents: 743b11ec5076fba1e152913b1636974fa20a8248
Message:Added the handling of the k, m and g suffixes in the pretty size.

PHP allows for the configuration sizes to be set with k, m or g suffix, like 3m for 3MB. This patch
correctly handle these cases.
Changes:

File differences

src/Pluf/Utils.php
8484
8585
8686
87
88
89
87
88
89
90
91
92
93
94
95
96
97
98
99
90100
91101
92102
    static function prettySize($size)
    {
        $mb = 1024*1024;
        if ($size > $mb) {
            $mysize = sprintf('%01.2f', $size/$mb).' '. __('MB');
    switch (strtolower(substr($size, -1))) {
        case 'k':
            $size = substr($size, 0, -1) * 1024;
    break;
        case 'm':
            $size = substr($size, 0, -1) * 1024*1024;
    break;
        case 'g':
            $size = substr($size, 0, -1) * 1024*1024*1024;
    break;
    }
        if ($size > (1024*1024)) {
            $mysize = sprintf('%01.2f', $size/(1024*1024)).' '. __('MB');
        } elseif ($size >= 1024) {
            $mysize = sprintf('%01.2f', $size/1024).' '.__('kB');
        } else {

Archive Download the corresponding diff file

Branches

Tags

Number of commits:
Page rendered in 0.15503s using 13 queries.