Skip to content

Commit 1d986ee

Browse files
committed
first commit
0 parents  commit 1d986ee

16 files changed

+861
-0
lines changed

.styleci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
preset: laravel

changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changelog
2+
3+
All notable changes to `FileManager` will be documented in this file.
4+
5+
## Version 1.0.0 - 2020-03-21
6+
7+
### Added
8+
- Everything

composer.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "backpack/filemanager",
3+
"description": "Backpack admin interface for files and folder, using elFinder",
4+
"license": "MIT",
5+
"authors": [
6+
{
7+
"name": "Cristian Tabacitu",
8+
"email": "[email protected]",
9+
"homepage": "https://backpackforlaravel.com"
10+
}
11+
],
12+
"homepage": "https://github.com/laravel-backpack/filemanager",
13+
"keywords": ["Laravel", "FileManager"],
14+
"require": {
15+
"backpack/crud": "^4.0.0|^4.1.0",
16+
"barryvdh/laravel-elfinder": "^0.4.5"
17+
},
18+
"require-dev": {
19+
"phpunit/phpunit": "^8.0",
20+
"mockery/mockery": "^1.1",
21+
"orchestra/testbench": "~3|~4",
22+
"sempro/phpunit-pretty-print": "^1.0"
23+
},
24+
"autoload": {
25+
"psr-4": {
26+
"Backpack\\FileManager\\": "src/"
27+
}
28+
},
29+
"autoload-dev": {
30+
"psr-4": {
31+
"Backpack\\FileManager\\Tests\\": "tests"
32+
}
33+
},
34+
"extra": {
35+
"laravel": {
36+
"providers": [
37+
"Backpack\\FileManager\\FileManagerServiceProvider"
38+
]
39+
}
40+
}
41+
}

config/elfinder.php

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?php
2+
3+
return [
4+
5+
/*
6+
|--------------------------------------------------------------------------
7+
| Upload dir
8+
|--------------------------------------------------------------------------
9+
|
10+
| The dir where to store the images (relative from public).
11+
|
12+
*/
13+
'dir' => ['uploads'],
14+
15+
/*
16+
|--------------------------------------------------------------------------
17+
| Filesystem disks (Flysytem)
18+
|--------------------------------------------------------------------------
19+
|
20+
| Define an array of Filesystem disks, which use Flysystem.
21+
| You can set extra options, example:
22+
|
23+
| 'my-disk' => [
24+
| 'URL' => url('to/disk'),
25+
| 'alias' => 'Local storage',
26+
| ]
27+
*/
28+
'disks' => [
29+
// 'uploads',
30+
],
31+
32+
/*
33+
|--------------------------------------------------------------------------
34+
| Routes group config
35+
|--------------------------------------------------------------------------
36+
|
37+
| The default group settings for the elFinder routes.
38+
|
39+
*/
40+
41+
'route' => [
42+
'prefix' => config('backpack.base.route_prefix', 'admin').'/elfinder',
43+
'middleware' => ['web', config('backpack.base.middleware_key', 'admin')], //Set to null to disable middleware filter
44+
],
45+
46+
/*
47+
|--------------------------------------------------------------------------
48+
| Access filter
49+
|--------------------------------------------------------------------------
50+
|
51+
| Filter callback to check the files
52+
|
53+
*/
54+
55+
'access' => 'Barryvdh\Elfinder\Elfinder::checkAccess',
56+
57+
/*
58+
|--------------------------------------------------------------------------
59+
| Roots
60+
|--------------------------------------------------------------------------
61+
|
62+
| By default, the roots file is LocalFileSystem, with the above public dir.
63+
| If you want custom options, you can set your own roots below.
64+
|
65+
*/
66+
67+
'roots' => null,
68+
69+
/*
70+
|--------------------------------------------------------------------------
71+
| Options
72+
|--------------------------------------------------------------------------
73+
|
74+
| These options are merged, together with 'roots' and passed to the Connector.
75+
| See https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options-2.1
76+
|
77+
*/
78+
79+
'options' => [],
80+
81+
];

