123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <?php
- use \Chamilo\CoreBundle\Component\Editor\CkEditor\CkEditor;
- class HtmlEditor extends HTML_QuickForm_textarea
- {
-
- public $editor;
-
- public $fullPage;
-
- public function __construct(
- $name = null,
- $elementLabel = null,
- $attributes = [],
- $config = []
- ) {
- if (empty($name)) {
- return false;
- }
- parent::__construct($name, $elementLabel, $attributes);
- $this->_persistantFreeze = true;
- $this->_type = 'html_editor';
-
- $editor = new CkEditor();
- if ($editor) {
- $this->editor = $editor;
- $this->editor->setName($name);
- $this->editor->processConfig($config);
- }
- }
-
- public function toHtml()
- {
- $value = $this->getValue();
- if ($this->editor) {
- if ($this->editor->getConfigAttribute('fullPage')) {
- if (strlen(trim($value)) == 0) {
-
-
- $value = '<html><head><title></title></head><body></body></html>';
- $this->setValue($value);
- }
- }
- }
- if ($this->isFrozen()) {
- return $this->getFrozenHtml();
- } else {
- $styleCss = $this->editor->getConfigAttribute('style');
- if ($styleCss) {
- $style = true;
- } else {
- $style = false;
- }
- return $this->buildEditor($style);
- }
- }
-
- public function getFrozenHtml()
- {
- return $this->getValue();
- }
-
- public function buildEditor($style = false)
- {
- $result = '';
- if ($this->editor) {
- $this->editor->value = $this->getValue();
- $this->editor->setName($this->getName());
- if ($style == true) {
- $result = $this->editor->createHtmlStyle();
- } else {
- $result = $this->editor->createHtml();
- }
- }
- return $result;
- }
- }
|