Initial Commit

This commit is contained in:
Riley Schneider
2025-12-03 16:38:10 +01:00
parent c5e26bf594
commit b732d8d4b5
17680 changed files with 5977495 additions and 2 deletions

View File

@@ -0,0 +1,54 @@
<?php
/**
*
* Address rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
*
* @package Text_Wiki
*
* @author Michele Tomaiuolo <tomamic@yahoo.it>
*
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
*
* @version CVS: $Id: Address.php 228638 2007-02-01 09:33:00Z mic $
*
* @link http://pear.php.net/package/Text_Wiki
*
*/
class Text_Wiki_Render_Xhtml_Address extends Text_Wiki_Render {
var $conf = array(
'css' => null
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
if ($options['type'] == 'start') {
$css = $this->formatConf(' class="%s"', 'css');
return "<address$css>";
}
if ($options['type'] == 'end') {
return '</address>';
}
}
}
?>

View File

@@ -0,0 +1,48 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Anchor rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Anchor.php 206940 2006-02-10 23:07:03Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders an anchor target name in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Anchor extends Text_Wiki_Render {
var $conf = array(
'css' => null
);
function token($options)
{
extract($options); // $type, $name
if ($type == 'start') {
$css = $this->formatConf(' class="%s"', 'css');
$format = "<a$css id=\"%s\">";
return sprintf($format, $this->textEncode($name));
}
if ($type == 'end') {
return '</a>';
}
}
}
?>

View File

@@ -0,0 +1,72 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Blockquote rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Blockquote.php 236408 2007-05-26 18:25:45Z mic $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders a blockquote in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Blockquote extends Text_Wiki_Render {
var $conf = array(
'css' => null
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
$type = $options['type'];
$level = $options['level'];
// set up indenting so that the results look nice; we do this
// in two steps to avoid str_pad mathematics. ;-)
$pad = str_pad('', $level, "\t");
$pad = str_replace("\t", ' ', $pad);
// pick the css type
$css = $this->formatConf(' class="%s"', 'css');
if (isset($options['css'])) {
$css = ' class="' . $options['css']. '"';
}
// starting
if ($type == 'start') {
return "$pad<blockquote$css>";
}
// ending
if ($type == 'end') {
return $pad . "</blockquote>\n";
}
}
}
?>

View File

@@ -0,0 +1,57 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Bold rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Bold.php 191862 2005-07-30 08:03:29Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders bold text in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Bold extends Text_Wiki_Render {
var $conf = array(
'css' => null
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
if ($options['type'] == 'start') {
$css = $this->formatConf(' class="%s"', 'css');
return "<b$css>";
}
if ($options['type'] == 'end') {
return '</b>';
}
}
}
?>

View File

@@ -0,0 +1,62 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Box rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Box.php 231098 2007-03-03 23:00:54Z mic $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders a box drawn in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Box extends Text_Wiki_Render {
var $conf = array(
'css' => 'simplebox'
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
if ($options['type'] == 'start') {
if ($options['css']) {
$css = ' class="' . $options['css']. '"';
}
else {
$css = $this->formatConf(' class="%s"', 'css');
}
return "<div $css>";
}
if ($options['type'] == 'end') {
return '</div>';
}
}
}
?>

View File

@@ -0,0 +1,52 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Break rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Break.php 191862 2005-07-30 08:03:29Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders line breaks in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Break extends Text_Wiki_Render {
var $conf = array(
'css' => null
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
$css = $this->formatConf(' class="%s"', 'css');
return "<br$css />\n";
}
}
?>

View File

@@ -0,0 +1,62 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Center rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Center.php 230212 2007-02-19 08:51:19Z mic $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders centered content in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Center extends Text_Wiki_Render {
var $conf = array(
'css' => null
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
if ($options['type'] == 'start') {
$css = $this->getConf('css');
if ($css) {
return "<div class=\"$css\">";
}
else {
return '<div style="text-align: center;">';
}
}
if ($options['type'] == 'end') {
return '</div>';
}
}
}
?>

View File

@@ -0,0 +1,133 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Code rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Code.php 206940 2006-02-10 23:07:03Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders code blocks in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Code extends Text_Wiki_Render {
var $conf = array(
'css' => null, // class for <pre>
'css_code' => null, // class for generic <code>
'css_php' => null, // class for PHP <code>
'css_html' => null, // class for HTML <code>
'css_filename' => null // class for optional filename <div>
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
$text = $options['text'];
$attr = $options['attr'];
$type = strtolower($attr['type']);
$css = $this->formatConf(' class="%s"', 'css');
$css_code = $this->formatConf(' class="%s"', 'css_code');
$css_php = $this->formatConf(' class="%s"', 'css_php');
$css_html = $this->formatConf(' class="%s"', 'css_html');
$css_filename = $this->formatConf(' class="%s"', 'css_filename');
if ($type == 'php') {
if (substr($options['text'], 0, 5) != '<?php') {
// PHP code example:
// add the PHP tags
$text = "<?php\n" . $options['text'] . "\n?>"; // <?php
}
// convert tabs to four spaces
$text = str_replace("\t", " ", $text);
// colorize the code block (also converts HTML entities and adds
// <code>...</code> tags)
ob_start();
highlight_string($text);
$text = ob_get_contents();
ob_end_clean();
// replace <br /> tags with simple newlines.
// replace non-breaking space with simple spaces.
// translate HTML <font> and color to XHTML <span> and style.
// courtesy of research by A. Kalin :-).
$map = array(
'<br />' => "\n",
'&nbsp;' => ' ',
'<font' => '<span',
'</font>' => '</span>',
'color="' => 'style="color:'
);
$text = strtr($text, $map);
// get rid of the last newline inside the code block
// (becuase higlight_string puts one there)
if (substr($text, -8) == "\n</code>") {
$text = substr($text, 0, -8) . "</code>";
}
// replace all <code> tags with classed tags
if ($css_php) {
$text = str_replace('<code>', "<code$css_php>", $text);
}
// done
$text = "<pre$css>$text</pre>";
} elseif ($type == 'html' || $type == 'xhtml') {
// HTML code example:
// add <html> opening and closing tags,
// convert tabs to four spaces,
// convert entities.
$text = str_replace("\t", " ", $text);
$text = "<html>\n$text\n</html>";
$text = $this->textEncode($text);
$text = "<pre$css><code$css_html>$text</code></pre>";
} else {
// generic code example:
// convert tabs to four spaces,
// convert entities.
$text = str_replace("\t", " ", $text);
$text = $this->textEncode($text);
$text = "<pre$css><code$css_code>$text</code></pre>";
}
if ($css_filename && isset($attr['filename'])) {
$text = "<div$css_filename>" .
$attr['filename'] . '</div>' . $text;
}
return "\n$text\n\n";
}
}
?>

