Skip to content

Commit 93e4635

Browse files
authored
Merge branch 'master' into master
2 parents 7252d61 + e1a31e2 commit 93e4635

File tree

11 files changed

+113
-17
lines changed

11 files changed

+113
-17
lines changed

docs/integration.md

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,54 @@ Check `vendor/unisharp/laravel-filemanager/src/views/demo.blade.php`, which alre
3434
$('textarea.my-editor').ckeditor(options);
3535
</script>
3636
```
37+
38+
### Option 2: TinyMCE5
3739

38-
### Option 2: TinyMCE4
40+
```html
41+
<script src="/path-to-your-tinymce/tinymce.min.js"></script>
42+
<textarea name="content" class="form-control my-editor">{!! old('content', $content) !!}</textarea>
43+
<script>
44+
var editor_config = {
45+
path_absolute : "/",
46+
selector: 'textarea.my-editor',
47+
relative_urls: false,
48+
plugins: [
49+
"advlist autolink lists link image charmap print preview hr anchor pagebreak",
50+
"searchreplace wordcount visualblocks visualchars code fullscreen",
51+
"insertdatetime media nonbreaking save table directionality",
52+
"emoticons template paste textpattern"
53+
],
54+
toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image media",
55+
file_picker_callback : function(callback, value, meta) {
56+
var x = window.innerWidth || document.documentElement.clientWidth || document.getElementsByTagName('body')[0].clientWidth;
57+
var y = window.innerHeight|| document.documentElement.clientHeight|| document.getElementsByTagName('body')[0].clientHeight;
58+
59+
var cmsURL = editor_config.path_absolute + 'laravel-filemanager?editor=' + meta.fieldname;
60+
if (meta.filetype == 'image') {
61+
cmsURL = cmsURL + "&type=Images";
62+
} else {
63+
cmsURL = cmsURL + "&type=Files";
64+
}
65+
66+
tinyMCE.activeEditor.windowManager.openUrl({
67+
url : cmsURL,
68+
title : 'Filemanager',
69+
width : x * 0.8,
70+
height : y * 0.8,
71+
resizable : "yes",
72+
close_previous : "no",
73+
onMessage: (api, message) => {
74+
callback(message.content);
75+
}
76+
});
77+
}
78+
};
79+
80+
tinymce.init(editor_config);
81+
</script>
82+
```
83+
84+
### Option 3: TinyMCE4
3985

4086
```html
4187
<script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
@@ -78,7 +124,7 @@ Check `vendor/unisharp/laravel-filemanager/src/views/demo.blade.php`, which alre
78124
</script>
79125
```
80126

81-
### Option 3: Summernote
127+
### Option 4: Summernote
82128

83129
```html
84130
<!-- dependencies (Summernote depends on Bootstrap & jQuery) -->

public/js/filemanager.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Open file manager and return selected files.
3+
* Promise is never resolved if window is closed.
4+
*
5+
* @returns Promise<array> Array of selected files with properties:
6+
* icon string
7+
* is_file bool
8+
* is_image bool
9+
* name string
10+
* thumb_url string|null
11+
* time int
12+
* url string
13+
*/
14+
window.filemanager = function filemanager() {
15+
var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '/filemanager';
16+
var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'FileManager';
17+
var features = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'width=900,height=600';
18+
return new Promise(function (resolve) {
19+
window.open(url, target, features);
20+
window.SetUrl = resolve;
21+
});
22+
};

public/js/filemanager.min.js

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

