定制 devrundebug/yii2-kcfinder 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

devrundebug/yii2-kcfinder

最新稳定版本:1.0.6

Composer 安装命令:

composer require devrundebug/yii2-kcfinder

包简介

KCFinder integration for Yii2 (frozen to upstream tag 3.12)

README 文档

README

KCFinder for Yii2

Forked from [iutbay/yii2-kcfinder]

dependency frozen for sunhater/kcfinder tag 3.12, as there is a problem with the last 3.20-test* tag at composer install

Originally forked from [iutbay/yii2-kcfinder] (original readme below)

KCFinder for Yii2.

WARNING : I don't have time actually to maintain this repository, but take a look here (WIP)...

Installation

The preferred way to install this helper is through composer.

Since kcfinder package do not have stable release on packagist, you should use these settings in your composer.json file :

"minimum-stability": "dev",
"prefer-stable": true,

After, either run

php composer.phar require "iutbay/yii2-kcfinder" "dev-master"

or add

"iutbay/yii2-kcfinder" : "dev-master"

to the require section of your application's composer.json file.

Widget Use

Without model :

use iutbay\yii2kcfinder\KCFinderInputWidget;

echo KCFinderInputWidget::widget([
	'name' => 'image',
]);

With model and ActiveForm :

use iutbay\yii2kcfinder\KCFinderInputWidget;

echo $form->field($model, 'images')->widget(KCFinderInputWidget::className(), [
	'multiple' => true,
]);

Use with 2amigos/yii2-ckeditor-widget

You should extend \dosamigos\ckeditor\CKEditor, e.g. :

namespace app\widgets;

use yii\helpers\ArrayHelper;

use iutbay\yii2kcfinder\KCFinderAsset;

class CKEditor extends \dosamigos\ckeditor\CKEditor
{

	public $enableKCFinder = true;

	/**
	 * Registers CKEditor plugin
	 */
	protected function registerPlugin()
	{
		if ($this->enableKCFinder)
		{
			$this->registerKCFinder();
		}

		parent::registerPlugin();
	}

	/**
	 * Registers KCFinder
	 */
	protected function registerKCFinder()
	{
		$register = KCFinderAsset::register($this->view);
		$kcfinderUrl = $register->baseUrl;

		$browseOptions = [
			'filebrowserBrowseUrl' => $kcfinderUrl . '/browse.php?opener=ckeditor&type=files',
			'filebrowserUploadUrl' => $kcfinderUrl . '/upload.php?opener=ckeditor&type=files',
		];

		$this->clientOptions = ArrayHelper::merge($browseOptions, $this->clientOptions);
	}

}

You should then set KCFinder options using session var, e.g. :

// kcfinder options
// http://kcfinder.sunhater.com/install#dynamic
$kcfOptions = array_merge(KCFinder::$kcfDefaultOptions, [
	'uploadURL' => Yii::getAlias('@web').'/upload',
	'access' => [
		'files' => [
			'upload' => true,
			'delete' => false,
			'copy' => false,
			'move' => false,
			'rename' => false,
		],
		'dirs' => [
			'create' => true,
			'delete' => false,
			'rename' => false,
		],
	],
]);

// Set kcfinder session options
Yii::$app->session->set('KCFINDER', $kcfOptions);

统计信息

  • 总下载量: 10
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 22
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固