2013-01-18 23:31:09 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace OCA\files\lib;
|
|
|
|
|
|
|
|
class Helper
|
|
|
|
{
|
|
|
|
public static function buildFileStorageStatistics($dir) {
|
|
|
|
$l = new \OC_L10N('files');
|
|
|
|
$maxUploadFilesize = \OCP\Util::maxUploadFilesize($dir);
|
|
|
|
$maxHumanFilesize = \OCP\Util::humanFileSize($maxUploadFilesize);
|
|
|
|
$maxHumanFilesize = $l->t('Upload') . ' max. ' . $maxHumanFilesize;
|
|
|
|
|
|
|
|
// information about storage capacities
|
2013-08-26 22:59:58 +00:00
|
|
|
$storageInfo = \OC_Helper::getStorageInfo($dir);
|
2013-01-18 23:31:09 +00:00
|
|
|
|
|
|
|
return array('uploadMaxFilesize' => $maxUploadFilesize,
|
|
|
|
'maxHumanFilesize' => $maxHumanFilesize,
|
|
|
|
'usedSpacePercent' => (int)$storageInfo['relative']);
|
|
|
|
}
|
2013-09-11 22:39:52 +00:00
|
|
|
|
|
|
|
public static function determineIcon($file) {
|
|
|
|
if($file['type'] === 'dir') {
|
|
|
|
$dir = $file['directory'];
|
|
|
|
$absPath = \OC\Files\Filesystem::getView()->getAbsolutePath($dir.'/'.$file['name']);
|
|
|
|
$mount = \OC\Files\Filesystem::getMountManager()->find($absPath);
|
|
|
|
if (!is_null($mount)) {
|
|
|
|
$sid = $mount->getStorageId();
|
|
|
|
if (!is_null($sid)) {
|
|
|
|
$sid = explode(':', $sid);
|
|
|
|
if ($sid[0] === 'shared') {
|
|
|
|
return \OC_Helper::mimetypeIcon('dir-shared');
|
|
|
|
}
|
|
|
|
if ($sid[0] !== 'local') {
|
|
|
|
return \OC_Helper::mimetypeIcon('dir-external');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return \OC_Helper::mimetypeIcon('dir');
|
|
|
|
}
|
|
|
|
|
|
|
|
if($file['isPreviewAvailable']) {
|
|
|
|
$relativePath = substr($file['path'], 6);
|
|
|
|
return \OC_Helper::previewIcon($relativePath);
|
|
|
|
}
|
|
|
|
return \OC_Helper::mimetypeIcon($file['mimetype']);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-18 23:31:09 +00:00
|
|
|
}
|