View File

@@ -0,0 +1,79 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Colortext rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Colortext.php 191862 2005-07-30 08:03:29Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders colored text in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Colortext extends Text_Wiki_Render {
var $colors = array(
'aqua',
'black',
'blue',
'fuchsia',
'gray',
'green',
'lime',
'maroon',
'navy',
'olive',
'purple',
'red',
'silver',
'teal',
'white',
'yellow'
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
$type = $options['type'];
$color = $options['color'];
if (! in_array($color, $this->colors) && $color{0} != '#') {
$color = '#' . $color;
}
if ($type == 'start') {
return "<span style=\"color: $color;\">";
}
if ($options['type'] == 'end') {
return '</span>';
}
}
}
?>

View File

@@ -0,0 +1,87 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Deflist rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Deflist.php 191862 2005-07-30 08:03:29Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders definition lists in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Deflist extends Text_Wiki_Render {
var $conf = array(
'css_dl' => null,
'css_dt' => null,
'css_dd' => null
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
$type = $options['type'];
$pad = " ";
switch ($type) {
case 'list_start':
$css = $this->formatConf(' class="%s"', 'css_dl');
return "<dl$css>\n";
break;
case 'list_end':
return "</dl>\n\n";
break;
case 'term_start':
$css = $this->formatConf(' class="%s"', 'css_dt');
return $pad . "<dt$css>";
break;
case 'term_end':
return "</dt>\n";
break;
case 'narr_start':
$css = $this->formatConf(' class="%s"', 'css_dd');
return $pad . $pad . "<dd$css>";
break;
case 'narr_end':
return "</dd>\n";
break;
default:
return '';
}
}
}
?>

View File

@@ -0,0 +1,46 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Delimiter rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Delimiter.php 191862 2005-07-30 08:03:29Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class set back the replaced delimiters in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Delimiter extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
return $options['text'];
}
}
?>

View File

@@ -0,0 +1,46 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Embed rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Embed.php 191862 2005-07-30 08:03:29Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class replaces the embedded php output in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Embed extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
return $options['text'];
}
}
?>

View File

@@ -0,0 +1,58 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Emphasis rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Emphasis.php 191862 2005-07-30 08:03:29Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders emphasized text in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Emphasis extends Text_Wiki_Render {
var $conf = array(
'css' => null
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
if ($options['type'] == 'start') {
$css = $this->formatConf(' class="%s"', 'css');
return "<em$css>";
}
if ($options['type'] == 'end') {
return '</em>';
}
}
}
?>

View File

@@ -0,0 +1,83 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* BBCode: extra Font rules renderer to size the text
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @copyright 2005 bertrand Gugger
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Font.php 192578 2005-08-06 11:36:45Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* Font rule render class (used for BBCode)
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @copyright 2005 bertrand Gugger
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
* @see Text_Wiki::Text_Wiki_Render()
*/
class Text_Wiki_Render_Xhtml_Font extends Text_Wiki_Render {
/* var $size = array(
'xx-small',
'x-small',
'small',
'medium',
'large',
'x-large',
'xx-large',
'larger',
'smaller'
);
var $units = array(
'em',
'ex',
'px',
'in',
'cm',
'mm',
'pt',
'pc'
);
*/
/**
* Renders a token into text matching the requested format.
* process the font size option
*
* @access public
* @param array $options The "options" portion of the token (second element).
* @return string The text rendered from the token options.
*/
function token($options)
{
if ($options['type'] == 'end') {
return '</span>';
}
if ($options['type'] != 'start') {
return '';
}
$ret = '<span style="';
if (isset($options['size'])) {
$size = trim($options['size']);
if (is_numeric($size)) {
$size .= 'px';
}
$ret .= "font-size: $size;";
}
return $ret.'">';
}
}
?>

View File

