ElFinder β ΡΠ°ΠΉΠ»ΠΎΠ²ΡΠΉ ΠΌΠ΅Π½Π΅Π΄ΠΆΠ΅Ρ Π΄Π»Ρ ΡΠ°ΠΉΡΠ°.
mihaildev/yii2-elfinder-flysystem - https://github.com/MihailDev/yii2-elfinder-flysystem/
Local
Azure
AWS S3 V2
AWS S3 V3
Copy.com
Dropbox
FTP
GridFS
Memory
Null / Test
Rackspace
ReplicateAdapter
SFTP
WebDAV
PHPCR
ZipArchive
Π£Π΄ΠΎΠ±Π½Π΅Π΅ Π²ΡΠ΅Π³ΠΎ ΡΡΡΠ°Π½ΠΎΠ²ΠΈΡΡ ΡΡΠΎ ΡΠ°ΡΡΠΈΡΠ΅Π½ΠΈΠ΅ ΡΠ΅ΡΠ΅Π· composer.
ΠΠΈΠ±ΠΎ Π·Π°ΠΏΡΡΡΠΈΡΡ
php composer.phar require --prefer-dist mihaildev/yii2-elfinder "*"
ΠΈΠ»ΠΈ Π΄ΠΎΠ±Π°Π²ΠΈΡΡ
"mihaildev/yii2-elfinder": "*"
Π² ΡΠ°Π·Π΄Π΅Π»Π΅ require
Π²Π°ΡΠ΅Π³ΠΎ composer.json ΡΠ°ΠΉΠ»Π°.
'controllerMap' => [
'elfinder' => [
'class' => 'mihaildev\elfinder\Controller',
'access' => ['@'], //Π³Π»ΠΎΠ±Π°Π»ΡΠ½ΡΠΉ Π΄ΠΎΡΡΡΠΏ ΠΊ ΡΠ°ΠΈΠ» ΠΌΠ΅Π½Π΅Π΄ΠΆΠ΅ΡΡ @ - Π΄Π»Ρ Π°Π²ΡΠΎΡΠΈΠ·ΠΎΡΠΎΠ²Π°Π½Π½ΡΡ
, ? - Π΄Π»Ρ Π³ΠΎΡΡΠ΅ΠΉ , ΡΡΠΎΠ± ΠΎΡΠΊΡΡΡΡ Π²ΡΠ΅ΠΌ ['@', '?']
'disabledCommands' => ['netmount'], //ΠΎΡΠΊΠ»ΡΡΠ΅Π½ΠΈΠ΅ Π½Π΅Π½ΡΠΆΠ½ΡΡ
ΠΊΠΎΠΌΠ°Π½Π΄ https://github.com/Studio-42/elFinder/wiki/Client-configuration-options#commands
'roots' => [
[
'baseUrl'=>'@web',
'basePath'=>'@webroot',
'path' => 'files/global',
'name' => 'Global'
],
[
'class' => 'mihaildev\elfinder\volume\UserPath',
'path' => 'files/user_{id}',
'name' => 'My Documents'
],
[
'path' => 'files/some',
'name' => ['category' => 'my','message' => 'Some Name'] //ΠΏΠ΅ΡΠ΅Π²ΠΎΠ΄ Yii::t($category, $message)
],
[
'path' => 'files/some',
'name' => ['category' => 'my','message' => 'Some Name'], // Yii::t($category, $message)
'access' => ['read' => '*', 'write' => 'UserFilesAccess'] // * - Π΄Π»Ρ Π²ΡΠ΅Ρ
, ΠΈΠ½Π°ΡΠ΅ ΠΏΡΠΎΠ²Π΅ΡΠΊΠ° Π΄ΠΎΡΡΡΠΏΠ° Π² Π΄Π°Π°Π°Π½ΠΎΠΌ ΠΏΡΠΈΠΌΠ΅ΡΠ΅ Π²ΡΠ΅ ΠΌΠΎΠ³ΡΡ Π²ΠΈΠ΄Π΅Ρ Π° ΡΠ΅Π΄Π°ΠΊΡΠΈΡΠΎΠ²Π°ΡΡ ΠΌΠΎΠ³ΡΡ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»ΠΈ ΡΠΎΠ»ΡΠΊΠΎ Ρ ΠΏΡΠ°Π²Π°ΠΌΠΈ UserFilesAccess
]
],
'watermark' => [
'source' => __DIR__.'/logo.png', // Path to Water mark image
'marginRight' => 5, // Margin right pixel
'marginBottom' => 5, // Margin bottom pixel
'quality' => 95, // JPEG image save quality
'transparency' => 70, // Water mark image transparency ( other than PNG )
'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field )
'targetMinPixel' => 200 // Target image minimum pixel size
]
]
],
'controllerMap' => [
'elfinder' => [
'class' => 'mihaildev\elfinder\PathController',
'access' => ['@'],
'root' => [
'path' => 'files',
'name' => 'Files'
],
'watermark' => [
'source' => __DIR__.'/logo.png', // Path to Water mark image
'marginRight' => 5, // Margin right pixel
'marginBottom' => 5, // Margin bottom pixel
'quality' => 95, // JPEG image save quality
'transparency' => 70, // Water mark image transparency ( other than PNG )
'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field )
'targetMinPixel' => 200 // Target image minimum pixel size
]
]
],
Π Π°Π·Π½ΠΈΡΠ° ΠΌΠ΅ΠΆΠ΄Ρ PathController ΠΈ Controller Π² ΡΠΎΠΌ ΡΡΠΎ PathController ΡΠ°Π±ΠΎΡΠ°Π΅Ρ ΡΠΎΠ»ΡΠΊΠΎ Ρ ΠΎΠ΄Π½ΠΎΠΉ ΠΏΠ°ΠΏΠΊΠΎΠΉ ΡΠ°ΠΊΠΆΠ΅ ΠΈΠΌΠ΅Π΅Ρ Π΄ΠΎΠΏ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡΡ ΠΏΠ΅ΡΠ΅Π΄Π°ΡΡ Π² Π·Π°ΠΏΡΠΎΡΠ΅ Π½Π° ΠΎΡΠΊΡΡΡΠΈΠ΅ ΠΏΠΎΠ΄ Π΄Π΅ΡΠΈΡΠΎΡΠΈΠΈ
ΠΠ° Π΄Π°Π½Π½ΡΠΉ ΠΌΠΎΠΌΠ΅Π½Ρ ΡΠ΅Π°Π»ΠΈΠ·ΠΎΠ²Π°Π½Π½ΠΎ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠ΅ ΡΠΎΠ»ΡΠΊΠΎ LocalFileSystem Ρ ΡΠ°Π½ΠΈΠ»ΠΈΡΠ° (mihaildev\elfinder\volume\Local ΠΈ mihaildev\elfinder\volume\UserPath) Π΄Π»Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΡ ΠΎΡΡΠ°Π»ΡΠ½ΡΡ Π²Π°ΠΌ ΠΏΡΠΈΠΉΠ΄ΡΡΡΡ Π²ΡΡ Π½Π°ΡΡΡΠ°ΠΈΠ²Π°ΡΡ ΡΠ΅ΡΠ΅Π· mihaildev\elfinder\volume\Base ΡΠ°ΠΊΠΆΠ΅ Π΄ΠΎΠ±Π°Π²Π»Π΅Π½Π½ΠΎ ΡΠ°ΡΡΠΈΡΠ΅Π½ΠΈΠ΅ https://github.com/MihailDev/yii2-elfinder-flysystem/ ΡΡΠΎ Π΄ΠΎΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ ΠΈΠ½ΡΠ΅Π³ΡΠΈΡΠΎΠ²Π°ΡΡ Flysystem Ρ ΡΠ°Π½ΠΈΠ»ΠΈΡΠ° ΡΠ°ΠΊΠΈΠ΅ ΠΊΠ°ΠΊ Local Azure AWS S3 V2 AWS S3 V3 Copy.com Dropbox FTP GridFS Memory Null / Test Rackspace ReplicateAdapter SFTP WebDAV PHPCR ZipArchive
'controllerMap' => [
'elfinder' => [
...
'managerOptions' => [
...
'handlers' => [
'select' => 'function(event, elfinderInstance) {
console.log(event.data);
console.log(event.data.selected);
}',
'open' => 'function(event, elfinderInstance) {...}',
],
...
],
...
]
],
ΡΠΏΠΈΡΠΎΠΊ ΡΠΎΠ±ΡΡΠΈΠΉ - https://github.com/Studio-42/elFinder/wiki/Client-event-API#event-list
ΠΠ·Π·Π° ΡΠ»ΠΎΠΆΠ½ΠΎΠΉ Π½Π°ΡΡΡΠΎΠΉΠΊΠΈ Π±ΡΠ»Π° ΠΏΠ΅ΡΠ΅Π΄Π΅Π»Π°Π½Π½Π° ΡΠ°Π±ΠΎΡΠ° ΠΏΠ»Π°Π³ΠΈΠ½ΠΎΠ² Π½ΠΎ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡΡ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΡΡΠ°ΡΡΠ΅ ΠΏΠ»Π°Π³ΠΈΠ½Ρ ΠΏΡΠΈΡΡΡΡΡΠ²ΡΠ΅Ρ
'controllerMap' => [
'elfinder' => [
'class' => 'mihaildev\elfinder\Controller',
//'plugin' => ['\mihaildev\elfinder\plugin\Sluggable'],
'plugin' => [
[
'class'=>'\mihaildev\elfinder\plugin\Sluggable',
'lowercase' => true,
'replacement' => '-'
]
],
'roots' => [
[
'baseUrl'=>'@web',
'basePath'=>'@webroot',
'path' => 'files/global',
'name' => 'Global',
'plugin' => [
'Sluggable' => [
'lowercase' => false,
]
]
],
]
ΠΠ°ΡΡΡΠΎΠΉΠΊΠ° ΡΡΠ°ΡΠΎΠ³ΠΎ ΠΏΠ»Π°Π³ΠΈΠ½Π° (Π½Π° ΠΏΡΠΈΠΌΠ΅ΡΠ΅ ΠΏΠ»Π°Π³ΠΈΠ½Π° Sanitizer)
'controllerMap' => [
'elfinder' => [
'class' => 'mihaildev\elfinder\Controller',
'connectOptions' => [
'bind' => [
'upload.pre mkdir.pre mkfile.pre rename.pre archive.pre ls.pre' => array(
'Plugin.Sanitizer.cmdPreprocess'
),
'ls' => array(
'Plugin.Sanitizer.cmdPostprocess'
),
'upload.presave' => array(
'Plugin.Sanitizer.onUpLoadPreSave'
)
],
'plugin' => [
'Sanitizer' => array(
'enable' => true,
'targets' => array('\\','/',':','*','?','"','<','>','|'), // target chars
'replace' => '_' // replace to this
)
],
],
'roots' => [
[
'baseUrl'=>'@web',
'basePath'=>'@webroot',
'path' => 'files/global',
'name' => 'Global',
'plugin' => [
'Sanitizer' => array(
'enable' => true,
'targets' => array('\\','/',':','*','?','"','<','>','|'), // target chars
'replace' => '_' // replace to this
)
]
],
]
use mihaildev\elfinder\InputFile;
use mihaildev\elfinder\ElFinder;
use yii\web\JsExpression;
echo InputFile::widget([
'language' => 'ru',
'controller' => 'elfinder', // Π²ΡΡΠ°Π²Π»ΡΠ΅ΠΌ Π½Π°Π·Π²Π°Π½ΠΈΠ΅ ΠΊΠΎΠ½ΡΡΠΎΠ»Π»Π΅ΡΠ°, ΠΏΠΎ ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ ΡΠ°Π²Π΅Π½ elfinder
'filter' => 'image', // ΡΠΈΠ»ΡΡΡ ΡΠ°ΠΉΠ»ΠΎΠ², ΠΌΠΎΠΆΠ½ΠΎ Π·Π°Π΄Π°ΡΡ ΠΌΠ°ΡΡΠΈΠ² ΡΠΈΠ»ΡΡΡΠΎΠ² https://github.com/Studio-42/elFinder/wiki/Client-configuration-options#wiki-onlyMimes
'name' => 'myinput',
'value' => '',
]);
echo $form->field($model, 'attribute')->widget(InputFile::className(), [
'language' => 'ru',
'controller' => 'elfinder', // Π²ΡΡΠ°Π²Π»ΡΠ΅ΠΌ Π½Π°Π·Π²Π°Π½ΠΈΠ΅ ΠΊΠΎΠ½ΡΡΠΎΠ»Π»Π΅ΡΠ°, ΠΏΠΎ ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ ΡΠ°Π²Π΅Π½ elfinder
'filter' => 'image', // ΡΠΈΠ»ΡΡΡ ΡΠ°ΠΉΠ»ΠΎΠ², ΠΌΠΎΠΆΠ½ΠΎ Π·Π°Π΄Π°ΡΡ ΠΌΠ°ΡΡΠΈΠ² ΡΠΈΠ»ΡΡΡΠΎΠ² https://github.com/Studio-42/elFinder/wiki/Client-configuration-options#wiki-onlyMimes
'template' => '<div class="input-group">{input}<span class="input-group-btn">{button}</span></div>',
'options' => ['class' => 'form-control'],
'buttonOptions' => ['class' => 'btn btn-default'],
'multiple' => false // Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡΡ Π²ΡΠ±ΠΎΡΠ° Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΈΡ
ΡΠ°ΠΉΠ»ΠΎΠ²
]);
echo ElFinder::widget([
'language' => 'ru',
'controller' => 'elfinder', // Π²ΡΡΠ°Π²Π»ΡΠ΅ΠΌ Π½Π°Π·Π²Π°Π½ΠΈΠ΅ ΠΊΠΎΠ½ΡΡΠΎΠ»Π»Π΅ΡΠ°, ΠΏΠΎ ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ ΡΠ°Π²Π΅Π½ elfinder
'filter' => 'image', // ΡΠΈΠ»ΡΡΡ ΡΠ°ΠΉΠ»ΠΎΠ², ΠΌΠΎΠΆΠ½ΠΎ Π·Π°Π΄Π°ΡΡ ΠΌΠ°ΡΡΠΈΠ² ΡΠΈΠ»ΡΡΡΠΎΠ² https://github.com/Studio-42/elFinder/wiki/Client-configuration-options#wiki-onlyMimes
'callbackFunction' => new JsExpression('function(file, id){}') // id - id Π²ΠΈΠ΄ΠΆΠ΅ΡΠ°
]);
use mihaildev\elfinder\InputFile;
use mihaildev\elfinder\ElFinder;
use yii\web\JsExpression;
echo InputFile::widget([
'language' => 'ru',
'controller' => 'elfinder', // Π²ΡΡΠ°Π²Π»ΡΠ΅ΠΌ Π½Π°Π·Π²Π°Π½ΠΈΠ΅ ΠΊΠΎΠ½ΡΡΠΎΠ»Π»Π΅ΡΠ°, ΠΏΠΎ ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ ΡΠ°Π²Π΅Π½ elfinder
'path' => 'image', // Π±ΡΠ΄Π΅Ρ ΠΎΡΠΊΡΡΡΠ° ΠΏΠ°ΠΏΠΊΠ° ΠΈΠ· Π½Π°ΡΡΡΠΎΠ΅ΠΊ ΠΊΠΎΠ½ΡΡΠΎΠ»Π»Π΅ΡΠ° Ρ Π΄ΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠ΅ΠΌ ΡΠΊΠ°Π·Π°Π½Π½ΠΎΠΉ ΠΏΠΎΠ΄ Π΄Π΅ΡΠΈΡΠΎΡΠΈΠΈ
'filter' => 'image', // ΡΠΈΠ»ΡΡΡ ΡΠ°ΠΉΠ»ΠΎΠ², ΠΌΠΎΠΆΠ½ΠΎ Π·Π°Π΄Π°ΡΡ ΠΌΠ°ΡΡΠΈΠ² ΡΠΈΠ»ΡΡΡΠΎΠ² https://github.com/Studio-42/elFinder/wiki/Client-configuration-options#wiki-onlyMimes
'name' => 'myinput',
'value' => '',
]);
echo $form->field($model, 'attribute')->widget(InputFile::className(), [
'language' => 'ru',
'controller' => 'elfinder', // Π²ΡΡΠ°Π²Π»ΡΠ΅ΠΌ Π½Π°Π·Π²Π°Π½ΠΈΠ΅ ΠΊΠΎΠ½ΡΡΠΎΠ»Π»Π΅ΡΠ°, ΠΏΠΎ ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ ΡΠ°Π²Π΅Π½ elfinder
'path' => 'image', // Π±ΡΠ΄Π΅Ρ ΠΎΡΠΊΡΡΡΠ° ΠΏΠ°ΠΏΠΊΠ° ΠΈΠ· Π½Π°ΡΡΡΠΎΠ΅ΠΊ ΠΊΠΎΠ½ΡΡΠΎΠ»Π»Π΅ΡΠ° Ρ Π΄ΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠ΅ΠΌ ΡΠΊΠ°Π·Π°Π½Π½ΠΎΠΉ ΠΏΠΎΠ΄ Π΄Π΅ΡΠΈΡΠΎΡΠΈΠΈ
'filter' => 'image', // ΡΠΈΠ»ΡΡΡ ΡΠ°ΠΉΠ»ΠΎΠ², ΠΌΠΎΠΆΠ½ΠΎ Π·Π°Π΄Π°ΡΡ ΠΌΠ°ΡΡΠΈΠ² ΡΠΈΠ»ΡΡΡΠΎΠ² https://github.com/Studio-42/elFinder/wiki/Client-configuration-options#wiki-onlyMimes
'template' => '<div class="input-group">{input}<span class="input-group-btn">{button}</span></div>',
'options' => ['class' => 'form-control'],
'buttonOptions' => ['class' => 'btn btn-default'],
'multiple' => false // Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡΡ Π²ΡΠ±ΠΎΡΠ° Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΈΡ
ΡΠ°ΠΉΠ»ΠΎΠ²
]);
echo ElFinder::widget([
'language' => 'ru',
'controller' => 'elfinder', // Π²ΡΡΠ°Π²Π»ΡΠ΅ΠΌ Π½Π°Π·Π²Π°Π½ΠΈΠ΅ ΠΊΠΎΠ½ΡΡΠΎΠ»Π»Π΅ΡΠ°, ΠΏΠΎ ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ ΡΠ°Π²Π΅Π½ elfinder
'path' => 'image', // Π±ΡΠ΄Π΅Ρ ΠΎΡΠΊΡΡΡΠ° ΠΏΠ°ΠΏΠΊΠ° ΠΈΠ· Π½Π°ΡΡΡΠΎΠ΅ΠΊ ΠΊΠΎΠ½ΡΡΠΎΠ»Π»Π΅ΡΠ° Ρ Π΄ΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠ΅ΠΌ ΡΠΊΠ°Π·Π°Π½Π½ΠΎΠΉ ΠΏΠΎΠ΄ Π΄Π΅ΡΠΈΡΠΎΡΠΈΠΈ
'filter' => 'image', // ΡΠΈΠ»ΡΡΡ ΡΠ°ΠΉΠ»ΠΎΠ², ΠΌΠΎΠΆΠ½ΠΎ Π·Π°Π΄Π°ΡΡ ΠΌΠ°ΡΡΠΈΠ² ΡΠΈΠ»ΡΡΡΠΎΠ² https://github.com/Studio-42/elFinder/wiki/Client-configuration-options#wiki-onlyMimes
'callbackFunction' => new JsExpression('function(file, id){}') // id - id Π²ΠΈΠ΄ΠΆΠ΅ΡΠ°
]);
use mihaildev\elfinder\ElFinder;
$ckeditorOptions = ElFinder::ckeditorOptions($controller,[/* Some CKEditor Options */]);
ΠΠ»Ρ ΡΠΊΠ°Π·Π°Π½ΠΈΡ ΠΏΠΎΠ΄ΠΊΠ°ΡΠ°Π»ΠΎΠ³Π° (ΠΏΡΠΈ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠΈ PathController)
use mihaildev\elfinder\ElFinder;
$ckeditorOptions = ElFinder::ckeditorOptions([$controller, 'path' => 'some/sub/path'],[/* Some CKEditor Options */]);
ΠΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠ΅ ΡΠΎΠ²ΠΌΠ΅ΡΡΠ½ΠΎ Ρ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ΠΌ "mihaildev/yii2-ckeditor" (https://github.com/MihailDev/yii2-ckeditor)
use mihaildev\ckeditor\CKEditor;
use mihaildev\elfinder\ElFinder;
$form->field($model, 'attribute')->widget(CKEditor::className(), [
...
'editorOptions' => ElFinder::ckeditorOptions('elfinder',[/* Some CKEditor Options */]),
...
]);
ΠΠ»Ρ ΡΠΊΠ°Π·Π°Π½ΠΈΡ ΠΏΠΎΠ΄ΠΊΠ°ΡΠ°Π»ΠΎΠ³Π° (ΠΏΡΠΈ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠΈ PathController)
use mihaildev\ckeditor\CKEditor;
use mihaildev\elfinder\ElFinder;
$form->field($model, 'attribute')->widget(CKEditor::className(), [
...
'editorOptions' => ElFinder::ckeditorOptions(['elfinder', 'path' => 'some/sub/path'],[/* Some CKEditor Options */]),
...
]);
ΠΡΠΈ Π²ΡΡΡΠ°ΠΈΠ²Π°Π½ΠΈΠ΅ Π±Π΅Π· iframe Π²ΠΎΠ·ΠΌΠΎΠΆΠ΅Π½ ΠΊΠΎΠ½ΡΠ»ΠΈΠΊΡ Ρ bootstrap.js. Studio-42/elFinder#740 Π Π΅ΡΠ΅Π½ΠΈΠ΅ - Π΄ΠΎΠ±Π°Π²Π»ΡΠ΅ΠΌ Π² ΡΠ°Π±Π»ΠΎΠ½ Π·Π°ΠΏΠΈΡΡ
mihaildev\elfinder\Assets::noConflict($this);
ElFinder Wiki - https://github.com/Studio-42/elFinder/wiki
Flysystem
https://github.com/MihailDev/yii2-elfinder-flysystem/
https://github.com/barryvdh/elfinder-flysystem-driver