From 6d7c9fbdc8220285dafb76fae98d206f3afa8f12 Mon Sep 17 00:00:00 2001 From: nohn Date: Thu, 14 Jul 2005 06:46:53 +0000 Subject: [PATCH] forgot something... --- bundled-libs/Net/CheckIP.php | 2 +- bundled-libs/Net/Socket.php | 386 +++++++++++------- bundled-libs/Net/URL.php | 2 +- bundled-libs/Text/Wiki/Parse.php | 253 ++++++++++++ .../Text/Wiki/Parse/Default/Anchor.php | 67 +++ .../Text/Wiki/Parse/Default/Blockquote.php | 163 ++++++++ bundled-libs/Text/Wiki/Parse/Default/Bold.php | 61 +++ .../Text/Wiki/Parse/Default/Break.php | 54 +++ .../Text/Wiki/Parse/Default/Center.php | 60 +++ bundled-libs/Text/Wiki/Parse/Default/Code.php | 81 ++++ .../Text/Wiki/Parse/Default/Colortext.php | 74 ++++ .../Text/Wiki/Parse/Default/Deflist.php | 104 +++++ .../Text/Wiki/Parse/Default/Delimiter.php | 62 +++ .../Text/Wiki/Parse/Default/Embed.php | 88 ++++ .../Text/Wiki/Parse/Default/Emphasis.php | 67 +++ .../Text/Wiki/Parse/Default/Freelink.php | 111 +++++ .../Text/Wiki/Parse/Default/Function.php | 115 ++++++ .../Text/Wiki/Parse/Default/Heading.php | 89 ++++ .../Text/Wiki/Parse/Default/Horiz.php | 52 +++ bundled-libs/Text/Wiki/Parse/Default/Html.php | 57 +++ .../Text/Wiki/Parse/Default/Image.php | 76 ++++ .../Text/Wiki/Parse/Default/Include.php | 84 ++++ .../Text/Wiki/Parse/Default/Interwiki.php | 120 ++++++ .../Text/Wiki/Parse/Default/Italic.php | 67 +++ bundled-libs/Text/Wiki/Parse/Default/List.php | 230 +++++++++++ .../Text/Wiki/Parse/Default/Newline.php | 57 +++ .../Text/Wiki/Parse/Default/Paragraph.php | 128 ++++++ .../Text/Wiki/Parse/Default/Phplookup.php | 58 +++ .../Text/Wiki/Parse/Default/Prefilter.php | 62 +++ bundled-libs/Text/Wiki/Parse/Default/Raw.php | 55 +++ .../Text/Wiki/Parse/Default/Revise.php | 130 ++++++ .../Text/Wiki/Parse/Default/Strong.php | 67 +++ .../Text/Wiki/Parse/Default/Superscript.php | 67 +++ .../Text/Wiki/Parse/Default/Table.php | 208 ++++++++++ .../Text/Wiki/Parse/Default/Tighten.php | 32 ++ bundled-libs/Text/Wiki/Parse/Default/Toc.php | 112 +++++ bundled-libs/Text/Wiki/Parse/Default/Tt.php | 69 ++++ bundled-libs/Text/Wiki/Parse/Default/Url.php | 265 ++++++++++++ .../Text/Wiki/Parse/Default/Wikilink.php | 158 +++++++ bundled-libs/Text/Wiki/Render.php | 167 ++++++++ bundled-libs/Text/Wiki/Render/Latex.php | 90 ++++ .../Text/Wiki/Render/Latex/Anchor.php | 33 ++ .../Text/Wiki/Render/Latex/Blockquote.php | 36 ++ bundled-libs/Text/Wiki/Render/Latex/Bold.php | 4 + bundled-libs/Text/Wiki/Render/Latex/Break.php | 24 ++ .../Text/Wiki/Render/Latex/Center.php | 33 ++ bundled-libs/Text/Wiki/Render/Latex/Code.php | 26 ++ .../Text/Wiki/Render/Latex/Colortext.php | 58 +++ .../Text/Wiki/Render/Latex/Deflist.php | 53 +++ .../Text/Wiki/Render/Latex/Delimiter.php | 25 ++ bundled-libs/Text/Wiki/Render/Latex/Embed.php | 23 ++ .../Text/Wiki/Render/Latex/Emphasis.php | 29 ++ .../Text/Wiki/Render/Latex/Freelink.php | 34 ++ .../Text/Wiki/Render/Latex/Function.php | 23 ++ .../Text/Wiki/Render/Latex/Heading.php | 33 ++ bundled-libs/Text/Wiki/Render/Latex/Horiz.php | 23 ++ bundled-libs/Text/Wiki/Render/Latex/Html.php | 25 ++ bundled-libs/Text/Wiki/Render/Latex/Image.php | 70 ++++ .../Text/Wiki/Render/Latex/Include.php | 8 + .../Text/Wiki/Render/Latex/Interwiki.php | 60 +++ .../Text/Wiki/Render/Latex/Italic.php | 5 + bundled-libs/Text/Wiki/Render/Latex/List.php | 57 +++ .../Text/Wiki/Render/Latex/Newline.php | 12 + .../Text/Wiki/Render/Latex/Paragraph.php | 31 ++ .../Text/Wiki/Render/Latex/Phplookup.php | 34 ++ .../Text/Wiki/Render/Latex/Prefilter.php | 40 ++ bundled-libs/Text/Wiki/Render/Latex/Raw.php | 23 ++ .../Text/Wiki/Render/Latex/Revise.php | 38 ++ .../Text/Wiki/Render/Latex/Strong.php | 30 ++ .../Text/Wiki/Render/Latex/Superscript.php | 31 ++ bundled-libs/Text/Wiki/Render/Latex/Table.php | 93 +++++ .../Text/Wiki/Render/Latex/Tighten.php | 9 + bundled-libs/Text/Wiki/Render/Latex/Toc.php | 30 ++ bundled-libs/Text/Wiki/Render/Latex/Tt.php | 30 ++ bundled-libs/Text/Wiki/Render/Latex/Url.php | 35 ++ .../Text/Wiki/Render/Latex/Wikilink.php | 60 +++ bundled-libs/Text/Wiki/Render/Plain.php | 16 + .../Text/Wiki/Render/Plain/Anchor.php | 23 ++ .../Text/Wiki/Render/Plain/Blockquote.php | 39 ++ bundled-libs/Text/Wiki/Render/Plain/Bold.php | 23 ++ bundled-libs/Text/Wiki/Render/Plain/Break.php | 24 ++ .../Text/Wiki/Render/Plain/Center.php | 23 ++ bundled-libs/Text/Wiki/Render/Plain/Code.php | 24 ++ .../Text/Wiki/Render/Plain/Colortext.php | 23 ++ .../Text/Wiki/Render/Plain/Deflist.php | 59 +++ .../Text/Wiki/Render/Plain/Delimiter.php | 23 ++ bundled-libs/Text/Wiki/Render/Plain/Embed.php | 23 ++ .../Text/Wiki/Render/Plain/Emphasis.php | 23 ++ .../Text/Wiki/Render/Plain/Freelink.php | 23 ++ .../Text/Wiki/Render/Plain/Function.php | 39 ++ .../Text/Wiki/Render/Plain/Heading.php | 14 + bundled-libs/Text/Wiki/Render/Plain/Horiz.php | 23 ++ bundled-libs/Text/Wiki/Render/Plain/Html.php | 24 ++ bundled-libs/Text/Wiki/Render/Plain/Image.php | 22 + .../Text/Wiki/Render/Plain/Include.php | 8 + .../Text/Wiki/Render/Plain/Interwiki.php | 23 ++ .../Text/Wiki/Render/Plain/Italic.php | 23 ++ bundled-libs/Text/Wiki/Render/Plain/List.php | 68 +++ .../Text/Wiki/Render/Plain/Newline.php | 12 + .../Text/Wiki/Render/Plain/Paragraph.php | 31 ++ .../Text/Wiki/Render/Plain/Phplookup.php | 25 ++ .../Text/Wiki/Render/Plain/Prefilter.php | 40 ++ bundled-libs/Text/Wiki/Render/Plain/Raw.php | 23 ++ .../Text/Wiki/Render/Plain/Revise.php | 24 ++ .../Text/Wiki/Render/Plain/Strong.php | 24 ++ .../Text/Wiki/Render/Plain/Superscript.php | 23 ++ bundled-libs/Text/Wiki/Render/Plain/Table.php | 57 +++ .../Text/Wiki/Render/Plain/Tighten.php | 10 + bundled-libs/Text/Wiki/Render/Plain/Toc.php | 39 ++ bundled-libs/Text/Wiki/Render/Plain/Tt.php | 24 ++ bundled-libs/Text/Wiki/Render/Plain/Url.php | 25 ++ .../Text/Wiki/Render/Plain/Wikilink.php | 24 ++ bundled-libs/Text/Wiki/Render/Xhtml.php | 33 ++ .../Text/Wiki/Render/Xhtml/Anchor.php | 37 ++ .../Text/Wiki/Render/Xhtml/Blockquote.php | 46 +++ bundled-libs/Text/Wiki/Render/Xhtml/Bold.php | 34 ++ bundled-libs/Text/Wiki/Render/Xhtml/Break.php | 29 ++ .../Text/Wiki/Render/Xhtml/Center.php | 29 ++ bundled-libs/Text/Wiki/Render/Xhtml/Code.php | 102 +++++ .../Text/Wiki/Render/Xhtml/Colortext.php | 56 +++ .../Text/Wiki/Render/Xhtml/Deflist.php | 64 +++ .../Text/Wiki/Render/Xhtml/Delimiter.php | 23 ++ bundled-libs/Text/Wiki/Render/Xhtml/Embed.php | 23 ++ .../Text/Wiki/Render/Xhtml/Emphasis.php | 35 ++ .../Text/Wiki/Render/Xhtml/Freelink.php | 9 + .../Text/Wiki/Render/Xhtml/Function.php | 87 ++++ .../Text/Wiki/Render/Xhtml/Heading.php | 29 ++ bundled-libs/Text/Wiki/Render/Xhtml/Horiz.php | 28 ++ bundled-libs/Text/Wiki/Render/Xhtml/Html.php | 24 ++ bundled-libs/Text/Wiki/Render/Xhtml/Image.php | 151 +++++++ .../Text/Wiki/Render/Xhtml/Include.php | 8 + .../Text/Wiki/Render/Xhtml/Interwiki.php | 74 ++++ .../Text/Wiki/Render/Xhtml/Italic.php | 34 ++ bundled-libs/Text/Wiki/Render/Xhtml/List.php | 142 +++++++ .../Text/Wiki/Render/Xhtml/Newline.php | 12 + .../Text/Wiki/Render/Xhtml/Paragraph.php | 36 ++ .../Text/Wiki/Render/Xhtml/Phplookup.php | 59 +++ .../Text/Wiki/Render/Xhtml/Prefilter.php | 40 ++ bundled-libs/Text/Wiki/Render/Xhtml/Raw.php | 23 ++ .../Text/Wiki/Render/Xhtml/Revise.php | 45 ++ .../Text/Wiki/Render/Xhtml/Strong.php | 35 ++ .../Text/Wiki/Render/Xhtml/Superscript.php | 34 ++ bundled-libs/Text/Wiki/Render/Xhtml/Table.php | 98 +++++ .../Text/Wiki/Render/Xhtml/Tighten.php | 10 + bundled-libs/Text/Wiki/Render/Xhtml/Toc.php | 80 ++++ bundled-libs/Text/Wiki/Render/Xhtml/Tt.php | 35 ++ bundled-libs/Text/Wiki/Render/Xhtml/Url.php | 91 +++++ .../Text/Wiki/Render/Xhtml/Wikilink.php | 137 +++++++ 148 files changed, 8072 insertions(+), 159 deletions(-) create mode 100644 bundled-libs/Text/Wiki/Parse.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Anchor.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Blockquote.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Bold.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Break.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Center.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Code.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Colortext.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Deflist.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Delimiter.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Embed.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Emphasis.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Freelink.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Function.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Heading.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Horiz.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Html.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Image.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Include.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Interwiki.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Italic.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/List.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Newline.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Paragraph.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Phplookup.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Prefilter.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Raw.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Revise.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Strong.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Superscript.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Table.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Tighten.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Toc.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Tt.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Url.php create mode 100644 bundled-libs/Text/Wiki/Parse/Default/Wikilink.php create mode 100644 bundled-libs/Text/Wiki/Render.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Anchor.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Blockquote.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Bold.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Break.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Center.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Code.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Colortext.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Deflist.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Delimiter.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Embed.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Emphasis.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Freelink.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Function.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Heading.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Horiz.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Html.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Image.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Include.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Interwiki.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Italic.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/List.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Newline.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Paragraph.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Phplookup.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Prefilter.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Raw.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Revise.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Strong.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Superscript.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Table.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Tighten.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Toc.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Tt.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Url.php create mode 100644 bundled-libs/Text/Wiki/Render/Latex/Wikilink.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Anchor.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Blockquote.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Bold.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Break.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Center.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Code.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Colortext.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Deflist.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Delimiter.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Embed.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Emphasis.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Freelink.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Function.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Heading.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Horiz.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Html.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Image.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Include.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Interwiki.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Italic.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/List.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Newline.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Paragraph.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Phplookup.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Prefilter.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Raw.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Revise.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Strong.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Superscript.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Table.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Tighten.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Toc.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Tt.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Url.php create mode 100644 bundled-libs/Text/Wiki/Render/Plain/Wikilink.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Anchor.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Blockquote.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Bold.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Break.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Center.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Code.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Colortext.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Deflist.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Delimiter.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Embed.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Emphasis.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Freelink.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Function.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Heading.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Horiz.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Html.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Image.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Include.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Interwiki.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Italic.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/List.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Newline.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Paragraph.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Phplookup.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Prefilter.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Raw.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Revise.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Strong.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Superscript.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Table.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Tighten.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Toc.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Tt.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Url.php create mode 100644 bundled-libs/Text/Wiki/Render/Xhtml/Wikilink.php diff --git a/bundled-libs/Net/CheckIP.php b/bundled-libs/Net/CheckIP.php index 2e3f15a..b0fbc73 100644 --- a/bundled-libs/Net/CheckIP.php +++ b/bundled-libs/Net/CheckIP.php @@ -17,7 +17,7 @@ // | Guido Haeger | // +----------------------------------------------------------------------+ // -// $Id: CheckIP.php,v 1.2 2004/11/19 11:05:24 garvinhicking Exp $ +// $Id: CheckIP.php,v 1.5 2002/08/17 09:41:24 mj Exp $ /** * Class to validate the syntax of IPv4 adresses diff --git a/bundled-libs/Net/Socket.php b/bundled-libs/Net/Socket.php index 9d73e06..7c4ff1d 100644 --- a/bundled-libs/Net/Socket.php +++ b/bundled-libs/Net/Socket.php @@ -17,90 +17,109 @@ // | Chuck Hagenbuch | // +----------------------------------------------------------------------+ // -// $Id: Socket.php,v 1.1 2004/12/06 09:18:23 nohn Exp $ -// +// $Id: Socket.php,v 1.24 2005/02/03 20:40:16 chagenbu Exp $ require_once 'PEAR.php'; +define('NET_SOCKET_READ', 1); +define('NET_SOCKET_WRITE', 2); +define('NET_SOCKET_ERROR', 3); + /** - * Generalized Socket class. More docs to be written. + * Generalized Socket class. * - * @version 1.0 + * @version 1.1 * @author Stig Bakken * @author Chuck Hagenbuch */ class Net_Socket extends PEAR { - // {{{ properties - /** Socket file pointer. */ + /** + * Socket file pointer. + * @var resource $fp + */ var $fp = null; - /** Whether the socket is blocking. */ + /** + * Whether the socket is blocking. Defaults to true. + * @var boolean $blocking + */ var $blocking = true; - /** Whether the socket is persistent. */ + /** + * Whether the socket is persistent. Defaults to false. + * @var boolean $persistent + */ var $persistent = false; - /** The IP address to connect to. */ + /** + * The IP address to connect to. + * @var string $addr + */ var $addr = ''; - /** The port number to connect to. */ + /** + * The port number to connect to. + * @var integer $port + */ var $port = 0; - /** Number of seconds to wait on socket connections before - assuming there's no more data. */ + /** + * Number of seconds to wait on socket connections before assuming + * there's no more data. Defaults to no timeout. + * @var integer $timeout + */ var $timeout = false; - /** Number of bytes to read at a time in readLine() and - readAll(). */ - var $lineLength = 2048; - // }}} - - // {{{ constructor /** - * Constructs a new Net_Socket object. - * - * @access public + * Number of bytes to read at a time in readLine() and + * readAll(). Defaults to 2048. + * @var integer $lineLength */ - function Net_Socket() - { - $this->PEAR(); - } - // }}} + var $lineLength = 2048; - // {{{ connect() /** * Connect to the specified port. If called when the socket is * already connected, it disconnects and connects again. * - * @param $addr string IP address or host name - * @param $port int TCP port number - * @param $persistent bool (optional) whether the connection is - * persistent (kept open between requests by the web server) - * @param $timeout int (optional) how long to wait for data - * @param $options array see options for stream_context_create + * @param string $addr IP address or host name. + * @param integer $port TCP port number. + * @param boolean $persistent (optional) Whether the connection is + * persistent (kept open between requests + * by the web server). + * @param integer $timeout (optional) How long to wait for data. + * @param array $options See options for stream_context_create. + * * @access public - * @return mixed true on success or error object + * + * @return boolean | PEAR_Error True on success or a PEAR_Error on failure. */ - function connect($addr, $port, $persistent = null, $timeout = null, $options = null) + function connect($addr, $port = 0, $persistent = null, $timeout = null, $options = null) { if (is_resource($this->fp)) { @fclose($this->fp); $this->fp = null; } - if (strspn($addr, '.0123456789') == strlen($addr)) { + if (!$addr) { + return $this->raiseError('$addr cannot be empty'); + } elseif (strspn($addr, '.0123456789') == strlen($addr) || + strstr($addr, '/') !== false) { $this->addr = $addr; } else { - $this->addr = gethostbyname($addr); + $this->addr = @gethostbyname($addr); } + $this->port = $port % 65536; + if ($persistent !== null) { $this->persistent = $persistent; } + if ($timeout !== null) { $this->timeout = $timeout; } + $openfunc = $this->persistent ? 'pfsockopen' : 'fsockopen'; $errno = 0; $errstr = ''; @@ -111,7 +130,7 @@ class Net_Socket extends PEAR { $timeout = 0; } $context = stream_context_create($options); - $fp = $openfunc($this->addr, $this->port, $errno, $errstr, $timeout, $context); + $fp = @$openfunc($this->addr, $this->port, $errno, $errstr, $timeout, $context); } else { if ($this->timeout) { $fp = @$openfunc($this->addr, $this->port, $errno, $errstr, $this->timeout); @@ -128,9 +147,7 @@ class Net_Socket extends PEAR { return $this->setBlocking($this->blocking); } - // }}} - // {{{ disconnect() /** * Disconnects from the peer, closes the socket. * @@ -139,71 +156,65 @@ class Net_Socket extends PEAR { */ function disconnect() { - if (is_resource($this->fp)) { - fclose($this->fp); - $this->fp = null; - return true; + if (!is_resource($this->fp)) { + return $this->raiseError('not connected'); } - return $this->raiseError("not connected"); + + @fclose($this->fp); + $this->fp = null; + return true; } - // }}} - // {{{ isBlocking() /** * Find out if the socket is in blocking mode. * * @access public - * @return bool the current blocking mode. + * @return boolean The current blocking mode. */ function isBlocking() { return $this->blocking; } - // }}} - // {{{ setBlocking() /** * Sets whether the socket connection should be blocking or * not. A read call to a non-blocking socket will return immediately * if there is no data available, whereas it will block until there * is data for blocking sockets. * - * @param $mode bool true for blocking sockets, false for nonblocking + * @param boolean $mode True for blocking sockets, false for nonblocking. * @access public * @return mixed true on success or an error object otherwise */ function setBlocking($mode) { - if (is_resource($this->fp)) { - $this->blocking = $mode; - socket_set_blocking($this->fp, $this->blocking); - return true; + if (!is_resource($this->fp)) { + return $this->raiseError('not connected'); } - return $this->raiseError("not connected"); + + $this->blocking = $mode; + socket_set_blocking($this->fp, $this->blocking); + return true; } - // }}} - // {{{ setTimeout() /** * Sets the timeout value on socket descriptor, * expressed in the sum of seconds and microseconds * - * @param $seconds int seconds - * @param $microseconds int microseconds + * @param integer $seconds Seconds. + * @param integer $microseconds Microseconds. * @access public * @return mixed true on success or an error object otherwise */ function setTimeout($seconds, $microseconds) { - if (is_resource($this->fp)) { - socket_set_timeout($this->fp, $seconds, $microseconds); - return true; + if (!is_resource($this->fp)) { + return $this->raiseError('not connected'); } - return $this->raiseError("not connected"); + + return socket_set_timeout($this->fp, $seconds, $microseconds); } - // }}} - // {{{ getStatus() /** * Returns information about an existing socket resource. * Currently returns four entries in the result array: @@ -220,14 +231,13 @@ class Net_Socket extends PEAR { */ function getStatus() { - if (is_resource($this->fp)) { - return socket_get_status($this->fp); + if (!is_resource($this->fp)) { + return $this->raiseError('not connected'); } - return $this->raiseError("not connected"); + + return socket_get_status($this->fp); } - // }}} - // {{{ gets() /** * Get a specified line of data * @@ -237,69 +247,87 @@ class Net_Socket extends PEAR { */ function gets($size) { - if (is_resource($this->fp)) { - return fgets($this->fp, $size); + if (!is_resource($this->fp)) { + return $this->raiseError('not connected'); } - return $this->raiseError("not connected"); + + return @fgets($this->fp, $size); } - // }}} - // {{{ read() /** * Read a specified amount of data. This is guaranteed to return, * and has the added benefit of getting everything in one fread() * chunk; if you know the size of the data you're getting * beforehand, this is definitely the way to go. * - * @param $size The number of bytes to read from the socket. + * @param integer $size The number of bytes to read from the socket. * @access public * @return $size bytes of data from the socket, or a PEAR_Error if * not connected. */ function read($size) { - if (is_resource($this->fp)) { - return fread($this->fp, $size); + if (!is_resource($this->fp)) { + return $this->raiseError('not connected'); } - return $this->raiseError("not connected"); + + return @fread($this->fp, $size); } - // }}} - // {{{ write() /** * Write a specified amount of data. * + * @param string $data Data to write. + * @param integer $blocksize Amount of data to write at once. + * NULL means all at once. + * * @access public * @return mixed true on success or an error object otherwise */ - function write($data) + function write($data, $blocksize = null) { - if (is_resource($this->fp)) { + if (!is_resource($this->fp)) { + return $this->raiseError('not connected'); + } + + if (is_null($blocksize) && !OS_WINDOWS) { return fwrite($this->fp, $data); + } else { + if (is_null($blocksize)) { + $blocksize = 1024; + } + + $pos = 0; + $size = strlen($data); + while ($pos < $size) { + $written = @fwrite($this->fp, substr($data, $pos, $blocksize)); + if ($written === false) { + return false; + } + $pos += $written; + } + + return $pos; } - return $this->raiseError("not connected"); } - // }}} - // {{{ writeLine() /** * Write a line of data to the socket, followed by a trailing "\r\n". * * @access public * @return mixed fputs result, or an error */ - function writeLine ($data) + function writeLine($data) { - if (is_resource($this->fp)) { - return $this->write($data . "\r\n"); + if (!is_resource($this->fp)) { + return $this->raiseError('not connected'); } - return $this->raiseError("not connected"); + + return fwrite($this->fp, $data . "\r\n"); } - // }}} - // {{{ eof() /** - * Tests for end-of-file on a socket descriptor + * Tests for end-of-file on a socket descriptor. * * @access public * @return bool @@ -308,9 +336,7 @@ class Net_Socket extends PEAR { { return (is_resource($this->fp) && feof($this->fp)); } - // }}} - // {{{ readByte() /** * Reads a byte of data * @@ -320,14 +346,13 @@ class Net_Socket extends PEAR { */ function readByte() { - if (is_resource($this->fp)) { - return ord($this->read(1)); + if (!is_resource($this->fp)) { + return $this->raiseError('not connected'); } - return $this->raiseError("not connected"); + + return ord(@fread($this->fp, 1)); } - // }}} - // {{{ readWord() /** * Reads a word of data * @@ -337,36 +362,34 @@ class Net_Socket extends PEAR { */ function readWord() { - if (is_resource($this->fp)) { - $buf = $this->read(2); - return (ord($buf[0]) + (ord($buf[1]) << 8)); + if (!is_resource($this->fp)) { + return $this->raiseError('not connected'); } - return $this->raiseError("not connected"); + + $buf = @fread($this->fp, 2); + return (ord($buf[0]) + (ord($buf[1]) << 8)); } - // }}} - // {{{ readInt() /** * Reads an int of data * * @access public - * @return 1 int of data from the socket, or a PEAR_Error if - * not connected. + * @return integer 1 int of data from the socket, or a PEAR_Error if + * not connected. */ function readInt() { - if (is_resource($this->fp)) { - $buf = $this->read(4); - return (ord($buf[0]) + (ord($buf[1]) << 8) + - (ord($buf[2]) << 16) + (ord($buf[3]) << 24)); + if (!is_resource($this->fp)) { + return $this->raiseError('not connected'); } - return $this->raiseError("not connected"); + + $buf = @fread($this->fp, 4); + return (ord($buf[0]) + (ord($buf[1]) << 8) + + (ord($buf[2]) << 16) + (ord($buf[3]) << 24)); } - // }}} - // {{{ readString() /** - * Reads a zeroterminated string of data + * Reads a zero-terminated string of data * * @access public * @return string, or a PEAR_Error if @@ -374,18 +397,17 @@ class Net_Socket extends PEAR { */ function readString() { - if (is_resource($this->fp)) { - $string = ''; - while (($char = $this->read(1)) != "\x00") { - $string .= $char; - } - return $string; + if (!is_resource($this->fp)) { + return $this->raiseError('not connected'); } - return $this->raiseError("not connected"); + + $string = ''; + while (($char = @fread($this->fp, 1)) != "\x00") { + $string .= $char; + } + return $string; } - // }}} - // {{{ readIPAddress() /** * Reads an IP Address and returns it in a dot formated string * @@ -395,16 +417,15 @@ class Net_Socket extends PEAR { */ function readIPAddress() { - if (is_resource($this->fp)) { - $buf = $this->read(4); - return sprintf("%s.%s.%s.%s", ord($buf[0]), ord($buf[1]), - ord($buf[2]), ord($buf[3])); + if (!is_resource($this->fp)) { + return $this->raiseError('not connected'); } - return $this->raiseError("not connected"); + + $buf = @fread($this->fp, 4); + return sprintf("%s.%s.%s.%s", ord($buf[0]), ord($buf[1]), + ord($buf[2]), ord($buf[3])); } - // }}} - // {{{ readLine() /** * Read until either the end of the socket or a newline, whichever * comes first. Strips the trailing newline from the returned data. @@ -416,41 +437,92 @@ class Net_Socket extends PEAR { */ function readLine() { - if (is_resource($this->fp)) { - $line = ''; - $timeout = time() + $this->timeout; - while (!$this->eof() && (!$this->timeout || time() < $timeout)) { - $line .= $this->gets($this->lineLength); - if (substr($line, -2) == "\r\n" || - substr($line, -1) == "\n") { - return rtrim($line, "\r\n"); - } + if (!is_resource($this->fp)) { + return $this->raiseError('not connected'); + } + + $line = ''; + $timeout = time() + $this->timeout; + while (!feof($this->fp) && (!$this->timeout || time() < $timeout)) { + $line .= @fgets($this->fp, $this->lineLength); + if (substr($line, -1) == "\n") { + return rtrim($line, "\r\n"); } - return $line; } - return $this->raiseError("not connected"); + return $line; } - // }}} - // {{{ readAll() /** - * Read until the socket closes. THIS FUNCTION WILL NOT EXIT if the - * socket is in blocking mode until the socket closes. + * Read until the socket closes, or until there is no more data in + * the inner PHP buffer. If the inner buffer is empty, in blocking + * mode we wait for at least 1 byte of data. Therefore, in + * blocking mode, if there is no data at all to be read, this + * function will never exit (unless the socket is closed on the + * remote end). * * @access public - * @return All data until the socket closes, or a PEAR_Error if - * not connected. + * + * @return string All data until the socket closes, or a PEAR_Error if + * not connected. */ function readAll() { - if (is_resource($this->fp)) { - $data = ''; - while (!$this->eof()) - $data .= $this->read($this->lineLength); - return $data; + if (!is_resource($this->fp)) { + return $this->raiseError('not connected'); + } + + $data = ''; + while (!feof($this->fp)) { + $data .= @fread($this->fp, $this->lineLength); + } + return $data; + } + + /** + * Runs the equivalent of the select() system call on the socket + * with a timeout specified by tv_sec and tv_usec. + * + * @param integer $state Which of read/write/error to check for. + * @param integer $tv_sec Number of seconds for timeout. + * @param integer $tv_usec Number of microseconds for timeout. + * + * @access public + * @return False if select fails, integer describing which of read/write/error + * are ready, or PEAR_Error if not connected. + */ + function select($state, $tv_sec, $tv_usec = 0) + { + if (!is_resource($this->fp)) { + return $this->raiseError('not connected'); + } + + $read = null; + $write = null; + $except = null; + if ($state & NET_SOCKET_READ) { + $read[] = $this->fp; + } + if ($state & NET_SOCKET_WRITE) { + $write[] = $this->fp; + } + if ($state & NET_SOCKET_ERROR) { + $except[] = $this->fp; + } + if (false === ($sr = stream_select($read, $write, $except, $tv_sec, $tv_usec))) { + return false; + } + + $result = 0; + if (count($read)) { + $result |= NET_SOCKET_READ; + } + if (count($write)) { + $result |= NET_SOCKET_WRITE; + } + if (count($except)) { + $result |= NET_SOCKET_ERROR; } - return $this->raiseError("not connected"); + return $result; } - // }}} } diff --git a/bundled-libs/Net/URL.php b/bundled-libs/Net/URL.php index 349c59c..6331fc0 100644 --- a/bundled-libs/Net/URL.php +++ b/bundled-libs/Net/URL.php @@ -32,7 +32,7 @@ // | Author: Richard Heyes | // +-----------------------------------------------------------------------+ // -// $Id: URL.php,v 1.1 2004/12/06 09:18:23 nohn Exp $ +// $Id: URL.php,v 1.36 2004/06/19 18:58:50 richard Exp $ // // Net_URL Class diff --git a/bundled-libs/Text/Wiki/Parse.php b/bundled-libs/Text/Wiki/Parse.php new file mode 100644 index 0000000..53c0ae8 --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse.php @@ -0,0 +1,253 @@ + +* +* @package Text_Wiki +* +* $Id: Parse.php,v 1.2 2004/09/25 19:05:13 pmjones Exp $ +* +*/ + +class Text_Wiki_Parse { + + + /** + * + * Configuration options for this parser rule. + * + * @access public + * + * @var string + * + */ + + var $conf = array(); + + + /** + * + * Regular expression to find matching text for this rule. + * + * @access public + * + * @var string + * + * @see parse() + * + */ + + var $regex = null; + + + /** + * + * The name of this rule for new token array elements. + * + * @access public + * + * @var string + * + */ + + var $rule = null; + + + /** + * + * A reference to the calling Text_Wiki object. + * + * This is needed so that each rule has access to the same source + * text, token set, URLs, interwiki maps, page names, etc. + * + * @access public + * + * @var object + */ + + var $wiki = null; + + + /** + * + * Constructor for this parser rule. + * + * @access public + * + * @param object &$obj The calling "parent" Text_Wiki object. + * + */ + + function Text_Wiki_Parse(&$obj) + { + // set the reference to the calling Text_Wiki object; + // this allows us access to the shared source text, token + // array, etc. + $this->wiki =& $obj; + + // set the name of this rule; generally used when adding + // to the tokens array. strip off the Text_Wiki_Parse_ portion. + // text_wiki_parse_ + // 0123456789012345 + $tmp = substr(get_class($this), 16); + $this->rule = ucwords(strtolower($tmp)); + + // override config options for the rule if specified + if (isset($this->wiki->parseConf[$this->rule]) && + is_array($this->wiki->parseConf[$this->rule])) { + + $this->conf = array_merge( + $this->conf, + $this->wiki->parseConf[$this->rule] + ); + + } + } + + + /** + * + * Abstrct method to parse source text for matches. + * + * Applies the rule's regular expression to the source text, passes + * every match to the process() method, and replaces the matched text + * with the results of the processing. + * + * @access public + * + * @see Text_Wiki_Parse::process() + * + */ + + function parse() + { + $this->wiki->source = preg_replace_callback( + $this->regex, + array(&$this, 'process'), + $this->wiki->source + ); + } + + + /** + * + * Abstract method to generate replacements for matched text. + * + * @access public + * + * @param array $matches An array of matches from the parse() method + * as generated by preg_replace_callback. $matches[0] is the full + * matched string, $matches[1] is the first matched pattern, + * $matches[2] is the second matched pattern, and so on. + * + * @return string The processed text replacement; defaults to the + * full matched string (i.e., no changes to the text). + * + * @see Text_Wiki_Parse::parse() + * + */ + + function process(&$matches) + { + return $matches[0]; + } + + + /** + * + * Simple method to safely get configuration key values. + * + * @access public + * + * @param string $key The configuration key. + * + * @param mixed $default If the key does not exist, return this value + * instead. + * + * @return mixed The configuration key value (if it exists) or the + * default value (if not). + * + */ + + function getConf($key, $default = null) + { + if (isset($this->conf[$key])) { + return $this->conf[$key]; + } else { + return $default; + } + } + + + /** + * + * Extract 'attribute="value"' portions of wiki markup. + * + * This kind of markup is typically used only in macros, but is useful + * anywhere. + * + * The syntax is pretty strict; there can be no spaces between the + * option name, the equals, and the first double-quote; the value + * must be surrounded by double-quotes. You can escape characters in + * the value with a backslash, and the backslash will be stripped for + * you. + * + * @access public + * + * @param string $text The "attributes" portion of markup. + * + * @return array An associative array of key-value pairs where the + * key is the option name and the value is the option value. + * + */ + + function getAttrs($text) + { + // find the =" sections; + $tmp = explode('="', trim($text)); + + // basic setup + $k = count($tmp) - 1; + $attrs = array(); + $key = null; + + // loop through the sections + foreach ($tmp as $i => $val) { + + // first element is always the first key + if ($i == 0) { + $key = trim($val); + continue; + } + + // find the last double-quote in the value. + // the part to the left is the value for the last key, + // the part to the right is the next key name + $pos = strrpos($val, '"'); + $attrs[$key] = stripslashes(substr($val, 0, $pos)); + $key = trim(substr($val, $pos+1)); + + } + + return $attrs; + + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Anchor.php b/bundled-libs/Text/Wiki/Parse/Default/Anchor.php new file mode 100644 index 0000000..c7fe46e --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Anchor.php @@ -0,0 +1,67 @@ + +* +* @author Paul M. Jones +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Anchor extends Text_Wiki_Parse { + + + /** + * + * The regular expression used to find source text matching this + * rule. Looks like a macro: [[# anchor_name]] + * + * @access public + * + * @var string + * + */ + + var $regex = '/(\[\[# )([-_A-Za-z0-9.]+?)( .+)?(\]\])/i'; + + + /** + * + * Generates a token entry for the matched text. Token options are: + * + * 'text' => The full matched text, not including the tags. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return A delimited token number to be used as a placeholder in + * the source text. + * + */ + + function process(&$matches) { + + $name = $matches[2]; + $text = $matches[3]; + + $start = $this->wiki->addToken( + $this->rule, + array('type' => 'start', 'name' => $name) + ); + + $end = $this->wiki->addToken( + $this->rule, + array('type' => 'end', 'name' => $name) + ); + + // done, place the script output directly in the source + return $start . trim($text) . $end; + } +} +?> diff --git a/bundled-libs/Text/Wiki/Parse/Default/Blockquote.php b/bundled-libs/Text/Wiki/Parse/Default/Blockquote.php new file mode 100644 index 0000000..5029b04 --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Blockquote.php @@ -0,0 +1,163 @@ +' at the start of the line, followed by a space, +* and then the quote text; each '>' indicates an additional level of +* quoting. +* +* $Id: Blockquote.php,v 1.1 2005/01/31 15:46:52 pmjones Exp $ +* +* @author Paul M. Jones +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Blockquote extends Text_Wiki_Parse { + + + /** + * + * Regex for parsing the source text. + * + * @access public + * + * @var string + * + * @see parse() + * + */ + + var $regex = '/\n((\>).*\n)(?!(\>))/Us'; + + + /** + * + * Generates a replacement for the matched text. + * + * Token options are: + * + * 'type' => + * 'start' : the start of a blockquote + * 'end' : the end of a blockquote + * + * 'level' => the indent level (0 for the first level, 1 for the + * second, etc) + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return A series of text and delimited tokens marking the different + * list text and list elements. + * + */ + + function process(&$matches) + { + // the replacement text we will return to parse() + $return = ''; + + // the list of post-processing matches + $list = array(); + + // $matches[1] is the text matched as a list set by parse(); + // create an array called $list that contains a new set of + // matches for the various list-item elements. + preg_match_all( + '=^(\>+) (.*\n)=Ums', + $matches[1], + $list, + PREG_SET_ORDER + ); + + // a stack of starts and ends; we keep this so that we know what + // indent level we're at. + $stack = array(); + + // loop through each list-item element. + foreach ($list as $key => $val) { + + // $val[0] is the full matched list-item line + // $val[1] is the number of initial '>' chars (indent level) + // $val[2] is the quote text + + // we number levels starting at 1, not zero + $level = strlen($val[1]); + + // get the text of the line + $text = $val[2]; + + // add a level to the list? + while ($level > count($stack)) { + + // the current indent level is greater than the number + // of stack elements, so we must be starting a new + // level. push the new level onto the stack with a + // dummy value (boolean true)... + array_push($stack, true); + + $return .= "\n"; + + // ...and add a start token to the return. + $return .= $this->wiki->addToken( + $this->rule, + array( + 'type' => 'start', + 'level' => $level - 1 + ) + ); + + $return .= "\n\n"; + } + + // remove a level? + while (count($stack) > $level) { + + // as long as the stack count is greater than the + // current indent level, we need to end list types. + // continue adding end-list tokens until the stack count + // and the indent level are the same. + array_pop($stack); + + $return .= "\n\n"; + + $return .= $this->wiki->addToken( + $this->rule, + array ( + 'type' => 'end', + 'level' => count($stack) + ) + ); + + $return .= "\n"; + } + + // add the line text. + $return .= $text; + } + + // the last line may have been indented. go through the stack + // and create end-tokens until the stack is empty. + $return .= "\n"; + + while (count($stack) > 0) { + array_pop($stack); + $return .= $this->wiki->addToken( + $this->rule, + array ( + 'type' => 'end', + 'level' => count($stack) + ) + ); + } + + // we're done! send back the replacement text. + return "\n$return\n\n"; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Bold.php b/bundled-libs/Text/Wiki/Parse/Default/Bold.php new file mode 100644 index 0000000..62f7708 --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Bold.php @@ -0,0 +1,61 @@ + +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Bold extends Text_Wiki_Parse { + + + /** + * + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * + * @access public + * + * @var string + * + * @see parse() + * + */ + + var $regex = "/'''(()|[^'].*)'''/U"; + + + /** + * + * Generates a replacement for the matched text. Token options are: + * + * 'type' => ['start'|'end'] The starting or ending point of the + * emphasized text. The text itself is left in the source. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return A pair of delimited tokens to be used as a placeholder in + * the source text surrounding the text to be emphasized. + * + */ + + function process(&$matches) + { + $start = $this->wiki->addToken($this->rule, array('type' => 'start')); + $end = $this->wiki->addToken($this->rule, array('type' => 'end')); + return $start . $matches[1] . $end; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Break.php b/bundled-libs/Text/Wiki/Parse/Default/Break.php new file mode 100644 index 0000000..86264ed --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Break.php @@ -0,0 +1,54 @@ + +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Break extends Text_Wiki_Parse { + + + /** + * + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * + * @access public + * + * @var string + * + * @see parse() + * + */ + + var $regex = '/ _\n/'; + + + /** + * + * Generates a replacement token for the matched text. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return string A delimited token to be used as a placeholder in + * the source text. + * + */ + + function process(&$matches) + { + return $this->wiki->addToken($this->rule); + } +} + +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Center.php b/bundled-libs/Text/Wiki/Parse/Default/Center.php new file mode 100644 index 0000000..d7d3148 --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Center.php @@ -0,0 +1,60 @@ + +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Center extends Text_Wiki_Parse { + + + /** + * + * The regular expression used to find source text matching this + * rule. + * + * @access public + * + * @var string + * + */ + + var $regex = '/\n\= (.*?)\n/'; + + /** + * + * Generates a token entry for the matched text. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return A delimited token number to be used as a placeholder in + * the source text. + * + */ + + function process(&$matches) + { + $start = $this->wiki->addToken( + $this->rule, + array('type' => 'start') + ); + + $end = $this->wiki->addToken( + $this->rule, + array('type' => 'end') + ); + + return "\n" . $start . $matches[1] . $end . "\n"; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Code.php b/bundled-libs/Text/Wiki/Parse/Default/Code.php new file mode 100644 index 0000000..90499d1 --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Code.php @@ -0,0 +1,81 @@ + on a line by itself, +* followed by the inline code example, and terminated with the string +* on a line by itself. The code example is run through the +* native PHP highlight_string() function to colorize it, then surrounded +* with
...
tags when rendered as XHTML. +* +* @author Paul M. Jones +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Code extends Text_Wiki_Parse { + + + /** + * + * The regular expression used to find source text matching this + * rule. + * + * @access public + * + * @var string + * + */ + + var $regex = '/^(\)\n(.+)\n(\<\/code\>)(\s|$)/Umsi'; + + + /** + * + * Generates a token entry for the matched text. Token options are: + * + * 'text' => The full matched text, not including the tags. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return A delimited token number to be used as a placeholder in + * the source text. + * + */ + + function process(&$matches) + { + // are there additional attribute arguments? + $args = trim($matches[2]); + + if ($args == '') { + $options = array( + 'text' => $matches[3], + 'attr' => array('type' => '') + ); + } else { + // get the attributes... + $attr = $this->getAttrs($args); + + // ... and make sure we have a 'type' + if (! isset($attr['type'])) { + $attr['type'] = ''; + } + + // retain the options + $options = array( + 'text' => $matches[3], + 'attr' => $attr + ); + } + + return $this->wiki->addToken($this->rule, $options) . $matches[5]; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Colortext.php b/bundled-libs/Text/Wiki/Parse/Default/Colortext.php new file mode 100644 index 0000000..1b0ff69 --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Colortext.php @@ -0,0 +1,74 @@ + +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Colortext extends Text_Wiki_Parse { + + /** + * + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * + * @access public + * + * @var string + * + * @see parse() + * + */ + + var $regex = "/\#\#(.+?)\|(.+?)\#\#/"; + + + /** + * + * Generates a replacement for the matched text. Token options are: + * + * 'type' => ['start'|'end'] The starting or ending point of the + * emphasized text. The text itself is left in the source. + * + * 'color' => the color indicator + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return string A pair of delimited tokens to be used as a + * placeholder in the source text surrounding the text to be + * emphasized. + * + */ + + function process(&$matches) + { + $start = $this->wiki->addToken( + $this->rule, + array( + 'type' => 'start', + 'color' => $matches[1] + ) + ); + + $end = $this->wiki->addToken( + $this->rule, + array( + 'type' => 'end', + 'color' => $matches[1] + ) + ); + + return $start . $matches[2] . $end; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Deflist.php b/bundled-libs/Text/Wiki/Parse/Default/Deflist.php new file mode 100644 index 0000000..2bd5969 --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Deflist.php @@ -0,0 +1,104 @@ + +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Deflist extends Text_Wiki_Parse { + + + /** + * + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * + * @access public + * + * @var string + * + * @see parse() + * + */ + + var $regex = '/\n((: ).*\n)(?!(: |\n))/Us'; + + + /** + * + * Generates a replacement for the matched text. Token options are: + * + * 'type' => + * 'list_start' : the start of a definition list + * 'list_end' : the end of a definition list + * 'term_start' : the start of a definition term + * 'term_end' : the end of a definition term + * 'narr_start' : the start of definition narrative + * 'narr_end' : the end of definition narrative + * 'unknown' : unknown type of definition portion + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return A series of text and delimited tokens marking the different + * list text and list elements. + * + */ + + function process(&$matches) + { + // the replacement text we will return to parse() + $return = ''; + + // the list of post-processing matches + $list = array(); + + // start the deflist + $options = array('type' => 'list_start'); + $return .= $this->wiki->addToken($this->rule, $options); + + // $matches[1] is the text matched as a list set by parse(); + // create an array called $list that contains a new set of + // matches for the various definition-list elements. + preg_match_all( + '/^(: )(.*)?( : )(.*)?$/Ums', + $matches[1], + $list, + PREG_SET_ORDER + ); + + // add each term and narrative + foreach ($list as $key => $val) { + $return .= ( + $this->wiki->addToken($this->rule, array('type' => 'term_start')) . + trim($val[2]) . + $this->wiki->addToken($this->rule, array('type' => 'term_end')) . + $this->wiki->addToken($this->rule, array('type' => 'narr_start')) . + trim($val[4]) . + $this->wiki->addToken($this->rule, array('type' => 'narr_end')) + ); + } + + + // end the deflist + $options = array('type' => 'list_end'); + $return .= $this->wiki->addToken($this->rule, $options); + + // done! + return "\n" . $return . "\n\n"; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Delimiter.php b/bundled-libs/Text/Wiki/Parse/Default/Delimiter.php new file mode 100644 index 0000000..82366f9 --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Delimiter.php @@ -0,0 +1,62 @@ + +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Delimiter extends Text_Wiki_Parse { + + /** + * + * Constructor. Overrides the Text_Wiki_Parse constructor so that we + * can set the $regex property dynamically (we need to include the + * Text_Wiki $delim character. + * + * @param object &$obj The calling "parent" Text_Wiki object. + * + * @param string $name The token name to use for this rule. + * + */ + + function Text_Wiki_Parse_delimiter(&$obj) + { + parent::Text_Wiki_Parse($obj); + $this->regex = '/' . $this->wiki->delim . '/'; + } + + + /** + * + * Generates a token entry for the matched text. Token options are: + * + * 'text' => The full matched text. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return A delimited token number to be used as a placeholder in + * the source text. + * + */ + + function process(&$matches) + { + return $this->wiki->addToken( + $this->rule, + array('text' => $this->wiki->delim) + ); + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Embed.php b/bundled-libs/Text/Wiki/Parse/Default/Embed.php new file mode 100644 index 0000000..ab83094 --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Embed.php @@ -0,0 +1,88 @@ + or other similar tags. Be +* careful. +* +* @author Paul M. Jones +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Embed extends Text_Wiki_Parse { + + var $conf = array( + 'base' => '/path/to/scripts/' + ); + + var $file = null; + + var $output = null; + + var $vars = null; + + + /** + * + * The regular expression used to find source text matching this + * rule. + * + * @access public + * + * @var string + * + */ + + var $regex = '/(\[\[embed )(.+?)( .+?)?(\]\])/i'; + + + /** + * + * Generates a token entry for the matched text. Token options are: + * + * 'text' => The full matched text, not including the tags. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return A delimited token number to be used as a placeholder in + * the source text. + * + */ + + function process(&$matches) + { + // save the file location + $this->file = $this->getConf('base', './') . $matches[2]; + + // extract attribs as variables in the local space + $this->vars = $this->getAttrs($matches[3]); + unset($this->vars['this']); + extract($this->vars); + + // run the script + ob_start(); + include($this->file); + $this->output = ob_get_contents(); + ob_end_clean(); + + // done, place the script output directly in the source + return $this->wiki->addToken( + $this->rule, + array('text' => $this->output) + ); + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Emphasis.php b/bundled-libs/Text/Wiki/Parse/Default/Emphasis.php new file mode 100644 index 0000000..92a14a5 --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Emphasis.php @@ -0,0 +1,67 @@ + +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_emphasis extends Text_Wiki_Parse { + + + /** + * + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * + * @access public + * + * @var string + * + * @see parse() + * + */ + + var $regex = "/\/\/(.*?)\/\//"; + + + /** + * + * Generates a replacement for the matched text. Token options are: + * + * 'type' => ['start'|'end'] The starting or ending point of the + * emphasized text. The text itself is left in the source. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return string A pair of delimited tokens to be used as a + * placeholder in the source text surrounding the text to be + * emphasized. + * + */ + + function process(&$matches) + { + $start = $this->wiki->addToken( + $this->rule, array('type' => 'start') + ); + + $end = $this->wiki->addToken( + $this->rule, array('type' => 'end') + ); + + return $start . $matches[1] . $end; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Freelink.php b/bundled-libs/Text/Wiki/Parse/Default/Freelink.php new file mode 100644 index 0000000..c77d1bd --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Freelink.php @@ -0,0 +1,111 @@ + +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Freelink extends Text_Wiki_Parse { + + + /** + * + * Constructor. We override the Text_Wiki_Parse constructor so we can + * explicitly comment each part of the $regex property. + * + * @access public + * + * @param object &$obj The calling "parent" Text_Wiki object. + * + */ + + function Text_Wiki_Parse_Freelink(&$obj) + { + parent::Text_Wiki_Parse($obj); + + $this->regex = + '/' . // START regex + "\\(\\(" . // double open-parens + "(" . // START freelink page patter + "[-A-Za-z0-9 _+\\/.,;:!?'\"\\[\\]\\{\\}&\xc0-\xff]+" . // 1 or more of just about any character + ")" . // END freelink page pattern + "(" . // START display-name + "\|" . // a pipe to start the display name + "[-A-Za-z0-9 _+\\/.,;:!?'\"\\[\\]\\{\\}&\xc0-\xff]+" . // 1 or more of just about any character + ")?" . // END display-name pattern 0 or 1 + "(" . // START pattern for named anchors + "\#" . // a hash mark + "[A-Za-z]" . // 1 alpha + "[-A-Za-z0-9_:.]*" . // 0 or more alpha, digit, underscore + ")?" . // END named anchors pattern 0 or 1 + "()\\)\\)" . // double close-parens + '/'; // END regex + } + + + /** + * + * Generates a replacement for the matched text. Token options are: + * + * 'page' => the wiki page name (e.g., HomePage). + * + * 'text' => alternative text to be displayed in place of the wiki + * page name. + * + * 'anchor' => a named anchor on the target wiki page + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return A delimited token to be used as a placeholder in + * the source text, plus any text priot to the match. + * + */ + + function process(&$matches) + { + // use nice variable names + $page = $matches[1]; + $text = $matches[2]; + + // get rid of the leading # from the anchor, if any + $anchor = substr($matches[3], 1); + + // is the page given a new text appearance? + if (trim($text) == '') { + // no + $text = $page; + } else { + // yes, strip the leading | character + $text = substr($text, 1); + } + + // set the options + $options = array( + 'page' => $page, + 'text' => $text, + 'anchor' => $anchor + ); + + // return a token placeholder + return $this->wiki->addToken($this->rule, $options); + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Function.php b/bundled-libs/Text/Wiki/Parse/Default/Function.php new file mode 100644 index 0000000..6ad99d4 --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Function.php @@ -0,0 +1,115 @@ +)\n(.+)\n(\<\/function\>)(\s|$)/Umsi'; + + function process(&$matches) + { + // default options + $opts = array( + 'name' => null, + 'access' => null, + 'return' => null, + 'params' => array(), + 'throws' => array() + ); + + // split apart the markup lines and loop through them + $lines = explode("\n", $matches[2]); + foreach ($lines as $line) { + + // skip blank lines + if (trim($line) == '') { + continue; + } + + // find the first ':' on the line; the left part is the + // type, the right part is the value. skip lines without + // a ':' on them. + $pos = strpos($line, ':'); + if ($pos === false) { + continue; + } + + // $type is the line type: name, access, return, param, throws + // 012345678901234 + // name: something + $type = trim(substr($line, 0, $pos)); + $val = trim(substr($line, $pos+1)); + + switch($type) { + + case 'a': + case 'access': + $opts['access'] = $val; + break; + + case 'n': + case 'name': + $opts['name'] = $val; + break; + + case 'p': + case 'param': + $tmp = explode(',', $val); + $k = count($tmp); + if ($k == 1) { + $opts['params'][] = array( + 'type' => $tmp[0], + 'descr' => null, + 'default' => null + ); + } elseif ($k == 2) { + $opts['params'][] = array( + 'type' => $tmp[0], + 'descr' => $tmp[1], + 'default' => null + ); + } else { + $opts['params'][] = array( + 'type' => $tmp[0], + 'descr' => $tmp[1], + 'default' => $tmp[2] + ); + } + break; + + case 'r': + case 'return': + case 'returns': + $opts['return'] = $val; + break; + + case 't': + case 'throws': + $tmp = explode(',', $val); + $k = count($tmp); + if ($k == 1) { + $opts['throws'][] = array( + 'type' => $tmp[0], + 'descr' => null + ); + } else { + $opts['throws'][] = array( + 'type' => $tmp[0], + 'descr' => $tmp[1] + ); + } + break; + + default: + $opts[$type] = $val; + break; + + } + } + + // add the token back in place + return $this->wiki->addToken($this->rule, $opts) . $matches[4]; + } +} + +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Heading.php b/bundled-libs/Text/Wiki/Parse/Default/Heading.php new file mode 100644 index 0000000..0918e7c --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Heading.php @@ -0,0 +1,89 @@ + +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Heading extends Text_Wiki_Parse { + + + /** + * + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * + * @access public + * + * @var string + * + * @see parse() + * + */ + + var $regex = '/^(\+{1,6}) (.*)/m'; + + var $conf = array( + 'id_prefix' => 'toc' + ); + + /** + * + * Generates a replacement for the matched text. Token options are: + * + * 'type' => ['start'|'end'] The starting or ending point of the + * heading text. The text itself is left in the source. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return string A pair of delimited tokens to be used as a + * placeholder in the source text surrounding the heading text. + * + */ + + function process(&$matches) + { + // keep a running count for header IDs. we use this later + // when constructing TOC entries, etc. + static $id; + if (! isset($id)) { + $id = 0; + } + + $prefix = htmlspecialchars($this->getConf('id_prefix')); + + $start = $this->wiki->addToken( + $this->rule, + array( + 'type' => 'start', + 'level' => strlen($matches[1]), + 'text' => $matches[2], + 'id' => $prefix . $id ++ + ) + ); + + $end = $this->wiki->addToken( + $this->rule, + array( + 'type' => 'end', + 'level' => strlen($matches[1]) + ) + ); + + return $start . $matches[2] . $end . "\n"; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Horiz.php b/bundled-libs/Text/Wiki/Parse/Default/Horiz.php new file mode 100644 index 0000000..9907f4b --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Horiz.php @@ -0,0 +1,52 @@ + +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Horiz extends Text_Wiki_Parse { + + + /** + * + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * + * @access public + * + * @var string + * + * @see parse() + * + */ + + var $regex = '/^([-]{4,})$/m'; + + + /** + * + * Generates a replacement token for the matched text. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return string A token marking the horizontal rule. + * + */ + + function process(&$matches) + { + return $this->wiki->addToken($this->rule); + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Html.php b/bundled-libs/Text/Wiki/Parse/Default/Html.php new file mode 100644 index 0000000..515b381 --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Html.php @@ -0,0 +1,57 @@ + on its +* own line, and the block end is marked by on its own line. +* +* @author Paul M. Jones +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Html extends Text_Wiki_Parse { + + + /** + * + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * + * @access public + * + * @var string + * + * @see parse() + * + */ + + var $regex = '/^\\n(.+)\n\<\/html\>(\s|$)/Umsi'; + + + /** + * + * Generates a replacement for the matched text. Token options are: + * + * 'text' => The text of the HTML to be rendered as-is. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return A delimited token to be used as a placeholder in + * the source text, plus any text following the HTML block. + * + */ + + function process(&$matches) + { + $options = array('text' => $matches[1]); + return $this->wiki->addToken($this->rule, $options) . $matches[2]; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Image.php b/bundled-libs/Text/Wiki/Parse/Default/Image.php new file mode 100644 index 0000000..764fd57 --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Image.php @@ -0,0 +1,76 @@ + or other similar tags. Be +* careful. +* +* In the future, we'll add a rule config options to set the base embed +* path so that it is limited to one directory. +* +* @author Paul M. Jones +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Image extends Text_Wiki_Parse { + + + /** + * + * The regular expression used to find source text matching this + * rule. + * + * @access public + * + * @var string + * + */ + + var $regex = '/(\[\[image )(.+?)(\]\])/i'; + + + /** + * + * Generates a token entry for the matched text. Token options are: + * + * 'src' => The image source, typically a relative path name. + * + * 'opts' => Any macro options following the source. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return A delimited token number to be used as a placeholder in + * the source text. + * + */ + + function process(&$matches) + { + $pos = strpos($matches[2], ' '); + + if ($pos === false) { + $options = array( + 'src' => $matches[2], + 'attr' => array()); + } else { + // everything after the space is attribute arguments + $options = array( + 'src' => substr($matches[2], 0, $pos), + 'attr' => $this->getAttrs(substr($matches[2], $pos+1)) + ); + } + + return $this->wiki->addToken($this->rule, $options); + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Include.php b/bundled-libs/Text/Wiki/Parse/Default/Include.php new file mode 100644 index 0000000..1ba7d1d --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Include.php @@ -0,0 +1,84 @@ + or other similar tags. Be +* careful. +* +* @author Paul M. Jones +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Include extends Text_Wiki_Parse { + + var $conf = array( + 'base' => '/path/to/scripts/' + ); + + var $file = null; + + var $output = null; + + var $vars = null; + + /** + * + * The regular expression used to find source text matching this + * rule. + * + * @access public + * + * @var string + * + */ + + var $regex = '/(\[\[include )(.+?)( .+?)?(\]\])/i'; + + + /** + * + * Includes the results of the script directly into the source; the output + * will subsequently be parsed by the remaining Text_Wiki rules. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return The results of the included script. + * + */ + + function process(&$matches) + { + // save the file location + $this->file = $this->getConf('base', './') . $matches[2]; + + // extract attribs as variables in the local space + $this->vars = $this->getAttrs($matches[3]); + unset($this->vars['this']); + extract($this->vars); + + // run the script + ob_start(); + include($this->file); + $this->output = ob_get_contents(); + ob_end_clean(); + + // done, place the script output directly in the source + return $this->output; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Interwiki.php b/bundled-libs/Text/Wiki/Parse/Default/Interwiki.php new file mode 100644 index 0000000..6a4ef19 --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Interwiki.php @@ -0,0 +1,120 @@ + +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Interwiki extends Text_Wiki_Parse { + + // double-colons wont trip up now + var $regex = '([A-Za-z0-9_]+):((?!:)[A-Za-z0-9_\/=&~#.:;-]+)'; + + + /** + * + * Parser. We override the standard parser so we can + * find both described interwiki links and standalone links. + * + * @access public + * + * @return void + * + */ + + function parse() + { + // described interwiki links + $tmp_regex = '/\[' . $this->regex . ' (.+?)\]/'; + $this->wiki->source = preg_replace_callback( + $tmp_regex, + array(&$this, 'processDescr'), + $this->wiki->source + ); + + // standalone interwiki links + $tmp_regex = '/' . $this->regex . '/'; + $this->wiki->source = preg_replace_callback( + $tmp_regex, + array(&$this, 'process'), + $this->wiki->source + ); + + } + + + /** + * + * Generates a replacement for the matched standalone interwiki text. + * Token options are: + * + * 'site' => The key name for the Text_Wiki interwiki array map, + * usually the name of the interwiki site. + * + * 'page' => The page on the target interwiki to link to. + * + * 'text' => The text to display as the link. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return A delimited token to be used as a placeholder in + * the source text, plus any text priot to the match. + * + */ + + function process(&$matches) + { + $options = array( + 'site' => $matches[1], + 'page' => $matches[2], + 'text' => $matches[0] + ); + + return $this->wiki->addToken($this->rule, $options); + } + + + /** + * + * Generates a replacement for described interwiki links. Token + * options are: + * + * 'site' => The key name for the Text_Wiki interwiki array map, + * usually the name of the interwiki site. + * + * 'page' => The page on the target interwiki to link to. + * + * 'text' => The text to display as the link. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return A delimited token to be used as a placeholder in + * the source text, plus any text priot to the match. + * + */ + + function processDescr(&$matches) + { + $options = array( + 'site' => $matches[1], + 'page' => $matches[2], + 'text' => $matches[3] + ); + + return $this->wiki->addToken($this->rule, $options); + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Italic.php b/bundled-libs/Text/Wiki/Parse/Default/Italic.php new file mode 100644 index 0000000..d4d6ebf --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Italic.php @@ -0,0 +1,67 @@ + +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Italic extends Text_Wiki_Parse { + + + /** + * + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * + * @access public + * + * @var string + * + * @see parse() + * + */ + + var $regex = "/''(()|[^'].*)''/U"; + + + /** + * + * Generates a replacement for the matched text. Token options are: + * + * 'type' => ['start'|'end'] The starting or ending point of the + * emphasized text. The text itself is left in the source. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return string A pair of delimited tokens to be used as a + * placeholder in the source text surrounding the text to be + * emphasized. + * + */ + + function process(&$matches) + { + $start = $this->wiki->addToken( + $this->rule, array('type' => 'start') + ); + + $end = $this->wiki->addToken( + $this->rule, array('type' => 'end') + ); + + return $start . $matches[1] . $end; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/List.php b/bundled-libs/Text/Wiki/Parse/Default/List.php new file mode 100644 index 0000000..77b40b2 --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/List.php @@ -0,0 +1,230 @@ + +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_List extends Text_Wiki_Parse { + + + /** + * + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * + * @access public + * + * @var string + * + * @see parse() + * + */ + + var $regex = '/\n((\*|#) .*\n)(?! {0,}(\* |# |\n))/Us'; + + + /** + * + * Generates a replacement for the matched text. Token options are: + * + * 'type' => + * 'bullet_start' : the start of a bullet list + * 'bullet_end' : the end of a bullet list + * 'number_start' : the start of a number list + * 'number_end' : the end of a number list + * 'item_start' : the start of item text (bullet or number) + * 'item_end' : the end of item text (bullet or number) + * 'unknown' : unknown type of list or item + * + * 'level' => the indent level (0 for the first level, 1 for the + * second, etc) + * + * 'count' => the list item number at this level. not needed for + * xhtml, but very useful for PDF and RTF. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return A series of text and delimited tokens marking the different + * list text and list elements. + * + */ + + function process(&$matches) + { + // the replacement text we will return + $return = ''; + + // the list of post-processing matches + $list = array(); + + // a stack of list-start and list-end types; we keep this + // so that we know what kind of list we're working with + // (bullet or number) and what indent level we're at. + $stack = array(); + + // the item count is the number of list items for any + // given list-type on the stack + $itemcount = array(); + + // have we processed the very first list item? + $pastFirst = false; + + // populate $list with this set of matches. $matches[1] is the + // text matched as a list set by parse(). + preg_match_all( + '=^( {0,})(\*|#) (.*)$=Ums', + $matches[1], + $list, + PREG_SET_ORDER + ); + + // loop through each list-item element. + foreach ($list as $key => $val) { + + // $val[0] is the full matched list-item line + // $val[1] is the number of initial spaces (indent level) + // $val[2] is the list item type (* or #) + // $val[3] is the list item text + + // how many levels are we indented? (1 means the "root" + // list level, no indenting.) + $level = strlen($val[1]) + 1; + + // get the list item type + if ($val[2] == '*') { + $type = 'bullet'; + } elseif ($val[2] == '#') { + $type = 'number'; + } else { + $type = 'unknown'; + } + + // get the text of the list item + $text = $val[3]; + + // add a level to the list? + if ($level > count($stack)) { + + // the current indent level is greater than the + // number of stack elements, so we must be starting + // a new list. push the new list type onto the + // stack... + array_push($stack, $type); + + // ...and add a list-start token to the return. + $return .= $this->wiki->addToken( + $this->rule, + array( + 'type' => $type . '_list_start', + 'level' => $level - 1 + ) + ); + } + + // remove a level from the list? + while (count($stack) > $level) { + + // so we don't keep counting the stack, we set up a temp + // var for the count. -1 becuase we're going to pop the + // stack in the next command. $tmp will then equal the + // current level of indent. + $tmp = count($stack) - 1; + + // as long as the stack count is greater than the + // current indent level, we need to end list types. + // continue adding end-list tokens until the stack count + // and the indent level are the same. + $return .= $this->wiki->addToken( + $this->rule, + array ( + 'type' => array_pop($stack) . '_list_end', + 'level' => $tmp + ) + ); + + // reset to the current (previous) list type so that + // the new list item matches the proper list type. + $type = $stack[$tmp - 1]; + + // reset the item count for the popped indent level + unset($itemcount[$tmp + 1]); + } + + // add to the item count for this list (taking into account + // which level we are at). + if (! isset($itemcount[$level])) { + // first count + $itemcount[$level] = 0; + } else { + // increment count + $itemcount[$level]++; + } + + // is this the very first item in the list? + if (! $pastFirst) { + $first = true; + $pastFirst = true; + } else { + $first = false; + } + + // create a list-item starting token. + $start = $this->wiki->addToken( + $this->rule, + array( + 'type' => $type . '_item_start', + 'level' => $level, + 'count' => $itemcount[$level], + 'first' => $first + ) + ); + + // create a list-item ending token. + $end = $this->wiki->addToken( + $this->rule, + array( + 'type' => $type . '_item_end', + 'level' => $level, + 'count' => $itemcount[$level] + ) + ); + + // add the starting token, list-item text, and ending token + // to the return. + $return .= $start . $val[3] . $end; + } + + // the last list-item may have been indented. go through the + // list-type stack and create end-list tokens until the stack + // is empty. + while (count($stack) > 0) { + $return .= $this->wiki->addToken( + $this->rule, + array ( + 'type' => array_pop($stack) . '_list_end', + 'level' => count($stack) + ) + ); + } + + // we're done! send back the replacement text. + return "\n" . $return . "\n\n"; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Newline.php b/bundled-libs/Text/Wiki/Parse/Default/Newline.php new file mode 100644 index 0000000..67e2026 --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Newline.php @@ -0,0 +1,57 @@ + +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Newline extends Text_Wiki_Parse { + + + /** + * + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * + * @access public + * + * @var string + * + * @see parse() + * + */ + + var $regex = '/([^\n])\n([^\n])/m'; + + + /** + * + * Generates a replacement token for the matched text. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return string A delimited token to be used as a placeholder in + * the source text. + * + */ + + function process(&$matches) + { + return $matches[1] . + $this->wiki->addToken($this->rule) . + $matches[2]; + } +} + +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Paragraph.php b/bundled-libs/Text/Wiki/Parse/Default/Paragraph.php new file mode 100644 index 0000000..bbc4289 --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Paragraph.php @@ -0,0 +1,128 @@ + +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Paragraph extends Text_Wiki_Parse { + + /** + * + * The regular expression used to find source text matching this + * rule. + * + * @access public + * + * @var string + * + */ + + var $regex = "/^.*?\n\n/m"; + + var $conf = array( + 'skip' => array( + 'blockquote', // are we sure about this one? + 'code', + 'heading', + 'horiz', + 'deflist', + 'table', + 'list', + 'toc' + ) + ); + + + /** + * + * Generates a token entry for the matched text. Token options are: + * + * 'start' => The starting point of the paragraph. + * + * 'end' => The ending point of the paragraph. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return A delimited token number to be used as a placeholder in + * the source text. + * + */ + + function process(&$matches) + { + $delim = $this->wiki->delim; + + // was anything there? + if (trim($matches[0]) == '') { + return ''; + } + + // does the match start with a delimiter? + if (substr($matches[0], 0, 1) != $delim) { + // no. + + $start = $this->wiki->addToken( + $this->rule, array('type' => 'start') + ); + + $end = $this->wiki->addToken( + $this->rule, array('type' => 'end') + ); + + return $start . trim($matches[0]) . $end; + } + + // the line starts with a delimiter. read in the delimited + // token number, check the token, and see if we should + // skip it. + + // loop starting at the second character (we already know + // the first is a delimiter) until we find another + // delimiter; the text between them is a token key number. + $key = ''; + $len = strlen($matches[0]); + for ($i = 1; $i < $len; $i++) { + $char = $matches[0]{$i}; + if ($char == $delim) { + break; + } else { + $key .= $char; + } + } + + // look at the token and see if it's skippable (if we skip, + // it will not be marked as a paragraph) + $token_type = strtolower($this->wiki->tokens[$key][0]); + $skip = $this->getConf('skip', array()); + + if (in_array($token_type, $skip)) { + // this type of token should not have paragraphs applied to it. + // return the entire matched text. + return $matches[0]; + } else { + + $start = $this->wiki->addToken( + $this->rule, array('type' => 'start') + ); + + $end = $this->wiki->addToken( + $this->rule, array('type' => 'end') + ); + + return $start . trim($matches[0]) . $end; + } + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Phplookup.php b/bundled-libs/Text/Wiki/Parse/Default/Phplookup.php new file mode 100644 index 0000000..25511ea --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Phplookup.php @@ -0,0 +1,58 @@ + +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Phplookup extends Text_Wiki_Parse { + + + /** + * + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * + * @access public + * + * @var string + * + * @see parse() + * + */ + + var $regex = "/\[\[php (.+?)\]\]/"; + + + /** + * + * Generates a replacement for the matched text. Token options are: + * + * 'type' => ['start'|'end'] The starting or ending point of the + * teletype text. The text itself is left in the source. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return string A pair of delimited tokens to be used as a + * placeholder in the source text surrounding the teletype text. + * + */ + + function process(&$matches) + { + return $this->wiki->addToken( + $this->rule, array('text' => $matches[1]) + ); + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Prefilter.php b/bundled-libs/Text/Wiki/Parse/Default/Prefilter.php new file mode 100644 index 0000000..66f5eeb --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Prefilter.php @@ -0,0 +1,62 @@ + +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Prefilter extends Text_Wiki_Parse { + + + /** + * + * Simple parsing method. + * + * @access public + * + */ + + function parse() + { + // convert DOS line endings + $this->wiki->source = str_replace("\r\n", "\n", + $this->wiki->source); + + // convert Macintosh line endings + $this->wiki->source = str_replace("\r", "\n", + $this->wiki->source); + + // concat lines ending in a backslash + $this->wiki->source = str_replace("\\\n", "", + $this->wiki->source); + + // convert tabs to four-spaces + $this->wiki->source = str_replace("\t", " ", + $this->wiki->source); + + // add extra newlines at the top and end; this + // seems to help many rules. + $this->wiki->source = "\n" . $this->wiki->source . "\n\n"; + + // finally, compress all instances of 3 or more newlines + // down to two newlines. + $find = "/\n{3,}/m"; + $replace = "\n\n"; + $this->wiki->source = preg_replace($find, $replace, + $this->wiki->source); + } + +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Raw.php b/bundled-libs/Text/Wiki/Parse/Default/Raw.php new file mode 100644 index 0000000..eaa95a0 --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Raw.php @@ -0,0 +1,55 @@ + +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Raw extends Text_Wiki_Parse { + + + /** + * + * The regular expression used to find source text matching this + * rule. + * + * @access public + * + * @var string + * + */ + + var $regex = "/``(.*)``/U"; + + + /** + * + * Generates a token entry for the matched text. Token options are: + * + * 'text' => The full matched text. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return A delimited token number to be used as a placeholder in + * the source text. + * + */ + + function process(&$matches) + { + $options = array('text' => $matches[1]); + return $this->wiki->addToken($this->rule, $options); + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Revise.php b/bundled-libs/Text/Wiki/Parse/Default/Revise.php new file mode 100644 index 0000000..3425a0c --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Revise.php @@ -0,0 +1,130 @@ + +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Revise extends Text_Wiki_Parse { + + + /** + * + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * + * @access public + * + * @var string + * + * @see parse() + * + */ + + var $regex = "/\@\@({*?.*}*?)\@\@/U"; + + + /** + * + * Config options. + * + * @access public + * + * @var array + * + */ + + var $conf = array( + 'delmark' => '---', + 'insmark' => '+++' + ); + + + /** + * + * Generates a replacement for the matched text. Token options are: + * + * 'type' => ['start'|'end'] The starting or ending point of the + * inserted text. The text itself is left in the source. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return string A pair of delimited tokens to be used as a + * placeholder in the source text surrounding the teletype text. + * + */ + + function process(&$matches) + { + $output = ''; + $src = $matches[1]; + $delmark = $this->getConf('delmark'); // --- + $insmark = $this->getConf('insmark'); // +++ + + // '---' must be before '+++' (if they both appear) + $del = strpos($src, $delmark); + $ins = strpos($src, $insmark); + + // if neither is found, return right away + if ($del === false && $ins === false) { + return $matches[0]; + } + + // handle text to be deleted + if ($del !== false) { + + // move forward to the end of the deletion mark + $del += strlen($delmark); + + if ($ins === false) { + // there is no insertion text following + $text = substr($src, $del); + } else { + // there is insertion text following, + // mitigate the length + $text = substr($src, $del, $ins - $del); + } + + $output .= $this->wiki->addToken( + $this->rule, array('type' => 'del_start') + ); + + $output .= $text; + + $output .= $this->wiki->addToken( + $this->rule, array('type' => 'del_end') + ); + } + + // handle text to be inserted + if ($ins !== false) { + + // move forward to the end of the insert mark + $ins += strlen($insmark); + $text = substr($src, $ins); + + $output .= $this->wiki->addToken( + $this->rule, array('type' => 'ins_start') + ); + + $output .= $text; + + $output .= $this->wiki->addToken( + $this->rule, array('type' => 'ins_end') + ); + } + + return $output; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Strong.php b/bundled-libs/Text/Wiki/Parse/Default/Strong.php new file mode 100644 index 0000000..a46ef77 --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Strong.php @@ -0,0 +1,67 @@ + +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Strong extends Text_Wiki_Parse { + + + /** + * + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * + * @access public + * + * @var string + * + * @see parse() + * + */ + + var $regex = "/\*\*(.*?)\*\*/"; + + + /** + * + * Generates a replacement for the matched text. Token options are: + * + * 'type' => ['start'|'end'] The starting or ending point of the + * emphasized text. The text itself is left in the source. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return A pair of delimited tokens to be used as a placeholder in + * the source text surrounding the text to be emphasized. + * + */ + + function process(&$matches) + { + $start = $this->wiki->addToken( + $this->rule, array('type' => 'start') + ); + + $end = $this->wiki->addToken( + $this->rule, array('type' => 'end') + ); + + return $start . $matches[1] . $end; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Superscript.php b/bundled-libs/Text/Wiki/Parse/Default/Superscript.php new file mode 100644 index 0000000..5edf329 --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Superscript.php @@ -0,0 +1,67 @@ + +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Superscript extends Text_Wiki_Parse { + + + /** + * + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * + * @access public + * + * @var string + * + * @see parse() + * + */ + + var $regex = "/\^\^(()|.*)\^\^/U"; + + + /** + * + * Generates a replacement for the matched text. Token options are: + * + * 'type' => ['start'|'end'] The starting or ending point of the + * emphasized text. The text itself is left in the source. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return A pair of delimited tokens to be used as a placeholder in + * the source text surrounding the text to be emphasized. + * + */ + + function process(&$matches) + { + $start = $this->wiki->addToken( + $this->rule, array('type' => 'start') + ); + + $end = $this->wiki->addToken( + $this->rule, array('type' => 'end') + ); + + return $start . $matches[1] . $end; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Table.php b/bundled-libs/Text/Wiki/Parse/Default/Table.php new file mode 100644 index 0000000..e24db22 --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Table.php @@ -0,0 +1,208 @@ + +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Table extends Text_Wiki_Parse { + + + /** + * + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * + * @access public + * + * @var string + * + * @see parse() + * + */ + + var $regex = '/\n((\|\|).*)(\n)(?!(\|\|))/Us'; + + + /** + * + * Generates a replacement for the matched text. + * + * Token options are: + * + * 'type' => + * 'table_start' : the start of a bullet list + * 'table_end' : the end of a bullet list + * 'row_start' : the start of a number list + * 'row_end' : the end of a number list + * 'cell_start' : the start of item text (bullet or number) + * 'cell_end' : the end of item text (bullet or number) + * + * 'cols' => the number of columns in the table (for 'table_start') + * + * 'rows' => the number of rows in the table (for 'table_start') + * + * 'span' => column span (for 'cell_start') + * + * 'attr' => column attribute flag (for 'cell_start') + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return A series of text and delimited tokens marking the different + * table elements and cell text. + * + */ + + function process(&$matches) + { + // our eventual return value + $return = ''; + + // the number of columns in the table + $num_cols = 0; + + // the number of rows in the table + $num_rows = 0; + + // rows are separated by newlines in the matched text + $rows = explode("\n", $matches[1]); + + // loop through each row + foreach ($rows as $row) { + + // increase the row count + $num_rows ++; + + // start a new row + $return .= $this->wiki->addToken( + $this->rule, + array('type' => 'row_start') + ); + + // cells are separated by double-pipes + $cell = explode("||", $row); + + // get the number of cells (columns) in this row + $last = count($cell) - 1; + + // is this more than the current column count? + // (we decrease by 1 because we never use cell zero) + if ($last - 1 > $num_cols) { + // increase the column count + $num_cols = $last - 1; + } + + // by default, cells span only one column (their own) + $span = 1; + + // ignore cell zero, and ignore the "last" cell; cell zero + // is before the first double-pipe, and the "last" cell is + // after the last double-pipe. both are always empty. + for ($i = 1; $i < $last; $i ++) { + + // if there is no content at all, then it's an instance + // of two sets of || next to each other, indicating a + // span. + if ($cell[$i] == '') { + + // add to the span and loop to the next cell + $span += 1; + continue; + + } else { + + // this cell has content. + + // find any special "attr"ibute cell markers + if (substr($cell[$i], 0, 2) == '> ') { + // right-align + $attr = 'right'; + $cell[$i] = substr($cell[$i], 2); + } elseif (substr($cell[$i], 0, 2) == '= ') { + // center-align + $attr = 'center'; + $cell[$i] = substr($cell[$i], 2); + } elseif (substr($cell[$i], 0, 2) == '< ') { + // left-align + $attr = 'left'; + $cell[$i] = substr($cell[$i], 2); + } elseif (substr($cell[$i], 0, 2) == '~ ') { + $attr = 'header'; + $cell[$i] = substr($cell[$i], 2); + } else { + $attr = null; + } + + // start a new cell... + $return .= $this->wiki->addToken( + $this->rule, + array ( + 'type' => 'cell_start', + 'attr' => $attr, + 'span' => $span + ) + ); + + // ...add the content... + $return .= trim($cell[$i]); + + // ...and end the cell. + $return .= $this->wiki->addToken( + $this->rule, + array ( + 'type' => 'cell_end', + 'attr' => $attr, + 'span' => $span + ) + ); + + // reset the span. + $span = 1; + } + + } + + // end the row + $return .= $this->wiki->addToken( + $this->rule, + array('type' => 'row_end') + ); + + } + + // wrap the return value in start and end tokens + $return = + $this->wiki->addToken( + $this->rule, + array( + 'type' => 'table_start', + 'rows' => $num_rows, + 'cols' => $num_cols + ) + ) + . $return . + $this->wiki->addToken( + $this->rule, + array( + 'type' => 'table_end' + ) + ); + + // we're done! + return "\n$return\n\n"; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Tighten.php b/bundled-libs/Text/Wiki/Parse/Default/Tighten.php new file mode 100644 index 0000000..a1c5e59 --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Tighten.php @@ -0,0 +1,32 @@ + +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Tighten extends Text_Wiki_Parse { + + + /** + * + * Apply tightening directly to the source text. + * + * @access public + * + */ + + function parse() + { + $this->wiki->source = str_replace("\n", '', + $this->wiki->source); + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Toc.php b/bundled-libs/Text/Wiki/Parse/Default/Toc.php new file mode 100644 index 0000000..c147ce3 --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Toc.php @@ -0,0 +1,112 @@ + +* +* @package Text_Wiki +* +*/ + + +class Text_Wiki_Parse_Toc extends Text_Wiki_Parse { + + + /** + * + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * + * @access public + * + * @var string + * + * @see parse() + * + */ + + var $regex = "/\n\[\[toc( .*)?\]\]\n/m"; + + + /** + * + * Generates a replacement for the matched text. + * + * Token options are: + * + * 'type' => ['list_start'|'list_end'|'item_start'|'item_end'|'target'] + * + * 'level' => The heading level (1-6). + * + * 'count' => Which entry number this is in the list. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return string A token indicating the TOC collection point. + * + */ + + function process(&$matches) + { + $count = 0; + + if (isset($matches[1])) { + $attr = $this->getAttrs(trim($matches[1])); + } else { + $attr = array(); + } + + $output = $this->wiki->addToken( + $this->rule, + array( + 'type' => 'list_start', + 'level' => 0, + 'attr' => $attr + ) + ); + + foreach ($this->wiki->getTokens('Heading') as $key => $val) { + + if ($val[1]['type'] != 'start') { + continue; + } + + $options = array( + 'type' => 'item_start', + 'id' => $val[1]['id'], + 'level' => $val[1]['level'], + 'count' => $count ++ + ); + + $output .= $this->wiki->addToken($this->rule, $options); + + $output .= $val[1]['text']; + + $output .= $this->wiki->addToken( + $this->rule, + array( + 'type' => 'item_end', + 'level' => $val[1]['level'] + ) + ); + } + + $output .= $this->wiki->addToken( + $this->rule, array( + 'type' => 'list_end', + 'level' => 0 + ) + ); + + return $output; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Tt.php b/bundled-libs/Text/Wiki/Parse/Default/Tt.php new file mode 100644 index 0000000..adf05b7 --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Tt.php @@ -0,0 +1,69 @@ + ['start'|'end'] The starting or ending point of the +* teletype text. The text itself is left in the source. +* +* +* $Id: Tt.php,v 1.1 2005/01/31 15:46:52 pmjones Exp $ +* +* @author Paul M. Jones +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Tt extends Text_Wiki_Parse { + + + /** + * + * The regular expression used to parse the source text. + * + * @access public + * + * @var string + * + * @see parse() + * + */ + + var $regex = "/{{({*?.*}*?)}}/U"; + + + /** + * + * Generates a replacement for the matched text. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return string A pair of delimited tokens to be used as a + * placeholder in the source text surrounding the teletype text. + * + */ + + function process(&$matches) + { + $start = $this->wiki->addToken( + $this->rule, array('type' => 'start') + ); + + $end = $this->wiki->addToken( + $this->rule, array('type' => 'end') + ); + + return $start . $matches[1] . $end; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Url.php b/bundled-libs/Text/Wiki/Parse/Default/Url.php new file mode 100644 index 0000000..c78de9b --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Url.php @@ -0,0 +1,265 @@ + tag (for the 'xhtml' +* format). +* +* Token options are: +* +* 'type' => ['inline'|'footnote'|'descr'] the type of URL +* +* 'href' => the URL link href portion +* +* 'text' => the displayed text of the URL link +* +* $Id: Url.php,v 1.1 2005/01/31 15:46:52 pmjones Exp $ +* +* @author Paul M. Jones +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Url extends Text_Wiki_Parse { + + + /** + * + * Keeps a running count of numbered-reference URLs. + * + * @access public + * + * @var int + * + */ + + var $footnoteCount = 0; + + + /** + * + * URL schemes recognized by this rule. + * + * @access public + * + * @var array + * + */ + + var $conf = array( + 'schemes' => array( + 'http://', + 'https://', + 'ftp://', + 'gopher://', + 'news://', + 'mailto:' + ) + ); + + + /** + * + * Constructor. + * + * We override the constructor so we can comment the regex nicely. + * + * @access public + * + */ + + function Text_Wiki_Parse_Url(&$obj) + { + parent::Text_Wiki_Parse($obj); + + // convert the list of recognized schemes to a regex-safe string, + // where the pattern delim is a slash + $tmp = array(); + $list = $this->getConf('schemes', array()); + foreach ($list as $val) { + $tmp[] = preg_quote($val, '/'); + } + $schemes = implode('|', $tmp); + + // build the regex + $this->regex = + "($schemes)" . // allowed schemes + "(" . // start pattern + "[^ \\/\"\'{$this->wiki->delim}]*\\/" . // no spaces, backslashes, slashes, double-quotes, single quotes, or delimiters; + ")*" . // end pattern + "[^ \\t\\n\\/\"\'{$this->wiki->delim}]*" . + "[A-Za-z0-9\\/?=&~_]"; + } + + + /** + * + * Find three different kinds of URLs in the source text. + * + * @access public + * + */ + + function parse() + { + // ------------------------------------------------------------- + // + // Described-reference (named) URLs. + // + + // the regular expression for this kind of URL + $tmp_regex = '/\[(' . $this->regex . ') ([^\]]+)\]/'; + + // use a custom callback processing method to generate + // the replacement text for matches. + $this->wiki->source = preg_replace_callback( + $tmp_regex, + array(&$this, 'processDescr'), + $this->wiki->source + ); + + + // ------------------------------------------------------------- + // + // Numbered-reference (footnote-style) URLs. + // + + // the regular expression for this kind of URL + $tmp_regex = '/\[(' . $this->regex . ')\]/U'; + + // use a custom callback processing method to generate + // the replacement text for matches. + $this->wiki->source = preg_replace_callback( + $tmp_regex, + array(&$this, 'processFootnote'), + $this->wiki->source + ); + + + // ------------------------------------------------------------- + // + // Normal inline URLs. + // + + // the regular expression for this kind of URL + + $tmp_regex = '/(^|[^A-Za-z])(' . $this->regex . ')(.*?)/'; + + // use the standard callback for inline URLs + $this->wiki->source = preg_replace_callback( + $tmp_regex, + array(&$this, 'process'), + $this->wiki->source + ); + } + + + /** + * + * Process inline URLs. + * + * @param array &$matches + * + * @param array $matches An array of matches from the parse() method + * as generated by preg_replace_callback. $matches[0] is the full + * matched string, $matches[1] is the first matched pattern, + * $matches[2] is the second matched pattern, and so on. + * + * @return string The processed text replacement. + * + */ + + function process(&$matches) + { + // set options + $options = array( + 'type' => 'inline', + 'href' => $matches[2], + 'text' => $matches[2] + ); + + // tokenize + return $matches[1] . $this->wiki->addToken($this->rule, $options) . $matches[5]; + } + + + /** + * + * Process numbered (footnote) URLs. + * + * Token options are: + * @param array &$matches + * + * @param array $matches An array of matches from the parse() method + * as generated by preg_replace_callback. $matches[0] is the full + * matched string, $matches[1] is the first matched pattern, + * $matches[2] is the second matched pattern, and so on. + * + * @return string The processed text replacement. + * + */ + + function processFootnote(&$matches) + { + // keep a running count for footnotes + $this->footnoteCount++; + + // set options + $options = array( + 'type' => 'footnote', + 'href' => $matches[1], + 'text' => $this->footnoteCount + ); + + // tokenize + return $this->wiki->addToken($this->rule, $options); + } + + + /** + * + * Process described-reference (named-reference) URLs. + * + * Token options are: + * 'type' => ['inline'|'footnote'|'descr'] the type of URL + * 'href' => the URL link href portion + * 'text' => the displayed text of the URL link + * + * @param array &$matches + * + * @param array $matches An array of matches from the parse() method + * as generated by preg_replace_callback. $matches[0] is the full + * matched string, $matches[1] is the first matched pattern, + * $matches[2] is the second matched pattern, and so on. + * + * @return string The processed text replacement. + * + */ + + function processDescr(&$matches) + { + // set options + $options = array( + 'type' => 'descr', + 'href' => $matches[1], + 'text' => $matches[4] + ); + + // tokenize + return $this->wiki->addToken($this->rule, $options); + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Parse/Default/Wikilink.php b/bundled-libs/Text/Wiki/Parse/Default/Wikilink.php new file mode 100644 index 0000000..f25538e --- /dev/null +++ b/bundled-libs/Text/Wiki/Parse/Default/Wikilink.php @@ -0,0 +1,158 @@ + the wiki page name. +* +* 'text' => the displayed link text. +* +* 'anchor' => a named anchor on the target wiki page. +* +* $Id: Wikilink.php,v 1.1 2005/01/31 15:46:52 pmjones Exp $ +* +* @author Paul M. Jones +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Parse_Wikilink extends Text_Wiki_Parse { + + + /** + * + * Constructor. + * + * We override the Text_Wiki_Parse constructor so we can + * explicitly comment each part of the $regex property. + * + * @access public + * + * @param object &$obj The calling "parent" Text_Wiki object. + * + */ + + function Text_Wiki_Parse_Wikilink(&$obj) + { + parent::Text_Wiki_Parse($obj); + + // allows numbers as "lowercase letters" in the regex + $this->regex = + "(!?" . // START WikiPage pattern (1) + "[A-Z]" . // 1 upper + "[A-Za-z0-9]*" . // 0+ alpha or digit + "[a-z0-9]+" . // 1+ lower or digit + "[A-Z]" . // 1 upper + "[A-Za-z0-9]*" . // 0+ or more alpha or digit + ")" . // END WikiPage pattern (/1) + "((\#" . // START Anchor pattern (2)(3) + "[A-Za-z]" . // 1 alpha + "(" . // start sub pattern (4) + "[-A-Za-z0-9_:.]*" . // 0+ dash, alpha, digit, underscore, colon, dot + "[-A-Za-z0-9_]" . // 1 dash, alpha, digit, or underscore + ")?)?)"; // end subpatterns (/4)(/3)(/2) + + } + + + /** + * + * First parses for described links, then for standalone links. + * + * @access public + * + * @return void + * + */ + + function parse() + { + // described wiki links + $tmp_regex = '/\[' . $this->regex . ' (.+?)\]/'; + $this->wiki->source = preg_replace_callback( + $tmp_regex, + array(&$this, 'processDescr'), + $this->wiki->source + ); + + // standalone wiki links + $tmp_regex = '/(^|[^A-Za-z0-9\-_])' . $this->regex . '/'; + $this->wiki->source = preg_replace_callback( + $tmp_regex, + array(&$this, 'process'), + $this->wiki->source + ); + } + + + /** + * + * Generate a replacement for described links. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return A delimited token to be used as a placeholder in + * the source text, plus any text priot to the match. + * + */ + + function processDescr(&$matches) + { + // set the options + $options = array( + 'page' => $matches[1], + 'text' => $matches[5], + 'anchor' => $matches[3] + ); + + // create and return the replacement token and preceding text + return $this->wiki->addToken($this->rule, $options); // . $matches[7]; + } + + + /** + * + * Generate a replacement for standalone links. + * + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return A delimited token to be used as a placeholder in + * the source text, plus any text prior to the match. + * + */ + + function process(&$matches) + { + // when prefixed with !, it's explicitly not a wiki link. + // return everything as it was. + if ($matches[2]{0} == '!') { + return $matches[1] . substr($matches[2], 1) . $matches[3]; + } + + // set the options + $options = array( + 'page' => $matches[2], + 'text' => $matches[2] . $matches[3], + 'anchor' => $matches[3] + ); + + // create and return the replacement token and preceding text + return $matches[1] . $this->wiki->addToken($this->rule, $options); + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render.php b/bundled-libs/Text/Wiki/Render.php new file mode 100644 index 0000000..ab77bde --- /dev/null +++ b/bundled-libs/Text/Wiki/Render.php @@ -0,0 +1,167 @@ +wiki =& $obj; + + // get the config-key-name for this object, + // strip the Text_Wiki_Render_ part + // 01234567890123456 + $tmp = get_class($this); + $tmp = substr($tmp, 17); + + // split into pieces at the _ mark. + // first part is format, second part is rule. + $part = explode('_', $tmp); + $this->format = isset($part[0]) ? ucwords(strtolower($part[0])) : null; + $this->rule = isset($part[1]) ? ucwords(strtolower($part[1])) : null; + + // is there a format but no rule? + // then this is the "main" render object, with + // pre() and post() methods. + if ($this->format && ! $this->rule && + isset($this->wiki->formatConf[$this->format]) && + is_array($this->wiki->formatConf[$this->format])) { + + // this is a format render object + $this->conf = array_merge( + $this->conf, + $this->wiki->formatConf[$this->format] + ); + + } + + // is there a format and a rule? + if ($this->format && $this->rule && + isset($this->wiki->renderConf[$this->format][$this->rule]) && + is_array($this->wiki->renderConf[$this->format][$this->rule])) { + + // this is a rule render object + $this->conf = array_merge( + $this->conf, + $this->wiki->renderConf[$this->format][$this->rule] + ); + } + } + + + /** + * + * Simple method to safely get configuration key values. + * + * @access public + * + * @param string $key The configuration key. + * + * @param mixed $default If the key does not exist, return this value + * instead. + * + * @return mixed The configuration key value (if it exists) or the + * default value (if not). + * + */ + + function getConf($key, $default = null) + { + if (isset($this->conf[$key])) { + return $this->conf[$key]; + } else { + return $default; + } + } + + + /** + * + * Simple method to wrap a configuration in an sprintf() format. + * + * @access public + * + * @param string $key The configuration key. + * + * @param string $format The sprintf() format string. + * + * @return mixed The formatted configuration key value (if it exists) + * or null (if it does not). + * + */ + + function formatConf($format, $key) + { + if (isset($this->conf[$key])) { + return sprintf($format, $this->conf[$key]); + } else { + return null; + } + } + +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex.php b/bundled-libs/Text/Wiki/Render/Latex.php new file mode 100644 index 0000000..4383bda --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex.php @@ -0,0 +1,90 @@ + +* +* @package Text_Wiki +* +* @todo [http://google.com] becomes 1 with a LaTeX footnote in subscript. +* This should be a normal LaTeX footnote associated with the +* previous word? +* +* @todo parse "..." to be ``...'' +* +* @todo parse '...' to be `...' +* +* @todo move escape_latex to a static function, move escaping to the +* individual .php files they are associated with +* +* @todo allow the user to add conf items to do things like +* + A custom document header +* + Custom page headings +* + Include packages +* + Set Title, Author, Date +* + Include a title page +* + Not output Document Head/Foot (maybe combinding many pages?) +* +*/ + +class Text_Wiki_Render_Latex extends Text_Wiki_Render { + function escape_latex ($txt) { + $txt = str_replace("\\", "\\\\", $txt); + $txt = str_replace('#', '\#', $txt); + $txt = str_replace('$', '\$', $txt); + $txt = str_replace('%', '\%', $txt); + $txt = str_replace('^', '\^', $txt); + $txt = str_replace('&', '\&', $txt); + $txt = str_replace('_', '\_', $txt); + $txt = str_replace('{', '\{', $txt); + $txt = str_replace('}', '\}', $txt); + + // Typeset things a bit prettier than normas + $txt = str_replace('~', '$\sim$', $txt); + $txt = str_replace('...', '\ldots', $txt); + + return $txt; + } + + function escape($tok, $ele) { + if (isset($tok[$ele])) { + $tok[$ele] = $this->escape_latex($tok[$ele]); + } + + return $tok; + } + + function pre() + { + foreach ($this->wiki->tokens as $k => $tok) { + if ($tok[0] == 'Code') { + continue; + } + + $tok[1] = $this->escape($tok[1], 'text'); + $tok[1] = $this->escape($tok[1], 'page'); + $tok[1] = $this->escape($tok[1], 'href'); + + $this->wiki->tokens[$k] = $tok; + } + + $this->wiki->source = $this->escape_latex($this->wiki->source); + + return + "\\documentclass{article}\n". + "\\usepackage{ulem}\n". + "\\pagestyle{headings}\n". + "\\begin{document}\n"; + } + + function post() + { + return "\\end{document}\n"; + } + +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Anchor.php b/bundled-libs/Text/Wiki/Render/Latex/Anchor.php new file mode 100644 index 0000000..b7e0a81 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Anchor.php @@ -0,0 +1,33 @@ + +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Render_Latex_Anchor extends Text_Wiki_Render { + + function token($options) + { + extract($options); // $type, $name + + if ($type == 'start') { + //return sprintf('',$name); + return ''; + } + + if ($type == 'end') { + //return ''; + return ''; + } + } +} + +?> diff --git a/bundled-libs/Text/Wiki/Render/Latex/Blockquote.php b/bundled-libs/Text/Wiki/Render/Latex/Blockquote.php new file mode 100644 index 0000000..9810622 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Blockquote.php @@ -0,0 +1,36 @@ + 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']; + + // starting + if ($type == 'start') { + return "\\begin{quote}\n"; + } + + // ending + if ($type == 'end') { + return "\\end{quote}\n\n"; + } + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Bold.php b/bundled-libs/Text/Wiki/Render/Latex/Bold.php new file mode 100644 index 0000000..ed72993 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Bold.php @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Break.php b/bundled-libs/Text/Wiki/Render/Latex/Break.php new file mode 100644 index 0000000..1f3fdd3 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Break.php @@ -0,0 +1,24 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Center.php b/bundled-libs/Text/Wiki/Render/Latex/Center.php new file mode 100644 index 0000000..59adffd --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Center.php @@ -0,0 +1,33 @@ +\n"; + return '
'; + } + + if ($options['type'] == 'end') { + //return "\n"; + return '
'; + } + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Code.php b/bundled-libs/Text/Wiki/Render/Latex/Code.php new file mode 100644 index 0000000..40bb45a --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Code.php @@ -0,0 +1,26 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Colortext.php b/bundled-libs/Text/Wiki/Render/Latex/Colortext.php new file mode 100644 index 0000000..86ff095 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Colortext.php @@ -0,0 +1,58 @@ +colors)) { + $color = '#' . $color; + } + + if ($type == 'start') { + return ""; + } + + if ($options['type'] == 'end') { + return ''; + } + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Deflist.php b/bundled-libs/Text/Wiki/Render/Latex/Deflist.php new file mode 100644 index 0000000..8dbfe97 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Deflist.php @@ -0,0 +1,53 @@ + 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']; + switch ($type) + { + case 'list_start': + return "\\begin{description}\n"; + + case 'list_end': + return "\\end{description}\n\n"; + + case 'term_start': + return '\item['; + + case 'term_end': + return '] '; + + case 'narr_start': + return '{'; + + case 'narr_end': + return "}\n"; + + default: + return ''; + + } + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Delimiter.php b/bundled-libs/Text/Wiki/Render/Latex/Delimiter.php new file mode 100644 index 0000000..49a50aa --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Delimiter.php @@ -0,0 +1,25 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Embed.php b/bundled-libs/Text/Wiki/Render/Latex/Embed.php new file mode 100644 index 0000000..0936c7d --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Embed.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Emphasis.php b/bundled-libs/Text/Wiki/Render/Latex/Emphasis.php new file mode 100644 index 0000000..d949b42 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Emphasis.php @@ -0,0 +1,29 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Freelink.php b/bundled-libs/Text/Wiki/Render/Latex/Freelink.php new file mode 100644 index 0000000..469e0e6 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Freelink.php @@ -0,0 +1,34 @@ + array(), + 'view_url' => 'http://example.com/index.php?page=%s', + 'new_url' => 'http://example.com/new.php?page=%s', + 'new_text' => '?' + ); + + + /** + * + * 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) + { + // get nice variable names (page, text, anchor) + extract($options); + + return "$text\\footnote\{$anchor} "; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Function.php b/bundled-libs/Text/Wiki/Render/Latex/Function.php new file mode 100644 index 0000000..5f4c488 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Function.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Heading.php b/bundled-libs/Text/Wiki/Render/Latex/Heading.php new file mode 100644 index 0000000..eab4d54 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Heading.php @@ -0,0 +1,33 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Horiz.php b/bundled-libs/Text/Wiki/Render/Latex/Horiz.php new file mode 100644 index 0000000..bb159d4 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Horiz.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Html.php b/bundled-libs/Text/Wiki/Render/Latex/Html.php new file mode 100644 index 0000000..350de4a --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Html.php @@ -0,0 +1,25 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Image.php b/bundled-libs/Text/Wiki/Render/Latex/Image.php new file mode 100644 index 0000000..e6c084b --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Image.php @@ -0,0 +1,70 @@ + '/' + ); + + + /** + * + * 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 'Image: NI'; + + $src = '"' . + $this->getConf('base', '/') . + $options['src'] . '"'; + + if (isset($options['attr']['link'])) { + + // this image has a link + if (strpos($options['attr']['link'], '://')) { + // it's a URL + $href = $options['attr']['link']; + } else { + $href = $this->wiki->getRenderConf('xhtml', 'wikilink', 'view_url') . + $options['attr']['link']; + } + + } else { + // image is not linked + $href = null; + } + + // unset these so they don't show up as attributes + unset($options['attr']['link']); + + $attr = ''; + $alt = false; + foreach ($options['attr'] as $key => $val) { + if (strtolower($key) == 'alt') { + $alt = true; + } + $attr .= " $key=\"$val\""; + } + + // always add an "alt" attribute per Stephane Solliec + if (! $alt) { + $attr .= ' alt="' . basename($options['src']) . '"'; + } + + if ($href) { + return ""; + } else { + return ""; + } + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Include.php b/bundled-libs/Text/Wiki/Render/Latex/Include.php new file mode 100644 index 0000000..f23d7a5 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Include.php @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Interwiki.php b/bundled-libs/Text/Wiki/Render/Latex/Interwiki.php new file mode 100644 index 0000000..d569a07 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Interwiki.php @@ -0,0 +1,60 @@ + 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' + ); + + + /** + * + * 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) + { + $site = $options['site']; + $page = $options['page']; + $text = $options['text']; + + 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', ''); + + if ($target && trim($target) != '') { + $target = " target=\"$target\""; + } + + return "$text\\footnote\{$href}"; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Italic.php b/bundled-libs/Text/Wiki/Render/Latex/Italic.php new file mode 100644 index 0000000..6078530 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Italic.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/List.php b/bundled-libs/Text/Wiki/Render/Latex/List.php new file mode 100644 index 0000000..6936e38 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/List.php @@ -0,0 +1,57 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Newline.php b/bundled-libs/Text/Wiki/Render/Latex/Newline.php new file mode 100644 index 0000000..f5d09c4 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Newline.php @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Paragraph.php b/bundled-libs/Text/Wiki/Render/Latex/Paragraph.php new file mode 100644 index 0000000..45d487e --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Paragraph.php @@ -0,0 +1,31 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Phplookup.php b/bundled-libs/Text/Wiki/Render/Latex/Phplookup.php new file mode 100644 index 0000000..8c75604 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Phplookup.php @@ -0,0 +1,34 @@ + '_blank'); + + /** + * + * 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 'Phplookup: NI'; + + $text = trim($options['text']); + + $target = $this->getConf('target', ''); + if ($target) { + $target = " target=\"$target\""; + } + + return "$text"; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Prefilter.php b/bundled-libs/Text/Wiki/Render/Latex/Prefilter.php new file mode 100644 index 0000000..13a2edf --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Prefilter.php @@ -0,0 +1,40 @@ + | +// +----------------------------------------------------------------------+ +// +// $Id: Prefilter.php,v 1.2 2004/09/25 19:05:13 pmjones Exp $ + + +/** +* +* This class implements a Text_Wiki_Render_Latex 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. +* +* @author Jeremy Cowgar +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Render_Latex_Prefilter extends Text_Wiki_Render { + function token() + { + return ''; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Raw.php b/bundled-libs/Text/Wiki/Render/Latex/Raw.php new file mode 100644 index 0000000..4ef4cbe --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Raw.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Revise.php b/bundled-libs/Text/Wiki/Render/Latex/Revise.php new file mode 100644 index 0000000..f880156 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Revise.php @@ -0,0 +1,38 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Strong.php b/bundled-libs/Text/Wiki/Render/Latex/Strong.php new file mode 100644 index 0000000..721ffa3 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Strong.php @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Superscript.php b/bundled-libs/Text/Wiki/Render/Latex/Superscript.php new file mode 100644 index 0000000..887a8b3 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Superscript.php @@ -0,0 +1,31 @@ +'; + } + + if ($options['type'] == 'end') { + return ''; + } + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Table.php b/bundled-libs/Text/Wiki/Render/Latex/Table.php new file mode 100644 index 0000000..96c773d --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Table.php @@ -0,0 +1,93 @@ + 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) + extract($options); + + switch ($type) + { + case 'table_start': + $this->cell_count = $cols; + + $tbl_start = '\begin{tabular}{|'; + for ($a=0; $a < $this->cell_count; $a++) { + $tbl_start .= 'l|'; + } + $tbl_start .= "}\n"; + + return $tbl_start; + + case 'table_end': + return "\\hline\n\\end{tabular}\n"; + + case 'row_start': + $this->is_spanning = false; + $this->cell_id = 0; + return "\\hline\n"; + + case 'row_end': + return "\\\\\n"; + + case 'cell_start': + if ($span > 1) { + $col_spec = ''; + if ($this->cell_id == 0) { + $col_spec = '|'; + } + $col_spec .= 'l|'; + + $this->cell_id += $span; + $this->is_spanning = true; + + return "\\multicolumn\{$span}\{$col_spec}{"; + } + + $this->cell_id += 1; + return ''; + + case 'cell_end': + $out = ''; + if ($this->is_spanning) { + $this->is_spanning = false; + $out = '}'; + } + + if ($this->cell_id != $this->cell_count) { + $out .= ' & '; + } + + return $out; + + default: + return ''; + + } + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Tighten.php b/bundled-libs/Text/Wiki/Render/Latex/Tighten.php new file mode 100644 index 0000000..7755e94 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Tighten.php @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Toc.php b/bundled-libs/Text/Wiki/Render/Latex/Toc.php new file mode 100644 index 0000000..fc5846f --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Toc.php @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Tt.php b/bundled-libs/Text/Wiki/Render/Latex/Tt.php new file mode 100644 index 0000000..45073a7 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Tt.php @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Url.php b/bundled-libs/Text/Wiki/Render/Latex/Url.php new file mode 100644 index 0000000..47a9d37 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Url.php @@ -0,0 +1,35 @@ + false, + 'images' => true, + 'img_ext' => array('jpg', 'jpeg', 'gif', 'png') + ); + + /** + * + * 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); + + return " $text\\footnote\{$href}"; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Latex/Wikilink.php b/bundled-libs/Text/Wiki/Render/Latex/Wikilink.php new file mode 100644 index 0000000..3cf33a6 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Latex/Wikilink.php @@ -0,0 +1,60 @@ + array(), + 'view_url' => 'http://example.com/index.php?page=%s', + 'new_url' => 'http://example.com/new.php?page=%s', + 'new_text' => '?' + ); + + /** + * + * 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); + + // are we checking page existence? + $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; + } + + // convert *after* checking against page names so as not to mess + // up what the user typed and what we're checking. + $page = htmlspecialchars($page); + $anchor = htmlspecialchars($anchor); + $text = htmlspecialchars($text); + + $href = $this->getConf('view_url'); + + if (strpos($href, '%s') === false) { + // use the old form (page-at-end) + $href = $href . $page . $anchor; + } else { + // use the new form (sprintf format string) + $href = sprintf($href, $page . $anchor); + } + + // get the CSS class and generate output + $css = $this->formatConf(' class="%s"', 'css'); + return "$text\\footnote\{$href}"; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain.php b/bundled-libs/Text/Wiki/Render/Plain.php new file mode 100644 index 0000000..e1b02a8 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain.php @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Anchor.php b/bundled-libs/Text/Wiki/Render/Plain/Anchor.php new file mode 100644 index 0000000..f24f467 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Anchor.php @@ -0,0 +1,23 @@ + +* +* @author Paul M. Jones +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Render_Plain_Anchor extends Text_Wiki_Render { + + function token($options) + { + return $options['name']; + } +} + +?> diff --git a/bundled-libs/Text/Wiki/Render/Plain/Blockquote.php b/bundled-libs/Text/Wiki/Render/Plain/Blockquote.php new file mode 100644 index 0000000..08da94a --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Blockquote.php @@ -0,0 +1,39 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Bold.php b/bundled-libs/Text/Wiki/Render/Plain/Bold.php new file mode 100644 index 0000000..628fb51 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Bold.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Break.php b/bundled-libs/Text/Wiki/Render/Plain/Break.php new file mode 100644 index 0000000..5705bed --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Break.php @@ -0,0 +1,24 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Center.php b/bundled-libs/Text/Wiki/Render/Plain/Center.php new file mode 100644 index 0000000..7b36367 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Center.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Code.php b/bundled-libs/Text/Wiki/Render/Plain/Code.php new file mode 100644 index 0000000..5f523a3 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Code.php @@ -0,0 +1,24 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Colortext.php b/bundled-libs/Text/Wiki/Render/Plain/Colortext.php new file mode 100644 index 0000000..d577fe0 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Colortext.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Deflist.php b/bundled-libs/Text/Wiki/Render/Plain/Deflist.php new file mode 100644 index 0000000..d05593b --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Deflist.php @@ -0,0 +1,59 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Delimiter.php b/bundled-libs/Text/Wiki/Render/Plain/Delimiter.php new file mode 100644 index 0000000..0e436aa --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Delimiter.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Embed.php b/bundled-libs/Text/Wiki/Render/Plain/Embed.php new file mode 100644 index 0000000..3a4304f --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Embed.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Emphasis.php b/bundled-libs/Text/Wiki/Render/Plain/Emphasis.php new file mode 100644 index 0000000..8d32995 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Emphasis.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Freelink.php b/bundled-libs/Text/Wiki/Render/Plain/Freelink.php new file mode 100644 index 0000000..61de294 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Freelink.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Function.php b/bundled-libs/Text/Wiki/Render/Plain/Function.php new file mode 100644 index 0000000..c90644f --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Function.php @@ -0,0 +1,39 @@ + $val) { + $output .= "{$val['type']} {$val['descr']} {$val['default']} "; + } + + $output .= ') '; + + foreach ($throws as $key => $val) { + $output .= "{$val['type']} {$val['descr']} "; + } + + return $output; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Heading.php b/bundled-libs/Text/Wiki/Render/Plain/Heading.php new file mode 100644 index 0000000..306f2bf --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Heading.php @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Horiz.php b/bundled-libs/Text/Wiki/Render/Plain/Horiz.php new file mode 100644 index 0000000..9d93764 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Horiz.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Html.php b/bundled-libs/Text/Wiki/Render/Plain/Html.php new file mode 100644 index 0000000..e64e94b --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Html.php @@ -0,0 +1,24 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Image.php b/bundled-libs/Text/Wiki/Render/Plain/Image.php new file mode 100644 index 0000000..c5ddd6f --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Image.php @@ -0,0 +1,22 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Include.php b/bundled-libs/Text/Wiki/Render/Plain/Include.php new file mode 100644 index 0000000..445990a --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Include.php @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Interwiki.php b/bundled-libs/Text/Wiki/Render/Plain/Interwiki.php new file mode 100644 index 0000000..892f372 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Interwiki.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Italic.php b/bundled-libs/Text/Wiki/Render/Plain/Italic.php new file mode 100644 index 0000000..e2a596c --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Italic.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/List.php b/bundled-libs/Text/Wiki/Render/Plain/List.php new file mode 100644 index 0000000..9983689 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/List.php @@ -0,0 +1,68 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Newline.php b/bundled-libs/Text/Wiki/Render/Plain/Newline.php new file mode 100644 index 0000000..7c7903e --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Newline.php @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Paragraph.php b/bundled-libs/Text/Wiki/Render/Plain/Paragraph.php new file mode 100644 index 0000000..16e536f --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Paragraph.php @@ -0,0 +1,31 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Phplookup.php b/bundled-libs/Text/Wiki/Render/Plain/Phplookup.php new file mode 100644 index 0000000..a4268d1 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Phplookup.php @@ -0,0 +1,25 @@ + '_blank'); + + /** + * + * 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 trim($options['text']); + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Prefilter.php b/bundled-libs/Text/Wiki/Render/Plain/Prefilter.php new file mode 100644 index 0000000..417d193 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Prefilter.php @@ -0,0 +1,40 @@ + | +// +----------------------------------------------------------------------+ +// +// $Id: Prefilter.php,v 1.2 2004/09/25 19:05:14 pmjones Exp $ + + +/** +* +* 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. +* +* @author Paul M. Jones +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Render_Plain_Prefilter extends Text_Wiki_Render { + function token() + { + return ''; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Raw.php b/bundled-libs/Text/Wiki/Render/Plain/Raw.php new file mode 100644 index 0000000..e7fa8a8 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Raw.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Revise.php b/bundled-libs/Text/Wiki/Render/Plain/Revise.php new file mode 100644 index 0000000..32bbcad --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Revise.php @@ -0,0 +1,24 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Strong.php b/bundled-libs/Text/Wiki/Render/Plain/Strong.php new file mode 100644 index 0000000..7ff55a3 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Strong.php @@ -0,0 +1,24 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Superscript.php b/bundled-libs/Text/Wiki/Render/Plain/Superscript.php new file mode 100644 index 0000000..d239ee3 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Superscript.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Table.php b/bundled-libs/Text/Wiki/Render/Plain/Table.php new file mode 100644 index 0000000..4956cf2 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Table.php @@ -0,0 +1,57 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Tighten.php b/bundled-libs/Text/Wiki/Render/Plain/Tighten.php new file mode 100644 index 0000000..e2babf4 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Tighten.php @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Toc.php b/bundled-libs/Text/Wiki/Render/Plain/Toc.php new file mode 100644 index 0000000..34f3061 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Toc.php @@ -0,0 +1,39 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Tt.php b/bundled-libs/Text/Wiki/Render/Plain/Tt.php new file mode 100644 index 0000000..c59ccf4 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Tt.php @@ -0,0 +1,24 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Url.php b/bundled-libs/Text/Wiki/Render/Plain/Url.php new file mode 100644 index 0000000..4326c76 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Url.php @@ -0,0 +1,25 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Plain/Wikilink.php b/bundled-libs/Text/Wiki/Render/Plain/Wikilink.php new file mode 100644 index 0000000..8337dda --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Plain/Wikilink.php @@ -0,0 +1,24 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml.php b/bundled-libs/Text/Wiki/Render/Xhtml.php new file mode 100644 index 0000000..1b7de08 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml.php @@ -0,0 +1,33 @@ + HTML_ENTITIES); + + function pre() + { + // attempt to translate HTML entities in the source before continuing. + $type = $this->getConf('translate', null); + + // are we translating html? + if ($type !== false && $type !== null) { + + // yes! get the translation table. + $xlate = get_html_translation_table($type); + + // remove the delimiter character it doesn't get translated + unset($xlate[$this->wiki->delim]); + + // translate! + $this->wiki->source = strtr($this->wiki->source, $xlate); + } + + } + + function post() + { + return; + } + +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Anchor.php b/bundled-libs/Text/Wiki/Render/Xhtml/Anchor.php new file mode 100644 index 0000000..1cebf8e --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Anchor.php @@ -0,0 +1,37 @@ + +* +* @author Paul M. Jones +* +* @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 = ""; + return sprintf($format ,$name); + } + + if ($type == 'end') { + return ''; + } + } +} + +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Blockquote.php b/bundled-libs/Text/Wiki/Render/Xhtml/Blockquote.php new file mode 100644 index 0000000..e573b74 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Blockquote.php @@ -0,0 +1,46 @@ + 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'); + + // starting + if ($type == 'start') { + return "$pad"; + } + + // ending + if ($type == 'end') { + return $pad . "\n"; + } + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Bold.php b/bundled-libs/Text/Wiki/Render/Xhtml/Bold.php new file mode 100644 index 0000000..0530d38 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Bold.php @@ -0,0 +1,34 @@ + 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 ""; + } + + if ($options['type'] == 'end') { + return ''; + } + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Break.php b/bundled-libs/Text/Wiki/Render/Xhtml/Break.php new file mode 100644 index 0000000..28145aa --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Break.php @@ -0,0 +1,29 @@ + 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 "\n"; + } +} + +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Center.php b/bundled-libs/Text/Wiki/Render/Xhtml/Center.php new file mode 100644 index 0000000..4b0464d --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Center.php @@ -0,0 +1,29 @@ +'; + } + + if ($options['type'] == 'end') { + return ''; + } + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Code.php b/bundled-libs/Text/Wiki/Render/Xhtml/Code.php new file mode 100644 index 0000000..306c3e4 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Code.php @@ -0,0 +1,102 @@ + null, // class for
+        'css_code' => null, // class for generic 
+        'css_php'  => null, // class for PHP 
+        'css_html' => null // class for HTML 
+    );
+    
+    /**
+    * 
+    * 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');
+        
+        if ($type == 'php') {
+            
+            // PHP code example:
+            // add the PHP tags
+            $text = ""; // ... tags)
+            ob_start();
+            highlight_string($text);
+            $text = ob_get_contents();
+            ob_end_clean();
+            
+            // replace 
tags with simple newlines. + // replace non-breaking space with simple spaces. + // translate HTML and color to XHTML and style. + // courtesy of research by A. Kalin :-). + $map = array( + '
' => "\n", + ' ' => ' ', + ' '' => '
', + '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
") { + $text = substr($text, 0, -8) . "
"; + } + + // replace all tags with classed tags + if ($css_php) { + $text = str_replace('', "", $text); + } + + // done + $text = "$text
"; + + } elseif ($type == 'html' || $type == 'xhtml') { + + // HTML code example: + // add opening and closing tags, + // convert tabs to four spaces, + // convert entities. + $text = str_replace("\t", " ", $text); + $text = "\n$text\n"; + $text = htmlentities($text); + $text = "$text"; + + } else { + // generic code example: + // convert tabs to four spaces, + // convert entities. + $text = str_replace("\t", " ", $text); + $text = htmlentities($text); + $text = "$text"; + } + + return "\n$text\n\n"; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Colortext.php b/bundled-libs/Text/Wiki/Render/Xhtml/Colortext.php new file mode 100644 index 0000000..95882e4 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Colortext.php @@ -0,0 +1,56 @@ +colors)) { + $color = '#' . $color; + } + + if ($type == 'start') { + return ""; + } + + if ($options['type'] == 'end') { + return ''; + } + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Deflist.php b/bundled-libs/Text/Wiki/Render/Xhtml/Deflist.php new file mode 100644 index 0000000..c2f7251 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Deflist.php @@ -0,0 +1,64 @@ + 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 "\n"; + break; + + case 'list_end': + return "\n\n"; + break; + + case 'term_start': + $css = $this->formatConf(' class="%s"', 'css_dt'); + return $pad . ""; + break; + + case 'term_end': + return "\n"; + break; + + case 'narr_start': + $css = $this->formatConf(' class="%s"', 'css_dd'); + return $pad . $pad . ""; + break; + + case 'narr_end': + return "\n"; + break; + + default: + return ''; + + } + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Delimiter.php b/bundled-libs/Text/Wiki/Render/Xhtml/Delimiter.php new file mode 100644 index 0000000..2cbd685 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Delimiter.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Embed.php b/bundled-libs/Text/Wiki/Render/Xhtml/Embed.php new file mode 100644 index 0000000..1ff8472 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Embed.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Emphasis.php b/bundled-libs/Text/Wiki/Render/Xhtml/Emphasis.php new file mode 100644 index 0000000..b7756e5 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Emphasis.php @@ -0,0 +1,35 @@ + 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 ""; + } + + if ($options['type'] == 'end') { + return ''; + } + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Freelink.php b/bundled-libs/Text/Wiki/Render/Xhtml/Freelink.php new file mode 100644 index 0000000..0872a3c --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Freelink.php @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Function.php b/bundled-libs/Text/Wiki/Render/Xhtml/Function.php new file mode 100644 index 0000000..fff37c1 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Function.php @@ -0,0 +1,87 @@ + ', ', + + // the "main" format string + 'format_main' => '%access %return %name ( %params ) %throws', + + // the looped format string for required params + 'format_param' => '%type %descr', + + // the looped format string for params with default values + 'format_paramd' => '[%type %descr default %default]', + + // the looped format string for throws + 'format_throws' => 'throws %type %descr' + ); + + /** + * + * 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', htmlspecialchars($access), $output); + $output = str_replace('%return', htmlspecialchars($return), $output); + $output = str_replace('%name', htmlspecialchars($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', htmlspecialchars($val['type']), $tmp); + $tmp = str_replace('%descr', htmlspecialchars($val['descr']), $tmp); + $tmp = str_replace('%default', htmlspecialchars($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', htmlspecialchars($val['type']), $tmp); + $tmp = str_replace('%descr', htmlspecialchars($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 .= ''; + return "\n$output\n\n"; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Heading.php b/bundled-libs/Text/Wiki/Render/Xhtml/Heading.php new file mode 100644 index 0000000..c5e3074 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Heading.php @@ -0,0 +1,29 @@ + null, + 'css_h2' => null, + 'css_h3' => null, + 'css_h4' => null, + 'css_h5' => null, + 'css_h6' => null + ); + + function token($options) + { + // get nice variable names (id, type, level) + extract($options); + + if ($type == 'start') { + $css = $this->formatConf(' class="%s"', "css_h$level"); + return ""; + } + + if ($type == 'end') { + return "\n"; + } + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Horiz.php b/bundled-libs/Text/Wiki/Render/Xhtml/Horiz.php new file mode 100644 index 0000000..d397ab6 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Horiz.php @@ -0,0 +1,28 @@ + 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 "\n"; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Html.php b/bundled-libs/Text/Wiki/Render/Xhtml/Html.php new file mode 100644 index 0000000..404621b --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Html.php @@ -0,0 +1,24 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Image.php b/bundled-libs/Text/Wiki/Render/Xhtml/Image.php new file mode 100644 index 0000000..ebeda8b --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Image.php @@ -0,0 +1,151 @@ + '/', + '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 + $href = $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 + // we make up an align="center" value for the tag. + if (isset($options['attr']['align']) && + $options['attr']['align'] == 'center') { + + // unset so it won't show up as an attribute + unset($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'] .= ' '; + } + + // add a "center" style to the existing style. + $options['attr']['style'] .= + 'display: block; margin-left: auto; margin-right: auto;'; + } + + // 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; + } else { + // is a local file + $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 = '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 = htmlspecialchars($key); + $val = htmlspecialchars($val); + $output .= " $key=\"$val\""; + } + + // always add an "alt" attribute per Stephane Solliec + if (! $alt) { + $alt = htmlspecialchars(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 = htmlspecialchars($href); + $css = $this->formatConf(' class="%s"', 'css_link'); + $output = "$output"; + } + + return $output; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Include.php b/bundled-libs/Text/Wiki/Render/Xhtml/Include.php new file mode 100644 index 0000000..f04a7d4 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Include.php @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Interwiki.php b/bundled-libs/Text/Wiki/Render/Xhtml/Interwiki.php new file mode 100644 index 0000000..30b363e --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Interwiki.php @@ -0,0 +1,74 @@ + 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) + { + $site = $options['site']; + $page = $options['page']; + $text = $options['text']; + $css = $this->formatConf(' class="%s"', 'css'); + + 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 + $text = htmlspecialchars($text); + $output = " \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Italic.php b/bundled-libs/Text/Wiki/Render/Xhtml/Italic.php new file mode 100644 index 0000000..6ae3a9a --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Italic.php @@ -0,0 +1,34 @@ + 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 ""; + } + + if ($options['type'] == 'end') { + return ''; + } + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/List.php b/bundled-libs/Text/Wiki/Render/Xhtml/List.php new file mode 100644 index 0000000..b6dabba --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/List.php @@ -0,0 +1,142 @@ + 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 = ""; + + // 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 = "\n$pad"; + + // 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': + + // build the base HTML + $css = $this->formatConf(' class="%s"', 'css_ol'); + $html = ""; + + // 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 = "\n$pad"; + + // 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"; + + // 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 = "$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; + } + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Newline.php b/bundled-libs/Text/Wiki/Render/Xhtml/Newline.php new file mode 100644 index 0000000..441dfb2 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Newline.php @@ -0,0 +1,12 @@ +\n"; + } +} + +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Paragraph.php b/bundled-libs/Text/Wiki/Render/Xhtml/Paragraph.php new file mode 100644 index 0000000..4d992c0 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Paragraph.php @@ -0,0 +1,36 @@ + 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 ""; + } + + if ($type == 'end') { + return "

\n\n"; + } + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Phplookup.php b/bundled-libs/Text/Wiki/Render/Xhtml/Phplookup.php new file mode 100644 index 0000000..91b2598 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Phplookup.php @@ -0,0 +1,59 @@ + '_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 = "getConf('target', ''); + if ($target) { + // use a "popup" window. this is XHTML compliant, suggested by + // Aaron Kalin. uses the $target as the new window name. + $target = htmlspecialchars($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; + } + + $q = htmlspecialchars($q); + $text = htmlspecialchars($text); + + // finish and return + $output .= " href=\"http://php.net/$q\">$text"; + return $output; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Prefilter.php b/bundled-libs/Text/Wiki/Render/Xhtml/Prefilter.php new file mode 100644 index 0000000..6308db6 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Prefilter.php @@ -0,0 +1,40 @@ + | +// +----------------------------------------------------------------------+ +// +// $Id: Prefilter.php,v 1.5 2004/09/25 19:05:14 pmjones Exp $ + + +/** +* +* 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. +* +* @author Paul M. Jones +* +* @package Text_Wiki +* +*/ + +class Text_Wiki_Render_Xhtml_Prefilter extends Text_Wiki_Render { + function token() + { + return ''; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Raw.php b/bundled-libs/Text/Wiki/Render/Xhtml/Raw.php new file mode 100644 index 0000000..a986aa0 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Raw.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Revise.php b/bundled-libs/Text/Wiki/Render/Xhtml/Revise.php new file mode 100644 index 0000000..7cb5e95 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Revise.php @@ -0,0 +1,45 @@ + 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 ""; + } + + if ($options['type'] == 'del_end') { + return ""; + } + + if ($options['type'] == 'ins_start') { + $css = $this->formatConf(' class="%s"', 'css_ins'); + return ""; + } + + if ($options['type'] == 'ins_end') { + return ""; + } + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Strong.php b/bundled-libs/Text/Wiki/Render/Xhtml/Strong.php new file mode 100644 index 0000000..6b231bd --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Strong.php @@ -0,0 +1,35 @@ + 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 ""; + } + + if ($options['type'] == 'end') { + return ''; + } + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Superscript.php b/bundled-libs/Text/Wiki/Render/Xhtml/Superscript.php new file mode 100644 index 0000000..f1226ad --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Superscript.php @@ -0,0 +1,34 @@ + 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 ""; + } + + if ($options['type'] == 'end') { + return ''; + } + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Table.php b/bundled-libs/Text/Wiki/Render/Xhtml/Table.php new file mode 100644 index 0000000..231be57 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Table.php @@ -0,0 +1,98 @@ + 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) + extract($options); + + $pad = ' '; + + switch ($type) { + + case 'table_start': + $css = $this->formatConf(' class="%s"', 'css_table'); + return "\n\n\n"; + break; + + case 'table_end': + return "\n\n"; + break; + + case 'row_start': + $css = $this->formatConf(' class="%s"', 'css_tr'); + return "$pad\n"; + break; + + case 'row_end': + return "$pad\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 .= "formatConf(' class="%s"', 'css_td'); + $html .= " 1) { + $html .= " colspan=\"$span\""; + } + + // add alignment + if ($attr != 'header' && $attr != '') { + $html .= " style=\"text-align: $attr;\""; + } + + // done! + $html .= '>'; + return $html; + break; + + case 'cell_end': + if ($attr == 'header') { + return "\n"; + } else { + return "\n"; + } + break; + + default: + return ''; + + } + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Tighten.php b/bundled-libs/Text/Wiki/Render/Xhtml/Tighten.php new file mode 100644 index 0000000..fdc1738 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Tighten.php @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Toc.php b/bundled-libs/Text/Wiki/Render/Xhtml/Toc.php new file mode 100644 index 0000000..e5b5f4b --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Toc.php @@ -0,0 +1,80 @@ + null, + 'css_item' => null, + 'title' => 'Table of Contents', + 'div_id' => 'toc' + ); + + 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': + + $html = 'getConf('css_list'); + if ($css) { + $html .= " class=\"$css\""; + } + + $div_id = $this->getConf('div_id'); + if ($div_id) { + $html .= " id=\"$div_id\""; + } + + $html .= '>'; + $html .= $this->getConf('title'); + return $html; + break; + + case 'list_end': + return "\n"; + break; + + case 'item_start': + $html = 'getConf('css_item'); + if ($css) { + $html .= " class=\"$css\""; + } + + $pad = ($level - $this->min); + $html .= " style=\"margin-left: {$pad}em;\">"; + + $html .= ""; + return $html; + break; + + case 'item_end': + return "\n"; + break; + } + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Tt.php b/bundled-libs/Text/Wiki/Render/Xhtml/Tt.php new file mode 100644 index 0000000..e40ea97 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Tt.php @@ -0,0 +1,35 @@ + 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 ""; + } + + if ($options['type'] == 'end') { + return ''; + } + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Url.php b/bundled-libs/Text/Wiki/Render/Xhtml/Url.php new file mode 100644 index 0000000..2799ae6 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Url.php @@ -0,0 +1,91 @@ + '_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 = htmlspecialchars($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 = htmlspecialchars($text); + } + + // generate an image tag + $css = $this->formatConf(' class="%s"', 'css_img'); + $output = ""; + + } else { + + // allow for alternative targets on non-anchor HREFs + if ($href{0} == '#') { + $target = ''; + } else { + $target = $this->getConf('target'); + } + + // generate a regular link (not an image) + $text = htmlspecialchars($text); + $css = $this->formatConf(' class="%s"', "css_$type"); + $output = "'; + } + } + + return $output; + } +} +?> \ No newline at end of file diff --git a/bundled-libs/Text/Wiki/Render/Xhtml/Wikilink.php b/bundled-libs/Text/Wiki/Render/Xhtml/Wikilink.php new file mode 100644 index 0000000..e5815c8 --- /dev/null +++ b/bundled-libs/Text/Wiki/Render/Xhtml/Wikilink.php @@ -0,0 +1,137 @@ + 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; + } + } + + // convert *after* checking against page names so as not to mess + // up what the user typed and what we're checking. + $page = htmlspecialchars($page); + $anchor = htmlspecialchars($anchor); + $text = htmlspecialchars($text); + + // 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 . $page . $anchor; + } else { + // use the new form (sprintf format string) + $href = sprintf($href, $page . $anchor); + } + + // get the CSS class and generate output + $css = $this->formatConf(' class="%s"', 'css'); + $output = "$text"; + + } 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 + $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 . $page; + } else { + // use the new form + $href = sprintf($href, $page); + } + } + + // get the appropriate CSS class and new-link text + $css = $this->formatConf(' class="%s"', '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 + $output = "$page"; + } elseif ($pos == 'before') { + // use the new_text BEFORE the page name + $output = "$new$text"; + } else { + // default, use the new_text link AFTER the page name + $output = "$text$new"; + } + } + return $output; + } +} +?> \ No newline at end of file -- 2.39.5