2017 © Pedro Peláez
 

library yii2-ueditor-widget

yii2-ueditor-widget

image

lxpgw/yii2-ueditor-widget

yii2-ueditor-widget

  • Saturday, October 10, 2015
  • by light
  • Repository
  • 1 Watchers
  • 0 Stars
  • 7 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 10 Forks
  • 0 Open issues
  • 12 Versions
  • 0 % Grown

The README.md

yii2-ueditor-widget

composer.json

"require": {
        "xj/yii2-ueditor-widget": "*"
},

example:

username, [
    'id' => Html::getInputId($model, 'username'),
    'name' => Html::getInputName($model, 'username'),
    'type' => 'text/plain',
]);
echo Ueditor::widget([
    'model' => $model,
    'attribute' => 'username',
    'renderTag' => false,
    'jsOptions' => [
        'serverUrl' => common\helpers\Url::to(['upload']),
        'autoHeightEnable' => true,
        'autoFloatEnable' => true
    ],
]);
?>


 $model,
    'attribute' => 'password',
    'name' => 'customName',
    'value' => 'content',
    'style' => 'width:100%;height:400px',
    'renderTag' => true,
    'readyEvent' => 'console.log("example2 ready")',
    'jsOptions' => [
        'serverUrl' => yii\helpers\Url::to(['upload']),
        'autoHeightEnable' => true,
        'autoFloatEnable' => true
    ],
]);
?>

Action:

public function actions() {
return [
    'upload' => [
        'class' => \xj\ueditor\actions\Upload::className(),
        'uploadBasePath' => '@webroot', //file system path
        'uploadBaseUrl' => '@web', //web path
    'csrf' => true, //csrf校验
        'configPatch' => [
            'imageMaxSize' => 500 * 1024, //图片
            'scrawlMaxSize' => 500 * 1024, //涂鸦
            'catcherMaxSize' => 500 * 1024, //远程
            'videoMaxSize' => 1024 * 1024, //视频
            'fileMaxSize' => 1024 * 1024, //文件
            'imageManagerListPath' => '/', //图片列表
            'fileManagerListPath' => '/', //文件列表
        ],
        // OR Closure
        'pathFormat' => [
            'imagePathFormat' => 'image/{yyyy}{mm}{dd}/{time}{rand:6}',
            'scrawlPathFormat' => 'image/{yyyy}{mm}{dd}/{time}{rand:6}',
            'snapscreenPathFormat' => 'image/{yyyy}{mm}{dd}/{time}{rand:6}',
            'snapscreenPathFormat' => 'image/{yyyy}{mm}{dd}/{time}{rand:6}',
            'catcherPathFormat' => 'image/{yyyy}{mm}{dd}/{time}{rand:6}',
            'videoPathFormat' => 'video/{yyyy}{mm}{dd}/{time}{rand:6}',
            'filePathFormat' => 'file/{yyyy}{mm}{dd}/{time}{rand:6}',
        ],

        // For Closure
        'pathFormat' => [
            'imagePathFormat' => [$this, 'format'],
            'scrawlPathFormat' => [$this, 'format'],
            'snapscreenPathFormat' => [$this, 'format'],
            'snapscreenPathFormat' => [$this, 'format'],
            'catcherPathFormat' => [$this, 'format'],
            'videoPathFormat' => [$this, 'format'],
            'filePathFormat' => [$this, 'format'],
        ],

        'beforeUpload' => function($action) {
//          throw new \yii\base\Exception('error message'); //break
        },
        'afterUpload' => function($action) {
            /*@var $action \xj\ueditor\actions\Upload */

            var_dump($action->result);
            //  'state' => string 'SUCCESS' (length=7)
            //  'url' => string '/attachment/201109/1425310269294251.jpg' (length=61)
            //  'relativePath' => string '201109/1425310269294251.jpg' ()
            //  'title' => string '1425310269294251.jpg' (length=20)
            //  'original' => string 'Chrysanthemum.jpg' (length=17)
            //  'type' => string '.jpg' (length=4)
            //  'size' => int 879394

            throw new \yii\base\Exception('error message'); //break
        },
    ],
];
}

// for Closure Format
public function format(\xj\ueditor\actions\Uploader $action) {
    $fileext = $action->fileType;
    $filehash = sha1(uniqid() . time());
    $p1 = substr($filehash, 0, 2);
    $p2 = substr($filehash, 2, 2);
    return "{$p1}/{$p2}/{$filehash}.{$fileext}";
}

The Versions

10/10 2015

dev-master

9999999-dev

yii2-ueditor-widget

  Sources   Download

BSD-3-Clause

The Requires

 

by Avatar xjflyttp

10/10 2015

1.0.10

1.0.10.0

yii2-ueditor-widget

  Sources   Download

BSD-3-Clause

The Requires

 

by Avatar xjflyttp

10/10 2015

1.0.9

1.0.9.0

yii2-ueditor-widget

  Sources   Download

BSD-3-Clause

The Requires

 

by Avatar xjflyttp

11/05 2015

1.0.8

1.0.8.0

yii2-ueditor-widget

  Sources   Download

BSD-3-Clause

The Requires

 

by Avatar xjflyttp

18/03 2015

1.0.7

1.0.7.0

yii2-ueditor-widget

  Sources   Download

BSD-3-Clause

The Requires

 

by Avatar xjflyttp

06/03 2015

1.0.6

1.0.6.0

yii2-ueditor-widget

  Sources   Download

BSD-3-Clause

The Requires

 

by Avatar xjflyttp

02/03 2015

1.0.5

1.0.5.0

yii2-ueditor-widget

  Sources   Download

BSD-3-Clause

The Requires

 

by Avatar xjflyttp

27/01 2015

1.0.4

1.0.4.0

yii2-ueditor-widget

  Sources   Download

BSD-3-Clause

The Requires

 

by Avatar xjflyttp

07/08 2014

1.0.3

1.0.3.0

yii2-ueditor-widget

  Sources   Download

BSD-3-Clause

The Requires

 

by Avatar xjflyttp

21/07 2014

1.0.2

1.0.2.0

yii2-ueditor-widget

  Sources   Download

BSD-3-Clause

The Requires

  • xj/ueditor *

 

by Avatar xjflyttp

20/07 2014

1.0.1

1.0.1.0

yii2-ueditor-widget

  Sources   Download

BSD-3-Clause

The Requires

  • xj/ueditor *

 

by Avatar xjflyttp

28/05 2014

1.0.0

1.0.0.0

yii2-ueditor-widget

  Sources   Download

BSD-3-Clause

The Requires

  • xj/ueditor *

 

by Avatar xjflyttp