laravel-6 support

This commit is contained in:
RafficMohammed
2023-01-08 01:17:22 +05:30
parent 1a5c16ae4b
commit 774eed8b0e
4962 changed files with 279380 additions and 297961 deletions

View File

@@ -0,0 +1,2 @@
source 'https://rubygems.org'
gem 'github-pages', group: :jekyll_plugins

View File

@@ -2,7 +2,7 @@ theme: jekyll-theme-cayman
# Setup
title: Laravel File Manager
description: File manager/gallery with CKEditor, TinyMCE and Summernote support.
description: It's like Dropbox for your Laravel app.
google_analytics: UA-92410814-4
# About/contact

View File

@@ -8,6 +8,12 @@
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="{{ '/assets/css/style.css?v=' | append: site.github.build_revision | relative_url }}">
<style>
h1.project-name {
margin-top: 100px;
}
h2.project-tagline {
margin-bottom: 5rem;
}
#nav > span > a {
color: #dddddd;
}
@@ -15,20 +21,86 @@
content: ' |';
color: #dddddd;
}
.button-group {
display: flex;
justify-content: center;
margin-bottom: 30px;
}
@media screen and (max-width: 42em) {
a.btn {
width: 50%;
margin: 0;
}
a.btn + a.btn {
margin-top: 0;
margin-left: 15px;
}
}
.main-content {
padding: 1rem !important;
}
#carbonads {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", Helvetica, Arial, sans-serif;
overflow: hidden;
background-color: rgba(0, 0, 0, .05);
font-size: 14px;
padding: 15px 15px 15px 160px;
}
#carbonads a {
text-decoration: none;
}
#carbonads a:hover {
color: inherit;
}
.carbon-img {
float: left;
margin-left: -145px;
width: 130px;
height: 100px;
}
.carbon-img img {
width: 130px;
height: 100px;
}
.carbon-text {
color: #333;
}
.carbon-poweredby {
display: block;
color: #777;
}
@media only screen and (min-width: 400px) {
#carbonads {
max-width: 330px;
}
}
</style>
</head>
<body>
<section class="page-header">
<h1 class="project-name">{{ site.title | default: site.github.repository_name }}</h1>
<h2 class="project-tagline">{{ site.description | default: site.github.project_tagline }}</h2>
<a class="btn" href="https://github.com/UniSharp/laravel-filemanager-example-5.3" target="_blank">Demo</a>
{% if site.github.is_project_page %}
<div class="button-group">
<a class="btn" href="https://github.com/UniSharp/laravel-filemanager-example-5.3" target="_blank">Demo</a>
{% if site.github.is_project_page %}
<a href="{{ site.github.repository_url }}" class="btn">View on GitHub</a>
{% endif %}
{% if site.show_downloads %}
<a href="{{ site.github.zip_url }}" class="btn">Download .zip</a>
<a href="{{ site.github.tar_url }}" class="btn">Download .tar.gz</a>
{% endif %}
{% endif %}
{% if site.show_downloads %}
<a href="{{ site.github.zip_url }}" class="btn">Download .zip</a>
<a href="{{ site.github.tar_url }}" class="btn">Download .tar.gz</a>
{% endif %}
</div>
<nav id="nav">
<span><a href="/laravel-filemanager">Home</a></span>
<span><a href="installation">Installation</a></span>
@@ -38,10 +110,12 @@
<span><a href="events">Events</a></span>
<span><a href="upgrade">Upgrade</a></span>
<span><a href="contribution">Contribution</a></span>
<span><a href="security">Security</a></span>
</nav>
</section>
<section class="main-content">
<script async type="text/javascript" src="//cdn.carbonads.com/carbon.js?serve=CK7DE2JL&placement=unisharpgithubio" id="_carbonads_js"></script>
{{ content }}
<footer class="site-footer">

View File

