@@ -48,7 +48,7 @@ |
||
48 | 48 | |
49 | 49 | public static function boot() |
50 | 50 | { |
51 | - Route::group(['namespace' => 'Epesi\FileStorage'], function(){ |
|
51 | + Route::group(['namespace' => 'Epesi\FileStorage'], function() { |
|
52 | 52 | Route::get('file', 'FileStorageController@get')->middleware('web', FileStorageAccess::class); |
53 | 53 | }); |
54 | 54 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | protected function setPeriodSelection() |
36 | 36 | { |
37 | - if (! $this->periodSelection) { |
|
37 | + if (!$this->periodSelection) { |
|
38 | 38 | $this->periodSelection = []; |
39 | 39 | foreach ([1, 2, 3, 4] as $count) { |
40 | 40 | $this->periodSelection[$count . ' weeks'] = trans_choice('{1} :count week |[2,*] :count weeks', $count); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | } |
43 | 43 | |
44 | 44 | foreach ($this->periodSelection as $key => $period) { |
45 | - $default = $key == $this->defaultPeriod? ' (' . __('Default') . ')': ''; |
|
45 | + $default = $key == $this->defaultPeriod ? ' (' . __('Default') . ')' : ''; |
|
46 | 46 | |
47 | 47 | $this->periodSelection[$key] = $period . $default; |
48 | 48 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | protected function addContents() |
52 | 52 | { |
53 | - if (! $this->file) { |
|
53 | + if (!$this->file) { |
|
54 | 54 | $this->set(__('Wrong parameters for file')); |
55 | 55 | return; |
56 | 56 | } |
@@ -70,13 +70,13 @@ discard block |
||
70 | 70 | |
71 | 71 | protected function addFileDetails($container = null) |
72 | 72 | { |
73 | - $container = $container?: $this; |
|
73 | + $container = $container ?: $this; |
|
74 | 74 | |
75 | 75 | $container->add(new FileDetailsLister($this->file)); |
76 | 76 | } |
77 | 77 | |
78 | 78 | protected function addFileRemoteLinks($container = null) { |
79 | - $container = $container?: $this; |
|
79 | + $container = $container ?: $this; |
|
80 | 80 | |
81 | 81 | foreach ($this->file->userActiveLinks() as $link) { |
82 | 82 | $container->add(['View', __('Remote access link expiring :expiry', ['expiry' => $link['expires_at']->format('Y-m-d H:i:s')])]); |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $container->js(true, new jsExpression('new ClipboardJS(".copy-button")')); |
91 | 91 | |
92 | 92 | $container->on('click', '.delete-link', $this->add(['jsCallback', 'postTrigger' => 'link'])->set(function($j, $linkId) { |
93 | - if (! $link = FileRemoteAccess::create()->load($linkId)) return; |
|
93 | + if (!$link = FileRemoteAccess::create()->load($linkId)) return; |
|
94 | 94 | |
95 | 95 | $link->delete(); |
96 | 96 | |
@@ -101,19 +101,19 @@ discard block |
||
101 | 101 | protected function addFileControlButtons() { |
102 | 102 | $urls = FileStorageAccessJoint::getActionUrls($this->file); |
103 | 103 | |
104 | - if (! $this->actionDisabled('preview') && ($urls['preview']?? null)) { |
|
104 | + if (!$this->actionDisabled('preview') && ($urls['preview']?? null)) { |
|
105 | 105 | $this->add(['Button', 'class' => ['basic'], 'icon' => 'file alternate outline'])->set(__('View'))->link($urls['preview'])->setAttr(['target' => '_blank']); |
106 | 106 | } |
107 | 107 | |
108 | - if (! $this->actionDisabled('download') && ($urls['download']?? null)) { |
|
108 | + if (!$this->actionDisabled('download') && ($urls['download']?? null)) { |
|
109 | 109 | $this->add(['Button', 'class' => ['basic'], 'icon' => 'file download'])->set(__('Download'))->link($urls['download']); |
110 | 110 | } |
111 | 111 | |
112 | - if (! $this->actionDisabled('history')) { |
|
112 | + if (!$this->actionDisabled('history')) { |
|
113 | 113 | $this->add(['Button', 'class' => ['basic'], 'icon' => 'history'])->set(__('Access History'))->link(url('view/filestorage:file-access-history/body') . '?' . http_build_query(['id' => $this->file->id])); |
114 | 114 | } |
115 | 115 | |
116 | - if (! $this->actionDisabled('remote')) { |
|
116 | + if (!$this->actionDisabled('remote')) { |
|
117 | 117 | $linkControl = $this->add(['View', 'ui' => 'basic buttons']); |
118 | 118 | |
119 | 119 | $linkButton = $linkControl->add(['Button', 'class' => ['basic'], 'icon' => 'linkify'])->set(__('Get Remote Link')); |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | $dropdown->setSource($this->periodSelection); |
124 | 124 | |
125 | 125 | $dropdown->onChange(function($value) { |
126 | - $period = array_search($value, $this->periodSelection)?: $this->defaultPeriod; |
|
126 | + $period = array_search($value, $this->periodSelection) ?: $this->defaultPeriod; |
|
127 | 127 | |
128 | 128 | FileRemoteAccess::grant($this->file, $period); |
129 | 129 |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | public function getDefaultSource() |
35 | 35 | { |
36 | - return $this->file? [ |
|
36 | + return $this->file ? [ |
|
37 | 37 | 'name' => [ |
38 | 38 | 'title'=> __('Name'), |
39 | 39 | 'descr'=> $this->file['name'] |
@@ -50,6 +50,6 @@ discard block |
||
50 | 50 | 'title'=> __('Stored At'), |
51 | 51 | 'descr'=> $this->file['created_at'] |
52 | 52 | ] |
53 | - ]: []; |
|
53 | + ] : []; |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | \ No newline at end of file |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | $file = self::create()->tryLoad($id); |
62 | 62 | |
63 | - if (! $file->ref('content')['hash']) { |
|
63 | + if (!$file->ref('content')['hash']) { |
|
64 | 64 | throw new FileNotFound('File object does not have corresponding content'); |
65 | 65 | } |
66 | 66 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | if (!$useCache || !isset($cache[$link])) { |
89 | 89 | $file = self::create()->tryLoadBy('link', $link); |
90 | 90 | |
91 | - $cache[$link] = $file? $file->get('id'): null; |
|
91 | + $cache[$link] = $file ? $file->get('id') : null; |
|
92 | 92 | |
93 | 93 | if (!$cache[$link] && $throwException) { |
94 | 94 | throw new LinkNotFound($link); |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | try { |
125 | 125 | $file = is_numeric($idOrMeta) ? self::retrieve($idOrMeta) : $idOrMeta; |
126 | 126 | |
127 | - if (! file_exists($file->ref('content')['path'])) { |
|
127 | + if (!file_exists($file->ref('content')['path'])) { |
|
128 | 128 | throw new FileNotFound('Exception - file not found: ' . $file->ref('content')['path']); |
129 | 129 | } |
130 | 130 | } catch (\Exception $exception) { |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | { |
150 | 150 | $ids = []; |
151 | 151 | foreach ((array) $files as $filePath) { |
152 | - if (! is_numeric($filePath)) { |
|
152 | + if (!is_numeric($filePath)) { |
|
153 | 153 | $ids[] = self::store($filePath); |
154 | 154 | |
155 | 155 | continue; |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | return $file['id']; |
189 | 189 | } |
190 | 190 | |
191 | - if (! $content && is_string($fileOrPath)) { |
|
191 | + if (!$content && is_string($fileOrPath)) { |
|
192 | 192 | $content = file_get_contents($fileOrPath); |
193 | 193 | |
194 | 194 | $file = [ |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | ]; |
197 | 197 | } |
198 | 198 | |
199 | - if (! empty($file['link']) && self::getIdByLink($file['link'], false)) { |
|
199 | + if (!empty($file['link']) && self::getIdByLink($file['link'], false)) { |
|
200 | 200 | throw new LinkDuplicate($file['link']); |
201 | 201 | } |
202 | 202 | |
@@ -221,9 +221,9 @@ discard block |
||
221 | 221 | |
222 | 222 | public static function getThumbnailField($model) |
223 | 223 | { |
224 | - if (! $model->thumbnailPossible()) return false; |
|
224 | + if (!$model->thumbnailPossible()) return false; |
|
225 | 225 | |
226 | - $image = new \Imagick($model->ref('content')['path'] . '[0]'); |
|
226 | + $image = new \Imagick($model->ref('content')['path'] . '[0]'); |
|
227 | 227 | |
228 | 228 | $image->setImageFormat('jpg'); |
229 | 229 |
@@ -44,9 +44,9 @@ |
||
44 | 44 | public static function grant($file, $expires = self::DEFAULT_PERIOD) |
45 | 45 | { |
46 | 46 | return self::create()->insert([ |
47 | - 'file_id' => is_numeric($file)? $file: $file->id, |
|
47 | + 'file_id' => is_numeric($file) ? $file : $file->id, |
|
48 | 48 | 'token' => md5(uniqid(rand(), true)), |
49 | - 'created_by' => Auth::id()?: 0, |
|
49 | + 'created_by' => Auth::id() ?: 0, |
|
50 | 50 | 'expires_at' => date('Y-m-d H:i:s', strtotime($expires)), |
51 | 51 | ]); |
52 | 52 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | |
19 | 19 | protected $appends = ['path']; |
20 | 20 | |
21 | - function init(){ |
|
21 | + function init() { |
|
22 | 22 | parent::init(); |
23 | 23 | |
24 | 24 | $this->addFields([ |
@@ -115,13 +115,13 @@ discard block |
||
115 | 115 | |
116 | 116 | $path = self::getStoragePath($hash); |
117 | 117 | |
118 | - if (! self::storage()->exists($path)) { |
|
118 | + if (!self::storage()->exists($path)) { |
|
119 | 119 | self::storage()->put($path, $content); |
120 | 120 | } |
121 | 121 | |
122 | 122 | $content = self::create()->addCondition('hash', $hash); |
123 | 123 | |
124 | - if (! $content->action('count')->getOne()) { |
|
124 | + if (!$content->action('count')->getOne()) { |
|
125 | 125 | return $content->insert([ |
126 | 126 | 'size' => self::storage()->size($path), |
127 | 127 | 'type' => self::storage()->mimeType($path) |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | final public static function getActionUrls($file, $accessParams = []) |
51 | 51 | { |
52 | - $id = is_numeric($file)? $file: $file['id']; |
|
52 | + $id = is_numeric($file) ? $file : $file['id']; |
|
53 | 53 | |
54 | 54 | $urls = []; |
55 | 55 | foreach (static::$allowedActions as $action) { |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | final protected function hasUserAccess() |
68 | 68 | { |
69 | - return $this->forUsersOnly? (bool) Auth::id(): true; |
|
69 | + return $this->forUsersOnly ? (bool) Auth::id() : true; |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |