Skip to content

Commit c68b4fc

Browse files
committed
Merge pull request #23 from fraterblack/master
Implemented TinyMCE support and pt-BR translation. Thanks @fraterblack
2 parents fc396b0 + c98a0e4 commit c68b4fc

File tree

3 files changed

+173
-8
lines changed

3 files changed

+173
-8
lines changed

README.md

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ PR is welcome.
77
* The project was forked from [tsawler/laravel-filemanager](http://packalyst.com/packages/package/tsawler/laravel-filemanager)
88
* Support public and private folders for multi users
99
* Customizable views, routes and middlewares
10-
* Supported locales : en, fr, zh-TW, zh-CN
10+
* Supported locales : en, fr, zh-TW, zh-CN, pt-BR
1111

1212
## Requirements
1313

@@ -45,8 +45,8 @@ PR is welcome.
4545
php artisan vendor:publish --tag=lfm_public
4646
```
4747
48-
1. Initiate ckeditor with options :
49-
48+
1. Implementation:
49+
CKEditor
5050
```javascript
5151
<script>
5252
CKEDITOR.replace( 'editor', {
@@ -58,6 +58,49 @@ PR is welcome.
5858
</script>
5959
```
6060
61+
TinyMCE 4
62+
```javascript
63+
<script>
64+
var editor_config = {
65+
path_absolute : "http://path_to_filemanager/",
66+
selector: "textarea",
67+
plugins: [
68+
"advlist autolink lists link image charmap print preview hr anchor pagebreak",
69+
"searchreplace wordcount visualblocks visualchars code fullscreen",
70+
"insertdatetime media nonbreaking save table contextmenu directionality",
71+
"emoticons template paste textcolor colorpicker textpattern"
72+
],
73+
toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image media",
74+
relative_urls: false,
75+
file_browser_callback : function(field_name, url, type, win) {
76+
var w = window,
77+
d = document,
78+
e = d.documentElement,
79+
g = d.getElementsByTagName('body')[0],
80+
x = w.innerWidth || e.clientWidth || g.clientWidth,
81+
y = w.innerHeight|| e.clientHeight|| g.clientHeight;
82+
83+
var cmsURL = editor_config.path_absolute + 'filemanager/show?&field_name='+field_name+'&lang='+ tinymce.settings.language;
84+
85+
if(type == 'image') {
86+
cmsURL = cmsURL + "&type=images";
87+
}
88+
89+
tinyMCE.activeEditor.windowManager.open({
90+
file : cmsURL,
91+
title : 'Filemanager',
92+
width : x * 0.8,
93+
height : y * 0.8,
94+
resizable : "yes",
95+
close_previous : "no"
96+
});
97+
}
98+
};
99+
100+
tinymce.init(editor_config);
101+
</script>
102+
```
103+
61104
1. Ensure that the files & images directories(in `config/lfm.php`) are writable by your web server
62105
63106
## Config
@@ -111,6 +154,13 @@ In `config/lfm.php` :
111154
```
112155

113156
And be sure to include the `?type=Images` or `?type=Files` parameter.
157+
158+
TinyMCE
159+
```javascript
160+
...
161+
var cmsURL = editor_config.path_absolute + 'your-custom-route/show?&field_name='+field_name+'&lang='+ tinymce.settings.language;
162+
...
163+
```
114164

115165
1. To customize the views :
116166

src/lang/pt-BR/lfm.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
return [
4+
'nav-upload' => 'Enviar',
5+
'nav-thumbnails' => 'Miniatura',
6+
'nav-list' => 'Lista',
7+
8+
'menu-new' => 'Nova Pasta',
9+
'menu-rename' => 'Renomear',
10+
'menu-delete' => 'Deletar',
11+
'menu-view' => 'Ver',
12+
'menu-download' => 'Download',
13+
'menu-resize' => 'Redimensionar',
14+
'menu-crop' => 'Cortar',
15+
16+
'title-page' => 'Gerenciador de Arquivos',
17+
'title-panel' => 'Gerenciador de Arquivos',
18+
'title-upload' => 'Envio de Arquivo',
19+
'title-view' => 'Ver Arquivo',
20+
'title-root' => 'Arquivos',
21+
'title-shares' => 'Arquivos Compartilhados',
22+
'title-item' => 'Item',
23+
'title-size' => 'Tamanho',
24+
'title-type' => 'Tipo',
25+
'title-modified' => 'Modificado',
26+
'title-action' => 'Ação',
27+
28+
'type-folder' => 'Pasta',
29+
30+
'message-empty' => 'A pasta está vazia.',
31+
'message-choose' => 'Escolha um arquivo',
32+
'message-delete' => 'Você está certo que quer deletar este arquivo?',
33+
'message-name' => 'Nome da pasta:',
34+
'message-rename' => 'Renomear para:',
35+
36+
'error-rename' => 'Nome de arquivo já está em uso!',
37+
'error-file-empty' => 'Você deve escolher um arquivo!',
38+
'error-file-exist' => 'Um arquivo com este nome já existe!',
39+
'error-delete' => 'Você não pode deletar esta pasta, pois ela não está vazia!',
40+
'error-folder-name' => 'Nome da pasta não pode ser vazio!',
41+
'error-folder-exist'=> 'Uma pasta com este nome já existe!',
42+
43+
'btn-upload' => 'Enviar Arquivo',
44+
'btn-close' => 'Fechar',
45+
'btn-uploading' => 'Enviando...',
46+
'btn-crop' => 'Cortar',
47+
'btn-cancel' => 'Cancelar',
48+
'btn-resize' => 'Redimensionar',
49+
50+
'resize-ratio' => 'Proporção:',
51+
'resize-scaled' => 'Imagem dimensionada:',
52+
'resize-true' => 'Sim',
53+
'resize-old-height' => 'Altura Original:',
54+
'resize-old-width' => 'Largura Original:',
55+
'resize-new-height' => 'Altura:',
56+
'resize-new-width' => 'Largura:',
57+
58+
'locale-bootbox' => 'pt_BR',
59+
];

src/views/index.blade.php

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ function useFile(file) {
364364
var item_url = image_url;
365365
366366
@if ((Session::has('lfm_type')) && (Session::get('lfm_type') != "Images"))
367-
item_url = file_url;
367+
item_url = file_url;
368368
@endif
369369
370370
if (path != '/') {
@@ -377,11 +377,67 @@ function getUrlParam(paramName) {
377377
return ( match && match.length > 1 ) ? match[1] : null;
378378
}
379379
380-
var funcNum = getUrlParam('CKEditorFuncNum');
381-
382-
window.opener.CKEDITOR.tools.callFunction(funcNum, path + '/' + file);
380+
var field_name = getUrlParam('field_name');
381+
var url = item_url + file;
382+
383+
if(window.opener || window.tinyMCEPopup || field_name || getUrlParam('CKEditorCleanUpFuncNum') || getUrlParam('CKEditor')) {
384+
if(window.tinyMCEPopup){
385+
// use TinyMCE > 3.0 integration method
386+
var win = tinyMCEPopup.getWindowArg("window");
387+
win.document.getElementById(tinyMCEPopup.getWindowArg("input")).value = url;
388+
if (typeof(win.ImageDialog) != "undefined") {
389+
// Update image dimensions
390+
if (win.ImageDialog.getImageData)
391+
win.ImageDialog.getImageData();
392+
393+
// Preview if necessary
394+
if (win.ImageDialog.showPreviewImage)
395+
win.ImageDialog.showPreviewImage(url);
396+
}
397+
tinyMCEPopup.close();
398+
return;
399+
}
400+
401+
// tinymce 4 and colorbox
402+
if (field_name) {
403+
parent.document.getElementById(field_name).value = url;
404+
405+
if(typeof parent.tinyMCE !== "undefined") {
406+
parent.tinyMCE.activeEditor.windowManager.close();
407+
}
408+
if(typeof parent.$.fn.colorbox !== "undefined") {
409+
parent.$.fn.colorbox.close();
410+
}
411+
412+
} else if(getUrlParam('CKEditor')) {
413+
// use CKEditor 3.0 + integration method
414+
if (window.opener) {
415+
// Popup
416+
window.opener.CKEDITOR.tools.callFunction(getUrlParam('CKEditorFuncNum'), url);
417+
} else {
418+
// Modal (in iframe)
419+
parent.CKEDITOR.tools.callFunction(getUrlParam('CKEditorFuncNum'), url);
420+
parent.CKEDITOR.tools.callFunction(getUrlParam('CKEditorCleanUpFuncNum'));
421+
}
422+
} else {
383423
384-
window.opener.CKEDITOR.tools.callFunction(funcNum, item_url + file);
424+
// use FCKEditor 2.0 integration method
425+
if (data['Properties']['Width'] != '') {
426+
var p = url;
427+
var w = data['Properties']['Width'];
428+
var h = data['Properties']['Height'];
429+
window.opener.SetUrl(p,w,h);
430+
} else {
431+
window.opener.SetUrl(url);
432+
}
433+
}
434+
435+
if (window.opener) {
436+
window.close();
437+
}
438+
} else {
439+
$.prompt(lg.fck_select_integration);
440+
}
385441
386442
window.close();
387443
}

0 commit comments

Comments
 (0)