@@ -0,0 +1,35 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Freelink rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Freelink.php 191862 2005-07-30 08:03:29Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* The wikilink render class.
*/
require_once 'Text/Wiki/Render/Xhtml/Wikilink.php';
/**
* This class renders free links in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Freelink extends Text_Wiki_Render_Xhtml_Wikilink {
// renders identically to wikilinks, only the parsing is different :-)
}
?>

View File

@@ -0,0 +1,108 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Function rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Function.php 206940 2006-02-10 23:07:03Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders a function description in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Function extends Text_Wiki_Render {
var $conf = array(
// list separator for params and throws
'list_sep' => ', ',
// the "main" format string
'format_main' => '%access %return <b>%name</b> ( %params ) %throws',
// the looped format string for required params
'format_param' => '%type <i>%descr</i>',
// the looped format string for params with default values
'format_paramd' => '[%type <i>%descr</i> default %default]',
// the looped format string for throws
'format_throws' => '<b>throws</b> %type <i>%descr</i>'
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
extract($options); // name, access, return, params, throws
// build the baseline output
$output = $this->conf['format_main'];
$output = str_replace('%access', $this->textEncode($access), $output);
$output = str_replace('%return', $this->textEncode($return), $output);
$output = str_replace('%name', $this->textEncode($name), $output);
// build the set of params
$list = array();
foreach ($params as $key => $val) {
// is there a default value?
if ($val['default']) {
$tmp = $this->conf['format_paramd'];
} else {
$tmp = $this->conf['format_param'];
}
// add the param elements
$tmp = str_replace('%type', $this->textEncode($val['type']), $tmp);
$tmp = str_replace('%descr', $this->textEncode($val['descr']), $tmp);
$tmp = str_replace('%default', $this->textEncode($val['default']), $tmp);
$list[] = $tmp;
}
// insert params into output
$tmp = implode($this->conf['list_sep'], $list);
$output = str_replace('%params', $tmp, $output);
// build the set of throws
$list = array();
foreach ($throws as $key => $val) {
$tmp = $this->conf['format_throws'];
$tmp = str_replace('%type', $this->textEncode($val['type']), $tmp);
$tmp = str_replace('%descr', $this->textEncode($val['descr']), $tmp);
$list[] = $tmp;
}
// insert throws into output
$tmp = implode($this->conf['list_sep'], $list);
$output = str_replace('%throws', $tmp, $output);
// close the div and return the output
$output .= '</div>';
return "\n$output\n\n";
}
}
?>

View File

@@ -0,0 +1,88 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Heading rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Heading.php 196293 2005-09-18 13:39:39Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders headings in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Heading extends Text_Wiki_Render {
var $conf = array(
'css_h1' => null,
'css_h2' => null,
'css_h3' => null,
'css_h4' => null,
'css_h5' => null,
'css_h6' => null
);
function token($options)
{
$collapse = null;
static $jsOutput = false;
// get nice variable names (id, type, level)
extract($options);
switch($type) {
case 'start':
$css = $this->formatConf(' class="%s"', "css_h$level");
return '
<h'.$level.$css.' id="'.$id.'"'.($collapse !== null ? ' onclick="hideTOC(\''.$id.'\');"' : '').'>';
case 'end':
return '</h'.$level.'>
'.($collapse !== null ? '<a id="'.$id.'__link" href="javascript:void();" onclick="hideTOC(\''.$id.'\')">['.($collapse ? '+' : '-').']</a>
' : '');
case 'startContent':
if ($collapse !== null) {
if ($jsOutput) {
$js = '';
} else {
$js = '
<script language="javascript">
function hideTOC(id) {
div = document.getElementById(id+"__content");
link = document.getElementById(id+"__link");
if (div.style.display == "none") {
div.style.display = "";
link.innerHTML = "[-]";
} else {
div.style.display = "none";
link.innerHTML = "[+]";
}
}
</script>
';
}
} else {
$js = '';
}
return $js.'
<div style="'.($collapse === true ? 'display: none; ' : '').'padding: 0px; margin: 0px; border: none;" id="'.$id.'__content">
';
case 'endContent':
return '
</div>
';
}
}
}
?>

View File

@@ -0,0 +1,51 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Horiz rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Horiz.php 191862 2005-07-30 08:03:29Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders an horizontal bar in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Horiz extends Text_Wiki_Render {
var $conf = array(
'css' => null
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
$css = $this->formatConf(' class="%s"', 'css');
return "<hr$css />\n";
}
}
?>

View File

@@ -0,0 +1,47 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Html rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Html.php 191862 2005-07-30 08:03:29Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders preformated html in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Html extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
return $options['text'];
}
}
?>

View File

@@ -0,0 +1,184 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Image rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Image.php 231923 2007-03-15 15:04:50Z justinpatrin $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class inserts an image in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Image extends Text_Wiki_Render {
var $conf = array(
'base' => '/',
'url_base' => null,
'css' => null,
'css_link' => null
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
// note the image source
$src = $options['src'];
// is the source a local file or URL?
if (strpos($src, '://') === false) {
// the source refers to a local file.
// add the URL base to it.
$src = $this->getConf('base', '/') . $src;
}
// stephane@metacites.net
// is the image clickable?
if (isset($options['attr']['link'])) {
// yes, the image is clickable.
// are we linked to a URL or a wiki page?
if (strpos($options['attr']['link'], '://')) {
// it's a URL, prefix the URL base
$href = $this->getConf('url_base') . $options['attr']['link'];
} else {
// it's a WikiPage; assume it exists.
/** @todo This needs to honor sprintf wikilinks (pmjones) */
/** @todo This needs to honor interwiki (pmjones) */
/** @todo This needs to honor freelinks (pmjones) */
$href = $this->wiki->getRenderConf('xhtml', 'wikilink', 'view_url') .
$options['attr']['link'];
}
} else {
// image is not clickable.
$href = null;
}
// unset so it won't show up as an attribute
unset($options['attr']['link']);
// stephane@metacites.net -- 25/07/2004
// use CSS for all alignment
if (isset($options['attr']['align'])) {
// make sure we have a style attribute
if (!isset($options['attr']['style'])) {
// no style, set up a blank one
$options['attr']['style'] = '';
} else {
// style exists, add a space
$options['attr']['style'] .= ' ';
}
if ($options['attr']['align'] == 'center') {
// add a "center" style to the existing style.
$options['attr']['style'] .=
'display: block; margin-left: auto; margin-right: auto;';
} else {
// add a float style to the existing style
$options['attr']['style'] .=
'float: '.$options['attr']['align'];
}
// unset so it won't show up as an attribute
unset($options['attr']['align']);
}
// stephane@metacites.net -- 25/07/2004
// try to guess width and height
if (! isset($options['attr']['width']) &&
! isset($options['attr']['height'])) {
// does the source refer to a local file or a URL?
if (strpos($src,'://')) {
// is a URL link
$imageFile = $src;
} elseif ($src[0] == '.') {
// reg at dav-muz dot net -- 2005-03-07
// is a local file on relative path.
$imageFile = $src; # ...don't do anything because it's perfect!
} else {
// is a local file on absolute path.
$imageFile = $_SERVER['DOCUMENT_ROOT'] . $src;
}
// attempt to get the image size
$imageSize = @getimagesize($imageFile);
if (is_array($imageSize)) {
$options['attr']['width'] = $imageSize[0];
$options['attr']['height'] = $imageSize[1];
}
}
// start the HTML output
$output = '<img src="' . $this->textEncode($src) . '"';
// get the CSS class but don't add it yet
$css = $this->formatConf(' class="%s"', 'css');
// add the attributes to the output, and be sure to
// track whether or not we find an "alt" attribute
$alt = false;
foreach ($options['attr'] as $key => $val) {
// track the 'alt' attribute
if (strtolower($key) == 'alt') {
$alt = true;
}
// the 'class' attribute overrides the CSS class conf
if (strtolower($key) == 'class') {
$css = null;
}
$key = $this->textEncode($key);
$val = $this->textEncode($val);
$output .= " $key=\"$val\"";
}
// always add an "alt" attribute per Stephane Solliec
if (! $alt) {
$alt = $this->textEncode(basename($options['src']));
$output .= " alt=\"$alt\"";
}
// end the image tag with the automatic CSS class (if any)
$output .= "$css />";
// was the image clickable?
if ($href) {
// yes, add the href and return
$href = $this->textEncode($href);
$css = $this->formatConf(' class="%s"', 'css_link');
$output = "<a$css href=\"$href\">$output</a>";
}
return $output;
}
}
?>

