@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @suppress SqlInjectionChecker |
62 | 62 | */ |
63 | 63 | public function propagateChange($internalPath, $time, $sizeDifference = 0) { |
64 | - $storageId = (int)$this->storage->getStorageCache()->getNumericId(); |
|
64 | + $storageId = (int) $this->storage->getStorageCache()->getNumericId(); |
|
65 | 65 | |
66 | 66 | $parents = $this->getParents($internalPath); |
67 | 67 | |
@@ -76,12 +76,12 @@ discard block |
||
76 | 76 | $etag = uniqid(); // since we give all folders the same etag we don't ask the storage for the etag |
77 | 77 | |
78 | 78 | $builder = $this->connection->getQueryBuilder(); |
79 | - $hashParams = array_map(function ($hash) use ($builder) { |
|
79 | + $hashParams = array_map(function($hash) use ($builder) { |
|
80 | 80 | return $builder->expr()->literal($hash); |
81 | 81 | }, $parentHashes); |
82 | 82 | |
83 | 83 | $builder->update('filecache') |
84 | - ->set('mtime', $builder->createFunction('GREATEST(`mtime`, ' . $builder->createNamedParameter((int)$time, IQueryBuilder::PARAM_INT) . ')')) |
|
84 | + ->set('mtime', $builder->createFunction('GREATEST(`mtime`, '.$builder->createNamedParameter((int) $time, IQueryBuilder::PARAM_INT).')')) |
|
85 | 85 | ->set('etag', $builder->createNamedParameter($etag, IQueryBuilder::PARAM_STR)) |
86 | 86 | ->where($builder->expr()->eq('storage', $builder->createNamedParameter($storageId, IQueryBuilder::PARAM_INT))) |
87 | 87 | ->andWhere($builder->expr()->in('path_hash', $hashParams)); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | // we need to do size separably so we can ignore entries with uncalculated size |
93 | 93 | $builder = $this->connection->getQueryBuilder(); |
94 | 94 | $builder->update('filecache') |
95 | - ->set('size', $builder->createFunction('`size` + ' . $builder->createNamedParameter($sizeDifference))) |
|
95 | + ->set('size', $builder->createFunction('`size` + '.$builder->createNamedParameter($sizeDifference))) |
|
96 | 96 | ->where($builder->expr()->eq('storage', $builder->createNamedParameter($storageId, IQueryBuilder::PARAM_INT))) |
97 | 97 | ->andWhere($builder->expr()->in('path_hash', $hashParams)) |
98 | 98 | ->andWhere($builder->expr()->gt('size', $builder->expr()->literal(-1, IQueryBuilder::PARAM_INT))); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | $parents = []; |
108 | 108 | foreach ($parts as $part) { |
109 | 109 | $parents[] = $parent; |
110 | - $parent = trim($parent . '/' . $part, '/'); |
|
110 | + $parent = trim($parent.'/'.$part, '/'); |
|
111 | 111 | } |
112 | 112 | return $parents; |
113 | 113 | } |
@@ -152,17 +152,17 @@ discard block |
||
152 | 152 | $this->connection->beginTransaction(); |
153 | 153 | |
154 | 154 | $query = $this->connection->getQueryBuilder(); |
155 | - $storageId = (int)$this->storage->getStorageCache()->getNumericId(); |
|
155 | + $storageId = (int) $this->storage->getStorageCache()->getNumericId(); |
|
156 | 156 | |
157 | 157 | $query->update('filecache') |
158 | - ->set('mtime', $query->createFunction('GREATEST(`mtime`, ' . $query->createParameter('time') . ')')) |
|
158 | + ->set('mtime', $query->createFunction('GREATEST(`mtime`, '.$query->createParameter('time').')')) |
|
159 | 159 | ->set('etag', $query->expr()->literal(uniqid())) |
160 | 160 | ->where($query->expr()->eq('storage', $query->expr()->literal($storageId, IQueryBuilder::PARAM_INT))) |
161 | 161 | ->andWhere($query->expr()->eq('path_hash', $query->createParameter('hash'))); |
162 | 162 | |
163 | 163 | $sizeQuery = $this->connection->getQueryBuilder(); |
164 | 164 | $sizeQuery->update('filecache') |
165 | - ->set('size', $sizeQuery->createFunction('`size` + ' . $sizeQuery->createParameter('size'))) |
|
165 | + ->set('size', $sizeQuery->createFunction('`size` + '.$sizeQuery->createParameter('size'))) |
|
166 | 166 | ->where($query->expr()->eq('storage', $query->expr()->literal($storageId, IQueryBuilder::PARAM_INT))) |
167 | 167 | ->andWhere($query->expr()->eq('path_hash', $query->createParameter('hash'))) |
168 | 168 | ->andWhere($sizeQuery->expr()->gt('size', $sizeQuery->expr()->literal(-1, IQueryBuilder::PARAM_INT))); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | public function __construct(ILogger $logger) { |
73 | 73 | $this->logger = $logger; |
74 | 74 | $baseUrl = \OC::$WEBROOT; |
75 | - if(!(\OC::$server->getConfig()->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) { |
|
75 | + if (!(\OC::$server->getConfig()->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) { |
|
76 | 76 | $baseUrl = \OC::$server->getURLGenerator()->linkTo('', 'index.php'); |
77 | 77 | } |
78 | 78 | if (!\OC::$CLI && isset($_SERVER['REQUEST_METHOD'])) { |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | $this->routingFiles = []; |
99 | 99 | foreach (\OC_APP::getEnabledApps() as $app) { |
100 | 100 | $appPath = \OC_App::getAppPath($app); |
101 | - if($appPath !== false) { |
|
102 | - $file = $appPath . '/appinfo/routes.php'; |
|
101 | + if ($appPath !== false) { |
|
102 | + $file = $appPath.'/appinfo/routes.php'; |
|
103 | 103 | if (file_exists($file)) { |
104 | 104 | $this->routingFiles[$app] = $file; |
105 | 105 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @param null|string $app |
116 | 116 | */ |
117 | 117 | public function loadRoutes($app = null) { |
118 | - if(is_string($app)) { |
|
118 | + if (is_string($app)) { |
|
119 | 119 | $app = \OC_App::cleanAppId($app); |
120 | 120 | } |
121 | 121 | |
@@ -130,14 +130,14 @@ discard block |
||
130 | 130 | if (isset($this->loadedApps[$app])) { |
131 | 131 | return; |
132 | 132 | } |
133 | - $file = \OC_App::getAppPath($app) . '/appinfo/routes.php'; |
|
133 | + $file = \OC_App::getAppPath($app).'/appinfo/routes.php'; |
|
134 | 134 | if ($file !== false && file_exists($file)) { |
135 | 135 | $routingFiles = [$app => $file]; |
136 | 136 | } else { |
137 | 137 | $routingFiles = []; |
138 | 138 | } |
139 | 139 | } |
140 | - \OC::$server->getEventLogger()->start('loadroutes' . $requestedApp, 'Loading Routes'); |
|
140 | + \OC::$server->getEventLogger()->start('loadroutes'.$requestedApp, 'Loading Routes'); |
|
141 | 141 | foreach ($routingFiles as $app => $file) { |
142 | 142 | if (!isset($this->loadedApps[$app])) { |
143 | 143 | if (!\OC_App::isAppLoaded($app)) { |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | $this->useCollection($app); |
151 | 151 | $this->requireRouteFile($file, $app); |
152 | 152 | $collection = $this->getCollection($app); |
153 | - $collection->addPrefix('/apps/' . $app); |
|
153 | + $collection->addPrefix('/apps/'.$app); |
|
154 | 154 | $this->root->addCollection($collection); |
155 | 155 | |
156 | 156 | // Also add the OCS collection |
@@ -162,8 +162,8 @@ discard block |
||
162 | 162 | if (!isset($this->loadedApps['core'])) { |
163 | 163 | $this->loadedApps['core'] = true; |
164 | 164 | $this->useCollection('root'); |
165 | - require_once __DIR__ . '/../../../settings/routes.php'; |
|
166 | - require_once __DIR__ . '/../../../core/routes.php'; |
|
165 | + require_once __DIR__.'/../../../settings/routes.php'; |
|
166 | + require_once __DIR__.'/../../../core/routes.php'; |
|
167 | 167 | |
168 | 168 | // Also add the OCS collection |
169 | 169 | $collection = $this->getCollection('root.ocs'); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | $collection->addPrefix('/ocs'); |
176 | 176 | $this->root->addCollection($collection); |
177 | 177 | } |
178 | - \OC::$server->getEventLogger()->end('loadroutes' . $requestedApp); |
|
178 | + \OC::$server->getEventLogger()->end('loadroutes'.$requestedApp); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -246,14 +246,14 @@ discard block |
||
246 | 246 | public function match($url) { |
247 | 247 | if (substr($url, 0, 6) === '/apps/') { |
248 | 248 | // empty string / 'apps' / $app / rest of the route |
249 | - list(, , $app,) = explode('/', $url, 4); |
|
249 | + list(,, $app,) = explode('/', $url, 4); |
|
250 | 250 | |
251 | 251 | $app = \OC_App::cleanAppId($app); |
252 | 252 | \OC::$REQUESTEDAPP = $app; |
253 | 253 | $this->loadRoutes($app); |
254 | 254 | } else if (substr($url, 0, 13) === '/ocsapp/apps/') { |
255 | 255 | // empty string / 'ocsapp' / 'apps' / $app / rest of the route |
256 | - list(, , , $app,) = explode('/', $url, 5); |
|
256 | + list(,,, $app,) = explode('/', $url, 5); |
|
257 | 257 | |
258 | 258 | $app = \OC_App::cleanAppId($app); |
259 | 259 | \OC::$REQUESTEDAPP = $app; |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | // However, since Symfony does not allow empty route names, the route |
278 | 278 | // we need to match is '/', so we need to append the '/' here. |
279 | 279 | try { |
280 | - $parameters = $matcher->match($url . '/'); |
|
280 | + $parameters = $matcher->match($url.'/'); |
|
281 | 281 | } catch (ResourceNotFoundException $newException) { |
282 | 282 | // If we still didn't match a route, we throw the original exception |
283 | 283 | throw $e; |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | if (is_array($routes)) { |
368 | 368 | $appNameSpace = App::buildAppNamespace($appName); |
369 | 369 | |
370 | - $applicationClassName = $appNameSpace . '\\AppInfo\\Application'; |
|
370 | + $applicationClassName = $appNameSpace.'\\AppInfo\\Application'; |
|
371 | 371 | |
372 | 372 | if (class_exists($applicationClassName)) { |
373 | 373 | $application = new $applicationClassName(); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | return new DataResponse(); |
85 | 85 | } |
86 | 86 | |
87 | - $this->logger->error('Could not accept federated share with id: ' . $id, |
|
87 | + $this->logger->error('Could not accept federated share with id: '.$id, |
|
88 | 88 | ['app' => 'files_sharing']); |
89 | 89 | |
90 | 90 | throw new OCSNotFoundException('wrong share ID, share doesn\'t exist.'); |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @return array enriched share info with data from the filecache |
116 | 116 | */ |
117 | 117 | private static function extendShareInfo($share) { |
118 | - $view = new \OC\Files\View('/' . \OC_User::getUser() . '/files/'); |
|
118 | + $view = new \OC\Files\View('/'.\OC_User::getUser().'/files/'); |
|
119 | 119 | $info = $view->getFileInfo($share['mountpoint']); |
120 | 120 | |
121 | 121 | $share['mimetype'] = $info->getMimetype(); |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | throw new OCSNotFoundException('Share does not exist'); |
179 | 179 | } |
180 | 180 | |
181 | - $mountPoint = '/' . \OC_User::getUser() . '/files' . $shareInfo['mountpoint']; |
|
181 | + $mountPoint = '/'.\OC_User::getUser().'/files'.$shareInfo['mountpoint']; |
|
182 | 182 | |
183 | 183 | if ($this->externalManager->removeShare($mountPoint) === true) { |
184 | 184 | return new DataResponse(); |
@@ -25,7 +25,7 @@ |
||
25 | 25 | use OCA\Testing\AlternativeHomeUserBackend; |
26 | 26 | |
27 | 27 | class Application extends App { |
28 | - public function __construct (array $urlParams = array()) { |
|
28 | + public function __construct(array $urlParams = array()) { |
|
29 | 29 | $appName = 'testing'; |
30 | 30 | parent::__construct($appName, $urlParams); |
31 | 31 |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | */ |
99 | 99 | protected function getPath($user, $path) { |
100 | 100 | $node = $this->rootFolder->getUserFolder($user)->get($path); |
101 | - return 'files/' . md5($node->getStorage()->getId() . '::' . trim($node->getInternalPath(), '/')); |
|
101 | + return 'files/'.md5($node->getStorage()->getId().'::'.trim($node->getInternalPath(), '/')); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | |
135 | 135 | try { |
136 | 136 | $lockingProvider->acquireLock($path, $type); |
137 | - $this->config->setAppValue('testing', 'locking_' . $path, $type); |
|
137 | + $this->config->setAppValue('testing', 'locking_'.$path, $type); |
|
138 | 138 | return new DataResponse(); |
139 | 139 | } catch (LockedException $e) { |
140 | 140 | throw new OCSException('', Http::STATUS_LOCKED, $e); |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | |
162 | 162 | try { |
163 | 163 | $lockingProvider->changeLock($path, $type); |
164 | - $this->config->setAppValue('testing', 'locking_' . $path, $type); |
|
164 | + $this->config->setAppValue('testing', 'locking_'.$path, $type); |
|
165 | 165 | return new DataResponse(); |
166 | 166 | } catch (LockedException $e) { |
167 | 167 | throw new OCSException('', Http::STATUS_LOCKED, $e); |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | |
189 | 189 | try { |
190 | 190 | $lockingProvider->releaseLock($path, $type); |
191 | - $this->config->deleteAppValue('testing', 'locking_' . $path); |
|
191 | + $this->config->deleteAppValue('testing', 'locking_'.$path); |
|
192 | 192 | return new DataResponse(); |
193 | 193 | } catch (LockedException $e) { |
194 | 194 | throw new OCSException('', Http::STATUS_LOCKED, $e); |
@@ -231,9 +231,9 @@ discard block |
||
231 | 231 | if (strpos($lock, 'locking_') === 0) { |
232 | 232 | $path = substr($lock, strlen('locking_')); |
233 | 233 | |
234 | - if ($type === ILockingProvider::LOCK_EXCLUSIVE && (int)$this->config->getAppValue('testing', $lock) === ILockingProvider::LOCK_EXCLUSIVE) { |
|
234 | + if ($type === ILockingProvider::LOCK_EXCLUSIVE && (int) $this->config->getAppValue('testing', $lock) === ILockingProvider::LOCK_EXCLUSIVE) { |
|
235 | 235 | $lockingProvider->releaseLock($path, $this->config->getAppValue('testing', $lock)); |
236 | - } else if ($type === ILockingProvider::LOCK_SHARED && (int)$this->config->getAppValue('testing', $lock) === ILockingProvider::LOCK_SHARED) { |
|
236 | + } else if ($type === ILockingProvider::LOCK_SHARED && (int) $this->config->getAppValue('testing', $lock) === ILockingProvider::LOCK_SHARED) { |
|
237 | 237 | $lockingProvider->releaseLock($path, $this->config->getAppValue('testing', $lock)); |
238 | 238 | } else { |
239 | 239 | $lockingProvider->releaseLock($path, $this->config->getAppValue('testing', $lock)); |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | * @return bool |
51 | 51 | * @since 5.0.0 |
52 | 52 | */ |
53 | - static public function rmdirr( $dir ) { |
|
54 | - return \OC_Helper::rmdirr( $dir ); |
|
53 | + static public function rmdirr($dir) { |
|
54 | + return \OC_Helper::rmdirr($dir); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * does NOT work for ownClouds filesystem, use OC_FileSystem::getMimeType instead |
62 | 62 | * @since 5.0.0 |
63 | 63 | */ |
64 | - static public function getMimeType( $path ) { |
|
64 | + static public function getMimeType($path) { |
|
65 | 65 | return \OC::$server->getMimeTypeDetector()->detect($path); |
66 | 66 | } |
67 | 67 | |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | * @return int the number of bytes copied |
83 | 83 | * @since 5.0.0 |
84 | 84 | */ |
85 | - public static function streamCopy( $source, $target ) { |
|
86 | - list($count, ) = \OC_Helper::streamCopy( $source, $target ); |
|
85 | + public static function streamCopy($source, $target) { |
|
86 | + list($count,) = \OC_Helper::streamCopy($source, $target); |
|
87 | 87 | return $count; |
88 | 88 | } |
89 | 89 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @deprecated 8.1.0 use getTemporaryFile() of \OCP\ITempManager - \OC::$server->getTempManager() |
97 | 97 | * @since 5.0.0 |
98 | 98 | */ |
99 | - public static function tmpFile( $postfix='' ) { |
|
99 | + public static function tmpFile($postfix = '') { |
|
100 | 100 | return \OC::$server->getTempManager()->getTemporaryFile($postfix); |
101 | 101 | } |
102 | 102 | |
@@ -131,6 +131,6 @@ discard block |
||
131 | 131 | * @since 5.0.0 |
132 | 132 | */ |
133 | 133 | public static function getStorage($app) { |
134 | - return \OC_App::getStorage( $app ); |
|
134 | + return \OC_App::getStorage($app); |
|
135 | 135 | } |
136 | 136 | } |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | * @param array $headers additional key value based headers |
47 | 47 | * @since 8.1.0 |
48 | 48 | */ |
49 | - public function __construct($data='', $statusCode=Http::STATUS_OK, |
|
50 | - $headers=[]) { |
|
49 | + public function __construct($data = '', $statusCode = Http::STATUS_OK, |
|
50 | + $headers = []) { |
|
51 | 51 | $this->data = $data; |
52 | 52 | $this->setStatus($statusCode); |
53 | 53 | $this->setHeaders(array_merge($this->getHeaders(), $headers)); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @return DataDisplayResponse Reference to this object |
71 | 71 | * @since 8.1.0 |
72 | 72 | */ |
73 | - public function setData($data){ |
|
73 | + public function setData($data) { |
|
74 | 74 | $this->data = $data; |
75 | 75 | |
76 | 76 | return $this; |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @return string the data |
83 | 83 | * @since 8.1.0 |
84 | 84 | */ |
85 | - public function getData(){ |
|
85 | + public function getData() { |
|
86 | 86 | return $this->data; |
87 | 87 | } |
88 | 88 |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @param string $source either a local file or string data |
50 | 50 | * @return bool |
51 | 51 | */ |
52 | - public abstract function addFile($path, $source=''); |
|
52 | + public abstract function addFile($path, $source = ''); |
|
53 | 53 | /** |
54 | 54 | * rename a file or folder in the archive |
55 | 55 | * @param string $source |
@@ -126,15 +126,15 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function addRecursive($path, $source) { |
128 | 128 | $dh = opendir($source); |
129 | - if(is_resource($dh)) { |
|
129 | + if (is_resource($dh)) { |
|
130 | 130 | $this->addFolder($path); |
131 | 131 | while (($file = readdir($dh)) !== false) { |
132 | - if($file === '.' || $file === '..') { |
|
132 | + if ($file === '.' || $file === '..') { |
|
133 | 133 | continue; |
134 | 134 | } |
135 | - if(is_dir($source.'/'.$file)) { |
|
135 | + if (is_dir($source.'/'.$file)) { |
|
136 | 136 | $this->addRecursive($path.'/'.$file, $source.'/'.$file); |
137 | - }else{ |
|
137 | + } else { |
|
138 | 138 | $this->addFile($path.'/'.$file, $source.'/'.$file); |
139 | 139 | } |
140 | 140 | } |
@@ -33,21 +33,21 @@ discard block |
||
33 | 33 | |
34 | 34 | use Icewind\Streams\CallbackWrapper; |
35 | 35 | |
36 | -class ZIP extends Archive{ |
|
36 | +class ZIP extends Archive { |
|
37 | 37 | /** |
38 | 38 | * @var \ZipArchive zip |
39 | 39 | */ |
40 | - private $zip=null; |
|
40 | + private $zip = null; |
|
41 | 41 | private $path; |
42 | 42 | |
43 | 43 | /** |
44 | 44 | * @param string $source |
45 | 45 | */ |
46 | 46 | public function __construct($source) { |
47 | - $this->path=$source; |
|
48 | - $this->zip=new \ZipArchive(); |
|
49 | - if($this->zip->open($source, \ZipArchive::CREATE)) { |
|
50 | - }else{ |
|
47 | + $this->path = $source; |
|
48 | + $this->zip = new \ZipArchive(); |
|
49 | + if ($this->zip->open($source, \ZipArchive::CREATE)) { |
|
50 | + } else { |
|
51 | 51 | \OCP\Util::writeLog('files_archive', 'Error while opening archive '.$source, \OCP\Util::WARN); |
52 | 52 | } |
53 | 53 | } |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | * @param string $source either a local file or string data |
66 | 66 | * @return bool |
67 | 67 | */ |
68 | - public function addFile($path, $source='') { |
|
69 | - if($source and $source[0]=='/' and file_exists($source)) { |
|
70 | - $result=$this->zip->addFile($source, $path); |
|
71 | - }else{ |
|
72 | - $result=$this->zip->addFromString($path, $source); |
|
68 | + public function addFile($path, $source = '') { |
|
69 | + if ($source and $source[0] == '/' and file_exists($source)) { |
|
70 | + $result = $this->zip->addFile($source, $path); |
|
71 | + } else { |
|
72 | + $result = $this->zip->addFromString($path, $source); |
|
73 | 73 | } |
74 | - if($result) { |
|
75 | - $this->zip->close();//close and reopen to save the zip |
|
74 | + if ($result) { |
|
75 | + $this->zip->close(); //close and reopen to save the zip |
|
76 | 76 | $this->zip->open($this->path); |
77 | 77 | } |
78 | 78 | return $result; |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | * @return boolean|null |
85 | 85 | */ |
86 | 86 | public function rename($source, $dest) { |
87 | - $source=$this->stripPath($source); |
|
88 | - $dest=$this->stripPath($dest); |
|
87 | + $source = $this->stripPath($source); |
|
88 | + $dest = $this->stripPath($dest); |
|
89 | 89 | $this->zip->renameName($source, $dest); |
90 | 90 | } |
91 | 91 | /** |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @return int |
95 | 95 | */ |
96 | 96 | public function filesize($path) { |
97 | - $stat=$this->zip->statName($path); |
|
97 | + $stat = $this->zip->statName($path); |
|
98 | 98 | return $stat['size']; |
99 | 99 | } |
100 | 100 | /** |
@@ -111,13 +111,13 @@ discard block |
||
111 | 111 | * @return array |
112 | 112 | */ |
113 | 113 | public function getFolder($path) { |
114 | - $files=$this->getFiles(); |
|
115 | - $folderContent=array(); |
|
116 | - $pathLength=strlen($path); |
|
117 | - foreach($files as $file) { |
|
118 | - if(substr($file, 0, $pathLength)==$path and $file!=$path) { |
|
119 | - if(strrpos(substr($file, 0, -1), '/')<=$pathLength) { |
|
120 | - $folderContent[]=substr($file, $pathLength); |
|
114 | + $files = $this->getFiles(); |
|
115 | + $folderContent = array(); |
|
116 | + $pathLength = strlen($path); |
|
117 | + foreach ($files as $file) { |
|
118 | + if (substr($file, 0, $pathLength) == $path and $file != $path) { |
|
119 | + if (strrpos(substr($file, 0, -1), '/') <= $pathLength) { |
|
120 | + $folderContent[] = substr($file, $pathLength); |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 | } |
@@ -128,10 +128,10 @@ discard block |
||
128 | 128 | * @return array |
129 | 129 | */ |
130 | 130 | public function getFiles() { |
131 | - $fileCount=$this->zip->numFiles; |
|
132 | - $files=array(); |
|
133 | - for($i=0;$i<$fileCount;$i++) { |
|
134 | - $files[]=$this->zip->getNameIndex($i); |
|
131 | + $fileCount = $this->zip->numFiles; |
|
132 | + $files = array(); |
|
133 | + for ($i = 0; $i < $fileCount; $i++) { |
|
134 | + $files[] = $this->zip->getNameIndex($i); |
|
135 | 135 | } |
136 | 136 | return $files; |
137 | 137 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | * @return bool |
168 | 168 | */ |
169 | 169 | public function fileExists($path) { |
170 | - return ($this->zip->locateName($path)!==false) or ($this->zip->locateName($path.'/')!==false); |
|
170 | + return ($this->zip->locateName($path) !== false) or ($this->zip->locateName($path.'/') !== false); |
|
171 | 171 | } |
172 | 172 | /** |
173 | 173 | * remove a file or folder from the archive |
@@ -175,9 +175,9 @@ discard block |
||
175 | 175 | * @return bool |
176 | 176 | */ |
177 | 177 | public function remove($path) { |
178 | - if($this->fileExists($path.'/')) { |
|
178 | + if ($this->fileExists($path.'/')) { |
|
179 | 179 | return $this->zip->deleteName($path.'/'); |
180 | - }else{ |
|
180 | + } else { |
|
181 | 181 | return $this->zip->deleteName($path); |
182 | 182 | } |
183 | 183 | } |
@@ -188,23 +188,23 @@ discard block |
||
188 | 188 | * @return resource |
189 | 189 | */ |
190 | 190 | public function getStream($path, $mode) { |
191 | - if($mode=='r' or $mode=='rb') { |
|
191 | + if ($mode == 'r' or $mode == 'rb') { |
|
192 | 192 | return $this->zip->getStream($path); |
193 | 193 | } else { |
194 | 194 | //since we can't directly get a writable stream, |
195 | 195 | //make a temp copy of the file and put it back |
196 | 196 | //in the archive when the stream is closed |
197 | - if(strrpos($path, '.')!==false) { |
|
198 | - $ext=substr($path, strrpos($path, '.')); |
|
199 | - }else{ |
|
200 | - $ext=''; |
|
197 | + if (strrpos($path, '.') !== false) { |
|
198 | + $ext = substr($path, strrpos($path, '.')); |
|
199 | + } else { |
|
200 | + $ext = ''; |
|
201 | 201 | } |
202 | - $tmpFile=\OCP\Files::tmpFile($ext); |
|
203 | - if($this->fileExists($path)) { |
|
202 | + $tmpFile = \OCP\Files::tmpFile($ext); |
|
203 | + if ($this->fileExists($path)) { |
|
204 | 204 | $this->extractFile($path, $tmpFile); |
205 | 205 | } |
206 | 206 | $handle = fopen($tmpFile, $mode); |
207 | - return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) { |
|
207 | + return CallbackWrapper::wrap($handle, null, null, function() use ($path, $tmpFile) { |
|
208 | 208 | $this->writeBack($tmpFile, $path); |
209 | 209 | }); |
210 | 210 | } |
@@ -223,9 +223,9 @@ discard block |
||
223 | 223 | * @return string |
224 | 224 | */ |
225 | 225 | private function stripPath($path) { |
226 | - if(!$path || $path[0]=='/') { |
|
226 | + if (!$path || $path[0] == '/') { |
|
227 | 227 | return substr($path, 1); |
228 | - }else{ |
|
228 | + } else { |
|
229 | 229 | return $path; |
230 | 230 | } |
231 | 231 | } |