Laravel version update

Laravel version update
This commit is contained in:
Manish Verma
2018-08-06 18:48:58 +05:30
parent d143048413
commit 126fbb0255
13678 changed files with 1031482 additions and 778530 deletions

View File

@@ -0,0 +1,11 @@
theme: jekyll-theme-cayman
# Setup
title: Laravel File Manager
description: File manager/gallery with CKEditor, TinyMCE and Summernote support.
google_analytics: UA-92410814-4
# About/contact
author:
name: UniSharp
url: https://github.com/UniSharp

View File

@@ -0,0 +1,67 @@
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="UTF-8">
<title>{{ page.title | default: site.title }}</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#157878">
<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>
#nav > span > a {
color: #dddddd;
}
#nav > span:not(:last-child)::after {
content: ' |';
color: #dddddd;
}
</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 %}
<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 %}
<nav id="nav">
<span><a href="/laravel-filemanager">Home</a></span>
<span><a href="installation">Installation</a></span>
<span><a href="integration">Integration</a></span>
<span><a href="config">Config</a></span>
<span><a href="customization">Customization</a></span>
<span><a href="events">Events</a></span>
<span><a href="upgrade">Upgrade</a></span>
<span><a href="contribution">Contribution</a></span>
</nav>
</section>
<section class="main-content">
{{ content }}
<footer class="site-footer">
{% if site.github.is_project_page %}
<span class="site-footer-owner"><a href="{{ site.github.repository_url }}">{{ site.github.repository_name }}</a> is maintained by <a href="{{ site.github.owner_url }}">{{ site.github.owner_name }}</a>.</span>
{% endif %}
<span class="site-footer-credits">This page was generated by <a href="https://pages.github.com">GitHub Pages</a>.</span>
</footer>
</section>
{% if site.google_analytics %}
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '{{ site.google_analytics }}', 'auto');
ga('send', 'pageview');
</script>
{% endif %}
</body>
</html>

View File

@@ -0,0 +1,97 @@
**The config is in `config/lfm.php`.**
## 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. |
## 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. |
### 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`
## Working Directory:
| 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/`. |
## Startup Views:
| 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". |
## 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 . |
## Thumbnail dimensions:
| 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). |
## 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 |
### 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.
For example, overriding these settings will not work:
* upload\_max\_filesize
* post\_max\_size
**Why this is expected behaviour:**
upload\_max\_filesize and post\_max\_size will get set but uploaded files are already passed to your PHP script before the settings are changed.

View File

@@ -0,0 +1,13 @@
## Steps to contribute
1. Fork [unisharp/laravel-filemanager](https://github.com/UniSharp/laravel-filemanager) from GitHub.
1. Run commands below:
```
git clone git@github.com:UniSharp/laravel-filemanager-example-5.3.git
cd laravel-filemanager-example-5.3
composer require unisharp/laravel-filemanager:dev-master
make init
```
1. Edit codes in `vendor/unisharp/laravel-filemanager`
1. Push your changes to your fork.
1. Send a pull request to [unisharp/laravel-filemanager](https://github.com/UniSharp/laravel-filemanager).

View File

@@ -0,0 +1,34 @@
## Routes
1. Copy the routes in `/vendor/unisharp/laravel-filemanager/src/routes.php`
1. Make sure urls below is correspond to your route (remember to include type parameter `?type=Images` or `?type=Files`) :
* CKEditor
```javascript
CKEDITOR.replace('editor', {
filebrowserImageBrowseUrl: '/your-custom-route?type=Images',
filebrowserBrowseUrl: '/your-custom-route?type=Files'
});
```
* TinyMCE
```javascript
...
var cmsURL = editor_config.path_absolute + 'your-custom-route?field_name='+field_name+'&lang='+ tinymce.settings.language;
if (type == 'image') {
cmsURL = cmsURL + "&type=Images";
} else {
cmsURL = cmsURL + "&type=Files";
}
...
```
## Views
Copy views to `resources/views/vendor/unisharp/laravel-filemanager/` :
```bash
php artisan vendor:publish --tag=lfm_view
```
## Translations
1. Copy `vendor/unisharp/laravel-filemanager/src/lang/en` to `/resources/lang/vendor/laravel-filemanager/<YOUR LANGUAGE>/lfm.php`.
1. Edit the file as you please.

View File

@@ -0,0 +1,97 @@
## 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
## How to use
* Sample code : [laravel-filemanager-demo-events](https://github.com/UniSharp/laravel-filemanager-demo-events)
* To use events you can add a listener to listen to the events.
Snippet for `EventServiceProvider`
```php
protected $listen = [
ImageWasUploaded::class => [
UploadListener::class,
],
];
```
The `UploadListener` will look like:
```php
class UploadListener
{
public function handle($event)
{
$method = 'on'.class_basename($event);
if (method_exists($this, $method)) {
call_user_func([$this, $method], $event);
}
}
public function onImageWasUploaded(ImageWasUploaded $event)
{
$path = $event->path();
//your code, for example resizing and cropping
}
}
```
* Or by using Event Subscribers
Snippet for `EventServiceProvider`
```php
protected $subscribe = [
UploadListener::class
];
```
The `UploadListener` will look like:
```php
public function subscribe($events)
{
$events->listen('*', UploadListener::class);
}
public function handle($event)
{
$method = 'on'.class_basename($event);
if (method_exists($this, $method)) {
call_user_func([$this, $method], $event);
}
}
public function onImageWasUploaded(ImageWasUploaded $event)
{
$path = $event->path();
// your code, for example resizing and cropping
}
public function onImageWasRenamed(ImageWasRenamed $event)
{
// image was renamed
}
public function onImageWasDeleted(ImageWasDeleted $event)
{
// image was deleted
}
public function onFolderWasRenamed(FolderWasRenamed $event)
{
// folder was renamed
}
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