View File

@@ -0,0 +1,32 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Include rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Include.php 191862 2005-07-30 08:03:29Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders included maekup in XHTML. (empty)
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Include extends Text_Wiki_Render {
function token()
{
return '';
}
}
?>

View File

@@ -0,0 +1,103 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Interwiki rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Interwiki.php 231896 2007-03-15 00:08:47Z justinpatrin $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders inter wikis links in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Interwiki extends Text_Wiki_Render {
var $conf = array(
'sites' => array(
'MeatBall' => 'http://www.usemod.com/cgi-bin/mb.pl?%s',
'Advogato' => 'http://advogato.org/%s',
'Wiki' => 'http://c2.com/cgi/wiki?%s'
),
'target' => '_blank',
'css' => null
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
$text = $options['text'];
if (isset($options['url'])) {
// calculated by the parser (e.g. Mediawiki)
$href = $options['url'];
} else {
$site = $options['site'];
// toggg 2006/02/05 page name must be url encoded (e.g. may contain spaces)
$page = $this->urlEncode($options['page']);
if (isset($this->conf['sites'][$site])) {
$href = $this->conf['sites'][$site];
} else {
return $text;
}
// old form where page is at end,
// or new form with %s placeholder for sprintf()?
if (strpos($href, '%s') === false) {
// use the old form
$href = $href . $page;
} else {
// use the new form
$href = sprintf($href, $page);
}
}
// allow for alternative targets
$target = $this->getConf('target');
// build base link
$css = $this->formatConf(' class="%s"', 'css');
$text = $this->textEncode($text);
$output = "<a$css href=\"$href\"";
// are we targeting a specific window?
if ($target && $target != '_self') {
// this is XHTML compliant, suggested by Aaron Kalin.
// code tip is actually from youngpup.net, and it
// uses the $target as the new window name.
$target = $this->textEncode($target);
$output .= " onclick=\"window.open(this.href, '$target');";
$output .= " return false;\"";
}
$output .= ">$text</a>";
return $output;
}
}
?>

View File

@@ -0,0 +1,57 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Italic rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Italic.php 191862 2005-07-30 08:03:29Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders italic text in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Italic extends Text_Wiki_Render {
var $conf = array(
'css' => null
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
if ($options['type'] == 'start') {
$css = $this->formatConf(' class="%s"', 'css');
return "<i$css>";
}
if ($options['type'] == 'end') {
return '</i>';
}
}
}
?>

View File

