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';
29 function WysiwygEdit()
31 $this->_transformer_tags = false;
34 function Head($name = 'edit[content]')
36 trigger_error("virtual", E_USER_ERROR);
39 // to be called after </textarea>
40 function Textarea($textarea, $wikitext, $name = 'edit[content]')
42 trigger_error("virtual", E_USER_ERROR);
46 * Handler to convert the Wiki Markup to HTML before editing.
47 * This will be converted back by WysiwygEdit_ConvertAfter if required.
48 * *text* => '<b>text<b>'
50 function ConvertBefore($text)
52 require_once 'lib/BlockParser.php';
53 $xml = TransformText($text, 2.0, $GLOBALS['request']->getArg('pagename'));
58 * FIXME: Handler to convert the HTML formatting back to wiki formatting.
59 * Derived from InlineParser, but returning wiki text instead of HtmlElement objects.
60 * '<b>text<b>' => '<SPAN style="FONT-WEIGHT: bold">text</SPAN>' => '*text*'
62 * TODO: Switch over to HtmlParser
64 function ConvertAfter($text)
68 $trfm = new HtmlTransformer($this->_transformer_tags);
70 $markup = $trfm->parse($text); // version 2.0
75 // re-use these classes for the regexp's.
76 // just output strings instead of XmlObjects
77 class Markup_html_br extends Markup_linebreak
79 function markup($match)
85 class Markup_html_simple_tag extends Markup_html_emphasis
87 function markup($match, $body)
89 $tag = substr($match, 1, -1);
93 return "*" . $body . "*";
95 return "<big>" . $body . "</big>";
98 return "_" . $body . "_";
103 class Markup_html_p extends BalancedMarkup
105 var $_start_regexp = "<(?:p|P)( class=\".*\")?>";
107 function getEndRegexp($match)
109 return "<\\/" . substr($match, 1);
112 function markup($match, $body)
118 //'<SPAN style="FONT-WEIGHT: bold">text</SPAN>' => '*text*'
119 class Markup_html_spanbold extends BalancedMarkup
121 var $_start_regexp = "<(?:span|SPAN) style=\"FONT-WEIGHT: bold\">";
123 function getEndRegexp($match)
125 return "<\\/" . substr($match, 1);
128 function markup($match, $body)
130 //Todo: convert style formatting to simplier nested <b><i> tags
131 return "*" . $body . "*";
135 class HtmlTransformer extends InlineTransformer
137 function HtmlTransformer($tags = false)
140 array('escape', 'html_br', 'html_spanbold', 'html_simple_tag',
143 'html_a','html_span','html_div',
144 'html_table','html_hr','html_pre',
146 'html_indent','html_ol','html_li','html_ul','html_img'
148 return $this->InlineTransformer($tags);
156 // c-hanging-comment-ender-p: nil
157 // indent-tabs-mode: nil