/** * This test is to check whether messages get actually translated to non-english * * @dataProvider languages * @param $language */ public function testSizeFormatTranslation($language) { $formatter = new CFormatter(); Yii::app()->language = $language; $this->assertNotEquals('1 byte', $formatter->formatSize(1, true)); $this->assertNotEquals('1 kilobyte', $formatter->formatSize(1024, true)); $this->assertNotEquals('1 megabyte', $formatter->formatSize(1024 * 1024, true)); $this->assertNotEquals('1 gigabyte', $formatter->formatSize(1024 * 1024 * 1024, true)); $this->assertNotEquals('1 terabyte', $formatter->formatSize(1024 * 1024 * 1024 * 1024, true)); // test sizeformat works with non integers $formatter->sizeFormat['decimals'] = 4; $this->assertNotEquals('1.5137 kilobytes', $formatter->formatSize(1550, true)); }
public function getFormattedBytes() { $formatter = new CFormatter(); return $formatter->formatSize(filesize("upload/" . $this->filename_local)); }
function GetMaxUploadFileSize() { $val = trim(ini_get("post_max_size")); $last = strtolower($val[strlen($val) - 1]); switch ($last) { case 'g': $val *= 1024; case 'm': $val *= 1024; case 'k': $val *= 1024; } return $val; } $formatter = new CFormatter(); $UploadLimit = $formatter->formatSize(GetMaxUploadFileSize()); ?> <div class="container"> <div class="row"> <div class="col-xs-12"> <h2><?php print $data->name; ?> </h2> </div> </div> <?php if (Yii::app()->user->getId()) { ?>