remove WebGUI::Utility::formatBytes
This commit is contained in:
parent
42784e1b98
commit
006a5003c2
8 changed files with 13 additions and 39 deletions
|
|
@ -17,7 +17,7 @@ package WebGUI::Asset::File;
|
|||
use strict;
|
||||
use Carp;
|
||||
|
||||
|
||||
use Number::Format ();
|
||||
use Moose;
|
||||
use WebGUI::Definition::Asset;
|
||||
extends 'WebGUI::Asset';
|
||||
|
|
@ -573,7 +573,7 @@ sub view {
|
|||
$var{controls} = $self->getToolbar;
|
||||
$var{fileUrl} = $self->getFileUrl;
|
||||
$var{fileIcon} = $self->getFileIconUrl;
|
||||
$var{fileSize} = formatBytes($self->get("assetSize"));
|
||||
$var{fileSize} = Number::Format::format_bytes($self->get("assetSize"));
|
||||
my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate});
|
||||
if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) {
|
||||
$self->session->cache->set($self->getViewCacheKey, $out, $self->get("cacheTimeout"));
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ has '+uiLevel' => (
|
|||
);
|
||||
|
||||
use WebGUI::Utility;
|
||||
use Number::Format ();
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -237,7 +238,7 @@ sub view {
|
|||
title => $child->title,
|
||||
menuTitle => $child->menuTitle,
|
||||
synopsis => $child->synopsis || '',
|
||||
size => WebGUI::Utility::formatBytes($child->assetSize),
|
||||
size => Number::Format::format_bytes($child->assetSize),
|
||||
"date.epoch" => $child->revisionDate,
|
||||
"icon.small" => $child->getIcon(1),
|
||||
"icon.big" => $child->getIcon,
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ package WebGUI::Asset;
|
|||
=cut
|
||||
|
||||
use strict;
|
||||
use WebGUI::Utility qw(formatBytes);
|
||||
use Number::Format ();
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -593,7 +593,7 @@ sub www_manageClipboard {
|
|||
."','" . $plus . "<a href=\"".$child->getUrl("op=assetManager")."\">" . $title
|
||||
."</a>','<p style=\"display:inline;vertical-align:middle;\"><img src=\"".$child->getIcon(1)."\" style=\"border-style:none;vertical-align:middle;\" alt=\"".$child->getName."\" /></p> ".$child->getName
|
||||
."','".$self->session->datetime->epochToHuman($child->get("revisionDate"))
|
||||
."','".formatBytes($child->get("assetSize"))."');\n";
|
||||
."','".Number::Format::format_bytes($child->get("assetSize"))."');\n";
|
||||
$output .= "assetManager.AddLineSortData('','".$title."','".$child->getName
|
||||
."','".$child->get("revisionDate")."','".$child->get("assetSize")."');\n";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,8 @@ package WebGUI::Asset;
|
|||
=cut
|
||||
|
||||
use strict;
|
||||
use WebGUI::Utility qw(isIn formatBytes);
|
||||
use WebGUI::Utility qw(isIn);
|
||||
use Number::Format ();
|
||||
use JSON;
|
||||
|
||||
=head1 NAME
|
||||
|
|
@ -437,7 +438,7 @@ sub www_manageTrash {
|
|||
.'" style="vertical-align:middle;border-style:none;" alt='
|
||||
.$child->getName .'" /></p> ' . $child->getName,
|
||||
$self->session->datetime->epochToHuman($child->get("revisionDate")),
|
||||
formatBytes($child->get("assetSize"))
|
||||
Number::Format::format_bytes($child->get("assetSize"))
|
||||
);
|
||||
$amethod->('AddLineSortData',
|
||||
'', $title, $child->getName,
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use WebGUI::Paginator;
|
|||
use WebGUI::Utility;
|
||||
use WebGUI::Macro::AdminBar;
|
||||
use Tie::IxHash;
|
||||
use Number::Format ();
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -651,7 +652,7 @@ sub www_search {
|
|||
revisionDate => $session->datetime->epochToHuman( $asset->get( "revisionDate" ) ),
|
||||
hasChildren => ( $asset->hasChildren ? "+ " : " " ),
|
||||
rank => $asset->getRank,
|
||||
size => formatBytes( $asset->get( 'assetSize' ) ),
|
||||
size => Number::Format::format_bytes( $asset->get( 'assetSize' ) ),
|
||||
);
|
||||
|
||||
# The asset icon
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ use Net::CIDR::Lite;
|
|||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(&isBetween &makeTabSafe &makeArrayTabSafe &randomizeHash &commify &randomizeArray &isInSubnet
|
||||
&formatBytes &sortHashDescending &sortHash &isIn &makeCommaSafe &makeArrayCommaSafe &randint &round &scalarEquals
|
||||
&sortHashDescending &sortHash &isIn &makeCommaSafe &makeArrayCommaSafe &randint &round &scalarEquals
|
||||
);
|
||||
|
||||
|
||||
|
|
@ -39,7 +39,6 @@ This package provides miscellaneous but useful utilities to the WebGUI programme
|
|||
|
||||
use WebGUI::Utility;
|
||||
$string = commify($integer);
|
||||
$size = formatBytes($integer);
|
||||
$boolean = isBetween($value, $first, $second);
|
||||
$boolean = isIn($value, @array);
|
||||
$boolean = isInSubnet($ip, \@subnets);
|
||||
|
|
@ -92,30 +91,6 @@ sub emailRegex {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 formatBytes ( integer )
|
||||
|
||||
Returns a formatted file size like "3MB" or "44kB".
|
||||
|
||||
=head3 integer
|
||||
|
||||
An integer representing the number of bytes to format.
|
||||
|
||||
=cut
|
||||
|
||||
sub formatBytes {
|
||||
my $size = shift;
|
||||
if ($size > 1048576) {
|
||||
return round($size/1048576).' MB';
|
||||
} elsif ($size > 1024) {
|
||||
return round($size/1024).' kB';
|
||||
} else {
|
||||
return $size.' B';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isBetween ( value, first, second )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue