Skip to content

Commit aff715c

Browse files
committed
add independent use init function, update readme
1 parent c831ef6 commit aff715c

File tree

6 files changed

+104
-34
lines changed

6 files changed

+104
-34
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[![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) [![Latest Unstable Version](https://poser.pugx.org/unisharp/laravel-filemanager/v/unstable)](https://packagist.org/packages/unisharp/laravel-filemanager) [![License](https://poser.pugx.org/unisharp/laravel-filemanager/license)](https://packagist.org/packages/unisharp/laravel-filemanager)
22

3-
# laravel-filemanager
3+
# Laravel Filemanager
44

55
A files and images management user interface with file uploading support. (Works well with CKEditor and TinyMCE)
66

@@ -9,9 +9,11 @@ PR is welcome!
99
## Overview
1010

1111
* The project was forked from [tsawler/laravel-filemanager](http://packalyst.com/packages/package/tsawler/laravel-filemanager)
12-
* Support public and private folders for multi users
13-
* Customizable views, routes and middlewares
12+
* Customizable routes and middlewares
1413
* Supported locales : en, fr, pt-BR, tr, zh-CN, zh-TW
14+
* Supports public and private folders for multi users
15+
* Supports multi-level folders
16+
* Supports using independently(see integration doc)
1517

1618
## Documents
1719

@@ -28,8 +30,10 @@ PR is welcome!
2830
* All contibutors from GitHub. (issues / PR)
2931
* Special thanks to
3032
* [@taswler](https://github.com/tsawler) the original author.
33+
* [@olivervogel](https://github.com/olivervogel) for the awesome [image library](https://github.com/Intervention/image)
3134
* [@welcoMattic](https://github.com/welcoMattic) providing fr translations and lots of bugfixes.
3235
* [@fraterblack](https://github.com/fraterblack) TinyMCE 4 support and pt-BR translations.
3336
* [@1dot44mb](https://github.com/1dot44mb) tr translations.
34-
* [@olivervogel](https://github.com/olivervogel) for the awesome [image library](https://github.com/Intervention/image)
37+
* [@Nikita240](https://github.com/Nikita240) fixing controller extending errors.
38+
* [@amin101](https://github.com/amin101) guide for independent use and fixes for url/directory error on Windows
3539
* [All @UniSharp members](https://github.com/UniSharp)

doc/config.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## Documents
2+
3+
1. [Installation](https://github.com/UniSharp/laravel-filemanager/blob/master/doc/installation.md)
4+
1. [Intergration](https://github.com/UniSharp/laravel-filemanager/blob/master/doc/integration.md)
5+
1. [Config](https://github.com/UniSharp/laravel-filemanager/blob/master/doc/config.md)
6+
1. [Customization](https://github.com/UniSharp/laravel-filemanager/blob/master/doc/customization.md)
7+
18
## Config
29

310
In `config/lfm.php` :

doc/customization.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1+
## Documents
2+
3+
1. [Installation](https://github.com/UniSharp/laravel-filemanager/blob/master/doc/installation.md)
4+
1. [Intergration](https://github.com/UniSharp/laravel-filemanager/blob/master/doc/integration.md)
5+
1. [Config](https://github.com/UniSharp/laravel-filemanager/blob/master/doc/config.md)
6+
1. [Customization](https://github.com/UniSharp/laravel-filemanager/blob/master/doc/customization.md)
7+
18
## Customization
29

3-
1. If the route is changed, make sure urls below is correspond to your route :
10+
Feel free to customize the routes and views if your need.
11+
12+
### Routes
13+
14+
1. Copy the routes in src/routes.php
15+
16+
1. Make sure urls below is correspond to your route :
417

518
CKEditor
619
```javascript
@@ -25,8 +38,10 @@
2538
}
2639
...
2740
```
28-
29-
1. To customize the views :
41+
42+
### Views
43+
44+
1. Copy the views form src/views/ :
3045

3146
on Linux :
3247

doc/installation.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## Documents
2+
3+
1. [Installation](https://github.com/UniSharp/laravel-filemanager/blob/master/doc/installation.md)
4+
1. [Intergration](https://github.com/UniSharp/laravel-filemanager/blob/master/doc/integration.md)
5+
1. [Config](https://github.com/UniSharp/laravel-filemanager/blob/master/doc/config.md)
6+
1. [Customization](https://github.com/UniSharp/laravel-filemanager/blob/master/doc/customization.md)
7+
18
## Requirements
29

310
* php >= 5.5

doc/integration.md

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## Documents
2+
3+
1. [Installation](https://github.com/UniSharp/laravel-filemanager/blob/master/doc/installation.md)
4+
1. [Intergration](https://github.com/UniSharp/laravel-filemanager/blob/master/doc/integration.md)
5+
1. [Config](https://github.com/UniSharp/laravel-filemanager/blob/master/doc/config.md)
6+
1. [Customization](https://github.com/UniSharp/laravel-filemanager/blob/master/doc/customization.md)
7+
18
## WYSIWYG Editor Integration:
29
### Option 1: CKEditor
310

@@ -80,34 +87,31 @@
8087

8188
##Independent use
8289

83-
If you are going to use filemanager independently,meaning set the value of an input to selected photo/file url,follow this structure:
84-
85-
1. create a popup window or modal(whatever you like):
86-
87-
```html
88-
<a href="/laravel-filemanager" id="feature-img-container"><img src="no_photo.jpg"></a>
89-
<input name="thumbnail" type="hidden" id="thumbnail">
90-
```
91-
92-
```javascript
93-
$('#feature-img-container').on('click', function(e)
94-
{
95-
96-
window.open(this.href, 'Filemanager', 'width=900,height=600');
90+
If you are going to use filemanager independently, meaning set the value of an input to selected photo/file url, follow this structure:
9791

98-
return false;
99-
});
100-
```
92+
1. Create a button, input, and image preview holder if you are going to choose images.
10193

102-
2. define a function named `SetUrl`:
94+
Specify the id to the input and image preview by `data-input` and `data-preview`.
10395

104-
```javascript
105-
function SetUrl(url){
96+
```html
97+
<div class="input-group">
98+
<span class="input-group-btn">
99+
<a id="lfm" data-input="thumbnail" data-preview="holder" class="btn btn-primary">
100+
<i class="fa fa-picture-o"> Choose
101+
</a>
102+
</span>
103+
<input id="thumbnail" class="form-control" type="text" name="filepath">
104+
</div>
105+
<img id="holder" style="margin-top:15px;max-height:100px;">
106+
```
107+
108+
1. Init filemanager with type. (required jQuery)
109+
110+
```javascript
111+
$('#lfm').filemanager('image');
112+
```
113+
or
106114

107-
//set the value of the desired input to image url,often this is a hidden input
108-
$('#thumbnail').val(url);
109-
110-
//set or change the feature image src,recall wordpress feature image
111-
$('#feature-img-container').find('img').attr('src',url);
112-
}
113-
```
115+
```javascript
116+
$('#lfm').filemanager('file');
117+
```

public/js/lfm.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
(function( $ ){
2+
3+
$.fn.filemanager = function(type = 'image') {
4+
5+
if (type === 'image' || type === 'images') {
6+
type = 'Images';
7+
} else {
8+
type = 'Files';
9+
}
10+
11+
let input_id = this.data('input');
12+
let preview_id = this.data('preview');
13+
14+
this.on('click', function(e) {
15+
localStorage.setItem('target_input', input_id);
16+
localStorage.setItem('target_preview', preview_id);
17+
window.open('/laravel-filemanager?type=' + type, 'FileManager', 'width=900,height=600');
18+
return false;
19+
});
20+
}
21+
22+
})(jQuery);
23+
24+
25+
function SetUrl(url){
26+
//set the value of the desired input to image url
27+
let target_input = $('#' + localStorage.getItem('target_input'));
28+
target_input.val(url);
29+
30+
//set or change the preview image src
31+
let target_preview = $('#' + localStorage.getItem('target_preview'));
32+
target_preview.attr('src',url);
33+
}

0 commit comments

Comments
 (0)