public function actionIndex() { $action = Yii::app()->request->getParam('action'); $size = Yii::app()->request->getParam('size'); $start = Yii::app()->request->getParam('start'); $callback = Yii::app()->request->getParam('callback'); $ueditor = new UEditor($action, $size, $start, $callback); echo $ueditor->executeUEditor(); }
/** * 获取编辑器 * * @access public * @param string $fname 表单名称 * @param string $fvalue 表单值 * @param string $nheight 内容高度 * @param string $etype 编辑器类型 * @param string $gtype 获取值类型 * @param string $isfullpage 是否全屏 * @return string */ public static function getEditor($fname, $fvalue, $nwidth = "700", $nheight = "350", $etype = "Sline", $ptype = '', $gtype = "print", $jsEditor = false) { require DOCROOT . '/public/vendor/slineeditor/ueditor.php'; $UEditor = new UEditor(); $UEditor->basePath = $GLOBALS['cfg_cmspath'] . 'public/vendor/slineeditor/'; $nheight = $nheight == 400 ? 300 : $nheight; $config = $events = array(); $GLOBALS['tools'] = empty($toolbar[$etype]) ? $GLOBALS['tools'] : $toolbar[$etype]; $config['toolbars'] = $GLOBALS['tools']; $config['minFrameHeight'] = $nheight; $config['initialFrameHeight'] = $nheight; $config['initialFrameWidth'] = $nwidth; $config['autoHeightEnabled'] = false; if (!$jsEditor) { $code = $UEditor->editor($fname, $fvalue, $config, $events); } else { $code = $UEditor->jseditor($fname, $fvalue, $config, $events); } if ($gtype == "print") { echo $code; } else { return $code; } }
<?php use yii\helpers\Html; use yii\bootstrap\ActiveForm; /* @var $this yii\web\View */ $this->title = 'My Yii Application'; use macle\ueditor\Ueditor; //echo Ueditor::widget(['id'=>"newstext"]); //echo \kucha\ueditor\UEditor::widget([]); echo UEditor::widget(['events' => ['initialFrameHeight' => '200', 'lang' => 'en', 'toolbars' => [['fullscreen', 'source', 'undo', 'redo', '|', 'fontsize', 'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', '|', 'lineheight', '|', 'indent', '|']]]]); ?> <?php $form = ActiveForm::begin(['id' => 'form-signup', 'options' => ['enctype' => 'multipart/form-data']]); ?> <?php echo $form->field($model, 'img'); ?> <?php echo $form->field($model, 'desc')->widget('macle\\ueditor\\Ueditor', ['id' => 'Test[desc]']); ?> <div class="form-group"> <?php echo Html::submitButton('Signup', ['class' => 'btn btn-primary', 'name' => 'signup-button']); ?> </div> <?php ActiveForm::end(); ?>