@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | { |
102 | 102 | if (is_string($value)) { |
103 | 103 | if ($value != self::VISIBILITY_PRIVATE && $value != self::VISIBILITY_PUBLIC) { |
104 | - throw new \InvalidArgumentException('The visibility must be set to either "' . self::VISIBILITY_PRIVATE . '" or "' . self::VISIBILITY_PUBLIC . '"'); |
|
104 | + throw new \InvalidArgumentException('The visibility must be set to either "'.self::VISIBILITY_PRIVATE.'" or "'.self::VISIBILITY_PUBLIC.'"'); |
|
105 | 105 | } |
106 | 106 | $this->setAttribute('visibility', $value); |
107 | 107 | } // If the value is a boolean then a value of true means public a value of false means private |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | $this->setAttribute('visibility', $value ? self::VISIBILITY_PUBLIC : self::VISIBILITY_PRIVATE); |
110 | 110 | } // We have no idea what you passed in :-S |
111 | 111 | else { |
112 | - throw new \InvalidArgumentException('Incorrect value being set on visibility, expecting either a boolean or a string, you gave ' . print_r($value, true)); |
|
112 | + throw new \InvalidArgumentException('Incorrect value being set on visibility, expecting either a boolean or a string, you gave '.print_r($value, true)); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 |
@@ -158,7 +158,9 @@ |
||
158 | 158 | |
159 | 159 | $result = $this->put($path = trim($path), $stream, $visibility); |
160 | 160 | |
161 | - if (is_resource($stream)) fclose($stream); |
|
161 | + if (is_resource($stream)) { |
|
162 | + fclose($stream); |
|
163 | + } |
|
162 | 164 | |
163 | 165 | return $result ? (bool) $path : false; |
164 | 166 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | |
236 | 236 | foreach ($paths as $path) { |
237 | 237 | try { |
238 | - if (! $this->_flysystem->delete($path)) { |
|
238 | + if (!$this->_flysystem->delete($path)) { |
|
239 | 239 | $success = false; |
240 | 240 | } |
241 | 241 | } catch (FileNotFoundException $e) { |
@@ -414,10 +414,10 @@ discard block |
||
414 | 414 | * @param string $algorithm - Any algorithm supported by hash() |
415 | 415 | * @return string return the hash output string on success or an empty string if the file path can not be read as a stream |
416 | 416 | */ |
417 | - public function hash($path, $algorithm='md5') |
|
417 | + public function hash($path, $algorithm = 'md5') |
|
418 | 418 | { |
419 | 419 | if (!in_array($algorithm, hash_algos())) { |
420 | - throw new \InvalidArgumentException('Hash algorithm ' . $algorithm . ' is not supported'); |
|
420 | + throw new \InvalidArgumentException('Hash algorithm '.$algorithm.' is not supported'); |
|
421 | 421 | } |
422 | 422 | $stream = $this->_flysystem->readStream($path); |
423 | 423 | if ($stream === false) { |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | ->all(); |
184 | 184 | $success = true; |
185 | 185 | foreach ($files as $file) { |
186 | - if ( ! $this->delete($file['path'])) { |
|
186 | + if (!$this->delete($file['path'])) { |
|
187 | 187 | $success = false; |
188 | 188 | } |
189 | 189 | } |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | $query->where(['like', 'path', $directory]); |
297 | 297 | } |
298 | 298 | $result = $query->asArray()->limit(1000)->all(); |
299 | - $result = array_map(function($r){ |
|
299 | + $result = array_map(function($r) { |
|
300 | 300 | return DbFile::convertToFileSystemFormat($r); |
301 | 301 | }, $result); |
302 | 302 | return Util::emulateDirectories($result); |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | { |
313 | 313 | $path = rtrim($path, '/'); |
314 | 314 | $sanitizedPath = addcslashes($path, '_%'); |
315 | - return $sanitizedPath . '/'; |
|
315 | + return $sanitizedPath.'/'; |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | /** |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | * @param string $path |
397 | 397 | * @throws \neon\firefly\services\fileManager\FileExceedsMemoryLimitException |
398 | 398 | */ |
399 | - protected function _checkFileSizeLimit($path, $message='') |
|
399 | + protected function _checkFileSizeLimit($path, $message = '') |
|
400 | 400 | { |
401 | 401 | if (function_exists('ini_get')) { |
402 | 402 | $bytes = to_bytes(ini_get('memory_limit')); |
@@ -203,8 +203,7 @@ |
||
203 | 203 | $file = DbFile::findOne($dirname); |
204 | 204 | if ($file === null) { |
205 | 205 | $file = new DbFile(['path' => $dirname]); |
206 | - } |
|
207 | - else if ($file->type == DbFile::TYPE_FILE) { |
|
206 | + } else if ($file->type == DbFile::TYPE_FILE) { |
|
208 | 207 | throw new FileExistsException('Can not create a directory as a file already exists.'); |
209 | 208 | } |
210 | 209 | if ($visibility = $config->get('visibility')) { |
@@ -179,11 +179,11 @@ |
||
179 | 179 | |
180 | 180 | // get the adapter driver for the drive (e.g. S3 | local) |
181 | 181 | $configObj = (new $driver($config)); |
182 | - if ( ! $configObj instanceof IDriverConfig) { |
|
182 | + if (!$configObj instanceof IDriverConfig) { |
|
183 | 183 | throw new \InvalidArgumentException('The driver specified is not a valid implementation of \neon\firefly\services\fileSystem\interfaces\IDriverConfig'); |
184 | 184 | } |
185 | 185 | $driverObj = $configObj->getAdapter(); |
186 | - if ( ! $driverObj instanceof AdapterInterface) { |
|
186 | + if (!$driverObj instanceof AdapterInterface) { |
|
187 | 187 | throw new \InvalidArgumentException('The driver config object ('.$driver.') does not provide a valid driver implementing \League\Flysystem\AdapterInterface'); |
188 | 188 | } |
189 | 189 | // get the generic Filesystem adapter |
@@ -51,68 +51,68 @@ discard block |
||
51 | 51 | * Receiver constructor. |
52 | 52 | * @param Request $request |
53 | 53 | */ |
54 | - public function __construct(Request $request) |
|
55 | - { |
|
56 | - $this->_request = $request; |
|
57 | - } |
|
54 | + public function __construct(Request $request) |
|
55 | + { |
|
56 | + $this->_request = $request; |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Get the temporary path where plupload will store the file uploads |
|
61 | - * @return string - writable directory path |
|
62 | - */ |
|
63 | - public function getPath() |
|
64 | - { |
|
65 | - $path = neon()->getAlias('@runtime/plupload'); |
|
66 | - if (!is_dir($path)) { |
|
67 | - mkdir($path, 0755, true); |
|
68 | - } |
|
69 | - return $path; |
|
70 | - } |
|
59 | + /** |
|
60 | + * Get the temporary path where plupload will store the file uploads |
|
61 | + * @return string - writable directory path |
|
62 | + */ |
|
63 | + public function getPath() |
|
64 | + { |
|
65 | + $path = neon()->getAlias('@runtime/plupload'); |
|
66 | + if (!is_dir($path)) { |
|
67 | + mkdir($path, 0755, true); |
|
68 | + } |
|
69 | + return $path; |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * Whether the plupload upload will be uploaded in chunks |
|
74 | - * @return bool |
|
75 | - */ |
|
76 | - public function hasChunks() |
|
77 | - { |
|
78 | - return (bool) $this->_request->getBodyParam('chunks', false); |
|
79 | - } |
|
72 | + /** |
|
73 | + * Whether the plupload upload will be uploaded in chunks |
|
74 | + * @return bool |
|
75 | + */ |
|
76 | + public function hasChunks() |
|
77 | + { |
|
78 | + return (bool) $this->_request->getBodyParam('chunks', false); |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * Receive a plupload upload |
|
83 | - * @param string $name - Name of the request variable that holds |
|
84 | - * the plupload file(s) - typically the name of the plupload input field |
|
85 | - * @param \Closure $handler - A handler function that is passed the uploaded file |
|
86 | - * method signature is: function(\neon\core\web\UploadedFile $file) {} |
|
87 | - * @return array - return the result of the upload back to plupload, this should be json encoded |
|
88 | - */ |
|
89 | - public function receive($name, \Closure $handler) |
|
90 | - { |
|
91 | - $response = []; |
|
92 | - $response['jsonrpc'] = '2.0'; |
|
93 | - if ($this->hasChunks()) { |
|
94 | - $result = $this->receiveChunks($name, $handler); |
|
95 | - } else { |
|
96 | - $result = $this->receiveSingle($name, $handler); |
|
97 | - } |
|
98 | - $response['result'] = $result; |
|
99 | - $response['id'] = 'plup'; |
|
100 | - return $response; |
|
101 | - } |
|
81 | + /** |
|
82 | + * Receive a plupload upload |
|
83 | + * @param string $name - Name of the request variable that holds |
|
84 | + * the plupload file(s) - typically the name of the plupload input field |
|
85 | + * @param \Closure $handler - A handler function that is passed the uploaded file |
|
86 | + * method signature is: function(\neon\core\web\UploadedFile $file) {} |
|
87 | + * @return array - return the result of the upload back to plupload, this should be json encoded |
|
88 | + */ |
|
89 | + public function receive($name, \Closure $handler) |
|
90 | + { |
|
91 | + $response = []; |
|
92 | + $response['jsonrpc'] = '2.0'; |
|
93 | + if ($this->hasChunks()) { |
|
94 | + $result = $this->receiveChunks($name, $handler); |
|
95 | + } else { |
|
96 | + $result = $this->receiveSingle($name, $handler); |
|
97 | + } |
|
98 | + $response['result'] = $result; |
|
99 | + $response['id'] = 'plup'; |
|
100 | + return $response; |
|
101 | + } |
|
102 | 102 | |
103 | - /** |
|
104 | - * Process single file upload |
|
105 | - * @param string $name |
|
106 | - * @param \Closure $handler - function to call on successful upload completed |
|
107 | - * @return bool|mixed |
|
108 | - */ |
|
109 | - public function receiveSingle($name, \Closure $handler) |
|
110 | - { |
|
111 | - if ($this->_request->file($name)) { |
|
112 | - return $handler($this->_request->file($name)); |
|
113 | - } |
|
114 | - return false; |
|
115 | - } |
|
103 | + /** |
|
104 | + * Process single file upload |
|
105 | + * @param string $name |
|
106 | + * @param \Closure $handler - function to call on successful upload completed |
|
107 | + * @return bool|mixed |
|
108 | + */ |
|
109 | + public function receiveSingle($name, \Closure $handler) |
|
110 | + { |
|
111 | + if ($this->_request->file($name)) { |
|
112 | + return $handler($this->_request->file($name)); |
|
113 | + } |
|
114 | + return false; |
|
115 | + } |
|
116 | 116 | |
117 | 117 | /** |
118 | 118 | * Process chunked file upload |
@@ -121,30 +121,30 @@ discard block |
||
121 | 121 | * @throws \Exception |
122 | 122 | * @return bool |
123 | 123 | */ |
124 | - public function receiveChunks($name, $handler) |
|
125 | - { |
|
126 | - $result = false; |
|
127 | - if ($this->_request->file($name)) { |
|
128 | - $file = $this->_request->file($name); |
|
129 | - $chunk = (int) $this->_request->getBodyParam("chunk", 0); |
|
130 | - $chunks = (int) $this->_request->getBodyParam("chunks", 0 ); |
|
131 | - $originalName = $this->_request->getBodyParam('name'); |
|
132 | - $filePath = $this->getPath().'/'.$originalName.'.part'; |
|
133 | - $this->_removeOldData($filePath); |
|
134 | - $this->_appendData($filePath, $file); |
|
135 | - if ($chunk == $chunks - 1) { |
|
136 | - $file = new UploadedFile([ |
|
137 | - 'name' => $originalName, |
|
138 | - 'size' => filesize($filePath), |
|
139 | - 'tempName' => $filePath, |
|
140 | - 'error' => UPLOAD_ERR_OK |
|
141 | - ]); |
|
142 | - $result = $handler($file); |
|
143 | - unlink($filePath); |
|
144 | - } |
|
145 | - } |
|
146 | - return $result; |
|
147 | - } |
|
124 | + public function receiveChunks($name, $handler) |
|
125 | + { |
|
126 | + $result = false; |
|
127 | + if ($this->_request->file($name)) { |
|
128 | + $file = $this->_request->file($name); |
|
129 | + $chunk = (int) $this->_request->getBodyParam("chunk", 0); |
|
130 | + $chunks = (int) $this->_request->getBodyParam("chunks", 0 ); |
|
131 | + $originalName = $this->_request->getBodyParam('name'); |
|
132 | + $filePath = $this->getPath().'/'.$originalName.'.part'; |
|
133 | + $this->_removeOldData($filePath); |
|
134 | + $this->_appendData($filePath, $file); |
|
135 | + if ($chunk == $chunks - 1) { |
|
136 | + $file = new UploadedFile([ |
|
137 | + 'name' => $originalName, |
|
138 | + 'size' => filesize($filePath), |
|
139 | + 'tempName' => $filePath, |
|
140 | + 'error' => UPLOAD_ERR_OK |
|
141 | + ]); |
|
142 | + $result = $handler($file); |
|
143 | + unlink($filePath); |
|
144 | + } |
|
145 | + } |
|
146 | + return $result; |
|
147 | + } |
|
148 | 148 | |
149 | 149 | /** |
150 | 150 | * Todo: requires test |
@@ -164,15 +164,15 @@ discard block |
||
164 | 164 | * @param string $path Optional firefly media virtual path |
165 | 165 | * @return array |
166 | 166 | */ |
167 | - public function receiveToFirefly($name, $path='/') |
|
168 | - { |
|
169 | - return $this->receive($name, function (UploadedFile $file) use ($path) { |
|
170 | - // save file to firefly |
|
171 | - $id = neon()->firefly->fileManager->saveFile($file); |
|
172 | - $meta = neon()->firefly->mediaManager->addFile($id, $path); |
|
173 | - return $meta; |
|
174 | - }); |
|
175 | - } |
|
167 | + public function receiveToFirefly($name, $path='/') |
|
168 | + { |
|
169 | + return $this->receive($name, function (UploadedFile $file) use ($path) { |
|
170 | + // save file to firefly |
|
171 | + $id = neon()->firefly->fileManager->saveFile($file); |
|
172 | + $meta = neon()->firefly->mediaManager->addFile($id, $path); |
|
173 | + return $meta; |
|
174 | + }); |
|
175 | + } |
|
176 | 176 | |
177 | 177 | /** |
178 | 178 | * Receives a file and saves it to firefly file manager only. |
@@ -206,29 +206,29 @@ discard block |
||
206 | 206 | * @param UploadedFile $file |
207 | 207 | * @throws PluploadException |
208 | 208 | */ |
209 | - protected function _appendData($filePathPartial, UploadedFile $file) |
|
210 | - { |
|
211 | - if (!$out = fopen($filePathPartial, 'ab')) { |
|
212 | - throw new PluploadException('Failed to open output stream.', 102); |
|
213 | - } |
|
214 | - if (!$in = fopen($file->getRealPath(), 'rb')) { |
|
215 | - throw new PluploadException('Failed to open input stream', 101); |
|
216 | - } |
|
217 | - while ($buff = fread($in, 4096)) { |
|
218 | - fwrite($out, $buff); |
|
219 | - } |
|
220 | - fclose($out); |
|
221 | - fclose($in); |
|
222 | - } |
|
209 | + protected function _appendData($filePathPartial, UploadedFile $file) |
|
210 | + { |
|
211 | + if (!$out = fopen($filePathPartial, 'ab')) { |
|
212 | + throw new PluploadException('Failed to open output stream.', 102); |
|
213 | + } |
|
214 | + if (!$in = fopen($file->getRealPath(), 'rb')) { |
|
215 | + throw new PluploadException('Failed to open input stream', 101); |
|
216 | + } |
|
217 | + while ($buff = fread($in, 4096)) { |
|
218 | + fwrite($out, $buff); |
|
219 | + } |
|
220 | + fclose($out); |
|
221 | + fclose($in); |
|
222 | + } |
|
223 | 223 | |
224 | 224 | /** |
225 | 225 | * Remove old files |
226 | 226 | * @param string $filePath |
227 | 227 | */ |
228 | - protected function _removeOldData($filePath) |
|
229 | - { |
|
230 | - if (file_exists($filePath) && filemtime($filePath) < time() - $this->maxFileAge) { |
|
231 | - unlink($filePath); |
|
232 | - } |
|
233 | - } |
|
228 | + protected function _removeOldData($filePath) |
|
229 | + { |
|
230 | + if (file_exists($filePath) && filemtime($filePath) < time() - $this->maxFileAge) { |
|
231 | + unlink($filePath); |
|
232 | + } |
|
233 | + } |
|
234 | 234 | } |
235 | 235 | \ No newline at end of file |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | if ($this->_request->file($name)) { |
128 | 128 | $file = $this->_request->file($name); |
129 | 129 | $chunk = (int) $this->_request->getBodyParam("chunk", 0); |
130 | - $chunks = (int) $this->_request->getBodyParam("chunks", 0 ); |
|
130 | + $chunks = (int) $this->_request->getBodyParam("chunks", 0); |
|
131 | 131 | $originalName = $this->_request->getBodyParam('name'); |
132 | 132 | $filePath = $this->getPath().'/'.$originalName.'.part'; |
133 | 133 | $this->_removeOldData($filePath); |
@@ -164,9 +164,9 @@ discard block |
||
164 | 164 | * @param string $path Optional firefly media virtual path |
165 | 165 | * @return array |
166 | 166 | */ |
167 | - public function receiveToFirefly($name, $path='/') |
|
167 | + public function receiveToFirefly($name, $path = '/') |
|
168 | 168 | { |
169 | - return $this->receive($name, function (UploadedFile $file) use ($path) { |
|
169 | + return $this->receive($name, function(UploadedFile $file) use ($path) { |
|
170 | 170 | // save file to firefly |
171 | 171 | $id = neon()->firefly->fileManager->saveFile($file); |
172 | 172 | $meta = neon()->firefly->mediaManager->addFile($id, $path); |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | public function receiveToFireflyFileManager($name) |
195 | 195 | { |
196 | - return $this->receive($name, function (UploadedFile $file) { |
|
196 | + return $this->receive($name, function(UploadedFile $file) { |
|
197 | 197 | // save file to firefly |
198 | 198 | $id = neon()->firefly->fileManager->saveFile($file); |
199 | 199 | return neon()->firefly->fileManager->getMeta($id); |
@@ -138,7 +138,7 @@ |
||
138 | 138 | * Send appropriate cache headers |
139 | 139 | * @param string $mime - mime type of file |
140 | 140 | * @param string|int $size - size in bytes of response |
141 | - * @param string $modified - MySQL Datetime |
|
141 | + * @param string $modified - MySQL Datetime |
|
142 | 142 | * @param string $eTag - eTag token header to use |
143 | 143 | * @param string $name - filename string to use in content disposition header |
144 | 144 | */ |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $id = $request->get('id'); |
38 | 38 | if (!$firefly->fileManager->exists($id)) { |
39 | 39 | // show placeholder image - should be handled by image manager - controllers should not know |
40 | - return neon()->response->sendFile(dirname(__DIR__) . '/assets/placeholder.jpg', 'No File', ['inline' => true]); |
|
40 | + return neon()->response->sendFile(dirname(__DIR__).'/assets/placeholder.jpg', 'No File', ['inline' => true]); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | // as the url is unique for a file we can be aggressive about caching |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | return $firefly->fileManager->sendFile($id, (bool) $download); |
56 | 56 | } catch (\Exception $e) { |
57 | 57 | // if path unknown respond with a blank placeholder |
58 | - return neon()->response->sendFile(dirname(__DIR__) . '/assets/placeholder.jpg', 'No File', ['inline' => true]); |
|
58 | + return neon()->response->sendFile(dirname(__DIR__).'/assets/placeholder.jpg', 'No File', ['inline' => true]); |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $id = neon()->request->getRequired('id'); |
82 | 82 | |
83 | 83 | // create a unique request key - add v2 to force use of new cached version |
84 | - $requestKey = neon()->request->absoluteUrl . 'v10'; |
|
84 | + $requestKey = neon()->request->absoluteUrl.'v10'; |
|
85 | 85 | |
86 | 86 | // see if we already have this in cache and the browser already has it too |
87 | 87 | // We want to remove the need to process images when ever possible |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function generatePublicFile($id, $imageContent) |
134 | 134 | { |
135 | - $dir = substr($id,0, 3); |
|
135 | + $dir = substr($id, 0, 3); |
|
136 | 136 | $publicDir = neon()->getAlias("@webroot/assets/firefly/$dir"); |
137 | 137 | if (!file_exists($publicDir)) { |
138 | 138 | FileHelper::createDirectory($publicDir); |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | * Handle a request that can return a 304 not modified header |
168 | 168 | * @param bool|string $cacheKey - default false - if cache key is specified |
169 | 169 | */ |
170 | - public function handleNotModified($cacheKey=false) |
|
170 | + public function handleNotModified($cacheKey = false) |
|
171 | 171 | { |
172 | 172 | $requestHeaders = neon()->request->headers; |
173 | 173 | $browserHasCache = (isset($requestHeaders['If-Modified-Since']) || isset($requestHeaders['If-None-Match'])); |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | { |
184 | 184 | header($_SERVER['SERVER_PROTOCOL'].' 304 Not modified'); |
185 | 185 | header('Cache-Control: private, max-age=30000000, immutable, only-if-cached'); |
186 | - header('Expires: ' . Carbon::now()->addYear(10)->toRfc1123String()); |
|
186 | + header('Expires: '.Carbon::now()->addYear(10)->toRfc1123String()); |
|
187 | 187 | exit; |
188 | 188 | } |
189 | 189 |
@@ -46,8 +46,9 @@ discard block |
||
46 | 46 | |
47 | 47 | // set expiry information on the file |
48 | 48 | $meta = $firefly->fileManager->getMeta($id); |
49 | - if ($meta['mime_type'] == 'image/svg') |
|
50 | - $meta['mime_type'] = 'image/svg+xml'; |
|
49 | + if ($meta['mime_type'] == 'image/svg') { |
|
50 | + $meta['mime_type'] = 'image/svg+xml'; |
|
51 | + } |
|
51 | 52 | $this->sendCacheHeaders($meta['mime_type'], $meta['size'], $meta['updated_at'], md5($request->absoluteUrl), $meta['name']); |
52 | 53 | $download = $request->get('download', $request->get('dl', false)); |
53 | 54 | try { |
@@ -110,7 +111,9 @@ discard block |
||
110 | 111 | $processedImage = neon()->firefly->imageManager->process($idOrUrl, neon()->request->get()); |
111 | 112 | $mimeType = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $processedImage); |
112 | 113 | // svgs don't seem display in browsers without specifically the svg+xml mime type |
113 | - if ($mimeType === 'image/svg') $mimeType = 'image/svg+xml'; |
|
114 | + if ($mimeType === 'image/svg') { |
|
115 | + $mimeType = 'image/svg+xml'; |
|
116 | + } |
|
114 | 117 | return [ |
115 | 118 | // recalculate the mime type in case was spoofed |
116 | 119 | 'size' => strlen($processedImage), |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param string $path GET variable 'path' e.g. /my/folder |
94 | 94 | * @return array |
95 | 95 | */ |
96 | - public function actionList($path='', $deleted=0) |
|
96 | + public function actionList($path = '', $deleted = 0) |
|
97 | 97 | { |
98 | 98 | $items = neon()->firefly->mediaManager->listContents($path, $deleted); |
99 | 99 | return ['data' => [ |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $transform = neon()->request->getBodyParam('transform'); |
129 | 129 | // information of the current file |
130 | 130 | $sourceMeta = neon()->firefly->getMeta($transform['sourceImage']); |
131 | - $transform['rotate'] = Arr::get($transform, 'crop.rotate', false); |
|
131 | + $transform['rotate'] = Arr::get($transform, 'crop.rotate', false); |
|
132 | 132 | $width = Arr::get($transform, 'crop.width', false); |
133 | 133 | $height = Arr::get($transform, 'crop.height', false); |
134 | 134 |
@@ -221,15 +221,18 @@ |
||
221 | 221 | { |
222 | 222 | $items = neon()->request->getBodyParam('items'); |
223 | 223 | $into = neon()->request->getBodyParam('into'); |
224 | - if ($items === null) |
|
225 | - throw new BadRequestHttpException('You must specify an "items" parameter - containing an array of item ids to move'); |
|
226 | - if ($into === null) |
|
227 | - throw new BadRequestHttpException('You must specify an "into" parameter - specifying the directory to move the items into'); |
|
224 | + if ($items === null) { |
|
225 | + throw new BadRequestHttpException('You must specify an "items" parameter - containing an array of item ids to move'); |
|
226 | + } |
|
227 | + if ($into === null) { |
|
228 | + throw new BadRequestHttpException('You must specify an "into" parameter - specifying the directory to move the items into'); |
|
229 | + } |
|
228 | 230 | if (strpos($into, '/') !== false) { |
229 | 231 | // into has been specified as a path |
230 | 232 | $dir = neon()->firefly->mediaManager->getDirectoryMeta($into); |
231 | - if ($dir === null) |
|
232 | - throw new BadRequestHttpException("No directory exists with the specified path of '$into' "); |
|
233 | + if ($dir === null) { |
|
234 | + throw new BadRequestHttpException("No directory exists with the specified path of '$into' "); |
|
235 | + } |
|
233 | 236 | $into = $dir['id']; |
234 | 237 | } |
235 | 238 | return neon()->firefly->mediaManager->move($items, $into); |
@@ -4,17 +4,17 @@ |
||
4 | 4 | |
5 | 5 | class m170830_121945_firefly_change_local_drive_to_media extends Migration |
6 | 6 | { |
7 | - public function safeUp() |
|
8 | - { |
|
9 | - $this->execute('UPDATE firefly_file_manager SET drive = "media" WHERE drive = "local"'); |
|
10 | - } |
|
7 | + public function safeUp() |
|
8 | + { |
|
9 | + $this->execute('UPDATE firefly_file_manager SET drive = "media" WHERE drive = "local"'); |
|
10 | + } |
|
11 | 11 | |
12 | - public function safeDown() |
|
13 | - { |
|
14 | - $this->execute('UPDATE firefly_file_manager SET drive = "local" WHERE drive = "media"'); |
|
15 | - } |
|
12 | + public function safeDown() |
|
13 | + { |
|
14 | + $this->execute('UPDATE firefly_file_manager SET drive = "local" WHERE drive = "media"'); |
|
15 | + } |
|
16 | 16 | |
17 | - /* |
|
17 | + /* |
|
18 | 18 | // Use up()/down() to run migration code without a transaction. |
19 | 19 | public function up() |
20 | 20 | { |
@@ -5,8 +5,8 @@ discard block |
||
5 | 5 | |
6 | 6 | class m161123_191412_firefly_files_table extends Migration |
7 | 7 | { |
8 | - public function safeUp() |
|
9 | - { |
|
8 | + public function safeUp() |
|
9 | + { |
|
10 | 10 | $this->createTable(DbFile::tableName(), [ |
11 | 11 | // limit the path size on the db file storage driver. |
12 | 12 | // otherwise the key gets too big. |
@@ -35,11 +35,11 @@ discard block |
||
35 | 35 | 'created_at' => $this->datetime()->comment('When the file was first created'), |
36 | 36 | 'PRIMARY KEY (`path`(150))' |
37 | 37 | ]); |
38 | - } |
|
38 | + } |
|
39 | 39 | |
40 | - public function safeDown() |
|
41 | - { |
|
40 | + public function safeDown() |
|
41 | + { |
|
42 | 42 | $this->dropTable(DbFile::tableName()); |
43 | - } |
|
43 | + } |
|
44 | 44 | |
45 | 45 | } |