static function EditorTextArea($id, $name, $content, $buttons, $context, $arributes = array(), $asset = null, $author = null) { $html = JCKHtmlwriter::textarea($id, $name, $content, $arributes); //load CKEditor script $javascript = new JCKJavascript(); $id = JCKOutput::fixId($id); $javascript->addScriptDeclaration('window.addDomReadyEvent.add(function() { CKEDITOR.config.expandedToolbar = true; CKEDITOR.tools.callHashFunction("' . $id . '","' . $id . '"); });'); $javascript->addToHead(); //set event handlers $args['name'] = $id; $args['event'] = 'onGetInsertMethod'; $results[] = $context->update($args); foreach ($results as $result) { if (is_string($result) && trim($result)) { $html .= $result; } } //Get buttons if (!empty($buttons) || is_array($buttons) && !array_key_exists(0, $buttons)) { // Load modal popup behavior JHTML::_('behavior.modal', 'a.modal-button'); $editor = JFactory::getEditor('jckeditor'); $plugins = $editor->getButtons($id, $buttons, $asset, $author); $buttons = ''; $container = ''; if (version_compare(JVERSION, '3.0', 'ge')) { foreach ($plugins as $plugin) { $className = $plugin->get('modal') ? "modal-button btn" : 'btn'; $url = $plugin->get('link') ? JURI::base() . $plugin->get('link') : ''; $click = $plugin->get('onclick') ? $plugin->get('onclick') : 'IeCursorFix(); return false;'; $options = $plugin->get('options'); $content = $plugin->get('text'); $buttonName = $plugin->get('name'); $content = '<i class="icon-' . $buttonName . '"></i>' . $content; $linkAttributes = array("rel" => $options, 'onclick' => $click); $buttons .= JCKHtmlwriter::link($url, $content, '', $className, $linkAttributes); } $innerContainer = JCKHtmlwriter::DivContainer($buttons, '', 'btn-toolbar'); $container = JCKHtmlwriter::DivContainer($innerContainer, 'editor-xtd-buttons', 'btn-toolbar pull-left'); } else { foreach ($plugins as $plugin) { $className = $plugin->get('modal') ? "modal-button" : ''; $url = $plugin->get('link') ? JURI::base() . $plugin->get('link') : ''; $click = $plugin->get('onclick') ? $plugin->get('onclick') : ''; $options = $plugin->get('options'); $content = $plugin->get('text'); $buttonName = $plugin->get('name'); $buttons .= JCKHtmlwriter::buttonModalLink($url, $content, $options, $buttonName, $className, $click, array("class" => "button2-left")); } $container = JCKHtmlwriter::DivContainer($buttons, 'editor-xtd-buttons'); } $html .= $container; } return $html; }
static function buttonModalLink($url, $content, $options, $name, $className = '', $click = '', $attributes = array()) { $linkAttributes["rel"] = $options; if ($click) { $linkAttributes["onclick"] = $click; } $link = JCKHtmlwriter::link($url, $content, '', $className, $linkAttributes); $container = JCKHtmlwriter::DivContainer($link, '', $name); return JCKHtmlwriter::DivContainer($container, '', '', $attributes); }
static function EditorTextArea($name, $content, $buttons, $context) { $html = JCKHtmlwriter::textarea($name, $content); //load CKEditor script $javascript = new JCKJavascript(); $filtername = JCKOutput::cleanString($name); $name = JCKOutput::fixId($name); $javascript->addScriptDeclaration('window.addDomReadyEvent.add(function() { CKEDITOR.config.expandedToolbar = true; CKEDITOR.tools.callHashFunction("' . $name . '","' . $name . '"); });'); $html .= $javascript->toString(); //Get buttons if (!empty($buttons) || is_array($buttons) && !array_key_exists(0, $buttons)) { // Load modal popup behavior JHTML::_('behavior.modal', 'a.modal-button'); $editor = JFactory::getEditor('jckeditor'); //set event handlers $args['name'] = $name; $args['event'] = 'onGetInsertMethod'; $results[] = $context->update($args); foreach ($results as $result) { if (is_string($result) && trim($result)) { $html .= $result; } } $plugins = $editor->getButtons($name, $buttons); $buttons = ''; foreach ($plugins as $plugin) { $className = $plugin->get('modal') ? "modal-button" : ''; $url = $plugin->get('link') ? $plugin->get('link') : ''; $click = $plugin->get('onclick') ? $plugin->get('onclick') : ''; $options = $plugin->get('options'); $content = $plugin->get('text'); $buttonName = $plugin->get('name'); $buttons .= JCKHtmlwriter::buttonModalLink($url, $content, $options, $buttonName, $className, $click, array("class" => "button2-left")); } $container = JCKHtmlwriter::DivContainer($buttons, 'editor-xtd-buttons'); $html .= $container; } return $html; }
/** * ckeditor Lite WYSIWYG Editor - display the editor * * @param string The name of the editor area * @param string The content of the field * @param string The name of the form field * @param string The width of the editor area * @param string The height of the editor area * @param int The number of columns for the editor area * @param int The number of rows for the editor area * @param mixed Can be boolean or array. */ function onDisplay($name, $content, $width, $height, $col, $row, $buttons = true, $id = null, $asset = null, $author = null) { // Load modal popup behavior JHTML::_('behavior.modal', 'a.modal-button'); // initialise $error varable $errors = ''; static $loaded; if (empty($id)) { $id = $name; } if (!$width) { $width = "100%"; } if (!$height) { $height = "350px"; } $skin = $this->params->get('skin'); if ($skin == 'kama' && $width == '100%') { $width = '99%'; } $arributes = array("rows" => $row, 'cols' => $col, "style" => "width:{$width};height:{$height}"); if (!$loaded) { /* Generate the Output */ $this->params->set('editorname', $id); if (!$this->params->get('hheight', '')) { $this->params->set('hheight', $height); } if (!$this->params->get('wwidth', '')) { $this->params->set('wwidth', $width); } $javascript = JCKJavascriptHelper::getHeadJavascript($this->params, $errors, $return_script); $javascript->addToHead(); $loaded = JCKOutput::fixId($id); if (!$return_script) { return; } //Here we will use JFCKJavascript output to screen //html element as well jckimport('ckeditor.htmlwriter.helper'); return $errors . JCKHtmlwriterHelper::EditorTextArea($id, $name, $content, $buttons, $this, $arributes, $asset, $author); } //end if return JCKHtmlwriter::TextArea($id, $name, $content, $arributes) . '<script>window.addDomReadyEvent.add( function(){ CKEDITOR.on("instanceReady",function(evt) { if(evt.editor.name == "' . $loaded . '") { var editor = CKEDITOR.replace( "' . JCKOutput::fixId($id) . '", CKEDITOR.instances["' . $loaded . '"].config ); var xtdbuttons = CKEDITOR.document.getById("editor-xtd-buttons"); if(xtdbuttons) { buttonsHtml = xtdbuttons.getOuterHtml().replace(/' . $loaded . '/g,"' . JCKOutput::fixId($id) . '"); var buttonsElement = CKEDITOR.dom.element.createFromHtml(buttonsHtml); editor.container.getParent().append(buttonsElement); var elements = buttonsElement.getElementsByTag("a"); for(i= 0; i < elements.count();i++) { //override mootools model click event if(elements.getItem(i).hasClass("modal-button")) { (function() { var el = $(elements.getItem(i).$); el.addEvent("click", function(e) { new Event(e).stop(); SqueezeBox.fromElement(el, { parse: "rel" }); }); })(); } } } } }) });</script>'; }