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

Commit 7876be0

Browse files
authored
Merge pull request #2 from overtrue/analysis-qvyexx
Applied fixes from StyleCI
2 parents 57ddbad + 17eb45b commit 7876be0

File tree

12 files changed

+171
-170
lines changed

12 files changed

+171
-170
lines changed

src/LocalStorage.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ class LocalStorage implements StorageInterface
2626
* @param \Symfony\Component\HttpFoundation\File\UploadedFile $file
2727
* @param string $filename
2828
*
29-
* @return mixed
30-
*
3129
* @throws \Overtrue\LaravelUEditor\StoreErrorException
30+
*
31+
* @return mixed
3232
*/
3333
public function store(UploadedFile $file, $filename)
3434
{
@@ -73,7 +73,7 @@ public function lists($path, $start, $size = 20, array $allowFiles = [])
7373

7474
foreach ($filesIterator as $file) {
7575
$files[] = [
76-
'url' => asset($path.'/'.$file->getRelativePathname()),
76+
'url' => asset($path.'/'.$file->getRelativePathname()),
7777
'mtime' => $file->getMTime(),
7878
];
7979
}

src/StorageManager.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ public function upload(Request $request)
4444
$filename = $this->getFilename($file, $config);
4545

4646
$response = [
47-
'state' => 'SUCCESS',
48-
'url' => $this->getUrl($filename),
49-
'title' => $filename,
47+
'state' => 'SUCCESS',
48+
'url' => $this->getUrl($filename),
49+
'title' => $filename,
5050
'original' => $file->getClientOriginalName(),
51-
'type' => $file->getExtension(),
52-
'size' => $file->getSize(),
51+
'type' => $file->getExtension(),
52+
'size' => $file->getSize(),
5353
];
5454

5555
try {
@@ -77,7 +77,7 @@ public function listFiles($path, $start, $size = 20, array $allowFiles = [])
7777

7878
return [
7979
'state' => empty($files) ? 'no match file' : 'SUCCESS',
80-
'list' => $files,
80+
'list' => $files,
8181
'start' => $start,
8282
'total' => count($files),
8383
];
@@ -173,9 +173,9 @@ public function getUploadConfig($action)
173173
foreach ($prefixes as $prefix) {
174174
if ($action == $upload[$prefix.'ActionName']) {
175175
$config = [
176-
'action' => array_get($upload, $prefix.'ActionName'),
177-
'field_name' => array_get($upload, $prefix.'FieldName'),
178-
'max_size' => array_get($upload, $prefix.'MaxSize'),
176+
'action' => array_get($upload, $prefix.'ActionName'),
177+
'field_name' => array_get($upload, $prefix.'FieldName'),
178+
'max_size' => array_get($upload, $prefix.'MaxSize'),
179179
'allow_files' => array_get($upload, $prefix.'AllowFiles', []),
180180
'path_format' => array_get($upload, $prefix.'PathFormat'),
181181
];
@@ -209,7 +209,7 @@ public function formatPath($path)
209209
{
210210
$time = time();
211211
$partials = explode('-', date('Y-y-m-d-H-i-s'));
212-
$replacement = ['{yyyy}','{yy}', '{mm}', '{dd}', '{hh}', '{ii}', '{ss}'];
212+
$replacement = ['{yyyy}', '{yy}', '{mm}', '{dd}', '{hh}', '{ii}', '{ss}'];
213213
$path = str_replace($replacement, $partials, $path);
214214
$path = str_replace('{time}', $time, $path);
215215

src/UEditorServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function boot(Router $router)
3838
], 'assets');
3939

4040
$this->publishes([
41-
__DIR__.'/views' => base_path('resources/views/vendor/ueditor'),
41+
__DIR__.'/views' => base_path('resources/views/vendor/ueditor'),
4242
__DIR__.'/translations' => base_path('resources/lang/vendor/ueditor'),
4343
], 'resources');
4444

src/assets/ueditor/php/Uploader.class.php

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,29 @@ class Uploader
2020
private $fileSize; //文件大小
2121
private $fileType; //文件类型
2222
private $stateInfo; //上传状态信息,
23-
private $stateMap = array( //上传状态映射表,国际化用户需考虑此处数据的国际化
23+
private $stateMap = [ //上传状态映射表,国际化用户需考虑此处数据的国际化
2424
'SUCCESS', //上传成功标记,在UEditor中内不可改变,否则flash判断会出错
2525
'文件大小超出 upload_max_filesize 限制',
2626
'文件大小超出 MAX_FILE_SIZE 限制',
2727
'文件未被完整上传',
2828
'没有文件被上传',
2929
'上传文件为空',
30-
'ERROR_TMP_FILE' => '临时文件错误',
30+
'ERROR_TMP_FILE' => '临时文件错误',
3131
'ERROR_TMP_FILE_NOT_FOUND' => '找不到临时文件',
32-
'ERROR_SIZE_EXCEED' => '文件大小超出网站限制',
33-
'ERROR_TYPE_NOT_ALLOWED' => '文件类型不允许',
34-
'ERROR_CREATE_DIR' => '目录创建失败',
35-
'ERROR_DIR_NOT_WRITEABLE' => '目录没有写权限',
36-
'ERROR_FILE_MOVE' => '文件保存时出错',
37-
'ERROR_FILE_NOT_FOUND' => '找不到上传文件',
38-
'ERROR_WRITE_CONTENT' => '写入文件内容错误',
39-
'ERROR_UNKNOWN' => '未知错误',
40-
'ERROR_DEAD_LINK' => '链接不可用',
41-
'ERROR_HTTP_LINK' => '链接不是http链接',
42-
'ERROR_HTTP_CONTENTTYPE' => '链接contentType不正确',
43-
'INVALID_URL' => '非法 URL',
44-
'INVALID_IP' => '非法 IP',
45-
);
32+
'ERROR_SIZE_EXCEED' => '文件大小超出网站限制',
33+
'ERROR_TYPE_NOT_ALLOWED' => '文件类型不允许',
34+
'ERROR_CREATE_DIR' => '目录创建失败',
35+
'ERROR_DIR_NOT_WRITEABLE' => '目录没有写权限',
36+
'ERROR_FILE_MOVE' => '文件保存时出错',
37+
'ERROR_FILE_NOT_FOUND' => '找不到上传文件',
38+
'ERROR_WRITE_CONTENT' => '写入文件内容错误',
39+
'ERROR_UNKNOWN' => '未知错误',
40+
'ERROR_DEAD_LINK' => '链接不可用',
41+
'ERROR_HTTP_LINK' => '链接不是http链接',
42+
'ERROR_HTTP_CONTENTTYPE' => '链接contentType不正确',
43+
'INVALID_URL' => '非法 URL',
44+
'INVALID_IP' => '非法 IP',
45+
];
4646

4747
/**
4848
* 构造函数.
@@ -121,7 +121,7 @@ private function upFile()
121121
$this->stateInfo = $this->getStateInfo('ERROR_CREATE_DIR');
122122

123123
return;
124-
} elseif (!is_writeable($dirname)) {
124+
} elseif (!is_writable($dirname)) {
125125
$this->stateInfo = $this->getStateInfo('ERROR_DIR_NOT_WRITEABLE');
126126

127127
return;
@@ -165,7 +165,7 @@ private function upBase64()
165165
$this->stateInfo = $this->getStateInfo('ERROR_CREATE_DIR');
166166

167167
return;
168-
} elseif (!is_writeable($dirname)) {
168+
} elseif (!is_writable($dirname)) {
169169
$this->stateInfo = $this->getStateInfo('ERROR_DIR_NOT_WRITEABLE');
170170

171171
return;
@@ -236,9 +236,9 @@ private function saveRemote()
236236
//打开输出缓冲区并获取远程图片
237237
ob_start();
238238
$context = stream_context_create(
239-
array('http' => array(
239+
['http' => [
240240
'follow_location' => false, // don't follow redirects
241-
))
241+
]]
242242
);
243243
readfile($imgUrl, false, $context);
244244
$img = ob_get_contents();
@@ -265,7 +265,7 @@ private function saveRemote()
265265
$this->stateInfo = $this->getStateInfo('ERROR_CREATE_DIR');
266266

267267
return;
268-
} elseif (!is_writeable($dirname)) {
268+
} elseif (!is_writable($dirname)) {
269269
$this->stateInfo = $this->getStateInfo('ERROR_DIR_NOT_WRITEABLE');
270270

271271
return;
@@ -391,13 +391,13 @@ private function checkSize()
391391
*/
392392
public function getFileInfo()
393393
{
394-
return array(
395-
'state' => $this->stateInfo,
396-
'url' => $this->fullName,
397-
'title' => $this->fileName,
394+
return [
395+
'state' => $this->stateInfo,
396+
'url' => $this->fullName,
397+
'title' => $this->fileName,
398398
'original' => $this->oriName,
399-
'type' => $this->fileType,
400-
'size' => $this->fileSize,
401-
);
399+
'type' => $this->fileType,
400+
'size' => $this->fileSize,
401+
];
402402
}
403403
}

src/assets/ueditor/php/action_crawler.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99
include 'Uploader.class.php';
1010

1111
/* 上传配置 */
12-
$config = array(
12+
$config = [
1313
'pathFormat' => $CONFIG['catcherPathFormat'],
14-
'maxSize' => $CONFIG['catcherMaxSize'],
14+
'maxSize' => $CONFIG['catcherMaxSize'],
1515
'allowFiles' => $CONFIG['catcherAllowFiles'],
16-
'oriName' => 'remote.png',
17-
);
16+
'oriName' => 'remote.png',
17+
];
1818
$fieldName = $CONFIG['catcherFieldName'];
1919

2020
/* 抓取远程图片 */
21-
$list = array();
21+
$list = [];
2222
if (isset($_POST[$fieldName])) {
2323
$source = $_POST[$fieldName];
2424
} else {
@@ -27,18 +27,18 @@
2727
foreach ($source as $imgUrl) {
2828
$item = new Uploader($imgUrl, $config, 'remote');
2929
$info = $item->getFileInfo();
30-
array_push($list, array(
31-
'state' => $info['state'],
32-
'url' => $info['url'],
33-
'size' => $info['size'],
34-
'title' => htmlspecialchars($info['title']),
30+
array_push($list, [
31+
'state' => $info['state'],
32+
'url' => $info['url'],
33+
'size' => $info['size'],
34+
'title' => htmlspecialchars($info['title']),
3535
'original' => htmlspecialchars($info['original']),
36-
'source' => htmlspecialchars($imgUrl),
37-
));
36+
'source' => htmlspecialchars($imgUrl),
37+
]);
3838
}
3939

4040
/* 返回抓取数据 */
41-
return json_encode(array(
41+
return json_encode([
4242
'state' => count($list) ? 'SUCCESS' : 'ERROR',
43-
'list' => $list,
44-
));
43+
'list' => $list,
44+
]);

src/assets/ueditor/php/action_list.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@
3333
$path = $_SERVER['DOCUMENT_ROOT'].(substr($path, 0, 1) == '/' ? '' : '/').$path;
3434
$files = getfiles($path, $allowFiles);
3535
if (!count($files)) {
36-
return json_encode(array(
36+
return json_encode([
3737
'state' => 'no match file',
38-
'list' => array(),
38+
'list' => [],
3939
'start' => $start,
4040
'total' => count($files),
41-
));
41+
]);
4242
}
4343

4444
/* 获取指定范围的列表 */
4545
$len = count($files);
46-
for ($i = min($end, $len) - 1, $list = array(); $i < $len && $i >= 0 && $i >= $start; --$i) {
46+
for ($i = min($end, $len) - 1, $list = []; $i < $len && $i >= 0 && $i >= $start; --$i) {
4747
$list[] = $files[$i];
4848
}
4949
//倒序
@@ -52,12 +52,12 @@
5252
//}
5353

5454
/* 返回数据 */
55-
$result = json_encode(array(
55+
$result = json_encode([
5656
'state' => 'SUCCESS',
57-
'list' => $list,
57+
'list' => $list,
5858
'start' => $start,
5959
'total' => count($files),
60-
));
60+
]);
6161

6262
return $result;
6363

@@ -69,7 +69,7 @@
6969
*
7070
* @return array
7171
*/
72-
function getfiles($path, $allowFiles, &$files = array())
72+
function getfiles($path, $allowFiles, &$files = [])
7373
{
7474
if (!is_dir($path)) {
7575
return;
@@ -85,10 +85,10 @@ function getfiles($path, $allowFiles, &$files = array())
8585
getfiles($path2, $allowFiles, $files);
8686
} else {
8787
if (preg_match("/\.(".$allowFiles.')$/i', $file)) {
88-
$files[] = array(
89-
'url' => substr($path2, strlen($_SERVER['DOCUMENT_ROOT'])),
88+
$files[] = [
89+
'url' => substr($path2, strlen($_SERVER['DOCUMENT_ROOT'])),
9090
'mtime' => filemtime($path2),
91-
);
91+
];
9292
}
9393
}
9494
}

src/assets/ueditor/php/action_upload.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,38 +11,38 @@
1111
$base64 = 'upload';
1212
switch (htmlspecialchars($_GET['action'])) {
1313
case 'uploadimage':
14-
$config = array(
14+
$config = [
1515
'pathFormat' => $CONFIG['imagePathFormat'],
16-
'maxSize' => $CONFIG['imageMaxSize'],
16+
'maxSize' => $CONFIG['imageMaxSize'],
1717
'allowFiles' => $CONFIG['imageAllowFiles'],
18-
);
18+
];
1919
$fieldName = $CONFIG['imageFieldName'];
2020
break;
2121
case 'uploadscrawl':
22-
$config = array(
22+
$config = [
2323
'pathFormat' => $CONFIG['scrawlPathFormat'],
24-
'maxSize' => $CONFIG['scrawlMaxSize'],
24+
'maxSize' => $CONFIG['scrawlMaxSize'],
2525
'allowFiles' => $CONFIG['scrawlAllowFiles'],
26-
'oriName' => 'scrawl.png',
27-
);
26+
'oriName' => 'scrawl.png',
27+
];
2828
$fieldName = $CONFIG['scrawlFieldName'];
2929
$base64 = 'base64';
3030
break;
3131
case 'uploadvideo':
32-
$config = array(
32+
$config = [
3333
'pathFormat' => $CONFIG['videoPathFormat'],
34-
'maxSize' => $CONFIG['videoMaxSize'],
34+
'maxSize' => $CONFIG['videoMaxSize'],
3535
'allowFiles' => $CONFIG['videoAllowFiles'],
36-
);
36+
];
3737
$fieldName = $CONFIG['videoFieldName'];
3838
break;
3939
case 'uploadfile':
4040
default:
41-
$config = array(
41+
$config = [
4242
'pathFormat' => $CONFIG['filePathFormat'],
43-
'maxSize' => $CONFIG['fileMaxSize'],
43+
'maxSize' => $CONFIG['fileMaxSize'],
4444
'allowFiles' => $CONFIG['fileAllowFiles'],
45-
);
45+
];
4646
$fieldName = $CONFIG['fileFieldName'];
4747
break;
4848
}

src/assets/ueditor/php/controller.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
//header('Access-Control-Allow-Origin: http://www.baidu.com'); //设置http://www.baidu.com允许跨域访问
34
//header('Access-Control-Allow-Headers: X-Requested-With,X_Requested_With'); //设置允许的跨域header
45
date_default_timezone_set('Asia/chongqing');
@@ -39,9 +40,9 @@
3940
break;
4041

4142
default:
42-
$result = json_encode(array(
43+
$result = json_encode([
4344
'state' => '请求地址出错',
44-
));
45+
]);
4546
break;
4647
}
4748

@@ -50,9 +51,9 @@
5051
if (preg_match("/^[\w_]+$/", $_GET['callback'])) {
5152
echo htmlspecialchars($_GET['callback']).'('.$result.')';
5253
} else {
53-
echo json_encode(array(
54+
echo json_encode([
5455
'state' => 'callback参数不合法',
55-
));
56+
]);
5657
}
5758
} else {
5859
echo $result;

0 commit comments

Comments
 (0)