Exemplo n.º 1
1
 public function run()
 {
     parent::run();
     // Saves $id will be the id of the element that ckeditor will target
     list($name, $id) = $this->resolveNameID();
     // Publish assets to public directory
     $baseDir = dirname(__FILE__);
     $assets = Yii::app()->getAssetManager()->publish($baseDir . DIRECTORY_SEPARATOR . 'assets');
     $cs = Yii::app()->getClientScript();
     $cs->registerScriptFile($assets . '/ckeditor.js');
     echo CHtml::activeTextArea($this->model, $this->attribute, array('rows' => 10, 'cols' => 70));
     $this->options = array_merge(array('filebrowserBrowseUrl' => array('/backend/elfinderBrowse'), 'height' => '250px', 'allowedContent' => true), $this->options);
     $this->setConfig($this->options);
     $this->ECKE->replace($id, $this->_config);
 }
Exemplo n.º 2
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     Yii::import('bootstrap.behaviors.TbWidget');
     $this->attachBehavior('tbWidget', new TbWidget());
     if (!isset($this->assetPath)) {
         $this->assetPath = realpath(dirname(__FILE__) . '/../assets');
     }
     if (!$this->asDropDownList && !isset($this->pluginOptions['data'])) {
         $this->pluginOptions['data'] = $this->normalizeData($this->data);
     }
     if (isset($this->htmlOptions['placeholder'])) {
         if ($this->asDropDownList) {
             $this->htmlOptions['prompt'] = $this->htmlOptions['placeholder'];
         } else {
             $this->pluginOptions['placeholder'] = $this->htmlOptions['placeholder'];
         }
         unset($this->htmlOptions['placeholder']);
     }
     if (!$this->bindPlugin) {
         $this->htmlOptions['data-plugin'] = 'select2';
         $this->htmlOptions['data-plugin-options'] = CJSON::encode($this->pluginOptions);
     }
     if (TbArray::popValue('block', $this->htmlOptions, false)) {
         TbHtml::addCssClass('input-block-level', $this->htmlOptions);
     }
 }
Exemplo n.º 3
0
 public function init()
 {
     $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'source';
     $this->baseurl = Yii::app()->getAssetManager()->publish($dir);
     $this->kcFinderPath = $this->baseurl . "/kcfinder/";
     parent::init();
 }
Exemplo n.º 4
0
    public function run()
    {
        parent::run();
        list($name, $id) = $this->resolveNameID();
        $baseDir = dirname(__FILE__);
        $assets = Yii::app()->getAssetManager()->publish($baseDir . DIRECTORY_SEPARATOR . 'assets');
        $cs = Yii::app()->getClientScript();
        $cs->registerScriptFile($assets . '/ckeditor.js');
        $this->htmlOptions['id'] = $id;
        //        $this->htmlOptions['class'] = 'ckeditor';
        if (!array_key_exists('style', $this->htmlOptions)) {
            $this->htmlOptions['style'] = "width:{$this->width};height:{$this->height};";
        }
        if (!array_key_exists('cols', $this->htmlOptions)) {
            $this->htmlOptions['cols'] = self::COLS;
        }
        if (!array_key_exists('rows', $this->htmlOptions)) {
            $this->htmlOptions['rows'] = self::ROWS;
        }
        $options = $this->makeOptions();
        $js = <<<EOP
CKEDITOR.replace('{$name}',{$options});
EOP;
        $cs->registerScript('Yii.' . get_class($this) . '#' . $id, $js, CClientScript::POS_LOAD);
        if ($this->hasModel()) {
            $html = CHtml::activeTextArea($this->model, $this->attribute, $this->htmlOptions);
        } else {
            $html = CHtml::textArea($name, $this->value, $this->htmlOptions);
        }
        echo $html;
    }
Exemplo n.º 5
0
 public function init()
 {
     parent::init();
     if (empty($this->model) || empty($this->attribute)) {
         throw new Exception("Model and Attribute must be declared");
     }
 }
Exemplo n.º 6
0
 public function init()
 {
     list($this->name, $this->id) = $this->resolveNameID();
     //не стал делать сеттер, если хочешь допиши
     $this->attachBehaviors($this->behaviors());
     parent::init();
 }
