Skip to content
This repository was archived by the owner on Aug 22, 2021. It is now read-only.

Commit 62294aa

Browse files
committed
init commit.
0 parents  commit 62294aa

File tree

295 files changed

+130495
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

295 files changed

+130495
-0
lines changed

.editorconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
; top-most EditorConfig file
2+
root = true
3+
4+
; Unix-style newlines
5+
[*]
6+
end_of_line = LF
7+
8+
[*.php]
9+
indent_style = space
10+
indent_size = 4

.gitattributes

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
* text=auto
2+
3+
/tests export-ignore
4+
.gitattributes export-ignore
5+
.gitignore export-ignore
6+
.scrutinizer.yml export-ignore
7+
.travis.yml export-ignore
8+
phpunit.php export-ignore
9+
phpunit.xml.dist export-ignore
10+
phpunit.xml export-ignore
11+
.php_cs export-ignore

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
*.DS_Store
2+
/vendor
3+
/coverage
4+
sftp-config.json
5+
composer.lock
6+
.subsplit
7+
.php_cs.cache

.php_cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
/**
3+
* PHP-CS-fixer configuration.
4+
*/
5+
6+
$finder = Symfony\CS\Finder\DefaultFinder::create()
7+
->in(__DIR__ . '/src/')
8+
;
9+
10+
return Symfony\CS\Config\Config::create()
11+
->fixers(array (
12+
0 => 'symfony',
13+
))
14+
->finder($finder)
15+
->setUsingCache(true)
16+
;

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Laravel-ueditor
2+
3+
# Usage
4+
5+
# License
6+
7+
MIT

composer.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "overtrue/laravel-ueditor",
3+
"description": "UEditor integration for Laravel.",
4+
"license": "MIT",
5+
"authors": [
6+
{
7+
"name": "overtrue",
8+
"email": "[email protected]"
9+
}
10+
],
11+
"require": {},
12+
"require-dev": {
13+
"fabpot/php-cs-fixer": "^1.10"
14+
}
15+
}

src/.gitkeep

Whitespace-only changes.

src/LocalStorage.php

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?php
2+
/**
3+
* LocalStorage.php.
4+
*
5+
* This file is part of the laravel-ueditor.
6+
*
7+
* (c) overtrue <[email protected]>
8+
*
9+
* This source file is subject to the MIT license that is bundled
10+
* with this source code in the file LICENSE.
11+
*/
12+
namespace App\Services\UEditor;
13+
14+
use Exception;
15+
use Symfony\Component\Finder\Finder;
16+
use Symfony\Component\HttpFoundation\File\UploadedFile;
17+
18+
/**
19+
* Class LocalStorage.
20+
*/
21+
class LocalStorage implements StorageInterface
22+
{
23+
/**
24+
* Store file.
25+
*
26+
* @param \Symfony\Component\HttpFoundation\File\UploadedFile $file
27+
* @param string $filename
28+
*
29+
* @return mixed
30+
*
31+
* @throws \App\Services\UEditor\StoreErrorException
32+
*/
33+
public function store(UploadedFile $file, $filename)
34+
{
35+
$directory = public_path(dirname($filename));
36+
37+
if (!is_dir($directory) && !mkdir($directory, 0777, true)) {
38+
throw new StoreErrorException(trans('ERROR_CREATE_DIR'));
39+
} elseif (!is_writable($directory)) {
40+
throw new StoreErrorException(trans('ERROR_DIR_NOT_WRITEABLE'));
41+
}
42+
43+
try {
44+
return $file->move($directory, basename($filename));
45+
} catch (Exception $e) {
46+
throw new StoreErrorException(trans('ERROR_FILE_MOVE'));
47+
}
48+
}
49+
50+
/**
51+
* List files of path.
52+
*
53+
* @param string $path
54+
* @param int $start
55+
* @param int $size
56+
* @param array $allowFiles
57+
*
58+
* @return array
59+
*/
60+
public function lists($path, $start, $size = 20, array $allowFiles = [])
61+
{
62+
$filesIterator = Finder::create()->files()->in(public_path($path))
63+
->sortByChangedTime()
64+
->filter(function ($file) use ($allowFiles) {
65+
if (empty($allowFiles)) {
66+
return true;
67+
}
68+
69+
return in_array('.'.pathinfo($file->getRelativePathname(), PATHINFO_EXTENSION), $allowFiles);
70+
});
71+
72+
$files = [];
73+
74+
foreach ($filesIterator as $file) {
75+
$files[] = [
76+
'url' => asset($path.'/'.$file->getRelativePathname()),
77+
'mtime' => $file->getMTime(),
78+
];
79+
}
80+
81+
return $files;
82+
}
83+
84+
/**
85+
* Make the url of file.
86+
*
87+
* @param string $filename
88+
*
89+
* @return mixed
90+
*/
91+
public function getUrl($filename)
92+
{
93+
return asset($filename);
94+
}
95+
}

