From f05a1cc5fcdb4c2b6ee3cbf499f980f800dbd105 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Thu, 17 Oct 2013 23:11:33 +0200 Subject: Wrap thead around 1st row, when 1st cell at 1st row is tableheader. Implements FS#1764 --- inc/parser/renderer.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'inc/parser/renderer.php') diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index c697e990c..ee0b2344d 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -245,6 +245,10 @@ class Doku_Renderer extends DokuWiki_Plugin { function table_close($pos = null){} + function tablethead_open(){} + + function tablethead_close(){} + function tablerow_open(){} function tablerow_close(){} -- cgit v1.2.3 From 8cc41db0f42cbb8028c05720e98b98451463c403 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 8 Jan 2014 21:14:51 +0100 Subject: fix renderer:plugin() signature in 82d616353e4c3680d88f083eb6f88fe68de92904 we introduced passing the raw match for syntax plugins to the plugin method of the renderer. This was introduced for renderer plugins that might need access to the raw syntax (like the table editor or WYSIWYG plugins). However the function signature was never updated, making these additional parameter basically secret. With strict standard this throws errors. This patch fixes this. --- inc/parser/renderer.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'inc/parser/renderer.php') diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index c697e990c..e3401fd48 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -59,9 +59,15 @@ class Doku_Renderer extends DokuWiki_Plugin { return false; } - - //handle plugin rendering - function plugin($name,$data){ + /** + * handle plugin rendering + * + * @param string $name Plugin name + * @param mixed $data custom data set by handler + * @param string $state matched state if any + * @param string $match raw matched syntax + */ + function plugin($name,$data,$state='',$match=''){ $plugin = plugin_load('syntax',$name); if($plugin != null){ $plugin->render($this->getFormat(),$this,$data); -- cgit v1.2.3 From 2345e871e407dbece52f3181cd8b077f07cbb0c1 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sat, 15 Feb 2014 11:11:15 +0100 Subject: wikilink creating refactored to _resolveinterwiki(). Added DOKU_BASE for local target --- inc/parser/renderer.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'inc/parser/renderer.php') diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index e3401fd48..66a106b11 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -321,6 +321,11 @@ class Doku_Renderer extends DokuWiki_Plugin { //default $url = $url.rawurlencode($reference); } + //url without slashes is handled as a pageid + if(strpos($url,'/') === false) { + list($url, $urlparam) = explode('?', $url, 2); + $url = wl($url, $urlparam); + } if($hash) $url .= '#'.rawurlencode($hash); return $url; -- cgit v1.2.3 From 5a9ce44695f44ecc76f356c1fc26f0a1846231b7 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sat, 15 Feb 2014 11:17:09 +0100 Subject: code reformatting --- inc/parser/renderer.php | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'inc/parser/renderer.php') diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index 66a106b11..d01fc3899 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -273,17 +273,17 @@ class Doku_Renderer extends DokuWiki_Plugin { * * @author Andreas Gohr */ - function _simpleTitle($name){ + function _simpleTitle($name) { global $conf; //if there is a hash we use the ancor name only - list($name,$hash) = explode('#',$name,2); + list($name, $hash) = explode('#', $name, 2); if($hash) return $hash; - if($conf['useslash']){ - $name = strtr($name,';/',';:'); - }else{ - $name = strtr($name,';',':'); + if($conf['useslash']) { + $name = strtr($name, ';/', ';:'); + } else { + $name = strtr($name, ';', ':'); } return noNSorNS($name); @@ -292,9 +292,9 @@ class Doku_Renderer extends DokuWiki_Plugin { /** * Resolve an interwikilink */ - function _resolveInterWiki(&$shortcut,$reference){ + function _resolveInterWiki(&$shortcut, $reference) { //get interwiki URL - if ( isset($this->interwiki[$shortcut]) ) { + if(isset($this->interwiki[$shortcut])) { $url = $this->interwiki[$shortcut]; } else { // Default to Google I'm feeling lucky @@ -303,30 +303,30 @@ class Doku_Renderer extends DokuWiki_Plugin { } //split into hash and url part - list($reference,$hash) = explode('#',$reference,2); + list($reference, $hash) = explode('#', $reference, 2); //replace placeholder - if(preg_match('#\{(URL|NAME|SCHEME|HOST|PORT|PATH|QUERY)\}#',$url)){ + 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); + $url = str_replace('{URL}', rawurlencode($reference), $url); + $url = str_replace('{NAME}', $reference, $url); $parsed = parse_url($reference); if(!$parsed['port']) $parsed['port'] = 80; - $url = str_replace('{SCHEME}',$parsed['scheme'],$url); - $url = str_replace('{HOST}',$parsed['host'],$url); - $url = str_replace('{PORT}',$parsed['port'],$url); - $url = str_replace('{PATH}',$parsed['path'],$url); - $url = str_replace('{QUERY}',$parsed['query'],$url); - }else{ + $url = str_replace('{SCHEME}', $parsed['scheme'], $url); + $url = str_replace('{HOST}', $parsed['host'], $url); + $url = str_replace('{PORT}', $parsed['port'], $url); + $url = str_replace('{PATH}', $parsed['path'], $url); + $url = str_replace('{QUERY}', $parsed['query'], $url); + } else { //default - $url = $url.rawurlencode($reference); + $url = $url . rawurlencode($reference); } //url without slashes is handled as a pageid - if(strpos($url,'/') === false) { + if(strpos($url, '/') === false) { list($url, $urlparam) = explode('?', $url, 2); $url = wl($url, $urlparam); } - if($hash) $url .= '#'.rawurlencode($hash); + if($hash) $url .= '#' . rawurlencode($hash); return $url; } -- cgit v1.2.3 From 6496c33fc8e98f6e3acaaa5db0234d9c07bec4fe Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sat, 15 Feb 2014 14:34:26 +0100 Subject: interwiki : prefixed configurls handled as wikilinks --- inc/parser/renderer.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'inc/parser/renderer.php') diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index d01fc3899..fa70c299e 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -292,7 +292,7 @@ class Doku_Renderer extends DokuWiki_Plugin { /** * Resolve an interwikilink */ - function _resolveInterWiki(&$shortcut, $reference) { + function _resolveInterWiki(&$shortcut, $reference, &$exists=null) { //get interwiki URL if(isset($this->interwiki[$shortcut])) { $url = $this->interwiki[$shortcut]; @@ -322,9 +322,10 @@ class Doku_Renderer extends DokuWiki_Plugin { $url = $url . rawurlencode($reference); } //url without slashes is handled as a pageid - if(strpos($url, '/') === false) { - list($url, $urlparam) = explode('?', $url, 2); - $url = wl($url, $urlparam); + if($url{0} === ':') { + list($id, $urlparam) = explode('?', $url, 2); + $url = wl(cleanID($id), $urlparam); + $exists = page_exists($id); } if($hash) $url .= '#' . rawurlencode($hash); -- cgit v1.2.3 From f379edc2c80eee8cab2b94a4374113a0100f3929 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sat, 15 Feb 2014 16:51:48 +0100 Subject: fix comment in _resolveInterWiki --- inc/parser/renderer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/parser/renderer.php') diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index fa70c299e..01a1fbfec 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -321,7 +321,7 @@ class Doku_Renderer extends DokuWiki_Plugin { //default $url = $url . rawurlencode($reference); } - //url without slashes is handled as a pageid + //handle as wiki links if($url{0} === ':') { list($id, $urlparam) = explode('?', $url, 2); $url = wl(cleanID($id), $urlparam); -- cgit v1.2.3 From 2ada8709d3a0cea872f117823b244b400fac5f87 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Tue, 25 Feb 2014 20:32:56 +0000 Subject: add renderers to autolader --- inc/parser/renderer.php | 1 - 1 file changed, 1 deletion(-) (limited to 'inc/parser/renderer.php') diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index e3401fd48..6b6a1770b 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -6,7 +6,6 @@ * @author Andreas Gohr */ if(!defined('DOKU_INC')) die('meh.'); -require_once DOKU_INC . 'inc/plugin.php'; require_once DOKU_INC . 'inc/pluginutils.php'; /** -- cgit v1.2.3 From 489dcad6f038c54dda1f29c0887fa43f5b3f7fcb Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Fri, 28 Feb 2014 16:56:29 +0000 Subject: remove require handled by autoloader --- inc/parser/renderer.php | 1 - 1 file changed, 1 deletion(-) (limited to 'inc/parser/renderer.php') diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index 6b6a1770b..1f9ad00a2 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -6,7 +6,6 @@ * @author Andreas Gohr */ if(!defined('DOKU_INC')) die('meh.'); -require_once DOKU_INC . 'inc/pluginutils.php'; /** * An empty renderer, produces no output -- cgit v1.2.3 From 6d2af55dde922ac10a288b4195b1bf338e7bc5a9 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Wed, 5 Mar 2014 22:01:20 +0000 Subject: suppress errors where list() may not fill all vars --- inc/parser/renderer.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'inc/parser/renderer.php') diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index 1f9ad00a2..e748c36d8 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -274,8 +274,8 @@ class Doku_Renderer extends DokuWiki_Plugin { function _simpleTitle($name){ global $conf; - //if there is a hash we use the ancor name only - list($name,$hash) = explode('#',$name,2); + //if there is a hash we use the anchor name only + @list($name,$hash) = explode('#',$name,2); if($hash) return $hash; if($conf['useslash']){ @@ -301,7 +301,7 @@ class Doku_Renderer extends DokuWiki_Plugin { } //split into hash and url part - list($reference,$hash) = explode('#',$reference,2); + @list($reference,$hash) = explode('#',$reference,2); //replace placeholder if(preg_match('#\{(URL|NAME|SCHEME|HOST|PORT|PATH|QUERY)\}#',$url)){ -- cgit v1.2.3 From 2c2835c2888035a0b3b1fd8b096a962a0a5c40b5 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 24 May 2014 11:23:52 +0200 Subject: reformatting --- inc/parser/renderer.php | 285 +++++++++++++++++++++++++++++++----------------- 1 file changed, 182 insertions(+), 103 deletions(-) (limited to 'inc/parser/renderer.php') diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index e92b81bd7..71eeda952 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -44,7 +44,7 @@ class Doku_Renderer extends DokuWiki_Plugin { * * Has to be overidden by decendend classes */ - function getFormat(){ + function getFormat() { trigger_error('getFormat() not implemented in '.get_class($this), E_USER_WARNING); } @@ -60,15 +60,15 @@ class Doku_Renderer extends DokuWiki_Plugin { /** * handle plugin rendering * - * @param string $name Plugin name - * @param mixed $data custom data set by handler + * @param string $name Plugin name + * @param mixed $data custom data set by handler * @param string $state matched state if any * @param string $match raw matched syntax */ - function plugin($name,$data,$state='',$match=''){ - $plugin = plugin_load('syntax',$name); - if($plugin != null){ - $plugin->render($this->getFormat(),$this,$data); + function plugin($name, $data, $state = '', $match = '') { + $plugin = plugin_load('syntax', $name); + if($plugin != null) { + $plugin->render($this->getFormat(), $this, $data); } } @@ -78,9 +78,9 @@ class Doku_Renderer extends DokuWiki_Plugin { */ function nest($instructions) { - foreach ( $instructions as $instruction ) { + foreach($instructions as $instruction) { // execute the callback against ourself - if (method_exists($this,$instruction[0])) { + if(method_exists($this, $instruction[0])) { call_user_func_array(array($this, $instruction[0]), $instruction[1] ? $instruction[1] : array()); } } @@ -89,186 +89,265 @@ class Doku_Renderer extends DokuWiki_Plugin { // dummy closing instruction issued by Doku_Handler_Nest, normally the syntax mode should // override this instruction when instantiating Doku_Handler_Nest - however plugins will not // be able to - as their instructions require data. - function nest_close() {} + function nest_close() { + } - function document_start() {} + function document_start() { + } - function document_end() {} + function document_end() { + } - function render_TOC() { return ''; } + function render_TOC() { + return ''; + } - function toc_additem($id, $text, $level) {} + function toc_additem($id, $text, $level) { + } - function header($text, $level, $pos) {} + function header($text, $level, $pos) { + } - function section_open($level) {} + function section_open($level) { + } - function section_close() {} + function section_close() { + } - function cdata($text) {} + function cdata($text) { + } - function p_open() {} + function p_open() { + } - function p_close() {} + function p_close() { + } - function linebreak() {} + function linebreak() { + } - function hr() {} + function hr() { + } - function strong_open() {} + function strong_open() { + } - function strong_close() {} + function strong_close() { + } - function emphasis_open() {} + function emphasis_open() { + } - function emphasis_close() {} + function emphasis_close() { + } - function underline_open() {} + function underline_open() { + } - function underline_close() {} + function underline_close() { + } - function monospace_open() {} + function monospace_open() { + } - function monospace_close() {} + function monospace_close() { + } - function subscript_open() {} + function subscript_open() { + } - function subscript_close() {} + function subscript_close() { + } - function superscript_open() {} + function superscript_open() { + } - function superscript_close() {} + function superscript_close() { + } - function deleted_open() {} + function deleted_open() { + } - function deleted_close() {} + function deleted_close() { + } - function footnote_open() {} + function footnote_open() { + } - function footnote_close() {} + function footnote_close() { + } - function listu_open() {} + function listu_open() { + } - function listu_close() {} + function listu_close() { + } - function listo_open() {} + function listo_open() { + } - function listo_close() {} + function listo_close() { + } - function listitem_open($level) {} + function listitem_open($level) { + } - function listitem_close() {} + function listitem_close() { + } - function listcontent_open() {} + function listcontent_open() { + } - function listcontent_close() {} + function listcontent_close() { + } - function unformatted($text) {} + function unformatted($text) { + } - function php($text) {} + function php($text) { + } - function phpblock($text) {} + function phpblock($text) { + } - function html($text) {} + function html($text) { + } - function htmlblock($text) {} + function htmlblock($text) { + } - function preformatted($text) {} + function preformatted($text) { + } - function quote_open() {} + function quote_open() { + } - function quote_close() {} + function quote_close() { + } - function file($text, $lang = null, $file = null ) {} + function file($text, $lang = null, $file = null) { + } - function code($text, $lang = null, $file = null ) {} + function code($text, $lang = null, $file = null) { + } - function acronym($acronym) {} + function acronym($acronym) { + } - function smiley($smiley) {} + function smiley($smiley) { + } - function wordblock($word) {} + function wordblock($word) { + } - function entity($entity) {} + function entity($entity) { + } // 640x480 ($x=640, $y=480) - function multiplyentity($x, $y) {} + function multiplyentity($x, $y) { + } - function singlequoteopening() {} + function singlequoteopening() { + } - function singlequoteclosing() {} + function singlequoteclosing() { + } - function apostrophe() {} + function apostrophe() { + } - function doublequoteopening() {} + function doublequoteopening() { + } - function doublequoteclosing() {} + function doublequoteclosing() { + } // $link like 'SomePage' - function camelcaselink($link) {} + function camelcaselink($link) { + } - function locallink($hash, $name = null) {} + function locallink($hash, $name = null) { + } // $link like 'wiki:syntax', $title could be an array (media) - function internallink($link, $title = null) {} + function internallink($link, $title = null) { + } // $link is full URL with scheme, $title could be an array (media) - function externallink($link, $title = null) {} + function externallink($link, $title = null) { + } - function rss ($url,$params) {} + function rss($url, $params) { + } // $link is the original link - probably not much use // $wikiName is an indentifier for the wiki // $wikiUri is the URL fragment to append to some known URL - function interwikilink($link, $title = null, $wikiName, $wikiUri) {} + function interwikilink($link, $title = null, $wikiName, $wikiUri) { + } // Link to file on users OS, $title could be an array (media) - function filelink($link, $title = null) {} + function filelink($link, $title = null) { + } // Link to a Windows share, , $title could be an array (media) - function windowssharelink($link, $title = null) {} + function windowssharelink($link, $title = null) { + } // function email($address, $title = null) {} - function emaillink($address, $name = null) {} + function emaillink($address, $name = null) { + } - function internalmedia ($src, $title=null, $align=null, $width=null, - $height=null, $cache=null, $linking=null) {} + function internalmedia($src, $title = null, $align = null, $width = null, + $height = null, $cache = null, $linking = null) { + } - function externalmedia ($src, $title=null, $align=null, $width=null, - $height=null, $cache=null, $linking=null) {} + function externalmedia($src, $title = null, $align = null, $width = null, + $height = null, $cache = null, $linking = null) { + } - function internalmedialink ( - $src,$title=null,$align=null,$width=null,$height=null,$cache=null - ) {} + function internalmedialink( + $src, $title = null, $align = null, $width = null, $height = null, $cache = null + ) { + } function externalmedialink( - $src,$title=null,$align=null,$width=null,$height=null,$cache=null - ) {} - - function table_open($maxcols = null, $numrows = null, $pos = null){} + $src, $title = null, $align = null, $width = null, $height = null, $cache = null + ) { + } - function table_close($pos = null){} + function table_open($maxcols = null, $numrows = null, $pos = null) { + } - function tablethead_open(){} + function table_close($pos = null) { + } - function tablethead_close(){} + function tablethead_open() { + } - function tablerow_open(){} + function tablethead_close() { + } - function tablerow_close(){} + function tablerow_open() { + } - function tableheader_open($colspan = 1, $align = null, $rowspan = 1){} + function tablerow_close() { + } - function tableheader_close(){} + function tableheader_open($colspan = 1, $align = null, $rowspan = 1) { + } - function tablecell_open($colspan = 1, $align = null, $rowspan = 1){} + function tableheader_close() { + } - function tablecell_close(){} + function tablecell_open($colspan = 1, $align = null, $rowspan = 1) { + } + function tablecell_close() { + } // util functions follow, you probably won't need to reimplement them - /** * Removes any Namespace from the given name but keeps * casing and special chars @@ -294,13 +373,13 @@ class Doku_Renderer extends DokuWiki_Plugin { /** * Resolve an interwikilink */ - function _resolveInterWiki(&$shortcut, $reference, &$exists=null) { + function _resolveInterWiki(&$shortcut, $reference, &$exists = null) { //get interwiki URL if(isset($this->interwiki[$shortcut])) { $url = $this->interwiki[$shortcut]; } else { // Default to Google I'm feeling lucky - $url = 'http://www.google.com/search?q={URL}&btnI=lucky'; + $url = 'http://www.google.com/search?q={URL}&btnI=lucky'; $shortcut = 'go'; } @@ -310,8 +389,8 @@ class Doku_Renderer extends DokuWiki_Plugin { //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); + $url = str_replace('{URL}', rawurlencode($reference), $url); + $url = str_replace('{NAME}', $reference, $url); $parsed = parse_url($reference); if(!$parsed['port']) $parsed['port'] = 80; $url = str_replace('{SCHEME}', $parsed['scheme'], $url); @@ -321,15 +400,15 @@ class Doku_Renderer extends DokuWiki_Plugin { $url = str_replace('{QUERY}', $parsed['query'], $url); } else { //default - $url = $url . rawurlencode($reference); + $url = $url.rawurlencode($reference); } //handle as wiki links if($url{0} === ':') { list($id, $urlparam) = explode('?', $url, 2); - $url = wl(cleanID($id), $urlparam); + $url = wl(cleanID($id), $urlparam); $exists = page_exists($id); } - if($hash) $url .= '#' . rawurlencode($hash); + if($hash) $url .= '#'.rawurlencode($hash); return $url; } -- cgit v1.2.3 From cfa2b40e6bb053ff32af7199e4177fbbb92b0a57 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 24 May 2014 14:00:43 +0200 Subject: added doc blocks to all functions in renderer --- inc/parser/renderer.php | 492 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 447 insertions(+), 45 deletions(-) (limited to 'inc/parser/renderer.php') diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index 71eeda952..a486ed106 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -13,52 +13,79 @@ if(!defined('DOKU_INC')) die('meh.'); * Inherits from DokuWiki_Plugin for giving additional functions to render plugins */ class Doku_Renderer extends DokuWiki_Plugin { - var $info = array( + /** @var array Settings, control the behavior of the renderer */ + public $info = array( 'cache' => true, // may the rendered result cached? 'toc' => true, // render the TOC? ); - var $doc = ''; + /** @var array contains the smiley configuration, set in p_render() */ + public $smileys = array(); + /** @var array contains the entity configuration, set in p_render() */ + public $entities = array(); + /** @var array contains the acronym configuration, set in p_render() */ + public $acronyms = array(); + /** @var array contains the interwiki configuration, set in p_render() */ + public $interwiki = array(); - // keep some config options - var $acronyms = array(); - var $smileys = array(); - var $badwords = array(); - var $entities = array(); - var $interwiki = array(); + /** + * @var string the rendered document, this will be cached after the renderer ran through + */ + public $doc = ''; - // allows renderer to be used again, clean out any per-use values + /** + * clean out any per-use values + * + * This is called before each use of the renderer object and should be used to + * completely reset the state of the renderer to be reused for a new document + */ function reset() { } - function nocache() { - $this->info['cache'] = false; - } - - function notoc() { - $this->info['toc'] = false; + /** + * Allow the plugin to prevent DokuWiki from reusing an instance + * + * Since most renderer plugins fail to implement Doku_Renderer::reset() we default + * to reinstantiating the renderer here + * + * @return bool false if the plugin has to be instantiated + */ + function isSingleton() { + return false; } /** * Returns the format produced by this renderer. * - * Has to be overidden by decendend classes + * Has to be overidden by sub classes + * + * @return string */ function getFormat() { trigger_error('getFormat() not implemented in '.get_class($this), E_USER_WARNING); + return ''; } /** - * Allow the plugin to prevent DokuWiki from reusing an instance + * Disable caching of this renderer's output + */ + function nocache() { + $this->info['cache'] = false; + } + + /** + * Disable TOC generation for this renderer's output * - * @return bool false if the plugin has to be instantiated + * This might not be used for certain sub renderer */ - function isSingleton() { - return false; + function notoc() { + $this->info['toc'] = false; } /** - * handle plugin rendering + * Handle plugin rendering + * + * Most likely this needs NOT to be overwritten by sub classes * * @param string $name Plugin name * @param mixed $data custom data set by handler @@ -66,6 +93,7 @@ class Doku_Renderer extends DokuWiki_Plugin { * @param string $match raw matched syntax */ function plugin($name, $data, $state = '', $match = '') { + /** @var DokuWiki_Syntax_Plugin $plugin */ $plugin = plugin_load('syntax', $name); if($plugin != null) { $plugin->render($this->getFormat(), $this, $data); @@ -75,9 +103,10 @@ class Doku_Renderer extends DokuWiki_Plugin { /** * handle nested render instructions * this method (and nest_close method) should not be overloaded in actual renderer output classes + * + * @param array $instructions */ function nest($instructions) { - foreach($instructions as $instruction) { // execute the callback against ourself if(method_exists($this, $instruction[0])) { @@ -86,267 +115,638 @@ class Doku_Renderer extends DokuWiki_Plugin { } } - // dummy closing instruction issued by Doku_Handler_Nest, normally the syntax mode should - // override this instruction when instantiating Doku_Handler_Nest - however plugins will not - // be able to - as their instructions require data. + /** + * dummy closing instruction issued by Doku_Handler_Nest + * + * normally the syntax mode should override this instruction when instantiating Doku_Handler_Nest - + * however plugins will not be able to - as their instructions require data. + */ function nest_close() { } + #region Syntax modes - sub classes will need to implement them to fill $doc + + /** + * Initialize the document + */ function document_start() { } + /** + * Finalize the document + */ function document_end() { } + /** + * Render the Table of Contents + * + * @return string + */ function render_TOC() { return ''; } + /** + * Add an item to the TOC + * + * @param string $id the hash link + * @param string $text the text to display + * @param int $level the nesting level + */ function toc_additem($id, $text, $level) { } + /** + * Render a heading + * + * @param string $text the text to display + * @param int $level header level + * @param int $pos byte position in the original source + */ function header($text, $level, $pos) { } + /** + * Open a new section + * + * @param int $level section level (as determined by the previous header) + */ function section_open($level) { } + /** + * Close the current section + */ function section_close() { } + /** + * Render plain text data + * + * @param $text + */ function cdata($text) { } + /** + * Open a paragraph + */ function p_open() { } + /** + * Close a paragraph + */ function p_close() { } + /** + * Create a line breake + */ function linebreak() { } + /** + * Create a horizontal line + */ function hr() { } + /** + * Start strong (bold) formatting + */ function strong_open() { } + /** + * Stop strong (bold) formatting + */ function strong_close() { } + /** + * Start emphasis (italics) formatting + */ function emphasis_open() { } + /** + * Stop emphasis (italics) formatting + */ function emphasis_close() { } + /** + * Start underline formatting + */ function underline_open() { } + /** + * Stop underline formatting + */ function underline_close() { } + /** + * Start monospace formatting + */ function monospace_open() { } + /** + * Stop monospace formatting + */ function monospace_close() { } + /** + * Start a subscript + */ function subscript_open() { } + /** + * Stop a subscript + */ function subscript_close() { } + /** + * Start a superscript + */ function superscript_open() { } + /** + * Stop a superscript + */ function superscript_close() { } + /** + * Start deleted (strike-through) formatting + */ function deleted_open() { } + /** + * Stop deleted (strike-through) formatting + */ function deleted_close() { } + /** + * Start a footnote + */ function footnote_open() { } + /** + * Stop a footnote + */ function footnote_close() { } + /** + * Open an unordered list + */ function listu_open() { } + /** + * Close an unordered list + */ function listu_close() { } + /** + * Open an ordered list + */ function listo_open() { } + /** + * Close an ordered list + */ function listo_close() { } + /** + * Open a list item + * + * @param int $level the nesting level + */ function listitem_open($level) { } + /** + * Close a list item + */ function listitem_close() { } + /** + * Start the content of a list item + */ function listcontent_open() { } + /** + * Stop the content of a list item + */ function listcontent_close() { } + /** + * Output unformatted $text + * + * Defaults to $this->cdata() + * + * @param string $text + */ function unformatted($text) { + $this->cdata($text); } + /** + * Output inline PHP code + * + * If $conf['phpok'] is true this should evaluate the given code and append the result + * to $doc + * + * @param string $text The PHP code + */ function php($text) { } + /** + * Output block level PHP code + * + * If $conf['phpok'] is true this should evaluate the given code and append the result + * to $doc + * + * @param string $text The PHP code + */ function phpblock($text) { } + /** + * Output raw inline HTML + * + * If $conf['htmlok'] is true this should add the code as is to $doc + * + * @param string $text The HTML + */ function html($text) { } + /** + * Output raw block-level HTML + * + * If $conf['htmlok'] is true this should add the code as is to $doc + * + * @param string $text The HTML + */ function htmlblock($text) { } + /** + * Output preformatted text + * + * @param string $text + */ function preformatted($text) { } + /** + * Start a block quote + */ function quote_open() { } + /** + * Stop a block quote + */ function quote_close() { } + /** + * Display text as file content, optionally syntax highlighted + * + * @param string $text text to show + * @param string $lang programming language to use for syntax highlighting + * @param string $file file path label + */ function file($text, $lang = null, $file = null) { } + /** + * Display text as code content, optionally syntax highlighted + * + * @param string $text text to show + * @param string $lang programming language to use for syntax highlighting + * @param string $file file path label + */ function code($text, $lang = null, $file = null) { } + /** + * Format an acronym + * + * Uses $this->acronyms + * + * @param string $acronym + */ function acronym($acronym) { } + /** + * Format a smiley + * + * Uses $this->smiley + * + * @param string $smiley + */ function smiley($smiley) { } - function wordblock($word) { - } - + /** + * Format an entity + * + * Entities are basically small text replacements + * + * Uses $this->entities + * + * @param string $entity + */ function entity($entity) { } - // 640x480 ($x=640, $y=480) + /** + * Typographically format a multiply sign + * + * Example: ($x=640, $y=480) should result in "640×480" + * + * @param string|int $x first value + * @param string|int $y second value + */ function multiplyentity($x, $y) { } + /** + * Render an opening single quote char (language specific) + */ function singlequoteopening() { } + /** + * Render a closing single quote char (language specific) + */ function singlequoteclosing() { } + /** + * Render an apostrophe char (language specific) + */ function apostrophe() { } + /** + * Render an opening double quote char (language specific) + */ function doublequoteopening() { } + /** + * Render an closinging double quote char (language specific) + */ function doublequoteclosing() { } - // $link like 'SomePage' + /** + * Render a CamelCase link + * + * @param string $link The link name + * @see http://en.wikipedia.org/wiki/CamelCase + */ function camelcaselink($link) { } + /** + * Render a page local link + * + * @param string $hash hash link identifier + * @param string $name name for the link + */ function locallink($hash, $name = null) { } - // $link like 'wiki:syntax', $title could be an array (media) + /** + * Render a wiki internal link + * + * @param string $link page ID to link to. eg. 'wiki:syntax' + * @param string|array $title name for the link, array for media file + */ function internallink($link, $title = null) { } - // $link is full URL with scheme, $title could be an array (media) + /** + * Render an external link + * + * @param string $link full URL with scheme + * @param string|array $title name for the link, array for media file + */ function externallink($link, $title = null) { } + /** + * Render the output of an RSS feed + * + * @param string $url URL of the feed + * @param array $params Finetuning of the output + */ function rss($url, $params) { } - // $link is the original link - probably not much use - // $wikiName is an indentifier for the wiki - // $wikiUri is the URL fragment to append to some known URL + /** + * Render an interwiki link + * + * You may want to use $this->_resolveInterWiki() here + * + * @param string $link original link - probably not much use + * @param string|array $title 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 + */ function interwikilink($link, $title = null, $wikiName, $wikiUri) { } - // Link to file on users OS, $title could be an array (media) + /** + * Link to file on users OS + * + * @param string $link the link + * @param string|array $title name for the link, array for media file + */ function filelink($link, $title = null) { } - // Link to a Windows share, , $title could be an array (media) + /** + * Link to windows share + * + * @param string $link the link + * @param string|array $title name for the link, array for media file + */ function windowssharelink($link, $title = null) { } -// function email($address, $title = null) {} + /** + * Render a linked E-Mail Address + * + * Should honor $conf['mailguard'] setting + * + * @param string $address Email-Address + * @param string $name Display name + */ function emaillink($address, $name = null) { } + /** + * Render an internal media file + * + * @param string $src media ID + * @param string $title descriptive text + * @param string $align left|center|right + * @param int $width width of media in pixel + * @param int $height height of media in pixel + * @param string $cache cache|recache|nocache + * @param string $linking linkonly|detail|nolink + */ function internalmedia($src, $title = null, $align = null, $width = null, $height = null, $cache = null, $linking = null) { } + /** + * Render an external media file + * + * @param string $src full media URL + * @param string $title descriptive text + * @param string $align left|center|right + * @param int $width width of media in pixel + * @param int $height height of media in pixel + * @param string $cache cache|recache|nocache + * @param string $linking linkonly|detail|nolink + */ function externalmedia($src, $title = null, $align = null, $width = null, $height = null, $cache = null, $linking = null) { } - function internalmedialink( - $src, $title = null, $align = null, $width = null, $height = null, $cache = null - ) { + /** + * Render a link to an internal media file + * + * @param string $src media ID + * @param string $title descriptive text + * @param string $align left|center|right + * @param int $width width of media in pixel + * @param int $height height of media in pixel + * @param string $cache cache|recache|nocache + */ + function internalmedialink($src, $title = null, $align = null, + $width = null, $height = null, $cache = null) { } - function externalmedialink( - $src, $title = null, $align = null, $width = null, $height = null, $cache = null - ) { + /** + * Render a link to an external media file + * + * @param string $src media ID + * @param string $title descriptive text + * @param string $align left|center|right + * @param int $width width of media in pixel + * @param int $height height of media in pixel + * @param string $cache cache|recache|nocache + */ + function externalmedialink($src, $title = null, $align = null, + $width = null, $height = null, $cache = null) { } + /** + * Start a table + * + * @param int $maxcols maximum number of columns + * @param int $numrows NOT IMPLEMENTED + * @param int $pos byte position in the original source + */ function table_open($maxcols = null, $numrows = null, $pos = null) { } + /** + * Close a table + * + * @param int $pos byte position in the original source + */ function table_close($pos = null) { } + /** + * Open a table header + */ function tablethead_open() { } + /** + * Close a table header + */ function tablethead_close() { } + /** + * Open a table row + */ function tablerow_open() { } + /** + * Close a table row + */ function tablerow_close() { } + /** + * Open a table header cell + * + * @param int $colspan + * @param string $align left|center|right + * @param int $rowspan + */ function tableheader_open($colspan = 1, $align = null, $rowspan = 1) { } + /** + * Close a table header cell + */ function tableheader_close() { } + /** + * Open a table cell + * + * @param int $colspan + * @param string $align left|center|right + * @param int $rowspan + */ function tablecell_open($colspan = 1, $align = null, $rowspan = 1) { } + /** + * Close a table cell + */ function tablecell_close() { } - // util functions follow, you probably won't need to reimplement them + #endregion + + #region util functions, you probably won't need to reimplement them /** * Removes any Namespace from the given name but keeps @@ -412,6 +812,8 @@ class Doku_Renderer extends DokuWiki_Plugin { return $url; } + + #endregion } -- cgit v1.2.3 From 3dd5c2254a659d7d66017f016e3e0d3d89f479c6 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 24 May 2014 15:17:26 +0200 Subject: added doc blocks for xhtml renderer --- inc/parser/renderer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/parser/renderer.php') diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index a486ed106..5eddc903e 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -202,7 +202,7 @@ class Doku_Renderer extends DokuWiki_Plugin { } /** - * Create a line breake + * Create a line break */ function linebreak() { } @@ -607,7 +607,7 @@ class Doku_Renderer extends DokuWiki_Plugin { * Should honor $conf['mailguard'] setting * * @param string $address Email-Address - * @param string $name Display name + * @param string|array $name name for the link, array for media file */ function emaillink($address, $name = null) { } -- cgit v1.2.3 From 8e3a5477d12ec6c8413a09d966bf5a84c0666cab Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 24 May 2014 15:20:42 +0200 Subject: added short comment on how a renderer works --- inc/parser/renderer.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'inc/parser/renderer.php') diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index 5eddc903e..09294539e 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -11,6 +11,12 @@ if(!defined('DOKU_INC')) die('meh.'); * An empty renderer, produces no output * * Inherits from DokuWiki_Plugin for giving additional functions to render plugins + * + * The renderer transforms the syntax instructions created by the parser and handler into the + * desired output format. For each instruction a corresponding method defined in this class will + * be called. That method needs to produce the desired output for the instruction and add it to the + * $doc field. When all instructions are processed, the $doc field contents will be cached by + * DokuWiki and sent to the user. */ class Doku_Renderer extends DokuWiki_Plugin { /** @var array Settings, control the behavior of the renderer */ -- cgit v1.2.3 From 42ea7f447f39fbc2f79eaaec31f8c10ede59c5d0 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Wed, 1 Oct 2014 11:30:27 +0200 Subject: Many PHPDocs, some unused and dyn declared vars many PHPDocs some unused variables some dynamically declared variables declared --- inc/parser/renderer.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'inc/parser/renderer.php') diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index 09294539e..6c074e43e 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) { } @@ -759,6 +759,9 @@ class Doku_Renderer extends DokuWiki_Plugin { * casing and special chars * * @author Andreas Gohr + * + * @param string $name + * @return string */ function _simpleTitle($name) { global $conf; @@ -778,6 +781,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 -- cgit v1.2.3 From e3a24861f53db7293b2b17f05d5821871b85b2f6 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Mon, 1 Dec 2014 17:02:56 +0000 Subject: Update inbuilt renderers for node/leaf state in listitem_open - includes, xhtml renderer adding 'node' class to
  • when it contains child list(s) --- inc/parser/renderer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'inc/parser/renderer.php') diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index 09294539e..668b617d1 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -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) { } /** -- cgit v1.2.3