Changeset 756

Show
Ignore:
Timestamp:
12/29/07 16:16:52 (11 months ago)
Author:
michiel
Message:

Support MediaWiki? input format using PEAR::Text_Wiki_Mediawiki.
We ship the PEAR packages because they are labeled alpha so cannot be installed easily using pear on hosted platforms

Re #105

Location:
team/michiel/input_formats
Files:
200 added
2 modified

Legend:

Unmodified
Added
Removed
  • team/michiel/input_formats/common/mvblog_admin.php

    r755 r756  
    12931293                //put all known dossiers in $this->dossiers array 
    12941294                $this->_get_dossiers(); 
     1295                //only HTML and BBCODE can be handled by tinymce 
     1296                if (in_array($post["postformat"], array("HTML", "BBC")) && $this->settings["wysiwyg"]) 
     1297                        $autoload = 1; 
     1298                else 
     1299                        $autoload = 0; 
    12951300                ?> 
    12961301                <script language="javascript" type="text/javascript" src="../tiny_mce/tiny_mce_gzip.js"></script> 
     
    13061311                <?php 
    13071312                echo sprintf("<script language=\"javascript\" type=\"text/javascript\" src=\"../common/tinymce_conf.js.php?mode=%s&autoload=%d\"></script>\n", 
    1308                         $post["postformat"], $this->settings["wysiwyg"]); 
     1313                        $post["postformat"], $autoload); 
    13091314                ?> 
    13101315                <script language="javascript" type="text/javascript" src="../common/tinymce_filemanager.js"></script> 
     
    17981803                                                                <option value="HTML"<?php if ($settings["defaultpostformat"] == "HTML") echo " selected=\"selected\""; ?>>HTML</option> 
    17991804                                                                <option value="BBC"<?php if ($settings["defaultpostformat"] == "BBC") echo " selected=\"selected\""; ?>>BBCode</option> 
     1805                                                                <option value="MW"<?php if ($settings["defaultpostformat"] == "MW") echo " selected=\"selected\""; ?>>MediaWiki</option> 
    18001806                                                        </select> 
    18011807                                                </td> 
  • team/michiel/input_formats/common/mvblog_common.php

    r754 r756  
    407407         * - BBC: bbcode - uses internal bbcode parser 
    408408         * - HTML: html sourcecode - no processing is done 
     409         * - MW: MediaWiki sourcecode - uses PEAR::Text_Wiki_Mediawiki 
    409410         * 
    410411         * @param string $body The raw body data 
     
    416417                case "BBC": 
    417418                        $body = $this->parse_bbcode($body); 
     419                        break; 
     420                case "MW": 
     421                        $body = $this->parse_mediawiki($body); 
    418422                        break; 
    419423                } 
     
    489493                } 
    490494                return(stripslashes($string)); 
     495        } 
     496        /* }}} */ 
     497        /* parse_mediawiki {{{ */ 
     498        /** 
     499         * Parse Mediawiki formatted string into XHTML. 
     500         * This function uses PEAR::Text_Wiki and PEAR::Text_Wiki_Mediawiki. 
     501         * Because all plugins for Text_Wiki are alpha we include these 2 packages 
     502         * in the MvBlog sources. 
     503         * 
     504         * @param string $data The mediawiki source 
     505         * @return string XHTML representation of the wiki source 
     506         */ 
     507        public function parse_mediawiki($data) { 
     508                //add our PEAR directory to the include path 
     509                set_include_path(get_include_path().PATH_SEPARATOR.dirname(__FILE__)."/../lib/"); 
     510                //include the PEAR files 
     511                require_once("Text/Wiki.php"); 
     512                //wiki object 
     513                $wiki =& Text_Wiki::singleton("Mediawiki"); 
     514                $xhtml = $wiki->transform($data, "Xhtml"); 
     515                unset($wiki); 
     516                return $xhtml; 
    491517        } 
    492518        /* }}} */