summaryrefslogtreecommitdiff
path: root/inc/parser
diff options
context:
space:
mode:
Diffstat (limited to 'inc/parser')
-rw-r--r--inc/parser/code.php5
-rw-r--r--inc/parser/handler.php83
-rw-r--r--inc/parser/lexer.php33
-rw-r--r--inc/parser/metadata.php19
-rw-r--r--inc/parser/parser.php41
-rw-r--r--inc/parser/renderer.php39
-rw-r--r--inc/parser/xhtml.php140
7 files changed, 250 insertions, 110 deletions
diff --git a/inc/parser/code.php b/inc/parser/code.php
index 00b956c27..2353e0dfa 100644
--- a/inc/parser/code.php
+++ b/inc/parser/code.php
@@ -21,6 +21,11 @@ class Doku_Renderer_code extends Doku_Renderer {
$filename = utf8_basename($filename);
$filename = utf8_stripspecials($filename, '_');
+ // send CRLF to Windows clients
+ if(strpos($INPUT->server->str('HTTP_USER_AGENT'), 'Windows') !== false) {
+ $text = str_replace("\n", "\r\n", $text);
+ }
+
if($this->_codeblock == $INPUT->str('codeblock')) {
header("Content-Type: text/plain; charset=utf-8");
header("Content-Disposition: attachment; filename=$filename");
diff --git a/inc/parser/handler.php b/inc/parser/handler.php
index a1040d12e..815ac39c5 100644
--- a/inc/parser/handler.php
+++ b/inc/parser/handler.php
@@ -17,10 +17,13 @@ class Doku_Handler {
var $rewriteBlocks = true;
- function Doku_Handler() {
+ function __construct() {
$this->CallWriter = new Doku_Handler_CallWriter($this);
}
+ /**
+ * @param string $handler
+ */
function _addCall($handler, $args, $pos) {
$call = array($handler,$args, $pos);
$this->CallWriter->writeCall($call);
@@ -71,6 +74,7 @@ class Doku_Handler {
*/
function plugin($match, $state, $pos, $pluginname){
$data = array($match);
+ /** @var DokuWiki_Syntax_Plugin $plugin */
$plugin = plugin_load('syntax',$pluginname);
if($plugin != null){
$data = $plugin->handle($match, $state, $pos, $this);
@@ -132,6 +136,9 @@ class Doku_Handler {
return true;
}
+ /**
+ * @param string $name
+ */
function _nestingTag($match, $state, $pos, $name) {
switch ( $state ) {
case DOKU_LEXER_ENTER:
@@ -288,7 +295,7 @@ class Doku_Handler {
switch ( $state ) {
case DOKU_LEXER_ENTER:
$ReWriter = new Doku_Handler_Preformatted($this->CallWriter);
- $this->CallWriter = & $ReWriter;
+ $this->CallWriter = $ReWriter;
$this->_addCall('preformatted_start',array(), $pos);
break;
case DOKU_LEXER_EXIT:
@@ -525,6 +532,7 @@ class Doku_Handler {
$p['author'] = (preg_match('/\b(by|author)/',$params));
$p['date'] = (preg_match('/\b(date)/',$params));
$p['details'] = (preg_match('/\b(desc|detail)/',$params));
+ $p['nosort'] = (preg_match('/\b(nosort)\b/',$params));
if (preg_match('/\b(\d+)([dhm])\b/',$params,$match)) {
$period = array('d' => 86400, 'h' => 3600, 'm' => 60);
@@ -707,12 +715,21 @@ function Doku_Handler_Parse_Media($match) {
}
//------------------------------------------------------------------------
-class Doku_Handler_CallWriter {
+interface Doku_Handler_CallWriter_Interface {
+ public function writeCall($call);
+ public function writeCalls($calls);
+ public function finalise();
+}
+
+class Doku_Handler_CallWriter implements Doku_Handler_CallWriter_Interface {
var $Handler;
- function Doku_Handler_CallWriter(& $Handler) {
- $this->Handler = & $Handler;
+ /**
+ * @param Doku_Handler $Handler
+ */
+ function __construct(Doku_Handler $Handler) {
+ $this->Handler = $Handler;
}
function writeCall($call) {
@@ -737,7 +754,7 @@ class Doku_Handler_CallWriter {
*
* @author Chris Smith <chris@jalakai.co.uk>
*/
-class Doku_Handler_Nest {
+class Doku_Handler_Nest implements Doku_Handler_CallWriter_Interface {
var $CallWriter;
var $calls = array();
@@ -747,12 +764,12 @@ class Doku_Handler_Nest {
/**
* constructor
*
- * @param object $CallWriter the renderers current call writer
+ * @param Doku_Handler_CallWriter $CallWriter the renderers current call writer
* @param string $close closing instruction name, this is required to properly terminate the
* syntax mode if the document ends without a closing pattern
*/
- function Doku_Handler_Nest(& $CallWriter, $close="nest_close") {
- $this->CallWriter = & $CallWriter;
+ function __construct(Doku_Handler_CallWriter_Interface $CallWriter, $close="nest_close") {
+ $this->CallWriter = $CallWriter;
$this->closingInstruction = $close;
}
@@ -797,7 +814,7 @@ class Doku_Handler_Nest {
}
}
-class Doku_Handler_List {
+class Doku_Handler_List implements Doku_Handler_CallWriter_Interface {
var $CallWriter;
@@ -805,8 +822,10 @@ class Doku_Handler_List {
var $listCalls = array();
var $listStack = array();
- function Doku_Handler_List(& $CallWriter) {
- $this->CallWriter = & $CallWriter;
+ const NODE = 1;
+
+ function __construct(Doku_Handler_CallWriter_Interface $CallWriter) {
+ $this->CallWriter = $CallWriter;
}
function writeCall($call) {
@@ -856,7 +875,8 @@ class Doku_Handler_List {
$depth = $this->interpretSyntax($call[1][0], $listType);
$this->initialDepth = $depth;
- $this->listStack[] = array($listType, $depth);
+ // array(list type, current depth, index of current listitem_open)
+ $this->listStack[] = array($listType, $depth, 1);
$this->listCalls[] = array('list'.$listType.'_open',array(),$call[2]);
$this->listCalls[] = array('listitem_open',array(1),$call[2]);
@@ -881,6 +901,7 @@ class Doku_Handler_List {
function listOpen($call) {
$depth = $this->interpretSyntax($call[1][0], $listType);
$end = end($this->listStack);
+ $key = key($this->listStack);
// Not allowed to be shallower than initialDepth
if ( $depth < $this->initialDepth ) {
@@ -897,6 +918,9 @@ class Doku_Handler_List {
$this->listCalls[] = array('listitem_open',array($depth-1),$call[2]);
$this->listCalls[] = array('listcontent_open',array(),$call[2]);
+ // new list item, update list stack's index into current listitem_open
+ $this->listStack[$key][2] = count($this->listCalls) - 2;
+
// Switched list type...
} else {
@@ -908,7 +932,7 @@ class Doku_Handler_List {
$this->listCalls[] = array('listcontent_open',array(),$call[2]);
array_pop($this->listStack);
- $this->listStack[] = array($listType, $depth);
+ $this->listStack[] = array($listType, $depth, count($this->listCalls) - 2);
}
//------------------------------------------------------------------------
@@ -920,7 +944,10 @@ class Doku_Handler_List {
$this->listCalls[] = array('listitem_open', array($depth-1), $call[2]);
$this->listCalls[] = array('listcontent_open',array(),$call[2]);
- $this->listStack[] = array($listType, $depth);
+ // set the node/leaf state of this item's parent listitem_open to NODE
+ $this->listCalls[$this->listStack[$key][2]][1][1] = self::NODE;
+
+ $this->listStack[] = array($listType, $depth, count($this->listCalls) - 2);
//------------------------------------------------------------------------
// Getting shallower ( $depth < $end[1] )
@@ -934,6 +961,7 @@ class Doku_Handler_List {
while (1) {
$end = end($this->listStack);
+ $key = key($this->listStack);
if ( $end[1] <= $depth ) {
@@ -946,6 +974,9 @@ class Doku_Handler_List {
$this->listCalls[] = array('listitem_open',array($depth-1),$call[2]);
$this->listCalls[] = array('listcontent_open',array(),$call[2]);
+ // new list item, update list stack's index into current listitem_open
+ $this->listStack[$key][2] = count($this->listCalls) - 2;
+
} else {
// Switching list type...
$this->listCalls[] = array('list'.$end[0].'_close', array(), $call[2]);
@@ -954,7 +985,7 @@ class Doku_Handler_List {
$this->listCalls[] = array('listcontent_open',array(),$call[2]);
array_pop($this->listStack);
- $this->listStack[] = array($listType, $depth);
+ $this->listStack[] = array($listType, $depth, count($this->listCalls) - 2);
}
break;
@@ -993,7 +1024,7 @@ class Doku_Handler_List {
}
//------------------------------------------------------------------------
-class Doku_Handler_Preformatted {
+class Doku_Handler_Preformatted implements Doku_Handler_CallWriter_Interface {
var $CallWriter;
@@ -1003,8 +1034,8 @@ class Doku_Handler_Preformatted {
- function Doku_Handler_Preformatted(& $CallWriter) {
- $this->CallWriter = & $CallWriter;
+ function __construct(Doku_Handler_CallWriter_Interface $CallWriter) {
+ $this->CallWriter = $CallWriter;
}
function writeCall($call) {
@@ -1053,7 +1084,7 @@ class Doku_Handler_Preformatted {
}
//------------------------------------------------------------------------
-class Doku_Handler_Quote {
+class Doku_Handler_Quote implements Doku_Handler_CallWriter_Interface {
var $CallWriter;
@@ -1061,8 +1092,8 @@ class Doku_Handler_Quote {
var $quoteCalls = array();
- function Doku_Handler_Quote(& $CallWriter) {
- $this->CallWriter = & $CallWriter;
+ function __construct(Doku_Handler_CallWriter_Interface $CallWriter) {
+ $this->CallWriter = $CallWriter;
}
function writeCall($call) {
@@ -1145,7 +1176,7 @@ class Doku_Handler_Quote {
}
//------------------------------------------------------------------------
-class Doku_Handler_Table {
+class Doku_Handler_Table implements Doku_Handler_CallWriter_Interface {
var $CallWriter;
@@ -1160,8 +1191,8 @@ class Doku_Handler_Table {
var $currentRow = array('tableheader' => 0, 'tablecell' => 0);
var $countTableHeadRows = 0;
- function Doku_Handler_Table(& $CallWriter) {
- $this->CallWriter = & $CallWriter;
+ function __construct(Doku_Handler_CallWriter_Interface $CallWriter) {
+ $this->CallWriter = $CallWriter;
}
function writeCall($call) {
@@ -1526,7 +1557,7 @@ class Doku_Handler_Block {
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
- function Doku_Handler_Block(){
+ function __construct(){
global $DOKU_PLUGINS;
//check if syntax plugins were loaded
if(empty($DOKU_PLUGINS['syntax'])) return;
diff --git a/inc/parser/lexer.php b/inc/parser/lexer.php
index 2e84eca7c..17aa6c170 100644
--- a/inc/parser/lexer.php
+++ b/inc/parser/lexer.php
@@ -46,7 +46,7 @@ class Doku_LexerParallelRegex {
* for insensitive.
* @access public
*/
- function Doku_LexerParallelRegex($case) {
+ function __construct($case) {
$this->_case = $case;
$this->_patterns = array();
$this->_labels = array();
@@ -56,12 +56,12 @@ class Doku_LexerParallelRegex {
/**
* Adds a pattern with an optional label.
*
- * @param mixed $pattern Perl style regex. Must be UTF-8
+ * @param mixed $pattern Perl style regex. Must be UTF-8
* encoded. If its a string, the (, )
* lose their meaning unless they
* form part of a lookahead or
* lookbehind assertation.
- * @param string $label Label of regex to be returned
+ * @param bool|string $label Label of regex to be returned
* on a match. Label must be ASCII
* @access public
*/
@@ -151,7 +151,8 @@ class Doku_LexerParallelRegex {
* "or" operator. Caches the regex.
* Will automatically escape (, ) and / tokens.
*
- * @param array $patterns List of patterns in order.
+ * @internal array $_patterns List of patterns in order.
+ * @return null|string
* @access private
*/
function _getCompoundedRegex() {
@@ -231,7 +232,7 @@ class Doku_LexerStateStack {
* @param string $start Starting state name.
* @access public
*/
- function Doku_LexerStateStack($start) {
+ function __construct($start) {
$this->_stack = array($start);
}
@@ -295,10 +296,11 @@ class Doku_Lexer {
* @param boolean $case True for case sensitive.
* @access public
*/
- function Doku_Lexer(&$parser, $start = "accept", $case = false) {
+ function __construct($parser, $start = "accept", $case = false) {
$this->_case = $case;
+ /** @var Doku_LexerParallelRegex[] _regexes */
$this->_regexes = array();
- $this->_parser = &$parser;
+ $this->_parser = $parser;
$this->_mode = new Doku_LexerStateStack($start);
$this->_mode_handlers = array();
}
@@ -425,11 +427,13 @@ class Doku_Lexer {
* Sends the matched token and any leading unmatched
* text to the parser changing the lexer to a new
* mode if one is listed.
- * @param string $unmatched Unmatched leading portion.
- * @param string $matched Actual token match.
- * @param string $mode Mode after match. A boolean
+ * @param string $unmatched Unmatched leading portion.
+ * @param string $matched Actual token match.
+ * @param bool|string $mode Mode after match. A boolean
* false mode causes no change.
- * @param int $pos Current byte index location in raw doc
+ * @param int $initialPos
+ * @param int $matchPos
+ * Current byte index location in raw doc
* thats being parsed
* @return boolean False if there was any error
* from the parser.
@@ -498,11 +502,12 @@ class Doku_Lexer {
* Calls the parser method named after the current
* mode. Empty content will be ignored. The lexer
* has a parser handler for each mode in the lexer.
- * @param string $content Text parsed.
- * @param boolean $is_match Token is recognised rather
+ * @param string $content Text parsed.
+ * @param boolean $is_match Token is recognised rather
* than unparsed data.
- * @param int $pos Current byte index location in raw doc
+ * @param int $pos Current byte index location in raw doc
* thats being parsed
+ * @return bool
* @access private
*/
function _invokeParser($content, $is_match, $pos) {
diff --git a/inc/parser/metadata.php b/inc/parser/metadata.php
index 25bf3fe3d..ac8fd2130 100644
--- a/inc/parser/metadata.php
+++ b/inc/parser/metadata.php
@@ -165,7 +165,7 @@ class Doku_Renderer_metadata extends Doku_Renderer {
if(!isset($this->meta['title'])) $this->meta['title'] = $text;
// add the header to the TOC
- $hid = $this->_headerToLink($text, 'true');
+ $hid = $this->_headerToLink($text, true);
$this->toc_additem($hid, $text, $level);
// add to summary
@@ -251,8 +251,9 @@ class Doku_Renderer_metadata extends Doku_Renderer {
* Open a list item
*
* @param int $level the nesting level
+ * @param bool $node true when a node; false when a leaf
*/
- function listitem_open($level) {
+ function listitem_open($level,$node=false) {
$this->cdata(str_repeat(DOKU_TAB, $level).'* ');
}
@@ -421,8 +422,8 @@ class Doku_Renderer_metadata extends Doku_Renderer {
/**
* keep track of internal links in $this->meta['relation']['references']
*
- * @param string $id page ID to link to. eg. 'wiki:syntax'
- * @param string|array $name name for the link, array for media file
+ * @param string $id page ID to link to. eg. 'wiki:syntax'
+ * @param string|array|null $name name for the link, array for media file
*/
function internallink($id, $name = null) {
global $ID;
@@ -458,8 +459,8 @@ class Doku_Renderer_metadata extends Doku_Renderer {
/**
* Render an external link
*
- * @param string $url full URL with scheme
- * @param string|array $name name for the link, array for media file
+ * @param string $url full URL with scheme
+ * @param string|array|null $name name for the link, array for media file
*/
function externallink($url, $name = null) {
if(is_array($name)) {
@@ -628,9 +629,9 @@ class Doku_Renderer_metadata extends Doku_Renderer {
* Construct a title and handle images in titles
*
* @author Harry Fuecks <hfuecks@gmail.com>
- * @param string|array $title either string title or media array
- * @param string $default default title if nothing else is found
- * @param null|string $id linked page id (used to extract title from first heading)
+ * @param string|array|null $title either string title or media array
+ * @param string $default default title if nothing else is found
+ * @param null|string $id linked page id (used to extract title from first heading)
* @return string title text
*/
function _getLinkTitle($title, $default, $id = null) {
diff --git a/inc/parser/parser.php b/inc/parser/parser.php
index df01f3302..7814e94f6 100644
--- a/inc/parser/parser.php
+++ b/inc/parser/parser.php
@@ -61,24 +61,27 @@ class Doku_Parser {
var $connected = false;
- function addBaseMode(& $BaseMode) {
- $this->modes['base'] =& $BaseMode;
+ /**
+ * @param Doku_Parser_Mode_base $BaseMode
+ */
+ function addBaseMode($BaseMode) {
+ $this->modes['base'] = $BaseMode;
if ( !$this->Lexer ) {
$this->Lexer = new Doku_Lexer($this->Handler,'base', true);
}
- $this->modes['base']->Lexer =& $this->Lexer;
+ $this->modes['base']->Lexer = $this->Lexer;
}
/**
* PHP preserves order of associative elements
* Mode sequence is important
*/
- function addMode($name, & $Mode) {
+ function addMode($name, Doku_Parser_Mode_Interface $Mode) {
if ( !isset($this->modes['base']) ) {
$this->addBaseMode(new Doku_Parser_Mode_base());
}
- $Mode->Lexer = & $this->Lexer;
- $this->modes[$name] =& $Mode;
+ $Mode->Lexer = $this->Lexer;
+ $this->modes[$name] = $Mode;
}
function connectModes() {
@@ -139,6 +142,7 @@ interface Doku_Parser_Mode_Interface {
/**
* Called before any calls to connectTo
+ * @return void
*/
function preConnect();
@@ -146,11 +150,13 @@ interface Doku_Parser_Mode_Interface {
* Connects the mode
*
* @param string $mode
+ * @return void
*/
function connectTo($mode);
/**
* Called after all calls to connectTo
+ * @return void
*/
function postConnect();
@@ -220,7 +226,7 @@ class Doku_Parser_Mode_Plugin extends DokuWiki_Plugin implements Doku_Parser_Mod
//-------------------------------------------------------------------
class Doku_Parser_Mode_base extends Doku_Parser_Mode {
- function Doku_Parser_Mode_base() {
+ function __construct() {
global $PARSER_MODES;
$this->allowedModes = array_merge (
@@ -242,7 +248,7 @@ class Doku_Parser_Mode_base extends Doku_Parser_Mode {
//-------------------------------------------------------------------
class Doku_Parser_Mode_footnote extends Doku_Parser_Mode {
- function Doku_Parser_Mode_footnote() {
+ function __construct() {
global $PARSER_MODES;
$this->allowedModes = array_merge (
@@ -407,7 +413,10 @@ class Doku_Parser_Mode_formatting extends Doku_Parser_Mode {
),
);
- function Doku_Parser_Mode_formatting($type) {
+ /**
+ * @param string $type
+ */
+ function __construct($type) {
global $PARSER_MODES;
if ( !array_key_exists($type, $this->formatting) ) {
@@ -461,7 +470,7 @@ class Doku_Parser_Mode_formatting extends Doku_Parser_Mode {
//-------------------------------------------------------------------
class Doku_Parser_Mode_listblock extends Doku_Parser_Mode {
- function Doku_Parser_Mode_listblock() {
+ function __construct() {
global $PARSER_MODES;
$this->allowedModes = array_merge (
@@ -495,7 +504,7 @@ class Doku_Parser_Mode_listblock extends Doku_Parser_Mode {
//-------------------------------------------------------------------
class Doku_Parser_Mode_table extends Doku_Parser_Mode {
- function Doku_Parser_Mode_table() {
+ function __construct() {
global $PARSER_MODES;
$this->allowedModes = array_merge (
@@ -639,7 +648,7 @@ class Doku_Parser_Mode_file extends Doku_Parser_Mode {
//-------------------------------------------------------------------
class Doku_Parser_Mode_quote extends Doku_Parser_Mode {
- function Doku_Parser_Mode_quote() {
+ function __construct() {
global $PARSER_MODES;
$this->allowedModes = array_merge (
@@ -673,7 +682,7 @@ class Doku_Parser_Mode_acronym extends Doku_Parser_Mode {
var $acronyms = array();
var $pattern = '';
- function Doku_Parser_Mode_acronym($acronyms) {
+ function __construct($acronyms) {
usort($acronyms,array($this,'_compare'));
$this->acronyms = $acronyms;
}
@@ -720,7 +729,7 @@ class Doku_Parser_Mode_smiley extends Doku_Parser_Mode {
var $smileys = array();
var $pattern = '';
- function Doku_Parser_Mode_smiley($smileys) {
+ function __construct($smileys) {
$this->smileys = $smileys;
}
@@ -753,7 +762,7 @@ class Doku_Parser_Mode_wordblock extends Doku_Parser_Mode {
var $badwords = array();
var $pattern = '';
- function Doku_Parser_Mode_wordblock($badwords) {
+ function __construct($badwords) {
$this->badwords = $badwords;
}
@@ -788,7 +797,7 @@ class Doku_Parser_Mode_entity extends Doku_Parser_Mode {
var $entities = array();
var $pattern = '';
- function Doku_Parser_Mode_entity($entities) {
+ function __construct($entities) {
$this->entities = $entities;
}
diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php
index 09294539e..d7a3faef8 100644
--- a/inc/parser/renderer.php
+++ b/inc/parser/renderer.php
@@ -190,7 +190,7 @@ class Doku_Renderer extends DokuWiki_Plugin {
/**
* Render plain text data
*
- * @param $text
+ * @param string $text
*/
function cdata($text) {
}
@@ -343,8 +343,9 @@ class Doku_Renderer extends DokuWiki_Plugin {
* Open a list item
*
* @param int $level the nesting level
+ * @param bool $node true when a node; false when a leaf
*/
- function listitem_open($level) {
+ function listitem_open($level,$node=false) {
}
/**
@@ -707,6 +708,18 @@ class Doku_Renderer extends DokuWiki_Plugin {
}
/**
+ * Open a table body
+ */
+ function tabletbody_open() {
+ }
+
+ /**
+ * Close a table body
+ */
+ function tabletbody_close() {
+ }
+
+ /**
* Open a table row
*/
function tablerow_open() {
@@ -759,6 +772,9 @@ class Doku_Renderer extends DokuWiki_Plugin {
* casing and special chars
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $name
+ * @return string
*/
function _simpleTitle($name) {
global $conf;
@@ -778,6 +794,11 @@ class Doku_Renderer extends DokuWiki_Plugin {
/**
* Resolve an interwikilink
+ *
+ * @param string $shortcut identifier for the interwiki link
+ * @param string $reference fragment that refers the content
+ * @param null|bool $exists reference which returns if an internal page exists
+ * @return string interwikilink
*/
function _resolveInterWiki(&$shortcut, $reference, &$exists = null) {
//get interwiki URL
@@ -785,18 +806,26 @@ class Doku_Renderer extends DokuWiki_Plugin {
$url = $this->interwiki[$shortcut];
} else {
// Default to Google I'm feeling lucky
- $url = 'http://www.google.com/search?q={URL}&amp;btnI=lucky';
+ $url = 'https://www.google.com/search?q={URL}&amp;btnI=lucky';
$shortcut = 'go';
}
//split into hash and url part
- @list($reference, $hash) = explode('#', $reference, 2);
+ $hash = strrchr($reference, '#');
+ if($hash) {
+ $reference = substr($reference, 0, -strlen($hash));
+ $hash = substr($hash, 1);
+ }
//replace placeholder
if(preg_match('#\{(URL|NAME|SCHEME|HOST|PORT|PATH|QUERY)\}#', $url)) {
//use placeholders
$url = str_replace('{URL}', rawurlencode($reference), $url);
- $url = str_replace('{NAME}', $reference, $url);
+ //wiki names will be cleaned next, otherwise urlencode unsafe chars
+ $url = str_replace('{NAME}', ($url{0} === ':') ? $reference :
+ preg_replace_callback('/[[\\\\\]^`{|}#%]/', function($match) {
+ return rawurlencode($match[0]);
+ }, $reference), $url);
$parsed = parse_url($reference);
if(!$parsed['port']) $parsed['port'] = 80;
$url = str_replace('{SCHEME}', $parsed['scheme'], $url);
diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php
index 5627a0353..c92892a35 100644
--- a/inc/parser/xhtml.php
+++ b/inc/parser/xhtml.php
@@ -59,10 +59,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
/**
* Register a new edit section range
*
- * @param $type string The section type identifier
- * @param $title string The section title
- * @param $start int The byte position for the edit start
- * @return string A marker class for the starting HTML element
+ * @param string $type The section type identifier
+ * @param string $title The section title
+ * @param int $start The byte position for the edit start
+ * @return string A marker class for the starting HTML element
+ *
* @author Adrian Lang <lang@cosmocode.de>
*/
public function startSectionEdit($start, $type, $title = null) {
@@ -73,8 +74,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
/**
* Finish an edit section range
*
- * @param $end int The byte position for the edit end; null for the rest of
- * the page
+ * @param int $end The byte position for the edit end; null for the rest of the page
+ *
* @author Adrian Lang <lang@cosmocode.de>
*/
public function finishSectionEdit($end = null) {
@@ -456,9 +457,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
* Open a list item
*
* @param int $level the nesting level
+ * @param bool $node true when a node; false when a leaf
*/
- function listitem_open($level) {
- $this->doc .= '<li class="level'.$level.'">';
+ function listitem_open($level, $node=false) {
+ $branching = $node ? ' node' : '';
+ $this->doc .= '<li class="level'.$level.$branching.'">';
}
/**
@@ -758,27 +761,40 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
/**
* Render a CamelCase link
*
- * @param string $link The link name
+ * @param string $link The link name
+ * @param bool $returnonly whether to return html or write to doc attribute
* @see http://en.wikipedia.org/wiki/CamelCase
*/
- function camelcaselink($link) {
- $this->internallink($link, $link);
+ function camelcaselink($link, $returnonly = false) {
+ if($returnonly) {
+ return $this->internallink($link, $link, null, true);
+ } else {
+ $this->internallink($link, $link);
+ }
}
/**
* Render a page local link
*
- * @param string $hash hash link identifier
- * @param string $name name for the link
+ * @param string $hash hash link identifier
+ * @param string $name name for the link
+ * @param bool $returnonly whether to return html or write to doc attribute
*/
- function locallink($hash, $name = null) {
+ function locallink($hash, $name = null, $returnonly = false) {
global $ID;
$name = $this->_getLinkTitle($name, $hash, $isImage);
$hash = $this->_headerToLink($hash);
$title = $ID.' ↵';
- $this->doc .= '<a href="#'.$hash.'" title="'.$title.'" class="wikilink1">';
- $this->doc .= $name;
- $this->doc .= '</a>';
+
+ $doc = '<a href="#'.$hash.'" title="'.$title.'" class="wikilink1">';
+ $doc .= $name;
+ $doc .= '</a>';
+
+ if($returnonly) {
+ return $doc;
+ } else {
+ $this->doc .= $doc;
+ }
}
/**
@@ -821,6 +837,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
// now first resolve and clean up the $id
resolve_pageid(getNS($ID), $id, $exists, $this->date_at, true);
+ $link = array();
$name = $this->_getLinkTitle($name, $default, $isImage, $id, $linktype);
if(!$isImage) {
if($exists) {
@@ -880,10 +897,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
/**
* Render an external link
*
- * @param string $url full URL with scheme
- * @param string|array $name name for the link, array for media file
+ * @param string $url full URL with scheme
+ * @param string|array $name name for the link, array for media file
+ * @param bool $returnonly whether to return html or write to doc attribute
*/
- function externallink($url, $name = null) {
+ function externallink($url, $name = null, $returnonly = false) {
global $conf;
$name = $this->_getLinkTitle($name, $url, $isImage);
@@ -896,7 +914,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
// is there still an URL?
if(!$url) {
- $this->doc .= $name;
+ if($returnonly) {
+ return $name;
+ } else {
+ $this->doc .= $name;
+ }
return;
}
@@ -908,6 +930,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
}
//prepare for formating
+ $link = array();
$link['target'] = $conf['target']['extern'];
$link['style'] = '';
$link['pre'] = '';
@@ -921,7 +944,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
if($conf['relnofollow']) $link['more'] .= ' rel="nofollow"';
//output formatted
- $this->doc .= $this->_formatLink($link);
+ if($returnonly) {
+ return $this->_formatLink($link);
+ } else {
+ $this->doc .= $this->_formatLink($link);
+ }
}
/**
@@ -929,12 +956,13 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*
* You may want to use $this->_resolveInterWiki() here
*
- * @param string $match original link - probably not much use
- * @param string|array $name name for the link, array for media file
- * @param string $wikiName indentifier (shortcut) for the remote wiki
- * @param string $wikiUri the fragment parsed from the original link
+ * @param string $match original link - probably not much use
+ * @param string|array $name name for the link, array for media file
+ * @param string $wikiName indentifier (shortcut) for the remote wiki
+ * @param string $wikiUri the fragment parsed from the original link
+ * @param bool $returnonly whether to return html or write to doc attribute
*/
- function interwikilink($match, $name = null, $wikiName, $wikiUri) {
+ function interwikilink($match, $name = null, $wikiName, $wikiUri, $returnonly = false) {
global $conf;
$link = array();
@@ -972,19 +1000,25 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$link['title'] = htmlspecialchars($link['url']);
//output formatted
- $this->doc .= $this->_formatLink($link);
+ if($returnonly) {
+ return $this->_formatLink($link);
+ } else {
+ $this->doc .= $this->_formatLink($link);
+ }
}
/**
* Link to windows share
*
- * @param string $url the link
- * @param string|array $name name for the link, array for media file
+ * @param string $url the link
+ * @param string|array $name name for the link, array for media file
+ * @param bool $returnonly whether to return html or write to doc attribute
*/
- function windowssharelink($url, $name = null) {
+ function windowssharelink($url, $name = null, $returnonly = false) {
global $conf;
//simple setup
+ $link = array();
$link['target'] = $conf['target']['windows'];
$link['pre'] = '';
$link['suf'] = '';
@@ -999,11 +1033,16 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$link['title'] = $this->_xmlEntities($url);
$url = str_replace('\\', '/', $url);
+ $url = ltrim($url,'/');
$url = 'file:///'.$url;
$link['url'] = $url;
//output formatted
- $this->doc .= $this->_formatLink($link);
+ if($returnonly) {
+ return $this->_formatLink($link);
+ } else {
+ $this->doc .= $this->_formatLink($link);
+ }
}
/**
@@ -1011,10 +1050,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
*
* Honors $conf['mailguard'] setting
*
- * @param string $address Email-Address
- * @param string|array $name name for the link, array for media file
+ * @param string $address Email-Address
+ * @param string|array $name name for the link, array for media file
+ * @param bool $returnonly whether to return html or write to doc attribute
*/
- function emaillink($address, $name = null) {
+ function emaillink($address, $name = null, $returnonly = false) {
global $conf;
//simple setup
$link = array();
@@ -1046,7 +1086,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$link['title'] = $title;
//output formatted
- $this->doc .= $this->_formatLink($link);
+ if($returnonly) {
+ return $this->_formatLink($link);
+ } else {
+ $this->doc .= $this->_formatLink($link);
+ }
}
/**
@@ -1171,6 +1215,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
error_reporting($elvl);
}
+ if($params['nosort']) $feed->enable_order_by_date(false);
+
//decide on start and end
if($params['reverse']) {
$mod = -1;
@@ -1281,6 +1327,20 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
}
/**
+ * Open a table body
+ */
+ function tabletbody_open() {
+ $this->doc .= DOKU_TAB.'<tbody>'.DOKU_LF;
+ }
+
+ /**
+ * Close a table body
+ */
+ function tabletbody_close() {
+ $this->doc .= DOKU_TAB.'</tbody>'.DOKU_LF;
+ }
+
+ /**
* Open a table row
*/
function tablerow_open() {
@@ -1575,7 +1635,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
* Returns HTML code for images used in link titles
*
* @author Andreas Gohr <andi@splitbrain.org>
- * @param string $img
+ * @param array $img
* @return string HTML img tag or similar
*/
function _imageTitle($img) {
@@ -1660,7 +1720,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
// prepare alternative formats
$extensions = array('webm', 'ogv', 'mp4');
$files = media_alternativefiles($src, $extensions);
- $poster = media_alternativefiles($src, array('jpg', 'png'), true);
+ $poster = media_alternativefiles($src, array('jpg', 'png'));
if(!empty($poster)) {
$posterUrl = ml(reset($poster), '', true, '&');
}
@@ -1704,7 +1764,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
* @param array $atts - additional attributes for the <audio> tag
* @return string
*/
- function _audio($src, $atts = null) {
+ function _audio($src, $atts = array()) {
$files = array();
$isExternal = media_isexternal($src);
@@ -1744,7 +1804,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$out .= '</audio>'.NL;
return $out;
}
-
+
/**
* _getLastMediaRevisionAt is a helperfunction to internalmedia() and _media()
* which returns an existing media revision less or equal to rev or date_at