@@ -11,13 +11,10 @@ |
||
| 11 | 11 | |
| 12 | 12 | namespace Icybee\Modules\Files\Block; |
| 13 | 13 | |
| 14 | -use ICanBoogie\I18n; |
|
| 15 | 14 | use ICanBoogie\Operation; |
| 16 | - |
|
| 17 | 15 | use Brickrouge\Element; |
| 18 | 16 | use Brickrouge\Document; |
| 19 | 17 | use Brickrouge\Form; |
| 20 | - |
|
| 21 | 18 | use Icybee\Modules\Files as Root; |
| 22 | 19 | use Icybee\Modules\Files\File; |
| 23 | 20 | |
@@ -75,8 +75,7 @@ |
||
| 75 | 75 | try |
| 76 | 76 | { |
| 77 | 77 | $path = $this->record->pathname->relative; |
| 78 | - } |
|
| 79 | - catch (\Exception $e) |
|
| 78 | + } catch (\Exception $e) |
|
| 80 | 79 | { |
| 81 | 80 | # |
| 82 | 81 | # the associated file might have disappeared |
@@ -36,8 +36,8 @@ discard block |
||
| 36 | 36 | { |
| 37 | 37 | parent::add_assets($document); |
| 38 | 38 | |
| 39 | - $document->css->add(Root\DIR . 'public/edit.css'); |
|
| 40 | - $document->js->add(Root\DIR . 'public/edit.js'); |
|
| 39 | + $document->css->add(Root\DIR.'public/edit.css'); |
|
| 40 | + $document->js->add(Root\DIR.'public/edit.js'); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | protected function lazy_get_values() |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | protected function lazy_get_children() |
| 54 | 54 | { |
| 55 | - $folder = \ICanBoogie\REPOSITORY . 'tmp'; |
|
| 55 | + $folder = \ICanBoogie\REPOSITORY.'tmp'; |
|
| 56 | 56 | |
| 57 | 57 | if (!is_writable($folder)) |
| 58 | 58 | { |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | Element::CHILDREN => [ |
| 62 | 62 | |
| 63 | - $this->t('The folder %folder is not writable !', [ '%folder' => $folder ]) |
|
| 63 | + $this->t('The folder %folder is not writable !', ['%folder' => $folder]) |
|
| 64 | 64 | |
| 65 | 65 | ] |
| 66 | 66 | ]; |
@@ -117,9 +117,9 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | Form::LABEL => 'file', |
| 119 | 119 | Element::REQUIRED => empty($nid), |
| 120 | - \Brickrouge\File::FILE_WITH_LIMIT => $this->app->site->metas[$this->module->flat_id . '.max_file_size'], |
|
| 120 | + \Brickrouge\File::FILE_WITH_LIMIT => $this->app->site->metas[$this->module->flat_id.'.max_file_size'], |
|
| 121 | 121 | Element::WEIGHT => -100, |
| 122 | - \Brickrouge\File::T_UPLOAD_URL => Operation::encode($this->module->id . '/upload'), |
|
| 122 | + \Brickrouge\File::T_UPLOAD_URL => Operation::encode($this->module->id.'/upload'), |
|
| 123 | 123 | |
| 124 | 124 | 'value' => $path |
| 125 | 125 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | class Hooks |
| 20 | 20 | { |
| 21 | 21 | /** |
| 22 | - * @param Core|Binding\CoreBindings $app |
|
| 22 | + * @param Core $app |
|
| 23 | 23 | * |
| 24 | 24 | * @return FileStorageIndex |
| 25 | 25 | */ |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | - * @param Core|Binding\CoreBindings $app |
|
| 34 | + * @param Core $app |
|
| 35 | 35 | * |
| 36 | 36 | * @return FileStorage |
| 37 | 37 | */ |
@@ -14,7 +14,6 @@ |
||
| 14 | 14 | use ICanBoogie\Errors; |
| 15 | 15 | use ICanBoogie\HTTP\Request; |
| 16 | 16 | use ICanBoogie\HTTP\File as HTTPFile; |
| 17 | - |
|
| 18 | 17 | use Icybee\Modules\Files\File; |
| 19 | 18 | use Icybee\Modules\Files\Module; |
| 20 | 19 | |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | { |
| 28 | 28 | static $index; |
| 29 | 29 | |
| 30 | - return $index ?: $index = new FileStorageIndex(\ICanBoogie\REPOSITORY . 'files-index'); |
|
| 30 | + return $index ?: $index = new FileStorageIndex(\ICanBoogie\REPOSITORY.'files-index'); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -39,6 +39,6 @@ discard block |
||
| 39 | 39 | { |
| 40 | 40 | static $manager; |
| 41 | 41 | |
| 42 | - return $manager ?: $manager = new FileStorage(\ICanBoogie\REPOSITORY . 'files', $app->file_storage_index); |
|
| 42 | + return $manager ?: $manager = new FileStorage(\ICanBoogie\REPOSITORY.'files', $app->file_storage_index); |
|
| 43 | 43 | } |
| 44 | 44 | } |
@@ -14,7 +14,6 @@ |
||
| 14 | 14 | use ICanBoogie\Errors; |
| 15 | 15 | use ICanBoogie\HTTP\Request; |
| 16 | 16 | use ICanBoogie\HTTP\File as HTTPFile; |
| 17 | - |
|
| 18 | 17 | use Icybee\Modules\Files\File; |
| 19 | 18 | use Icybee\Modules\Files\Module; |
| 20 | 19 | |
@@ -114,8 +114,7 @@ discard block |
||
| 114 | 114 | $pathname = \ICanBoogie\REPOSITORY . 'tmp' . DIRECTORY_SEPARATOR . $filename; |
| 115 | 115 | |
| 116 | 116 | $file->move($pathname); |
| 117 | - } |
|
| 118 | - else if ($path && strpos($path, \ICanBoogie\strip_root(\ICanBoogie\REPOSITORY . "files")) !== 0) |
|
| 117 | + } else if ($path && strpos($path, \ICanBoogie\strip_root(\ICanBoogie\REPOSITORY . "files")) !== 0) |
|
| 119 | 118 | { |
| 120 | 119 | $file = $this->resolve_request_file_from_pathname($path); |
| 121 | 120 | |
@@ -175,8 +174,7 @@ discard block |
||
| 175 | 174 | |
| 176 | 175 | ]); |
| 177 | 176 | } |
| 178 | - } |
|
| 179 | - else if (!$this->key) |
|
| 177 | + } else if (!$this->key) |
|
| 180 | 178 | { |
| 181 | 179 | $errors->add(File::HTTP_FILE, "File is required."); |
| 182 | 180 | } |
@@ -111,17 +111,17 @@ discard block |
||
| 111 | 111 | if ($file && $file->is_valid) |
| 112 | 112 | { |
| 113 | 113 | $filename = \ICanBoogie\generate_v4_uuid(); |
| 114 | - $pathname = \ICanBoogie\REPOSITORY . 'tmp' . DIRECTORY_SEPARATOR . $filename; |
|
| 114 | + $pathname = \ICanBoogie\REPOSITORY.'tmp'.DIRECTORY_SEPARATOR.$filename; |
|
| 115 | 115 | |
| 116 | 116 | $file->move($pathname); |
| 117 | 117 | } |
| 118 | - else if ($path && strpos($path, \ICanBoogie\strip_root(\ICanBoogie\REPOSITORY . "files")) !== 0) |
|
| 118 | + else if ($path && strpos($path, \ICanBoogie\strip_root(\ICanBoogie\REPOSITORY."files")) !== 0) |
|
| 119 | 119 | { |
| 120 | 120 | $file = $this->resolve_request_file_from_pathname($path); |
| 121 | 121 | |
| 122 | 122 | if (!$file) |
| 123 | 123 | { |
| 124 | - $this->response->errors->add(File::HTTP_FILE, "Invalid or deleted file: %pathname", [ 'pathname' => $path ]); |
|
| 124 | + $this->response->errors->add(File::HTTP_FILE, "Invalid or deleted file: %pathname", ['pathname' => $path]); |
|
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | $error_message = $errors->add( |
| 162 | 162 | File::HTTP_FILE, |
| 163 | 163 | "Maximum file size is :size Mb", |
| 164 | - [ ':size' => round($max_file_size / 1024) ] |
|
| 164 | + [':size' => round($max_file_size / 1024)] |
|
| 165 | 165 | ); |
| 166 | 166 | } |
| 167 | 167 | |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | $error_message = $errors->add( |
| 171 | 171 | File::HTTP_FILE, |
| 172 | 172 | "Only the following file types are accepted: %accepted.", |
| 173 | - [ '%accepted' => implode(', ', $this->accept) |
|
| 173 | + ['%accepted' => implode(', ', $this->accept) |
|
| 174 | 174 | ]); |
| 175 | 175 | } |
| 176 | 176 | |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | protected function resolve_request_file_from_pathname($pathname) |
| 221 | 221 | { |
| 222 | 222 | $filename = basename($pathname); |
| 223 | - $info_pathname = \ICanBoogie\REPOSITORY . 'tmp' . DIRECTORY_SEPARATOR . $filename . '.info'; |
|
| 223 | + $info_pathname = \ICanBoogie\REPOSITORY.'tmp'.DIRECTORY_SEPARATOR.$filename.'.info'; |
|
| 224 | 224 | |
| 225 | 225 | if (!file_exists($info_pathname)) |
| 226 | 226 | { |
@@ -12,12 +12,10 @@ |
||
| 12 | 12 | namespace Icybee\Modules\Files\Routing; |
| 13 | 13 | |
| 14 | 14 | use ICanBoogie\HTTP\FileResponse; |
| 15 | -use ICanBoogie\HTTP\Request; |
|
| 16 | 15 | use ICanBoogie\Routing\Controller; |
| 17 | 16 | use ICanBoogie\Binding\Routing\ControllerBindings; |
| 18 | 17 | use ICanBoogie\Binding\Routing\ForwardUndefinedPropertiesToApplication; |
| 19 | 18 | use ICanBoogie\Module\ControllerBindings as ModuleBindings; |
| 20 | - |
|
| 21 | 19 | use Icybee\Modules\Files\Binding\CoreBindings; |
| 22 | 20 | use Icybee\Modules\Files\File; |
| 23 | 21 | |
@@ -80,7 +80,7 @@ |
||
| 80 | 80 | return new FileResponse($pathname, $this->request, [ |
| 81 | 81 | |
| 82 | 82 | FileResponse::OPTION_ETAG => $pathname->hash, |
| 83 | - FileResponse::OPTION_FILENAME => $record->title . $record->extension, |
|
| 83 | + FileResponse::OPTION_FILENAME => $record->title.$record->extension, |
|
| 84 | 84 | FileResponse::OPTION_MIME => $record->mime |
| 85 | 85 | |
| 86 | 86 | ]); |
@@ -105,7 +105,7 @@ |
||
| 105 | 105 | * |
| 106 | 106 | * If a file has no reference left it is deleted. |
| 107 | 107 | * |
| 108 | - * @param $key_or_id_or_uuid_or_hash |
|
| 108 | + * @param string $key_or_id_or_uuid_or_hash |
|
| 109 | 109 | */ |
| 110 | 110 | public function release($key_or_id_or_uuid_or_hash) |
| 111 | 111 | { |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | throw new \InvalidArgumentException("`\$root` parameter cannot be empty."); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - $this->root = rtrim($root, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
|
| 55 | + $this->root = rtrim($root, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; |
|
| 56 | 56 | $this->index = $index; |
| 57 | 57 | } |
| 58 | 58 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | { |
| 70 | 70 | $this->assert_hash_is_used($hash); |
| 71 | 71 | |
| 72 | - $key = IndexKey::from([ $nid, $uuid, $hash ]); |
|
| 72 | + $key = IndexKey::from([$nid, $uuid, $hash]); |
|
| 73 | 73 | |
| 74 | 74 | $this->index->add($key); |
| 75 | 75 | |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | protected function find_by_hash($hash) |
| 166 | 166 | { |
| 167 | 167 | $di = new \DirectoryIterator($this->root); |
| 168 | - $di = new \RegexIterator($di, '#^' . preg_quote($hash) . '\-#'); |
|
| 168 | + $di = new \RegexIterator($di, '#^'.preg_quote($hash).'\-#'); |
|
| 169 | 169 | |
| 170 | 170 | foreach ($di as $file) |
| 171 | 171 | { |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | { |
| 205 | 205 | $hash = $hash ?: $this->hash($pathname); |
| 206 | 206 | |
| 207 | - return Pathname::from([ $this->root, $hash ]); |
|
| 207 | + return Pathname::from([$this->root, $hash]); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | /** |
@@ -118,7 +118,7 @@ |
||
| 118 | 118 | /** |
| 119 | 119 | * Deletes key(s) from the index. |
| 120 | 120 | * |
| 121 | - * @param IndexKey|int|string $key_or_id_or_uuid_or_hash |
|
| 121 | + * @param IndexKey $key_or_id_or_uuid_or_hash |
|
| 122 | 122 | * |
| 123 | 123 | * @throws \InvalidArgumentException if `$key_or_id_or_uuid_or_hash` is not of the expected type. |
| 124 | 124 | */ |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public function __construct($root) |
| 82 | 82 | { |
| 83 | - $this->root = rtrim($root, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
|
| 83 | + $this->root = rtrim($root, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public function add(IndexKey $key) |
| 94 | 94 | { |
| 95 | - touch($this->root . $key); |
|
| 95 | + touch($this->root.$key); |
|
| 96 | 96 | |
| 97 | 97 | foreach ($this->find_by_id($key->id) as $match) |
| 98 | 98 | { |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | foreach ($matching as $match) |
| 135 | 135 | { |
| 136 | - unlink($this->root . $match); |
|
| 136 | + unlink($this->root.$match); |
|
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | $type = $methods[self::resolve_matching_type($key_or_id_or_uuid_or_hash)]; |
| 161 | 161 | |
| 162 | - return $this->{ 'find_by_' . $type }($key_or_id_or_uuid_or_hash); |
|
| 162 | + return $this->{ 'find_by_'.$type }($key_or_id_or_uuid_or_hash); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -171,9 +171,9 @@ discard block |
||
| 171 | 171 | */ |
| 172 | 172 | protected function find_by_key($key) |
| 173 | 173 | { |
| 174 | - $pathname = $this->root . $key; |
|
| 174 | + $pathname = $this->root.$key; |
|
| 175 | 175 | |
| 176 | - return file_exists($pathname) ? [ $key ] : null; |
|
| 176 | + return file_exists($pathname) ? [$key] : null; |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | */ |
| 186 | 186 | protected function find_by_id($id) |
| 187 | 187 | { |
| 188 | - return $this->matching('#^' . preg_quote(IndexKey::encode_id($id)) . '\-#'); |
|
| 188 | + return $this->matching('#^'.preg_quote(IndexKey::encode_id($id)).'\-#'); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | /** |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | */ |
| 198 | 198 | protected function find_by_encoded_uuid($encoded_uuid) |
| 199 | 199 | { |
| 200 | - return $this->matching("#^.{" . IndexKey::ENCODED_ID_LENGTH . '}\-' . preg_quote($encoded_uuid) . '\-#'); |
|
| 200 | + return $this->matching("#^.{".IndexKey::ENCODED_ID_LENGTH.'}\-'.preg_quote($encoded_uuid).'\-#'); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | */ |
| 222 | 222 | protected function find_by_hash($hash) |
| 223 | 223 | { |
| 224 | - return $this->matching("#^.{" . IndexKey::ENCODED_ID_LENGTH . '}\-.{' . IndexKey::ENCODED_UUID_LENGTH . '}\-' . preg_quote($hash) . '#'); |
|
| 224 | + return $this->matching("#^.{".IndexKey::ENCODED_ID_LENGTH.'}\-.{'.IndexKey::ENCODED_UUID_LENGTH.'}\-'.preg_quote($hash).'#'); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | /** |
@@ -69,7 +69,7 @@ |
||
| 69 | 69 | * |
| 70 | 70 | * @param string $key |
| 71 | 71 | * |
| 72 | - * @return array |
|
| 72 | + * @return string[] |
|
| 73 | 73 | */ |
| 74 | 74 | static private function parse_key($key) |
| 75 | 75 | { |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | $encoded_uuid = substr($key, self::ENCODED_ID_LENGTH + 1, self::ENCODED_UUID_LENGTH); |
| 78 | 78 | $hash = substr($key, self::ENCODED_ID_LENGTH + 1 + self::ENCODED_UUID_LENGTH + 1); |
| 79 | 79 | |
| 80 | - return [ $encoded_id, $encoded_uuid, $hash ]; |
|
| 80 | + return [$encoded_id, $encoded_uuid, $hash]; |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | static public function encode_id($id) |
| 105 | 105 | { |
| 106 | - return sprintf('%0' . self::ENCODED_ID_LENGTH . 'x', $id); |
|
| 106 | + return sprintf('%0'.self::ENCODED_ID_LENGTH.'x', $id); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | throw new \LogicException("Invalid UUID: $uuid."); |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - return Base64::encode_unpadded(hex2bin(strtr($uuid, [ '-' => '' ]))); |
|
| 135 | + return Base64::encode_unpadded(hex2bin(strtr($uuid, ['-' => '']))); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
@@ -27,9 +27,9 @@ |
||
| 27 | 27 | Model::EXTENDING => 'nodes', |
| 28 | 28 | Model::SCHEMA => [ |
| 29 | 29 | |
| 30 | - 'size' => [ 'integer', 'unsigned' => true ], |
|
| 31 | - 'mime' => [ 'varchar', 'charset' => 'ascii/general_ci' ], |
|
| 32 | - 'extension' => [ 'varchar', 16, 'charset' => 'ascii/general_ci' ], |
|
| 30 | + 'size' => ['integer', 'unsigned' => true], |
|
| 31 | + 'mime' => ['varchar', 'charset' => 'ascii/general_ci'], |
|
| 32 | + 'extension' => ['varchar', 16, 'charset' => 'ascii/general_ci'], |
|
| 33 | 33 | 'description' => 'text' |
| 34 | 34 | |
| 35 | 35 | ] |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class DownloadColumn extends ManageBlock\Column |
| 13 | 13 | { |
| 14 | - public function __construct(ManageBlock $manager, $id, array $options=[]) |
|
| 14 | + public function __construct(ManageBlock $manager, $id, array $options = []) |
|
| 15 | 15 | { |
| 16 | 16 | parent::__construct($manager, $id, [ |
| 17 | 17 | |