@@ -0,0 +1,172 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* List rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: List.php 200073 2005-11-06 10:38:25Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders bullet and ordered lists in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_List extends Text_Wiki_Render {
var $conf = array(
'css_ol' => null,
'css_ol_li' => null,
'css_ul' => null,
'css_ul_li' => null
);
/**
*
* Renders a token into text matching the requested format.
*
* This rendering method is syntactically and semantically compliant
* with XHTML 1.1 in that sub-lists are part of the previous list item.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
// make nice variables (type, level, count)
extract($options);
// set up indenting so that the results look nice; we do this
// in two steps to avoid str_pad mathematics. ;-)
$pad = str_pad('', $level, "\t");
$pad = str_replace("\t", ' ', $pad);
switch ($type) {
case 'bullet_list_start':
// build the base HTML
$css = $this->formatConf(' class="%s"', 'css_ul');
$html = "<ul$css>";
/*
// if this is the opening block for the list,
// put an extra newline in front of it so the
// output looks nice.
if ($level == 0) {
$html = "\n$html";
}
*/
// done!
return $html;
break;
case 'bullet_list_end':
// build the base HTML
$html = "</li>\n$pad</ul>";
// if this is the closing block for the list,
// put extra newlines after it so the output
// looks nice.
if ($level == 0) {
$html .= "\n\n";
}
// done!
return $html;
break;
case 'number_list_start':
if (isset($format)) {
$format = ' type="' . $format . '"';
} else {
$format = '';
}
// build the base HTML
$css = $this->formatConf(' class="%s"', 'css_ol');
$html = "<ol{$format}{$css}>";
/*
// if this is the opening block for the list,
// put an extra newline in front of it so the
// output looks nice.
if ($level == 0) {
$html = "\n$html";
}
*/
// done!
return $html;
break;
case 'number_list_end':
// build the base HTML
$html = "</li>\n$pad</ol>";
// if this is the closing block for the list,
// put extra newlines after it so the output
// looks nice.
if ($level == 0) {
$html .= "\n\n";
}
// done!
return $html;
break;
case 'bullet_item_start':
case 'number_item_start':
// pick the proper CSS class
if ($type == 'bullet_item_start') {
$css = $this->formatConf(' class="%s"', 'css_ul_li');
} else {
$css = $this->formatConf(' class="%s"', 'css_ol_li');
}
// build the base HTML
$html = "\n$pad<li$css>";
// for the very first item in the list, do nothing.
// but for additional items, be sure to close the
// previous item.
if ($count > 0) {
$html = "</li>$html";
}
// done!
return $html;
break;
case 'bullet_item_end':
case 'number_item_end':
default:
// ignore item endings and all other types.
// item endings are taken care of by the other types
// depending on their place in the list.
return '';
break;
}
}
}
?>

View File

@@ -0,0 +1,35 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Newline rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Newline.php 191862 2005-07-30 08:03:29Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders new lines in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Newline extends Text_Wiki_Render {
function token($options)
{
return "<br />\n";
}
}
?>

View File

@@ -0,0 +1,46 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Page rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Page.php 191862 2005-07-30 08:03:29Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders page markers in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Page extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
return 'PAGE MARKER HERE*&^%$#^$%*PAGEMARKERHERE';
}
}
?>

View File

@@ -0,0 +1,59 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Paragraph rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Paragraph.php 191862 2005-07-30 08:03:29Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders paragraphs in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Paragraph extends Text_Wiki_Render {
var $conf = array(
'css' => null
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
extract($options); //type
if ($type == 'start') {
$css = $this->formatConf(' class="%s"', 'css');
return "<p$css>";
}
if ($type == 'end') {
return "</p>\n\n";
}
}
}
?>

View File

@@ -0,0 +1,81 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Phplookup rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Phplookup.php 231896 2007-03-15 00:08:47Z justinpatrin $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders a link to php functions description in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Phplookup extends Text_Wiki_Render {
var $conf = array(
'target' => '_blank',
'css' => null
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
$text = trim($options['text']);
$css = $this->formatConf(' class="%s"', 'css');
// start the html
$output = "<a$css";
// are we targeting another window?
$target = $this->getConf('target', '');
if ($target && $target != '_self') {
// use a "popup" window. this is XHTML compliant, suggested by
// Aaron Kalin. uses the $target as the new window name.
$target = $this->textEncode($target);
$output .= " onclick=\"window.open(this.href, '$target');";
$output .= " return false;\"";
}
// take off the final parens for functions
if (substr($text, -2) == '()') {
$q = substr($text, 0, -2);
} else {
$q = $text;
}
// toggg 2006/02/05 page name must be url encoded (e.g. may contain spaces)
$q = $this->urlEncode($q);
$text = $this->textEncode($text);
// finish and return
$output .= " href=\"http://php.net/$q\">$text</a>";
return $output;
}
}
?>

View File

@@ -0,0 +1,47 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Plugin rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Plugin.php 191862 2005-07-30 08:03:29Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders wiki plugins in XHTML. (empty)
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Plugin extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
* Plugins produce wiki markup so are processed by parsing, no tokens produced
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
return '';
}
}
?>

View File

@@ -0,0 +1,34 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Prefilter rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Prefilter.php 191862 2005-07-30 08:03:29Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class implements a Text_Wiki_Render_Xhtml to "pre-filter" source text so
* that line endings are consistently \n, lines ending in a backslash \
* are concatenated with the next line, and tabs are converted to spaces.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Prefilter extends Text_Wiki_Render {
function token()
{
return '';
}
}
?>

View File

@@ -0,0 +1,47 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Preformatted rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Preformatted.php 229275 2007-02-07 13:40:44Z mic $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders preformated text in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Preformatted extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
$text = $this->textEncode($options['text']);
return '<pre>'.$text.'</pre>';
}
}
?>

View File

@@ -0,0 +1,46 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Raw rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Raw.php 214538 2006-06-09 21:32:24Z justinpatrin $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders not processed blocks in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Raw extends Text_Wiki_Render {
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
return $this->textEncode($options['text']);
}
}
?>

View File

