itxq / ckfinder
实现CkFinderComposer引用
v3.0.2
2020-05-20 01:03 UTC
Requires
- php: >=7.1.0
- ext-iconv: >=1.0
- itxq/pinyin: ^1.0
- itxq/singleton-pattern-php: ^1.0
- upyun/sdk: ^3.4
- dev-master
- v3.0.2
- v3.0.1
- v3.0.0
- v2.0.1
- v2.0.0
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-dependabot/composer/core/cksource/ckfinder/guzzlehttp/psr7-1.9.1
- dev-dependabot/composer/core/cksource/ckfinder/symfony/http-kernel-5.4.20
- dev-dependabot/composer/core/cksource/ckfinder/guzzlehttp/guzzle-6.5.8
- dev-dev
This package is auto-updated.
Last update: 2024-10-19 22:22:39 UTC
README
开源地址:
【GitHub:】https://github.com/itxq/ckfinder
【码云:】https://gitee.com/itxq/ckfinder
扩展安装:
-
方法一:composer命令
composer require itxq/ckfinder
-
方法二:直接下载压缩包,然后进入项目中执行 composer命令
composer update
来生成自动加载文件
引用扩展:
- 当你的项目不支持composer自动加载时,可以使用以下方式来引用该扩展包
// 引入扩展(具体路径请根据你的目录结构自行修改)
require_once __DIR__ . '/vendor/autoload.php';
使用示例:
<?php
use itxq\ckfinder\CkFinder;
require __DIR__ . '/vendor/autoload.php';
if (isset($_GET['command'])) {
try {
CkFinder::make()
// 配置缓存目录
->setConfig('runtime_path', __DIR__ . '/runtime')
// 授权信息
->setConfig('licenseName', 'licenseName')
->setConfig('licenseKey', 'licenseKey')
// 是否自动重命名(用于过滤用户提交包含中文以及特殊字符,中文会自动转为拼音)
->setConfig('auto_rename', ['folder' => true, 'file' => true])
// 设置PrivateDirKey (可用于区分不同用户的缓存目录,建议使用用户ID)
->setPrivateDirKey('')
// 添加一个又拍云存储空间(添加多个存储空间时,name不可重复)
->addBackend('my_upy', CkFinder::ADAPTER_UPY, [
// 又拍云操作员相关设置
'service' => 'service',
'operator' => 'operator',
'password' => 'password',
// 以下根路径和URL前缀需根据自己项目进行调整
'root' => 'my_upy/',
'baseUrl' => 'http://test.upy.com/my_upy'
])
// 为又拍云存储空间添加一个资源目录(可添加多个)
->addResource('云端存储', '01', 'my_upy')
// 添加一个本地存储空间(添加多个存储空间时,name不可重复)
->addBackend('my_local', CkFinder::ADAPTER_LOCAL, [
// 以下根路径和URL前缀需根据自己项目进行调整
'root' => __DIR__ . '/uploads/my_local',
'baseUrl' => '/uploads/my_local'
])
// 为本地存储空间添加一个资源目录(可添加多个)
->addResource('本地存储', '01', 'my_local')
->run();
} catch (Exception$exception) {
var_dump($exception->getMessage());
}
exit();
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div class="input-group">
<input type="text" id="demo" name="demo" placeholder="demo">
<span class="input-group-append input-group-btn add-on">
<button type="button" class="btn btn-primary" onclick="selectFileWithCKFinder('demo');">
选择
</button>
</span>
</div>
<script type="text/javascript" src="static/ckfinder.js"></script>
<script type="text/javascript">
function selectFileWithCKFinder(elementId) {
CKFinder.modal({
displayFoldersPanel: false,
// readOnly: true,
skin: 'neko',
// skin: 'jquery-mobile',
swatch: 'b',
connectorPath: 'index.php',
chooseFiles: true,
width: 800,
height: 600,
lugins: [],
onInit: function (finder) {
finder.on('files:choose', function (evt) {
var file = evt.data.files.first();
var output = document.getElementById(elementId);
output.value = file.getUrl();
});
finder.on('file:choose:resizedImage', function (evt) {
var output = document.getElementById(elementId);
output.value = evt.data.resizedUrl;
});
}
});
}
</script>
</body>
</html>
修改文件:
-
core/cksource/ckfinder/src/CKSource/CKFinder/Command/CreateFolder.php
-
core/cksource/ckfinder/src/CKSource/CKFinder/Command/RenameFolder.php
-
core/cksource/ckfinder/src/CKSource/CKFinder/Command/RenameFile.php
-
core/cksource/ckfinder/src/CKSource/CKFinder/Command/FileUpload.php
-
core/cksource/ckfinder/src/CKSource/CKFinder/Filesystem/File/File.php
-
core/cksource/ckfinder/src/CKSource/CKFinder/Filesystem/File/UploadedFile.php