Exemplo n.º 7
0
 public function init()
 {
     parent::init();
     list($name, $id) = $this->resolveNameID();
     $config = array("id" => $id, "height" => $this->height, "autogrow" => $this->autogrow);
     $js = 'window.setTimeout(function() { chive.initAce(' . json_encode($config) . '); }, 1000);';
     Yii::app()->clientScript->registerScript('Yii.AceEditor.' . $this->id, $js, CClientScript::POS_END);
 }
 /**
  * @throws \yii\base\InvalidConfigException
  */
 public function init()
 {
     parent::init();
     $this->options['class'] = $this->el;
     Yii::setAlias('@sirtrevorjs', dirname(__FILE__) . DIRECTORY_SEPARATOR . '..');
     $this->registerAsset();
     echo $this->renderInput();
 }
 public function init()
 {
     parent::init();
     Yii::import('bootstrap.behaviors.TbWidget');
     $this->attachBehavior('tbWidget', new TbWidget());
     if (!isset($this->assetPath)) {
         $this->assetPath = realpath(dirname(__FILE__) . '/../assets');
     }
 }
Exemplo n.º 10
0
 /**
  * 运行
  */
 public function run()
 {
     parent::run();
     $assets = $this->getAssetsPath();
     $clientScript = Yii::app()->getClientScript();
     $clientScript->registerScriptFile($assets . '/ueditor.config.js', CClientScript::POS_END);
     $clientScript->registerScriptFile($assets . '/ueditor.all.min.js', CClientScript::POS_END);
     $clientScript->registerScriptFile($assets . '/lang/' . $this->language . '.js', CClientScript::POS_END);
     $clientScript->registerScript('content', $this->makeOptions(), CClientScript::POS_END);
 }
Exemplo n.º 11
0
 public function init()
 {
     $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'source';
     $this->baseurl = Yii::app()->getAssetManager()->publish($dir);
     $this->kcFinderPath = $this->baseurl;
     $cs = Yii::app()->clientScript;
     $cs->registerCssFile($this->baseurl . "/run/kcfinder.css", "screen");
     $cs->registerScriptFile($this->baseurl . "/run/kcfinder.js");
     parent::init();
 }
Exemplo n.º 12
0
 /**
  * 运行
  */
 public function run()
 {
     parent::run();
     $this->assets = $assets = $this->getAssetsPath();
     $this->displayHtml();
     $clientScript = Yii::app()->getClientScript();
     $clientScript->registerCssFile($assets . '/default.css');
     $clientScript->registerScriptFile($assets . '/resumable.js', CClientScript::POS_END);
     $clientScript->registerScriptFile($assets . '/upload.js', CClientScript::POS_END);
 }
Exemplo n.º 13
0
 public function run()
 {
     parent::run();
     $assets = $this->getAssetsPath();
     $cs = Yii::app()->getClientScript();
     $cs->registerCssFile($assets . '/themes/default/default.css');
     $cs->registerCssFile($assets . '/plugins/code/prettify.css');
     $cs->registerScriptFile($assets . '/kindeditor.js', CClientScript::POS_HEAD);
     $cs->registerScriptFile($assets . '/lang/zh_CN.js', CClientScript::POS_HEAD);
     $cs->registerScriptFile($assets . '/plugins/code/prettify.js', CClientScript::POS_HEAD);
     $cs->registerScript('content', $this->makeOptions(), CClientScript::POS_HEAD);
 }
 public function init()
 {
     parent::init();
     Yii::import('bootstrap.behaviors.TbWidget');
     $this->attachBehavior('tbWidget', new TbWidget());
     if (!isset($this->assetPath)) {
         $this->assetPath = realpath(dirname(__FILE__) . '/../assets');
     }
     if (!$this->bindPlugin) {
         $this->htmlOptions['data-plugin'] = 'datetimepicker';
         $this->htmlOptions['data-plugin-options'] = CJSON::encode($this->pluginOptions);
     }
 }
Exemplo n.º 15
0
 public function init()
 {
     if (!isset($this->options['allowTimes'])) {
         $this->options['allowTimes'] = array();
         for ($i = 0; $i < 24; $i++) {
             $hour = str_pad($i, 2, 0, STR_PAD_LEFT);
             $minutes = str_pad($i, 2, 0, STR_PAD_LEFT);
             $this->options['allowTimes'][] = $hour . ':00';
             $this->options['allowTimes'][] = $hour . ':30';
         }
     }
     return parent::init();
 }
