Skip to content

Commit eb86dd7

Browse files
author
Dmytro Lukianenko
committed
Merge branch '3.2.x' into nightly
2 parents c6abcbd + 1acaf2e commit eb86dd7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+348
-306
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
# Composer
4242
/composer.phar
4343

44+
/vendor
4445
!/vendor/index.html
4546

4647
# IDE Helper
@@ -54,6 +55,7 @@ npm-debug.log
5455

5556
#docker
5657
/docker/nginx/logs/*
58+
/.env
5759

5860
# System
5961
ftpsync.settings

core/custom/define.php.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* - SESSION_COOKIE_PATH
77
* - SESSION_COOKIE_DOMAIN
88
* - SESSION_COOKIE_NAME
9-
* - MODX_CLASS
9+
* - EVO_CLASS
1010
* - EVO_CORE_PATH
1111
* - MODX_SITE_HOSTNAMES
1212
* - MGR_DIR

core/functions/actions/files.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ function ls($curpath, array $options = [])
160160
echo '<tr>';
161161
echo '<td>' . $dirs_array[$i]['text'] . '</td>';
162162
echo '<td class="text-nowrap">' . evolutionCMS()->toDateFormat($dirs_array[$i]['stats']['9']) . '</td>';
163-
echo '<td class="text-right">' . nicesize($dirs_array[$i]['stats']['7']) . '</td>';
163+
echo '<td class="text-right">' . niceSize($dirs_array[$i]['stats']['7']) . '</td>';
164164
echo '<td class="actions text-right">';
165165
echo $dirs_array[$i]['rename'];
166166
echo $dirs_array[$i]['delete'];
@@ -175,8 +175,8 @@ function ls($curpath, array $options = [])
175175
$filesizes += $files_array[$i]['stats']['7'];
176176
echo '<tr ' . markRow($files_array[$i]['file'], get_by_key($_REQUEST, 'path'), get_by_key($_REQUEST, 'mode')) . '>';
177177
echo '<td>' . $files_array[$i]['text'] . '</td>';
178-
echo '<td class="text-nowrap">' . evolutionCMS()->toDateFormat($files_array[$i]['stats']['9']) . '</td>';
179-
echo '<td class="text-right">' . nicesize($files_array[$i]['stats']['7']) . '</td>';
178+
echo '<td class="text-nowrap">' . evo()->toDateFormat($files_array[$i]['stats']['9']) . '</td>';
179+
echo '<td class="text-right">' . niceSize($files_array[$i]['stats']['7']) . '</td>';
180180
echo '<td class="actions text-right">';
181181
echo $files_array[$i]['unzip'];
182182
echo $files_array[$i]['view'];
@@ -425,7 +425,7 @@ function fileupload()
425425
if ($userfile['error'] == 0) {
426426
$img = (strpos($userfile['type'],
427427
'image') !== false) ? '<br /><img src="' . $path . '" height="75" />' : '';
428-
$msg .= "<p>" . $_lang['files_file_type'] . $userfile['type'] . ", " . nicesize(filesize($userfile['tmp_name'])) . $img . '</p>';
428+
$msg .= "<p>" . $_lang['files_file_type'] . $userfile['type'] . ", " . niceSize(filesize($userfile['tmp_name'])) . $img . '</p>';
429429
}
430430

431431
$userfilename = $userfile['tmp_name'];

core/functions/helper.php

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,23 +119,44 @@ function is_cli()
119119
}
120120
}
121121

122-
if (!function_exists('nicesize')) {
122+
if (!function_exists('niceSize')) {
123123
/**
124-
* @param $size
125-
* @return string
124+
* Format file size in human-readable format.
125+
*
126+
* Converts bytes to appropriate unit (B, KB, MB, GB, TB) with proper rounding.
127+
* Uses modern ISO/IEC 80000 standard formatting with uppercase units.
128+
*
129+
* @param int|float $size File size in bytes
130+
* @return string Formatted file size with unit
131+
*
132+
* @example
133+
* niceSize(1024); // "1 KB"
134+
* niceSize(1048576); // "1 MB"
135+
* niceSize(1536); // "1.5 KB"
136+
* niceSize(0); // "0 B"
126137
*/
127-
function nicesize($size)
138+
function niceSize($size)
128139
{
129-
$sizes = array('Tb' => 1099511627776, 'Gb' => 1073741824, 'Mb' => 1048576, 'Kb' => 1024, 'b' => 1);
130-
$precisions = count($sizes) - 1;
131-
foreach ($sizes as $unit => $bytes) {
132-
if ($size >= $bytes) {
133-
return number_format($size / $bytes, $precisions).' '.$unit;
134-
}
135-
$precisions--;
140+
$units = ['B', 'KB', 'MB', 'GB', 'TB'];
141+
$unitIndex = 0;
142+
143+
while ($size >= 1024 && $unitIndex < count($units) - 1) {
144+
$size /= 1024;
145+
$unitIndex++;
136146
}
137147

138-
return '0 b';
148+
return round($size, 2) . ' ' . $units[$unitIndex];
149+
}
150+
}
151+
152+
if (!function_exists('nicesize')) {
153+
/**
154+
* @deprecated since EVO 3.2.7, use niceSize()
155+
* @TODO: will be delete EVO 3.5
156+
*/
157+
function nicesize($size)
158+
{
159+
return niceSize($size);
139160
}
140161
}
141162

0 commit comments

Comments
 (0)