rob006 / yii-elfinder2
为 Yii 1.1 集成的 elFinder 2.1
1.1.7
2024-01-10 11:19 UTC
Requires
- php: ^5.4 || ^7.0 || ^8.0
- yiisoft/yii: ~1.1.18
Requires (Dev)
- rob006/yii-tinymce: ^1.0 | ^2.0
Suggests
- rob006/yii-tinymce: Provides WYSIWYG editor integration.
Replaces
- studio-42/elfinder: 2.1.64
README
基于 https://bitbucket.org/z_bodya/yii-elfinder,更新了 elFinder 并进行了一些代码改进。
如何使用
-
将源代码检出到您的项目中以扩展 ext.elFinder。您可以使用自定义的 elFinder 代码,只需将
elFindervendor
别名设置为指向您的 elFinder 代码目录。'aliases' => [ 'elFindervendor' => 'vendor.myCystomElFinder', ],
您可以从 https://github.com/Studio-42/elFinder/releases 获取 elFinder - 记得将
css
、img
、js
和sounds
目录移动到assets
目录,以便 elFinder 源代码看起来像 -
为连接器操作创建控制器,并配置其参数
class ElfinderController extends Controller { // don't forget configure access rules public function actions() { return [ // main action for elFinder connector 'connector' => [ 'class' => 'ext.elFinder.ElFinderConnectorAction', // elFinder connector configuration // https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options 'settings' => [ 'roots' => [ [ 'driver' => 'LocalFileSystem', 'path' => Yii::getPathOfAlias('webroot') . '/files/', 'URL' => Yii::app()->baseUrl . '/files/', 'alias' => 'Root Alias', 'acceptedName' => '/^[^\.].*$/', // disable creating dotfiles 'attributes' => [ [ 'pattern' => '/\/[.].*$/', // hide dotfiles 'read' => false, 'write' => false, 'hidden' => true, ], ], ], ], ], ], // action for TinyMCE popup with elFinder widget 'elfinderTinyMce' => [ 'class' => 'ext.elFinder.TinyMceElFinderPopupAction', 'connectorRoute' => 'connector', // main connector action id ], // action for file input popup with elFinder widget 'elfinderFileInput' => [ 'class' => 'ext.elFinder.ServerFileInputElFinderPopupAction', 'connectorRoute' => 'connector', // main connector action id ], ]; } }
-
ServerFileInput - 使用此小部件通过 elFinder 弹出窗口在服务器上选择文件
$this->widget('ext.elFinder.ServerFileInput', [ 'model' => $model, 'attribute' => 'field_name', 'popupConnectorRoute' => 'elfinder/elfinderFileInput', // relative route for file input action // ability to customize "Browse" button // 'customButton' => CHtml::button('Browse images', [ // 'id' => CHtml::getIdByName(CHtml::activeName($model, 'field_name')) . 'browse', // 'class' => 'btn', 'style' => 'margin-left:10px', // ]), // title for popup window (optional) 'popupTitle' => 'Files', ]);
-
ElFinderWidget - 使用此小部件管理文件
$this->widget('ext.elFinder.ElFinderWidget', [ 'connectorRoute' => 'elfinder/connector', // relative route for elFinder connector action ]);
-
TinyMceElFinder - 使用此小部件将 elFinder 集成到 yii-tinymce
$this->widget('ext.tinymce.TinyMce', [ 'model' => $model, 'attribute' => 'content', 'fileManager' => [ 'class' => 'ext.elFinder.TinyMceElFinder', 'popupConnectorRoute' => 'elfinder/elfinderTinyMce', // relative route for TinyMCE popup action // title for popup window (optional) 'popupTitle' => 'Files', ], ]);