@@ -0,0 +1,68 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Revise rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Revise.php 191862 2005-07-30 08:03:29Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders revision marks in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Revise extends Text_Wiki_Render {
var $conf = array(
'css_ins' => null,
'css_del' => null
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
if ($options['type'] == 'del_start') {
$css = $this->formatConf(' class="%s"', 'css_del');
return "<del$css>";
}
if ($options['type'] == 'del_end') {
return "</del>";
}
if ($options['type'] == 'ins_start') {
$css = $this->formatConf(' class="%s"', 'css_ins');
return "<ins$css>";
}
if ($options['type'] == 'ins_end') {
return "</ins>";
}
}
}
?>

View File

@@ -0,0 +1,74 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Smiley rule Xhtml renderer
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @copyright 2005 bertrand Gugger
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Smiley.php 206940 2006-02-10 23:07:03Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* Smiley rule Xhtml render class
*
* @category Text
* @package Text_Wiki
* @author Bertrand Gugger <bertrand@toggg.com>
* @copyright 2005 bertrand Gugger
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
* @see Text_Wiki::Text_Wiki_Render()
*/
class Text_Wiki_Render_Xhtml_Smiley extends Text_Wiki_Render {
/**
* Configuration keys for this rule
* 'prefix' => the path to smileys images inclusive file name prefix,
* starts with '/' ==> abolute reference
* if no file names prefix but some folder, terminates with '/'
* 'extension' => the file extension (inclusive '.'), e.g. :
* if prefix 'smileys/icon_' and extension '.gif'
* ':)' whose name is 'smile' will give relative file 'smileys/icon_smile.gif'
* if prefix '/image/smileys/' and extension '.png': absolute '/image/smileys/smile.gif'
* 'css' => optional style applied to smileys
*
* @access public
* @var array 'config-key' => mixed config-value
*/
var $conf = array(
'prefix' => 'images/smiles/icon_',
'extension' => '.gif',
'css' => null
);
/**
* Renders a token into text matching the requested format.
* process the Smileys
*
* @access public
* @param array $options The "options" portion of the token (second element).
* @return string The text rendered from the token options.
*/
function token($options)
{
$imageFile = $this->getConf('prefix') . $options['name'] . $this->getConf('extension');
// attempt to get the image size
$imageSize = @getimagesize($imageFile);
// return the HTML output
return '<img src="' . $this->textEncode($imageFile) . '"' .
(is_array($imageSize) ?
' width="' . $imageSize[0] . '" height="' . $imageSize[1] .'"' : '') .
' alt="' . $options['desc'] . '"' .
$this->formatConf(' class="%s"', 'css') . ' />';
}
}
?>

View File

@@ -0,0 +1,52 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Specialchar rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Specialchar.php 191862 2005-07-30 08:03:29Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders special characters in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_SpecialChar extends Text_Wiki_Render {
var $types = array('~bs~' => '&#92;',
'~hs~' => '&nbsp;',
'~amp~' => '&amp;',
'~ldq~' => '&ldquo;',
'~rdq~' => '&rdquo;',
'~lsq~' => '&lsquo;',
'~rsq~' => '&rsquo;',
'~c~' => '&copy;',
'~--~' => '&mdash;',
'" -- "' => '&mdash;',
'&quot; -- &quot;' => '&mdash;',
'~lt~' => '&lt;',
'~gt~' => '&gt;');
function token($options)
{
if (isset($this->types[$options['char']])) {
return $this->types[$options['char']];
} else {
return '&#'.substr($options['char'], 1, -1).';';
}
}
}
?>

View File

@@ -0,0 +1,58 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Strong rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Strong.php 191862 2005-07-30 08:03:29Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders text marked as strong in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Strong extends Text_Wiki_Render {
var $conf = array(
'css' => null
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
if ($options['type'] == 'start') {
$css = $this->formatConf(' class="%s"', 'css');
return "<strong$css>";
}
if ($options['type'] == 'end') {
return '</strong>';
}
}
}
?>

View File

@@ -0,0 +1,57 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Subscript rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Subscript.php 191862 2005-07-30 08:03:29Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders subscript text in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Subscript extends Text_Wiki_Render {
var $conf = array(
'css' => null
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
if ($options['type'] == 'start') {
$css = $this->formatConf(' class="%s"', 'css');
return "<sub$css>";
}
if ($options['type'] == 'end') {
return '</sub>';
}
}
}
?>

View File

@@ -0,0 +1,57 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Superscript rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Superscript.php 191862 2005-07-30 08:03:29Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders superscript text in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Superscript extends Text_Wiki_Render {
var $conf = array(
'css' => null
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
if ($options['type'] == 'start') {
$css = $this->formatConf(' class="%s"', 'css');
return "<sup$css>";
}
if ($options['type'] == 'end') {
return '</sup>';
}
}
}
?>

View File

