heredoc; public function __construct($options = null) { parent::__construct($options); $this->addScript('js/ckeditor/ckeditor.js'); $this->addScript('js/lib/form-element-ckeditor.js'); $ckeditorBasePath = addslashes(Qs_Constant::get('BASE_URL') . '/js/ckeditor/'); $this->addInlineScript( 'CKEDITOR_BASEPATH', 'window.CKEDITOR_BASEPATH = "' . $ckeditorBasePath . '"', ['beforeScripts' => true] ); } public function getPopupTemplate() { return $this->_popupTemplate; } public function setPopupTemplate($popupTemplate) { $this->_popupTemplate = $popupTemplate; return $this; } public function initScripts() { /** @var $doc App_Doc_Site */ $doc = Zend_Registry::get('doc'); $doc->addResources($this->getResources()); $doc->addInitObject('Qs_Form_Element_CkEditor', [$this->_getScriptOptions()]); return $this; } protected function _getEditorConfig() { /** @var $element Qs_Form_Element_HtmlEditor */ $element = $this->getElement(); $config = $element->getScriptOptions(); $editorAreaCss = 'css'; if (Qs_Constant::get('SITE_REVISION')) { $editorAreaCss .= '-' . Qs_Constant::get('SITE_REVISION'); } $editorAreaCss = Qs_Constant::get('WWW_PATH') . '/' . $editorAreaCss . '/ckeditor.css'; if (file_exists($editorAreaCss)) { $editorAreaCss = ltrim($editorAreaCss, '/'); $documentRoot = trim($_SERVER['DOCUMENT_ROOT'], '/'); $config['contentsCss'] = str_replace($documentRoot, '', $editorAreaCss); } return $config; } protected function _getScriptOptions() { /** @var $element Qs_Form_Element_HtmlEditor */ $element = $this->getElement(); $options['id'] = $element->getId(); $options['mode'] = $element->getMode(); $options['config'] = $this->_getEditorConfig(); return $options; } protected function renderPopupTemplate(array $placeholders) { return Qs_String::fill($this->getPopupTemplate(), $placeholders); } public function render($content) { $this->initScripts(); /** @var $element Qs_Form_Element_HtmlEditor */ $element = $this->getElement(); if ($element->getMode() == Qs_Form_Element_HtmlEditor::MODE_POPUP_BUTTON) { $modalId = $element->getId() . '-modal'; return Qs\Html::renderContainer( 'a', Qs\Html::renderContainer('i', '', ['class' => 'fa fa-lg fa-pencil-square-o']), [ 'class' => 'btn btn-light btn-small htmleditor-popup-btn' . ($element->getValue() ? ' btn-primary htmleditor-not-empty' : ''), 'id' => $element->getId() . '-popup-btn', 'href' => '#' . $modalId, 'role' => 'button', 'data-toggle' => 'modal', ] ) . $this->renderPopupTemplate([ 'id' => $modalId, 'modalHeader' => $element->getLabel(), 'modalBody' => $content, ]); } $height = $element->getHeight(); $editAction = 'Qs_CkEditor.getElementInstance(\'' . $element->getId() . '\').setEditMode(); return false;'; $content = '
getMode() != 'view') ? 'style = "display:none"' : '') . '> ' . 'Edit' . '
' . '
' . (($element->getMode() == 'view') ? $element->getValue() : '') . '
' . $content; if ($element->getHasMsWordNote() && $element->getToolbar() == 'Default') { $note = '

We strongly recommend to use this button ' . ' ' . '(see above in the toolbar) to insert the text from MS Word documents.

'; $content .= $note; } return $content; } }