Exemplo n.º 16
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     Yii::import('bootstrap.behaviors.TbWidget');
     $this->attachBehavior('tbWidget', new TbWidget());
     if (!isset($this->assetPath)) {
         $this->assetPath = Yii::getPathOfAlias('lib.bootstrap-wysihtml5');
     }
     if (!$this->bindPlugin) {
         $this->htmlOptions['data-plugin'] = 'wysihtml5';
         $this->htmlOptions['data-plugin-options'] = CJSON::encode($this->pluginOptions);
     }
     TbHtml::addCssStyle('width: ' . $this->width . 'px; height: ' . $this->height . 'px;', $this->htmlOptions);
 }
Exemplo n.º 17
0
 /**
  * Init widget
  */
 public function init()
 {
     parent::init();
     if ($this->assetsPath === null) {
         $this->assetsPath = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets';
     }
     if ($this->assetsUrl === null) {
         $this->assetsUrl = Yii::app()->assetManager->publish($this->assetsPath);
     }
     if ($this->selector === null) {
         list($this->name, $this->id) = $this->resolveNameId();
         $this->selector = '#' . $this->id;
     }
     $this->registerClientScript();
 }
Exemplo n.º 18
0
 /**
  * Init widget.
  */
 public function init()
 {
     parent::init();
     if ($this->selector === null) {
         list($this->name, $this->id) = $this->resolveNameID();
         $this->htmlOptions['id'] = $this->getId();
         $this->selector = '#' . $this->getId();
         if ($this->hasModel()) {
             echo CHtml::activeTextArea($this->model, $this->attribute, $this->htmlOptions);
         } else {
             echo CHtml::textArea($this->name, $this->value, $this->htmlOptions);
         }
     }
     $this->registerClientScript();
 }
Exemplo n.º 19
0
 public function init()
 {
     // Please change the config below to suit your needs
     $this->uploadPath = dirname(Yii::app()->request->scriptFile) . '/uploads/';
     $this->uploadUrl = Yii::app()->getRequest()->hostInfo . Yii::app()->baseUrl . '/uploads/';
     // We need to make the CKFinder accessible, let's publish it to the assets folder
     $lo_am = new CAssetManager();
     $this->path = Yii::app()->getAssetManager()->publish(Yii::app()->basePath . '/extensions/finder/ckfinder2.1', true);
     // And save the upload path to use with ckfinder's config file. Passing as js param did not work...
     $lo_session = new CHttpSession();
     $lo_session->open();
     $lo_session['auth'] = true;
     $lo_session['upload_path'] = $this->uploadPath;
     $lo_session['upload_url'] = $this->uploadUrl;
     parent::init();
 }
 public function init()
 {
     parent::init();
     if ($this->selector === null) {
         list($this->name, $this->id) = $this->resolveNameID();
         $this->htmlOptions['id'] = $this->getId();
         $this->selector = '#' . $this->getId();
         if ($this->hasModel()) {
             echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
         } else {
             echo CHtml::textField($this->name, $this->value, $this->htmlOptions);
         }
     }
     $this->registerMoment();
     $this->registerBootstrapDateRangePicker();
 }
Exemplo n.º 21
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     Yii::import('bootstrap.behaviors.TbWidget');
     $this->attachBehavior('tbWidget', new TbWidget());
     if (isset($this->locale)) {
         $this->pluginOptions['language'] = $this->locale;
     }
     if (!isset($this->assetPath)) {
         $this->assetPath = Yii::getPathOfAlias('lib.smalot-bootstrap-datetimepicker');
     }
     if (!$this->bindPlugin) {
         $this->htmlOptions['data-plugin'] = 'datetimepicker';
         $this->htmlOptions['data-plugin-options'] = CJSON::encode($this->pluginOptions);
     }
 }
Exemplo n.º 22
0
 public function init()
 {
     $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'source';
     $this->baseurl = Yii::app()->getAssetManager()->publish($dir);
     $cs = Yii::app()->clientScript;
     $cs->registerCoreScript('jquery');
     $cs->registerCoreScript('jquery.ui');
     $cs->registerScriptFile($this->baseurl . "/jquery.tmpl.min.js");
     $cs->registerScriptFile($this->baseurl . "/jquery.iframe-transport.js");
     $cs->registerScriptFile($this->baseurl . "/jquery.fileupload.js");
     $cs->registerScriptFile($this->baseurl . "/jquery.fileupload-ui.js");
     $cs->registerScriptFile($this->baseurl . "/application.js");
     $cs->registerCssFile("http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/base/jquery-ui.css", "screen");
     $cs->registerCssFile($this->baseurl . "/jquery.fileupload-ui.css", "screen");
     parent::init();
 }
