1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

xen:number size limited to mb?

Discussion in 'XenForo Development Discussions' started by Farjad, Aug 7, 2011.

  1. Farjad

    Farjad Member

    hello,

    i'm not sure if this has been asked before but i couldn't find anything.

    when adding in template: {xen:number $var, size} I seem to get stuck in "MB" and nothing higher. I was wondering if it was possible to make it go up to GB, TB, PB, etc. Or is there another function I could use in template --- I don't want to pre-render it cause I'd have to go through entire arrays then.
     
  2. Farjad

    Farjad Member

    bump. anyone?
     
  3. Farjad

    Farjad Member

    Just found it:

    XenForo_Locale.php
    PHP:
        public static function numberFormat($number$precision 0, array $language null)
        {
            if (!
    $language)
            {
                
    $language self::$_language;
            }

            if (!
    $language)
            {
                
    $decimalSep '.';
                
    $thousandsSep ',';
            }
            else
            {
                
    $decimalSep $language['decimal_point'];
                
    $thousandsSep $language['thousands_separator'];
            }

            if (
    $precision === 'size')
            {
                
    // TODO: this may need to be language dependent
                
    if ($number >= 1048576// 1 MB
                
    {
                    
    $number number_format($number 10485761$decimalSep$thousandsSep);
                    
    $unit ' MB';
                }
                else if (
    $number >= 1024// 1KB
                
    {
                    
    $number number_format($number 10241$decimalSep$thousandsSep);
                    
    $unit ' KB';
                }
                else
                {
                    
    $number number_format($number1$decimalSep$thousandsSep);
                    
    $unit ' bytes';
                }

                
    // return $number, not $number.0 when the decimal is 0.
                
    if (substr($number, -2) == '.0')
                {
                    
    $number substr($number0, -2);
                }

                return 
    $number $unit;
            }
            else
            {
                return 
    number_format($number$precision$decimalSep$thousandsSep);
            }
        }
    now, i can't override the size part of it without editing it, anyway of knowing this will include sizes bigger than MB in future xf releases? (or ability to make a code event listener on xenforo_locale)
     

Share This Page