Blame view

thread/widgets/editors/textarea/Textarea.php 1.69 KB
d1f8bd40   Alexey Boroda   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
  <?php
  
  namespace thread\widgets\editors\textarea;
  
  use yii\helpers\Html;
  use yii\widgets\InputWidget;
  
  /**
   * Class Textarea
   * 
   * @package thread\extensions\editors\textarea
   * @author FilamentV <vortex.filament@gmail.com>
   * @copyright (c), Thread
   */
  final class Textarea extends InputWidget {
  
      /**
       * Налаштування 
       * @var array
       */
      public $settings = [];
  
      /**
       * Виклик налаштувань для редактору
       * @var string ''|full|mini 
       */
      public $thema = '';
  
      /**
       * Мова інтерфейсу редатору
       * @var string 
       */
      public $language;
  
      /**
       * @var \yii\helpers\Html textarea
       */
      private $_textarea;
  
      /**
       * @throws \yii\base\InvalidConfigException
       */
      public function init() {
          parent::init();
  
          //Додаємо поле для редактору та визначаємо ідентифікатор
          if (!isset($this->settings['selector'])) {
              $this->settings['selector'] = '#' . $this->options['id'];
  
              $this->_textarea = ($this->hasModel()) ?
                      Html::activeTextarea($this->model, $this->attribute, $this->options) :
                      Html::textarea($this->name, $this->value, $this->options);
          }
          /* Якщо [[options['selector']]] false видаляємо з налаштувань. */
          if (isset($this->settings['selector']) && $this->settings['selector'] === false) {
              unset($this->settings['selector']);
          }
      }
  
      /**
       * @inheritdoc
       */
      public function run() {
          if ($this->_textarea !== null){
              echo $this->_textarea;
          }
      }
  
  }