Merge pull request #12451 from owncloud/issue/6101-remove-gettype-class

Move constants from GET_TYPE to OC\Files so they can be autoloaded
This commit is contained in:
Vincent Petry 2014-11-27 11:03:55 +01:00
commit 51190f711d
1 changed files with 9 additions and 12 deletions

View File

@ -24,17 +24,14 @@
// TODO: get rid of this using proper composer packages // TODO: get rid of this using proper composer packages
require_once 'mcnetic/phpzipstreamer/ZipStreamer.php'; require_once 'mcnetic/phpzipstreamer/ZipStreamer.php';
class GET_TYPE {
const FILE = 1;
const ZIP_FILES = 2;
const ZIP_DIR = 3;
}
/** /**
* Class for file server access * Class for file server access
* *
*/ */
class OC_Files { class OC_Files {
const FILE = 1;
const ZIP_FILES = 2;
const ZIP_DIR = 3;
/** /**
* @param string $filename * @param string $filename
@ -76,7 +73,7 @@ class OC_Files {
} }
if (is_array($files)) { if (is_array($files)) {
$get_type = GET_TYPE::ZIP_FILES; $get_type = self::ZIP_FILES;
$basename = basename($dir); $basename = basename($dir);
if ($basename) { if ($basename) {
$name = $basename . '.zip'; $name = $basename . '.zip';
@ -88,7 +85,7 @@ class OC_Files {
} else { } else {
$filename = $dir . '/' . $files; $filename = $dir . '/' . $files;
if (\OC\Files\Filesystem::is_dir($dir . '/' . $files)) { if (\OC\Files\Filesystem::is_dir($dir . '/' . $files)) {
$get_type = GET_TYPE::ZIP_DIR; $get_type = self::ZIP_DIR;
// downloading root ? // downloading root ?
if ($files === '') { if ($files === '') {
$name = 'download.zip'; $name = 'download.zip';
@ -97,12 +94,12 @@ class OC_Files {
} }
} else { } else {
$get_type = GET_TYPE::FILE; $get_type = self::FILE;
$name = $files; $name = $files;
} }
} }
if ($get_type === GET_TYPE::FILE) { if ($get_type === self::FILE) {
$zip = false; $zip = false;
if ($xsendfile && OC_App::isEnabled('files_encryption')) { if ($xsendfile && OC_App::isEnabled('files_encryption')) {
$xsendfile = false; $xsendfile = false;
@ -127,7 +124,7 @@ class OC_Files {
if ($zip) { if ($zip) {
$executionTime = intval(ini_get('max_execution_time')); $executionTime = intval(ini_get('max_execution_time'));
set_time_limit(0); set_time_limit(0);
if ($get_type === GET_TYPE::ZIP_FILES) { if ($get_type === self::ZIP_FILES) {
foreach ($files as $file) { foreach ($files as $file) {
$file = $dir . '/' . $file; $file = $dir . '/' . $file;
if (\OC\Files\Filesystem::is_file($file)) { if (\OC\Files\Filesystem::is_file($file)) {
@ -138,7 +135,7 @@ class OC_Files {
self::zipAddDir($file, $zip); self::zipAddDir($file, $zip);
} }
} }
} elseif ($get_type === GET_TYPE::ZIP_DIR) { } elseif ($get_type === self::ZIP_DIR) {
$file = $dir . '/' . $files; $file = $dir . '/' . $files;
self::zipAddDir($file, $zip); self::zipAddDir($file, $zip);
} }