phamxuanloc / yii2-roxymce
将 tinymce + roxy manager 集成到 yii2
1.0.4.1
2016-05-06 06:19 UTC
Requires
- ext-gd: *
- ext-mbstring: *
- ext-zip: *
- bower-asset/fontawesome: ^4.0
- bower-asset/jquery-dateformat: ^1.0
- bower-asset/tinymce-dist: ^4.3
- navatech/yii2-navatech-base: @dev
This package is not auto-updated.
Last update: 2024-09-25 15:06:12 UTC
README
此插件允许将 TinyMce 4 集成到 Roxy Fileman
用户故事
我一直在寻找一个好的 tinymce 文件管理器。
elFinder 很好,但功能太多,不符合我的风格。MoxieManager 可能与 tinymce 最佳搭配,但对我来说功能太多。
有一天,我看到了 roxyman,立刻就知道这就是我需要的。
安装
推荐通过 composer 安装此扩展
运行以下命令
composer require phamxuanloc/yii2-roxymce "@dev"
或者在 composer.json
的 require
部分添加,然后运行 composer update
"phamxuanloc/yii2-roxymce" : "@dev"
配置
只需将以下内容添加到 config/web.php
简单配置
[php]
'modules' => [
'roxymce' => [
'class' => '\phamxuanloc\roxymce\Module',
]
]
高级配置
[php]
'modules' => [
'roxymce' => [
'class' => '\phamxuanloc\roxymce\Module',
'config'=> [
//all below is not required
'FILES_ROOT' => 'uploads/image', //The root directory of roxymce's resource, where can be uploaded to. if not existed, Roxy will auto create
'DEFAULTVIEW' => 'list', //default view when you call roxymce (thumb/list)
'THUMBS_VIEW_WIDTH' => '100', //default width of thumbs when thumb view activated
'THUMBS_VIEW_HEIGHT' => '100', //default height of thumbs when thumb view activated
'MAX_IMAGE_WIDTH' => '1000', //default maximum width of image allowed to upload
'MAX_IMAGE_HEIGHT' => '1000', //default maximum height of image allowed to upload
'FORBIDDEN_UPLOADS' => 'zip js jsp jsb mhtml mht xhtml xht php phtml php3 php4 php5 phps shtml jhtml pl sh py cgi exe application gadget hta cpl msc jar vb jse ws wsf wsc wsh ps1 ps2 psc1 psc2 msh msh1 msh2 inf reg scf msp scr dll msi vbs bat com pif cmd vxd cpl htpasswd htaccess', //default forbidden upload files extension
'ALLOWED_UPLOADS' => 'jpeg jpg png gif mov mp3 mp4 avi wmv flv mpeg', //default allowed upload files extension
'FILEPERMISSIONS' => '0644', //default file permissions
'DIRPERMISSIONS' => '0755', //default folder permissions
'LANG' => 'en', //fix language interface. if NOT SET, language interface will auto follow Yii::$app->language
'DATEFORMAT' => 'dd/MM/yyyy HH:mm', //default datetime format
'OPEN_LAST_DIR' => 'yes', //default roxymce will open last dir where you leave
]
],
],
使用方法
在视图文件中调用 roxymce 小部件
包含 ActiveRecord 模型
[php]
//example in action create
$model = new Post();
//example in action update
$model = Post::findOne(['id' => 1]);
echo \phamxuanloc\roxymce\widgets\RoxyMceWidget::widget([
'model' => $model, //your Model, REQUIRED
'attribute' => 'content', //attribute name of your model, REQUIRED if using 'model' section
'name' => 'Post[content]', //default name of textarea which will be auto generated, NOT REQUIRED if using 'model' section
'value' => isset($_POST['Post']['content']) ? $_POST['Post']['content'] : $model->content, //default value of current textarea, NOT REQUIRED
'action' => Url::to(['roxymce/default']), //default roxymce action route, NOT REQUIRED
'options' => [//TinyMce options, NOT REQUIRED, see https://www.tinymce.com/docs/
'title' => 'RoxyMCE',//title of roxymce dialog, NOT REQUIRED
],
'htmlOptions' => [],//html options of this widget, NOT REQUIRED
]);
无 ActiveRecord 模型的示例 HTML
[php]
echo \phamxuanloc\roxymce\widgets\RoxyMceWidget::widget([
'name' => 'content', //default name of textarea which will be auto generated, REQUIRED if not using 'model' section
'value' => isset($_POST['content']) ? $_POST['content'] : '', //default value of current textarea, NOT REQUIRED
'action' => Url::to(['roxymce/default']), //default roxymce action route, NOT REQUIRED
'options' => [//TinyMce options, NOT REQUIRED, see https://www.tinymce.com/docs/
'title' => 'RoxyMCE',//title of roxymce dialog, NOT REQUIRED
],
'htmlOptions' => [],//html options of this widget, NOT REQUIRED
]);
示例 HTML 输入演示
[php]
use yii\bootstrap\Modal;
Modal::begin([
'header' => '<h2>Hello world</h2>',
'size' => Modal::SIZE_LARGE,
'id' => "modal"
//'toggleButton' => ['label' => 'click me'],
]);
echo "<div id='modalContent'><iframe width='100%' height='470px' src='".Url::to(['roxymce/default', 'type' => 'image', 'input' => 'filepath','modal'=>'modal','tabindex'=>-1,])."'></iframe></div>";
Modal::end();
[html]
<input type="text" id="filepath"/>
<a href="#" onclick="return demoPopup();">Choose Picture</a>
[javascript]
<script type="text/javascript">
function demoPopup() {
$('#modal').modal('show');
return false;
}
</script>
截图 & 演示
演示
请参考RoxyFileMan 演示并滚动到 TinyMce 部分