@@ -2,89 +2,261 @@
## Routing:
| Key | Type | Description |
|--------------------|---------|--------------------------------------------------------------------------------------------------------------|
| use\_package\_routes | boolean | Use routes from package or not. If false, you will need to define routes to all controllers of this package. |
| middlewares | array | Middlewares to be applied to default routes. For laravel 5.1 and before, remove 'web' from the array. |
| url_prefix | string | The url prefix to this package. Change it if necessary. |
### use\_package\_routes
* type: `boolean`
* default: `true`
Use default routes or not. You will need to define routes to all controllers of this package if this is set to `false`.
## Multi-User Mode:
| Key | Type | Description |
|--------------------|---------|------------------------------------------------------------------------------------------------|
| allow\_multi\_user | boolean | If true, private folders will be created for each signed-in user. |
| allow\_share\_folder | boolean | If true, share folder will be created. |
| user_field | string | Private folders will be named by this. Can receive column name of `users` table or class name. |
### allow\_private\_folder
### If you want to name private folders other than columns of users table, follow these steps:
1. Run `php artisan vendor:publish --tag=lfm_handler`.
2. Fill `App\Handler\ConfigHander::class` into `user_field`.
3. Edit `userField()` in the `App\Handler\ConfigHander`
* type: `boolean`
* default: `true`
Only the owner(each signed-in user) of the private can upload and manage files within. Set to `false` to turn this feature off.
### private\_folder\_name
* type: `string`
* default: user id
Privates folders for each user will be named by this config. Default to user id.
To change the behavior:
1. run `php artisan publish tag="lfm_handler"`
2. rewrite `userField` function in App\Handler\ConfigHandler class
3. set value of this config to App\Handler\ConfigHandler::class
### allow\_shared\_folder
* type: `boolean`
* default: `true`
### shared\_folder\_name
* type: `string`
* default: `"shares"`
Flexible way to customize client folders accessibility.
If you want to customize client folders:
1. run `php artisan publish tag="lfm_handler"`
2. rewrite `userField` function in `App\Handler\ConfigHandler` class
3. set value of this config to `App\Handler\ConfigHandler::class`
All users can upload and manage files within shared folders. Set to `false` to turn this feature off.
## Working Directory:
## Folder Categories
| Key | Type | Description |
|--------------------|--------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| base_directory | string | Which folder to store files in project, fill in 'public', 'resources', 'storage' and so on. Does not support path relative path like `../public_html` or `public/upload/user/`. |
| images\_folder\_name | string | Does not support path relative path like `../public_html` or `public/upload/user/`. |
| files\_folder\_name | string | Does not support path relative path like `../public_html` or `public/upload/user/`. |
| shared\_folder\_name | string | Does not support path relative path like `../public_html` or `public/upload/user/`. |
| thumb\_folder\_name | string | Does not support path relative path like `../public_html` or `public/upload/user/`. |
### folder\_categories
* type: `array` (nested)
* default:
## Startup Views:
```
'folder_categories' => [
'file' => [
'folder_name' => 'files',
'startup_view' => 'list',
'max_size' => 50000, // size in KB
'valid_mime' => [
'image/jpeg',
'image/pjpeg',
'image/png',
'image/gif',
'application/pdf',
'text/plain',
],
],
'image' => [
'folder_name' => 'photos',
'startup_view' => 'grid',
'max_size' => 50000, // size in KB
'valid_mime' => [
'image/jpeg',
'image/pjpeg',
'image/png',
'image/gif',
],
],
],
```
| Key | Type | Description |
|---------------------|--------|-----------------------------------------------------------------|
| images\_startup\_view | string | The default display type for images. Supported: "grid", "list". |
| files\_startup\_view | string | The default display type for files. Supported: "grid", "list". |
The default config creates two folder categories, `file` and `image`, each operates independently. Files uploaded by users will be placed under one of these folder categories, depend on which is configured with your WYSIWYG editor or stand-alone upload button.
Detail options are explained here:
* `folder_name`: The folder name of the category. For example, if `folder_name` is set to `files2` then:
* directory path of the private folder will be: `/<path-to-laravel>/storage/app/public/files2/<user-id>/`
* directory path of the shared folder will be: `/<path-to-laravel>/storage/app/public/files2/shares/`
* `startup_view`: The default display mode. Available options: `list` & `grid`.
* `max_size`: The maximum size(in KB) of of a single file to be uploaded.
* `valid_mime`: Only files with mime types listed here are allowed to be uploaded. See [full mime types list](http://docs.w3cub.com/http/basics_of_http/mime_types/complete_list_of_mime_types/).
## Pagination:
### paginator
* type: `array`
* default:
```
'paginator' => [
'perPage' => 30,
],
```
## Upload / Validation:
| Key | Type | Description |
|-------------------------|---------|--------------------------------------------------------------------------|
| rename_file | string | If true, the uploaded file will be renamed to uniqid() + file extension. |
| alphanumeric_filename | string | If true, non-alphanumeric file name will be replaced with `_`. |
| alphanumeric_directory | boolean | If true, non-alphanumeric folder name will be rejected. |
| should\_validate\_size | boolean | If true, the size of uploading file will be verified. |
| max\_image\_size | int | Specify max size of uploading image. |
| max\_file\_size | int | Specify max size of uploading file. |
| should\_validate\_mime | boolean | If true, the mime type of uploading file will be verified. |
| valid\_image\_mimetypes | array | Array of mime types. Available since v1.3.0 . |
| should\_create\_thumbnails | boolean | If true, thumbnails will be created for faster loading. |
| 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 . |
### disk
* type: `string`
* default: `public`
## Thumbnail dimensions:
Disk name of Laravel File System. All files are placed in here. Choose one of the `disks` section in `config/filesystems.php`.
### rename\_file
* type: `boolean`
* default: `false`
If set to `true`, the uploaded file will be renamed using `uniqid()`.
### alphanumeric\_filename
* type: `boolean`
* default: `false`
If set to `true`, non-alphanumeric file name will be replaced with `_`.
### alphanumeric\_directory
* type: `boolean`
* default: `false`
If set to `true`, non-alphanumeric folder name will be rejected.
### should\_validate\_size
* type: `boolean`
* default: `false`
If set to `true`, the size of uploading file will be verified.
### should\_validate\_mime
* type: `boolean`
* default: `true`
If set to `true`, the mime type of uploading file will be verified.
### over\_write\_on_duplicate
* type: `int`
* default: `false`
Define behavior on files with identical name. Setting it to `true` cause old file replace with new one. Setting it to `false` show `error-file-exist` error and abort the upload process.
## Thumbnail
### should\_create\_thumbnails
* type: `boolean`
* default: `true`
If set to `true`, thumbnails will be created for faster loading.
### thumb\_folder\_name
* type: `string`
* default: `thumbs`
Folder name to place thumbnails.
### raster\_mimetypes
* type: `array`
* default:
```
'raster_mimetypes' => [
'image/jpeg',
'image/pjpeg',
'image/png',
],
```
Create thumbnails automatically only for listed types. See [full mime types list](http://docs.w3cub.com/http/basics_of_http/mime_types/complete_list_of_mime_types/).
### thumb_img_width
* type: `int`
* default: `200`
Thumbnail images width (in px).
### thumb_img_height
* type: `int`
* default: `200`
Thumbnail images height (in px).
Create thumbnails automatically only for listed types.
| Key | Type | Description |
|------------------|--------|--------------------------------------------------|
| thumb\_img\_width | string | Width of thumbnail made when image is uploaded. |
| thumb\_img\_height | string | Height of thumbnail made when image is uploaded. |
## File Extension Information
| Key | Type | Description |
|-----------------|-------|---------------------------------------------|
| file\_type\_array | array | Map file extension with display names. |
| file\_icon\_array | array | Map file extension with icons(font-awsome). |
### file\_type\_array
* type: `array`
* default:
```
'file_type_array' => [
'pdf' => 'Adobe Acrobat',
'doc' => 'Microsoft Word',
'docx' => 'Microsoft Word',
'xls' => 'Microsoft Excel',
'xlsx' => 'Microsoft Excel',
'zip' => 'Archive',
'gif' => 'GIF Image',
'jpg' => 'JPEG Image',
'jpeg' => 'JPEG Image',
'png' => 'PNG Image',
'ppt' => 'Microsoft PowerPoint',
'pptx' => 'Microsoft PowerPoint',
],
```
Gives description for listed file extensions.
## php.ini override
| Key | Type | Description |
|-------------------|-----------------|-----------------------------------------------------------------------------------------------------------------------------------|
| php\_ini\_overrides | array or boolean | These values override your php.ini settings before uploading files. Set these to false to ingnore and apply your php.ini settings |
### php\_ini\_overrides
### Caveats
* type: `array` or `boolean`
* default:
```
'php_ini_overrides' => [
'memory_limit' => '256M',
],
```
These values override your php.ini settings before uploading files. Set these to false to ingnore and apply your php.ini settings
⚠️ **Caveats**
The php\_ini\_overrides are applied on every request the filemanager does and are reset once the script has finished executing.
This has one drawback: any ini settings that you might want to change that apply to the request itself will not work.

View File

@@ -9,5 +9,6 @@
make init
```
1. Edit codes in `vendor/unisharp/laravel-filemanager`
1. Push your changes to your fork.
1. Commit and follow rules in [Conventional Commits](https://www.conventionalcommits.org/).
1. Push your changes to a new branch other than `master`. Good branch name might be like: `feature/add-pagination`, `fix/file-not-displayed`.
1. Send a pull request to [unisharp/laravel-filemanager](https://github.com/UniSharp/laravel-filemanager).

View File

@@ -1,5 +1,18 @@
## Routes
1. Copy the routes in `/vendor/unisharp/laravel-filemanager/src/routes.php`
1. Edit `routes/web.php` :
Create route group to wrap package routes.
```php
Route::group(['prefix' => 'laravel-filemanager', 'middleware' => ['web', 'auth']], function () {
\UniSharp\LaravelFilemanager\Lfm::routes();
});
```
Make sure `auth` middleware is present to :
1. prevent unauthorized uploads
1. work properly with multi-user mode
1. Make sure urls below is correspond to your route (remember to include type parameter `?type=Images` or `?type=Files`) :
* CKEditor
@@ -8,7 +21,7 @@
filebrowserImageBrowseUrl: '/your-custom-route?type=Images',
filebrowserBrowseUrl: '/your-custom-route?type=Files'
});
```
```
* TinyMCE
```javascript
...

View File

@@ -1,17 +1,34 @@
## List of events
* Unisharp\Laravelfilemanager\Events\ImageIsUploading
* Unisharp\Laravelfilemanager\Events\ImageWasUploaded
* Unisharp\Laravelfilemanager\Events\ImageIsRenaming
* Unisharp\Laravelfilemanager\Events\ImageWasRenamed
* Unisharp\Laravelfilemanager\Events\ImageIsDeleting
* Unisharp\Laravelfilemanager\Events\ImageWasDeleted
* Unisharp\Laravelfilemanager\Events\FolderIsRenaming
* Unisharp\Laravelfilemanager\Events\FolderWasRenamed
* Unisharp\Laravelfilemanager\Events\ImageIsResizing
* Unisharp\Laravelfilemanager\Events\ImageWasResized
* Unisharp\Laravelfilemanager\Events\ImageIsCropping
* Unisharp\Laravelfilemanager\Events\ImageWasCropped
* File
* UniSharp\LaravelFilemanager\Events\FileIsUploading
* UniSharp\LaravelFilemanager\Events\FileWasUploaded
* UniSharp\LaravelFilemanager\Events\FileIsRenaming
* UniSharp\LaravelFilemanager\Events\FileWasRenamed
* UniSharp\LaravelFilemanager\Events\FileIsMoving
* UniSharp\LaravelFilemanager\Events\FileWasMoving
* UniSharp\LaravelFilemanager\Events\FileIsDeleting
* UniSharp\LaravelFilemanager\Events\FileWasDeleted
* Image
* UniSharp\LaravelFilemanager\Events\ImageIsUploading
* UniSharp\LaravelFilemanager\Events\ImageWasUploaded
* UniSharp\LaravelFilemanager\Events\ImageIsRenaming
* UniSharp\LaravelFilemanager\Events\ImageWasRenamed
* UniSharp\LaravelFilemanager\Events\ImageIsResizing
* UniSharp\LaravelFilemanager\Events\ImageWasResized
* UniSharp\LaravelFilemanager\Events\ImageIsCropping
* UniSharp\LaravelFilemanager\Events\ImageWasCropped
* UniSharp\LaravelFilemanager\Events\ImageIsDeleting
* UniSharp\LaravelFilemanager\Events\ImageWasDeleted
* Folder
* UniSharp\LaravelFilemanager\Events\FolderIsCreating
* UniSharp\LaravelFilemanager\Events\FolderWasCreated
* UniSharp\LaravelFilemanager\Events\FolderIsRenaming
* UniSharp\LaravelFilemanager\Events\FolderWasRenamed
* UniSharp\LaravelFilemanager\Events\FolderIsMoving
* UniSharp\LaravelFilemanager\Events\FolderWasMoving
* UniSharp\LaravelFilemanager\Events\FolderIsDeleting
* UniSharp\LaravelFilemanager\Events\FolderWasDeleted
## How to use
* Sample code : [laravel-filemanager-demo-events](https://github.com/UniSharp/laravel-filemanager-demo-events)

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 966 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -2,28 +2,34 @@
[![Total Downloads](https://poser.pugx.org/unisharp/laravel-filemanager/downloads)](https://packagist.org/packages/unisharp/laravel-filemanager)
[![License](https://poser.pugx.org/unisharp/laravel-filemanager/license)](https://packagist.org/packages/unisharp/laravel-filemanager)
This is the document of v2 version, v1 document can be found here: [https://github.com/UniSharp/laravel-filemanager/tree/v1/docs](https://github.com/UniSharp/laravel-filemanager/tree/v1/docs)
## Features
* CKEditor and TinyMCE integration
* Standalone button
* File upload and management
* Uploading validation
* Cropping and resizing of images
* Public and private folders for multi users
* RWD user interface, and can be entirely customized
* Supporting multiple files selection
* Supporting cloud storages integration(with Laravel file system)
* Multiple integration options:
* WYSIWYG editors integration (CKEditor, TinyMCE, Summernote)
* Standalone upload button
* Iframe
* Multi-user mode:
* Shared folders: all users can upload and manage files
* Private folders: dedicated folder for each user, only the owner can upload or manage files within
* 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
* Supports two categories: files and images. Each type works in different directory.
* Supported locales : ar, az, bg, cs, de, el, en, es, eu, fa, fr, he, hu, id, it, ka, nl, pl, pt, pt-BR, ro, rs, ru, sk, sv, tr, uk, vi, zh-CN, zh-TW
PR is welcome!
PRs are welcome!
## Screenshots
> Standalone button :
![Standalone button demo](https://unisharp.github.io/laravel-filemanager/images/lfm01.png)
> Grid view :
> Responsive design :
![Grid view demo](https://unisharp.github.io/laravel-filemanager/images/lfm02.png)
> List view :
![List view demo](https://unisharp.github.io/laravel-filemanager/images/lfm03.png)
![RWD demo](https://unisharp.github.io/laravel-filemanager/images/screenshots-v2.png)

View File

@@ -6,16 +6,28 @@
* Laravel 5
* requires [intervention/image](https://github.com/Intervention/image) (to make thumbs, crop and resize images).
## Installation
1. Install package
## TL;DR
1. Run these lines
```bash
composer require unisharp/laravel-filemanager:~1.8
composer require unisharp/laravel-filemanager
php artisan vendor:publish --tag=lfm_config
php artisan vendor:publish --tag=lfm_public
php artisan storage:link
```
1. Edit `config/app.php` :
1. Edit `APP_URL` in `.env`.
\* *For Laravel 5.5 and up, skip to step 3. All service providers and facades are automatically discovered.*
## Full Installation Guide
1. Install package
```bash
composer require unisharp/laravel-filemanager
```
1. (optional) Edit `config/app.php` :
\* *For Laravel 5.5 and up, skip to step 3. All service providers and facades are automatically discovered.*
Add service providers
@@ -39,16 +51,46 @@
php artisan vendor:publish --tag=lfm_config
php artisan vendor:publish --tag=lfm_public
```
1. Run commands to clear cache :
1. (optional) Run commands to clear cache :
```bash
php artisan route:clear
php artisan config:clear
```
1. Ensure that the files & images directories (in `config/lfm.php`) are writable by your web server (run commands like `chown` or `chmod`).
1. Create symbolic link :
```bash
php artisan storage:link
```
1. Edit `APP_URL` in `.env`.
1. Edit `routes/web.php` :
Create route group to wrap package routes.
```php
Route::group(['prefix' => 'laravel-filemanager', 'middleware' => ['web', 'auth']], function () {
\UniSharp\LaravelFilemanager\Lfm::routes();
});
```
Make sure `auth` middleware is present to :
1. prevent unauthorized uploads
1. work properly with multi-user mode
1. make sure database exists
1. login and visit `/laravel-filemanager/demo`
## Installing alpha version
* Run `composer require unisharp/laravel-filemanager:dev-master` to get the latest developer version.
## What's next
1. Check the [integration document](http://unisharp.github.io/laravel-filemanager/integration) to see how to apply this package.

View File

@@ -34,8 +34,54 @@ Check `vendor/unisharp/laravel-filemanager/src/views/demo.blade.php`, which alre
$('textarea.my-editor').ckeditor(options);
</script>
```
### Option 2: TinyMCE5
### Option 2: TinyMCE4
```html
<script src="/path-to-your-tinymce/tinymce.min.js"></script>
<textarea name="content" class="form-control my-editor">{!! old('content', $content) !!}</textarea>
<script>
var editor_config = {
path_absolute : "/",
selector: 'textarea.my-editor',
relative_urls: false,
plugins: [
"advlist autolink lists link image charmap print preview hr anchor pagebreak",
"searchreplace wordcount visualblocks visualchars code fullscreen",
"insertdatetime media nonbreaking save table directionality",
"emoticons template paste textpattern"
],
toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image media",
file_picker_callback : function(callback, value, meta) {
var x = window.innerWidth || document.documentElement.clientWidth || document.getElementsByTagName('body')[0].clientWidth;
var y = window.innerHeight|| document.documentElement.clientHeight|| document.getElementsByTagName('body')[0].clientHeight;
var cmsURL = editor_config.path_absolute + 'laravel-filemanager?editor=' + meta.fieldname;
if (meta.filetype == 'image') {
cmsURL = cmsURL + "&type=Images";
} else {
cmsURL = cmsURL + "&type=Files";
}
tinyMCE.activeEditor.windowManager.openUrl({
url : cmsURL,
title : 'Filemanager',
width : x * 0.8,
height : y * 0.8,
resizable : "yes",
close_previous : "no",
onMessage: (api, message) => {
callback(message.content);
}
});
}
};
tinymce.init(editor_config);
</script>
```
### Option 3: TinyMCE4
```html
<script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
@@ -78,13 +124,13 @@ Check `vendor/unisharp/laravel-filemanager/src/views/demo.blade.php`, which alre
</script>
```
### Option 3: Summernote
### Option 4: Summernote
```html
<!-- dependencies (Summernote depends on Bootstrap & jQuery) -->
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.css" rel="stylesheet">
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.js"></script>
<link href="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.3/summernote.css" rel="stylesheet">
<script src="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.3/summernote.js"></script>
@@ -94,44 +140,45 @@ Check `vendor/unisharp/laravel-filemanager/src/views/demo.blade.php`, which alre
<!-- summernote config -->
<script>
$(document).ready(function(){
$(document).ready(function(){
// Define function to open filemanager window
var lfm = function(options, cb) {
var route_prefix = (options && options.prefix) ? options.prefix : '/laravel-filemanager';
window.open(route_prefix + '?type=' + options.type || 'file', 'FileManager', 'width=900,height=600');
window.SetUrl = cb;
var route_prefix = (options && options.prefix) ? options.prefix : '/laravel-filemanager';
window.open(route_prefix + '?type=' + options.type || 'file', 'FileManager', 'width=900,height=600');
window.SetUrl = cb;
};
// Define LFM summernote button
var LFMButton = function(context) {
var ui = $.summernote.ui;
var button = ui.button({
contents: '<i class="note-icon-picture"></i> ',
tooltip: 'Insert image with filemanager',
click: function() {
lfm({type: 'image', prefix: '/file-manager'}, function(url, path) {
context.invoke('insertImage', url);
});
var ui = $.summernote.ui;
var button = ui.button({
contents: '<i class="note-icon-picture"></i> ',
tooltip: 'Insert image with filemanager',
click: function() {
}
});
return button.render();
lfm({type: 'image', prefix: '/laravel-filemanager'}, function(lfmItems, path) {
lfmItems.forEach(function (lfmItem) {
context.invoke('insertImage', lfmItem.url);
});
});
}
});
return button.render();
};
// Initialize summernote with LFM button in the popover button group
// Please note that you can add this button to any other button group you'd like
$('#summernote-editor').summernote({
toolbar: [
['popovers', ['lfm']],
],
buttons: {
lfm: LFMButton
}
toolbar: [
['popovers', ['lfm']],
],
buttons: {
lfm: LFMButton
}
})
});
});
</script>
```
@@ -151,11 +198,11 @@ If you are going to use filemanager independently, meaning set the value of an i
<input id="thumbnail" class="form-control" type="text" name="filepath">
</div>
<img id="holder" style="margin-top:15px;max-height:100px;">
```
```
1. Import lfm.js(run `php artisan vendor:publish` if you need).
```html
<script src="/vendor/laravel-filemanager/js/lfm.js"></script>
<script src="/vendor/laravel-filemanager/js/stand-alone-button.js"></script>
```
1. Init filemanager with type. (requires jQuery)
@@ -171,32 +218,61 @@ If you are going to use filemanager independently, meaning set the value of an i
Domain can be specified in the second parameter(optional, but will be required when developing on Windows mechines) :
```javascript
var domain = "{{ url() }}";
$('#lfm').filemanager('image', {prefix: domain});
var route_prefix = "url-to-filemanager";
$('#lfm').filemanager('image', {prefix: route_prefix});
```
## JavaScript integration
In case you are developing javascript application and you want dynamically to trigger filemanager popup, you can create function like this. It doesn't rely on jQuery.
```javascript
var lfm = function(options, cb) {
var lfm = function(id, type, options) {
let button = document.getElementById(id);
var route_prefix = (options && options.prefix) ? options.prefix : '/laravel-filemanager';
button.addEventListener('click', function () {
var route_prefix = (options && options.prefix) ? options.prefix : '/laravel-filemanager';
var target_input = document.getElementById(button.getAttribute('data-input'));
var target_preview = document.getElementById(button.getAttribute('data-preview'));
window.open(route_prefix + '?type=' + options.type || 'file', 'FileManager', 'width=900,height=600');
window.SetUrl = cb;
}
window.open(route_prefix + '?type=' + options.type || 'file', 'FileManager', 'width=900,height=600');
window.SetUrl = function (items) {
var file_path = items.map(function (item) {
return item.url;
}).join(',');
// set the value of the desired input to image url
target_input.value = file_path;
target_input.dispatchEvent(new Event('change'));
// clear previous preview
target_preview.innerHtml = '';
// set or change the preview image src
items.forEach(function (item) {
let img = document.createElement('img')
img.setAttribute('style', 'height: 5rem')
img.setAttribute('src', item.thumb_url)
target_preview.appendChild(img);
});
// trigger change event
target_preview.dispatchEvent(new Event('change'));
};
});
};
```
And use it like this:
```javascript
lfm({type: 'image', prefix: 'prefix'}, function(url, path) {
});
var route_prefix = "url-to-filemanager";
lfm('lfm', 'image', {prefix: route_prefix});
lfm('lfm2', 'file', {prefix: route_prefix});
```
The first parameter is id, the second parameter is the type of laravel filemanager(which ).
## Embed file manager
```html

View File

@@ -0,0 +1,15 @@
## Security
It is important to note that if you use your own routes **you must protect your routes to Laravel-Filemanager in order to prevent unauthorized uploads to your server**. Fortunately, Laravel makes this very easy.
If, for example, you want to ensure that only logged in users have the ability to access the Laravel-Filemanager, simply wrap the routes in a group, perhaps like this:
```php
Route::group(['middleware' => 'auth'], function () { // auth middleware is important!
\UniSharp\LaravelFilemanager\Lfm::routes();
});
```
This approach ensures that only authenticated users have access to the Laravel-Filemanager. If you are using Middleware or some other approach to enforce security, modify as needed.
**If you use the laravel-filemanager default route, make sure the `auth` middleware (set in config/lfm.php) is enabled and functional**.

View File

@@ -1,19 +1,23 @@
## Upgrade instructions
1. Please backup your own `config/lfm.php` before upgrading.
1. Run commands:
```bash
composer update unisharp/laravel-filemanager
php artisan vendor:publish --tag=lfm_view --force
php artisan vendor:publish --tag=lfm_public --force
php artisan vendor:publish --tag=lfm_config --force
php artisan route:clear
php artisan config:clear
```
1. Clear browser cache if page is broken after upgrading.
## Errors with namespace
We have changed namespace from `Unisharp` to `UniSharp`, and change the first character of every namespace into capital.
If you are updating this package and encounter any errors like `Class not found`, please remove this package entirely and reinstall again.