FileManager
This commit is contained in:
parent
c8948338bb
commit
f1e0900a7a
131 changed files with 5844 additions and 3081 deletions
|
|
@ -23,11 +23,11 @@
|
|||
"ext-exif": "*",
|
||||
"ext-fileinfo": "*",
|
||||
"intervention/image": "2.*",
|
||||
"illuminate/config": "5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.*",
|
||||
"illuminate/filesystem": "5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.*",
|
||||
"illuminate/support": "5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.*",
|
||||
"illuminate/http": "5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.*",
|
||||
"illuminate/container": "5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.*",
|
||||
"illuminate/config": "5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0",
|
||||
"illuminate/filesystem": "5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0",
|
||||
"illuminate/support": "5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0",
|
||||
"illuminate/http": "5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0",
|
||||
"illuminate/container": "5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0",
|
||||
"cviebrock/eloquent-sluggable": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
|
|
|
|||
|
|
@ -55,6 +55,8 @@ class FileController extends LfmController
|
|||
$content_id = $this->helper->input('content_id');
|
||||
$content_title = $this->helper->input('content_title');
|
||||
$content_description = $this->helper->input('content_description');
|
||||
$content_author = $this->helper->input('content_author');
|
||||
|
||||
|
||||
$file = $this->lfm->pretty($file_name);
|
||||
|
||||
|
|
@ -63,6 +65,7 @@ class FileController extends LfmController
|
|||
'id' => $content_id,
|
||||
'title' => $content_title,
|
||||
'description' => $content_description,
|
||||
'author' => $content_author,
|
||||
];
|
||||
|
||||
if($content_id && $content_id != ""){
|
||||
|
|
|
|||
|
|
@ -44,15 +44,27 @@ class UploadController extends LfmController
|
|||
|
||||
if (is_array($uploaded_files)) {
|
||||
$response = count($error_bag) > 0 ? $error_bag : parent::$success_response;
|
||||
} else { // upload via ckeditor 'Upload' tab
|
||||
} else { // upload via ckeditor5 expects json responses
|
||||
if (is_null($new_filename)) {
|
||||
$response = $error_bag[0];
|
||||
$response = ['error' =>
|
||||
[
|
||||
'message' => $error_bag[0]
|
||||
]
|
||||
];
|
||||
} else {
|
||||
$response = view(Lfm::PACKAGE_NAME . '::use')
|
||||
|
||||
/*$response = view(Lfm::PACKAGE_NAME . '::use')
|
||||
->withFile($this->lfm->setName($new_filename)->url());
|
||||
*/
|
||||
$url = $this->lfm->setName($new_filename)->url();
|
||||
|
||||
$response = [
|
||||
'url' => $url
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $response;
|
||||
return response()->json($response);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace IqContent\LaravelFilemanager;
|
||||
|
||||
use App\Models\CMSAuthor;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
|
||||
class LfmItem
|
||||
|
|
@ -9,7 +10,7 @@ class LfmItem
|
|||
private $lfm;
|
||||
private $helper;
|
||||
|
||||
private $columns = ['name', 'url', 'time', 'icon', 'color', 'is_file', 'is_image', 'thumb_url', 'size', 'dimension', 'content'];
|
||||
private $columns = ['name', 'url', 'time', 'icon', 'color', 'is_file', 'is_image', 'thumb_url', 'size', 'dimension', 'content', 'identifier'];
|
||||
public $attributes = [];
|
||||
|
||||
public function __construct(LfmPath $lfm, Lfm $helper)
|
||||
|
|
@ -119,11 +120,28 @@ class LfmItem
|
|||
public function content()
|
||||
{
|
||||
if($this->model()){
|
||||
return $this->model()->content;
|
||||
$content = $this->model()->content;
|
||||
|
||||
if(isset($content['author'])){
|
||||
$author = CMSAuthor::find($content['author']);
|
||||
if($author){
|
||||
$content['author_name'] = $author->name;
|
||||
}
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
public function identifier()
|
||||
{
|
||||
if($this->model()){
|
||||
return $this->model()->identifier;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function sizeRow()
|
||||
{
|
||||
return $this->isFile() ? $this->lfm->size() : '';
|
||||
|
|
|
|||
|
|
@ -313,11 +313,13 @@ class LfmPath
|
|||
// Upload section
|
||||
public function upload($file)
|
||||
{
|
||||
$this->uploadValidator($file);
|
||||
$error = $this->uploadValidator($file);
|
||||
if($error !== 'pass'){
|
||||
return false;
|
||||
}
|
||||
$new_file_name = $this->getNewName($file);
|
||||
$new_file_path = $this->setName($new_file_name)->path('absolute');
|
||||
|
||||
|
||||
$working_folder_id = $this->getModelParentFolderId();
|
||||
|
||||
//event(new ImageIsUploading($new_file_path));
|
||||
|
|
@ -339,7 +341,6 @@ class LfmPath
|
|||
]);
|
||||
// TODO should be "FileWasUploaded"
|
||||
// event(new ImageWasUploaded($new_file_path));
|
||||
|
||||
return $new_file_name;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,8 +54,8 @@
|
|||
options = {};
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
$("#notify").on("shown.bs.modal", function() {
|
||||
$("#notify").find('.modal-footer button.btn-primary').hide();
|
||||
var $dataX = $('#dataX'),
|
||||
$dataY = $('#dataY'),
|
||||
$dataHeight = $('#dataHeight'),
|
||||
|
|
@ -67,8 +67,7 @@
|
|||
preview: ".img-preview",
|
||||
strict: false,
|
||||
crop: function (data) {
|
||||
console.log(data);
|
||||
|
||||
// console.log(data);
|
||||
// Output the result data for cropping image.
|
||||
$dataX.val(Math.round(data.x));
|
||||
$dataY.val(Math.round(data.y));
|
||||
|
|
@ -78,14 +77,20 @@
|
|||
};
|
||||
$image.cropper(options);
|
||||
});
|
||||
|
||||
$("#notify").on("hidden.bs.modal", function() {
|
||||
$("#notify").find('.modal-footer button.btn-primary').show();
|
||||
$image.cropper('destroy');
|
||||
$("#notify").off("shown.bs.modal");
|
||||
$("#notify").off("hidden.bs.modal");
|
||||
});
|
||||
});
|
||||
|
||||
function closeAndLoadItems() {
|
||||
|
||||
$image = $('.crop-container > img');
|
||||
$image.cropper('destroy');
|
||||
$('#notify').modal('hide').find('.modal-body').html("");
|
||||
loadItems();
|
||||
LFileManager.loadItems();
|
||||
}
|
||||
function changeAspectRatio(_this, aspectRatio) {
|
||||
options.aspectRatio = aspectRatio;
|
||||
|
|
@ -96,7 +101,7 @@
|
|||
return false;
|
||||
}
|
||||
function performCrop() {
|
||||
performLfmRequest('cropimage', {
|
||||
LFileManager.performLfmRequest('cropimage', {
|
||||
img: $("#img").val(),
|
||||
working_dir: $("#working_dir").val(),
|
||||
dataX: $("#dataX").val(),
|
||||
|
|
@ -108,7 +113,7 @@
|
|||
}
|
||||
|
||||
function performCropNew() {
|
||||
performLfmRequest('cropnewimage', {
|
||||
LFileManager.performLfmRequest('cropnewimage', {
|
||||
img: $("#img").val(),
|
||||
working_dir: $("#working_dir").val(),
|
||||
dataX: $("#dataX").val(),
|
||||
|
|
|
|||
|
|
@ -205,43 +205,43 @@
|
|||
{
|
||||
name: 'rename',
|
||||
icon: 'edit',
|
||||
label: lang['menu-rename'],
|
||||
label: lfm_lang['menu-rename'],
|
||||
multiple: false
|
||||
},
|
||||
{
|
||||
name: 'download',
|
||||
icon: 'download',
|
||||
label: lang['menu-download'],
|
||||
label: lfm_lang['menu-download'],
|
||||
multiple: true
|
||||
},
|
||||
// {
|
||||
// name: 'preview',
|
||||
// icon: 'image',
|
||||
// label: lang['menu-view'],
|
||||
// label: lfm_lang['menu-view'],
|
||||
// multiple: true
|
||||
// },
|
||||
{
|
||||
name: 'move',
|
||||
icon: 'paste',
|
||||
label: lang['menu-move'],
|
||||
label: lfm_lang['menu-move'],
|
||||
multiple: true
|
||||
},
|
||||
{
|
||||
name: 'resize',
|
||||
icon: 'arrows-alt',
|
||||
label: lang['menu-resize'],
|
||||
label: lfm_lang['menu-resize'],
|
||||
multiple: false
|
||||
},
|
||||
{
|
||||
name: 'crop',
|
||||
icon: 'crop',
|
||||
label: lang['menu-crop'],
|
||||
label: lfm_lang['menu-crop'],
|
||||
multiple: false
|
||||
},
|
||||
{
|
||||
name: 'trash',
|
||||
icon: 'trash',
|
||||
label: lang['menu-delete'],
|
||||
label: lfm_lang['menu-delete'],
|
||||
multiple: true
|
||||
},
|
||||
];
|
||||
|
|
@ -250,12 +250,12 @@
|
|||
{
|
||||
by: 'alphabetic',
|
||||
icon: 'sort-alpha-down',
|
||||
label: lang['nav-sort-alphabetic']
|
||||
label: lfm_lang['nav-sort-alphabetic']
|
||||
},
|
||||
{
|
||||
by: 'time',
|
||||
icon: 'sort-numeric-down',
|
||||
label: lang['nav-sort-time']
|
||||
label: lfm_lang['nav-sort-time']
|
||||
}
|
||||
];
|
||||
</script>
|
||||
|
|
@ -268,7 +268,7 @@
|
|||
uploadMultiple: false,
|
||||
parallelUploads: 5,
|
||||
clickable: '#upload-button',
|
||||
dictDefaultMessage: lang['message-drop'],
|
||||
dictDefaultMessage: lfm_lang['message-drop'],
|
||||
init: function() {
|
||||
var _this = this; // For the closure
|
||||
this.on('success', function(file, response) {
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@
|
|||
$("#notify").modal('hide');
|
||||
var items =[];
|
||||
$("#items").find("input").each(function() {items.push(this.id)});
|
||||
performLfmRequest('domove', {
|
||||
LFileManager.performLfmRequest('domove', {
|
||||
items: items,
|
||||
goToFolder: $folder
|
||||
}).done(refreshFoldersAndItems);
|
||||
}).done(LFileManager.refreshFoldersAndItems);
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -116,10 +116,10 @@
|
|||
}
|
||||
|
||||
function doResize() {
|
||||
performLfmRequest('doresize', {
|
||||
LFileManager.performLfmRequest('doresize', {
|
||||
img: $("#img").val(),
|
||||
dataHeight: $("#height").val(),
|
||||
dataWidth: $("#width").val()
|
||||
}).done(loadItems);
|
||||
}).done(LFileManager.loadItems);
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue