[geeklog-cvs] geeklog: Implemented new function COM_renderWikiText to convert ...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Fri Oct 3 14:26:34 EDT 2008


details:   http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/47b75abdf9bc
changeset: 6416:47b75abdf9bc
user:      Dirk Haun <dirk at haun-online.de>
date:      Fri Oct 03 20:26:20 2008 +0200
description:
Implemented new function COM_renderWikiText to convert wiki-formatted text to (X)HTML (feature request #0000643)

diffstat:

3 files changed, 29 insertions(+), 16 deletions(-)
public_html/docs/history       |    2 ++
public_html/lib-common.php     |   25 +++++++++++++++++++++++++
system/classes/story.class.php |   18 ++----------------

diffs (82 lines):

diff -r c2d1fb443066 -r 47b75abdf9bc public_html/docs/history
--- a/public_html/docs/history	Fri Oct 03 19:18:41 2008 +0200
+++ b/public_html/docs/history	Fri Oct 03 20:26:20 2008 +0200
@@ -3,6 +3,8 @@
 ??? ??, 2008 (1.5.2)
 ------------
 
+- Implemented new function COM_renderWikiText to convert wiki-formatted text
+  to (X)HTML (feature request #0000643) [Dirk]
 - Added support for CUSTOM_formatEmailAddress and CUSTOM_emailEscape functions
   (feature request #0000727) [Dirk]
 - Fixed 'cookiedomain' being reported as changed in the Configuration
diff -r c2d1fb443066 -r 47b75abdf9bc public_html/lib-common.php
--- a/public_html/lib-common.php	Fri Oct 03 19:18:41 2008 +0200
+++ b/public_html/lib-common.php	Fri Oct 03 20:26:20 2008 +0200
@@ -6704,6 +6704,31 @@
     }
 }
 
+/**
+* Convert wiki-formatted text to (X)HTML
+*
+* @param    string  $wikitext   wiki-formatted text
+* @return   string              XHTML formatted text
+*
+*/
+function COM_renderWikiText($wikitext)
+{
+    global $_CONF;
+
+    if (!$_CONF['wikitext_editor']) {
+        return $wikitext;
+    }
+
+    require_once 'Text/Wiki.php';
+
+    $wiki = &new Text_Wiki();
+    $wiki->disableRule('wikilink');
+    $wiki->disableRule('freelink');
+    $wiki->disableRule('interwiki');
+
+    return $wiki->transform($wikitext, 'Xhtml');
+}
+
 // Now include all plugin functions
 foreach( $_PLUGINS as $pi_name )
 {
diff -r c2d1fb443066 -r 47b75abdf9bc system/classes/story.class.php
--- a/system/classes/story.class.php	Fri Oct 03 19:18:41 2008 +0200
+++ b/system/classes/story.class.php	Fri Oct 03 20:26:20 2008 +0200
@@ -1383,14 +1383,7 @@
             if ($this->_postmode == 'plaintext') {
                 $return = nl2br($this->_introtext);
             } elseif ($this->_postmode == 'wikitext') {
-                require_once 'Text/Wiki.php';
-
-                $wiki = &new Text_Wiki();
-                $wiki->disableRule('wikilink');
-                $wiki->disableRule('freelink');
-                $wiki->disableRule('interwiki');
-                $return = $this->_editUnescape($this->_introtext);
-                $return = $wiki->transform($return, 'Xhtml');
+                $return = COM_renderWikiText($this->_editUnescape($this->_introtext));
             } else {
                 $return = $this->_introtext;
             }
@@ -1402,14 +1395,7 @@
             if (($this->_postmode == 'plaintext') && !(empty($this->_bodytext))) {
                 $return = nl2br($this->_bodytext);
             } elseif (($this->_postmode == 'wikitext') && !(empty($this->_bodytext))) {
-                require_once 'Text/Wiki.php';
-
-                $wiki = &new Text_Wiki();
-                $wiki->disableRule('wikilink');
-                $wiki->disableRule('freelink');
-                $wiki->disableRule('interwiki');
-                $return = $this->_editUnescape($this->_bodytext);
-                $return = $wiki->transform($return, 'Xhtml');
+                $return = COM_renderWikiText($this->_editUnescape($this->_bodytext));
             } elseif (!empty($this->_bodytext)) {
                 $return = $this->_displayEscape($this->_bodytext);
             }



More information about the geeklog-cvs mailing list