HCE Project DC service web UI  0.2
Hierarchical Cluster Engine DC service web UI
 All Classes Namespaces Files Functions Variables Pages
TbCKEditor.php
Go to the documentation of this file.
1 <?php
17 class TbCKEditor extends CInputWidget
18 {
24  public $form;
25 
31  public $editorOptions = array();
32 
38  public function run()
39  {
40 
41  list($name, $id) = $this->resolveNameID();
42 
43  $this->registerClientScript($id);
44 
45  $this->htmlOptions['id'] = $id;
46 
47  // Do we have a model?
48  if ($this->hasModel()) {
49  if ($this->form) {
50  $html = $this->form->textArea($this->model, $this->attribute, $this->htmlOptions);
51  } else {
52  $html = CHtml::activeTextArea($this->model, $this->attribute, $this->htmlOptions);
53  }
54  } else {
55  $html = CHtml::textArea($name, $this->value, $this->htmlOptions);
56  }
57  echo $html;
58  }
59 
67  public function registerClientScript($id)
68  {
69  Booster::getBooster()->cs->registerPackage('ckeditor');
70 
71  $options = !empty($this->editorOptions) ? CJavaScript::encode($this->editorOptions) : '{}';
72 
73  Yii::app()->clientScript->registerScript(
74  __CLASS__ . '#' . $this->getId(),
75  "CKEDITOR.replace( '$id', $options);"
76  );
77  }
78 }