addInlineScript( 'CKEDITOR_BASEPATH', 'window.CKEDITOR_BASEPATH = "' . $ckeditorBasePath . '"', array('beforeScripts' => true) ); $doc->addScript('js/ckeditor/ckeditor.js'); $doc->addScript('js/lib/form-element-ckeditor.js'); $doc->addInitObject('Qs_Form_Element_CkEditor', array($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; } public function render($content) { /** @var $element Qs_Form_Element_HtmlEditor */ $element = $this->getElement(); $height = $element->getHeight(); $editAction = 'Qs_CkEditor.getElementInstance(\'' . $element->getId() . '\').setEditMode(); return false;'; $content = '
getMode() == 'edit') ? '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; } }