@@ -0,0 +1,140 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Table rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Table.php 202250 2005-12-06 15:29:29Z ritzmo $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders tables in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Table extends Text_Wiki_Render {
var $conf = array(
'css_table' => null,
'css_caption' => null,
'css_tr' => null,
'css_th' => null,
'css_td' => null
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
// make nice variable names (type, attr, span)
$span = $rowspan = 1;
extract($options);
// free format
$format = isset($format) ? ' '. $format : '';
$pad = ' ';
switch ($type) {
case 'table_start':
$css = $this->formatConf(' class="%s"', 'css_table');
return "\n\n<table$css$format>\n";
break;
case 'table_end':
return "</table>\n\n";
break;
case 'caption_start':
$css = $this->formatConf(' class="%s"', 'css_caption');
return "<caption$css$format>\n";
break;
case 'caption_end':
return "</caption>\n";
break;
case 'row_start':
$css = $this->formatConf(' class="%s"', 'css_tr');
return "$pad<tr$css$format>\n";
break;
case 'row_end':
return "$pad</tr>\n";
break;
case 'cell_start':
// base html
$html = $pad . $pad;
// is this a TH or TD cell?
if ($attr == 'header') {
// start a header cell
$css = $this->formatConf(' class="%s"', 'css_th');
$html .= "<th$css";
} else {
// start a normal cell
$css = $this->formatConf(' class="%s"', 'css_td');
$html .= "<td$css";
}
// add the column span
if ($span > 1) {
$html .= " colspan=\"$span\"";
}
// add the row span
if ($rowspan > 1) {
$html .= " rowspan=\"$rowspan\"";
}
// add alignment
if ($attr != 'header' && $attr != '') {
$html .= " style=\"text-align: $attr;\"";
}
// done!
$html .= "$format>";
return $html;
break;
case 'cell_end':
if ($attr == 'header') {
return "</th>\n";
} else {
return "</td>\n";
}
break;
default:
return '';
}
}
}
?>

View File

@@ -0,0 +1,34 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Tighten rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Tighten.php 191862 2005-07-30 08:03:29Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class makes the tightening in XHTML. (empty)
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Tighten extends Text_Wiki_Render {
function token()
{
return '';
}
}
?>

View File

@@ -0,0 +1,57 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Titlebar rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Titlebar.php 191862 2005-07-30 08:03:29Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders a title bar in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Titlebar extends Text_Wiki_Render {
var $conf = array(
'css' => 'titlebar'
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
if ($options['type'] == 'start') {
$css = $this->formatConf(' class="%s"', 'css');
return "<div$css>";
}
if ($options['type'] == 'end') {
return '</div>';
}
}
}
?>

View File

@@ -0,0 +1,115 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Toc rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Toc.php 191862 2005-07-30 08:03:29Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class inserts a table of content in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Toc extends Text_Wiki_Render {
var $conf = array(
'css_list' => null,
'css_item' => null,
'title' => '<strong>Table of Contents</strong>',
'div_id' => 'toc',
'collapse' => true
);
var $min = 2;
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
// type, id, level, count, attr
extract($options);
switch ($type) {
case 'list_start':
$css = $this->getConf('css_list');
$html = '';
// collapse div within a table?
if ($this->getConf('collapse')) {
$html .= '<table border="0" cellspacing="0" cellpadding="0">';
$html .= "<tr><td>\n";
}
// add the div, class, and id
$html .= '<div';
if ($css) {
$html .= " class=\"$css\"";
}
$div_id = $this->getConf('div_id');
if ($div_id) {
$html .= " id=\"$div_id\"";
}
// add the title, and done
$html .= '>';
$html .= $this->getConf('title');
return $html;
break;
case 'list_end':
if ($this->getConf('collapse')) {
return "\n</div>\n</td></tr></table>\n\n";
} else {
return "\n</div>\n\n";
}
break;
case 'item_start':
$html = "\n\t<div";
$css = $this->getConf('css_item');
if ($css) {
$html .= " class=\"$css\"";
}
$pad = ($level - $this->min);
$html .= " style=\"margin-left: {$pad}em;\">";
$html .= "<a href=\"#$id\">";
return $html;
break;
case 'item_end':
return "</a></div>";
break;
}
}
}
?>

View File

@@ -0,0 +1,58 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Tt rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Tt.php 191862 2005-07-30 08:03:29Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders monospaced text in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Tt extends Text_Wiki_Render {
var $conf = array(
'css' => null
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
if ($options['type'] == 'start') {
$css = $this->formatConf(' class="%s"', 'css');
return "<tt$css>";
}
if ($options['type'] == 'end') {
return '</tt>';
}
}
}
?>

View File

@@ -0,0 +1,57 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Underline rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Underline.php 191862 2005-07-30 08:03:29Z toggg $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders underlined text in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Underline extends Text_Wiki_Render {
var $conf = array(
'css' => null
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
if ($options['type'] == 'start') {
$css = $this->formatConf(' class="%s"', 'css');
return "<u$css>";
}
if ($options['type'] == 'end') {
return '</u>';
}
}
}
?>

View File

