rhushikeshc / clients-oriented-ftp

Automatically exported from code.google.com/p/clients-oriented-ftp
0 stars 0 forks source link

Sorting on client view in default template not working as expected #324

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Look at files in client view
2. Click on size
3. This orders alphanumerically not numerically

What is the expected output? What do you see instead?
expected sorted numerically
got orders alphanumerically 

What version of the product are you using? On what operating system?
r412  unix and windows

Please provide any additional information below.
I noticed that sorting on filesize on the default template 

I created myself a template based on the default with a specific thumbnail size.
I also wanted the filesize units be be the same on all files so I changed the 
function format_file_size

========================
/**
 * Receives the size of a file in bytes, and formats it for readability.
 * Used on files listings (templates and the files manager).
 */
function format_file_size($file,$d_type = "",$d_precision=2)
{
    /*I dislike the file sizes being in different units 
    in a client template view. I made this change to the function format_file_size
    Adding an extra parameter $d_type with default value of ""
    If this value is 
    kb the filesize is given in kilobyte
    mb the filesize is given in megabytes
    gd the filesize is given in gigabytes
    and added $d_precision to allow a precision change when specifying units

    For my files I use "mb" (as my files rairly go over 10mb)
    This now means that ordering on size works logically (as it is alphabetic not numeric)

    */
    switch(strtolower($d_type)){
        case "kb": echo round($file / 1024, $d_precision) . $d_type;break;
        case "mb": echo round($file / 1048576, $d_precision) . $d_type;break;
        case "gb": echo round($file / 1073741824, $d_precision) . $d_type;break;
    default : 
        if ($file < 1024) {
             /** No digits so put a ? much better than just seeing Byte */
            echo (ctype_digit($file))? $file . ' Byte' :  ' ? ' ;
        } elseif ($file < 1048576) {
            echo round($file / 1024, 2) . ' KB';
        } elseif ($file < 1073741824) {
            echo round($file / 1048576, 2) . ' MB';
        } elseif ($file < 1099511627776) {
            echo round($file / 1073741824, 2) . ' GB';
        } elseif ($file < 1125899906842624) {
            echo round($file / 1099511627776, 2) . ' TB';
        } elseif ($file < 1152921504606846976) {
            echo round($file / 1125899906842624, 2) . ' PB';
        } elseif ($file < 1180591620717411303424) {
            echo round($file / 1152921504606846976, 2) . ' EB';
        } elseif ($file < 1208925819614629174706176) {
            echo round($file / 1180591620717411303424, 2) . ' ZB';
        } else {
            echo round($file / 1208925819614629174706176, 2) . ' YB';
        }
    }
}

Original issue reported on code.google.com by AlanReib...@googlemail.com on 12 Jun 2013 at 9:22

GoogleCodeExporter commented 8 years ago
Hi which file have you edited?

Original comment by access_c...@hotmail.com on 23 Jun 2013 at 12:13

GoogleCodeExporter commented 8 years ago
sorry
the file edited is 

functions.php in includes

Original comment by AlanReib...@googlemail.com on 24 Jun 2013 at 8:37