Skip to content
Snippets Groups Projects
Commit 28a85630 authored by pbarroca's avatar pbarroca
Browse files

Nouveau view helper d'affichage de quantité de mémoire informatique

parent 2d1b2bef
No related merge requests found
......@@ -2010,6 +2010,7 @@ library/ZendAfi/View/Helper/Java/MenuImage.php -text
library/ZendAfi/View/Helper/ListeNotices.php -text
library/ZendAfi/View/Helper/MapEvents.php -text
library/ZendAfi/View/Helper/MapForLieu.php -text
library/ZendAfi/View/Helper/MemoryFormat.php -text
library/ZendAfi/View/Helper/MenuHorizontal.php -text
library/ZendAfi/View/Helper/NewsBibHelper.php -text
library/ZendAfi/View/Helper/NoteImg.php -text
......
......@@ -19,10 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class ZendAfi_View_Helper_FileInfos extends Zend_View_Helper_Abstract {
/** @var array */
protected $_units = array('o', 'Ko', 'Mo', 'Go', 'To', 'Po');
/**
* @param string $path
* @return string
......@@ -61,13 +57,8 @@ class ZendAfi_View_Helper_FileInfos extends Zend_View_Helper_Abstract {
return '';
}
$mod = 1024;
$size = filesize($path);
for ($i = 0; $size > $mod; $i++) {
$size /= $mod;
}
return ', ' . round($size, 2) . ' ' . $this->_units[$i];
return ', ' . $this->view->memoryFormat($size);
}
}
?>
\ No newline at end of file
<?php
/**
* Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
*
* AFI-OPAC 2.0 is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* AFI-OPAC 2.0 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with AFI-OPAC 2.0; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class ZendAfi_View_Helper_MemoryFormat extends Zend_View_Helper_Abstract {
/** @var array */
protected $_units = array('o', 'Ko', 'Mo', 'Go', 'To', 'Po');
/**
* @param $size int
* @return string
*/
public function memoryFormat($size) {
$mod = 1024;
for ($i = 0; $size > $mod; $i++)
$size /= $mod;
return round($size, 2) . ' ' . $this->_units[$i];
}
}
?>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment