From f9bc1699c0549d90177369e146698a12bff1c077 Mon Sep 17 00:00:00 2001 From: PHP_CodeSniffer formatter Date: Thu, 2 Jul 2020 02:51:07 +0100 Subject: [PATCH] Codesniffer autoformat --- Text/Wiki.php | 132 +++--- Text/Wiki/Parse.php | 10 +- Text/Wiki/Parse/Default/Anchor.php | 16 +- Text/Wiki/Parse/Default/Bibcite.php | 8 +- Text/Wiki/Parse/Default/Bibitem.php | 21 +- Text/Wiki/Parse/Default/Bibliography.php | 31 +- Text/Wiki/Parse/Default/Blockquote.php | 12 +- Text/Wiki/Parse/Default/Bold.php | 7 +- Text/Wiki/Parse/Default/Break.php | 3 +- Text/Wiki/Parse/Default/Button.php | 14 +- Text/Wiki/Parse/Default/Center.php | 6 +- Text/Wiki/Parse/Default/Clearfloat.php | 12 +- Text/Wiki/Parse/Default/Code.php | 6 +- Text/Wiki/Parse/Default/Collapsible.php | 16 +- Text/Wiki/Parse/Default/Colortext.php | 12 +- Text/Wiki/Parse/Default/Comment.php | 9 +- Text/Wiki/Parse/Default/Concatlines.php | 8 +- Text/Wiki/Parse/Default/Date.php | 27 +- Text/Wiki/Parse/Default/Deflist.php | 7 +- Text/Wiki/Parse/Default/Delimiter.php | 3 +- Text/Wiki/Parse/Default/Div.php | 16 +- Text/Wiki/Parse/Default/Divalign.php | 15 +- Text/Wiki/Parse/Default/Divprefilter.php | 12 +- Text/Wiki/Parse/Default/Email.php | 18 +- Text/Wiki/Parse/Default/Embed.php | 16 +- Text/Wiki/Parse/Default/Emphasis.php | 15 +- Text/Wiki/Parse/Default/Equationreference.php | 9 +- Text/Wiki/Parse/Default/File.php | 25 +- Text/Wiki/Parse/Default/Footnote.php | 27 +- Text/Wiki/Parse/Default/Footnoteblock.php | 43 +- Text/Wiki/Parse/Default/Footnoteitem.php | 3 +- Text/Wiki/Parse/Default/Form.php | 12 +- Text/Wiki/Parse/Default/Freelink.php | 48 +- Text/Wiki/Parse/Default/Function.php | 116 +++-- Text/Wiki/Parse/Default/Gallery.php | 17 +- Text/Wiki/Parse/Default/Heading.php | 11 +- Text/Wiki/Parse/Default/Horiz.php | 3 +- Text/Wiki/Parse/Default/Html.php | 15 +- Text/Wiki/Parse/Default/Iframe.php | 70 +-- Text/Wiki/Parse/Default/Iftags.php | 116 ++--- Text/Wiki/Parse/Default/Image.php | 17 +- Text/Wiki/Parse/Default/Include.php | 140 +++--- Text/Wiki/Parse/Default/Interwiki.php | 23 +- Text/Wiki/Parse/Default/Italic.php | 13 +- Text/Wiki/Parse/Default/List.php | 28 +- Text/Wiki/Parse/Default/Math.php | 44 +- Text/Wiki/Parse/Default/Mathinline.php | 11 +- Text/Wiki/Parse/Default/Module.php | 26 +- Text/Wiki/Parse/Default/Module654.php | 6 +- Text/Wiki/Parse/Default/Moduledelimiter.php | 3 +- Text/Wiki/Parse/Default/Modulepre.php | 15 +- Text/Wiki/Parse/Default/Newline.php | 5 +- Text/Wiki/Parse/Default/Note.php | 15 +- Text/Wiki/Parse/Default/Paragraph.php | 11 +- Text/Wiki/Parse/Default/Phplookup.php | 6 +- Text/Wiki/Parse/Default/Postfilter.php | 33 +- Text/Wiki/Parse/Default/Prefilter.php | 32 +- Text/Wiki/Parse/Default/Raw.php | 12 +- Text/Wiki/Parse/Default/Rawold.php | 6 +- Text/Wiki/Parse/Default/Revise.php | 23 +- Text/Wiki/Parse/Default/Separator.php | 11 +- Text/Wiki/Parse/Default/Size.php | 61 +-- Text/Wiki/Parse/Default/Smiley.php | 9 +- Text/Wiki/Parse/Default/Social.php | 23 +- Text/Wiki/Parse/Default/Span.php | 26 +- Text/Wiki/Parse/Default/Strikethrough.php | 12 +- Text/Wiki/Parse/Default/Strong.php | 12 +- Text/Wiki/Parse/Default/Subscript.php | 12 +- Text/Wiki/Parse/Default/Superscript.php | 15 +- Text/Wiki/Parse/Default/Table.php | 18 +- Text/Wiki/Parse/Default/Tableadv.php | 72 +-- Text/Wiki/Parse/Default/Tabview.php | 49 +- Text/Wiki/Parse/Default/Tighten.php | 10 +- Text/Wiki/Parse/Default/Toc.php | 19 +- Text/Wiki/Parse/Default/Tt.php | 15 +- Text/Wiki/Parse/Default/Typography.php | 10 +- Text/Wiki/Parse/Default/Underline.php | 12 +- Text/Wiki/Parse/Default/Url.php | 60 +-- Text/Wiki/Parse/Default/User.php | 15 +- Text/Wiki/Parse/Default/Wikilink.php | 39 +- Text/Wiki/Render.php | 12 +- Text/Wiki/Render/Xhtml.php | 79 ++-- Text/Wiki/Render/Xhtml/Anchor.php | 7 +- Text/Wiki/Render/Xhtml/Bibcite.php | 6 +- Text/Wiki/Render/Xhtml/Bibitem.php | 7 +- Text/Wiki/Render/Xhtml/Bibliography.php | 7 +- Text/Wiki/Render/Xhtml/Blockquote.php | 3 +- Text/Wiki/Render/Xhtml/Bold.php | 3 +- Text/Wiki/Render/Xhtml/Box.php | 3 +- Text/Wiki/Render/Xhtml/Break.php | 3 +- Text/Wiki/Render/Xhtml/Button.php | 165 +++---- Text/Wiki/Render/Xhtml/Center.php | 3 +- Text/Wiki/Render/Xhtml/Clearfloat.php | 8 +- Text/Wiki/Render/Xhtml/Code.php | 15 +- Text/Wiki/Render/Xhtml/Collapsible.php | 82 ++-- Text/Wiki/Render/Xhtml/Colortext.php | 3 +- Text/Wiki/Render/Xhtml/Comment.php | 6 +- Text/Wiki/Render/Xhtml/Concatlines.php | 3 +- Text/Wiki/Render/Xhtml/Date.php | 18 +- Text/Wiki/Render/Xhtml/Deflist.php | 39 +- Text/Wiki/Render/Xhtml/Delimiter.php | 6 +- Text/Wiki/Render/Xhtml/Div.php | 7 +- Text/Wiki/Render/Xhtml/Divalign.php | 7 +- Text/Wiki/Render/Xhtml/Divprefilter.php | 6 +- Text/Wiki/Render/Xhtml/Email.php | 6 +- Text/Wiki/Render/Xhtml/Embed.php | 11 +- Text/Wiki/Render/Xhtml/Emphasis.php | 3 +- Text/Wiki/Render/Xhtml/Equationreference.php | 6 +- Text/Wiki/Render/Xhtml/File.php | 25 +- Text/Wiki/Render/Xhtml/Font.php | 3 +- Text/Wiki/Render/Xhtml/Footnote.php | 6 +- Text/Wiki/Render/Xhtml/Footnoteblock.php | 30 +- Text/Wiki/Render/Xhtml/Footnoteitem.php | 7 +- Text/Wiki/Render/Xhtml/Form.php | 3 +- Text/Wiki/Render/Xhtml/Freelink.php | 3 +- Text/Wiki/Render/Xhtml/Function.php | 6 +- Text/Wiki/Render/Xhtml/Gallery.php | 439 +++++++++--------- Text/Wiki/Render/Xhtml/Heading.php | 43 +- Text/Wiki/Render/Xhtml/Horiz.php | 3 +- Text/Wiki/Render/Xhtml/Html.php | 3 +- Text/Wiki/Render/Xhtml/Iframe.php | 16 +- Text/Wiki/Render/Xhtml/Iftags.php | 8 +- Text/Wiki/Render/Xhtml/Image.php | 226 +++++---- Text/Wiki/Render/Xhtml/Include.php | 9 +- Text/Wiki/Render/Xhtml/Interwiki.php | 3 +- Text/Wiki/Render/Xhtml/Italic.php | 3 +- Text/Wiki/Render/Xhtml/List.php | 174 ++++--- Text/Wiki/Render/Xhtml/Math.php | 6 +- Text/Wiki/Render/Xhtml/Mathinline.php | 7 +- Text/Wiki/Render/Xhtml/Module.php | 8 +- Text/Wiki/Render/Xhtml/Module654.php | 3 +- Text/Wiki/Render/Xhtml/Moduledelimiter.php | 3 +- Text/Wiki/Render/Xhtml/Modulepre.php | 7 +- Text/Wiki/Render/Xhtml/Newline.php | 3 +- Text/Wiki/Render/Xhtml/Note.php | 7 +- Text/Wiki/Render/Xhtml/Paragraph.php | 3 +- Text/Wiki/Render/Xhtml/Phplookup.php | 3 +- Text/Wiki/Render/Xhtml/Plugin.php | 3 +- Text/Wiki/Render/Xhtml/Postfilter.php | 3 +- Text/Wiki/Render/Xhtml/Prefilter.php | 3 +- Text/Wiki/Render/Xhtml/Preformatted.php | 3 +- Text/Wiki/Render/Xhtml/Raw.php | 3 +- Text/Wiki/Render/Xhtml/Rawold.php | 3 +- Text/Wiki/Render/Xhtml/Revise.php | 3 +- Text/Wiki/Render/Xhtml/Separator.php | 3 +- Text/Wiki/Render/Xhtml/Size.php | 7 +- Text/Wiki/Render/Xhtml/Smiley.php | 3 +- Text/Wiki/Render/Xhtml/Social.php | 64 +-- Text/Wiki/Render/Xhtml/Span.php | 7 +- Text/Wiki/Render/Xhtml/Specialchar.php | 3 +- Text/Wiki/Render/Xhtml/Strikethrough.php | 6 +- Text/Wiki/Render/Xhtml/Strong.php | 3 +- Text/Wiki/Render/Xhtml/Subscript.php | 3 +- Text/Wiki/Render/Xhtml/Superscript.php | 3 +- Text/Wiki/Render/Xhtml/Table.php | 120 +++-- Text/Wiki/Render/Xhtml/Tableadv.php | 7 +- Text/Wiki/Render/Xhtml/Tabview.php | 8 +- Text/Wiki/Render/Xhtml/Tighten.php | 3 +- Text/Wiki/Render/Xhtml/Titlebar.php | 3 +- Text/Wiki/Render/Xhtml/Toc.php | 105 +++-- Text/Wiki/Render/Xhtml/Tt.php | 3 +- Text/Wiki/Render/Xhtml/Typography.php | 6 +- Text/Wiki/Render/Xhtml/Underline.php | 3 +- Text/Wiki/Render/Xhtml/Url.php | 34 +- Text/Wiki/Render/Xhtml/User.php | 7 +- Text/Wiki/Render/Xhtml/Wikilink.php | 59 ++- 166 files changed, 2109 insertions(+), 1892 deletions(-) diff --git a/Text/Wiki.php b/Text/Wiki.php index b747860..4606e3c 100644 --- a/Text/Wiki.php +++ b/Text/Wiki.php @@ -28,7 +28,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki { +class Text_Wiki +{ /** * @@ -41,7 +42,7 @@ class Text_Wiki { */ public $rules = array( - 'Include', + 'Include', 'Prefilter', 'Delimiter', // 'Moduledelimiter', @@ -53,11 +54,11 @@ class Text_Wiki { 'Module', 'Module654', - 'Iftags', + 'Iftags', 'Comment', 'Iframe', - 'Date', + 'Date', 'Math', 'Concatlines', @@ -335,17 +336,17 @@ class Text_Wiki { 'render' => array() ); - /** - * Storage for temporary variables. - */ - public $store = array(); + /** + * Storage for temporary variables. + */ + public $store = array(); - public $vars = array(); + public $vars = array(); - /** - * Stores format while processing the source. - */ - public $currentFormat; + /** + * Stores format while processing the source. + */ + public $currentFormat; /** * @@ -384,7 +385,6 @@ function Text_Wiki($rules = null) 'render', $this->fixPath(dirname(__FILE__)) . 'Wiki/Render/' ); - } /** @@ -545,7 +545,6 @@ function getRenderConf($format, $rule, $key = null) // no return null; } - } /** @@ -685,7 +684,6 @@ function insertRule($name, $tgt = null) } return true; - } /** @@ -806,7 +804,7 @@ function disableRule($name) function transform($text, $format = 'Xhtml') { - $this->currentFormat = $format; + $this->currentFormat = $format; $this->parse($text); $out = $this->render($format); $this->currentFormat = null; @@ -840,7 +838,6 @@ function parse($text) foreach ($this->rules as $name) { // do not parse the rules listed in $disable if (! in_array($name, $this->disable)) { - // load the parsing object $this->loadParseObj($name); @@ -850,7 +847,6 @@ function parse($text) $this->parseObj[$name]->parse(); } } - } } @@ -886,7 +882,7 @@ function render($format = 'Xhtml') // load the format object, or crap out if we can't find it $result = $this->loadFormatObj($format); if ($this->isError($result)) { - return $result; + return $result; } // pre-rendering activity @@ -902,16 +898,13 @@ function render($format = 'Xhtml') // pass through the parsed source text character by character $k = strlen($this->source); for ($i = 0; $i < $k; $i++) { - // the current character $char = $this->source[$i]; // are alredy in a delimited section? if ($in_delim) { - // yes; are we ending the section? if ($char == $this->delim) { - // yes, get the replacement text for the delimited // token number and unset the flag. $key = (int)$key; @@ -919,16 +912,11 @@ function render($format = 'Xhtml') $opts = $this->tokens[$key][1]; $output .= $this->renderObj[$rule]->token($opts); $in_delim = false; - } else { - // no, add to the dlimited token key number $key .= $char; - } - } else { - // not currently in a delimited section. // are we starting into a delimited section? if ($char == $this->delim) { @@ -948,18 +936,19 @@ function render($format = 'Xhtml') $output .= $this->formatObj[$format]->post(); } - // this is a nasty hack... should be put somewhere else, e.g. Postfilter? + // this is a nasty hack... should be put somewhere else, e.g. Postfilter? - // fix TOC tags within entries - $d = utf8_encode("\xFC"); - $output = preg_replace_callback("/$d$d(.*?)$d$d/s", array($this, 'strip'), $output); + // fix TOC tags within entries + $d = utf8_encode("\xFC"); + $output = preg_replace_callback("/$d$d(.*?)$d$d/s", array($this, 'strip'), $output); // return the rendered source text. return $output; } - public function strip($matches){ - return strip_tags($matches[1]); + public function strip($matches) + { + return strip_tags($matches[1]); } /** @@ -1107,20 +1096,19 @@ function loadParseObj($rule) $loc = $this->findFile('parse', $file); - if ($loc) { - // found the class - include_once $loc; - } else { - // can't find the class - $this->parseObj[$rule] = null; - // can't find the class - return $this->error( - "Parse rule '$rule' not found" - ); - } + if ($loc) { + // found the class + include_once $loc; + } else { + // can't find the class + $this->parseObj[$rule] = null; + // can't find the class + return $this->error( + "Parse rule '$rule' not found" + ); + } $this->parseObj[$rule] = new $class($this); - } /** @@ -1142,15 +1130,15 @@ function loadRenderObj($format, $rule) // load the class $loc = $this->findFile('render', $file); - if ($loc) { - // found the class - include_once $loc; - } else { - // can't find the class - return $this->error( - "Render rule '$rule' in format '$format' not found" - ); - } + if ($loc) { + // found the class + include_once $loc; + } else { + // can't find the class + return $this->error( + "Render rule '$rule' in format '$format' not found" + ); + } $this->renderObj[$rule] = new $class($this); } @@ -1172,15 +1160,15 @@ function loadFormatObj($format) $class = "Text_Wiki_Render_$format"; $loc = $this->findFile('render', $file); - if ($loc) { - // found the class - include_once $loc; - } else { - // can't find the class - return $this->error( - "Rendering format class '$class' not found" - ); - } + if ($loc) { + // found the class + include_once $loc; + } else { + // can't find the class + return $this->error( + "Rendering format class '$class' not found" + ); + } $this->formatObj[$format] = new $class($this); } @@ -1281,7 +1269,7 @@ function fixPath($path) $len = strlen($this->_dirSep); if (! empty($path) && - substr($path, -1 * $len, $len) != $this->_dirSep) { + substr($path, -1 * $len, $len) != $this->_dirSep) { return $path . $this->_dirSep; } else { return $path; @@ -1302,12 +1290,12 @@ function fixPath($path) function &error($message) { - throw new ProcessException($message); - // FIX? - if (! class_exists('PEAR_Error')) { - include_once 'PEAR.php'; - } - return PEAR::throwError($message); + throw new ProcessException($message); + // FIX? + if (! class_exists('PEAR_Error')) { + include_once 'PEAR.php'; + } + return PEAR::throwError($message); } /** @@ -1324,6 +1312,6 @@ function &error($message) function isError(&$obj) { - return is_a($obj, 'PEAR_Error'); + return is_a($obj, 'PEAR_Error'); } } diff --git a/Text/Wiki/Parse.php b/Text/Wiki/Parse.php index b4b24af..5ca1a19 100644 --- a/Text/Wiki/Parse.php +++ b/Text/Wiki/Parse.php @@ -37,7 +37,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Parse { +class Text_Wiki_Parse +{ /** * @@ -117,12 +118,10 @@ function Text_Wiki_Parse(&$obj) // 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] ); - } } @@ -142,7 +141,7 @@ function Text_Wiki_Parse(&$obj) function parse() { - if($this->regex){ + if ($this->regex) { $this->wiki->source = preg_replace_callback( $this->regex, array(&$this, 'process'), @@ -232,7 +231,6 @@ function getAttrs($text) // loop through the sections foreach ($tmp as $i => $val) { - // first element is always the first key if ($i == 0) { $key = trim($val); @@ -245,10 +243,8 @@ function getAttrs($text) $pos = strrpos($val, '"'); $attrs[$key] = stripslashes(substr($val, 0, $pos)); $key = trim(substr($val, $pos+1)); - } return $attrs; - } } diff --git a/Text/Wiki/Parse/Default/Anchor.php b/Text/Wiki/Parse/Default/Anchor.php index 0896a0d..e064500 100644 --- a/Text/Wiki/Parse/Default/Anchor.php +++ b/Text/Wiki/Parse/Default/Anchor.php @@ -33,7 +33,8 @@ * */ -class Text_Wiki_Parse_Anchor extends Text_Wiki_Parse { +class Text_Wiki_Parse_Anchor extends Text_Wiki_Parse +{ /** * @@ -45,7 +46,7 @@ class Text_Wiki_Parse_Anchor extends Text_Wiki_Parse { * @var string * */ - public $regex = '/' . + public $regex = '/' . '(\[\[\#\s)' . # Two brackets, then hash '([-_A-Za-z0-9.%]+?)' . # Contents of anchor '(\]\])' . # Closing brackets @@ -65,13 +66,16 @@ class Text_Wiki_Parse_Anchor extends Text_Wiki_Parse { * the source text. * */ - function process(&$matches) { + function process(&$matches) + { $name = $matches[2]; - $start = $this->wiki->addToken($this->rule, - array( - 'name' => $name)); + $start = $this->wiki->addToken( + $this->rule, + array( + 'name' => $name) + ); // done, place the script output directly in the source return $start; diff --git a/Text/Wiki/Parse/Default/Bibcite.php b/Text/Wiki/Parse/Default/Bibcite.php index a5ade76..fe4d7b6 100644 --- a/Text/Wiki/Parse/Default/Bibcite.php +++ b/Text/Wiki/Parse/Default/Bibcite.php @@ -30,7 +30,8 @@ * @author Michal Frackowiak * */ -class Text_Wiki_Parse_Bibcite extends Text_Wiki_Parse { +class Text_Wiki_Parse_Bibcite extends Text_Wiki_Parse +{ /** * @@ -43,14 +44,15 @@ class Text_Wiki_Parse_Bibcite extends Text_Wiki_Parse { * */ - public $regex = '/' . + public $regex = '/' . '\(\(' . # Opening parens 'bibcite\s' . # Module name and whitespace '([a-z0-9]+)' . # Alphanumeric citation '\)\)' . # Closing parens '/i'; - function process(&$matches) { + function process(&$matches) + { $label = $matches[1]; $options = array( 'label' => $label); diff --git a/Text/Wiki/Parse/Default/Bibitem.php b/Text/Wiki/Parse/Default/Bibitem.php index 2cdf755..61ab019 100644 --- a/Text/Wiki/Parse/Default/Bibitem.php +++ b/Text/Wiki/Parse/Default/Bibitem.php @@ -28,7 +28,8 @@ * */ -class Text_Wiki_Parse_Bibitem extends Text_Wiki_Parse { +class Text_Wiki_Parse_Bibitem extends Text_Wiki_Parse +{ /** * @@ -42,21 +43,25 @@ class Text_Wiki_Parse_Bibitem extends Text_Wiki_Parse { */ # ??? where is the string??? - function process(&$matches) { + function process(&$matches) + { $label = $matches[1]; $content = $matches[2]; $content = trim(str_replace("\n", " ", $content)); $this->wiki->vars['bibitems'][$label] = $content; $id = count($this->wiki->vars['bibitemIds']) + 1; $this->wiki->vars['bibitemIds'][$label] = $id; - return $this->wiki->addToken($this->rule, - array( + return $this->wiki->addToken( + $this->rule, + array( 'label' => $label, 'id' => $id, - 'type' => 'start')) . + 'type' => 'start') + ) . $content . $this->wiki->addToken( - $this->rule, - array( - 'type' => 'end')); + $this->rule, + array( + 'type' => 'end') + ); } } diff --git a/Text/Wiki/Parse/Default/Bibliography.php b/Text/Wiki/Parse/Default/Bibliography.php index 42c53a3..8ba281b 100644 --- a/Text/Wiki/Parse/Default/Bibliography.php +++ b/Text/Wiki/Parse/Default/Bibliography.php @@ -28,25 +28,32 @@ * */ -class Text_Wiki_Parse_Bibliography extends Text_Wiki_Parse { +class Text_Wiki_Parse_Bibliography extends Text_Wiki_Parse +{ public $regex = null; - function parse() { - $regex = '/' . + function parse() + { + $regex = '/' . '^' . # Start of line '\[\[bibliography' . # Tag name '(\s+[^\]]+)?' . # Parameters - '\]\]' . + '\]\]' . '(.*?)' . # Contents '\[\[\/bibliography\]\]' . # End tag '[\s]*$' . # Allow whitespace until end of the line '/sm'; - $this->wiki->source = preg_replace_callback($regex, - array(&$this, 'process'), $this->wiki->source, 1); + $this->wiki->source = preg_replace_callback( + $regex, + array(&$this, 'process'), + $this->wiki->source, + 1 + ); } - function process(&$matches) { + function process(&$matches) + { $inner = $matches[2]; $args = $this->getAttrs($matches[1]); $title = $args['title']; @@ -58,7 +65,7 @@ function process(&$matches) { $bi = $this->wiki->parseObj['Bibitem']; $inside = preg_replace_callback( - '/' . + '/' . '^' . # Start of line ':\s?' . # Colon, then optional whitespace '([a-z0-9]+)' . # Lowercase alphanumeric bib item name @@ -67,15 +74,17 @@ function process(&$matches) { '(.*)' . # Rest of the line is the item definition '$' . # End of line '/mix', - array(&$bi, 'process'), $inner); + array(&$bi, 'process'), + $inner + ); return "\n" . $this->wiki->addToken($this->rule, array( 'type' => 'start', 'title' => $title)) . str_replace("\n", " ", $inside) . $this->wiki->addToken($this->rule, array( 'type' => 'end')) . "\n"; } - function insertBibitem($matches) { + function insertBibitem($matches) + { return $matches[2]; } - } diff --git a/Text/Wiki/Parse/Default/Blockquote.php b/Text/Wiki/Parse/Default/Blockquote.php index 04892ab..8955e8c 100644 --- a/Text/Wiki/Parse/Default/Blockquote.php +++ b/Text/Wiki/Parse/Default/Blockquote.php @@ -37,7 +37,8 @@ * */ -class Text_Wiki_Parse_Blockquote extends Text_Wiki_Parse { +class Text_Wiki_Parse_Blockquote extends Text_Wiki_Parse +{ /** * @@ -51,7 +52,7 @@ class Text_Wiki_Parse_Blockquote extends Text_Wiki_Parse { * */ - public $regex = '/' . + public $regex = '/' . '\n' . # Start at a newline '((\>).*?\n)' . # Match a >, then anything up until a newline '(?!(\>))' . # Assert that the newline is not followed by a > @@ -93,8 +94,8 @@ function process(&$matches) // create an array called $list that contains a new set of // matches for the various list-item elements. preg_match_all( - '/' . - '^' . + '/' . + '^' . '(\>+?)' . # At least one > '\s' . # Require exactly one whitespace '(.*?\n)' . # Include anything else up until a newline @@ -110,7 +111,6 @@ function process(&$matches) // 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 @@ -123,7 +123,6 @@ function process(&$matches) // 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 @@ -146,7 +145,6 @@ function process(&$matches) // 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 diff --git a/Text/Wiki/Parse/Default/Bold.php b/Text/Wiki/Parse/Default/Bold.php index 06a6838..9d189f0 100644 --- a/Text/Wiki/Parse/Default/Bold.php +++ b/Text/Wiki/Parse/Default/Bold.php @@ -36,7 +36,8 @@ * */ -class Text_Wiki_Parse_Bold extends Text_Wiki_Parse { +class Text_Wiki_Parse_Bold extends Text_Wiki_Parse +{ /** * @@ -51,9 +52,9 @@ class Text_Wiki_Parse_Bold extends Text_Wiki_Parse { * */ - public $regex = "/" . + public $regex = "/" . "'''" . # Opening triple single-quotes - "(" . + "(" . "()" . # Nothing (captured, for some reason) "|[^'].*?)" . # OR any text that doesn't start with a single quote "'''" . # Closing triple single-quotes diff --git a/Text/Wiki/Parse/Default/Break.php b/Text/Wiki/Parse/Default/Break.php index 49ab5fa..2bcc0e1 100644 --- a/Text/Wiki/Parse/Default/Break.php +++ b/Text/Wiki/Parse/Default/Break.php @@ -33,7 +33,8 @@ * */ -class Text_Wiki_Parse_Break extends Text_Wiki_Parse { +class Text_Wiki_Parse_Break extends Text_Wiki_Parse +{ /** * diff --git a/Text/Wiki/Parse/Default/Button.php b/Text/Wiki/Parse/Default/Button.php index c9e1b71..33984ec 100644 --- a/Text/Wiki/Parse/Default/Button.php +++ b/Text/Wiki/Parse/Default/Button.php @@ -26,9 +26,10 @@ * @author Michal Frackowiak * */ -class Text_Wiki_Parse_Button extends Text_Wiki_Parse { +class Text_Wiki_Parse_Button extends Text_Wiki_Parse +{ - public $regex = '/' . + public $regex = '/' . '\[\[' . # Opening brackets 'button\s+' . # Tag name '([a-z0-9\-_]+)' . # Button name @@ -44,10 +45,10 @@ function process(&$matches) $allowedAttrs = array('text', 'class', 'style'); $options = array(); - foreach($allowedAttrs as $aa){ - if(isset($attr[$aa])){ - $options[$aa] = $attr[$aa]; - } + foreach ($allowedAttrs as $aa) { + if (isset($attr[$aa])) { + $options[$aa] = $attr[$aa]; + } } $type = str_replace("_", "-", $type); @@ -55,6 +56,5 @@ function process(&$matches) $options['type'] = $type; return $this->wiki->addToken($this->rule, $options); - } } diff --git a/Text/Wiki/Parse/Default/Center.php b/Text/Wiki/Parse/Default/Center.php index daff01e..9fb7d56 100644 --- a/Text/Wiki/Parse/Default/Center.php +++ b/Text/Wiki/Parse/Default/Center.php @@ -35,7 +35,8 @@ * */ -class Text_Wiki_Parse_Center extends Text_Wiki_Parse { +class Text_Wiki_Parse_Center extends Text_Wiki_Parse +{ /** * @@ -63,7 +64,8 @@ class Text_Wiki_Parse_Center extends Text_Wiki_Parse { * */ - function process(&$matches) { + function process(&$matches) + { $start = $this->wiki->addToken($this->rule, array( 'type' => 'start')); diff --git a/Text/Wiki/Parse/Default/Clearfloat.php b/Text/Wiki/Parse/Default/Clearfloat.php index 69a1724..e09465e 100644 --- a/Text/Wiki/Parse/Default/Clearfloat.php +++ b/Text/Wiki/Parse/Default/Clearfloat.php @@ -28,7 +28,8 @@ * */ -class Text_Wiki_Parse_Clearfloat extends Text_Wiki_Parse { +class Text_Wiki_Parse_Clearfloat extends Text_Wiki_Parse +{ /** * @@ -43,11 +44,11 @@ class Text_Wiki_Parse_Clearfloat extends Text_Wiki_Parse { * */ - public $regex = '/' . - '^' . + public $regex = '/' . + '^' . '([~]{4,})' . # ~~~~ '(>|<)?' . # Optional directional modifier - '$' . + '$' . '/m'; /** @@ -62,7 +63,8 @@ class Text_Wiki_Parse_Clearfloat extends Text_Wiki_Parse { * */ - function process(&$matches) { + function process(&$matches) + { $side = $matches[2]; $options = array('side' => $side); return "\n\n" . $this->wiki->addToken($this->rule, $options) . "\n\n"; diff --git a/Text/Wiki/Parse/Default/Code.php b/Text/Wiki/Parse/Default/Code.php index 3b490ab..f9341c0 100644 --- a/Text/Wiki/Parse/Default/Code.php +++ b/Text/Wiki/Parse/Default/Code.php @@ -37,7 +37,8 @@ * */ -class Text_Wiki_Parse_Code extends Text_Wiki_Parse { +class Text_Wiki_Parse_Code extends Text_Wiki_Parse +{ /** * @@ -73,7 +74,8 @@ class Text_Wiki_Parse_Code extends Text_Wiki_Parse { * */ - function process(&$matches) { + function process(&$matches) + { // are there additional attribute arguments? $args = trim($matches[1]); diff --git a/Text/Wiki/Parse/Default/Collapsible.php b/Text/Wiki/Parse/Default/Collapsible.php index 2f1f4a3..2be039d 100644 --- a/Text/Wiki/Parse/Default/Collapsible.php +++ b/Text/Wiki/Parse/Default/Collapsible.php @@ -28,7 +28,8 @@ * */ -class Text_Wiki_Parse_Collapsible extends Text_Wiki_Parse { +class Text_Wiki_Parse_Collapsible extends Text_Wiki_Parse +{ static $count = 0; @@ -43,14 +44,14 @@ class Text_Wiki_Parse_Collapsible extends Text_Wiki_Parse { * */ - public $regex = '/' . + public $regex = '/' . '(\n)?' . # Start with an optional newline? - '\[\[' . + '\[\[' . 'collapsible' . '(\s.*?)?' . # Parameters of collapsbile - '\]\]' . + '\]\]' . '(.*?)' . # Contents of collapsible - no nesting - '\[\[\/collapsible\]\]\s*' . + '\[\[\/collapsible\]\]\s*' . '/msi'; /** @@ -68,7 +69,8 @@ class Text_Wiki_Parse_Collapsible extends Text_Wiki_Parse { * */ - function process(&$matches) { + function process(&$matches) + { $content = $matches[3]; @@ -84,7 +86,5 @@ function process(&$matches) { 'count' => self::$count)); self::$count++; return $matches[1] . $matches[1] . $start . "\n\n" . $content . "\n\n" . $end; - } - } diff --git a/Text/Wiki/Parse/Default/Colortext.php b/Text/Wiki/Parse/Default/Colortext.php index fc3b97a..d1fd7ce 100644 --- a/Text/Wiki/Parse/Default/Colortext.php +++ b/Text/Wiki/Parse/Default/Colortext.php @@ -32,7 +32,8 @@ * */ -class Text_Wiki_Parse_Colortext extends Text_Wiki_Parse { +class Text_Wiki_Parse_Colortext extends Text_Wiki_Parse +{ /** * @@ -47,12 +48,12 @@ class Text_Wiki_Parse_Colortext extends Text_Wiki_Parse { * */ - public $regex = '/' . - '##' . + public $regex = '/' . + '##' . '(.+?)' . # Colou?r '\|' . # Pipe to split colour and text '(.+?)' . # Text - '##' . + '##' . '/'; /** @@ -74,7 +75,8 @@ class Text_Wiki_Parse_Colortext extends Text_Wiki_Parse { * */ - function process(&$matches) { + function process(&$matches) + { $start = $this->wiki->addToken($this->rule, array( 'type' => 'start', 'color' => $matches[1])); diff --git a/Text/Wiki/Parse/Default/Comment.php b/Text/Wiki/Parse/Default/Comment.php index 8827bd0..b8ef484 100644 --- a/Text/Wiki/Parse/Default/Comment.php +++ b/Text/Wiki/Parse/Default/Comment.php @@ -28,7 +28,8 @@ * */ -class Text_Wiki_Parse_Comment extends Text_Wiki_Parse { +class Text_Wiki_Parse_Comment extends Text_Wiki_Parse +{ /** * @@ -41,7 +42,7 @@ class Text_Wiki_Parse_Comment extends Text_Wiki_Parse { * */ - public $regex = '/' . + public $regex = '/' . '(\n)?' . # Optional newline? '\[!\-\-' . # [!-- '(.*?)' . # Any text - no nesting @@ -63,9 +64,9 @@ class Text_Wiki_Parse_Comment extends Text_Wiki_Parse { * */ - function process(&$matches) { + function process(&$matches) + { return ''; - } } diff --git a/Text/Wiki/Parse/Default/Concatlines.php b/Text/Wiki/Parse/Default/Concatlines.php index e5314da..6e8742f 100644 --- a/Text/Wiki/Parse/Default/Concatlines.php +++ b/Text/Wiki/Parse/Default/Concatlines.php @@ -24,7 +24,8 @@ * @author Michal Frackowiak * */ -class Text_Wiki_Parse_Concatlines extends Text_Wiki_Parse { +class Text_Wiki_Parse_Concatlines extends Text_Wiki_Parse +{ /** * @@ -34,11 +35,10 @@ class Text_Wiki_Parse_Concatlines extends Text_Wiki_Parse { * */ - function parse() { + function parse() + { // concat lines ending in a backslash $this->wiki->source = str_replace("\\\n", "", $this->wiki->source); - } - } diff --git a/Text/Wiki/Parse/Default/Date.php b/Text/Wiki/Parse/Default/Date.php index baf21df..f470316 100644 --- a/Text/Wiki/Parse/Default/Date.php +++ b/Text/Wiki/Parse/Default/Date.php @@ -23,15 +23,16 @@ * @author Michal Frackowiak * */ -class Text_Wiki_Parse_Date extends Text_Wiki_Parse { +class Text_Wiki_Parse_Date extends Text_Wiki_Parse +{ - public $regex = '/' . - '\[\[date\s+' . + public $regex = '/' . + '\[\[date\s+' . '([0-9]+)' . # A number, for a given time. Required. '(\s+.*?)?' . # Optional extra parameters (format) - '\]\]' . + '\]\]' . '/'; /** * @@ -51,19 +52,19 @@ class Text_Wiki_Parse_Date extends Text_Wiki_Parse { function process(&$matches) { - $options = array(); - $options['timestamp'] = $matches[1]; + $options = array(); + $options['timestamp'] = $matches[1]; - $attr = $this->getAttrs(trim($matches[2])); - foreach($attr as $key => $a){ - $options[$key] = $attr[$key]; - } + $attr = $this->getAttrs(trim($matches[2])); + foreach ($attr as $key => $a) { + $options[$key] = $attr[$key]; + } - $token = $this->wiki->addToken( - $this->rule, $options + $token = $this->wiki->addToken( + $this->rule, + $options ); return $token; } - } diff --git a/Text/Wiki/Parse/Default/Deflist.php b/Text/Wiki/Parse/Default/Deflist.php index a0efa29..5e160e9 100644 --- a/Text/Wiki/Parse/Default/Deflist.php +++ b/Text/Wiki/Parse/Default/Deflist.php @@ -39,7 +39,8 @@ * */ -class Text_Wiki_Parse_Deflist extends Text_Wiki_Parse { +class Text_Wiki_Parse_Deflist extends Text_Wiki_Parse +{ /** * @@ -54,8 +55,8 @@ class Text_Wiki_Parse_Deflist extends Text_Wiki_Parse { * */ - public $regex = '/' . - '\n' . + public $regex = '/' . + '\n' . '((:\s).*?\n)' . # Match colon, whitespace, then text up to newline '(?!(:\s|\n))' . # Do not match if followed by colon+ws or newline '/s'; diff --git a/Text/Wiki/Parse/Default/Delimiter.php b/Text/Wiki/Parse/Default/Delimiter.php index 8caf64e..cae00a6 100644 --- a/Text/Wiki/Parse/Default/Delimiter.php +++ b/Text/Wiki/Parse/Default/Delimiter.php @@ -33,7 +33,8 @@ * */ -class Text_Wiki_Parse_Delimiter extends Text_Wiki_Parse { +class Text_Wiki_Parse_Delimiter extends Text_Wiki_Parse +{ /** * diff --git a/Text/Wiki/Parse/Default/Div.php b/Text/Wiki/Parse/Default/Div.php index 1a884d5..ff2094d 100644 --- a/Text/Wiki/Parse/Default/Div.php +++ b/Text/Wiki/Parse/Default/Div.php @@ -28,7 +28,8 @@ * */ -class Text_Wiki_Parse_Div extends Text_Wiki_Parse { +class Text_Wiki_Parse_Div extends Text_Wiki_Parse +{ /** * @@ -61,7 +62,8 @@ class Text_Wiki_Parse_Div extends Text_Wiki_Parse { * */ - function process(&$matches) { + function process(&$matches) + { $content = $matches[2]; $attr = $this->getAttrs(trim($matches[1])); @@ -83,16 +85,18 @@ function process(&$matches) { 'type' => 'end')); return $start . "\n\n" . $content . "\n\n" . $end; - } - function parse() { + function parse() + { $oldSource = $this->wiki->source; $this->wiki->source = preg_replace_callback( - $this->regex, array(&$this, 'process'), $this->wiki->source); + $this->regex, + array(&$this, 'process'), + $this->wiki->source + ); if ($oldSource != $this->wiki->source) { $this->parse(); } } - } diff --git a/Text/Wiki/Parse/Default/Divalign.php b/Text/Wiki/Parse/Default/Divalign.php index 2676c5d..bb7d9f2 100644 --- a/Text/Wiki/Parse/Default/Divalign.php +++ b/Text/Wiki/Parse/Default/Divalign.php @@ -26,7 +26,8 @@ * */ -class Text_Wiki_Parse_Divalign extends Text_Wiki_Parse { +class Text_Wiki_Parse_Divalign extends Text_Wiki_Parse +{ /** * @@ -39,10 +40,10 @@ class Text_Wiki_Parse_Divalign extends Text_Wiki_Parse { * */ - public $regex = '/' . + public $regex = '/' . '^' . # Start of line '\[\[(=|<|>|==)\]\]' . # Opening tag with variations - '\n' . + '\n' . '((?:(?R)|.)*?)' . # Contents of tag - nesting is allowed '\[\[\/\\1\]\]' . # Closing tag that matches opening tag '$' . # End of line @@ -63,7 +64,8 @@ class Text_Wiki_Parse_Divalign extends Text_Wiki_Parse { * */ - function process(&$matches) { + function process(&$matches) + { $align = $matches[1]; $content = $matches[2]; @@ -86,10 +88,10 @@ function process(&$matches) { 'type' => 'end')); return $start . "\n\n" . $content . "\n\n" . $end; - } - function parse() { + function parse() + { $oldSource = $this->wiki->source; $this->wiki->source = preg_replace_callback($this->regex, array( &$this, 'process'), $this->wiki->source); @@ -97,5 +99,4 @@ function parse() { $this->parse(); } } - } diff --git a/Text/Wiki/Parse/Default/Divprefilter.php b/Text/Wiki/Parse/Default/Divprefilter.php index 088ecfc..b9c66be 100644 --- a/Text/Wiki/Parse/Default/Divprefilter.php +++ b/Text/Wiki/Parse/Default/Divprefilter.php @@ -29,7 +29,8 @@ * */ -class Text_Wiki_Parse_Divprefilter extends Text_Wiki_Parse { +class Text_Wiki_Parse_Divprefilter extends Text_Wiki_Parse +{ /** * @@ -42,10 +43,10 @@ class Text_Wiki_Parse_Divprefilter extends Text_Wiki_Parse { * */ - public $regex = '/' . - '\[\[\/div\]\]' . - '(\s*?)' . - '\[\[div' . + public $regex = '/' . + '\[\[\/div\]\]' . + '(\s*?)' . + '\[\[div' . '/msi'; /** * @@ -65,6 +66,5 @@ class Text_Wiki_Parse_Divprefilter extends Text_Wiki_Parse { function process(&$matches) { return '[[/div]][[div'; - } } diff --git a/Text/Wiki/Parse/Default/Email.php b/Text/Wiki/Parse/Default/Email.php index 00129d0..308f613 100644 --- a/Text/Wiki/Parse/Default/Email.php +++ b/Text/Wiki/Parse/Default/Email.php @@ -27,7 +27,8 @@ * */ -class Text_Wiki_Parse_Email extends Text_Wiki_Parse { +class Text_Wiki_Parse_Email extends Text_Wiki_Parse +{ /** * @@ -46,9 +47,10 @@ class Text_Wiki_Parse_Email extends Text_Wiki_Parse { '(?:\.[a-z0-9\-]+)+'; # Allow a dot so long as is is not the first # TODO: Replace this trash, probably with a filter_var statement. - function parse(){ + function parse() + { - // described emails + // described emails $tmp_regex = '/\[(' . $this->regex . ')\s(.+?)\]/i'; $this->wiki->source = preg_replace_callback( $tmp_regex, @@ -56,17 +58,17 @@ function parse(){ $this->wiki->source ); - // standalone emails + // standalone emails $tmp_regex = '/' . $this->regex . '/i'; $this->wiki->source = preg_replace_callback( $tmp_regex, array(&$this, 'process'), $this->wiki->source ); - } - function process(&$matches){ + function process(&$matches) + { $options = array( 'email' => $matches[0], 'text' => $matches[0] @@ -75,7 +77,8 @@ function process(&$matches){ return $this->wiki->addToken($this->rule, $options); } - function processDescr(&$matches){ + function processDescr(&$matches) + { $options = array( 'email' => $matches[1], 'text' => $matches[2] @@ -83,5 +86,4 @@ function processDescr(&$matches){ return $this->wiki->addToken($this->rule, $options); } - } diff --git a/Text/Wiki/Parse/Default/Embed.php b/Text/Wiki/Parse/Default/Embed.php index 3216507..fb7caeb 100644 --- a/Text/Wiki/Parse/Default/Embed.php +++ b/Text/Wiki/Parse/Default/Embed.php @@ -25,7 +25,8 @@ * */ -class Text_Wiki_Parse_Embed extends Text_Wiki_Parse { +class Text_Wiki_Parse_Embed extends Text_Wiki_Parse +{ /** * @@ -38,10 +39,10 @@ class Text_Wiki_Parse_Embed extends Text_Wiki_Parse { * */ - public $regex = '/' . - '\[\[embed(?:audio|video)?\]\]' . - '(.*?)' . - '\[\[\/embed(?:audio|video)?\]\]' . + public $regex = '/' . + '\[\[embed(?:audio|video)?\]\]' . + '(.*?)' . + '\[\[\/embed(?:audio|video)?\]\]' . '/msi'; /** * @@ -60,10 +61,9 @@ class Text_Wiki_Parse_Embed extends Text_Wiki_Parse { function process(&$matches) { - $content =trim($matches[1]); - $options = array('content' => $content); + $content =trim($matches[1]); + $options = array('content' => $content); return $this->wiki->addToken($this->rule, $options); - } } diff --git a/Text/Wiki/Parse/Default/Emphasis.php b/Text/Wiki/Parse/Default/Emphasis.php index 3a82854..96d3493 100644 --- a/Text/Wiki/Parse/Default/Emphasis.php +++ b/Text/Wiki/Parse/Default/Emphasis.php @@ -35,7 +35,8 @@ * */ -class Text_Wiki_Parse_Emphasis extends Text_Wiki_Parse { +class Text_Wiki_Parse_Emphasis extends Text_Wiki_Parse +{ /** * @@ -50,12 +51,12 @@ class Text_Wiki_Parse_Emphasis extends Text_Wiki_Parse { * */ - public $regex = "/" . + public $regex = "/" . "\/\/" . # // - "(" . + "(" . "[^\s]" . # Italic text cannot start with whitespace "(?:.*?[^\s])?" . # Anything that does not end in whitespace - ")" . + ")" . "\/\/" . # // "/"; @@ -79,11 +80,13 @@ class Text_Wiki_Parse_Emphasis extends Text_Wiki_Parse { function process(&$matches) { $start = $this->wiki->addToken( - $this->rule, array('type' => 'start') + $this->rule, + array('type' => 'start') ); $end = $this->wiki->addToken( - $this->rule, array('type' => 'end') + $this->rule, + array('type' => 'end') ); return $start . $matches[1] . $end; diff --git a/Text/Wiki/Parse/Default/Equationreference.php b/Text/Wiki/Parse/Default/Equationreference.php index cedc9ee..6c17d85 100644 --- a/Text/Wiki/Parse/Default/Equationreference.php +++ b/Text/Wiki/Parse/Default/Equationreference.php @@ -29,7 +29,8 @@ * */ -class Text_Wiki_Parse_Equationreference extends Text_Wiki_Parse { +class Text_Wiki_Parse_Equationreference extends Text_Wiki_Parse +{ /** * @@ -42,8 +43,8 @@ class Text_Wiki_Parse_Equationreference extends Text_Wiki_Parse { * */ - public $regex = '/' . - '\[\[eref\s(.*?)\]\]' . + public $regex = '/' . + '\[\[eref\s(.*?)\]\]' . '/'; /** * @@ -62,7 +63,7 @@ class Text_Wiki_Parse_Equationreference extends Text_Wiki_Parse { function process(&$matches) { - $label = trim($matches[1]); + $label = trim($matches[1]); $options = array('label'=>$label); diff --git a/Text/Wiki/Parse/Default/File.php b/Text/Wiki/Parse/Default/File.php index ecbea45..e28f040 100644 --- a/Text/Wiki/Parse/Default/File.php +++ b/Text/Wiki/Parse/Default/File.php @@ -25,7 +25,8 @@ * */ -class Text_Wiki_Parse_File extends Text_Wiki_Parse { +class Text_Wiki_Parse_File extends Text_Wiki_Parse +{ /** * @@ -38,26 +39,26 @@ class Text_Wiki_Parse_File extends Text_Wiki_Parse { * */ - public $regex = '/' . - '\[\[file' . - '\s+' . + public $regex = '/' . + '\[\[file' . + '\s+' . '(.+?)' . # Name of file '(?:\|(.+?))?' . # Pipe, then link text (optional) - '\]\]' . + '\]\]' . '/i'; function process(&$matches) { - $file = trim($matches[1]); - $anchor = trim($matches[2]); + $file = trim($matches[1]); + $anchor = trim($matches[2]); - if($anchor == null || $anchor === ''){ - $anchor = $file; - } + if ($anchor == null || $anchor === '') { + $anchor = $file; + } - $options = array('file' => $file, - 'anchor' => $anchor); + $options = array('file' => $file, + 'anchor' => $anchor); return $this->wiki->addToken($this->rule, $options); } } diff --git a/Text/Wiki/Parse/Default/Footnote.php b/Text/Wiki/Parse/Default/Footnote.php index 1ed7217..47055e8 100644 --- a/Text/Wiki/Parse/Default/Footnote.php +++ b/Text/Wiki/Parse/Default/Footnote.php @@ -28,7 +28,8 @@ * */ -class Text_Wiki_Parse_Footnote extends Text_Wiki_Parse { +class Text_Wiki_Parse_Footnote extends Text_Wiki_Parse +{ /** * @@ -41,24 +42,24 @@ class Text_Wiki_Parse_Footnote extends Text_Wiki_Parse { * */ - public $regex = '/' . - '\s*' . - '\[\[footnote\]\]' . - '(.*?)' . - '\[\[\/footnote\]\]' . + public $regex = '/' . + '\s*' . + '\[\[footnote\]\]' . + '(.*?)' . + '\[\[\/footnote\]\]' . '/s'; function process(&$matches) { - if($this->wiki->vars['footnotes'] == null){ - $this->wiki->vars['footnotes'] = array(); - } - $id = count($this->wiki->vars['footnotes'])+1; - //echo "dup[a]" + if ($this->wiki->vars['footnotes'] == null) { + $this->wiki->vars['footnotes'] = array(); + } + $id = count($this->wiki->vars['footnotes'])+1; + //echo "dup[a]" - $content = trim($matches[1]); + $content = trim($matches[1]); - $this->wiki->vars['footnotes'][$id-1] = $content; + $this->wiki->vars['footnotes'][$id-1] = $content; $options = array('id'=>$id); return $this->wiki->addToken($this->rule, $options); diff --git a/Text/Wiki/Parse/Default/Footnoteblock.php b/Text/Wiki/Parse/Default/Footnoteblock.php index 3187489..108104f 100644 --- a/Text/Wiki/Parse/Default/Footnoteblock.php +++ b/Text/Wiki/Parse/Default/Footnoteblock.php @@ -27,7 +27,8 @@ * */ -class Text_Wiki_Parse_Footnoteblock extends Text_Wiki_Parse { +class Text_Wiki_Parse_Footnoteblock extends Text_Wiki_Parse +{ /** * @@ -40,31 +41,35 @@ class Text_Wiki_Parse_Footnoteblock extends Text_Wiki_Parse { * */ - public $regex = null; + public $regex = null; - function parse(){ - $regex = '/(\[\[footnoteblock(\s+[^\]]+)?\]\])|($)/s'; - $this->wiki->source = preg_replace_callback($regex, array($this,"process"), $this->wiki->source, 1); + function parse() + { + $regex = '/(\[\[footnoteblock(\s+[^\]]+)?\]\])|($)/s'; + $this->wiki->source = preg_replace_callback($regex, array($this,"process"), $this->wiki->source, 1); } function process(&$matches) { - $footnotes = $this->wiki->vars['footnotes']; - if($footnotes == null) { return '';} - else if (count($footnotes) == 0){return '';} // render nothing if no footnotes. - $inside = ''; - $fni = $this->wiki->parseObj['Footnoteitem']; + $footnotes = $this->wiki->vars['footnotes']; + if ($footnotes == null) { + return ''; + } elseif (count($footnotes) == 0) { + return ''; + } // render nothing if no footnotes. + $inside = ''; + $fni = $this->wiki->parseObj['Footnoteitem']; - foreach($footnotes as $id => $content){ - $inside.=$this->wiki->addToken($fni->rule, array('type'=>'start', 'id' => $id+1)) - .$content."\n\n" - .$this->wiki->addToken($fni->rule, array('type'=>'end', 'id' => $id+1)); - } + foreach ($footnotes as $id => $content) { + $inside.=$this->wiki->addToken($fni->rule, array('type'=>'start', 'id' => $id+1)) + .$content."\n\n" + .$this->wiki->addToken($fni->rule, array('type'=>'end', 'id' => $id+1)); + } - $args = $this->getAttrs($matches[2]); - $title = $args['title']; + $args = $this->getAttrs($matches[2]); + $title = $args['title']; return "\n".$this->wiki->addToken($this->rule, array('type'=>'start', 'title' => $title)) - .$inside - .$this->wiki->addToken($this->rule, array('type'=>'end'))."\n"; + .$inside + .$this->wiki->addToken($this->rule, array('type'=>'end'))."\n"; } } diff --git a/Text/Wiki/Parse/Default/Footnoteitem.php b/Text/Wiki/Parse/Default/Footnoteitem.php index e024432..426665f 100644 --- a/Text/Wiki/Parse/Default/Footnoteitem.php +++ b/Text/Wiki/Parse/Default/Footnoteitem.php @@ -27,7 +27,8 @@ * */ -class Text_Wiki_Parse_Footnoteitem extends Text_Wiki_Parse { +class Text_Wiki_Parse_Footnoteitem extends Text_Wiki_Parse +{ /** * diff --git a/Text/Wiki/Parse/Default/Form.php b/Text/Wiki/Parse/Default/Form.php index 4a00bb4..04ac2df 100644 --- a/Text/Wiki/Parse/Default/Form.php +++ b/Text/Wiki/Parse/Default/Form.php @@ -30,7 +30,8 @@ * */ -class Text_Wiki_Parse_Form extends Text_Wiki_Parse { +class Text_Wiki_Parse_Form extends Text_Wiki_Parse +{ /** * @@ -43,12 +44,12 @@ class Text_Wiki_Parse_Form extends Text_Wiki_Parse { * */ - public $regex = '/' . - '\[\[form\]\]\s*\n' . + public $regex = '/' . + '\[\[form\]\]\s*\n' . '(.*)\n' . # Anything then a newline '---\s*\n' . # Three hyphens (???) '(.*)\n' . # Anything again - '\[\[\/form\]\]' . + '\[\[\/form\]\]' . '/is'; /** @@ -68,7 +69,8 @@ class Text_Wiki_Parse_Form extends Text_Wiki_Parse { * */ - function process(&$matches) { + function process(&$matches) + { $formYaml = $matches[1]; $dataYaml = $matches[2]; diff --git a/Text/Wiki/Parse/Default/Freelink.php b/Text/Wiki/Parse/Default/Freelink.php index 2a7dcec..b257e4e 100644 --- a/Text/Wiki/Parse/Default/Freelink.php +++ b/Text/Wiki/Parse/Default/Freelink.php @@ -41,19 +41,20 @@ * */ -class Text_Wiki_Parse_Freelink extends Text_Wiki_Parse { +class Text_Wiki_Parse_Freelink extends Text_Wiki_Parse +{ - public $regex = '/' . + public $regex = '/' . '\[\[\[' . # Opening brackets '([^\[\]\|\#]+)' . # Target page name - '\s*' . + '\s*' . '(' . # Match a URL fragment after the page name - '\#' . + '\#' . '[A-Za-z]' . # Require that first letter is alphanumeric - '[-A-Za-z0-9_:.]*' . + '[-A-Za-z0-9_:.]*' . ')?' . # URL fragment is optional - '\s*' . - '(' . + '\s*' . + '(' . '\|' . # Pipe to delimit link text '[^\]\|\[\#]*' . # Link text ')?' . # Link text is optional @@ -88,18 +89,18 @@ function process(&$matches) $text = $matches[3]; $anchor = $matches[2]; - if($page[0] == '_'){ - $page = substr($page, 1); - $nonbr = true; + if ($page[0] == '_') { + $page = substr($page, 1); + $nonbr = true; } // check if references to another site too. $site = null; - if(strpos($page, '::')){ - $site = substr($page,0,strpos($page, '::')); + if (strpos($page, '::')) { + $site = substr($page, 0, strpos($page, '::')); $site = WDStringUtils::toUnixName($site); - $page = substr($page,strpos($page, '::')+2); - if(!$page){ + $page = substr($page, strpos($page, '::')+2); + if (!$page) { $page = $site; } } @@ -108,13 +109,12 @@ function process(&$matches) if (trim($text) == '') { // no $text = $page; - if(strpos($text, ':') != false){ - $text = substr($text, strpos($text, ':')+1); - } - }elseif(trim($text) == '|'){ - // get $text from the page title (if exists) - $textFromTitle = true; - + if (strpos($text, ':') != false) { + $text = substr($text, strpos($text, ':')+1); + } + } elseif (trim($text) == '|') { + // get $text from the page title (if exists) + $textFromTitle = true; } else { // yes, strip the leading | character $text = substr($text, 1); @@ -127,14 +127,14 @@ function process(&$matches) // set the options $options = array( - 'site' => $site, + 'site' => $site, 'page' => $page, 'text' => $text, 'anchor' => $anchor, 'textFromTitle' => $textFromTitle ); - if($nonbr){ - $options['nonbr']=true; + if ($nonbr) { + $options['nonbr']=true; } // return a token placeholder diff --git a/Text/Wiki/Parse/Default/Function.php b/Text/Wiki/Parse/Default/Function.php index 231c31b..5180f61 100644 --- a/Text/Wiki/Parse/Default/Function.php +++ b/Text/Wiki/Parse/Default/Function.php @@ -28,14 +28,15 @@ * */ -class Text_Wiki_Parse_Function extends Text_Wiki_Parse { - - public $regex = '/' . - '^' . - '(\)\n' . - '(.+?)\n' . - '(\<\/function\>)' . - '(\s|$)' . +class Text_Wiki_Parse_Function extends Text_Wiki_Parse +{ + + public $regex = '/' . + '^' . + '(\)\n' . + '(.+?)\n' . + '(\<\/function\>)' . + '(\s|$)' . '/msi'; function process(&$matches) @@ -52,7 +53,6 @@ function process(&$matches) // 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; @@ -72,70 +72,68 @@ function process(&$matches) $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( + 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( + ); + } elseif ($k == 2) { + $opts['params'][] = array( 'type' => $tmp[0], 'descr' => $tmp[1], 'default' => null - ); - } else { - $opts['params'][] = array( + ); + } 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( + ); + } + 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( + ); + } else { + $opts['throws'][] = array( 'type' => $tmp[0], 'descr' => $tmp[1] - ); - } - break; - - default: - $opts[$type] = $val; - break; + ); + } + break; + default: + $opts[$type] = $val; + break; } } diff --git a/Text/Wiki/Parse/Default/Gallery.php b/Text/Wiki/Parse/Default/Gallery.php index 5e02927..fdacc2e 100644 --- a/Text/Wiki/Parse/Default/Gallery.php +++ b/Text/Wiki/Parse/Default/Gallery.php @@ -27,7 +27,8 @@ * */ -class Text_Wiki_Parse_Gallery extends Text_Wiki_Parse { +class Text_Wiki_Parse_Gallery extends Text_Wiki_Parse +{ /** * @@ -40,11 +41,11 @@ class Text_Wiki_Parse_Gallery extends Text_Wiki_Parse { * */ - public $regex = '/' . - '^' . - '\[\[gallery(\s[^\]]*?)?\]\]' . - '(?:((?:\n:\s[^\n]+)+)\n' . - '\[\[\/gallery\]\])?' . + public $regex = '/' . + '^' . + '\[\[gallery(\s[^\]]*?)?\]\]' . + '(?:((?:\n:\s[^\n]+)+)\n' . + '\[\[\/gallery\]\])?' . '/msi'; /** @@ -62,7 +63,8 @@ class Text_Wiki_Parse_Gallery extends Text_Wiki_Parse { * */ - function process(&$matches) { + function process(&$matches) + { $attr = $this->getAttrs(trim($matches[1])); $sources = $matches[2]; @@ -74,6 +76,5 @@ function process(&$matches) { $token = $this->wiki->addToken($this->rule, $options); return "\n\n" . $token . "\n\n"; - } } diff --git a/Text/Wiki/Parse/Default/Heading.php b/Text/Wiki/Parse/Default/Heading.php index 6ca6561..878eba6 100644 --- a/Text/Wiki/Parse/Default/Heading.php +++ b/Text/Wiki/Parse/Default/Heading.php @@ -34,7 +34,8 @@ * */ -class Text_Wiki_Parse_Heading extends Text_Wiki_Parse { +class Text_Wiki_Parse_Heading extends Text_Wiki_Parse +{ /** * @@ -76,10 +77,10 @@ function process(&$matches) // keep a running count for header IDs. we use this later // when constructing TOC entries, etc. - if($this->wiki->vars['headline_id'] === null){ - $this->wiki->vars['headline_id'] = 0; - } - $id = $this->wiki->vars['headline_id']; + if ($this->wiki->vars['headline_id'] === null) { + $this->wiki->vars['headline_id'] = 0; + } + $id = $this->wiki->vars['headline_id']; $prefix = htmlspecialchars($this->getConf('id_prefix')); diff --git a/Text/Wiki/Parse/Default/Horiz.php b/Text/Wiki/Parse/Default/Horiz.php index f3f41e4..e028fa9 100644 --- a/Text/Wiki/Parse/Default/Horiz.php +++ b/Text/Wiki/Parse/Default/Horiz.php @@ -31,7 +31,8 @@ * */ -class Text_Wiki_Parse_Horiz extends Text_Wiki_Parse { +class Text_Wiki_Parse_Horiz extends Text_Wiki_Parse +{ /** * diff --git a/Text/Wiki/Parse/Default/Html.php b/Text/Wiki/Parse/Default/Html.php index 5b08685..b0ed457 100644 --- a/Text/Wiki/Parse/Default/Html.php +++ b/Text/Wiki/Parse/Default/Html.php @@ -32,7 +32,8 @@ * */ -class Text_Wiki_Parse_Html extends Text_Wiki_Parse { +class Text_Wiki_Parse_Html extends Text_Wiki_Parse +{ /** * @@ -47,12 +48,12 @@ class Text_Wiki_Parse_Html extends Text_Wiki_Parse { * */ - public $regex = '/' . - '^' . - '\\n' . - '(.+?)\n' . - '\<\/html\>' . - '(\s|$)' . + public $regex = '/' . + '^' . + '\\n' . + '(.+?)\n' . + '\<\/html\>' . + '(\s|$)' . '/msi'; /** diff --git a/Text/Wiki/Parse/Default/Iframe.php b/Text/Wiki/Parse/Default/Iframe.php index c8a7b98..e9cb713 100644 --- a/Text/Wiki/Parse/Default/Iframe.php +++ b/Text/Wiki/Parse/Default/Iframe.php @@ -23,9 +23,10 @@ * @author Michal Frackowiak * */ -class Text_Wiki_Parse_Iframe extends Text_Wiki_Parse { +class Text_Wiki_Parse_Iframe extends Text_Wiki_Parse +{ - public $conf = array( + public $conf = array( 'schemes' => array( 'http://', 'https://', @@ -35,33 +36,33 @@ class Text_Wiki_Parse_Iframe extends Text_Wiki_Parse { 'mailto:', 'mms://' ) - ); + ); - public $regex = ''; + public $regex = ''; - function __construct($obj){ - parent::__construct($obj); + function __construct($obj) + { + parent::__construct($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); + // 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 - $urlRegex = + // build the regex + $urlRegex = "(?:(?:$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}]*?)"; - $this->regex = '/\[\[iframe\s+('.$urlRegex.')(\s+.*?)?\]\]/si'; - - } + $this->regex = '/\[\[iframe\s+('.$urlRegex.')(\s+.*?)?\]\]/si'; + } /** * @@ -78,26 +79,25 @@ function __construct($obj){ * */ - function process(&$matches) - { - - $options = array(); - $options['src'] = $matches[1]; - - $attr = $this->getAttrs(trim($matches[2])); + function process(&$matches) + { - $iframeAttributes = array('align', 'frameborder', 'height', 'scrolling', 'width', 'class', 'style'); + $options = array(); + $options['src'] = $matches[1]; - foreach($iframeAttributes as $a){ - $options[$a] = $attr[$a]; - } + $attr = $this->getAttrs(trim($matches[2])); - $token = $this->wiki->addToken( - $this->rule, $options - ); + $iframeAttributes = array('align', 'frameborder', 'height', 'scrolling', 'width', 'class', 'style'); - return $token; + foreach ($iframeAttributes as $a) { + $options[$a] = $attr[$a]; + } - } + $token = $this->wiki->addToken( + $this->rule, + $options + ); + return $token; + } } diff --git a/Text/Wiki/Parse/Default/Iftags.php b/Text/Wiki/Parse/Default/Iftags.php index cac8c3f..b2cc418 100644 --- a/Text/Wiki/Parse/Default/Iftags.php +++ b/Text/Wiki/Parse/Default/Iftags.php @@ -23,16 +23,17 @@ * @author Michal Frackowiak * */ -class Text_Wiki_Parse_Iftags extends Text_Wiki_Parse { +class Text_Wiki_Parse_Iftags extends Text_Wiki_Parse +{ - public $regex = '/' . - '\[\[iftags(\s[^\]]*)?\]\]' . # Opening iftags tag including parameters - '(' . - '(?:(?R)|.)' . # Contents of the page, including other iftags - '*?)' . # Non-greedy match to claim next closing tag - '\[\[\/iftags\]\]' . # Closing tag - '/msi'; + public $regex = '/' . + '\[\[iftags(\s[^\]]*)?\]\]' . # Opening iftags tag including parameters + '(' . + '(?:(?R)|.)' . # Contents of the page, including other iftags + '*?)' . # Non-greedy match to claim next closing tag + '\[\[\/iftags\]\]' . # Closing tag + '/msi'; # Note regarding non-greedy match: I'm not sure how a recursive regex match # works entirely, so I've written that it claims the next closing tag. # That's unlikely to be true and definitely not intended behaviour. @@ -56,65 +57,64 @@ class Text_Wiki_Parse_Iftags extends Text_Wiki_Parse { function process(&$matches) { - $page = $this->wiki->vars['page']; - if(!$page){ - $pageName = $this->wiki->vars['pageName']; - $site = $GLOBALS['site']; - $page = DB\PagePeer::instance()->selectByName($site->getSiteId(), $pageName); - } - if(!$page) { - return; - } + $page = $this->wiki->vars['page']; + if (!$page) { + $pageName = $this->wiki->vars['pageName']; + $site = $GLOBALS['site']; + $page = DB\PagePeer::instance()->selectByName($site->getSiteId(), $pageName); + } + if (!$page) { + return; + } - $tag0 = $tags0[0]; - $tags = $page->getTagsAsArray(); + $tag0 = $tags0[0]; + $tags = $page->getTagsAsArray(); - $tags0 = preg_split('/[, ]+/', trim($matches[1])); + $tags0 = preg_split('/[, ]+/', trim($matches[1])); - $allTags = array(); - $noTags = array(); - $anyTags = array(); + $allTags = array(); + $noTags = array(); + $anyTags = array(); - foreach($tags0 as $t){ - if (substr($t, 0, 1) == '+') { - $allTags[] = substr($t, 1); + foreach ($tags0 as $t) { + if (substr($t, 0, 1) == '+') { + $allTags[] = substr($t, 1); } elseif (substr($t, 0, 1) == '-') { - $noTags[] = substr($t, 1); + $noTags[] = substr($t, 1); } else { - $anyTags[] = $t; + $anyTags[] = $t; } - } + } - if(count($allTags) > 0){ - foreach($allTags as $t){ - /* If any of the required tags is not present, return ''. */ - if(!in_array($t, $tags)){ - return ''; - } - } - } - if(count($noTags) > 0){ - foreach($noTags as $t){ - /* If any of the forbidden tags is present, return ''. */ - if(in_array($t, $tags)){ - return ''; - } - } - } + if (count($allTags) > 0) { + foreach ($allTags as $t) { + /* If any of the required tags is not present, return ''. */ + if (!in_array($t, $tags)) { + return ''; + } + } + } + if (count($noTags) > 0) { + foreach ($noTags as $t) { + /* If any of the forbidden tags is present, return ''. */ + if (in_array($t, $tags)) { + return ''; + } + } + } - if(count($anyTags) > 0){ - foreach($anyTags as $t){ - /* If any of the "any" tags is present, return the content. */ - if(in_array($t, $tags)){ - return $matches[2]; - } - } - /* If not, return ''. */ - return ''; - } + if (count($anyTags) > 0) { + foreach ($anyTags as $t) { + /* If any of the "any" tags is present, return the content. */ + if (in_array($t, $tags)) { + return $matches[2]; + } + } + /* If not, return ''. */ + return ''; + } - /* If we are here, the content should be returned. */ - return $matches[2]; + /* If we are here, the content should be returned. */ + return $matches[2]; } - } diff --git a/Text/Wiki/Parse/Default/Image.php b/Text/Wiki/Parse/Default/Image.php index 96fc621..e2d32ae 100644 --- a/Text/Wiki/Parse/Default/Image.php +++ b/Text/Wiki/Parse/Default/Image.php @@ -30,7 +30,8 @@ * */ -class Text_Wiki_Parse_Image extends Text_Wiki_Parse { +class Text_Wiki_Parse_Image extends Text_Wiki_Parse +{ /** * URL schemes recognized by this rule. @@ -53,13 +54,13 @@ class Text_Wiki_Parse_Image extends Text_Wiki_Parse { * */ - public $regex = '/' . - '(' . + public $regex = '/' . + '(' . '\[\[' . # Start opening image tag '((?:f)?[<>=])?' . # Allow f for flickr integration and <, >, = - 'image' . + 'image' . '\s+' . # Require a whitespace before parameters - ')' . + ')' . '(.+?)' . # Parameters '(?:\]\])' . # End opening image tag '(?:(.*?)' . # Capture any text inside the image element @@ -83,7 +84,8 @@ class Text_Wiki_Parse_Image extends Text_Wiki_Parse { * @return The parser object * @access public */ - function Text_Wiki_Parse_Image(&$obj) { + function Text_Wiki_Parse_Image(&$obj) + { $default = $this->conf; parent::Text_Wiki_Parse($obj); @@ -109,7 +111,8 @@ function Text_Wiki_Parse_Image(&$obj) { * */ - function process(&$matches) { + function process(&$matches) + { $pos = strpos($matches[3], ' '); if ($pos === false) { diff --git a/Text/Wiki/Parse/Default/Include.php b/Text/Wiki/Parse/Default/Include.php index 91f0904..5ef6138 100644 --- a/Text/Wiki/Parse/Default/Include.php +++ b/Text/Wiki/Parse/Default/Include.php @@ -38,7 +38,8 @@ * */ -class Text_Wiki_Parse_Include extends Text_Wiki_Parse { +class Text_Wiki_Parse_Include extends Text_Wiki_Parse +{ public $conf = array( 'base' => '/path/to/scripts/' @@ -61,79 +62,80 @@ class Text_Wiki_Parse_Include extends Text_Wiki_Parse { * */ - public $regex = '/' . - '^\[\[include\s' . # Declare include module - '([a-zA-Z0-9\s\-:]+?)' . # Name or location of component - '(\s+.*?)?' . # Parameters - '(?:\]\])$' . # Match but not capture closing tags? Ok - '/ims'; + public $regex = '/' . + '^\[\[include\s' . # Declare include module + '([a-zA-Z0-9\s\-:]+?)' . # Name or location of component + '(\s+.*?)?' . # Parameters + '(?:\]\])$' . # Match but not capture closing tags? Ok + '/ims'; - function parse(){ - $level = 0; - do{ - $oldSource = $this->wiki->source; - $this->wiki->source = preg_replace_callback( - $this->regex, array(&$this, 'process'), $this->wiki->source); - $level++; - }while($oldSource != $this->wiki->source && $level<5); - - } + function parse() + { + $level = 0; + do { + $oldSource = $this->wiki->source; + $this->wiki->source = preg_replace_callback( + $this->regex, + array(&$this, 'process'), + $this->wiki->source + ); + $level++; + } while ($oldSource != $this->wiki->source && $level<5); + } function process(&$matches) { - $pageName = WDStringUtils::toUnixName(trim($matches[1])); - - // get page source (if exists) - - $runData = Ozone::getRunData(); - $site = $runData->getTemp("site"); - - $page = DB\PagePeer::instance()->selectByName($site->getSiteId(), $pageName); - - if($page == null){ - //$output = $this->wiki->addToken( - // $this->rule, array('fromIncludeRule' => true, 'type' => 'error', 'pageName' => $pageName) - $output = "\n\n".'[[div class="error-block"]]'."\n".sprintf(_('Page to be included %s can not be found!'),htmlspecialchars($pageName))."\n".'[[/div]]'."\n\n"; - - $wiki = $this->wiki; - if($wiki->vars['inclusionsNotExist'] == null){ - $wiki->vars['inclusionsNotExist'] = array(); - } - $wiki->vars['inclusionsNotExist'][$pageName] = $pageName; - }else { - - $output = $page->getSource(); - - // prepare entry... - $wiki = $this->wiki; - if($wiki->vars['inclusions'] == null){ - $wiki->vars['inclusions'] = array(); - } - $wiki->vars['inclusions'][$page->getPageId()] = $page->getPageId(); - - // preprocess the output too!!! - // missed a few rules so far... TODO!!! - - //process the output - make substitutions. - - $subs = $matches[2]; - if($subs){ - $subsArray = explode('|', $subs); - foreach($subsArray as $sub){ - if(strpos($sub, '=') !== false){ - $pos = strpos($sub,'='); - $var = trim(substr($sub, 0, $pos)); - $value = trim(substr($sub, $pos+1)); - if($value!='' && $var != '' && preg_match('/^[a-z0-9\-\_]+$/i', $var)){ - // substitute!!! - $output = str_replace('{$'.$var.'}', $value, $output); - } - } - } - } - - } + $pageName = WDStringUtils::toUnixName(trim($matches[1])); + + // get page source (if exists) + + $runData = Ozone::getRunData(); + $site = $runData->getTemp("site"); + + $page = DB\PagePeer::instance()->selectByName($site->getSiteId(), $pageName); + + if ($page == null) { + //$output = $this->wiki->addToken( + // $this->rule, array('fromIncludeRule' => true, 'type' => 'error', 'pageName' => $pageName) + $output = "\n\n".'[[div class="error-block"]]'."\n".sprintf(_('Page to be included %s can not be found!'), htmlspecialchars($pageName))."\n".'[[/div]]'."\n\n"; + + $wiki = $this->wiki; + if ($wiki->vars['inclusionsNotExist'] == null) { + $wiki->vars['inclusionsNotExist'] = array(); + } + $wiki->vars['inclusionsNotExist'][$pageName] = $pageName; + } else { + $output = $page->getSource(); + + // prepare entry... + $wiki = $this->wiki; + if ($wiki->vars['inclusions'] == null) { + $wiki->vars['inclusions'] = array(); + } + $wiki->vars['inclusions'][$page->getPageId()] = $page->getPageId(); + + // preprocess the output too!!! + // missed a few rules so far... TODO!!! + + //process the output - make substitutions. + + $subs = $matches[2]; + if ($subs) { + $subsArray = explode('|', $subs); + foreach ($subsArray as $sub) { + if (strpos($sub, '=') !== false) { + $pos = strpos($sub, '='); + $var = trim(substr($sub, 0, $pos)); + $value = trim(substr($sub, $pos+1)); + if ($value!='' && $var != '' && preg_match('/^[a-z0-9\-\_]+$/i', $var)) { + // substitute!!! + $output = str_replace('{$'.$var.'}', $value, $output); + } + } + } + } + } // done, place the script output directly in the source return "\n\n".$output."\n\n"; } diff --git a/Text/Wiki/Parse/Default/Interwiki.php b/Text/Wiki/Parse/Default/Interwiki.php index b299cc3..007687b 100644 --- a/Text/Wiki/Parse/Default/Interwiki.php +++ b/Text/Wiki/Parse/Default/Interwiki.php @@ -34,7 +34,8 @@ * */ -class Text_Wiki_Parse_Interwiki extends Text_Wiki_Parse { +class Text_Wiki_Parse_Interwiki extends Text_Wiki_Parse +{ // double-colons won't trip up now public $regex = '([A-Za-z0-9_\.]+):((?!:)[A-Za-z0-9_\/=&~#.:;\-\+]+)'; @@ -50,17 +51,23 @@ class Text_Wiki_Parse_Interwiki extends Text_Wiki_Parse { * */ - function parse() { + function parse() + { // standalone interwiki links $tmp_regex = '/\[(' . $this->regex . ')\]/'; $this->wiki->source = preg_replace_callback( - $tmp_regex, array(&$this, 'process'), $this->wiki->source); + $tmp_regex, + array(&$this, 'process'), + $this->wiki->source + ); // described interwiki links $tmp_regex = '/\[' . $this->regex . ' (.+?)\]/'; $this->wiki->source = preg_replace_callback( - $tmp_regex, array(&$this, 'processDescr'), $this->wiki->source); - + $tmp_regex, + array(&$this, 'processDescr'), + $this->wiki->source + ); } /** @@ -84,7 +91,8 @@ function parse() { * */ - function process(&$matches) { + function process(&$matches) + { $t = substr($matches[1], strpos($matches[1], ':') + 1); $options = array('site' => $matches[2], 'page' => $matches[3], 'text' => $t); @@ -122,7 +130,8 @@ function process(&$matches) { * */ - function processDescr(&$matches) { + function processDescr(&$matches) + { $options = array('site' => strtolower($matches[1]), 'page' => $matches[2], 'text' => $matches[3]); diff --git a/Text/Wiki/Parse/Default/Italic.php b/Text/Wiki/Parse/Default/Italic.php index 7b8064f..802a1b8 100644 --- a/Text/Wiki/Parse/Default/Italic.php +++ b/Text/Wiki/Parse/Default/Italic.php @@ -33,7 +33,8 @@ * */ -class Text_Wiki_Parse_Italic extends Text_Wiki_Parse { +class Text_Wiki_Parse_Italic extends Text_Wiki_Parse +{ /** * @@ -48,8 +49,8 @@ class Text_Wiki_Parse_Italic extends Text_Wiki_Parse { * */ - public $regex = "/" . - "''(()|[^'].*)''" . + public $regex = "/" . + "''(()|[^'].*)''" . "/"; /** @@ -72,11 +73,13 @@ class Text_Wiki_Parse_Italic extends Text_Wiki_Parse { function process(&$matches) { $start = $this->wiki->addToken( - $this->rule, array('type' => 'start') + $this->rule, + array('type' => 'start') ); $end = $this->wiki->addToken( - $this->rule, array('type' => 'end') + $this->rule, + array('type' => 'end') ); return $start . $matches[1] . $end; diff --git a/Text/Wiki/Parse/Default/List.php b/Text/Wiki/Parse/Default/List.php index feec9fd..5a1f02f 100644 --- a/Text/Wiki/Parse/Default/List.php +++ b/Text/Wiki/Parse/Default/List.php @@ -36,7 +36,8 @@ * */ -class Text_Wiki_Parse_List extends Text_Wiki_Parse { +class Text_Wiki_Parse_List extends Text_Wiki_Parse +{ /** * @@ -51,17 +52,17 @@ class Text_Wiki_Parse_List extends Text_Wiki_Parse { * */ - public $regex = '/^' . - '(' . - '(\*|#) .*\n' . - ')' . - '(?!' . - '\2 |' . - '(?: ' . - '{1,}(' . - '(?:\*|#)|\n' . - ')' . - ')' . + public $regex = '/^' . + '(' . + '(\*|#) .*\n' . + ')' . + '(?!' . + '\2 |' . + '(?: ' . + '{1,}(' . + '(?:\*|#)|\n' . + ')' . + ')' . ')/Usm'; /** @@ -123,7 +124,6 @@ function process(&$matches) // 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 #) @@ -147,7 +147,6 @@ function process(&$matches) // 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 @@ -166,7 +165,6 @@ function process(&$matches) // 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 diff --git a/Text/Wiki/Parse/Default/Math.php b/Text/Wiki/Parse/Default/Math.php index 0004636..460117a 100644 --- a/Text/Wiki/Parse/Default/Math.php +++ b/Text/Wiki/Parse/Default/Math.php @@ -29,7 +29,8 @@ * */ -class Text_Wiki_Parse_Math extends Text_Wiki_Parse { +class Text_Wiki_Parse_Math extends Text_Wiki_Parse +{ static $equationsArray = array(); @@ -44,17 +45,17 @@ class Text_Wiki_Parse_Math extends Text_Wiki_Parse { * */ - public $regex = '/' . - '^' . + public $regex = '/' . + '^' . '\[\[math' . # Start opening tag '(\s+[a-z0-9_]*?)?' . # Label - '((?:\s+' . + '((?:\s+' . '[a-z0-9]+="[^"]*"' . # Parameters '))*' . # Allow any number of parameters '\s*\]\]' . # End opening tag '((?:(?R)|.)*?)\n' . # Contents - nesting is ok for some reason '\[\[\/math\]\]' . # Closing tag - '(\s|$)' . + '(\s|$)' . '/msi'; /** @@ -72,26 +73,27 @@ class Text_Wiki_Parse_Math extends Text_Wiki_Parse { * */ - function process(&$matches){ + function process(&$matches) + { - if($this->wiki->vars['math_id'] == null){ - $this->wiki->vars['math_id'] = 1; - } - $id = $this->wiki->vars['math_id']; - $this->wiki->vars['math_id']++; + if ($this->wiki->vars['math_id'] == null) { + $this->wiki->vars['math_id'] = 1; + } + $id = $this->wiki->vars['math_id']; + $this->wiki->vars['math_id']++; - $label = trim($matches[1]); - $content = trim($matches[3]); + $label = trim($matches[1]); + $content = trim($matches[3]); - if(preg_match('/\include\s*\{|\input\s*\{/is', $content)){ - throw new ProcessException("Invalid LaTeX expression(s) found."); - } + if (preg_match('/\include\s*\{|\input\s*\{/is', $content)) { + throw new ProcessException("Invalid LaTeX expression(s) found."); + } - $args = $this->getAttrs($matches[2]); - $type = $args['type']; - if(!$type || !in_array($type, array('equation', 'eqnarray'))){ - $type = 'equation'; - } + $args = $this->getAttrs($matches[2]); + $type = $args['type']; + if (!$type || !in_array($type, array('equation', 'eqnarray'))) { + $type = 'equation'; + } $options = array('label'=>$label, 'content'=>$content, 'id'=>$id, 'type' => $type); self::$equationsArray[$label] = $id; diff --git a/Text/Wiki/Parse/Default/Mathinline.php b/Text/Wiki/Parse/Default/Mathinline.php index 4b544ff..44a6e83 100644 --- a/Text/Wiki/Parse/Default/Mathinline.php +++ b/Text/Wiki/Parse/Default/Mathinline.php @@ -29,7 +29,8 @@ * */ -class Text_Wiki_Parse_Mathinline extends Text_Wiki_Parse { +class Text_Wiki_Parse_Mathinline extends Text_Wiki_Parse +{ /** * @@ -42,12 +43,12 @@ class Text_Wiki_Parse_Mathinline extends Text_Wiki_Parse { * */ - public $regex = '/' . - '\[\[' . + public $regex = '/' . + '\[\[' . '\$' . # $ '(.*?)' . # Contents '\$' . # $ - '\]\]' . + '\]\]' . '/'; /** * @@ -66,7 +67,7 @@ class Text_Wiki_Parse_Mathinline extends Text_Wiki_Parse { function process(&$matches) { - $content = trim($matches[1]); + $content = trim($matches[1]); $options = array('content'=>$content); diff --git a/Text/Wiki/Parse/Default/Module.php b/Text/Wiki/Parse/Default/Module.php index 348a08b..471c372 100644 --- a/Text/Wiki/Parse/Default/Module.php +++ b/Text/Wiki/Parse/Default/Module.php @@ -28,7 +28,8 @@ * */ -class Text_Wiki_Parse_Module extends Text_Wiki_Parse { +class Text_Wiki_Parse_Module extends Text_Wiki_Parse +{ /** * @@ -41,15 +42,15 @@ class Text_Wiki_Parse_Module extends Text_Wiki_Parse { * */ - public $regex = '/' . + public $regex = '/' . '^' . # Require start of line '\[\[module' . # Start opening tag - '\s' . + '\s' . '([a-z0-9_\-\/]+)' . # Module name, alphanumeric + some chars '(\s+.*?)?' . # Optional module parameters '\]\]' . # End opening tag - '\s*\n' . - '(?:' . + '\s*\n' . + '(?:' . '(.*?)' . # Content betweent tags - no nesting '\[\[\/module\]\]' . # Closing tag ')?' . # The content and end tag is optional @@ -70,7 +71,8 @@ class Text_Wiki_Parse_Module extends Text_Wiki_Parse { * */ - function parse() { + function parse() + { do { $oldText = ($this->wiki->source); @@ -82,19 +84,23 @@ function parse() { } while ($oldText !== $this->wiki->source); } - function process(&$matches) { + function process(&$matches) + { // check if not containing another module!!! $con = $matches[0]; if (preg_match_all( - '/' . + '/' . '^' . # Require start of line '\[\[module' . # Start opening tag - '\s' . + '\s' . '([a-z0-9_\-\/]+)' . # Module name, alphanumeric + some chars '(\s+.*?)?' . # Optional module parameters '\]\]' . # End opening tag - '/smi', $con, $dummy) > 1) { + '/smi', + $con, + $dummy + ) > 1) { return preg_replace('/^\[\[module/', '[[module654', $con); } diff --git a/Text/Wiki/Parse/Default/Module654.php b/Text/Wiki/Parse/Default/Module654.php index 5cd573d..1e99c1f 100644 --- a/Text/Wiki/Parse/Default/Module654.php +++ b/Text/Wiki/Parse/Default/Module654.php @@ -28,7 +28,8 @@ * */ -class Text_Wiki_Parse_Module654 extends Text_Wiki_Parse { +class Text_Wiki_Parse_Module654 extends Text_Wiki_Parse +{ /** * @@ -58,7 +59,8 @@ class Text_Wiki_Parse_Module654 extends Text_Wiki_Parse { * */ - function process(&$matches) { + function process(&$matches) + { $moduleName = trim($matches[1]); diff --git a/Text/Wiki/Parse/Default/Moduledelimiter.php b/Text/Wiki/Parse/Default/Moduledelimiter.php index a18f504..9459ea4 100644 --- a/Text/Wiki/Parse/Default/Moduledelimiter.php +++ b/Text/Wiki/Parse/Default/Moduledelimiter.php @@ -28,7 +28,8 @@ * */ -class Text_Wiki_Parse_Moduledelimiter extends Text_Wiki_Parse { +class Text_Wiki_Parse_Moduledelimiter extends Text_Wiki_Parse +{ /** * diff --git a/Text/Wiki/Parse/Default/Modulepre.php b/Text/Wiki/Parse/Default/Modulepre.php index b62a5d4..d58597f 100644 --- a/Text/Wiki/Parse/Default/Modulepre.php +++ b/Text/Wiki/Parse/Default/Modulepre.php @@ -27,7 +27,8 @@ * */ -class Text_Wiki_Parse_Modulepre extends Text_Wiki_Parse { +class Text_Wiki_Parse_Modulepre extends Text_Wiki_Parse +{ /** * @@ -40,15 +41,15 @@ class Text_Wiki_Parse_Modulepre extends Text_Wiki_Parse { * */ - public $regex = '/' . + public $regex = '/' . '^' . # Require start of line '\[\[module654' . # Start opening tag - '\s' . + '\s' . '([a-z0-9_\-\/]+)' . # Module name, alphanumeric + some chars '(\s+.*?)?' . # Optional module parameters '\]\]' . # End opening tag - '\s*\n' . - '(?:' . + '\s*\n' . + '(?:' . '(.*?)' . # Content betweent tags - no nesting '\[\[\/module\]\]' . # Closing tag ')?' . # The content and end tag is optional @@ -69,11 +70,11 @@ class Text_Wiki_Parse_Modulepre extends Text_Wiki_Parse { * */ - function process(&$matches) { + function process(&$matches) + { return preg_replace('/^\[\[module654/', '[[module', $matches[0]); # Seems to just replace module 654 with standard. # Backwards compatibility maybe? - } } diff --git a/Text/Wiki/Parse/Default/Newline.php b/Text/Wiki/Parse/Default/Newline.php index c4cf9cf..3dcc3f7 100644 --- a/Text/Wiki/Parse/Default/Newline.php +++ b/Text/Wiki/Parse/Default/Newline.php @@ -34,7 +34,8 @@ * */ -class Text_Wiki_Parse_Newline extends Text_Wiki_Parse { +class Text_Wiki_Parse_Newline extends Text_Wiki_Parse +{ /** * @@ -48,7 +49,7 @@ class Text_Wiki_Parse_Newline extends Text_Wiki_Parse { * @see parse() * */ - public $regex = '/' . + public $regex = '/' . '([^\n])' . # Match any character that is not a newline '\n' . # Then a newline '(?!\n)' . # ...so long as it is not followed by another newline diff --git a/Text/Wiki/Parse/Default/Note.php b/Text/Wiki/Parse/Default/Note.php index ad602e9..2f2f8b6 100644 --- a/Text/Wiki/Parse/Default/Note.php +++ b/Text/Wiki/Parse/Default/Note.php @@ -27,7 +27,8 @@ * */ -class Text_Wiki_Parse_Note extends Text_Wiki_Parse { +class Text_Wiki_Parse_Note extends Text_Wiki_Parse +{ /** * @@ -40,11 +41,11 @@ class Text_Wiki_Parse_Note extends Text_Wiki_Parse { * */ - public $regex = '/' . - '(\n)?' . - '\[\[note\]\]\n' . + public $regex = '/' . + '(\n)?' . + '\[\[note\]\]\n' . '(.*?)' . # Contents of note - no nesting - '\[\[\/note\]\]' . + '\[\[\/note\]\]' . '/msi'; /** @@ -62,7 +63,8 @@ class Text_Wiki_Parse_Note extends Text_Wiki_Parse { * */ - function process(&$matches) { + function process(&$matches) + { $content = $matches[2]; @@ -74,6 +76,5 @@ function process(&$matches) { 'type' => 'end')); return $matches[1] . $matches[1] . $start . "\n\n" . $content . "\n\n" . $end; - } } diff --git a/Text/Wiki/Parse/Default/Paragraph.php b/Text/Wiki/Parse/Default/Paragraph.php index 6517e2b..167f230 100644 --- a/Text/Wiki/Parse/Default/Paragraph.php +++ b/Text/Wiki/Parse/Default/Paragraph.php @@ -34,7 +34,8 @@ * */ -class Text_Wiki_Parse_Paragraph extends Text_Wiki_Parse { +class Text_Wiki_Parse_Paragraph extends Text_Wiki_Parse +{ /** * @@ -48,7 +49,7 @@ class Text_Wiki_Parse_Paragraph extends Text_Wiki_Parse { */ # Matches some text followed by two newlines - public $regex = '/' . + public $regex = '/' . '^' . # Start of line '.*?' . # Anything '\n' . # A newline @@ -58,7 +59,7 @@ class Text_Wiki_Parse_Paragraph extends Text_Wiki_Parse { public $conf = array( 'skip' => array('blockquote', // are we sure about this one? -'code', 'clearfloat', + 'code', 'clearfloat', 'heading', 'horiz', 'deflist', 'table', 'tableadv', 'list', 'toc', 'center', 'tabview', 'div', 'divalignleft', @@ -90,7 +91,8 @@ class Text_Wiki_Parse_Paragraph extends Text_Wiki_Parse { * */ - function process(&$matches) { + function process(&$matches) + { $delim = $this->wiki->delim; // was anything there? @@ -141,7 +143,6 @@ function process(&$matches) { // return the entire matched text. return $matches[0]; } else { - $start = $this->wiki->addToken($this->rule, array( 'type' => 'start')); diff --git a/Text/Wiki/Parse/Default/Phplookup.php b/Text/Wiki/Parse/Default/Phplookup.php index c5a1610..0383765 100644 --- a/Text/Wiki/Parse/Default/Phplookup.php +++ b/Text/Wiki/Parse/Default/Phplookup.php @@ -28,7 +28,8 @@ * */ -class Text_Wiki_Parse_Phplookup extends Text_Wiki_Parse { +class Text_Wiki_Parse_Phplookup extends Text_Wiki_Parse +{ /** * @@ -64,7 +65,8 @@ class Text_Wiki_Parse_Phplookup extends Text_Wiki_Parse { function process(&$matches) { return $this->wiki->addToken( - $this->rule, array('text' => $matches[1]) + $this->rule, + array('text' => $matches[1]) ); } } diff --git a/Text/Wiki/Parse/Default/Postfilter.php b/Text/Wiki/Parse/Default/Postfilter.php index 10019f7..18bbe72 100644 --- a/Text/Wiki/Parse/Default/Postfilter.php +++ b/Text/Wiki/Parse/Default/Postfilter.php @@ -33,7 +33,8 @@ * */ -class Text_Wiki_Parse_Postfilter extends Text_Wiki_Parse { +class Text_Wiki_Parse_Postfilter extends Text_Wiki_Parse +{ /** * @@ -46,26 +47,38 @@ class Text_Wiki_Parse_Postfilter extends Text_Wiki_Parse { function parse() { - // fix TOC tags within entries + // fix TOC tags within entries // convert DOS line endings - $this->wiki->source = str_replace("\r\n", "\n", - $this->wiki->source); + $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); + $this->wiki->source = str_replace( + "\r", + "\n", + $this->wiki->source + ); // trim "whitespace lines" $this->wiki->source = preg_replace("/^\s+$/m", '', $this->wiki->source); // concat lines ending in a backslash - $this->wiki->source = str_replace("\\\n", "", - $this->wiki->source); + $this->wiki->source = str_replace( + "\\\n", + "", + $this->wiki->source + ); // convert tabs to four-spaces - $this->wiki->source = str_replace("\t", " ", - $this->wiki->source); + $this->wiki->source = str_replace( + "\t", + " ", + $this->wiki->source + ); // add extra newlines at the top and end; this // seems to help many rules. diff --git a/Text/Wiki/Parse/Default/Prefilter.php b/Text/Wiki/Parse/Default/Prefilter.php index 8cdfee2..544cbde 100644 --- a/Text/Wiki/Parse/Default/Prefilter.php +++ b/Text/Wiki/Parse/Default/Prefilter.php @@ -33,7 +33,8 @@ * */ -class Text_Wiki_Parse_Prefilter extends Text_Wiki_Parse { +class Text_Wiki_Parse_Prefilter extends Text_Wiki_Parse +{ /** * @@ -46,12 +47,18 @@ class Text_Wiki_Parse_Prefilter extends Text_Wiki_Parse { function parse() { // convert DOS line endings - $this->wiki->source = str_replace("\r\n", "\n", - $this->wiki->source); + $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); + $this->wiki->source = str_replace( + "\r", + "\n", + $this->wiki->source + ); // trim "whitespace lines" $this->wiki->source = preg_replace("/^\s+$/m", '', $this->wiki->source); @@ -60,8 +67,11 @@ function parse() // $this->wiki->source = str_replace("\\\n", "", // convert tabs to four-spaces - $this->wiki->source = str_replace("\t", " ", - $this->wiki->source); + $this->wiki->source = str_replace( + "\t", + " ", + $this->wiki->source + ); // add extra newlines at the top and end; this // seems to help many rules. @@ -70,12 +80,14 @@ function parse() // down to two newlines. $find = "/(\n\s*){3,}/m"; $replace = "\n\n"; - $this->wiki->source = preg_replace($find, $replace, - $this->wiki->source); + $this->wiki->source = preg_replace( + $find, + $replace, + $this->wiki->source + ); $d = utf8_encode("\xFC"); $this->wiki->source = str_replace("$d$d", '', $this->wiki->source); // TODO: sth more intelligent?Prefilter.php } - } diff --git a/Text/Wiki/Parse/Default/Raw.php b/Text/Wiki/Parse/Default/Raw.php index 3c4131d..957b989 100644 --- a/Text/Wiki/Parse/Default/Raw.php +++ b/Text/Wiki/Parse/Default/Raw.php @@ -34,7 +34,8 @@ * */ -class Text_Wiki_Parse_Raw extends Text_Wiki_Parse { +class Text_Wiki_Parse_Raw extends Text_Wiki_Parse +{ /** * @@ -47,11 +48,11 @@ class Text_Wiki_Parse_Raw extends Text_Wiki_Parse { * */ - public $regex = '/' . + public $regex = '/' . '(? $matches[1]); return $this->wiki->addToken($this->rule, $options); } diff --git a/Text/Wiki/Parse/Default/Rawold.php b/Text/Wiki/Parse/Default/Rawold.php index 9c1b08e..46e857f 100644 --- a/Text/Wiki/Parse/Default/Rawold.php +++ b/Text/Wiki/Parse/Default/Rawold.php @@ -34,7 +34,8 @@ * */ -class Text_Wiki_Parse_Rawold extends Text_Wiki_Parse { +class Text_Wiki_Parse_Rawold extends Text_Wiki_Parse +{ /** * @@ -64,7 +65,8 @@ class Text_Wiki_Parse_Rawold extends Text_Wiki_Parse { * */ - function process(&$matches) { + function process(&$matches) + { $options = array('text' => $matches[1]); return $this->wiki->addToken($this->rule, $options); } diff --git a/Text/Wiki/Parse/Default/Revise.php b/Text/Wiki/Parse/Default/Revise.php index 0e2db90..f833864 100644 --- a/Text/Wiki/Parse/Default/Revise.php +++ b/Text/Wiki/Parse/Default/Revise.php @@ -28,7 +28,8 @@ * */ -class Text_Wiki_Parse_Revise extends Text_Wiki_Parse { +class Text_Wiki_Parse_Revise extends Text_Wiki_Parse +{ /** * @@ -43,10 +44,10 @@ class Text_Wiki_Parse_Revise extends Text_Wiki_Parse { * */ - public $regex = '/' . - '\@\@' . + public $regex = '/' . + '\@\@' . '(\{*?.*?\}*?)' . # Text between any number of braces, including none - '\@\@' . + '\@\@' . '/'; /** @@ -98,7 +99,6 @@ function process(&$matches) // handle text to be deleted if ($del !== false) { - // move forward to the end of the deletion mark $del += strlen($delmark); @@ -112,31 +112,34 @@ function process(&$matches) } $output .= $this->wiki->addToken( - $this->rule, array('type' => 'del_start') + $this->rule, + array('type' => 'del_start') ); $output .= $text; $output .= $this->wiki->addToken( - $this->rule, array('type' => 'del_end') + $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') + $this->rule, + array('type' => 'ins_start') ); $output .= $text; $output .= $this->wiki->addToken( - $this->rule, array('type' => 'ins_end') + $this->rule, + array('type' => 'ins_end') ); } diff --git a/Text/Wiki/Parse/Default/Separator.php b/Text/Wiki/Parse/Default/Separator.php index b34b7d4..2e46814 100644 --- a/Text/Wiki/Parse/Default/Separator.php +++ b/Text/Wiki/Parse/Default/Separator.php @@ -31,7 +31,8 @@ * */ -class Text_Wiki_Parse_Separator extends Text_Wiki_Parse { +class Text_Wiki_Parse_Separator extends Text_Wiki_Parse +{ /** * @@ -46,10 +47,10 @@ class Text_Wiki_Parse_Separator extends Text_Wiki_Parse { * */ - public $regex = '/' . - '^' . - '([=]{4,})' . # "====", four or more = - '$' . + public $regex = '/' . + '^' . + '([=]{4,})' . # "====", four or more = + '$' . '/m'; /** diff --git a/Text/Wiki/Parse/Default/Size.php b/Text/Wiki/Parse/Default/Size.php index fa55e29..603ea83 100644 --- a/Text/Wiki/Parse/Default/Size.php +++ b/Text/Wiki/Parse/Default/Size.php @@ -26,7 +26,8 @@ * */ -class Text_Wiki_Parse_Size extends Text_Wiki_Parse { +class Text_Wiki_Parse_Size extends Text_Wiki_Parse +{ /** * @@ -39,7 +40,7 @@ class Text_Wiki_Parse_Size extends Text_Wiki_Parse { * */ - public $regex = '/' . + public $regex = '/' . '\[\[size\s([^\]]+)\]\]' . # Opening tag including parameters '((?:(?R)|.)*?)' . # Any content in between including other sizes '\[\[\/size\]\]' . # Closing tag @@ -62,11 +63,11 @@ class Text_Wiki_Parse_Size extends Text_Wiki_Parse { function process(&$matches) { - $content =$matches[2]; + $content =$matches[2]; - $size = trim($matches[1]); + $size = trim($matches[1]); - $allowedSizes = array( + $allowedSizes = array( '/^[0-9\.]{1,5}(em|px|%)$/', '/^xx\-small$/', '/^x\-small$/', @@ -77,42 +78,42 @@ function process(&$matches) '/^xx\-large$/', '/^smaller$/', '/^larger$/' - ); + ); - $good = false; - foreach($allowedSizes as $as){ - if(preg_match($as, $size)){ - $good=true; - break; - } - } + $good = false; + foreach ($allowedSizes as $as) { + if (preg_match($as, $size)) { + $good=true; + break; + } + } - if($good==false){ - return $matches[0]; - } + if ($good==false) { + return $matches[0]; + } - $options = array('size'=>$size, 'type'=>'start'); + $options = array('size'=>$size, 'type'=>'start'); - $start = $this->wiki->addToken($this->rule, $options); + $start = $this->wiki->addToken($this->rule, $options); - $end = $this->wiki->addToken( - $this->rule, array('type' => 'end') - ); + $end = $this->wiki->addToken( + $this->rule, + array('type' => 'end') + ); return $start . $content .$end; - } - function parse(){ - $oldSource = $this->wiki->source; + function parse() + { + $oldSource = $this->wiki->source; $this->wiki->source = preg_replace_callback( - $this->regex, - array(&$this, 'process'), - $this->wiki->source + $this->regex, + array(&$this, 'process'), + $this->wiki->source ); - if($oldSource != $this->wiki->source){ - $this->parse(); + if ($oldSource != $this->wiki->source) { + $this->parse(); } } - } diff --git a/Text/Wiki/Parse/Default/Smiley.php b/Text/Wiki/Parse/Default/Smiley.php index eb858ea..6fda3ff 100644 --- a/Text/Wiki/Parse/Default/Smiley.php +++ b/Text/Wiki/Parse/Default/Smiley.php @@ -30,7 +30,8 @@ * @link http://pear.php.net/package/Text_Wiki * @see Text_Wiki_Parse::Text_Wiki_Parse() */ -class Text_Wiki_Parse_Smiley extends Text_Wiki_Parse { +class Text_Wiki_Parse_Smiley extends Text_Wiki_Parse +{ /** * Configuration keys for this rule @@ -146,11 +147,13 @@ function Text_Wiki_Parse_Smiley(&$obj) function process(&$matches) { // tokenize - return $this->wiki->addToken($this->rule, + return $this->wiki->addToken( + $this->rule, array( 'symbol' => $matches[1], 'name' => $this->_smileys[$matches[1]][0], 'desc' => $this->_smileys[$matches[1]][1] - )); + ) + ); } } diff --git a/Text/Wiki/Parse/Default/Social.php b/Text/Wiki/Parse/Default/Social.php index 6f6263f..c91366b 100644 --- a/Text/Wiki/Parse/Default/Social.php +++ b/Text/Wiki/Parse/Default/Social.php @@ -27,7 +27,8 @@ * */ -class Text_Wiki_Parse_Social extends Text_Wiki_Parse { +class Text_Wiki_Parse_Social extends Text_Wiki_Parse +{ /** * @@ -40,26 +41,28 @@ class Text_Wiki_Parse_Social extends Text_Wiki_Parse { * */ - public $regex = '/' . - '\[\[social' . + public $regex = '/' . + '\[\[social' . '(\s+[^\]]+?)?' . # Parameters - '\]\]' . + '\]\]' . '/is'; function process(&$matches) { $sites = trim($matches[1]); - $d = utf8_encode("\xFE"); + $d = utf8_encode("\xFE"); - $out = $d."module \"wiki/social/SocialBookmarksModule\""; - if($sites!==null && $sites!=='') {$out.=" ".urlencode('sites="'.$sites.'"')." ";} - $out.=$d; + $out = $d."module \"wiki/social/SocialBookmarksModule\""; + if ($sites!==null && $sites!=='') { + $out.=" ".urlencode('sites="'.$sites.'"')." "; + } + $out.=$d; - return $out; + return $out; /* $sites = trim($matches[1]); - $options = array('sites' => $sites); + $options = array('sites' => $sites); return $this->wiki->addToken($this->rule, $options); */ diff --git a/Text/Wiki/Parse/Default/Span.php b/Text/Wiki/Parse/Default/Span.php index f6f02ea..62cf902 100644 --- a/Text/Wiki/Parse/Default/Span.php +++ b/Text/Wiki/Parse/Default/Span.php @@ -27,7 +27,8 @@ * */ -class Text_Wiki_Parse_Span extends Text_Wiki_Parse { +class Text_Wiki_Parse_Span extends Text_Wiki_Parse +{ /** * @@ -40,12 +41,12 @@ class Text_Wiki_Parse_Span extends Text_Wiki_Parse { * */ - public $regex = '/' . - '\[\[span' . + public $regex = '/' . + '\[\[span' . '(\s.[^\]]*)?' . # Parameters - '\]\]' . + '\]\]' . '((?:(?R)|.)*?)' . # Contents - nesting is ok - '\[\[\/span\]\]' . + '\[\[\/span\]\]' . '/msi'; /** @@ -63,7 +64,8 @@ class Text_Wiki_Parse_Span extends Text_Wiki_Parse { * */ - function process(&$matches) { + function process(&$matches) + { $content = $matches[2]; @@ -83,16 +85,18 @@ function process(&$matches) { $end = $this->wiki->addToken($this->rule, array('type' => 'end')); return $start . $content . $end; - } - function parse() { + function parse() + { $oldSource = $this->wiki->source; - $this->wiki->source = preg_replace_callback($this->regex, - array(&$this, 'process'), $this->wiki->source); + $this->wiki->source = preg_replace_callback( + $this->regex, + array(&$this, 'process'), + $this->wiki->source + ); if ($oldSource != $this->wiki->source) { $this->parse(); } } - } diff --git a/Text/Wiki/Parse/Default/Strikethrough.php b/Text/Wiki/Parse/Default/Strikethrough.php index 54b86e8..604e799 100644 --- a/Text/Wiki/Parse/Default/Strikethrough.php +++ b/Text/Wiki/Parse/Default/Strikethrough.php @@ -28,7 +28,8 @@ * */ -class Text_Wiki_Parse_Strikethrough extends Text_Wiki_Parse { +class Text_Wiki_Parse_Strikethrough extends Text_Wiki_Parse +{ /** * @@ -43,10 +44,10 @@ class Text_Wiki_Parse_Strikethrough extends Text_Wiki_Parse { * */ - public $regex = '/' . - '\-\-' . + public $regex = '/' . + '\-\-' . '([^\s](?:.*?[^\s])?)' . # Match anything that does not start or end with whitespace - '\-\-' . + '\-\-' . '/'; /** @@ -65,7 +66,8 @@ class Text_Wiki_Parse_Strikethrough extends Text_Wiki_Parse { * */ - function process(&$matches) { + function process(&$matches) + { $start = $this->wiki->addToken($this->rule, array( 'type' => 'start')); $end = $this->wiki->addToken($this->rule, array( diff --git a/Text/Wiki/Parse/Default/Strong.php b/Text/Wiki/Parse/Default/Strong.php index 97ad368..e93b9ac 100644 --- a/Text/Wiki/Parse/Default/Strong.php +++ b/Text/Wiki/Parse/Default/Strong.php @@ -36,7 +36,8 @@ * */ -class Text_Wiki_Parse_Strong extends Text_Wiki_Parse { +class Text_Wiki_Parse_Strong extends Text_Wiki_Parse +{ /** * @@ -51,10 +52,10 @@ class Text_Wiki_Parse_Strong extends Text_Wiki_Parse { * */ - public $regex = '/' . - '\*\*' . + public $regex = '/' . + '\*\*' . '([^\s\n](?:.*?[^\s\n])?)' . # Match anything that does not start or end with whitespace - '\*\*' . + '\*\*' . '/'; /** @@ -73,7 +74,8 @@ class Text_Wiki_Parse_Strong extends Text_Wiki_Parse { * */ - function process(&$matches) { + function process(&$matches) + { $start = $this->wiki->addToken($this->rule, array( 'type' => 'start')); diff --git a/Text/Wiki/Parse/Default/Subscript.php b/Text/Wiki/Parse/Default/Subscript.php index b018efa..7f2e1e5 100644 --- a/Text/Wiki/Parse/Default/Subscript.php +++ b/Text/Wiki/Parse/Default/Subscript.php @@ -30,7 +30,8 @@ * */ -class Text_Wiki_Parse_Subscript extends Text_Wiki_Parse { +class Text_Wiki_Parse_Subscript extends Text_Wiki_Parse +{ /** * @@ -45,10 +46,10 @@ class Text_Wiki_Parse_Subscript extends Text_Wiki_Parse { * */ - public $regex = '/' . - ',,' . + public $regex = '/' . + ',,' . '([^\s](?:.*?[^\s])?)' . # Match anything that does not start or end with whitespace - ',,' . + ',,' . '/'; /** @@ -67,7 +68,8 @@ class Text_Wiki_Parse_Subscript extends Text_Wiki_Parse { * */ - function process(&$matches) { + function process(&$matches) + { $start = $this->wiki->addToken($this->rule, array( 'type' => 'start')); diff --git a/Text/Wiki/Parse/Default/Superscript.php b/Text/Wiki/Parse/Default/Superscript.php index ce1794d..810ed00 100644 --- a/Text/Wiki/Parse/Default/Superscript.php +++ b/Text/Wiki/Parse/Default/Superscript.php @@ -30,7 +30,8 @@ * */ -class Text_Wiki_Parse_Superscript extends Text_Wiki_Parse { +class Text_Wiki_Parse_Superscript extends Text_Wiki_Parse +{ /** * @@ -45,10 +46,10 @@ class Text_Wiki_Parse_Superscript extends Text_Wiki_Parse { * */ - public $regex = '/' . - '\^\^' . + public $regex = '/' . + '\^\^' . '([^\s](?:.*?[^\s])?)' . # Match anything that does not start or end with whitespace - '\^\^' . + '\^\^' . '/'; /** @@ -70,11 +71,13 @@ class Text_Wiki_Parse_Superscript extends Text_Wiki_Parse { function process(&$matches) { $start = $this->wiki->addToken( - $this->rule, array('type' => 'start') + $this->rule, + array('type' => 'start') ); $end = $this->wiki->addToken( - $this->rule, array('type' => 'end') + $this->rule, + array('type' => 'end') ); return $start . $matches[1] . $end; diff --git a/Text/Wiki/Parse/Default/Table.php b/Text/Wiki/Parse/Default/Table.php index ff9ecef..3a53f54 100644 --- a/Text/Wiki/Parse/Default/Table.php +++ b/Text/Wiki/Parse/Default/Table.php @@ -34,7 +34,8 @@ * */ -class Text_Wiki_Parse_Table extends Text_Wiki_Parse { +class Text_Wiki_Parse_Table extends Text_Wiki_Parse +{ /** * @@ -49,12 +50,12 @@ class Text_Wiki_Parse_Table extends Text_Wiki_Parse { * */ - public $regex = '/' . - '\n' . - '(' . + public $regex = '/' . + '\n' . + '(' . '(\|\|)' . # || '.*?' . # Contents of rest of row - ')' . + ')' . '(\n)' . # Newline '(?!(\|\|))' . # Assert that the newline is not followed by || '/s'; @@ -106,7 +107,6 @@ function process(&$matches) // loop through each row foreach ($rows as $row) { - // increase the row count $num_rows ++; @@ -136,18 +136,14 @@ function process(&$matches) // 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 @@ -196,7 +192,6 @@ function process(&$matches) // reset the span. $span = 1; } - } // end the row @@ -204,7 +199,6 @@ function process(&$matches) $this->rule, array('type' => 'row_end') ); - } // wrap the return value in start and end tokens diff --git a/Text/Wiki/Parse/Default/Tableadv.php b/Text/Wiki/Parse/Default/Tableadv.php index 8203936..f583b31 100644 --- a/Text/Wiki/Parse/Default/Tableadv.php +++ b/Text/Wiki/Parse/Default/Tableadv.php @@ -27,28 +27,30 @@ * */ -class Text_Wiki_Parse_Tableadv extends Text_Wiki_Parse { +class Text_Wiki_Parse_Tableadv extends Text_Wiki_Parse +{ - public $regex = ';' . + public $regex = ';' . '\n\[\[table' . # Start a table after a new line '(\s.*?)?\]\]' . # Allow parameters on the table - '(\s*' . + '(\s*' . '(?:\[\[row' . # Start a row '(?:\s[^\]]*)?' . # Allow parameters on the row - '\]\]\s*' . + '\]\]\s*' . '(?:\[\[(column|col|cell)' . # Start a column or cell '(?:\s[^\]]*)?\]\]' . # Allow parameters on the column or cell '(?:(?R)|.)*?' . # Cell contents: another table, or anything else '\[\[/(column|col|cell)' . # End the column or cell '\]\]\s*)+' . # Allow at least one column or cell '\[\[/row\]\]\s*)+' . # Allow at least one row - ')' . + ')' . '\[\[/table\]\]\n' . # Force a new line after the table ';sxi'; private $_tmpSource = null; - function process(&$matches) { + function process(&$matches) + { $content = $matches[2]; $attr = $this->getAttrs(trim($matches[1])); $options = array(); @@ -63,54 +65,70 @@ function process(&$matches) { $content = preg_replace_callback( - $this->regex, array(&$this, 'process'), $content); + $this->regex, + array(&$this, 'process'), + $content + ); // look for rows - $content = preg_replace_callback( ';' . + $content = preg_replace_callback( + ';' . '(?:\n)?' . # Allow an optional new line '\[\[row' . # Start a new row '(\s[^\]]*)?' . # Allow parameters on row - '\]\]\s*' . - '(' . - '(' . - '\[\[' . + '\]\]\s*' . + '(' . + '(' . + '\[\[' . '(column|col|cell)' . # Start a new column or cell '(\s[^\]]*)?' . # Allow parameters on column or cell - '\]\].*?' . + '\]\].*?' . '' . # No content is permitted - '\[\[/' . + '\[\[/' . '(column|col|cell)' . # Close column or cell - '\]\]\s*' . - ')+' . + '\]\]\s*' . + ')+' . ')\[\[/row\]\]' . # Close row '(?:\n)?' . # Allow an optional new line ';msix', - array($this, '_handleRow'), $content); - - $start = $this->wiki->addToken($this->rule, - array_merge($options, array('type' => 'start'))); + array($this, '_handleRow'), + $content + ); + + $start = $this->wiki->addToken( + $this->rule, + array_merge($options, array('type' => 'start')) + ); $end = $this->wiki->addToken($this->rule, array('type' => 'end')); return "\n\n" . $start . $content . $end . "\n\n"; } - function parse() { + function parse() + { $this->wiki->source = preg_replace_callback( - $this->regex, array(&$this, 'process'), $this->wiki->source); + $this->regex, + array(&$this, 'process'), + $this->wiki->source + ); } - private function _handleRow($matches) { + private function _handleRow($matches) + { $content = $matches[2]; $attr = $this->getAttrs(trim($matches[1])); - $content = preg_replace_callback( ';' . + $content = preg_replace_callback( + ';' . '(?:\n)?' . # Optional new line '\[\[(?:column|col|cell)(\s[^\]]*)?\]\]' . # Opening column or cell '(.*?)' . # Content (anything) '\[\[/(column|col|cell)\]\]' . # Closing column or cell '(?:\n)?' . # Optional new line ';msix', - array($this, '_handleCell'), $content); + array($this, '_handleCell'), + $content + ); $options = array(); if ($attr['class']) { $options['class'] = $attr['class']; @@ -123,10 +141,10 @@ private function _handleRow($matches) { $end = $this->wiki->addToken($this->rule, array( 'type' => 'rowEnd')); return $start . $content . $end; - } - private function _handleCell($matches) { + private function _handleCell($matches) + { $content = $matches[2]; $attr = $this->getAttrs(trim($matches[1])); $options = array(); diff --git a/Text/Wiki/Parse/Default/Tabview.php b/Text/Wiki/Parse/Default/Tabview.php index 8472a0e..32ec089 100644 --- a/Text/Wiki/Parse/Default/Tabview.php +++ b/Text/Wiki/Parse/Default/Tabview.php @@ -26,7 +26,8 @@ * */ -class Text_Wiki_Parse_Tabview extends Text_Wiki_Parse { +class Text_Wiki_Parse_Tabview extends Text_Wiki_Parse +{ private static $_counter = 0; @@ -41,17 +42,17 @@ class Text_Wiki_Parse_Tabview extends Text_Wiki_Parse { * */ - public $regex = '/' . - '^' . + public $regex = '/' . + '^' . '\[\[(?:tabview|tabs)(\s.*?)?\]\]' . # Start tabview with parameters - '\s*' . + '\s*' . '(' . # Capture all tabs as a single group '(?:\[\[tab(\s.*?)?\]\]' . # Tab opening tag, with parameters '.*?' . # Contents of tab - no nesting '\[\[\/tab\]\]' . # Tab closing tag - '\s*' . + '\s*' . ')+' . # Require at least one tab - ')' . + ')' . '\[\[\/(?:tabview|tabs)\]\]\s*' . # Tabview closing tag '/msi'; @@ -61,7 +62,8 @@ class Text_Wiki_Parse_Tabview extends Text_Wiki_Parse { private $_tabCounter = 0; - function process(&$matches) { + function process(&$matches) + { $this->_tabs = array(); $this->_tabCounter = 0; @@ -88,21 +90,24 @@ function process(&$matches) { // find tabs - $content = preg_replace_callback( '/' . + $content = preg_replace_callback( + '/' . '\[\[tab' . # Single tab opening tag '(\s+[^\]]+?)?' . # Title of tab '(' . # Extract parameters - '(?:\s+' . - '[a-z0-9\-_]+' . - '=' . + '(?:\s+' . + '[a-z0-9\-_]+' . + '=' . '"[^"]+"' . # Parameter value is in quotes ')+' . # At least one parameter, if any are present ')?' . # Parameters are optional - '\]\]' . + '\]\]' . '(.*?)' . # Contents of tab - cannot contain [[tab]] '\[\[\/tab\]\]\n*' . # Tab closing tag '/msi', - array($this, '_handleTab'), $content); + array($this, '_handleTab'), + $content + ); $options = array('args' => $args, 'type' => 'start', 'tabs' => $this->_tabs, @@ -116,10 +121,10 @@ function process(&$matches) { self::$_counter++; return $matches[1] . $matches[1] . $start . "\n\n" . $content . "\n\n" . $end; - } - function parse() { + function parse() + { $oldSource = $this->wiki->source; $this->wiki->source = preg_replace_callback($this->regex, array( @@ -129,21 +134,24 @@ function parse() { } } - protected function _handleTab($matches) { + protected function _handleTab($matches) + { $argString = trim($matches[2]); // bad hack - I will forgget how it works in a few minutes $ff = false; - if (preg_match( '/' . + if (preg_match( + '/' . '^' . # Start of text '[a-z0-9\-_]+' . # Parameter name - '=' . + '=' . '"[^"]+"' . # Parameter value in quotes '$' . # End of text '/si', - trim($matches[1]))) { + trim($matches[1]) + )) { $argString .= ' ' . $matches[1]; $ff = true; - } + } $args = $this->getAttrs($argString); if (!isset($args['title']) && !$ff) { $args['title'] = trim($matches[1]); @@ -158,5 +166,4 @@ protected function _handleTab($matches) { $this->_tabCounter++; return $startTabToken . "\n\n" . $content . "\n\n" . $this->_endTabToken; } - } diff --git a/Text/Wiki/Parse/Default/Tighten.php b/Text/Wiki/Parse/Default/Tighten.php index f444cc4..9252015 100644 --- a/Text/Wiki/Parse/Default/Tighten.php +++ b/Text/Wiki/Parse/Default/Tighten.php @@ -28,7 +28,8 @@ * */ -class Text_Wiki_Parse_Tighten extends Text_Wiki_Parse { +class Text_Wiki_Parse_Tighten extends Text_Wiki_Parse +{ /** * @@ -40,7 +41,10 @@ class Text_Wiki_Parse_Tighten extends Text_Wiki_Parse { function parse() { - $this->wiki->source = str_replace("\n", '', - $this->wiki->source); + $this->wiki->source = str_replace( + "\n", + '', + $this->wiki->source + ); } } diff --git a/Text/Wiki/Parse/Default/Toc.php b/Text/Wiki/Parse/Default/Toc.php index b92dbd6..45729a1 100644 --- a/Text/Wiki/Parse/Default/Toc.php +++ b/Text/Wiki/Parse/Default/Toc.php @@ -34,7 +34,8 @@ * */ -class Text_Wiki_Parse_Toc extends Text_Wiki_Parse { +class Text_Wiki_Parse_Toc extends Text_Wiki_Parse +{ /** * @@ -49,14 +50,14 @@ class Text_Wiki_Parse_Toc extends Text_Wiki_Parse { * */ - public $regex = '/' . + public $regex = '/' . '^' . # Start of line '(?:\n*)' . # Allow any number of newlines (why) - '\[\[' . + '\[\[' . '(f[<>])?' . # Float direction - f> or f< - 'toc' . + 'toc' . '(\s.*)?' . # Parameters - '\]\]' . + '\]\]' . '(\n)*' . # Allow any number of newlines '/m'; # The newlines capture may interfere with a [[newlines]] module @@ -101,12 +102,11 @@ function process(&$matches) ) ); - if(strtolower($this->wiki->currentFormat) == 'xhtmleditable'){ - return "\n\n$output\n\n"; + if (strtolower($this->wiki->currentFormat) == 'xhtmleditable') { + return "\n\n$output\n\n"; } foreach ($this->wiki->getTokens('Heading') as $key => $val) { - if ($val[1]['type'] != 'start') { continue; } @@ -132,7 +132,8 @@ function process(&$matches) } $output .= $this->wiki->addToken( - $this->rule, array( + $this->rule, + array( 'type' => 'list_end', 'level' => 0, 'align' => $matches[1] diff --git a/Text/Wiki/Parse/Default/Tt.php b/Text/Wiki/Parse/Default/Tt.php index e172e7e..ed69cbd 100644 --- a/Text/Wiki/Parse/Default/Tt.php +++ b/Text/Wiki/Parse/Default/Tt.php @@ -39,7 +39,8 @@ * */ -class Text_Wiki_Parse_Tt extends Text_Wiki_Parse { +class Text_Wiki_Parse_Tt extends Text_Wiki_Parse +{ /** * @@ -53,10 +54,10 @@ class Text_Wiki_Parse_Tt extends Text_Wiki_Parse { * */ - public $regex = '/' . - '\{\{' . + public $regex = '/' . + '\{\{' . '(\{*?.*?\}*?)' . # Allows }, then text, then }. Sorry, what? - '\}\}' . + '\}\}' . '/'; /** @@ -75,11 +76,13 @@ class Text_Wiki_Parse_Tt extends Text_Wiki_Parse { function process(&$matches) { $start = $this->wiki->addToken( - $this->rule, array('type' => 'start') + $this->rule, + array('type' => 'start') ); $end = $this->wiki->addToken( - $this->rule, array('type' => 'end') + $this->rule, + array('type' => 'end') ); return $start . $matches[1] . $end; diff --git a/Text/Wiki/Parse/Default/Typography.php b/Text/Wiki/Parse/Default/Typography.php index 30ca8ac..633b000 100644 --- a/Text/Wiki/Parse/Default/Typography.php +++ b/Text/Wiki/Parse/Default/Typography.php @@ -26,7 +26,8 @@ * */ -class Text_Wiki_Parse_Typography extends Text_Wiki_Parse { +class Text_Wiki_Parse_Typography extends Text_Wiki_Parse +{ /** * @@ -54,11 +55,12 @@ class Text_Wiki_Parse_Typography extends Text_Wiki_Parse { * */ - function process(&$matches) { - + function process(&$matches) + { } - public function parse() { + public function parse() + { $source = $this->wiki->source; // fix a few typography things now... diff --git a/Text/Wiki/Parse/Default/Underline.php b/Text/Wiki/Parse/Default/Underline.php index 65e5619..ee845bb 100644 --- a/Text/Wiki/Parse/Default/Underline.php +++ b/Text/Wiki/Parse/Default/Underline.php @@ -36,7 +36,8 @@ * */ -class Text_Wiki_Parse_Underline extends Text_Wiki_Parse { +class Text_Wiki_Parse_Underline extends Text_Wiki_Parse +{ /** * @@ -51,10 +52,10 @@ class Text_Wiki_Parse_Underline extends Text_Wiki_Parse { * */ - public $regex = '/' . - '__' . + public $regex = '/' . + '__' . '([^\s](?:.*?[^\s])?)' . # Match anything so long as it does not start or end with whitespace - '__' . + '__' . '/'; /** @@ -73,7 +74,8 @@ class Text_Wiki_Parse_Underline extends Text_Wiki_Parse { * */ - function process(&$matches) { + function process(&$matches) + { $start = $this->wiki->addToken($this->rule, array( 'type' => 'start')); $end = $this->wiki->addToken($this->rule, array( diff --git a/Text/Wiki/Parse/Default/Url.php b/Text/Wiki/Parse/Default/Url.php index 31b137e..ea5b8d1 100644 --- a/Text/Wiki/Parse/Default/Url.php +++ b/Text/Wiki/Parse/Default/Url.php @@ -49,7 +49,8 @@ * */ -class Text_Wiki_Parse_Url extends Text_Wiki_Parse { +class Text_Wiki_Parse_Url extends Text_Wiki_Parse +{ /** * @@ -122,7 +123,6 @@ function Text_Wiki_Parse_Url(&$obj) "[^ \\/\"\'{$this->wiki->delim}]*\\/" . // no spaces, backslashes, slashes, double-quotes, single quotes, or delimiters; ")*" . // end pattern "[^ \\t\\n\\/\"{$this->wiki->delim}]*)"; - } /** @@ -141,16 +141,16 @@ function parse() // // the regular expression for this kind of URL - $tmp_regex = "/" . - "\[(\*)?" . - "(" . - "(?:".$this->regexLiberal.")" . + $tmp_regex = "/" . + "\[(\*)?" . + "(" . + "(?:".$this->regexLiberal.")" . + "|" . + "(?:#[a-zA-Z0-9_\-%]*)" . "|" . - "(?:#[a-zA-Z0-9_\-%]*)" . - "|" . - "(?:\/[^\s\t\n\"'".$this->wiki->delim."]*)" . - ")\s" . - "([^\]".$this->wiki->delim."]+)\]" . + "(?:\/[^\s\t\n\"'".$this->wiki->delim."]*)" . + ")\s" . + "([^\]".$this->wiki->delim."]+)\]" . "/"; // use a custom callback processing method to generate @@ -163,27 +163,27 @@ function parse() $postVars = $this->getConf("post_vars"); - if($postVars){ + if ($postVars) { // enable %%foo%% variables to act in described links # What is this? I haven't seen it before - $tmp_regex = '/' . + $tmp_regex = '/' . '\[' . # Opening bracket - '(\*)?' . - '(' . + '(\*)?' . + '(' . '%%' . # Opening %% '[^%]+' . # Then at least one character not % '%%' . # Closing %% '[^\s]*' . # Then anything except whitespace - ')' . + ')' . '\s' . # A whitespace '([^\]]+)' . # Match anything up until a closing bracket - '\]' . + '\]' . '/'; $this->wiki->source = preg_replace_callback( $tmp_regex, array(&$this, 'processPV'), $this->wiki->source - ); + ); } // ------------------------------------------------------------- @@ -193,10 +193,10 @@ function parse() // the regular expression for this kind of URL - $tmp_regex = '/' . + $tmp_regex = '/' . '(^|[^A-Za-z])' . # Start of line OR not letters '(\*)?' . # Any amount of asterisks - '(' . $this->regex . ')' . + '(' . $this->regex . ')' . '(.*?)' . # Then anything, but as few as possible? '/'; @@ -232,8 +232,8 @@ function process(&$matches) 'text' => $matches[3] ); - if($matches[2] == '*'){ - $options['target']='_blank'; + if ($matches[2] == '*') { + $options['target']='_blank'; } // tokenize return $matches[1] . $this->wiki->addToken($this->rule, $options) . $matches[6]; @@ -268,25 +268,25 @@ function processDescr(&$matches) 'text' => $matches[3] ); - if($matches[1] == '*'){ - $options['target']='_blank'; + if ($matches[1] == '*') { + $options['target']='_blank'; } // tokenize return $this->wiki->addToken($this->rule, $options); } - function processPV(&$matches) + function processPV(&$matches) { // set options $options = array( - 'type' => 'descr', - 'href' => $matches[2], - 'text' => $matches[3] + 'type' => 'descr', + 'href' => $matches[2], + 'text' => $matches[3] ); - if($matches[1] == '*'){ - $options['target']='_blank'; + if ($matches[1] == '*') { + $options['target']='_blank'; } // tokenize diff --git a/Text/Wiki/Parse/Default/User.php b/Text/Wiki/Parse/Default/User.php index 40eb6b6..7f2f932 100644 --- a/Text/Wiki/Parse/Default/User.php +++ b/Text/Wiki/Parse/Default/User.php @@ -25,7 +25,8 @@ * */ -class Text_Wiki_Parse_User extends Text_Wiki_Parse { +class Text_Wiki_Parse_User extends Text_Wiki_Parse +{ /** * @@ -38,15 +39,16 @@ class Text_Wiki_Parse_User extends Text_Wiki_Parse { * */ - public $regex = '/' . - '\[\[' . + public $regex = '/' . + '\[\[' . '(\*)?' . # Optional asterisk - 'user\s' . + 'user\s' . '([^\]]+)' . # Parameters (e.g. user name) - '\]\]' . + '\]\]' . '/i'; - function process(&$matches) { + function process(&$matches) + { $userName = $matches[2]; $options = array('userName' => $userName); if ($matches[1] == '*') { @@ -54,6 +56,5 @@ function process(&$matches) { } return $this->wiki->addToken($this->rule, $options); - } } diff --git a/Text/Wiki/Parse/Default/Wikilink.php b/Text/Wiki/Parse/Default/Wikilink.php index a320ec5..b56d491 100644 --- a/Text/Wiki/Parse/Default/Wikilink.php +++ b/Text/Wiki/Parse/Default/Wikilink.php @@ -42,10 +42,11 @@ * */ -class Text_Wiki_Parse_Wikilink extends Text_Wiki_Parse { +class Text_Wiki_Parse_Wikilink extends Text_Wiki_Parse +{ public $conf = array ( - 'ext_chars' => false + 'ext_chars' => false ); /** @@ -66,19 +67,19 @@ function Text_Wiki_Parse_Wikilink(&$obj) parent::Text_Wiki_Parse($obj); if ($this->getConf('ext_chars')) { - // use an extended character set; this should - // allow for umlauts and so on. taken from the - // Tavi project defaults.php file. - $upper = "A-Z\xc0-\xde"; - $lower = "a-z0-9\xdf-\xfe"; - $either = "A-Za-z0-9\xc0-\xfe"; - } else { - // the default character set, should be fine - // for most purposes. - $upper = "A-Z"; - $lower = "a-z0-9"; - $either = "A-Za-z0-9"; - } + // use an extended character set; this should + // allow for umlauts and so on. taken from the + // Tavi project defaults.php file. + $upper = "A-Z\xc0-\xde"; + $lower = "a-z0-9\xdf-\xfe"; + $either = "A-Za-z0-9\xc0-\xfe"; + } else { + // the default character set, should be fine + // for most purposes. + $upper = "A-Z"; + $lower = "a-z0-9"; + $either = "A-Za-z0-9"; + } // build the regular expression for finding WikiPage names. $this->regex = @@ -119,10 +120,10 @@ function parse() // standalone wiki links if ($this->getConf('ext_chars')) { - $either = "A-Za-z0-9\xc0-\xfe"; - } else { - $either = "A-Za-z0-9"; - } + $either = "A-Za-z0-9\xc0-\xfe"; + } else { + $either = "A-Za-z0-9"; + } $tmp_regex = "/(^|[^{$either}\-_]){$this->regex}/"; $this->wiki->source = preg_replace_callback( diff --git a/Text/Wiki/Render.php b/Text/Wiki/Render.php index 663c727..2289b88 100644 --- a/Text/Wiki/Render.php +++ b/Text/Wiki/Render.php @@ -23,7 +23,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render { +class Text_Wiki_Render +{ /** * @@ -108,20 +109,17 @@ function Text_Wiki_Render(&$obj) 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, @@ -179,8 +177,8 @@ function formatConf($format, $key) } } - function renderError($message){ - return '
'.$message.'
'; + function renderError($message) + { + return '
'.$message.'
'; } - } diff --git a/Text/Wiki/Render/Xhtml.php b/Text/Wiki/Render/Xhtml.php index 168c213..31adfad 100644 --- a/Text/Wiki/Render/Xhtml.php +++ b/Text/Wiki/Render/Xhtml.php @@ -23,12 +23,13 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml extends Text_Wiki_Render +{ public $conf = array( - 'translate' => HTML_SPECIALCHARS, - 'quotes' => ENT_COMPAT, - 'charset' => 'UTF-8' + 'translate' => HTML_SPECIALCHARS, + 'quotes' => ENT_COMPAT, + 'charset' => 'UTF-8' ); function pre() @@ -41,50 +42,50 @@ function pre() // have to check null and false because HTML_ENTITIES is a zero if ($type === HTML_ENTITIES) { + // keep a copy of the translated version of the delimiter + // so we can convert it back. + $new_delim = htmlentities($this->wiki->delim, $quotes, $charset); - // keep a copy of the translated version of the delimiter - // so we can convert it back. - $new_delim = htmlentities($this->wiki->delim, $quotes, $charset); + // convert the entities. we silence the call here so that + // errors about charsets don't pop up, per counsel from + // Jan at Horde. (http://pear.php.net/bugs/bug.php?id=4474) + $this->wiki->source = htmlentities( + $this->wiki->source, + $quotes, + $charset + ); - // convert the entities. we silence the call here so that - // errors about charsets don't pop up, per counsel from - // Jan at Horde. (http://pear.php.net/bugs/bug.php?id=4474) - $this->wiki->source = htmlentities( - $this->wiki->source, - $quotes, - $charset - ); + // re-convert the delimiter + $this->wiki->source = str_replace( + $new_delim, + $this->wiki->delim, + $this->wiki->source + ); + } elseif ($type === HTML_SPECIALCHARS) { + // keep a copy of the translated version of the delimiter + // so we can convert it back. + $new_delim = htmlspecialchars($this->wiki->delim, $quotes); - // re-convert the delimiter - $this->wiki->source = str_replace( - $new_delim, $this->wiki->delim, $this->wiki->source - ); - - } elseif ($type === HTML_SPECIALCHARS) { - - // keep a copy of the translated version of the delimiter - // so we can convert it back. - $new_delim = htmlspecialchars($this->wiki->delim, $quotes); - - // convert the entities. we silence the call here so that - // errors about charsets don't pop up, per counsel from - // Jan at Horde. (http://pear.php.net/bugs/bug.php?id=4474) - $this->wiki->source = htmlspecialchars( - $this->wiki->source, - $quotes, + // convert the entities. we silence the call here so that + // errors about charsets don't pop up, per counsel from + // Jan at Horde. (http://pear.php.net/bugs/bug.php?id=4474) + $this->wiki->source = htmlspecialchars( + $this->wiki->source, + $quotes, 'ISO-8859-1' - ); + ); - // re-convert the delimiter - $this->wiki->source = str_replace( - $new_delim, $this->wiki->delim, $this->wiki->source - ); - } + // re-convert the delimiter + $this->wiki->source = str_replace( + $new_delim, + $this->wiki->delim, + $this->wiki->source + ); + } } function post() { return; } - } diff --git a/Text/Wiki/Render/Xhtml/Anchor.php b/Text/Wiki/Render/Xhtml/Anchor.php index 4a87c63..dac1833 100644 --- a/Text/Wiki/Render/Xhtml/Anchor.php +++ b/Text/Wiki/Render/Xhtml/Anchor.php @@ -23,7 +23,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Anchor extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Anchor extends Text_Wiki_Render +{ public $conf = array( 'css' => null @@ -33,7 +34,7 @@ function token($options) { extract($options); // $type, $name - $format = ""; - return sprintf($format, htmlentities($name)); + $format = ""; + return sprintf($format, htmlentities($name)); } } diff --git a/Text/Wiki/Render/Xhtml/Bibcite.php b/Text/Wiki/Render/Xhtml/Bibcite.php index 5770f40..f6fe756 100644 --- a/Text/Wiki/Render/Xhtml/Bibcite.php +++ b/Text/Wiki/Render/Xhtml/Bibcite.php @@ -19,7 +19,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Bibcite extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Bibcite extends Text_Wiki_Render +{ public $conf = array(); @@ -36,7 +37,8 @@ class Text_Wiki_Render_Xhtml_Bibcite extends Text_Wiki_Render { * */ - function token($options) { + function token($options) + { $label = $options['label']; $id = $this->wiki->vars['bibitemIds'][$label]; $idPrefix = $this->wiki->getRenderConf('xhtml', 'bibitem', 'id_prefix'); diff --git a/Text/Wiki/Render/Xhtml/Bibitem.php b/Text/Wiki/Render/Xhtml/Bibitem.php index 8159ecc..7375267 100644 --- a/Text/Wiki/Render/Xhtml/Bibitem.php +++ b/Text/Wiki/Render/Xhtml/Bibitem.php @@ -20,7 +20,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Bibitem extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Bibitem extends Text_Wiki_Render +{ public $conf = array(); @@ -37,7 +38,8 @@ class Text_Wiki_Render_Xhtml_Bibitem extends Text_Wiki_Render { * */ - function token($options) { + function token($options) + { if ($options['type'] == "start") { $idPrefix = $this->getConf("id_prefix"); $label = $options['label']; @@ -49,5 +51,4 @@ function token($options) { return ''; } } - } diff --git a/Text/Wiki/Render/Xhtml/Bibliography.php b/Text/Wiki/Render/Xhtml/Bibliography.php index 8d4a5d0..f6fae70 100644 --- a/Text/Wiki/Render/Xhtml/Bibliography.php +++ b/Text/Wiki/Render/Xhtml/Bibliography.php @@ -20,7 +20,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Bibliography extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Bibliography extends Text_Wiki_Render +{ public $conf = array(); @@ -37,7 +38,8 @@ class Text_Wiki_Render_Xhtml_Bibliography extends Text_Wiki_Render { * */ - function token($options) { + function token($options) + { //if(count($bibitems) == 0){return '';} // render nothing if no footnotes. if ($options['type'] == 'start') { $title = $options['title']; @@ -53,6 +55,5 @@ function token($options) { if ($options['type'] == 'end') { return ''; } - } } diff --git a/Text/Wiki/Render/Xhtml/Blockquote.php b/Text/Wiki/Render/Xhtml/Blockquote.php index 438e934..0082a97 100644 --- a/Text/Wiki/Render/Xhtml/Blockquote.php +++ b/Text/Wiki/Render/Xhtml/Blockquote.php @@ -23,7 +23,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Blockquote extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Blockquote extends Text_Wiki_Render +{ public $conf = array( 'css' => null diff --git a/Text/Wiki/Render/Xhtml/Bold.php b/Text/Wiki/Render/Xhtml/Bold.php index e5c07f5..c936844 100644 --- a/Text/Wiki/Render/Xhtml/Bold.php +++ b/Text/Wiki/Render/Xhtml/Bold.php @@ -23,7 +23,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Bold extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Bold extends Text_Wiki_Render +{ public $conf = array( 'css' => null diff --git a/Text/Wiki/Render/Xhtml/Box.php b/Text/Wiki/Render/Xhtml/Box.php index 12ed00d..0c0d9e3 100644 --- a/Text/Wiki/Render/Xhtml/Box.php +++ b/Text/Wiki/Render/Xhtml/Box.php @@ -23,7 +23,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Box extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Box extends Text_Wiki_Render +{ public $conf = array( 'css' => null diff --git a/Text/Wiki/Render/Xhtml/Break.php b/Text/Wiki/Render/Xhtml/Break.php index 51bfebf..50a488e 100644 --- a/Text/Wiki/Render/Xhtml/Break.php +++ b/Text/Wiki/Render/Xhtml/Break.php @@ -23,7 +23,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Break extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Break extends Text_Wiki_Render +{ public $conf = array( 'css' => null diff --git a/Text/Wiki/Render/Xhtml/Button.php b/Text/Wiki/Render/Xhtml/Button.php index 8238cc2..5b2a1b0 100644 --- a/Text/Wiki/Render/Xhtml/Button.php +++ b/Text/Wiki/Render/Xhtml/Button.php @@ -18,90 +18,91 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Button extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Button extends Text_Wiki_Render +{ public $conf = array(); - function token($options){ - - $type = $options['type']; - $text = $options['text']; - $style = $options['style']; - $class = $options['class']; - - $allowedTypes = array( - 'edit', - 'edit-append', - 'edit-sections', - 'history', - 'print', - 'files', - 'tags', - 'source', - 'talk', - 'backlinks' - - ); - - $defaultText = array( - 'edit' => _('edit'), - 'edit-append' => _('append'), - 'edit-sections' => _('edit sections'), - 'history' => _('history'), - 'print' => _('print'), - 'files' => _('files'), - 'tags' => _('tags'), - 'source' => _('view source'), - 'talk' => _('talk'), - 'backlinks' => _('backlinks') - - ); - - $jsOnclick = array( - 'edit' => 'WIKIDOT.page.listeners.editClick(event)', - 'edit-append' => 'WIKIDOT.page.listeners.append(event)', - 'edit-sections' => 'WIKIDOT.page.listeners.toggleEditSections(event)', - 'history' => ' WIKIDOT.page.listeners.historyClick(event)', - 'print' => 'WIKIDOT.page.listeners.printClick(event)', - 'files' => 'WIKIDOT.page.listeners.filesClick(event)', - 'tags' => 'WIKIDOT.page.listeners.editTags(event)', - 'source' => 'WIKIDOT.page.listeners.viewSourceClick(event)', - 'talk' => "window.location.href='/talk:'+WIKIREQUEST.info.pageUnixName", - 'backlinks' => 'WIKIDOT.page.listeners.backlinksClick(event)' - - ); - - //$jsOnload = array( - // 'talk' => "this.href='/talk:'+WIKIREQUEST.info.pageUnixName; alert(this.href);" - - $hrefs = array(); - - if(!in_array($type, $allowedTypes)){ - return '
'._('The button type is not recognized').'
'; - } - - // ok, fine - - if(!$class){ - $class = "wiki-standalone-button"; - } - - if(!$text){ - $text = $defaultText[$type]; - } - - $out = ' _('edit'), + 'edit-append' => _('append'), + 'edit-sections' => _('edit sections'), + 'history' => _('history'), + 'print' => _('print'), + 'files' => _('files'), + 'tags' => _('tags'), + 'source' => _('view source'), + 'talk' => _('talk'), + 'backlinks' => _('backlinks') + + ); + + $jsOnclick = array( + 'edit' => 'WIKIDOT.page.listeners.editClick(event)', + 'edit-append' => 'WIKIDOT.page.listeners.append(event)', + 'edit-sections' => 'WIKIDOT.page.listeners.toggleEditSections(event)', + 'history' => ' WIKIDOT.page.listeners.historyClick(event)', + 'print' => 'WIKIDOT.page.listeners.printClick(event)', + 'files' => 'WIKIDOT.page.listeners.filesClick(event)', + 'tags' => 'WIKIDOT.page.listeners.editTags(event)', + 'source' => 'WIKIDOT.page.listeners.viewSourceClick(event)', + 'talk' => "window.location.href='/talk:'+WIKIREQUEST.info.pageUnixName", + 'backlinks' => 'WIKIDOT.page.listeners.backlinksClick(event)' + + ); + + //$jsOnload = array( + // 'talk' => "this.href='/talk:'+WIKIREQUEST.info.pageUnixName; alert(this.href);" + + $hrefs = array(); + + if (!in_array($type, $allowedTypes)) { + return '
'._('The button type is not recognized').'
'; + } + + // ok, fine + + if (!$class) { + $class = "wiki-standalone-button"; + } + + if (!$text) { + $text = $defaultText[$type]; + } + + $out = '
") { $side = "right"; - } else if ($side == "<") { + } elseif ($side == "<") { $side = "left"; } else { $side = "both"; diff --git a/Text/Wiki/Render/Xhtml/Code.php b/Text/Wiki/Render/Xhtml/Code.php index b2b4608..b5da94a 100644 --- a/Text/Wiki/Render/Xhtml/Code.php +++ b/Text/Wiki/Render/Xhtml/Code.php @@ -25,7 +25,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Code extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Code extends Text_Wiki_Render +{ public $conf = array( 'css' => null, // class for
@@ -60,15 +61,15 @@ function token($options)
         $css_html = $this->formatConf(' class="%s"', 'css_html');
         $css_filename = $this->formatConf(' class="%s"', 'css_filename');
 
-		$text = trim($text);
+        $text = trim($text);
 
 //        if ($type == 'php') {
-//        	 	/*if (substr($text, 0, 5) != '"; // highlight($text);
 //        }elseif ($type == 'cpp') {
 //            $highlighter = Text_Highlighter::factory('cpp');
@@ -107,7 +108,7 @@ function token($options)
 //            $highlighter = Text_Highlighter::factory('sql');
 //            $text = $highlighter->highlight($text);
 //        }elseif($type=="xml"){
-//       	 	$highlighter = Text_Highlighter::factory('xml');
+//              $highlighter = Text_Highlighter::factory('xml');
 //            $text = $highlighter->highlight($text);
 //        } else {
             // generic code example:
@@ -118,7 +119,7 @@ function token($options)
             $text = "$text
"; // } - $text = "
".$text."
"; + $text = "
".$text."
"; if ($css_filename && isset($attr['filename'])) { $text = "" . diff --git a/Text/Wiki/Render/Xhtml/Collapsible.php b/Text/Wiki/Render/Xhtml/Collapsible.php index 41d053b..9233fcf 100644 --- a/Text/Wiki/Render/Xhtml/Collapsible.php +++ b/Text/Wiki/Render/Xhtml/Collapsible.php @@ -20,7 +20,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Collapsible extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Collapsible extends Text_Wiki_Render +{ public $conf = array(); @@ -39,61 +40,58 @@ class Text_Wiki_Render_Xhtml_Collapsible extends Text_Wiki_Render { function token($options) { - $args = $options['args']; - if($args['folded'] == 'no' || $args['folded'] == 'false'){ - $folded = false; - }else{ - $folded = true; - } - - if($args['show']){ - $show = $args['show']; - }else{ - $show = "+ show block"; - } - - if($args['hide']){ - $hide = $args['hide']; - }else{ - $hide = "- hide block"; - } + $args = $options['args']; + if ($args['folded'] == 'no' || $args['folded'] == 'false') { + $folded = false; + } else { + $folded = true; + } - if($args['hideLocation'] && $args['hideLocation'] == 'bottom'){ - $hideLocation = 'bottom'; - }elseif($args['hideLocation'] && $args['hideLocation'] == 'both'){ - $hideLocation = 'both'; - }else{ - $hideLocation = 'top'; - } + if ($args['show']) { + $show = $args['show']; + } else { + $show = "+ show block"; + } - $count = $options['count']; + if ($args['hide']) { + $hide = $args['hide']; + } else { + $hide = "- hide block"; + } - $hideB = '
'; + if ($args['hideLocation'] && $args['hideLocation'] == 'bottom') { + $hideLocation = 'bottom'; + } elseif ($args['hideLocation'] && $args['hideLocation'] == 'both') { + $hideLocation = 'both'; + } else { + $hideLocation = 'top'; + } - if ($options['type'] == 'start') { + $count = $options['count']; - $out = '
'; - $out .= '
'; - $out .= ''.htmlspecialchars($show).''; - $out .= '
'; - $out .= '
'; - if($hideLocation == 'top' || $hideLocation == 'both'){ - $out .= $hideB; - } - $out .= '
'; + $hideB = ''; - return $out; + if ($options['type'] == 'start') { + $out = '
'; + $out .= '
'; + $out .= ''.htmlspecialchars($show).''; + $out .= '
'; + $out .= '
'; + if ($hideLocation == 'top' || $hideLocation == 'both') { + $out .= $hideB; + } + $out .= '
'; + return $out; } if ($options['type'] == 'end') { $out = "
"; - if($hideLocation == 'bottom' || $hideLocation == 'both'){ - $out .= $hideB; + if ($hideLocation == 'bottom' || $hideLocation == 'both') { + $out .= $hideB; } $out .= "
"; return $out; } - } } diff --git a/Text/Wiki/Render/Xhtml/Colortext.php b/Text/Wiki/Render/Xhtml/Colortext.php index 3b2824c..2489bb8 100644 --- a/Text/Wiki/Render/Xhtml/Colortext.php +++ b/Text/Wiki/Render/Xhtml/Colortext.php @@ -23,7 +23,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Colortext extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Colortext extends Text_Wiki_Render +{ public $colors = array( 'aqua', diff --git a/Text/Wiki/Render/Xhtml/Comment.php b/Text/Wiki/Render/Xhtml/Comment.php index 12d95b7..e7b4cad 100644 --- a/Text/Wiki/Render/Xhtml/Comment.php +++ b/Text/Wiki/Render/Xhtml/Comment.php @@ -20,7 +20,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Comment extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Comment extends Text_Wiki_Render +{ public $conf = array(); @@ -39,7 +40,6 @@ class Text_Wiki_Render_Xhtml_Comment extends Text_Wiki_Render { function token($options) { - return ''; - + return ''; } } diff --git a/Text/Wiki/Render/Xhtml/Concatlines.php b/Text/Wiki/Render/Xhtml/Concatlines.php index be855e4..4ece8a6 100644 --- a/Text/Wiki/Render/Xhtml/Concatlines.php +++ b/Text/Wiki/Render/Xhtml/Concatlines.php @@ -25,7 +25,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Concatlines extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Concatlines extends Text_Wiki_Render +{ function token() { return ''; diff --git a/Text/Wiki/Render/Xhtml/Date.php b/Text/Wiki/Render/Xhtml/Date.php index bbaefb1..7dfcbca 100644 --- a/Text/Wiki/Render/Xhtml/Date.php +++ b/Text/Wiki/Render/Xhtml/Date.php @@ -18,15 +18,17 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Date extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Date extends Text_Wiki_Render +{ - function token($options){ - $timestamp = $options['timestamp']; - $format = $options['format']; - if($format){ - $format = '|'.$format; - } - $output = '' . $timestamp . $format . ''; + function token($options) + { + $timestamp = $options['timestamp']; + $format = $options['format']; + if ($format) { + $format = '|'.$format; + } + $output = '' . $timestamp . $format . ''; return $output; } diff --git a/Text/Wiki/Render/Xhtml/Deflist.php b/Text/Wiki/Render/Xhtml/Deflist.php index 7e72ba0..d0266f6 100644 --- a/Text/Wiki/Render/Xhtml/Deflist.php +++ b/Text/Wiki/Render/Xhtml/Deflist.php @@ -23,7 +23,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Deflist extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Deflist extends Text_Wiki_Render +{ public $conf = array( 'css_dl' => null, @@ -50,37 +51,35 @@ function token($options) $pad = " "; switch ($type) { - - case 'list_start': - $css = $this->formatConf(' class="%s"', 'css_dl'); - return "\n"; + case 'list_start': + $css = $this->formatConf(' class="%s"', 'css_dl'); + return "\n"; break; - case 'list_end': - return "\n\n"; + case 'list_end': + return "\n\n"; break; - case 'term_start': - $css = $this->formatConf(' class="%s"', 'css_dt'); - return $pad . ""; + case 'term_start': + $css = $this->formatConf(' class="%s"', 'css_dt'); + return $pad . ""; break; - case 'term_end': - return "\n"; + case 'term_end': + return "\n"; break; - case 'narr_start': - $css = $this->formatConf(' class="%s"', 'css_dd'); - return $pad . $pad . ""; + case 'narr_start': + $css = $this->formatConf(' class="%s"', 'css_dd'); + return $pad . $pad . ""; break; - case 'narr_end': - return "\n"; + case 'narr_end': + return "\n"; break; - default: - return ''; - + default: + return ''; } } } diff --git a/Text/Wiki/Render/Xhtml/Delimiter.php b/Text/Wiki/Render/Xhtml/Delimiter.php index 394dcce..1a3699e 100644 --- a/Text/Wiki/Render/Xhtml/Delimiter.php +++ b/Text/Wiki/Render/Xhtml/Delimiter.php @@ -23,7 +23,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Delimiter extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Delimiter extends Text_Wiki_Render +{ /** * @@ -38,7 +39,8 @@ class Text_Wiki_Render_Xhtml_Delimiter extends Text_Wiki_Render { * */ - function token($options){ + function token($options) + { return $options['text']; } diff --git a/Text/Wiki/Render/Xhtml/Div.php b/Text/Wiki/Render/Xhtml/Div.php index 7ee4637..a68a988 100644 --- a/Text/Wiki/Render/Xhtml/Div.php +++ b/Text/Wiki/Render/Xhtml/Div.php @@ -19,7 +19,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Div extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Div extends Text_Wiki_Render +{ public $conf = array(); @@ -36,7 +37,8 @@ class Text_Wiki_Render_Xhtml_Div extends Text_Wiki_Render { * */ - function token($options) { + function token($options) + { if ($options['type'] == 'start') { $args = $options['args']; $argstr = ''; @@ -49,6 +51,5 @@ function token($options) { if ($options['type'] == 'end') { return "
"; } - } } diff --git a/Text/Wiki/Render/Xhtml/Divalign.php b/Text/Wiki/Render/Xhtml/Divalign.php index 19be9c4..50455c0 100644 --- a/Text/Wiki/Render/Xhtml/Divalign.php +++ b/Text/Wiki/Render/Xhtml/Divalign.php @@ -20,7 +20,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Divalign extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Divalign extends Text_Wiki_Render +{ public $conf = array(); @@ -37,7 +38,8 @@ class Text_Wiki_Render_Xhtml_Divalign extends Text_Wiki_Render { * */ - function token($options) { + function token($options) + { $align = $options['align']; if ($options['type'] == 'start') { @@ -47,6 +49,5 @@ function token($options) { if ($options['type'] == 'end') { return "
"; } - } } diff --git a/Text/Wiki/Render/Xhtml/Divprefilter.php b/Text/Wiki/Render/Xhtml/Divprefilter.php index 97d2242..f55fff2 100644 --- a/Text/Wiki/Render/Xhtml/Divprefilter.php +++ b/Text/Wiki/Render/Xhtml/Divprefilter.php @@ -19,9 +19,11 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Divprefilter extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Divprefilter extends Text_Wiki_Render +{ - function token() { + function token() + { return ''; } } diff --git a/Text/Wiki/Render/Xhtml/Email.php b/Text/Wiki/Render/Xhtml/Email.php index 938628a..d40513b 100644 --- a/Text/Wiki/Render/Xhtml/Email.php +++ b/Text/Wiki/Render/Xhtml/Email.php @@ -19,9 +19,11 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Email extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Email extends Text_Wiki_Render +{ - function token($options) { + function token($options) + { $email = $options['email']; $text = $options['text']; diff --git a/Text/Wiki/Render/Xhtml/Embed.php b/Text/Wiki/Render/Xhtml/Embed.php index d0858e1..c8594d0 100644 --- a/Text/Wiki/Render/Xhtml/Embed.php +++ b/Text/Wiki/Render/Xhtml/Embed.php @@ -20,7 +20,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Embed extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Embed extends Text_Wiki_Render +{ public $conf = array(); @@ -39,7 +40,8 @@ class Text_Wiki_Render_Xhtml_Embed extends Text_Wiki_Render { public $patterns = array(); - public function Text_Wiki_Render_Xhtml_Embed($obj) { + public function Text_Wiki_Render_Xhtml_Embed($obj) + { parent::Text_Wiki_Render($obj); $patternDir = WIKIDOT_ROOT . '/conf/wikiparser/embed'; @@ -48,10 +50,10 @@ public function Text_Wiki_Render_Xhtml_Embed($obj) { require $f; $this->_patterns = array_merge($this->patterns, $patterns); } - } - function token($options) { + function token($options) + { $content = trim($options['content']); @@ -70,6 +72,5 @@ function token($options) { //no match... return '
Sorry, no match for the embedded content.
'; - } } diff --git a/Text/Wiki/Render/Xhtml/Emphasis.php b/Text/Wiki/Render/Xhtml/Emphasis.php index 5d2563c..98b1a35 100644 --- a/Text/Wiki/Render/Xhtml/Emphasis.php +++ b/Text/Wiki/Render/Xhtml/Emphasis.php @@ -23,7 +23,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Emphasis extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Emphasis extends Text_Wiki_Render +{ public $conf = array( 'css' => null diff --git a/Text/Wiki/Render/Xhtml/Equationreference.php b/Text/Wiki/Render/Xhtml/Equationreference.php index ffb5fd1..60d1978 100644 --- a/Text/Wiki/Render/Xhtml/Equationreference.php +++ b/Text/Wiki/Render/Xhtml/Equationreference.php @@ -19,7 +19,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Equationreference extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Equationreference extends Text_Wiki_Render +{ public $conf = array(); @@ -36,7 +37,8 @@ class Text_Wiki_Render_Xhtml_Equationreference extends Text_Wiki_Render { * */ - function token($options) { + function token($options) + { $label = $options['label']; $refs = Text_Wiki_Parse_Math::$equationsArray; $id = $refs[$label]; diff --git a/Text/Wiki/Render/Xhtml/File.php b/Text/Wiki/Render/Xhtml/File.php index bee4772..d635c80 100644 --- a/Text/Wiki/Render/Xhtml/File.php +++ b/Text/Wiki/Render/Xhtml/File.php @@ -19,7 +19,8 @@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_File extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_File extends Text_Wiki_Render +{ public $conf = array( 'base' => '/' @@ -44,17 +45,17 @@ function token($options) $anchor = $options['anchor']; if (strpos($file, '/') !== false) { - // ok, hardcode the path... sorry. - $file = preg_replace("/^\//", '', $file); - $file = "/local--files/".$file; - }else{ - $noLocal = $this->getConf("no_local"); - if($noLocal){ - return '' . - 'Sorry, local files without page name specified not allowed. ' . - 'Use [[file pagename/filename]]'; - } - $file = $this->getConf('base', '/') . $file; + // ok, hardcode the path... sorry. + $file = preg_replace("/^\//", '', $file); + $file = "/local--files/".$file; + } else { + $noLocal = $this->getConf("no_local"); + if ($noLocal) { + return '' . + 'Sorry, local files without page name specified not allowed. ' . + 'Use [[file pagename/filename]]'; + } + $file = $this->getConf('base', '/') . $file; } $output = "$anchor"; diff --git a/Text/Wiki/Render/Xhtml/Font.php b/Text/Wiki/Render/Xhtml/Font.php index a14829b..997c3a6 100644 --- a/Text/Wiki/Render/Xhtml/Font.php +++ b/Text/Wiki/Render/Xhtml/Font.php @@ -26,7 +26,8 @@ * @link http://pear.php.net/package/Text_Wiki * @see Text_Wiki::Text_Wiki_Render() */ -class Text_Wiki_Render_Xhtml_Font extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Font extends Text_Wiki_Render +{ diff --git a/Text/Wiki/Render/Xhtml/Footnote.php b/Text/Wiki/Render/Xhtml/Footnote.php index 012381d..6c082bf 100644 --- a/Text/Wiki/Render/Xhtml/Footnote.php +++ b/Text/Wiki/Render/Xhtml/Footnote.php @@ -19,7 +19,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Footnote extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Footnote extends Text_Wiki_Render +{ public $conf = array(); @@ -36,7 +37,8 @@ class Text_Wiki_Render_Xhtml_Footnote extends Text_Wiki_Render { * */ - function token($options) { + function token($options) + { $label = $options['label']; $refs = Text_Wiki_Parse_Math::$equationsArray; $id = $options['id']; diff --git a/Text/Wiki/Render/Xhtml/Footnoteblock.php b/Text/Wiki/Render/Xhtml/Footnoteblock.php index e7da768..88bd3e4 100644 --- a/Text/Wiki/Render/Xhtml/Footnoteblock.php +++ b/Text/Wiki/Render/Xhtml/Footnoteblock.php @@ -18,7 +18,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Footnoteblock extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Footnoteblock extends Text_Wiki_Render +{ public $conf = array(); @@ -35,7 +36,8 @@ class Text_Wiki_Render_Xhtml_Footnoteblock extends Text_Wiki_Render { * */ - function token($options) { + function token($options) + { $footnotes = $this->wiki->vars['footnotes']; if (count($footnotes) == 0) { return ''; @@ -55,18 +57,18 @@ function token($options) { return '
'; } /* - $footnotes = $this->wiki->vars['footnotes']; - if(count($footnotes) == 0){return '';} // render nothing if no footnotes. - $out = ''; + $footnotes = $this->wiki->vars['footnotes']; + if(count($footnotes) == 0){return '';} // render nothing if no footnotes. + $out = ''; return $out; */ } diff --git a/Text/Wiki/Render/Xhtml/Footnoteitem.php b/Text/Wiki/Render/Xhtml/Footnoteitem.php index e116d7c..b70926d 100644 --- a/Text/Wiki/Render/Xhtml/Footnoteitem.php +++ b/Text/Wiki/Render/Xhtml/Footnoteitem.php @@ -18,7 +18,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Footnoteitem extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Footnoteitem extends Text_Wiki_Render +{ public $conf = array(); @@ -35,9 +36,9 @@ class Text_Wiki_Render_Xhtml_Footnoteitem extends Text_Wiki_Render { * */ - function token($options) { + function token($options) + { if ($options['type'] == 'start') { - $idPrefix = $this->wiki->getRenderConf('xhtml', 'footnote', 'id_prefix'); $id = $options['id']; $out = '$out\n\n"; break; - case 'item_start': - $html = "\n\tgetConf('css_item'); - if ($css) { - $html .= " class=\"$css\""; - } + $css = $this->getConf('css_item'); + if ($css) { + $html .= " class=\"$css\""; + } - $pad = ($level - $this->min); - $html .= " style=\"margin-left: {$pad}em;\">"; + $pad = ($level - $this->min); + $html .= " style=\"margin-left: {$pad}em;\">"; - $d = utf8_encode("\xFC"); - $html .= "$d$d"; - return $html; + $d = utf8_encode("\xFC"); + $html .= "$d$d"; + return $html; break; - case 'item_end': - $d = utf8_encode("\xFC"); - return "$d$d"; + case 'item_end': + $d = utf8_encode("\xFC"); + return "$d$d"; break; } } diff --git a/Text/Wiki/Render/Xhtml/Tt.php b/Text/Wiki/Render/Xhtml/Tt.php index 980f0d3..a1776c8 100644 --- a/Text/Wiki/Render/Xhtml/Tt.php +++ b/Text/Wiki/Render/Xhtml/Tt.php @@ -23,7 +23,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Tt extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Tt extends Text_Wiki_Render +{ public $conf = array( 'css' => null diff --git a/Text/Wiki/Render/Xhtml/Typography.php b/Text/Wiki/Render/Xhtml/Typography.php index 4f1d9b7..963961a 100644 --- a/Text/Wiki/Render/Xhtml/Typography.php +++ b/Text/Wiki/Render/Xhtml/Typography.php @@ -19,7 +19,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Typography extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Typography extends Text_Wiki_Render +{ public $replacements = array("``" => '“', "''" => '”', ",," => '„', "`" => '‘', "'" => '’', @@ -43,7 +44,8 @@ class Text_Wiki_Render_Xhtml_Typography extends Text_Wiki_Render { * */ - function token($options) { + function token($options) + { return ($this->replacements[$options['char']]); } } diff --git a/Text/Wiki/Render/Xhtml/Underline.php b/Text/Wiki/Render/Xhtml/Underline.php index 6c42969..a302c8e 100644 --- a/Text/Wiki/Render/Xhtml/Underline.php +++ b/Text/Wiki/Render/Xhtml/Underline.php @@ -23,7 +23,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Underline extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Underline extends Text_Wiki_Render +{ public $conf = array( 'css' => null diff --git a/Text/Wiki/Render/Xhtml/Url.php b/Text/Wiki/Render/Xhtml/Url.php index 7105e7a..2c97ae8 100644 --- a/Text/Wiki/Render/Xhtml/Url.php +++ b/Text/Wiki/Render/Xhtml/Url.php @@ -23,7 +23,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_Url extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Url extends Text_Wiki_Render +{ public $conf = array( //'target' => '_blank', @@ -60,14 +61,13 @@ function token($options) $ext = strtolower(substr($href, $pos + 1)); $href0 = $href; $href = htmlspecialchars($href); - if($href=="#"){ - $href="javascript:;"; + if ($href=="#") { + $href="javascript:;"; } // 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); @@ -77,17 +77,15 @@ function token($options) // generate an image tag $css = $this->formatConf(' class="%s"', 'css_img'); $output = ""; - } else { - // should we build a target clause? if ($href[0] == '#' || - strtolower(substr($href, 0, 7)) == 'mailto:') { - // targets not allowed for on-page anchors - // and mailto: links. + strtolower(substr($href, 0, 7)) == 'mailto:') { + // targets not allowed for on-page anchors + // and mailto: links. $target = ''; } else { - // allow targets on non-anchor non-mailto links + // allow targets on non-anchor non-mailto links $target = $this->getConf('target'); } @@ -96,7 +94,7 @@ function token($options) $css = $this->formatConf(' class="%s"', "css_$type"); $output = "wiki; - if($wiki->vars['externalLinks'] == null){ - $wiki->vars['externalLinks'] = array(); - } - if(preg_match(';^https?://;', $href0)){ - $href0 = substr($href0,0,2000); - $wiki->vars['externalLinks'][$href0]=$href0; - } + if ($wiki->vars['externalLinks'] == null) { + $wiki->vars['externalLinks'] = array(); + } + if (preg_match(';^https?://;', $href0)) { + $href0 = substr($href0, 0, 2000); + $wiki->vars['externalLinks'][$href0]=$href0; + } return $output; diff --git a/Text/Wiki/Render/Xhtml/User.php b/Text/Wiki/Render/Xhtml/User.php index 733e83d..5792f79 100644 --- a/Text/Wiki/Render/Xhtml/User.php +++ b/Text/Wiki/Render/Xhtml/User.php @@ -23,7 +23,8 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/Text_Wiki */ -class Text_Wiki_Render_Xhtml_User extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_User extends Text_Wiki_Render +{ public $conf = array(); @@ -40,7 +41,8 @@ class Text_Wiki_Render_Xhtml_User extends Text_Wiki_Render { * */ - function token($options) { + function token($options) + { $userName = $options['userName']; $unixName = WDStringUtils::toUnixName($userName); $c = new Criteria(); @@ -56,6 +58,5 @@ function token($options) { } return WDRenderUtils::renderUser($user, $o); } - } } diff --git a/Text/Wiki/Render/Xhtml/Wikilink.php b/Text/Wiki/Render/Xhtml/Wikilink.php index 3aff3b2..3866b77 100644 --- a/Text/Wiki/Render/Xhtml/Wikilink.php +++ b/Text/Wiki/Render/Xhtml/Wikilink.php @@ -28,7 +28,8 @@ use DB\PagePeer; -class Text_Wiki_Render_Xhtml_Wikilink extends Text_Wiki_Render { +class Text_Wiki_Render_Xhtml_Wikilink extends Text_Wiki_Render +{ public $conf = array( 'pages' => array(), // set to null or false to turn off page checks @@ -57,8 +58,7 @@ class Text_Wiki_Render_Xhtml_Wikilink extends Text_Wiki_Render { function token($options) { extract($options); - if($site){ - + if ($site) { $o = ''; $o .= $text; $o .= ''; @@ -73,7 +73,7 @@ function token($options) if (isset($this->conf['exists_callback'])) { $callback =& $this->conf['exists_callback']; } else { - $callback = false; + $callback = false; } if ($callback) { @@ -91,15 +91,15 @@ function token($options) } } - if($exists && $textFromTitle){ - // get displayed text from the page title - $pageObj = PagePeer::instance()->selectByPrimaryKey($exists); - $text = $pageObj->getTitleOrUnixName(); - } + if ($exists && $textFromTitle) { + // get displayed text from the page title + $pageObj = PagePeer::instance()->selectByPrimaryKey($exists); + $text = $pageObj->getTitleOrUnixName(); + } - if(!$exists && $textFromTitle){ - $text = $page; - } + if (!$exists && $textFromTitle) { + $text = $page; + } // convert *after* checking against page names so as not to mess // up what the user typed and what we're checking. @@ -107,21 +107,20 @@ function token($options) $anchor = htmlspecialchars(trim($anchor)); $text = htmlspecialchars(trim($text)); - if($nonbr){ - $text = str_replace(' ', ' ', $text); - } + if ($nonbr) { + $text = str_replace(' ', ' ', $text); + } // does the page exist? if ($exists) { - // PAGE EXISTS. - // store it in the array + // store it in the array - $wiki = $this->wiki; - if($wiki->vars['internalLinksExist'] == null){ - $wiki->vars['internalLinksExist'] = array(); - } - $wiki->vars['internalLinksExist'][$exists]=$exists; + $wiki = $this->wiki; + if ($wiki->vars['internalLinksExist'] == null) { + $wiki->vars['internalLinksExist'] = array(); + } + $wiki->vars['internalLinksExist'][$exists]=$exists; // link to the page view, but we have to build // the HREF. we support both the old form where @@ -140,28 +139,24 @@ function token($options) // get the CSS class and generate output $css = $this->formatConf(' class="%s"', 'css'); $output = "$text"; - } else { - $wiki = $this->wiki; - if($wiki->vars['internalLinksNotExist'] == null){ - $wiki->vars['internalLinksNotExist'] = array(); - } - $wiki->vars['internalLinksNotExist'][$page] = $page; + $wiki = $this->wiki; + if ($wiki->vars['internalLinksNotExist'] == null) { + $wiki->vars['internalLinksNotExist'] = array(); + } + $wiki->vars['internalLinksNotExist'][$page] = $page; // PAGE DOES NOT EXIST. - //WikiTransformation::$internalLinksNotExist[$page] = $page; //which is the page unix name! + //WikiTransformation::$internalLinksNotExist[$page] = $page; //which is the page unix name! // 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