= 1024 && $size < 1024*1024) return sprintf('%01.2f',$size/1024.0).' '.JText::_('KB'); else return sprintf('%01.2f', $size/(1024.0*1024)).' '.JText::_('MB'); } /** * Format the date. * @param int $date the unix datestamp * @return string formated date. */ function formatDate($date, $format="%d/%m/%Y, %H:%M") { return strftime($format, $date); } /** * Get the modified date of a file * * @return Formatted modified date * @param string $file Absolute path to file */ function getDate($file) { return Utils::formatDate(@filemtime($file)); } /** * Get the size of a file * * @return Formatted filesize value * @param string $file Absolute path to file */ function getSize($file) { return Utils::formatSize(@filesize($file)); } /** * Count the number of folders in a given folder * @return integer Total number of folders * @param string $path Abolute path to folder */ function countDirs($path) { jimport('joomla.filesystem.folder'); $total = 0; if (JFolder::exists($path)) { $folders = JFolder::folders($path); $total = count($folders); } return $total; } /** * Count the number of files in a folder * @return integer File total * @param string $path Absolute path to folder */ function countFiles($path) { jimport('joomla.filesystem.file'); $total = 0; if (JFolder::exists($path)) { $files = JFolder::files($path); $total = count($files); foreach ($files as $file) { if (strtolower($file) == 'index.html' || strtolower($file) == 'thumbs.db') { $total = $total -1; } } } return $total; } } ?>