4 * Baseclass for WysiwygEdit/*
6 * ENABLE_WYSIWYG - Support for some WYSIWYG_BACKEND Editors:
7 * tinymce, htmlarea3, FCKeditor, spaw, htmlarea2, Wikiwyg
8 * Not yet enabled as default, since we cannot convert HTML to Wiki Markup yet.
9 * (See HtmlParser.php for the ongoing efforts)
10 * We might use a PageType=html, which is contra wiki, but some people
11 * might prefer HTML markup.
13 * TODO: Change from ENABLE_WYSIWYG constant to user preference variable
14 * (checkbox setting or edit click as in gmail),
15 * when HtmlParser is finished.
16 * Based upon htmlarea3.php and tinymce.php
18 * WARNING! Probably incompatible with ENABLE_XHTML_XML (TestMe)
20 * @package WysiwygEdit
24 require_once("lib/InlineParser.php");
28 function WysiwygEdit() {
29 $this->_transformer_tags = false;
32 function Head($name='edit[content]') {
33 trigger_error("virtual", E_USER_ERROR);
36 // to be called after </textarea>
37 function Textarea($textarea,$wikitext,$name='edit[content]') {
38 trigger_error("virtual", E_USER_ERROR);
42 * Handler to convert the Wiki Markup to HTML before editing.
43 * This will be converted back by WysiwygEdit_ConvertAfter if required.
44 * *text* => '<b>text<b>'
46 function ConvertBefore($text) {
47 require_once("lib/BlockParser.php");
48 $xml = TransformText($text, 2.0, $GLOBALS['request']->getArg('pagename'));
53 * FIXME: Handler to convert the HTML formatting back to wiki formatting.
54 * Derived from InlineParser, but returning wiki text instead of HtmlElement objects.
55 * '<b>text<b>' => '<SPAN style="FONT-WEIGHT: bold">text</SPAN>' => '*text*'
57 * TODO: Switch over to HtmlParser
59 function ConvertAfter($text) {
62 $trfm = new HtmlTransformer($this->_transformer_tags);
64 $markup = $trfm->parse($text); // version 2.0
69 // re-use these classes for the regexp's.
70 // just output strings instead of XmlObjects
71 class Markup_html_br extends Markup_linebreak {
72 function markup ($match) {
77 class Markup_html_simple_tag extends Markup_html_emphasis {
78 function markup ($match, $body) {
79 $tag = substr($match, 1, -1);
85 return "<big>".$body."</big>";
93 class Markup_html_p extends BalancedMarkup
95 var $_start_regexp = "<(?:p|P)( class=\".*\")?>";
97 function getEndRegexp ($match) {
98 return "<\\/" . substr($match, 1);
100 function markup ($match, $body) {
105 //'<SPAN style="FONT-WEIGHT: bold">text</SPAN>' => '*text*'
106 class Markup_html_spanbold extends BalancedMarkup
108 var $_start_regexp = "<(?:span|SPAN) style=\"FONT-WEIGHT: bold\">";
110 function getEndRegexp ($match) {
111 return "<\\/" . substr($match, 1);
113 function markup ($match, $body) {
114 //Todo: convert style formatting to simplier nested <b><i> tags
115 return "*".$body."*";
119 class HtmlTransformer extends InlineTransformer
121 function HtmlTransformer ($tags = false) {
123 array('escape','html_br','html_spanbold','html_simple_tag',
126 'html_a','html_span','html_div',
127 'html_table','html_hr','html_pre',
129 'html_indent','html_ol','html_li','html_ul','html_img'
131 return $this->InlineTransformer($tags);
139 // c-hanging-comment-ender-p: nil
140 // indent-tabs-mode: nil