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; } protected function _translate($text) { $translator = $this->getElement()->getTranslator(); if ($translator) { $text = $translator->translate($text); } return $text; } 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;'; $langPrefix = $element->getLanguagePrefix(); $content = $langPrefix . '
getMode() == 'edit') ? 'style = "display:none"' : '') . '> ' . '' . $this->_translate('Edit') . '' . '
' . '
' . (($element->getMode() == 'view') ? $element->getValue() : '') . '
' . $content; if ($element->getHasMsWordNote() && $element->getToolbar() == 'Default') { $note = 'We strongly recommend to use this button %button% (see above in the toolbar) ' . 'to insert the text from MS Word documents'; $button = ''; $note = '

' . str_replace('%button%', $button, $this->_translate($note)) . '

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