src/Controllers/LfmController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ public function error($error_type, $variables = [])
8383
*/
8484
public function applyIniOverrides()
8585
{
86-
$overrides = config('lfm.php_ini_overrides');
86+
$overrides = config('lfm.php_ini_overrides', []);
87+
8788
if ($overrides && is_array($overrides) && count($overrides) === 0) {
8889
return;
8990
}

src/LaravelFilemanagerServiceProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public function boot()
5151
*/
5252
public function register()
5353
{
54+
$this->mergeConfigFrom(__DIR__ . '/config/lfm.php', 'lfm-config');
55+
5456
$this->app->singleton('laravel-filemanager', function () {
5557
return true;
5658
});

src/LfmItem.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,7 @@ public function size()
108108

109109
public function time()
110110
{
111-
if (!$this->isDirectory()) {
112-
return $this->lfm->lastModified();
113-
}
114-
115-
return false;
111+
return $this->lfm->lastModified();
116112
}
117113

118114
public function thumbUrl()

src/LfmPath.php

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,19 +273,37 @@ private function getNewName($file)
273273
$new_file_name = $this->helper
274274
->translateFromUtf8(trim(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME)));
275275

276+
$extension = $file->getClientOriginalExtension();
277+
276278
if (config('lfm.rename_file') === true) {
277279
$new_file_name = uniqid();
278280
} elseif (config('lfm.alphanumeric_filename') === true) {
279281
$new_file_name = preg_replace('/[^A-Za-z0-9\-\']/', '_', $new_file_name);
280282
}
281283

282-
$extension = $file->getClientOriginalExtension();
283-
284284
if ($extension) {
285-
$new_file_name .= '.' . $extension;
285+
$new_file_name_with_extention = $new_file_name . '.' . $extension;
286286
}
287287

288-
return $new_file_name;
288+
if (config('lfm.rename_duplicates') === true) {
289+
$counter = 1;
290+
$file_name_without_extentions = $new_file_name;
291+
while ($this->setName(($extension) ? $new_file_name_with_extention : $new_file_name)->exists()) {
292+
if (config('lfm.alphanumeric_filename') === true) {
293+
$suffix = '_'.$counter;
294+
} else {
295+
$suffix = " ({$counter})";
296+
}
297+
$new_file_name = $file_name_without_extentions.$suffix;
298+
299+
if ($extension) {
300+
$new_file_name_with_extention = $new_file_name . '.' . $extension;
301+
}
302+
$counter++;
303+
}
304+
}
305+
306+
return ($extension) ? $new_file_name_with_extention : $new_file_name;
289307
}
290308

291309
private function saveFile($file, $new_file_name)

src/LfmStorageRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function save($file)
4545
$nameint = strripos($this->path, "/");
4646
$nameclean = substr($this->path, $nameint + 1);
4747
$pathclean = substr_replace($this->path, "", $nameint);
48-
$this->disk->putFileAs($pathclean, $file, $nameclean, 'public');
48+
$this->disk->putFileAs($pathclean, $file, $nameclean);
4949
}
5050

5151
public function url($path)

src/config/lfm.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,28 +48,28 @@
4848
'folder_categories' => [
4949
'file' => [
5050
'folder_name' => 'files',
51-
'startup_view' => 'grid',
51+
'startup_view' => 'list',
5252
'max_size' => 50000, // size in KB
5353
'valid_mime' => [
5454
'image/jpeg',
5555
'image/pjpeg',
5656
'image/png',
5757
'image/gif',
5858
'image/svg+xml',
59+
'application/pdf',
60+
'text/plain',
5961
],
6062
],
6163
'image' => [
6264
'folder_name' => 'photos',
63-
'startup_view' => 'list',
65+
'startup_view' => 'grid',
6466
'max_size' => 50000, // size in KB
6567
'valid_mime' => [
6668
'image/jpeg',
6769
'image/pjpeg',
6870
'image/png',
6971
'image/gif',
7072
'image/svg+xml',
71-
'application/pdf',
72-
'text/plain',
7373
],
7474
],
7575
],
@@ -94,6 +94,8 @@
9494

9595
'rename_file' => false,
9696

97+
'rename_duplicates' => false,
98+
9799
'alphanumeric_filename' => false,
98100

99101
'alphanumeric_directory' => false,

src/lang/hu/lfm.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@
6262
'btn-copy-crop' => 'Másolás és vágás',
6363
'btn-cancel' => 'Mégse',
6464
'btn-resize' => 'Átméretezés',
65+
'btn-confirm' => 'Ok',
66+
'btn-crop-free' => 'Szabad arány',
6567

6668
'resize-ratio' => 'Arány:',
6769
'resize-scaled' => 'Kép méretarány:',

0 commit comments

Comments
 (0)