本文整理汇总了PHP中FileHelper::formatSize方法的典型用法代码示例。如果您正苦于以下问题:PHP FileHelper::formatSize方法的具体用法?PHP FileHelper::formatSize怎么用?PHP FileHelper::formatSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileHelper
的用法示例。
在下文中一共展示了FileHelper::formatSize方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build
public function build($runData)
{
// get current backups
$site = $runData->getTemp("site");
$c = new Criteria();
$c->add("site_id", $site->getSiteId());
$sb = DB_SiteBackupPeer::instance()->selectOne($c);
if ($sb) {
if ($sb->getStatus() == "completed") {
// get backup file size
$path = WIKIDOT_ROOT . '/web/files--sites/' . $site->getUnixName() . '/backup/' . $sb->getRand() . '/backup.zip';
// check if file exists
if (!file_exists($path)) {
// in case something failed
DB_SiteBackupPeer::instance()->delete($c);
$sb = null;
} else {
$size = filesize($path);
$sizeFormatted = FileHelper::formatSize($size);
$runData->contextAdd('size', $sizeFormatted);
}
}
}
$runData->contextAdd("site", $site);
$runData->contextAdd("backup", $sb);
}
示例2: actionIndex
public function actionIndex($ajax = null)
{
$load = SystemHelper::getLoad();
$totalspace = disk_total_space(VIREX_STORAGE_PATH);
$freespace = disk_free_space(VIREX_STORAGE_PATH);
$slov = new ProgressBar(100, $load, 150);
$slov->suff = '';
$slov->doneBg = '#9BB947';
$duov = new ProgressBar($totalspace, $totalspace - $freespace, 150);
$duov->suff = '';
$duov->doneBg = '#9BB947';
$sysHealth = array(array('id' => 2, 'Property' => 'Operating System', 'Value' => PHP_OS, 'Overview' => ''), array('id' => 3, 'Property' => 'Web server', 'Value' => $_SERVER["SERVER_SOFTWARE"], 'Overview' => ''), array('id' => 4, 'Property' => 'PHP version', 'Value' => PHP_VERSION, 'Overview' => ''), array('id' => 5, 'Property' => 'MySQL version', 'Value' => Yii::app()->db->serverVersion, 'Overview' => ''), array('id' => 1, 'Property' => 'Storage space', 'Value' => FileHelper::formatSize($totalspace - $freespace) . ' / ' . FileHelper::formatSize($totalspace), 'Overview' => $duov->display()), array('id' => 6, 'Property' => 'System load / CPU usage', 'Value' => '', 'Overview' => $slov->display()));
$this->render('index', array('systemHealth' => new CArrayDataProvider($sysHealth)));
}
示例3: build
public function build($runData)
{
$site = $runData->getTemp("site");
$settings = $site->getSettings();
$runData->contextAdd("site", $site);
$runData->contextAdd("settings", $settings);
$totalSize = FileHelper::totalSiteFilesSize($site->getSiteId());
$allowed = $settings->getFileStorageSize();
$maxUpload = min($allowed - $totalSize, 5242880);
$numberOfFiles = FileHelper::totalSiteFileNumber($site->getSiteId());
$runData->contextAdd("totalSiteSize", FileHelper::formatSize($totalSize));
$runData->contextAdd("numberOfFiles", $numberOfFiles);
$runData->contextAdd("totalSiteAllowedSize", FileHelper::formatSize($allowed));
$runData->contextAdd("availableSiteSize", FileHelper::formatSize($allowed - $totalSize));
$runData->contextAdd("maxUpload", $maxUpload);
$runData->contextAdd("maxUploadString", FileHelper::formatSize($maxUpload));
}
示例4: build
public function build($runData)
{
$site = $runData->getTemp("site");
$pageId = $runData->getParameterList()->getParameterValue("page_id");
if (!$pageId || !is_numeric($pageId)) {
throw new ProcessException(_("The page can not be found or does not exist."), "no_page");
}
$page = DB_PagePeer::instance()->selectByPrimaryKey($pageId);
if (!$page || $page->getSiteId() !== $site->getSiteId()) {
throw new ProcessException(_("The page can not be found or does not exist."), "no_page");
}
$files = $page->getFiles();
if (count($files) > 0) {
$runData->contextAdd("files", $files);
$runData->contextAdd("filePath", "/local--files/" . $page->getUnixName() . "/");
$totalPageSize = FileHelper::totalPageFilesSize($pageId);
$totalPageSize = FileHelper::formatSize($totalPageSize);
$runData->contextAdd("totalPageSize", $totalPageSize);
}
}
示例5: build
public function build($runData)
{
$site = $runData->getTemp("site");
$pl = $runData->getParameterList();
$pageId = $pl->getParameterValue("pageId");
$page = DB_PagePeer::instance()->selectByPrimaryKey($pageId);
if ($page == null || $page->getSiteId() != $site->getSiteId()) {
throw new ProcessException(_("Problem selecting destination page."), "no_page");
}
$category = $page->getCategory();
// now check for permissions!!!
$user = $runData->getUser();
WDPermissionManager::instance()->hasPagePermission('attach_file', $user, $category, $page);
$totalSize = FileHelper::totalSiteFilesSize($site->getSiteId());
$allowed = $site->getSettings()->getFileStorageSize();
$maxUpload = min($allowed - $totalSize, $site->getSettings()->getMaxUploadFileSize());
$runData->contextAdd("totalSiteSize", FileHelper::formatSize($totalSize));
$runData->contextAdd("totalSiteAllowedSize", FileHelper::formatSize($allowed));
$runData->contextAdd("availableSiteSize", FileHelper::formatSize($allowed - $totalSize));
$runData->contextAdd("maxUpload", $maxUpload);
$runData->contextAdd("maxUploadString", FileHelper::formatSize($maxUpload));
}
示例6: getSizeString
public function getSizeString()
{
return FileHelper::formatSize($this->getSize());
}
示例7: size
private function size($size)
{
// shortcut to FileHelper static method formatSize()
return $this->pad(FileHelper::formatSize($size));
}
示例8: logStats
public static function logStats()
{
if (!self::$debug) {
return true;
}
if (!ALogger::end_step()) {
ALogger::empty_line();
}
$execTime = number_format(microtime(true) - self::$startTime, 2) . 's';
$msg = "Time: " . self::color(self::CWHITE, $execTime) . "; Memory: " . self::color(self::CWHITE, FileHelper::formatSize(memory_get_peak_usage(true)));
self::$show_time_on_logs = false;
self::log($msg, null, 'debug', false);
list($ok, $errors) = self::getStats();
$errors = self::color(self::CLIGHT_RED, $errors);
$ok = self::color(self::CLIGHT_GREEN, $ok);
self::log('Errors: ' . $errors . '; Succesfull: ' . $ok, null, 'debug', false);
self::empty_line();
}