contributing.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Contributing
2+
3+
Contributions are welcome and will be fully credited.
4+
5+
Contributions are accepted via Pull Requests on [Github](https://github.com/backpack/filemanager).
6+
7+
# Things you could do
8+
If you want to contribute but do not know where to start, this list provides some starting points.
9+
- Add license text
10+
- Remove rewriteRules.php
11+
- Set up TravisCI, StyleCI, ScrutinizerCI
12+
- Write a comprehensive ReadMe
13+
14+
## Pull Requests
15+
16+
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
17+
18+
- **Document any change in behaviour** - Make sure the `readme.md` and any other relevant documentation are kept up-to-date.
19+
20+
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
21+
22+
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
23+
24+
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
25+
26+
27+
**Happy coding**!

license.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# The license
2+
3+
Copyright (c) Cristian Tabacitu <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
8+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9+
10+
11+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

phpunit.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit bootstrap="vendor/autoload.php"
3+
backupGlobals="false"
4+
backupStaticAttributes="false"
5+
colors="true"
6+
verbose="true"
7+
convertErrorsToExceptions="true"
8+
convertNoticesToExceptions="true"
9+
convertWarningsToExceptions="true"
10+
processIsolation="false"
11+
stopOnFailure="false">
12+
<testsuites>
13+
<testsuite name="Package">
14+
<directory suffix=".php">./tests/</directory>
15+
</testsuite>
16+
</testsuites>
17+
<filter>
18+
<whitelist>
19+
<directory>src/</directory>
20+
</whitelist>
21+
</filter>
22+
</phpunit>

readme.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# FileManager
2+
3+
[![Latest Version on Packagist][ico-version]][link-packagist]
4+
[![Total Downloads][ico-downloads]][link-downloads]
5+
[![Build Status][ico-travis]][link-travis]
6+
[![StyleCI][ico-styleci]][link-styleci]
7+
8+
Backpack admin interface for files and folder, using [barryvdh/laravel-elfinder](https://github.com/barryvdh/laravel-elfinder). This package _literally_ just:
9+
- creates a ```public/uploads``` folder;
10+
- installs ```barryvdh/laravel-elfinder```;
11+
- publishes an elFinder config and view, for elFinder to play nice with Backpack;
12+
- adds a menu item to the sidebar;
13+
14+
![https://backpackforlaravel.com/uploads/docs-4-0/media_library.png](https://backpackforlaravel.com/uploads/docs-4-0/media_library.png)
15+
16+
17+
## Installation
18+
19+
From your command line, require the package (this will also require barryvdh/laravel-elfinder):
20+
21+
``` bash
22+
composer require backpack/filemanager
23+
```
24+
25+
Then run the install process:
26+
27+
```bash
28+
php artisan backpack:filemanager:install
29+
```
30+
31+
That's it. Hit refresh in your admin panel, and you'll find a new sidebar item pointing to the File Manager.
32+
33+
## Usage
34+
35+
You can use elFinder in Backpack:
36+
- stand-alone, by accessing the ```/admin/elfinder``` route (see screenshot above);
37+
- inside the [```browse```](https://backpackforlaravel.com/docs/4.1/crud-fields#browse), [```browse_multiple```](https://backpackforlaravel.com/docs/4.1/crud-fields#browse_multiple) or [```ckeditor```](https://backpackforlaravel.com/docs/4.1/crud-fields#ckeditor) field types;
38+
39+
40+
## Security
41+
42+
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
43+
44+
## Credits
45+
46+
- [Cristian Tabacitu][link-author]
47+
- [All Contributors][link-contributors]
48+
49+
## License
50+
51+
MIT. Please see the [license file](license.md) for more information.
52+
53+
[ico-version]: https://img.shields.io/packagist/v/backpack/filemanager.svg?style=flat-square
54+
[ico-downloads]: https://img.shields.io/packagist/dt/backpack/filemanager.svg?style=flat-square
55+
[ico-travis]: https://img.shields.io/travis/backpack/filemanager/master.svg?style=flat-square
56+
[ico-styleci]: https://styleci.io/repos/12345678/shield
57+
58+
[link-packagist]: https://packagist.org/packages/backpack/filemanager
59+
[link-downloads]: https://packagist.org/packages/backpack/filemanager
60+
[link-travis]: https://travis-ci.org/backpack/filemanager
61+
[link-styleci]: https://styleci.io/repos/12345678
62+
[link-author]: https://tabacitu.ro
63+
[link-contributors]: ../../contributors

resources/views/ckeditor4.php

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>elFinder 2.0 - CKEditor</title>
6+
7+
<!-- jQuery and jQuery UI (REQUIRED) -->
8+
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" />
9+
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
10+
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
11+
12+
<!-- elFinder CSS (REQUIRED) -->
13+
<link rel="stylesheet" type="text/css" href="<?= asset($dir.'/css/elfinder.min.css') ?>">
14+
<!-- <link rel="stylesheet" type="text/css" href="<?= asset($dir.'/css/theme.css') ?>"> -->
15+
<link rel="stylesheet" type="text/css" href="<?= asset('packages/backpack/base/css/elfinder.backpack.theme.css') ?>">
16+
17+
<!-- elFinder JS (REQUIRED) -->
18+
<script src="<?= asset($dir.'/js/elfinder.min.js') ?>"></script>
19+
20+
<?php if ($locale) {
21+
?>
22+
<!-- elFinder translation (OPTIONAL) -->
23+
<script src="<?= asset($dir."/js/i18n/elfinder.$locale.js") ?>"></script>
24+
<?php
25+
} ?>
26+
27+
<!-- elFinder initialization (REQUIRED) -->
28+
<script type="text/javascript" charset="utf-8">
29+
// Helper function to get parameters from the query string.
30+
function getUrlParam(paramName) {
31+
var reParam = new RegExp('(?:[\?&]|&amp;)' + paramName + '=([^&]+)', 'i') ;
32+
var match = window.location.search.match(reParam) ;
33+
34+
return (match && match.length > 1) ? match[1] : '' ;
35+
}
36+
37+
$().ready(function() {
38+
var funcNum = getUrlParam('CKEditorFuncNum');
39+
40+
var elf = $('#elfinder').elfinder({
41+
// set your elFinder options here
42+
resizable: false,
43+
<?php if ($locale) {
44+
?>
45+
lang: '<?= $locale ?>', // locale
46+
<?php
47+
} ?>
48+
customData: {
49+
_token: '<?= csrf_token() ?>'
50+
},
51+
url: '<?= route('elfinder.connector') ?>', // connector URL
52+
getFileCallback : function(file) {
53+
window.opener.CKEDITOR.tools.callFunction(funcNum, file.url);
54+
window.close();
55+
}
56+
}).elfinder('instance');
57+
});
58+
$(window).resize(function(){
59+
var h = ($(window).height());
60+
if($('#elfinder').height() != h){
61+
$('#elfinder').height(h).resize();
62+
}
63+
});
64+
</script>
65+
</head>
66+
<body class="elfinder">
67+
<!-- Element where elFinder will be created (REQUIRED) -->
68+
<div id="elfinder"></div>
69+
</body>
70+
</html>

resources/views/elfinder.blade.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
@extends('backpack::layouts.top_left')
2+
3+
@section('after_scripts')
4+
<!-- jQuery and jQuery UI (REQUIRED) -->
5+
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" />
6+
<!-- <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> -->
7+
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
8+
9+
<!-- elFinder CSS (REQUIRED) -->
10+
<link rel="stylesheet" type="text/css" href="<?= asset($dir.'/css/elfinder.min.css') ?>">
11+
<!-- <link rel="stylesheet" type="text/css" href="<?= asset($dir.'/css/theme.css') ?>"> -->
12+
<link rel="stylesheet" type="text/css" href="<?= asset('packages/backpack/base/css/elfinder.backpack.theme.css') ?>">
13+
14+
<!-- elFinder JS (REQUIRED) -->
15+
<script src="<?= asset($dir.'/js/elfinder.min.js') ?>"></script>
16+
17+
<?php if ($locale) { ?>
18+
<!-- elFinder translation (OPTIONAL) -->
19+
<script src="<?= asset($dir."/js/i18n/elfinder.$locale.js") ?>"></script>
20+
<?php } ?>
21+
22+
<!-- elFinder initialization (REQUIRED) -->
23+
<script type="text/javascript" charset="utf-8">
24+
// Documentation for client options:
25+
// https://github.com/Studio-42/elFinder/wiki/Client-configuration-options
26+
$().ready(function() {
27+
$('#elfinder').elfinder({
28+
// set your elFinder options here
29+
<?php if ($locale) { ?>
30+
lang: '<?= $locale ?>', // locale
31+
<?php } ?>
32+
customData: {
33+
_token: '<?= csrf_token() ?>'
34+
},
35+
url : '<?= route('elfinder.connector') ?>' // connector URL
36+
});
37+
});
38+
</script>
39+
@endsection
40+
41+
@php
42+
$breadcrumbs = [
43+
trans('backpack::crud.admin') => url(config('backpack.base.route_prefix'), 'dashboard'),
44+
'File Manager' => false,
45+
];
46+
@endphp
47+
48+
@section('header')
49+
<section class="container-fluid">
50+
<h2>File Manager</h2>
51+
</section>
52+
@endsection
53+
54+
@section('content')
55+
56+
<!-- Element where elFinder will be created (REQUIRED) -->
57+
<div id="elfinder"></div>
58+
59+
@endsection

0 commit comments

Comments
 (0)