<?php
namespace Extension;
 use TCMS\ControlExtension;
 use TCMS\TException;
 class EditorDefault extends ControlExtension {
 public $option = [ 'name' => null, 'height' => '400px', 'visible' => true ];
 public function render($content, $option = null) {
 if($option == null || isset($option['name']) === false || empty($option['name'])) throw new TException("Vui lòng truyền vào option name cho extension upload-image-default", 501);
 copy_option($this->option, $option);
 echo '<textarea id="suneditor-' .$this->option['name']. '" name="' .$this->option['name']. '" height="' . $this->option['height'] . '" class="suneditor-txt">' . ($content == null ? '' : $content) . '</textarea>';
 $this->includeDialog();
 $this->addStyle(asset('/suneditor/suneditor.min.css'));
 $this->addScript(asset('/suneditor/suneditor.min.js'));
 if($this->option['visible']) $this->addScript(asset('/suneditor/suneditor-extension.js'));
 }
 private function includeDialog() {
 $dialogPath = __DIR__ . DIRECTORY_SEPARATOR . 'dialog-update-img.php';
 require_once($dialogPath);
 }
 }
 ?>