diff --git a/README.md b/README.md index 9065e1d8..7f188972 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,8 @@ If, for example, you want to ensure that only logged in users have the ability t ```php Route::group(['middleware' => 'auth'], function () { - Route::get('/laravel-filemanager', '\Unisharp\Laravelfilemanager\controllers\LfmController@show'); - Route::post('/laravel-filemanager/upload', '\Unisharp\Laravelfilemanager\controllers\UploadController@upload'); + Route::get('/laravel-filemanager', '\UniSharp\LaravelFilemanager\controllers\LfmController@show'); + Route::post('/laravel-filemanager/upload', '\UniSharp\LaravelFilemanager\controllers\UploadController@upload'); // list all lfm routes here... }); ``` diff --git a/composer.json b/composer.json index cb82425d..778d7972 100644 --- a/composer.json +++ b/composer.json @@ -40,27 +40,14 @@ }, "autoload": { "psr-4": { - "Unisharp\\Laravelfilemanager\\": "src/" + "UniSharp\\LaravelFilemanager\\": "src/" } }, "bin": ["bin/debug"], - "scripts": { - "post-install-cmd": [ - "php artisan vendor:publish --tag=lfm_config", - "php artisan vendor:publish --tag=lfm_public", - "php artisan route:clear", - "php aritsan config:clear" - ], - "post-update-cmd": [ - "php artisan vendor:publish --tag=lfm_public --force", - "php artisan route:clear", - "php aritsan config:clear" - ] - }, "extra": { "laravel": { "providers": [ - "Unisharp\\Laravelfilemanager\\LaravelFilemanagerServiceProvider" + "UniSharp\\LaravelFilemanager\\LaravelFilemanagerServiceProvider" ], "aliases": { } diff --git a/docs/config.md b/docs/config.md index 13e4bc7d..eee5961f 100644 --- a/docs/config.md +++ b/docs/config.md @@ -58,6 +58,7 @@ | raster\_mimetypes | array | Array of mime types. Thumbnails will be created only for these mimetypes. | | create\_folder\_mode | int | Permission setting for folders created by this package. | | create\_file\_mode | int | Permission setting for files uploaded to this package. | +| should\_change\_file\_mode | boolean | If true, it will attempt to chmod the file after upload | | valid\_file\_mimetypes | array | Array of mime types. Available since v1.3.0 . | diff --git a/docs/index.md b/docs/index.md index a5fef620..ca92bb37 100644 --- a/docs/index.md +++ b/docs/index.md @@ -10,7 +10,7 @@ * Public and private folders for multi users * Customizable routes, middlewares, views, and folder path * Supports two types : files and images. Each type works in different directory. - * Supported locales : ar, bg, de, el, en, es, fa, fr, he, hu, nl, pl, pt-BR, pt_PT, ro, ru, tr, zh-CN, zh-TW + * Supported locales : ar, bg, de, el, en, es, fa, fr, it, he, hu, nl, pl, pt-BR, pt_PT, ro, ru, tr, zh-CN, zh-TW PR is welcome! diff --git a/docs/installation.md b/docs/installation.md index b2584ccd..209c97da 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -20,7 +20,7 @@ Add service providers ```php - Unisharp\Laravelfilemanager\LaravelFilemanagerServiceProvider::class, + UniSharp\LaravelFilemanager\LaravelFilemanagerServiceProvider::class, Intervention\Image\ImageServiceProvider::class, ``` diff --git a/src/controllers/Controller.php b/src/Controllers/Controller.php similarity index 83% rename from src/controllers/Controller.php rename to src/Controllers/Controller.php index d0619013..ad0b0a0e 100644 --- a/src/controllers/Controller.php +++ b/src/Controllers/Controller.php @@ -1,6 +1,6 @@ $file_to_delete]); + return parent::error('folder-not-found', ['folder' => htmlspecialchars($file_to_delete)]); } if (File::isDirectory($file_to_delete)) { diff --git a/src/controllers/DemoController.php b/src/Controllers/DemoController.php similarity index 80% rename from src/controllers/DemoController.php rename to src/Controllers/DemoController.php index 98204dfa..642f7c5a 100644 --- a/src/controllers/DemoController.php +++ b/src/Controllers/DemoController.php @@ -1,6 +1,6 @@ getRealPath(), $new_file_path); } - chmod($new_file_path, config('lfm.create_file_mode', 0644)); + if (config('lfm.should_change_file_mode', true)) { + chmod($new_file_path, config('lfm.create_file_mode', 0644)); + } } catch (\Exception $e) { array_push($this->errors, parent::error('invalid')); diff --git a/src/Events/FolderIsRenaming.php b/src/Events/FolderIsRenaming.php index 6e4c07f0..b28e9a87 100644 --- a/src/Events/FolderIsRenaming.php +++ b/src/Events/FolderIsRenaming.php @@ -1,6 +1,6 @@ getFormatedWorkingDir(), $this->ds . $thumb_folder_name); + $in_thumb_folder = Str::contains($this->getFormatedWorkingDir(), $this->ds . $thumb_folder_name); if (! $in_thumb_folder) { return $thumb_folder_name . $this->ds; @@ -268,7 +269,7 @@ private function removeDuplicateSlash($path) */ private function removeFirstSlash($path) { - if (starts_with($path, $this->ds)) { + if (Str::startsWith($path, $this->ds)) { $path = substr($path, 1); } @@ -284,7 +285,7 @@ private function removeFirstSlash($path) private function removeLastSlash($path) { // remove last slash - if (ends_with($path, $this->ds)) { + if (Str::endsWith($path, $this->ds)) { $path = substr($path, 0, -1); } @@ -332,7 +333,7 @@ public function translateToUtf8($input) */ public function isProcessingImages() { - return lcfirst(str_singular(request('type'))) === 'image'; + return lcfirst(Str::singular(request('type', '') ?: '')) === 'image'; } /** @@ -518,7 +519,7 @@ public function fileIsImage($file) { $mime_type = $this->getFileType($file); - return starts_with($mime_type, 'image'); + return Str::startsWith($mime_type, 'image'); } /** diff --git a/src/config/lfm.php b/src/config/lfm.php index a6e6224b..05b7b954 100644 --- a/src/config/lfm.php +++ b/src/config/lfm.php @@ -33,7 +33,7 @@ // Then you can rewrite userField function in App\Handler\ConfigHander class // And set 'user_field' to App\Handler\ConfigHander::class // Ex: The private folder of user will be named as the user id. - 'user_field' => Unisharp\Laravelfilemanager\Handlers\ConfigHandler::class, + 'user_field' => UniSharp\LaravelFilemanager\Handlers\ConfigHandler::class, /* |-------------------------------------------------------------------------- @@ -110,6 +110,9 @@ // permissions to be set on file upload. 'create_file_mode' => 0644, + + // If true, it will attempt to chmod the file after upload + 'should_change_file_mode' => true, // available since v1.3.0 // only when '/laravel-filemanager?type=Files' diff --git a/src/lang/it/lfm.php b/src/lang/it/lfm.php new file mode 100644 index 00000000..dc9415c5 --- /dev/null +++ b/src/lang/it/lfm.php @@ -0,0 +1,76 @@ + 'Indietro', + 'nav-new' => 'Nuova Cartella', + 'nav-upload' => 'Carica', + 'nav-thumbnails' => 'Anteprima', + 'nav-list' => 'Elencare', + 'nav-sort' => 'Ordinare', + 'nav-sort-alphabetic'=> 'Ordine Alfabetico', + 'nav-sort-time' => 'Ordine Temporale', + + 'menu-rename' => 'Rinomina', + 'menu-delete' => 'Elimina', + 'menu-view' => 'Anteprima', + 'menu-download' => 'Scarica', + 'menu-resize' => 'Ridimensiona', + 'menu-crop' => 'Taglia', + + 'title-page' => 'File Manager', + 'title-panel' => 'Laravel FileManager', + 'title-upload' => 'Carica File(s)', + 'title-view' => 'Vedi File', + 'title-user' => 'Files', + 'title-share' => 'Files Condivisi', + 'title-item' => 'Voce', + 'title-size' => 'Dimensione', + 'title-type' => 'Tipo', + 'title-modified' => 'Modificato', + 'title-action' => 'Azione', + + 'type-folder' => 'Cartella', + + 'message-empty' => 'La cartella è vuota.', + 'message-choose' => 'Scegli i File(s)', + 'message-delete' => 'Sei sicuro di voler cancellare questa voce?', + 'message-name' => 'Nome Cartella:', + 'message-rename' => 'Rinomina:', + 'message-extension_not_found' => 'Per favore installa gd oppure la estensione di imagick per tagliare, ridimensionare e creare anteprime delle immagini.', + + 'error-rename' => 'Il nome del file è già in uso!', + 'error-file-name' => 'Il nome del file non può essere vuoto!', + 'error-file-empty' => 'Devi scegliere un file!', + 'error-file-exist' => 'Esiste già un file con questo nome!', + 'error-file-size' => 'La dimensione del file eccede il limite del server! (dimensione massima: :max)', + 'error-delete-folder'=> 'Non puoi cancellare questa cartella perchè non è vuota!', + 'error-folder-name' => 'Il nome della cartella non può essere vuoto!', + 'error-folder-exist'=> 'Esiste già una cartella con questo nome!', + 'error-folder-alnum'=> 'Si può nominare una cartella solo con caratteri alfanumerici!', + 'error-folder-not-found'=> 'Cartella non trovata! (:folder)', + 'error-mime' => 'Unexpected MimeType: ', + 'error-size' => 'Superato il limite di dimensione:', + 'error-instance' => 'Il file caricato deve essere una istanza di UploadedFile', + 'error-invalid' => 'Richiesta di caricamento non valida', + 'error-other' => 'Si è veriifcato un errore: ', + 'error-too-large' => 'Richiesta di entità troppo grande!', + + 'btn-upload' => 'Carica File(s)', + 'btn-uploading' => 'Sto Caricando...', + 'btn-close' => 'Chiudi', + 'btn-crop' => 'Taglia', + 'btn-copy-crop' => 'Copia & Taglia', + 'btn-cancel' => 'Cancella', + 'btn-resize' => 'Ridimensiona', + + 'resize-ratio' => 'Proporzione:', + 'resize-scaled' => 'Immagine scalata:', + 'resize-true' => 'Sì', + 'resize-old-height' => 'Altezza Originale:', + 'resize-old-width' => 'Larghezza Originale:', + 'resize-new-height' => 'Altezza:', + 'resize-new-width' => 'Larghezza:', + + 'locale-bootbox' => 'it', +]; diff --git a/src/lang/vi/lfm.php b/src/lang/vi/lfm.php index b613c920..0175b40b 100644 --- a/src/lang/vi/lfm.php +++ b/src/lang/vi/lfm.php @@ -1,67 +1,73 @@ 'Quay lại', - 'nav-new' => 'Tạo thư mục mới', + 'nav-back' => 'Trở lại', + 'nav-new' => 'Thư mục mới', 'nav-upload' => 'Tải lên', - 'nav-thumbnails' => 'Ảnh đại diện', + 'nav-thumbnails' => 'Hình thu nhỏ', 'nav-list' => 'Danh sách', 'nav-sort' => 'Sắp xếp', - 'nav-sort-alphabetic'=> 'Sắp xếp theo thứ tự Alphabet', + 'nav-sort-alphabetic'=> 'Sắp xếp theo bảng chữ cái', 'nav-sort-time' => 'Sắp xếp theo thời gian', 'menu-rename' => 'Đổi tên', - 'menu-delete' => 'Xoá', + 'menu-delete' => 'Xóa bỏ', 'menu-view' => 'Xem trước', - 'menu-download' => 'Tải xuống', + 'menu-download' => 'Tải về', 'menu-resize' => 'Thay đổi kích thước', - 'menu-crop' => 'Cắt hình', + 'menu-crop' => 'Cắt', + 'menu-move' => 'Di chuyển', + 'menu-multiple' => 'Chọn nhiều', - 'title-page' => 'Trình quản lý tập tin', + 'title-page' => 'Quản lý tập tin', 'title-panel' => 'Trình quản lý tập tin Laravel', - 'title-upload' => 'Tải lên', - 'title-view' => 'Xem tập tin', - 'title-root' => 'Các tập tin', - 'title-shares' => 'Các tập tin được chia sẽ', + 'title-upload' => 'Tải lên tập tin', + 'title-view' => 'Xem tài liệu', + 'title-user' => 'Các tập tin', + 'title-share' => 'Thư mục chia sẻ', 'title-item' => 'Mục', 'title-size' => 'Kích thước', - 'title-type' => 'Loại', - 'title-modified' => 'Đã chỉnh sửa', - 'title-action' => 'Hành động', + 'title-type' => 'Kiểu', + 'title-modified' => 'Sửa đổi', + 'title-action' => 'Hoạt động', 'type-folder' => 'Thư mục', - 'message-empty' => 'Thư mục trống.', + 'message-empty' => 'Thư mục rỗng.', 'message-choose' => 'Chọn tập tin', - 'message-delete' => 'Bạn có chắc chắn muốn xoá mục này?', + 'message-delete' => 'Bạn có chắc bạn muốn xóa mục này?', 'message-name' => 'Tên thư mục:', 'message-rename' => 'Đổi tên thành:', - 'message-extension_not_found' => 'Vui lòng cài đặt gói mở rộng gd hoặc imagick để cắt, thay đổi kích thước và tạo ảnh đại điện cho các hình ảnh.', + 'message-extension_not_found' => 'Vui lòng cài đặt gd hoặc extension imagick để cắt, thay đổi kích thước và tạo hình thu nhỏ của hình ảnh.', + 'message-drop' => 'Hoặc thả tập tin vào đây để tải lên', - 'error-rename' => 'Tên tập tin đã được chọn!', - 'error-file-name' => 'Tên tập tin không được trống!', - 'error-file-empty' => 'Bạn phải lựa chọn 1 tập tin!', - 'error-file-exist' => 'Cùng tên với tập tin khác!', - 'error-file-size' => 'Kích thước tập tin đạt tối đa! (kích thước tối đa: :max)', - 'error-delete-folder'=> 'Bạn không thể xoá thư mục này bởi vì nó không trống!', - 'error-folder-name' => 'Tên thư mục không được trống!', - 'error-folder-exist'=> 'Tên thư mục đã được sử dụng!', - 'error-folder-alnum'=> 'Tên thư mục chỉ được sử dụng chữ hoặc số!', + 'error-rename' => 'Tên tệp đã được sử dụng!', + 'error-file-name' => 'Tên tệp không thể để trống!', + 'error-file-empty' => 'Bạn phải chọn một tập tin!', + 'error-file-exist' => 'Một tập tin với tên này đã tồn tại!', + 'error-file-size' => 'Kích thước tệp vượt quá giới hạn máy chủ! (Kích thước tối đa: :max)', + 'error-delete-folder'=> 'Bạn không thể xóa thư mục này vì nó không trống!', + 'error-folder-name' => 'Tên thư mục không được để trống!', + 'error-folder-exist'=> 'Một thư mục có tên này đã tồn tại!', + 'error-folder-alnum'=> 'Chỉ cho phép tên thư mục chữ và số!', 'error-folder-not-found'=> 'Không tìm thấy thư mục! (:folder)', - 'error-mime' => 'Không hỗ trợ MimeType: ', - 'error-size' => 'Kích thước quá lớn:', - 'error-instance' => 'Tập tin được tải lên phải là một kiểu UploadedFile', + 'error-mime' => 'Unexpected MimeType: ', + 'error-size' => 'Kích thước quá giới hạn:', + 'error-instance' => 'Tệp đã tải lên phải là một phiên bản của UploadedFile', 'error-invalid' => 'Yêu cầu tải lên không hợp lệ', - 'error-other' => 'Có lỗi xảy ra: ', - 'error-too-large' => 'Kích thước yêu cầu quá lơn!', + 'error-other' => 'Một lỗi đã xảy ra: ', + 'error-too-large' => 'Yêu cầu thực thể quá lớn!', - 'btn-upload' => 'Tải tập tin', + 'btn-upload' => 'Tải lên tập tin', 'btn-uploading' => 'Đang tải lên...', 'btn-close' => 'Đóng', 'btn-crop' => 'Cắt', 'btn-copy-crop' => 'Sao chép và Cắt', - 'btn-cancel' => 'Huỷ bỏ', + 'btn-crop-free' => 'Free', + 'btn-cancel' => 'Hủy bỏ', + 'btn-confirm' => 'Xác nhận', 'btn-resize' => 'Thay đổi kích thước', + 'btn-open' => 'Mở thư mục', 'resize-ratio' => 'Tỷ lệ:', 'resize-scaled' => 'Hình ảnh thu nhỏ:', diff --git a/src/routes.php b/src/routes.php index b123f44e..84d6d8b2 100644 --- a/src/routes.php +++ b/src/routes.php @@ -1,12 +1,12 @@ 'CropController@getNewCropimage', - 'as' => 'getCropimage', + 'as' => 'getNewCropimage', ]); // rename diff --git a/src/views/crop.blade.php b/src/views/crop.blade.php index 2840f3e0..ae24f49e 100644 --- a/src/views/crop.blade.php +++ b/src/views/crop.blade.php @@ -23,9 +23,9 @@ - {{--

diff --git a/src/views/grid-view.blade.php b/src/views/grid-view.blade.php index 6a9ef913..bb6a300c 100644 --- a/src/views/grid-view.blade.php +++ b/src/views/grid-view.blade.php @@ -9,8 +9,8 @@ is_file ? $item->url : $item->path; ?>
is_file && $thumb_src) onclick="fileView('{{ $item_path }}', '{{ $item->updated }}')" - @elseif($item->is_file) onclick="download('{{ $item_name }}')" @endif > + @if($item->is_file && $thumb_src) onclick="useFile({{ json_encode($item_path) }}, '{{ $item->updated }}')" + @elseif($item->is_file) onclick="download({{ json_encode($item_name) }})" @endif > @if($thumb_src) @else @@ -22,8 +22,8 @@
diff --git a/src/views/index.blade.php b/src/views/index.blade.php index 24d909d2..fec646bb 100644 --- a/src/views/index.blade.php +++ b/src/views/index.blade.php @@ -14,15 +14,15 @@ {{ trans('laravel-filemanager::lfm.title-page') }} - - + + {{-- Use the line below instead of the above if you need to cache the css. --}} {{-- --}} - +
@@ -206,8 +206,8 @@ } }); }, - acceptedFiles: "{{ lcfirst(str_singular(request('type'))) == 'image' ? implode(',', config('lfm.valid_image_mimetypes')) : implode(',', config('lfm.valid_file_mimetypes')) }}", - maxFilesize: ({{ lcfirst(str_singular(request('type'))) == 'image' ? config('lfm.max_image_size') : config('lfm.max_file_size') }} / 1000) + acceptedFiles: "{{ lcfirst(\Illuminate\Support\Str::singular(request('type') ?: '')) == 'image' ? implode(',', config('lfm.valid_image_mimetypes')) : implode(',', config('lfm.valid_file_mimetypes')) }}", + maxFilesize: ({{ lcfirst(\Illuminate\Support\Str::singular(request('type') ?: '')) == 'image' ? config('lfm.max_image_size') : config('lfm.max_file_size') }} / 1000) } diff --git a/src/views/list-view.blade.php b/src/views/list-view.blade.php index 41c70fb6..42566fe4 100644 --- a/src/views/list-view.blade.php +++ b/src/views/list-view.blade.php @@ -11,9 +11,21 @@ @foreach($items as $item) - + @if($item->is_file) + thumb; ?> + @if($thumb_src) + + + + @else + + @endif + @else + + @endif + - {{ str_limit($item->name, $limit = 40, $end = '...') }} + {{ \Illuminate\Support\Str::limit($item->name, $limit = 40, $end = '...') }} {{ $item->size }} @@ -21,25 +33,25 @@ {{ $item->time }} @if($item->is_file) - + @if($item->thumb) - + - + - + @endif @endif - + - + @@ -67,10 +79,10 @@

- {{ str_limit($item->name, $limit = 20, $end = '...') }} + {{ \Illuminate\Support\Str::limit($item->name, $limit = 20, $end = '...') }}    - {{-- + {{-- --}}