SourceForge logo
SourceForge logo
Menu

phpwiki-checkins

From: Reini U. <ru...@us...> - 2005年10月31日 16:46:26
Update of /cvsroot/phpwiki/phpwiki/lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29727
Modified Files:
	WysiwygEdit.php 
Log Message:
move old default transformers to baseclass
Index: WysiwygEdit.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/WysiwygEdit.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -2 -b -p -d -r1.1 -r1.2
--- WysiwygEdit.php	30 Oct 2005 14:22:15 -0000	1.1
+++ WysiwygEdit.php	31 Oct 2005 16:46:13 -0000	1.2
@@ -1,17 +1,20 @@
 <?php
+rcs_id('$Id$');
 /**
- * Baseclass for WysiwygEdit/tinymce, WysiwygEdit/htmlarea3, WysiwygEdit/htmlarea2
+ * Baseclass for WysiwygEdit/tinymce, WysiwygEdit/htmlarea3, WysiwygEdit/htmlarea2, ...
 *
- * ENABLE_WYSIWYG - Support for some WYSIWYG HTML Editor (tinymce or htmlarea3)
+ * ENABLE_WYSIWYG - Support for some WYSIWYG HTML Editors 
+ * (tinymce, htmlarea3, FCKeditor, spaw, htmlarea2, ...)
 * Not yet enabled, since we cannot convert HTML to Wiki Markup yet.
 * (See HtmlParser.php for the ongoing efforts)
- * We might use a HTML PageType, which is contra wiki, but some people 
+ * We might use a PageType=html, which is contra wiki, but some people 
 * might prefer HTML markup.
 *
- * TODO: Change from constant to user preference variable 
+ * TODO: Change from ENABLE_WYSIWYG constant to user preference variable 
 * (checkbox setting or edit click as in gmail),
 * when HtmlParser is finished.
 * Based upon htmlarea3.php and tinymce.php
- * WARNING! Incompatible with ENABLE_XHTML_XML
+ *
+ * WARNING! Probably incompatible with ENABLE_XHTML_XML (TestMe)
 *
 * @package WysiwygEdit
@@ -21,12 +24,9 @@
 require_once("lib/InlineParser.php");
 
-// TODO: move to config-default.ini
-if (!defined('USE_HTMLAREA3')) define('USE_HTMLAREA3', false);
-if (!defined('USE_HTMLAREA2')) define('USE_HTMLAREA2', false);
-if (!defined('USE_TINYMCE')) define('USE_TINYMCE', true);
-
 class WysiwygEdit {
 
- function WysiwygEdit() { }
+ function WysiwygEdit() { 
+ $this->_transformer_tags = false;
+ }
 
 function Head($name='edit[content]') {
@@ -52,9 +52,11 @@ class WysiwygEdit {
 * Derived from InlineParser, but returning wiki text instead of HtmlElement objects.
 * '<b>text<b>' => '<SPAN style="FONT-WEIGHT: bold">text</SPAN>' => '*text*'
+ *
+ * TODO: Switch over to HtmlParser
 */
 function ConvertAfter($text) {
 static $trfm;
 if (empty($trfm)) {
- $trfm = new HtmlTransformer();
+ $trfm = new HtmlTransformer($this->_transformer_tags);
 }
 $markup = $trfm->parse($text); // version 2.0
@@ -63,6 +65,75 @@ class WysiwygEdit {
 }
 
+// re-use these classes for the regexp's.
+// just output strings instead of XmlObjects
+class Markup_html_br extends Markup_linebreak {
+ function markup ($match) {
+ return $match;
+ }
+}
+
+class Markup_html_simple_tag extends Markup_html_emphasis {
+ function markup ($match, $body) {
+ $tag = substr($match, 1, -1);
+ switch ($tag) {
+ case 'b':
+ case 'strong':
+ return "*".$body."*";
+ case 'big': 
+ return "<big>".$body."</big>";
+ case 'i':
+ case 'em':
+ return "_".$body."_";
+ }
+ }
+}
+
+class Markup_html_p extends BalancedMarkup
+{
+ var $_start_regexp = "<(?:p|P)( class=\".*\")?>";
+
+ function getEndRegexp ($match) {
+ return "<\\/" . substr($match, 1);
+ }
+ function markup ($match, $body) {
+ return $body."\n";
+ }
+}
+
+//'<SPAN style="FONT-WEIGHT: bold">text</SPAN>' => '*text*'
+class Markup_html_spanbold extends BalancedMarkup
+{
+ var $_start_regexp = "<(?:span|SPAN) style=\"FONT-WEIGHT: bold\">";
+
+ function getEndRegexp ($match) {
+ return "<\\/" . substr($match, 1);
+ }
+ function markup ($match, $body) {
+ //Todo: convert style formatting to simplier nested <b><i> tags
+ return "*".$body."*";
+ }
+}
+
+class HtmlTransformer extends InlineTransformer
+{
+ function HtmlTransformer ($tags = false) {
+ if (!$tags) $tags = 
+ array('escape','html_br','html_spanbold','html_simple_tag',
+ 'html_p',);
+ /*
+ 'html_a','html_span','html_div',
+ 'html_table','html_hr','html_pre',
+ 'html_blockquote',
+ 'html_indent','html_ol','html_li','html_ul','html_img'
+ */
+ return $this->InlineTransformer($tags);
+ }
+}
+
 /*
 $Log$
+ Revision 1.2 2005年10月31日 16:46:13 rurban
+ move old default transformers to baseclass
+
 Revision 1.1 2005年10月30日 14:22:15 rurban
 refactor WysiwygEdit
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /