bastarann / yii2kcfinder
KCFinder for Yii2
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- iutbay/yii2-fontawesome: dev-master
- sunhater/kcfinder: *
- yiisoft/yii2-bootstrap: *
- yiisoft/yii2-jui: *
This package is not auto-updated.
Last update: 2024-12-21 20:24:51 UTC
README
KCFinder for Yii2.
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 "bastarann/yii2kcfinder" "*"
or add
"bastarann/yii2kcfinder" : "*"
to the require section of your application's composer.json
file.
Widget Use
Without model :
use bastarann\yii2kcfinder\KCFinderInputWidget; echo KCFinderInputWidget::widget([ 'name' => 'image', ]);
With model and ActiveForm :
use bastarann\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 bastarann\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);