View File

@@ -0,0 +1,29 @@
[![Latest Stable Version](https://poser.pugx.org/unisharp/laravel-filemanager/v/stable)](https://packagist.org/packages/unisharp/laravel-filemanager)
[![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)
## Features
* CKEditor and TinyMCE integration
* Standalone button
* Uploading validation
* Cropping and resizing of images
* 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
PR is welcome!
## Screenshots
> Standalone button :
![Standalone button demo](https://unisharp.github.io/laravel-filemanager/images/lfm01.png)
> Grid view :
![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)

View File

@@ -0,0 +1,56 @@
## Requirements
* php >= 5.4
* exif extension
* fileinfo extension
* GD Library >=2.0 or Imagick PHP extension >=6.5.7
* Laravel 5
* requires [intervention/image](https://github.com/Intervention/image) (to make thumbs, crop and resize images).
## Installation
1. Install package
```bash
composer require unisharp/laravel-filemanager:~1.8
```
1. 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
```php
UniSharp\LaravelFilemanager\LaravelFilemanagerServiceProvider::class,
Intervention\Image\ImageServiceProvider::class,
```
And add class aliases
```php
'Image' => Intervention\Image\Facades\Image::class,
```
Code above is for Laravel 5.1.
In Laravel 5.0 should leave only quoted class names.
1. Publish the package's config and assets :
```bash
php artisan vendor:publish --tag=lfm_config
php artisan vendor:publish --tag=lfm_public
```
1. 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`).
## What's next
1. Check the [integration document](http://unisharp.github.io/laravel-filemanager/integration) to see how to apply this package.
1. Check the [config document](http://unisharp.github.io/laravel-filemanager/config) to discover the flexibility of this package.

View File

@@ -0,0 +1,204 @@
## Note
Check `vendor/unisharp/laravel-filemanager/src/views/demo.blade.php`, which already integrated all options from below.
## WYSIWYG Editor Integration:
### Option 1: CKEditor
```html
<textarea id="my-editor" name="content" class="form-control">{!! old('content', 'test editor content') !!}</textarea>
<script src="//cdn.ckeditor.com/4.6.2/standard/ckeditor.js"></script>
<script>
var options = {
filebrowserImageBrowseUrl: '/laravel-filemanager?type=Images',
filebrowserImageUploadUrl: '/laravel-filemanager/upload?type=Images&_token={{csrf_token()}}',
filebrowserBrowseUrl: '/laravel-filemanager?type=Files',
filebrowserUploadUrl: '/laravel-filemanager/upload?type=Files&_token={{csrf_token()}}'
};
</script>
```
* Sample 1 - Replace by ID:
```html
<script>
CKEDITOR.replace('my-editor', options);
</script>
```
* Sample 2 - With JQuery Selector:
```html
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="/vendor/unisharp/laravel-ckeditor/adapters/jquery.js"></script>
<script>
$('textarea.my-editor').ckeditor(options);
</script>
```
### Option 2: TinyMCE4
```html
<script src="//cdn.tinymce.com/4/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",
plugins: [
"advlist autolink lists link image charmap print preview hr anchor pagebreak",
"searchreplace wordcount visualblocks visualchars code fullscreen",
"insertdatetime media nonbreaking save table contextmenu directionality",
"emoticons template paste textcolor colorpicker textpattern"
],
toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image media",
relative_urls: false,
file_browser_callback : function(field_name, url, type, win) {
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?field_name=' + field_name;
if (type == 'image') {
cmsURL = cmsURL + "&type=Images";
} else {
cmsURL = cmsURL + "&type=Files";
}
tinyMCE.activeEditor.windowManager.open({
file : cmsURL,
title : 'Filemanager',
width : x * 0.8,
height : y * 0.8,
resizable : "yes",
close_previous : "no"
});
}
};
tinymce.init(editor_config);
</script>
```
### Option 3: 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>
<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>
<!-- markup -->
<textarea id="summernote-editor" name="content">{!! old('content', $content) !!}</textarea>
<!-- summernote config -->
<script>
$(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;
};
// 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);
});
}
});
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
}
})
});
</script>
```
## Standalone button
If you are going to use filemanager independently, meaning set the value of an input to selected photo/file url, follow this structure:
1. Create a button, input, and image preview holder if you are going to choose images.
Specify the id to the input and image preview by `data-input` and `data-preview`.
```html
<div class="input-group">
<span class="input-group-btn">
<a id="lfm" data-input="thumbnail" data-preview="holder" class="btn btn-primary">
<i class="fa fa-picture-o"></i> Choose
</a>
</span>
<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>
```
1. Init filemanager with type. (requires jQuery)
```javascript
$('#lfm').filemanager('image');
```
or
```javascript
$('#lfm').filemanager('file');
```
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});
```
## 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 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;
}
```
And use it like this:
```javascript
lfm({type: 'image', prefix: 'prefix'}, function(url, path) {
});
```
## Embed file manager
```html
<iframe src="/laravel-filemanager" style="width: 100%; height: 500px; overflow: hidden; border: none;"></iframe>
```

View File

@@ -0,0 +1,19 @@
## 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.