src/QiNiuStorage.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
/**
3+
* QiNiuStorage.php.
4+
*
5+
* This file is part of the laravel-ueditor.
6+
*
7+
* (c) overtrue <[email protected]>
8+
*
9+
* This source file is subject to the MIT license that is bundled
10+
* with this source code in the file LICENSE.
11+
*/
12+
namespace App\Services\UEditor;
13+
14+
use Symfony\Component\HttpFoundation\File\UploadedFile;
15+
16+
/**
17+
* Class QiNiuStorage.
18+
*/
19+
class QiNiuStorage implements StorageInterface
20+
{
21+
/**
22+
* Store file.
23+
*
24+
* @param \Symfony\Component\HttpFoundation\File\UploadedFile $file
25+
* @param string $filename
26+
*
27+
* @return mixed
28+
*/
29+
public function store(UploadedFile $file, $filename)
30+
{
31+
// TODO: Implement store() method.
32+
}
33+
34+
/**
35+
* List files of path.
36+
*
37+
* @param string $path
38+
* @param int $start
39+
* @param int $size
40+
* @param array $allowFiles
41+
*
42+
* @return array
43+
*/
44+
public function lists($path, $start, $size = 20, array $allowFiles = [])
45+
{
46+
// TODO: Implement lists() method.
47+
}
48+
49+
/**
50+
* Make the url of file.
51+
*
52+
* @param $filename
53+
*
54+
* @return mixed
55+
*/
56+
public function getUrl($filename)
57+
{
58+
// TODO: Implement getUrl() method.
59+
}
60+
}

src/StorageInterface.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/**
3+
* StorageInterface.php.
4+
*
5+
* This file is part of the laravel-ueditor.
6+
*
7+
* (c) overtrue <[email protected]>
8+
*
9+
* This source file is subject to the MIT license that is bundled
10+
* with this source code in the file LICENSE.
11+
*/
12+
namespace App\Services\UEditor;
13+
14+
use Symfony\Component\HttpFoundation\File\File;
15+
use Symfony\Component\HttpFoundation\File\UploadedFile;
16+
17+
/**
18+
* Interface StorageInterface.
19+
*/
20+
interface StorageInterface
21+
{
22+
/**
23+
* Store file.
24+
*
25+
* @param \Symfony\Component\HttpFoundation\File\UploadedFile $file
26+
* @param string $filename
27+
*
28+
* @return mixed
29+
*/
30+
public function store(UploadedFile $file, $filename);
31+
32+
/**
33+
* List files of path.
34+
*
35+
* @param string $path
36+
* @param int $start
37+
* @param int $size
38+
* @param array $allowFiles
39+
*
40+
* @return array
41+
*/
42+
public function lists($path, $start, $size = 20, array $allowFiles = []);
43+
44+
/**
45+
* Make the url of file.
46+
*
47+
* @param $filename
48+
*
49+
* @return mixed
50+
*/
51+
public function getUrl($filename);
52+
}

0 commit comments

Comments
 (0)