Source for file test_Text_Wiki.php
Documentation is available at test_Text_Wiki.php
// needed for error checking
require_once 'Text/Wiki.php';
* Eventually set an include path if all parsers/renderers not installed
* $Id: test_Text_Wiki.php,v 1.18 2006/03/01 16:58:17 justinpatrin Exp $
$parser = $render = $source = '';
$plist = array ('Default', 'BBCode', 'Cowiki', 'Doku', 'Mediawiki', 'Tiki');
$rlist = array ('Xhtml', 'Plain', 'Latex', 'Cowiki', 'Doku', 'Tiki', 'Ooosxw', 'Pdf', 'Docbook');
* Here we need to know if we are running from command line or from web
* That runs anyway: if (isset($_SERVER['SERVER_NAME'])) {
* but have some o(l|d)d compatibility problem ...
$parser = isset ($_SERVER['argv'][1 ]) ? $_SERVER['argv'][1 ] : 'BBCode';
$render = isset ($_SERVER['argv'][2 ]) ? $_SERVER['argv'][2 ] : 'Xhtml';
if (!isset ($_SERVER['argv'][3 ]) or !is_readable($sou = $_SERVER['argv'][3 ])) {
die ("Enter a text file to be processed as 3d argument\n First and second are parser and renderer\n");
if (isset ($_REQUEST['example'])
&& in_array($_REQUEST['exchoice'], $elist)) {
$_REQUEST['source'], $match)) {
$_REQUEST['parser'] = $match[1 ];
$_REQUEST['translate'] = true;
foreach (array ('parser'=> $plist[0 ], 'render'=> $rlist[0 ],
'exchoice'=> ($elist ? $elist[0 ] : ''), 'source'=> '')
if(!isset ($_REQUEST[$fld])) {
if (!isset ($_REQUEST['translate'])) {
echo bldHtml('', $plist, $rlist, $elist);
// instantiate a Text_Wiki object from the given class
// If you want to include rules, use
//$wiki = & Text_Wiki::singleton($parser, $rules);
// If you want to get a new copy of the class use factory
//$wiki =& Text_Wiki::factory($parser);
// when rendering XHTML, make sure wiki links point to a
//$wiki->setRenderConf('xhtml', 'wikilink', 'view_url',
// 'http://example.com/view.php?page=');
// set an array of pages that exist in the wiki
// and tell the XHTML renderer about them
//$pages = array('HomePage', 'AnotherPage', 'SomeOtherPage');
$wiki->setRenderConf ('xhtml', 'code', 'css_filename', 'codefilename');
// transform the wiki text into given rendering
$result = $wiki->transform ($source, $render);
// display the transformed text
echo bldHtml($result, $plist, $rlist, $elist);
if (PEAR ::isError ($result)) {
function bldOpt($name, $list) {
$ret .= " <option value='{$opt}'".
($opt == $_REQUEST[$name]? " selected" : "").
function bldHtml($result, $plist, $rlist, $elist) {
$optparser = bldOpt('parser', $plist);
$optrender = bldOpt('render', $rlist);
$optexample = bldOpt('exchoice', $elist);
if (PEAR ::isError ($result)) {
$hresult = '<span class="error">' .
if ($_REQUEST['render'] != 'Xhtml') {
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<title>PEAR::Text_Wiki Demo</title>
<meta name="AUTHOR" content="bertrand Gugger / Toggg">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="KEYWORDS" content="PEAR, Wiki, Parse, Render, Convert, PHP, BBCode, Xhtml, Plain, Latex">
text-decoration: underline;
<h3>PEAR::Text_Wiki Demo</h3>
<div style="float: left;">
<SELECT name="parser">{ $optparser}</SELECT>
<SELECT name="render">{ $optrender}</SELECT>
<INPUT type="submit" name="translate" value="translate" />
<textarea name="source" cols="60" rows="25">{ $_REQUEST['source']}</textarea>
<SELECT name="exchoice">{ $optexample}</SELECT>
<INPUT type="submit" name="example" value="Load example" />
<div style="float: down; font-family: monospace;">
&& (substr($subfil, -4 ) == '.txt')) {
Documentation generated on Mon, 11 Mar 2019 14:37:33 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|