定制 drmabuse/yii2-sir-trevor-js 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

drmabuse/yii2-sir-trevor-js

Composer 安装命令:

composer require drmabuse/yii2-sir-trevor-js

包简介

Yii 2 Sir Trevor JS widget

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License

Version 0.0.5

a sir-trevor-js module

Sir Trevor in action

Browser support

Sir Trevor is only tested on the following modern browsers:

  • IE10+
  • Chrome 25+
  • Safari 5+
  • Firefox 16+

Dependencies

Sir Trevor requires Underscore (or LoDash), jQuery (or Zepto) and Eventable.

Contributing

See the roadmap and read a little about the philosophy guiding development.

Todo

1. create output from Input

Get Started

Installation using composer:

composer install drmabuse/yii2-sir-trevor-js:"*"

Basic Usage

<?=
$form->field(
    $model,
    'attributeName')->widget(\drmabuse\sirtrevorjs\SirTrevorWidget::className(),
    [
        'imageUploadUrl' => \yii\helpers\Url::to(['file/sir-trevor-upload']),
        'language'      => 'de',//es,fi,pt,fr,de,cn,
        'assetMode'     => 'min'//dev,
        'element'       => '.sir-trevor'// wil add to the textarea,
        'initJs'        => 'SirTrevor....'//PLZ read before Sir Trevor Api
        'options'       => ['class' => 'mysexyTextarea'],
        'blockOptions'  => Json::encode(
             [
                'el'          => new JsExpression("$('.sir-trevor')"),
                'blockTypes'  => [
                     "Heading",
                     "Text",
                     "List",
                     "Quote",
                     "Image",
                     "Video",
                     "Tweet",
                     "Columns",
                     "Code",
                     "Gallery"
                 ],
                'defaultType' => false
            ]
        )
    ]   
)
?>
//Output
<?php
    use drmabuse\sirtrevorjs\SirTrevorConverter;
    $converter = new SirTrevorConverter();
?>
<?= $converter->toHtml($json) ?>

Advanced Usage

Image Block - Example File Upload Handler

/**
     * Action for file uploads via sir-trevor image block from SirTrevorWidget (input widget)
     *
     * @param $root relative base folder
     */
    public function actionSirTrevorUpload($root)
    {
        $upload         = UploadedFile::getInstanceByName('attachment[file]');
        $model          = new File();
        $name_id        = Inflector::slug(str_replace($upload->extension, '', $upload->name));
        $model->path    = 'images/' . $root . '/' . $model->name_id . '.' . $upload->extension;
        $savePath       = \Yii::getAlias('@backend/web') . '/' . $model->path;
        
        $response = new Response();
        $response->format = Response::FORMAT_JSON;
        $response->data['message'] = "File";
        
        if (!is_file($savePath) && is_dir(dirname($savePath))) {
            if ($upload->saveAs($model->path)) {
                $model->mime_type = FileHelper::getMimeType($model->path);
                $model->file_size = $upload->size;
                if ($model->save()) {
                    $items = $this->getItems($this->rootPath);
                    list($width, $height, $type, $attr) = getimagesize($model->path);
                    $response->setStatusCode(200);
                    $response->content = Json::encode(['file' => ['url' => $model->path]]);
                    \Yii::$app->end(0, $response);
                } else {
                    $response->statusText = "Database record could not be saved.";
                }
            } else {
                $response->statusText = "File could not be saved.";
            }
        }else{
            $response->statusText = "File exists or root folder '{$savePath}' not found.";
        }

        $response->setStatusCode(500);
        \Yii::$app->end(0, $response);

    }

Developer Info

If you want to compile/build from the latest javascript sources, use the following commands to get the JavaScript dependencies.

npm update
bower update

To create the asset files run

grunt default

To create a new version

grunt bumpup
grunt semantic

drmabuse/yii2-sir-trevor-js 适用场景与选型建议

drmabuse/yii2-sir-trevor-js 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 5.5k 次下载、GitHub Stars 达 15, 最近一次更新时间为 2014 年 05 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「yii2」 「sir trevor js」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 drmabuse/yii2-sir-trevor-js 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 drmabuse/yii2-sir-trevor-js 我们能提供哪些服务?
定制开发 / 二次开发

基于 drmabuse/yii2-sir-trevor-js 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 5.5k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 15
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 15
  • Watchers: 5
  • Forks: 9
  • 开发语言: JavaScript

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2014-05-04