function wikiplugin_wysiwyg($data, $params) { global $wysiwyglib; include_once 'lib/ckeditor_tiki/wysiwyglib.php'; // TODO refactor: defaults for plugins? $defaults = array(); $plugininfo = wikiplugin_wysiwyg_info(); foreach ($plugininfo['params'] as $key => $param) { $defaults["{$key}"] = $param['default']; } $params = array_merge($defaults, $params); $html = TikiLib::lib('tiki')->parse_data($data, array('is_html' => true)); global $tiki_p_edit, $page, $prefs; static $execution = 0; if ($tiki_p_edit === 'y') { $class = "wp_wysiwyg"; $exec_key = $class . '_' . ++$execution; $style = " style='min-width:{$params['width']};min-height:{$params['height']}'"; $params['section'] = empty($params['section']) ? 'wysiwyg_plugin' : $params['section']; $params['_wysiwyg'] = 'y'; $params['is_html'] = true; //$params['comments'] = true; $ckoption = $wysiwyglib->setUpEditor(true, $exec_key, $params, '', false); $html = "<div id='{$exec_key}' class='{$class}'{$style}>" . $html . '</div>'; $js = '$("#' . $exec_key . '").wysiwygPlugin("' . $execution . '", "' . $page . '", ' . $ckoption . ')'; TikiLib::lib('header')->add_jq_onready($js); } return $html; }
function wikiplugin_wysiwyg($data, $params) { // TODO refactor: defaults for plugins? $defaults = array(); $plugininfo = wikiplugin_wysiwyg_info(); foreach ($plugininfo['params'] as $key => $param) { $defaults["{$key}"] = $param['default']; } $params = array_merge($defaults, $params); global $tiki_p_edit, $page, $prefs, $user; static $execution = 0; global $wikiplugin_included_page; if (!empty($wikiplugin_included_page)) { $sourcepage = $wikiplugin_included_page; } else { $sourcepage = $page; } if ($params['use_html'] !== 'y') { $is_html = false; } else { $is_html = true; } $html = TikiLib::lib('edit')->parseToWysiwyg($data, true, $is_html, array('page' => $sourcepage)); if (TikiLib::lib('tiki')->user_has_perm_on_object($user, $sourcepage, 'wiki page', 'tiki_p_edit')) { $class = "wp_wysiwyg"; $exec_key = $class . '_' . ++$execution; $style = " style='min-width:{$params['width']};min-height:{$params['height']}'"; $params['section'] = empty($params['section']) ? 'wysiwyg_plugin' : $params['section']; $params['_wysiwyg'] = 'y'; $params['is_html'] = $is_html; $params['_is_html'] = $is_html; // needed for toolbars //$params['comments'] = true; $ckoption = TikiLib::lib('wysiwyg')->setUpEditor($is_html, $exec_key, $params, ''); if ($prefs['namespace_enabled'] == 'y' && $prefs['namespace_force_links'] == 'y') { $namespace = TikiLib::lib('wiki')->get_namespace($sourcepage); if ($namespace) { $namespace .= $prefs['namespace_separator']; } } else { $namespace = ''; } $namespace = htmlspecialchars($namespace); $html = "<div id='{$exec_key}' class='{$class}'{$style} data-initial='{$namespace}' data-html='{$params['use_html']}'>" . $html . '</div>'; $js = '$("#' . $exec_key . '").wysiwygPlugin("' . $execution . '", "' . $sourcepage . '", ' . $ckoption . ');'; TikiLib::lib('header')->add_jsfile('lib/ckeditor_tiki/tiki-ckeditor.js')->add_jq_onready($js); } return $html; }
function wikiplugin_wysiwyg($data, $params) { global $wysiwyglib; include_once('lib/ckeditor_tiki/wysiwyglib.php'); // TODO refactor: defaults for plugins? $defaults = array(); $plugininfo = wikiplugin_wysiwyg_info(); foreach ($plugininfo['params'] as $key => $param) { $defaults["$key"] = $param['default']; } $params = array_merge($defaults, $params); $html = TikiLib::lib('tiki')->parse_data($data, array('is_html' => true)); global $tiki_p_edit, $page, $prefs; static $execution = 0; if ($tiki_p_edit === 'y') { $class = "wp_wysiwyg"; $exec_key = $class . '_' . ++ $execution; $style = " style='min-width:{$params['width']};min-height:{$params['height']}'"; $params['section'] = empty($params['section']) ? 'wysiwyg_plugin' : $params['section']; $params['_wysiwyg'] = 'y'; $params['is_html'] = true; //$params['comments'] = true; $ckoption = $wysiwyglib->setUpEditor(true, $exec_key, $params, '', false); $html = "<div id='$exec_key' class='{$class}'$style>" . $html . '</div>'; $js = ' $("#' . $exec_key . '").each(function(){ var wp_bgcol = $(this).css("background-color"); $(this).mouseover(function(){ $(this).css({ backgroundColor: "#ddd", cusor: "crosshair" }); }).mouseout(function(){ $(this).css({ backgroundColor: wp_bgcol, cusor: "inherit" }); }).click(function(){ var $this = $(this); // TODO set modal somehow? //$("body *:not(#" + $(this).attr("id") + ")").css({backgroundColor: "#ddd"}); var ok = true; $(".' . $class . ':not(#' . $exec_key . ')").each(function () { if (CKEDITOR.instances[$(this).attr("id")]) { if (CKEDITOR.instances[$(this).attr("id")].mayBeDirty) { if (confirm(tr("You have unsaved changes in this WYSIWYG section.\nDo you want to save your changes?"))) { CKEDITOR.instances[$(this).attr("id")].focus(); ok = false; return; } } CKEDITOR.instances[$(this).attr("id")].destroy(); } $(".button_" + $(this).attr("id")).remove(); }); if (!ok) { return; } $this.ckeditor(function() { // close others var editor = CKEDITOR.instances[$this.attr("id")]; var editorSelector = "#cke_" + this.element.getId(); $(editorSelector).after( $("<button class=\"button_' . $exec_key . '\">" + tr("Cancel") + "</button>").button() .click(function() { $(".button_' . $exec_key . '").remove(); editor.destroy(); }) ).after( $("<button class=\"button_' . $exec_key . '\">" + tr("Save") + "</button>").button() .click(function(event) { var data = editor.getData(); $(editorSelector).modal(tr("Saving...")); $.post("tiki-wikiplugin_edit.php", { page: "' . $page . '", type: "wysiwyg", message: "Modified by WYSIWYG Plugin", index: ' . $execution . ', content: data }, function() { location.reload(); }); return false; }) ); }, ' . $ckoption . ' ); }); }); '; TikiLib::lib('header')->add_jq_onready($js); } return '~np~' . $html . '~/np~'; }