@@ -0,0 +1,131 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Url rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Url.php 236400 2007-05-26 17:15:41Z mic $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders URL links in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Url extends Text_Wiki_Render {
var $conf = array(
'target' => '_blank',
'images' => true,
'img_ext' => array('jpg', 'jpeg', 'gif', 'png'),
'css_inline' => null,
'css_footnote' => null,
'css_descr' => null,
'css_img' => null
);
/**
*
* Renders a token into text matching the requested format.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
// create local variables from the options array (text,
// href, type)
extract($options);
// find the rightmost dot and determine the filename
// extension.
$pos = strrpos($href, '.');
$ext = strtolower(substr($href, $pos + 1));
$href = $this->textEncode($href);
// does the filename extension indicate an image file?
if ($this->getConf('images') &&
in_array($ext, $this->getConf('img_ext', array()))) {
// create alt text for the image
if (! isset($text) || $text == '') {
$text = basename($href);
$text = $this->textEncode($text);
}
// generate an image tag
$css = $this->formatConf(' class="%s"', 'css_img');
$start = "<img$css src=\"$href\" alt=\"$text\" title=\"$text\" /><!-- ";
$end = " -->";
} else {
// should we build a target clause?
if ($href{0} == '#' ||
strtolower(substr($href, 0, 7)) == 'mailto:') {
// targets not allowed for on-page anchors
// and mailto: links.
$target = '';
} else {
// allow targets on non-anchor non-mailto links
$target = $this->getConf('target');
}
// generate a regular link (not an image)
$text = $this->textEncode($text);
$css = $this->formatConf(' class="%s"', "css_$type");
$start = "<a$css href=\"$href\"";
if ($target && $target != '_self') {
// use a "popup" window. this is XHTML compliant, suggested by
// Aaron Kalin. uses the $target as the new window name.
$target = $this->textEncode($target);
$start .= " onclick=\"window.open(this.href, '$target');";
$start .= " return false;\"";
}
if (isset($name)) {
$start .= " id=\"$name\"";
}
// finish up output
$start .= ">";
$end = "</a>";
// make numbered references look like footnotes when no
// CSS class specified, make them superscript by default
if ($type == 'footnote' && ! $css) {
$start = '<sup>' . $start;
$end = $end . '</sup>';
}
}
if ($options['type'] == 'start') {
$output = $start;
} else if ($options['type'] == 'end') {
$output = $end;
} else {
$output = $start . $text . $end;
}
return $output;
}
}
?>

View File

@@ -0,0 +1,177 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
/**
* Wikilink rule end renderer for Xhtml
*
* PHP versions 4 and 5
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Wikilink.php 224670 2006-12-08 21:25:24Z justinpatrin $
* @link http://pear.php.net/package/Text_Wiki
*/
/**
* This class renders wiki links in XHTML.
*
* @category Text
* @package Text_Wiki
* @author Paul M. Jones <pmjones@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Text_Wiki
*/
class Text_Wiki_Render_Xhtml_Wikilink extends Text_Wiki_Render {
var $conf = array(
'pages' => array(), // set to null or false to turn off page checks
'view_url' => 'http://example.com/index.php?page=%s',
'new_url' => 'http://example.com/new.php?page=%s',
'new_text' => '?',
'new_text_pos' => 'after', // 'before', 'after', or null/false
'css' => null,
'css_new' => null,
'exists_callback' => null // call_user_func() callback
);
/**
*
* Renders a token into XHTML.
*
* @access public
*
* @param array $options The "options" portion of the token (second
* element).
*
* @return string The text rendered from the token options.
*
*/
function token($options)
{
// make nice variable names (page, anchor, text)
extract($options);
// is there a "page existence" callback?
// we need to access it directly instead of through
// getConf() because we'll need a reference (for
// object instance method callbacks).
if (isset($this->conf['exists_callback'])) {
$callback =& $this->conf['exists_callback'];
} else {
$callback = false;
}
if ($callback) {
// use the callback function
$exists = call_user_func($callback, $page);
} else {
// no callback, go to the naive page array.
$list = $this->getConf('pages');
if (is_array($list)) {
// yes, check against the page list
$exists = in_array($page, $list);
} else {
// no, assume it exists
$exists = true;
}
}
$anchor = '#'.$this->urlEncode(substr($anchor, 1));
// does the page exist?
if ($exists) {
// PAGE EXISTS.
// link to the page view, but we have to build
// the HREF. we support both the old form where
// the page always comes at the end, and the new
// form that uses %s for sprintf()
$href = $this->getConf('view_url');
if (strpos($href, '%s') === false) {
// use the old form (page-at-end)
$href = $href . $this->urlEncode($page) . $anchor;
} else {
// use the new form (sprintf format string)
$href = sprintf($href, $this->urlEncode($page)) . $anchor;
}
// get the CSS class and generate output
$css = ' class="'.$this->textEncode($this->getConf('css')).'"';
$start = '<a'.$css.' href="'.$this->textEncode($href).'">';
$end = '</a>';
} else {
// PAGE DOES NOT EXIST.
// link to a create-page url, but only if new_url is set
$href = $this->getConf('new_url', null);
// set the proper HREF
if (! $href || trim($href) == '') {
// no useful href, return the text as it is
//TODO: This is no longer used, need to look closer into this branch
$output = $text;
} else {
// yes, link to the new-page href, but we have to build
// it. we support both the old form where
// the page always comes at the end, and the new
// form that uses sprintf()
if (strpos($href, '%s') === false) {
// use the old form
$href = $href . $this->urlEncode($page);
} else {
// use the new form
$href = sprintf($href, $this->urlEncode($page));
}
}
// get the appropriate CSS class and new-link text
$css = ' class="'.$this->textEncode($this->getConf('css_new')).'"';
$new = $this->getConf('new_text');
// what kind of linking are we doing?
$pos = $this->getConf('new_text_pos');
if (! $pos || ! $new) {
// no position (or no new_text), use css only on the page name
$start = '<a'.$css.' href="'.$this->textEncode($href).'">';
$end = '</a>';
} elseif ($pos == 'before') {
// use the new_text BEFORE the page name
$start = '<a'.$css.' href="'.$this->textEncode($href).'">'.$this->textEncode($new).'</a>';
$end = '';
} else {
// default, use the new_text link AFTER the page name
$start = '';
$end = '<a'.$css.' href="'.$this->textEncode($href).'">'.$this->textEncode($new).'</a>';
}
}
if (!strlen($text)) {
$start .= $this->textEncode($page);
}
if (isset($type)) {
switch ($type) {
case 'start':
$output = $start;
break;
case 'end':
$output = $end;
break;
}
} else {
$output = $start.$this->textEncode($text).$end;
}
return $output;
}
}
?>