4 * Baseclass for WysiwygEdit/*
6 * ENABLE_WYSIWYG - Support for some WYSIWYG_BACKEND Editors:
7 * tinymce, htmlarea3, CKeditor, 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';
26 abstract class WysiwygEdit
29 function WysiwygEdit()
31 $this->_transformer_tags = false;
34 abstract function Head($name = 'edit[content]');
36 // to be called after </textarea>
37 abstract function Textarea($textarea, $wikitext, $name = 'edit[content]');
40 * Handler to convert the Wiki Markup to HTML before editing.
41 * This will be converted back by WysiwygEdit_ConvertAfter if required.
42 * *text* => '<b>text<b>'
47 function ConvertBefore($text)
50 * @var WikiRequest $request
54 require_once 'lib/BlockParser.php';
55 $xml = TransformText($text, $request->getArg('pagename'));
60 * FIXME: Handler to convert the HTML formatting back to wiki formatting.
61 * Derived from InlineParser, but returning wiki text instead of HtmlElement objects.
62 * '<b>text<b>' => '<span style="font-weight: bold">text</span>' => '*text*'
64 * TODO: Switch over to HtmlParser
69 function ConvertAfter($text)
73 $trfm = new HtmlTransformer($this->_transformer_tags);
75 $markup = $trfm->parse($text); // version 2.0
80 // re-use these classes for the regexp's.
81 // just output strings instead of XmlObjects
82 class Markup_html_br extends Markup_linebreak
84 function markup($match)
90 class Markup_html_simple_tag extends Markup_html_emphasis
92 function markup($match, $body)
94 $tag = substr($match, 1, -1);
98 return "*" . $body . "*";
100 return "<big>" . $body . "</big>";
103 return "_" . $body . "_";
109 class Markup_html_p extends BalancedMarkup
111 function getStartRegexp()
113 return "<(?:p|P)( class=\".*\")?>";
116 function getEndRegexp($match)
118 return "<\\/" . substr($match, 1);
121 function markup($match, $body)
127 //'<span style="font-weight: bold">text</span>' => '*text*'
128 class Markup_html_spanbold extends BalancedMarkup
130 function getStartRegexp()
132 return "<(?:span|SPAN) style=\"font-weight: bold\">";
135 function getEndRegexp($match)
137 return "<\\/" . substr($match, 1);
140 function markup($match, $body)
142 //Todo: convert style formatting to simplier nested <b><i> tags
143 return "*" . $body . "*";
147 class HtmlTransformer extends InlineTransformer
149 function __construct($tags = false)
152 $tags = array('escape', 'html_br', 'html_spanbold', 'html_simple_tag', 'html_p',);
154 'html_a','html_span','html_div',
155 'html_table','html_hr','html_pre',
157 'html_indent','html_ol','html_li','html_ul','html_img'
159 parent::__construct($tags);
167 // c-hanging-comment-ender-p: nil
168 // indent-tabs-mode: nil