本文整理汇总了PHP中FileHelper::totalSiteFilesSize方法的典型用法代码示例。如果您正苦于以下问题:PHP FileHelper::totalSiteFilesSize方法的具体用法?PHP FileHelper::totalSiteFilesSize怎么用?PHP FileHelper::totalSiteFilesSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileHelper
的用法示例。
在下文中一共展示了FileHelper::totalSiteFilesSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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));
}
示例2: 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));
}
示例3: uploadFileEvent
public function uploadFileEvent($runData)
{
try {
// the event method will not use OZONE functionality for file processing but
// rather a low-level approach.
$status = "ok";
// status variable that will be passed to template
$pl = $runData->getParameterList();
$site = $runData->getTemp("site");
$pageId = $pl->getParameterValue("page_id");
$page = DB_PagePeer::instance()->selectByPrimaryKey($pageId);
if ($page == null || $page->getSiteId() != $site->getSiteId()) {
$status = "error";
$runData->contextAdd("status", $status);
$runData->contextAdd("message", _("Page does not exist???"));
return;
}
$category = $page->getCategory();
// now check for permissions!!!
$user = $runData->getUser();
WDPermissionManager::instance()->hasPagePermission('attach_file', $user, $category, $page);
$userId = $runData->getUserId();
if ($userId == null) {
$userString = $runData->createIpString();
}
$file = $_FILES['userfile'];
$comments = trim($pl->getParameterValue("comments"));
$comments = substr($comments, 0, 110);
if ($file['error'] === 2 || $file['error'] === 1) {
$status = "size_error";
$runData->contextAdd("status", $file['error']);
$runData->contextAdd("message", _("Error uploading file - file size exceeds limit."));
return;
}
if ($file['error'] === 3) {
$status = "partial_error";
$runData->contextAdd("status", $file['error']);
$runData->contextAdd("message", _("Error uploading file - file only partially uploaded."));
return;
}
if ($file['error'] == 4) {
$status = "no_file";
$runData->contextAdd("status", $file['error']);
$runData->contextAdd("message", _("Error uploading file - no file uploaded."));
return;
}
if ($file['error'] != 0) {
$status = "other_error";
$runData->contextAdd("status", $file['error']);
$runData->contextAdd("message", _("Error uploading file - no file uploaded."));
return;
}
if ($file['size'] == 0) {
$status = "zero_size";
$runData->contextAdd("status", $status);
$runData->contextAdd("message", _("Error uploading file - the file has 0 bytes size."));
return;
}
if (!is_uploaded_file($file['tmp_name'])) {
$status = "invalid_file";
$runData->contextAdd("status", $status);
$runData->contextAdd("message", _("Error uploading file - invalid file."));
return;
}
$totalSize = FileHelper::totalSiteFilesSize($site->getSiteId());
$allowed = $site->getSettings()->getFileStorageSize();
$maxUpload = min($allowed - $totalSize, $site->getSettings()->getMaxUploadFileSize());
if ($file['size'] > $maxUpload) {
$status = "too_big";
$runData->contextAdd("status", $status);
$runData->contextAdd("message", _("Error uploading file - file size exceeds limit."));
return;
}
// check if destination file exists!
$destinationFilename = $pl->getParameterValue("dfilename");
if ($destinationFilename === "" || $destinationFilename == null) {
// use the original name
$destinationFilename = $file['name'];
}
$c = new Criteria();
$c->add("filename", $destinationFilename);
$c->add("site_id", $site->getSiteId());
$c->add("page_id", $pageId);
$conflictFiles = DB_FilePeer::instance()->select($c);
if (count($conflictFiles) > 0) {
// file already exists!!!
try {
WDPermissionManager::instance()->hasPagePermission('replace_file', $user, $category, $page);
$overwritePermission = true;
} catch (Exception $e) {
$overwritePermission = false;
}
if ($pl->getParameterValue("force") && $overwritePermission) {
DB_FilePeer::instance()->delete($c);
} else {
$status = "file_exists";
$runData->contextAdd("status", $status);
$runData->contextAdd("message", _("Error uploading file - file by that name already exists."));
return;
}
//.........这里部分代码省略.........