Skip to content

Commit b678019

Browse files
author
gwleuverink
committed
Updating to unisharp master branch
2 parents 256eb30 + a774800 commit b678019

29 files changed

+695
-328
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Please check the following instructions before submitting a bug :
2+
* Make sure you are using the latest version.
3+
* If you are new to this package, make sure you followed every step from [installation document](http://unisharp.github.io/laravel-filemanager/installation).
4+
* If you have problem applying this package, please check the [integration document](http://unisharp.github.io/laravel-filemanager/integration).
5+
* If anything went broken after you upgraded, please check the [upgrade document](http://unisharp.github.io/laravel-filemanager/upgrade).
6+
7+
If your problem still remains, please do these steps :
8+
* run `php ./vendor/unisharp/laravel-filemanager/bin/debug` and paste the results here.
9+
* (optional) If there are errors in browser console, click on the links and you should see some PHP exceptions. Please capture screenshots and paste them here.

README.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,33 @@
1313
* Demo : [Laravel Filemanager container](https://github.com/UniSharp/laravel-filemanager-example-5.3)
1414

1515
## v1.7 released
16+
* Please follow the intructions in [upgrade document](https://unisharp.github.io/laravel-filemanager/upgrade).
1617
* Important changes :
1718
* All code refactored.
1819
* Fix Windows compatibility.
1920
* Fix file cannot be uploaded to "File Mode".
2021
* Config file is also refactored, see [config document](https://unisharp.github.io/laravel-filemanager/config).
21-
* Please follow the intructions in [this document](https://unisharp.github.io/laravel-filemanager/upgrade) to upgrade.
22-
22+
23+
## Security
24+
25+
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.
26+
27+
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:
28+
29+
```php
30+
Route::group(array('before' => 'auth'), function ()
31+
{
32+
Route::get('/laravel-filemanager', '\Unisharp\Laravelfilemanager\controllers\LfmController@show');
33+
Route::post('/laravel-filemanager/upload', '\Unisharp\Laravelfilemanager\controllers\LfmController@upload');
34+
// list all lfm routes here...
35+
});
36+
```
37+
38+
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.
39+
40+
**If you use the laravel-filemanager default route, make sure the `auth` middleware (set in config/lfm.php) is enabled and functional**.
41+
42+
2343
## Credits
2444
Special thanks to
2545

docs/_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ theme: jekyll-theme-cayman
22

33
# Setup
44
title: Laravel File Manager
5-
description: File manager/gallery with CKEditor and TinyMCE support.
5+
description: File manager/gallery with CKEditor, TinyMCE and Summernote support.
66

77
# About/contact
88
author:

docs/config.md

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ In `config/lfm.php` :
1717
// The url to this package. Change it if necessary.
1818
'prefix' => 'laravel-filemanager',
1919

20+
// The prefix of urls to non-public files, for exmaple if: base_directory !== 'public'
21+
// Without slashes
22+
'urls_prefix' => '',
23+
2024
/*
2125
|--------------------------------------------------------------------------
2226
| Multi-User Mode
@@ -25,10 +29,15 @@ In `config/lfm.php` :
2529

2630
// If true, private folders will be created for each signed-in user.
2731
'allow_multi_user' => true,
32+
// If true, share folder will be created when allow_multi_user is true.
33+
'allow_share_folder' => true,
2834

29-
// The database column to identify a user. Make sure the value is unique.
30-
// Ex: When set to 'id', the private folder of user will be named as the user id.
31-
'user_field' => 'id',
35+
// Flexibla way to customize client folders accessibility
36+
// Ex: The private folder of user will be named as the user id.
37+
// You cant use a closure when using the optimized config file (in Laravel 5.2 anyway)
38+
'user_field' => function() {
39+
return auth()->user()->id;
40+
},
3241

3342
/*
3443
|--------------------------------------------------------------------------
@@ -72,15 +81,22 @@ In `config/lfm.php` :
7281
// If true, non-alphanumeric folder name will be rejected.
7382
'alphanumeric_directory' => false,
7483

75-
'max_image_size' => 500,
76-
'max_file_size' => 1000,
84+
// If true, the uploading file's size will be verified for over than max_image_size/max_file_size.
85+
'should_validate_size' => false,
86+
87+
'max_image_size' => 50000,
88+
'max_file_size' => 50000,
89+
90+
// If true, the uploading file's mime type will be valid in valid_image_mimetypes/valid_file_mimetypes.
91+
'should_validate_mime' => false,
7792

7893
// available since v1.3.0
7994
'valid_image_mimetypes' => [
8095
'image/jpeg',
8196
'image/pjpeg',
8297
'image/png',
83-
'image/gif'
98+
'image/gif',
99+
'image/svg+xml',
84100
],
85101

86102
// available since v1.3.0
@@ -90,10 +106,20 @@ In `config/lfm.php` :
90106
'image/pjpeg',
91107
'image/png',
92108
'image/gif',
109+
'image/svg+xml',
93110
'application/pdf',
94111
'text/plain',
95112
],
96113

114+
/*
115+
|--------------------------------------------------------------------------
116+
| Image / Folder Setting
117+
|--------------------------------------------------------------------------
118+
*/
119+
120+
'thumb_img_width' => 200,
121+
'thumb_img_height' => 200,
122+
97123
/*
98124
|--------------------------------------------------------------------------
99125
| File Extension Information
@@ -129,4 +155,28 @@ In `config/lfm.php` :
129155
'ppt' => 'fa-file-powerpoint-o',
130156
'pptx' => 'fa-file-powerpoint-o',
131157
],
158+
159+
/*
160+
|--------------------------------------------------------------------------
161+
| php.ini override
162+
|--------------------------------------------------------------------------
163+
*/
164+
// These values override your php.ini settings before uploading files
165+
// Set these to false to ingnore and apply your php.ini settings
166+
'php_ini_overrides' => [
167+
'memory_limit' => '256M'
168+
],
132169
```
170+
171+
## Caveats
172+
### php.ini overrides
173+
174+
The php_ini_overrides are applied on every request the filemanager does and are reset once the script has finished executing.
175+
This has one drawback: any ini settings that you might want to change that apply to the request itself will not work.
176+
177+
For example, overriding these settings will not work:
178+
* upload_max_filesize
179+
* post_max_size
180+
181+
**Why this is expected behaviour:**
182+
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.

docs/installation.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## Requirements
22
* php >= 5.4
3+
* exif extension
4+
* gd OR imagick (choose one only)
35
* Laravel 5
46
* requires [intervention/image](https://github.com/Intervention/image) (to make thumbs, crop and resize images).
57

@@ -35,4 +37,8 @@
3537
php artisan vendor:publish --tag=lfm_public
3638
```
3739
38-
1. Ensure that the files & images directories (in `config/lfm.php`) are writable by your web server(run commands like `chown` or `chmod`).
40+
1. Ensure that the files & images directories (in `config/lfm.php`) are writable by your web server (run commands like `chown` or `chmod`).
41+
42+
1. Check the [integration document](http://unisharp.github.io/laravel-filemanager/integration) to see how to apply this package.
43+
44+
1. Check the [config document](http://unisharp.github.io/laravel-filemanager/config) to discover the flexibility of this package.

docs/integration.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,63 @@ Check `vendor/unisharp/laravel-filemanager/src/views/demo.blade.php`, which alre
7878
</script>
7979
```
8080

81+
### Option 3: Summernote
82+
83+
```html
84+
<!-- dependencies (Summernote depends on Bootstrap & jQuery) -->
85+
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.css" rel="stylesheet">
86+
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.js"></script>
87+
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.js"></script>
88+
89+
<link href="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.3/summernote.css" rel="stylesheet">
90+
<script src="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.3/summernote.js"></script>
91+
92+
<!-- markup -->
93+
<textarea id="summernote-editor" name="content">{!! old('content', $content) !!}</textarea>
94+
95+
<!-- summernote config -->
96+
<script>
97+
$(document).ready(function(){
98+
99+
// Define function to open filemanager window
100+
var lfm = function(options, cb) {
101+
var route_prefix = (options && options.prefix) ? options.prefix : '/laravel-filemanager';
102+
window.open(route_prefix + '?type=' + options.type || 'file', 'FileManager', 'width=900,height=600');
103+
window.SetUrl = cb;
104+
};
105+
106+
// Define LFM summernote button
107+
var LFMButton = function(context) {
108+
var ui = $.summernote.ui;
109+
var button = ui.button({
110+
contents: '<i class="note-icon-picture"></i> ',
111+
tooltip: 'Insert image with filemanager',
112+
click: function() {
113+
114+
lfm({type: 'image', prefix: '/file-manager'}, function(url, path) {
115+
context.invoke('insertImage', url);
116+
});
117+
118+
}
119+
});
120+
return button.render();
121+
};
122+
123+
// Initialize summernote with LFM button in the popover button group
124+
// Please note that you can add this button to any other button group you'd like
125+
$('#summernote-editor').summernote({
126+
toolbar: [
127+
['popovers', ['lfm']],
128+
],
129+
buttons: {
130+
lfm: LFMButton
131+
}
132+
})
133+
134+
});
135+
</script>
136+
```
137+
81138
## Standalone button
82139
If you are going to use filemanager independently, meaning set the value of an input to selected photo/file url, follow this structure:
83140

public/css/lfm.css

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@
4747
text-overflow: ellipsis;
4848
}
4949

50-
.img-row {
51-
margin-bottom: 20px;
52-
}
53-
5450
.clickable {
5551
cursor: pointer;
5652
}
@@ -67,44 +63,52 @@
6763
display: none;
6864
}
6965

70-
.thumbnail {
71-
max-width: 210px;
72-
max-height: 210px;
73-
margin-bottom: 0 !important;
74-
}
75-
76-
.thumbnail-mobile {
77-
height: 60px;
78-
width: 60px;
79-
}
80-
8166
.square {
8267
width: 100%;
8368
padding-bottom: 100%;
8469
position: relative;
70+
border: 1px solid rgb(221, 221, 221);
71+
border-radius: 3px;
72+
// max-width: 210px;
73+
max-height: 210px;
8574
}
86-
.square > img, .square > .icon-container {
75+
.visible-xs .square {
76+
width: 60px;
77+
}
78+
.square > img {
79+
padding: 5px;
8780
position: absolute;
88-
top: 0;
89-
right: 0;
90-
bottom: 0;
91-
left: 0;
9281
max-width: 100%;
82+
max-height: 100%;
83+
margin: 0 auto;
84+
display: inline-block;
85+
vertical-align: middle;
86+
}
87+
.square > i {
88+
font-size: 80px;
89+
padding: 5px;
90+
position: absolute;
91+
top: calc(50% - 40px);
92+
left: calc(50% - 40px);
93+
}
94+
.visible-xs .square > i {
95+
font-size: 50px;
96+
padding: 0px auto;
97+
padding-top: 5px;
98+
top: calc(50% - 25px);
99+
left: calc(50% - 25px);
93100
}
94101

95-
.icon-container {
102+
.caption {
103+
margin-top: 10px;
104+
margin-bottom: 20px;
105+
}
106+
.caption > .btn-group {
96107
width: 100%;
97-
height: 100%;
98-
text-align: center;
99-
margin: 0 auto;
100108
}
101-
.icon-container:before {
102-
content: '';
103-
display: inline-block;
104-
vertical-align: middle ;
105-
height: 100%;
109+
.caption > .btn-group > .item_name {
110+
width: calc(100% - 25px);
106111
}
107-
.icon-container > i {
108-
display: inline-block;
109-
vertical-align: middle;
112+
.caption > .btn-group > .dropdown-toggle {
113+
width: 25px;
110114
}

public/css/mfb.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/js/lfm.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
(function( $ ){
22

33
$.fn.filemanager = function(type, options) {
4-
type = type || 'image';
5-
6-
if (type === 'image' || type === 'images') {
7-
type = 'Images';
8-
} else {
9-
type = 'Files';
10-
}
4+
type = type || 'file';
115

126
this.on('click', function(e) {
137
var route_prefix = (options && options.prefix) ? options.prefix : '/laravel-filemanager';

0 commit comments

Comments
 (0)