Fixed style according to owncloud styleguide
This commit is contained in:
parent
8e190a5a97
commit
de7e419610
|
@ -42,10 +42,13 @@ class OC_Files {
|
||||||
* - versioned
|
* - versioned
|
||||||
*/
|
*/
|
||||||
public static function getFileInfo($path) {
|
public static function getFileInfo($path) {
|
||||||
|
$path = OC_Filesystem::normalizePath($path);
|
||||||
if (($path == '/Shared' || substr($path, 0, 8) == '/Shared/') && OC_App::isEnabled('files_sharing')) {
|
if (($path == '/Shared' || substr($path, 0, 8) == '/Shared/') && OC_App::isEnabled('files_sharing')) {
|
||||||
if ($path == '/Shared') {
|
if ($path == '/Shared') {
|
||||||
list($info) = OCP\Share::getItemsSharedWith('file', OC_Share_Backend_File::FORMAT_FILE_APP_ROOT);
|
list($info) = OCP\Share::getItemsSharedWith('file', OC_Share_Backend_File::FORMAT_FILE_APP_ROOT);
|
||||||
}else{
|
} else {
|
||||||
|
$info = array();
|
||||||
|
if (OC_Filesystem::file_exists($path)) {
|
||||||
$info['size'] = OC_Filesystem::filesize($path);
|
$info['size'] = OC_Filesystem::filesize($path);
|
||||||
$info['mtime'] = OC_Filesystem::filemtime($path);
|
$info['mtime'] = OC_Filesystem::filemtime($path);
|
||||||
$info['ctime'] = OC_Filesystem::filectime($path);
|
$info['ctime'] = OC_Filesystem::filectime($path);
|
||||||
|
@ -53,6 +56,7 @@ class OC_Files {
|
||||||
$info['encrypted'] = false;
|
$info['encrypted'] = false;
|
||||||
$info['versioned'] = false;
|
$info['versioned'] = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$info = OC_FileCache::get($path);
|
$info = OC_FileCache::get($path);
|
||||||
}
|
}
|
||||||
|
@ -87,13 +91,13 @@ class OC_Files {
|
||||||
foreach ($files as &$file) {
|
foreach ($files as &$file) {
|
||||||
$file['directory'] = $directory;
|
$file['directory'] = $directory;
|
||||||
$file['type'] = ($file['mimetype'] == 'httpd/unix-directory') ? 'dir' : 'file';
|
$file['type'] = ($file['mimetype'] == 'httpd/unix-directory') ? 'dir' : 'file';
|
||||||
$permissions = OCP\Share::PERMISSION_READ;
|
$permissions = OCP\PERMISSION_READ;
|
||||||
// NOTE: Remove check when new encryption is merged
|
// NOTE: Remove check when new encryption is merged
|
||||||
if (!$file['encrypted']) {
|
if (!$file['encrypted']) {
|
||||||
$permissions |= OCP\Share::PERMISSION_SHARE;
|
$permissions |= OCP\PERMISSION_SHARE;
|
||||||
}
|
}
|
||||||
if ($file['type'] == 'dir' && $file['writable']) {
|
if ($file['type'] == 'dir' && $file['writable']) {
|
||||||
$permissions |= OCP\Share::PERMISSION_CREATE;
|
$permissions |= OCP\PERMISSION_CREATE;
|
||||||
}
|
}
|
||||||
if ($file['writable']) {
|
if ($file['writable']) {
|
||||||
$permissions |= OCP\PERMISSION_UPDATE | OCP\PERMISSION_DELETE;
|
$permissions |= OCP\PERMISSION_UPDATE | OCP\PERMISSION_DELETE;
|
||||||
|
@ -138,8 +142,9 @@ class OC_Files {
|
||||||
public static function get($dir, $files, $only_header = false) {
|
public static function get($dir, $files, $only_header = false) {
|
||||||
$xsendfile = false;
|
$xsendfile = false;
|
||||||
if (isset($_SERVER['MOD_X_SENDFILE_ENABLED']) ||
|
if (isset($_SERVER['MOD_X_SENDFILE_ENABLED']) ||
|
||||||
isset($_SERVER['MOD_X_ACCEL_REDIRECT_ENABLED']))
|
isset($_SERVER['MOD_X_ACCEL_REDIRECT_ENABLED'])) {
|
||||||
$xsendfile = true;
|
$xsendfile = true;
|
||||||
|
}
|
||||||
if(strpos($files, ';')) {
|
if(strpos($files, ';')) {
|
||||||
$files=explode(';', $files);
|
$files=explode(';', $files);
|
||||||
}
|
}
|
||||||
|
@ -149,11 +154,12 @@ class OC_Files {
|
||||||
$executionTime = intval(ini_get('max_execution_time'));
|
$executionTime = intval(ini_get('max_execution_time'));
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
$zip = new ZipArchive();
|
$zip = new ZipArchive();
|
||||||
if ($xsendfile)
|
if ($xsendfile) {
|
||||||
$filename = OC_Helper::tmpFileNoClean('.zip');
|
$filename = OC_Helper::tmpFileNoClean('.zip');
|
||||||
else
|
}else{
|
||||||
$filename = OC_Helper::tmpFile('.zip');
|
$filename = OC_Helper::tmpFile('.zip');
|
||||||
if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)!==TRUE) {
|
}
|
||||||
|
if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)!==true) {
|
||||||
exit("cannot open <$filename>\n");
|
exit("cannot open <$filename>\n");
|
||||||
}
|
}
|
||||||
foreach($files as $file) {
|
foreach($files as $file) {
|
||||||
|
@ -173,11 +179,12 @@ class OC_Files {
|
||||||
$executionTime = intval(ini_get('max_execution_time'));
|
$executionTime = intval(ini_get('max_execution_time'));
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
$zip = new ZipArchive();
|
$zip = new ZipArchive();
|
||||||
if ($xsendfile)
|
if ($xsendfile) {
|
||||||
$filename = OC_Helper::tmpFileNoClean('.zip');
|
$filename = OC_Helper::tmpFileNoClean('.zip');
|
||||||
else
|
}else{
|
||||||
$filename = OC_Helper::tmpFile('.zip');
|
$filename = OC_Helper::tmpFile('.zip');
|
||||||
if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)!==TRUE) {
|
}
|
||||||
|
if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)!==true) {
|
||||||
exit("cannot open <$filename>\n");
|
exit("cannot open <$filename>\n");
|
||||||
}
|
}
|
||||||
$file=$dir.'/'.$files;
|
$file=$dir.'/'.$files;
|
||||||
|
@ -201,9 +208,10 @@ class OC_Files {
|
||||||
}else{
|
}else{
|
||||||
header('Content-Type: '.OC_Filesystem::getMimeType($filename));
|
header('Content-Type: '.OC_Filesystem::getMimeType($filename));
|
||||||
$storage = OC_Filesystem::getStorage($filename);
|
$storage = OC_Filesystem::getStorage($filename);
|
||||||
if ($storage instanceof OC_Filestorage_Local)
|
if ($storage instanceof OC_Filestorage_Local) {
|
||||||
self::addSendfileHeader(OC_Filesystem::getLocalFile($filename));
|
self::addSendfileHeader(OC_Filesystem::getLocalFile($filename));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}elseif($zip or !OC_Filesystem::file_exists($filename)) {
|
}elseif($zip or !OC_Filesystem::file_exists($filename)) {
|
||||||
header("HTTP/1.0 404 Not Found");
|
header("HTTP/1.0 404 Not Found");
|
||||||
$tmpl = new OC_Template( '', '404', 'guest' );
|
$tmpl = new OC_Template( '', '404', 'guest' );
|
||||||
|
@ -227,8 +235,9 @@ class OC_Files {
|
||||||
flush();
|
flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$xsendfile)
|
if (!$xsendfile) {
|
||||||
unlink($filename);
|
unlink($filename);
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
OC_Filesystem::readfile($filename);
|
OC_Filesystem::readfile($filename);
|
||||||
}
|
}
|
||||||
|
@ -243,9 +252,10 @@ class OC_Files {
|
||||||
if (isset($_SERVER['MOD_X_SENDFILE_ENABLED'])) {
|
if (isset($_SERVER['MOD_X_SENDFILE_ENABLED'])) {
|
||||||
header("X-Sendfile: " . $filename);
|
header("X-Sendfile: " . $filename);
|
||||||
}
|
}
|
||||||
if (isset($_SERVER['MOD_X_ACCEL_REDIRECT_ENABLED']))
|
if (isset($_SERVER['MOD_X_ACCEL_REDIRECT_ENABLED'])) {
|
||||||
header("X-Accel-Redirect: " . $filename);
|
header("X-Accel-Redirect: " . $filename);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static function zipAddDir($dir, $zip, $internalDir='') {
|
public static function zipAddDir($dir, $zip, $internalDir='') {
|
||||||
$dirname=basename($dir);
|
$dirname=basename($dir);
|
||||||
|
|
|
@ -534,8 +534,9 @@ class OC_Helper {
|
||||||
public static function tmpFileNoClean($postfix='') {
|
public static function tmpFileNoClean($postfix='') {
|
||||||
$tmpDirNoClean=get_temp_dir().'/oc-noclean/';
|
$tmpDirNoClean=get_temp_dir().'/oc-noclean/';
|
||||||
if (!file_exists($tmpDirNoClean) || !is_dir($tmpDirNoClean)) {
|
if (!file_exists($tmpDirNoClean) || !is_dir($tmpDirNoClean)) {
|
||||||
if (file_exists($tmpDirNoClean))
|
if (file_exists($tmpDirNoClean)) {
|
||||||
unlink($tmpDirNoClean);
|
unlink($tmpDirNoClean);
|
||||||
|
}
|
||||||
mkdir($tmpDirNoClean);
|
mkdir($tmpDirNoClean);
|
||||||
}
|
}
|
||||||
$file=$tmpDirNoClean.md5(time().rand()).$postfix;
|
$file=$tmpDirNoClean.md5(time().rand()).$postfix;
|
||||||
|
|
Loading…
Reference in New Issue