I saved this in .../plugins/edit/tinymce.php

In order to make this usefull, you also need the rescuehtml-plugin, to allow HTML to be passed through.

<?php
/*

        Integrates the TinyMCE - Editor into ErfurtWiki

        Requires TinyMCE to be installed (=extracted)
        into /path/to/website/tinymce

        To get TinyMCE, visit
        http://tinymce.moxiecode.com/

        In order to make this usefull, you also need the
        rescuehtml-plugin, to allow HTML to be passed through.

        TinyMCE itself is LGPL-software.
        This plugin shall be distributable by the same terms as EWiki.

        Author: Stefan@Waidele.info

*/


define("EWIKI_UP_TINYMCE", "tinymce");


#-- <input>
$ewiki_plugins["edit_form_append"][] = "ewiki_aedit_tinymce";
function ewiki_aedit_tinymce($id, &$data, $action) {

   $var = EWIKI_UP_TINYMCE;
   return(ewiki_t(<<< EOT
<!-- tinyMCE: configure to meet your requirements -->
<!-- http://tinymce.moxiecode.com/ -->
<script language="javascript"
        type="text/javascript"
        src="/tinymce/jscripts/tiny_mce/tiny_mce.js">
</script>
<script language="javascript"
        type="text/javascript">
   tinyMCE.init({
      mode : "textareas",
      theme : "advanced",
      extended_valid_elements : "p,strong",
      theme_advanced_blockformats : "p,h2,h3,h4,h5,h6",
      theme_advanced_toolbar_location : "top",
      theme_advanced_toolbar_align    : "left",

      theme_advanced_buttons1         : "code, spacer, cut, copy, paste, spacer, undo, redo, spacer, \
                                         bold, italic, underline, strikethrough, spacer, \
                                         justifyleft, justifycenter, justifyright, justifyfull, spacer,\
                                         bullist, numlist, outdent, indent, spacer, link, unlink, image, cleanup, help",
      theme_advanced_buttons2         : "hr, removeformat, sub, sup, formatselect, forecolor, charmap, visualaid",
      theme_advanced_buttons3         : "",

      theme_advanced_path_location : "bottom"
  });
</script>
<!-- /tinyMCE -->
EOT
   ));
}

?>


Hi Stefan,

Can you be more specific about: In order to make this usefull, you also need the rescuehtml-plugin, to allow HTML to be passed through.

thanks

mario: Thanks for this code, Stefan! It was also possible to simple allow full HTML support then (EWIKI_ALLOW_HTML I think). You can then wrap everything into <html>*HtmlOnly...</html> or <htm>*HalfWikiHalfHtml</htm> tags.

The _html2wiki() from TextUpload could also be used, though that's slow and less reliable and you'd loose all the funcitonality a WYSIWYG editor like this provides. Thanks again for the hint, didn't know that TinyMce is LGPL. We'll probably integrate it then with the distribution (finally a reason for a new release!!! *grin*)


*StW: I want .../plugins/markup/rescuehtml.php to allow tag with attributes. I am not very fluent in PHP, so could anybody please assist me with the regex?

For tags without attributes, this line does the trick

$wiki_source = preg_replace('#&lt;(/?('.implode("|",$rescue_html).'))&gt;#i', '<$1>', $wiki_source);

I thought this should do it:

$wiki_source = preg_replace('#&lt;(/?('.implode("|",$rescue_html).')) (.*?)&gt;#i', '<$1 $2>', $wiki_source);

I added (.*?) to match the least amount of any characters until &gt; is found (= the attribute), and I added $2 to insert that attribute to the output.

But as I said, it does not work. "<p align="right"> will be converted into "<p p>".


Hey dude,

I rewrote the regular expression today. You were pretty close, but you can probably put the whole thing into one regular expression, then you just need $1.

bottom corner