Exemplo n.º 23
0
 /**
  * Init widget.
  */
 public function init()
 {
     parent::init();
     if ($this->selector === null) {
         list($this->name, $this->id) = $this->resolveNameID();
         $this->htmlOptions['id'] = $this->getId();
         $this->selector = '#' . $this->getId();
         if ($this->hasModel()) {
             echo CHtml::activeTextArea($this->model, $this->attribute, $this->htmlOptions);
         } else {
             echo CHtml::textArea($this->name, $this->value, $this->htmlOptions);
         }
     }
     $package = array_merge(array('baseUrl' => $this->getAssetsUrl()), $this->package);
     self::initClientScript($package, isset($this->options['lang']) && $this->options['lang'] !== 'en' ? $this->options['lang'] : null);
     $this->registerClientScript();
 }
Exemplo n.º 24
0
 /**
  * Initialize component
  */
 public function init()
 {
     if (self::$initialized === false) {
         self::$initialized = true;
         $assetsUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('ext.elrte.lib'), false, -1, YII_DEBUG);
         $cs = Yii::app()->clientScript;
         // Elrte
         $cs->registerCssFile($assetsUrl . '/elrte/css/elrte.min.css');
         $cs->registerScriptFile($assetsUrl . '/elrte/js/elrte.min.js');
         $cs->registerScriptFile($assetsUrl . '/elrte/js/i18n/elrte.ru.js');
         // Elfinder
         $cs->registerCssFile($assetsUrl . '/elfinder/css/elfinder.min.css');
         $cs->registerCssFile($assetsUrl . '/elfinder/css/theme.css');
         $cs->registerScriptFile($assetsUrl . '/elfinder/js/elfinder.min.js');
         $cs->registerScriptFile($assetsUrl . '/elfinder/js/i18n/elfinder.ru.js');
         $cs->registerScriptFile($assetsUrl . '/helper.js');
     }
     parent::init();
 }
Exemplo n.º 25
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     Yii::import('bootstrap.behaviors.TbWidget');
     $this->attachBehavior('tbWidget', new TbWidget());
     if (!isset($this->assetPath)) {
         $this->assetPath = Yii::getPathOfAlias('lib.select2');
     }
     if (!$this->asDropDownList && !isset($this->pluginOptions['data'])) {
         $this->pluginOptions['data'] = $data = $this->normalizeData($this->data);
     }
     if (!$this->bindPlugin) {
         $this->htmlOptions['data-plugin'] = 'select2';
         $this->htmlOptions['data-plugin-options'] = CJSON::encode($this->pluginOptions);
     }
     if (TbArray::popValue('block', $this->htmlOptions, false)) {
         TbHtml::addCssClass('input-block-level', $this->htmlOptions);
     }
 }
Exemplo n.º 26
0
 /**
  *
  */
 public function init()
 {
     $this->directory || ($this->directory = app()->getRuntimePath() . '/ck_uploads/');
     if (!file_exists($this->directory)) {
         mkdir($this->directory, 0755, true);
     }
     $ckFinderPath = Yii::getPathOfAlias('vendor') . '/cornernote/ckfinder-assets/ckfinder';
     $this->path = app()->assetManager->publish($ckFinderPath, false, -1, YII_DEBUG);
     if (!$this->resourceTypes) {
         $this->resourceTypes[] = array('name' => t('CK Uploads'), 'url' => $this->url, 'directory' => $this->directory, 'maxSize' => $this->maxSize, 'allowedExtensions' => is_array($this->allowedExtensions) ? implode(',', $this->allowedExtensions) : $this->allowedExtensions, 'deniedExtensions' => is_array($this->deniedExtensions) ? implode(',', $this->deniedExtensions) : $this->deniedExtensions);
     }
     $lo_session = new CHttpSession();
     $lo_session->open();
     $lo_session['ck_auth'] = true;
     $lo_session['ck_upload_path'] = $this->directory . '/';
     $lo_session['ck_upload_url'] = $this->url . '/';
     $lo_session['ck_resource'] = $this->resourceTypes;
     parent::init();
 }
