Version 4.1.19

This commit is contained in:
Neo committed 2025-12-19 05:38:56 -08:00
1 parent 28bd025b35
commit 2bd5025018
2674 files changed
+233518 -77766

No files matched your search

+31 -16
View File
@@ -2,9 +2,9 @@
/**
* @brief Template Plugin - Filesize
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 18 Nov 2013
* @version SVN_VERSION_NUMBER
*/
@@ -46,9 +46,10 @@ class _Filesize
* @param int $sizeInBytes Size in bytes
* @param bool $decimal If TRUE, will calculate based on decimal figures rather than binary
* @param bool $json If TRUE, will format for json
* @param bool $get If TRUE, will get the language string rather than add to stack
* @return string
*/
public static function humanReadableFilesize( $sizeInBytes, $decimal=FALSE, $json=FALSE )
public static function humanReadableFilesize( $sizeInBytes, $decimal=FALSE, $json=FALSE, $get=FALSE )
{
$sizeInBytes = floatval( $sizeInBytes );
@@ -57,24 +58,38 @@ class _Filesize
$raised = $decimal ? pow( 1000, $pow / 10 ) : pow( 2, $pow );
if ( $sizeInBytes >= $raised )
{
$format = array( 'sprintf' => round( ( $sizeInBytes / $raised ), 1 ) );
if( $json === TRUE )
if ( $get )
{
$format['json'] = TRUE;
return sprintf( \IPS\Member::loggedIn()->language()->get( 'filesize_' . $sig ), round( ( $sizeInBytes / $raised ), 2 ) );
}
else
{
$format = array( 'sprintf' => round( ( $sizeInBytes / $raised ), 2 ) );
if( $json === TRUE )
{
$format['json'] = TRUE;
}
return \IPS\Member::loggedIn()->language()->addToStack( 'filesize_' . $sig, FALSE, $format );
}
return \IPS\Member::loggedIn()->language()->addToStack( 'filesize_' . $sig, FALSE, $format );
}
}
$format = array( 'sprintf' => $sizeInBytes );
if( $json === TRUE )
if ( $get )
{
$format['json'] = TRUE;
return sprintf( \IPS\Member::loggedIn()->language()->get( 'filesize_b' ), $sizeInBytes );
}
else
{
$format = array( 'sprintf' => $sizeInBytes );
if( $json === TRUE )
{
$format['json'] = TRUE;
}
return \IPS\Member::loggedIn()->language()->addToStack( 'filesize_b', FALSE, $format );
}
return \IPS\Member::loggedIn()->language()->addToStack( 'filesize_b', FALSE, $format );
}
}