@@ -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 | |
@@ -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 | |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | { |
| 30 | 30 | $value = $modifiers['size']; |
| 31 | 31 | |
| 32 | - if (in_array($value, [ 'l', 'm', 's' ])) |
|
| 32 | + if (in_array($value, ['l', 'm', 's'])) |
|
| 33 | 33 | { |
| 34 | 34 | $filters['size'] = $value; |
| 35 | 35 | } |
@@ -32,8 +32,7 @@ |
||
| 32 | 32 | if (in_array($value, [ 'l', 'm', 's' ])) |
| 33 | 33 | { |
| 34 | 34 | $filters['size'] = $value; |
| 35 | - } |
|
| 36 | - else |
|
| 35 | + } else |
|
| 37 | 36 | { |
| 38 | 37 | unset($filters['size']); |
| 39 | 38 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | static public function encode($data) |
| 27 | 27 | { |
| 28 | - return strtr(base64_encode($data), [ '+' => '-', '/' => '_' ]); |
|
| 28 | + return strtr(base64_encode($data), ['+' => '-', '/' => '_']); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | static public function decode($data) |
| 39 | 39 | { |
| 40 | - return base64_decode(strtr($data, [ '-' => '+', '_' => '/' ])); |
|
| 40 | + return base64_decode(strtr($data, ['-' => '+', '_' => '/'])); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -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 | { |
@@ -45,8 +45,7 @@ discard block |
||
| 45 | 45 | mkdir($path); |
| 46 | 46 | |
| 47 | 47 | file_put_contents($path . DIRECTORY_SEPARATOR . '.htaccess', 'Deny from all'); |
| 48 | - } |
|
| 49 | - else |
|
| 48 | + } else |
|
| 50 | 49 | { |
| 51 | 50 | $errors->add($this->id, "Unable to create %directory directory, its parent is not writable.", [ '%directory' => $path ]); |
| 52 | 51 | } |
@@ -67,8 +66,7 @@ discard block |
||
| 67 | 66 | mkdir($path); |
| 68 | 67 | |
| 69 | 68 | file_put_contents($path . DIRECTORY_SEPARATOR . '.htaccess', 'Allow from all'); |
| 70 | - } |
|
| 71 | - else |
|
| 69 | + } else |
|
| 72 | 70 | { |
| 73 | 71 | $errors->add($this->id, "Unable to create %directory directory, its parent is not writable", [ '%directory' => $path ]); |
| 74 | 72 | } |
@@ -89,8 +87,7 @@ discard block |
||
| 89 | 87 | mkdir($path); |
| 90 | 88 | |
| 91 | 89 | file_put_contents($path . DIRECTORY_SEPARATOR . '.htaccess', 'Deny from all'); |
| 92 | - } |
|
| 93 | - else |
|
| 90 | + } else |
|
| 94 | 91 | { |
| 95 | 92 | $errors->add($this->id, 'Unable to create %directory directory, its parent is not writable', [ '%directory' => $path ]); |
| 96 | 93 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | # $repository/tmp |
| 35 | 35 | # |
| 36 | 36 | |
| 37 | - $path = $repository . 'tmp'; |
|
| 37 | + $path = $repository.'tmp'; |
|
| 38 | 38 | |
| 39 | 39 | if (!file_exists($path)) |
| 40 | 40 | { |
@@ -44,11 +44,11 @@ discard block |
||
| 44 | 44 | { |
| 45 | 45 | mkdir($path); |
| 46 | 46 | |
| 47 | - file_put_contents($path . DIRECTORY_SEPARATOR . '.htaccess', 'Deny from all'); |
|
| 47 | + file_put_contents($path.DIRECTORY_SEPARATOR.'.htaccess', 'Deny from all'); |
|
| 48 | 48 | } |
| 49 | 49 | else |
| 50 | 50 | { |
| 51 | - $errors->add($this->id, "Unable to create %directory directory, its parent is not writable.", [ '%directory' => $path ]); |
|
| 51 | + $errors->add($this->id, "Unable to create %directory directory, its parent is not writable.", ['%directory' => $path]); |
|
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | # $repository/files |
| 57 | 57 | # |
| 58 | 58 | |
| 59 | - $path = $repository . 'files'; |
|
| 59 | + $path = $repository.'files'; |
|
| 60 | 60 | |
| 61 | 61 | if (!file_exists($path)) |
| 62 | 62 | { |
@@ -66,11 +66,11 @@ discard block |
||
| 66 | 66 | { |
| 67 | 67 | mkdir($path); |
| 68 | 68 | |
| 69 | - file_put_contents($path . DIRECTORY_SEPARATOR . '.htaccess', 'Allow from all'); |
|
| 69 | + file_put_contents($path.DIRECTORY_SEPARATOR.'.htaccess', 'Allow from all'); |
|
| 70 | 70 | } |
| 71 | 71 | else |
| 72 | 72 | { |
| 73 | - $errors->add($this->id, "Unable to create %directory directory, its parent is not writable", [ '%directory' => $path ]); |
|
| 73 | + $errors->add($this->id, "Unable to create %directory directory, its parent is not writable", ['%directory' => $path]); |
|
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | # $repository/files-index |
| 79 | 79 | # |
| 80 | 80 | |
| 81 | - $path = $repository . 'files-index'; |
|
| 81 | + $path = $repository.'files-index'; |
|
| 82 | 82 | |
| 83 | 83 | if (!file_exists($path)) |
| 84 | 84 | { |
@@ -88,11 +88,11 @@ discard block |
||
| 88 | 88 | { |
| 89 | 89 | mkdir($path); |
| 90 | 90 | |
| 91 | - file_put_contents($path . DIRECTORY_SEPARATOR . '.htaccess', 'Deny from all'); |
|
| 91 | + file_put_contents($path.DIRECTORY_SEPARATOR.'.htaccess', 'Deny from all'); |
|
| 92 | 92 | } |
| 93 | 93 | else |
| 94 | 94 | { |
| 95 | - $errors->add($this->id, 'Unable to create %directory directory, its parent is not writable', [ '%directory' => $path ]); |
|
| 95 | + $errors->add($this->id, 'Unable to create %directory directory, its parent is not writable', ['%directory' => $path]); |
|
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | |
@@ -118,22 +118,22 @@ discard block |
||
| 118 | 118 | # $repository/tmp |
| 119 | 119 | # |
| 120 | 120 | |
| 121 | - $path = $repository . 'tmp'; |
|
| 121 | + $path = $repository.'tmp'; |
|
| 122 | 122 | |
| 123 | 123 | if (!is_dir($path)) |
| 124 | 124 | { |
| 125 | - $errors->add($this->id, "The %directory directory is missing.", [ '%directory' => $path ]); |
|
| 125 | + $errors->add($this->id, "The %directory directory is missing.", ['%directory' => $path]); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | # |
| 129 | 129 | # $repository/files |
| 130 | 130 | # |
| 131 | 131 | |
| 132 | - $path = $repository . 'files'; |
|
| 132 | + $path = $repository.'files'; |
|
| 133 | 133 | |
| 134 | 134 | if (!is_dir($path)) |
| 135 | 135 | { |
| 136 | - $errors->add($this->id, "The %directory directory is missing.", [ '%directory' => $path ]); |
|
| 136 | + $errors->add($this->id, "The %directory directory is missing.", ['%directory' => $path]); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | return parent::is_installed($errors); |
@@ -141,18 +141,18 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | public function clean_temporary_files($lifetime = 3600) |
| 143 | 143 | { |
| 144 | - $path = \ICanBoogie\REPOSITORY . 'tmp'; |
|
| 144 | + $path = \ICanBoogie\REPOSITORY.'tmp'; |
|
| 145 | 145 | |
| 146 | 146 | if (!is_dir($path)) |
| 147 | 147 | { |
| 148 | - \ICanBoogie\log_error('The directory %directory does not exists', [ '%directory' => $path ]); |
|
| 148 | + \ICanBoogie\log_error('The directory %directory does not exists', ['%directory' => $path]); |
|
| 149 | 149 | |
| 150 | 150 | return; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | if (!is_writable($path)) |
| 154 | 154 | { |
| 155 | - \ICanBoogie\log_error('The directory %directory is not writable', [ '%directory' => $path ]); |
|
| 155 | + \ICanBoogie\log_error('The directory %directory is not writable', ['%directory' => $path]); |
|
| 156 | 156 | |
| 157 | 157 | return; |
| 158 | 158 | } |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | foreach ($model->select("nid, path")->mode(\PDO::FETCH_NUM) as list($nid, $path)) |
| 64 | 64 | { |
| 65 | - $update('.' . pathinfo($path, PATHINFO_EXTENSION), $nid); |
|
| 65 | + $update('.'.pathinfo($path, PATHINFO_EXTENSION), $nid); |
|
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | foreach ($model->select("nid, uuid, path")->mode(\PDO::FETCH_NUM) as list($nid, $uuid, $path)) |
| 86 | 86 | { |
| 87 | - $path = $document_root . $path; |
|
| 87 | + $path = $document_root.$path; |
|
| 88 | 88 | |
| 89 | 89 | if (!file_exists($path)) |
| 90 | 90 | { |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | $hash = $storage->add($path)->hash; |
| 97 | - $index->add(IndexKey::from([ $nid, $uuid, $hash ])); |
|
| 97 | + $index->add(IndexKey::from([$nid, $uuid, $hash])); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | $model->remove_column('path'); |
@@ -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 | } |
@@ -79,7 +79,7 @@ |
||
| 79 | 79 | return new FileResponse($pathname, $this->request, [ |
| 80 | 80 | |
| 81 | 81 | FileResponse::OPTION_ETAG => $pathname->hash, |
| 82 | - FileResponse::OPTION_FILENAME => $record->title . $record->extension, |
|
| 82 | + FileResponse::OPTION_FILENAME => $record->title.$record->extension, |
|
| 83 | 83 | FileResponse::OPTION_MIME => $record->mime |
| 84 | 84 | |
| 85 | 85 | ]); |