You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
99 lines
2.5 KiB
99 lines
2.5 KiB
![]()
19 years ago
|
<?php
|
||
![]()
14 years ago
|
/* For licensing terms, see /license.txt */
|
||
![]()
19 years ago
|
|
||
![]()
11 years ago
|
use \Chamilo\CoreBundle\Component\Editor\CkEditor\CkEditor;
|
||
![]()
19 years ago
|
|
||
|
/**
|
||
![]()
13 years ago
|
* A html editor field to use with QuickForm
|
||
|
*/
|
||
![]()
11 years ago
|
class HtmlEditor extends HTML_QuickForm_textarea
|
||
![]()
11 years ago
|
{
|
||
|
/** @var \Chamilo\CoreBundle\Component\Editor\Editor */
|
||
|
public $editor;
|
||
![]()
13 years ago
|
|
||
|
/**
|
||
|
* Full page
|
||
|
*/
|
||
|
var $fullPage;
|
||
|
var $fck_editor;
|
||
![]()
11 years ago
|
var $content;
|
||
![]()
13 years ago
|
|
||
|
/**
|
||
|
* Class constructor
|
||
![]()
11 years ago
|
* @param string HTML editor name/id
|
||
|
* @param string HTML editor label
|
||
|
* @param array Attributes for the textarea
|
||
|
* @param array $config Optional configuration settings for the online editor.
|
||
|
* @return bool
|
||
![]()
13 years ago
|
*/
|
||
![]()
11 years ago
|
public function HtmlEditor($name = null, $elementLabel = null, $attributes = null, $config = null)
|
||
![]()
11 years ago
|
{
|
||
|
if (empty($name)) {
|
||
|
return false;
|
||
|
}
|
||
![]()
13 years ago
|
|
||
![]()
11 years ago
|
HTML_QuickForm_element :: HTML_QuickForm_element($name, $elementLabel, $attributes);
|
||
![]()
13 years ago
|
$this->_persistantFreeze = true;
|
||
|
$this->_type = 'html_editor';
|
||
|
|
||
![]()
11 years ago
|
global $fck_attribute;
|
||
![]()
13 years ago
|
|
||
![]()
11 years ago
|
//$editor = Container::getHtmlEditor();
|
||
|
$editor = new CkEditor();
|
||
|
if ($editor) {
|
||
|
$this->editor = $editor;
|
||
|
$this->editor->setName($name);
|
||
|
$this->editor->processConfig($fck_attribute);
|
||
|
$this->editor->processConfig($config);
|
||
![]()
13 years ago
|
}
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Return the HTML editor in HTML
|
||
|
* @return string
|
||
|
*/
|
||
![]()
11 years ago
|
public function toHtml()
|
||
|
{
|
||
![]()
13 years ago
|
$value = $this->getValue();
|
||
![]()
11 years ago
|
if ($this->editor) {
|
||
|
if ($this->editor->getConfigAttribute('fullPage')) {
|
||
|
if (strlen(trim($value)) == 0) {
|
||
|
// TODO: To be considered whether here to be added DOCTYPE, language and character set declarations.
|
||
|
$value = '<html><head><title></title></head><body></body></html>';
|
||
|
$this->setValue($value);
|
||
|
}
|
||
![]()
13 years ago
|
}
|
||
|
}
|
||
![]()
11 years ago
|
|
||
|
if ($this->isFrozen()) {
|
||
![]()
13 years ago
|
return $this->getFrozenHtml();
|
||
|
} else {
|
||
![]()
11 years ago
|
return $this->buildEditor();
|
||
![]()
13 years ago
|
}
|
||
|
}
|
||
|
|
||
|
/**
|
||
![]()
11 years ago
|
* Returns the html area content in HTML
|
||
![]()
13 years ago
|
* @return string
|
||
|
*/
|
||
![]()
11 years ago
|
public function getFrozenHtml()
|
||
|
{
|
||
![]()
13 years ago
|
return $this->getValue();
|
||
|
}
|
||
|
|
||
|
/**
|
||
![]()
11 years ago
|
* @return string
|
||
![]()
13 years ago
|
*/
|
||
![]()
11 years ago
|
public function buildEditor()
|
||
|
{
|
||
|
$result = '';
|
||
|
if ($this->editor) {
|
||
|
$this->editor->value = $this->getValue();
|
||
|
$this->editor->setName($this->getName());
|
||
|
$result = $this->editor->createHtml();
|
||
![]()
12 years ago
|
}
|
||
|
|
||
![]()
13 years ago
|
return $result;
|
||
|
}
|
||
![]()
12 years ago
|
}
|