Exemplo n.º 27
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (!$this->hasModel() && $this->name === null) {
         throw new CException("Either 'name', or 'model' and 'attribute' properties must be specified.");
     }
     if (!isset($this->htmlOptions['id'])) {
         $this->htmlOptions['id'] = $this->hasModel() ? CHtml::activeId($this->model, $this->attribute) : $this->getId();
     }
     $this->attachBehavior('ywplugin', array('class' => 'yiiwheels.behaviors.WhPlugin'));
     $this->htmlOptions = TbArray::merge($this->asDataAttributes($this->pluginOptions), $this->htmlOptions);
     $this->pluginOptions = false;
     if ($this->hasModel()) {
         $this->htmlOptions['data-name'] = CHtml::activeId($this->model, $this->attribute);
         $this->htmlOptions['data-value'] = CHtml::value($this->model, $this->attribute);
     } else {
         $this->htmlOptions['data-name'] = $this->name;
         $this->htmlOptions['data-value'] = $this->value;
     }
 }
Exemplo n.º 28
0
    public function run()
    {
        parent::run();
        list($name, $id) = $this->resolveNameID();
        $assets = Yii::app()->getAssetManager()->publish(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets');
        $options = $this->makeOptions();
        $cs = Yii::app()->getClientScript();
        $cs->registerScriptFile($assets . '/ckeditor.js');
        $this->htmlOptions['id'] = $id;
        $js = <<<EOP
CKEDITOR.replace('{$name}',{$options});
EOP;
        $cs->registerScript('Yii.' . get_class($this) . '#' . $id, $js, CClientScript::POS_LOAD);
        if ($this->hasModel()) {
            $html = CHtml::activeTextArea($this->model, $this->attribute, $this->htmlOptions);
        } else {
            $html = CHtml::textArea($name, $this->value, $this->htmlOptions);
        }
        echo $html;
    }
Exemplo n.º 29
0
 public function init()
 {
     parent::init();
     $checkboxClass = class_exists(\Befound\Widgets\CheckBoxColumn::CLASS) ? \Befound\Widgets\CheckBoxColumn::CLASS : \CCheckBoxColumn::CLASS;
     $this->checkBoxColumn = array_merge(array('class' => $checkboxClass, 'headerTemplate' => '{item}', 'checked' => function ($model, $row, $source) {
         if (is_array($this->model->{$this->attribute})) {
             return in_array($model->{$source->name}, $this->model->{$this->attribute});
         } else {
             return $model->{$source->name} == $this->model->{$this->attribute};
         }
     }), $this->checkBoxColumn);
     if (isset($this->checkBoxColumn['header'])) {
         $this->checkBoxColumn['headerTemplate'] = $this->checkBoxColumn['header'] . '&nbsp;&nbsp;' . $this->checkBoxColumn['headerTemplate'];
     }
     if ($this->multiple) {
         $this->options['selectableRows'] = 2;
     } else {
         $this->options['selectableRows'] = 1;
     }
     CHtml::resolveNameID($this->model, $this->attribute, $this->htmlOptions);
     if (substr($this->htmlOptions['name'], -2) !== '[]') {
         $this->htmlOptions['name'] .= '[]';
     }
     $this->checkBoxColumn['checkBoxHtmlOptions']['name'] = $this->htmlOptions['name'];
     //search for placeholder const in the columns
     $foundplaceholder = false;
     foreach ($this->options['columns'] as $key => $column) {
         if ($column == static::CHECKBOX_COLUMN) {
             $this->options['columns'][$key] = $this->checkBoxColumn;
             $foundplaceholder = true;
             break;
         }
     }
     //if not found, choose the last column
     if (!$foundplaceholder) {
         $this->options['columns'][] = $this->checkBoxColumn;
     }
     if (!isset($this->options['id'])) {
         $this->options['id'] = $this->resolveNameID()[1];
     }
 }
Exemplo n.º 30
-1
 public function run()
 {
     parent::run();
     // Saves $id will be the id of the element that ckeditor will target
     list($name, $id) = $this->resolveNameID();
     // Publish assets to public directory
     $baseDir = dirname(__FILE__);
     $assets = Yii::app()->getAssetManager()->publish($baseDir . DIRECTORY_SEPARATOR . 'assets');
     $cs = Yii::app()->getClientScript();
     $cs->registerScriptFile($assets . '/ckeditor.js');
     echo CHtml::activeTextArea($this->model, $this->attribute, array('rows' => 10, 'cols' => 70));
     $this->ECKE->replace($id, $this->_config);
 }