From 5c2eed9a193e9341fbfee63d4a973898acdc5ee5 Mon Sep 17 00:00:00 2001 From: lisps Date: Thu, 21 Nov 2013 15:50:52 +0100 Subject: add parameter at($DATE_AT) and mind revisions --- inc/parserutils.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'inc/parserutils.php') diff --git a/inc/parserutils.php b/inc/parserutils.php index b67daaabb..c50bf7332 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -56,7 +56,7 @@ define('METADATA_RENDER_UNLIMITED', 4); * * @author Andreas Gohr */ -function p_wiki_xhtml($id, $rev='', $excuse=true){ +function p_wiki_xhtml($id, $rev='', $excuse=true,$date_at=''){ $file = wikiFN($id,$rev); $ret = ''; @@ -65,9 +65,9 @@ function p_wiki_xhtml($id, $rev='', $excuse=true){ $keep = $ID; $ID = $id; - if($rev){ + if($rev || $date_at){ if(@file_exists($file)){ - $ret = p_render('xhtml',p_get_instructions(io_readWikiPage($file,$id,$rev)),$info); //no caching on old revisions + $ret = p_render('xhtml',p_get_instructions(io_readWikiPage($file,$id,$rev)),$info,$rev,$date_at); //no caching on old revisions }elseif($excuse){ $ret = p_locale_xhtml('norev'); } @@ -583,7 +583,7 @@ function p_sort_modes($a, $b){ * @author Harry Fuecks * @author Andreas Gohr */ -function p_render($mode,$instructions,&$info){ +function p_render($mode,$instructions,&$info,$rev='',$date_at=''){ if(is_null($instructions)) return ''; $Renderer =& p_get_renderer($mode); @@ -591,6 +591,13 @@ function p_render($mode,$instructions,&$info){ $Renderer->reset(); + if($rev) { + $Renderer->rev = $rev; + } + if($date_at) { + $Renderer->date_at = $date_at; + } + $Renderer->smileys = getSmileys(); $Renderer->entities = getEntities(); $Renderer->acronyms = getAcronyms(); -- cgit v1.2.3 From 4bde2196a1e3572cead3f4d4e4b6a5a752bd62b3 Mon Sep 17 00:00:00 2001 From: lisps Date: Fri, 22 Nov 2013 09:04:44 +0100 Subject: remove property rev from xhtml.php changed variable name $create_time to $modified_time --- inc/parserutils.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'inc/parserutils.php') diff --git a/inc/parserutils.php b/inc/parserutils.php index c50bf7332..ecb1ac888 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -67,7 +67,7 @@ function p_wiki_xhtml($id, $rev='', $excuse=true,$date_at=''){ if($rev || $date_at){ if(@file_exists($file)){ - $ret = p_render('xhtml',p_get_instructions(io_readWikiPage($file,$id,$rev)),$info,$rev,$date_at); //no caching on old revisions + $ret = p_render('xhtml',p_get_instructions(io_readWikiPage($file,$id,$rev)),$info,max($rev,$date_at)); //no caching on old revisions }elseif($excuse){ $ret = p_locale_xhtml('norev'); } @@ -583,7 +583,7 @@ function p_sort_modes($a, $b){ * @author Harry Fuecks * @author Andreas Gohr */ -function p_render($mode,$instructions,&$info,$rev='',$date_at=''){ +function p_render($mode,$instructions,&$info,$date_at=''){ if(is_null($instructions)) return ''; $Renderer =& p_get_renderer($mode); @@ -591,9 +591,6 @@ function p_render($mode,$instructions,&$info,$rev='',$date_at=''){ $Renderer->reset(); - if($rev) { - $Renderer->rev = $rev; - } if($date_at) { $Renderer->date_at = $date_at; } -- cgit v1.2.3 From 1c8a8d7b204705f17b35bc64d62981204405e372 Mon Sep 17 00:00:00 2001 From: lisps Date: Mon, 25 Nov 2013 13:45:01 +0100 Subject: change behavior only on date_at --- inc/parserutils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/parserutils.php') diff --git a/inc/parserutils.php b/inc/parserutils.php index ecb1ac888..b97fb5d00 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -67,7 +67,7 @@ function p_wiki_xhtml($id, $rev='', $excuse=true,$date_at=''){ if($rev || $date_at){ if(@file_exists($file)){ - $ret = p_render('xhtml',p_get_instructions(io_readWikiPage($file,$id,$rev)),$info,max($rev,$date_at)); //no caching on old revisions + $ret = p_render('xhtml',p_get_instructions(io_readWikiPage($file,$id,$rev)),$info,$date_at); //no caching on old revisions }elseif($excuse){ $ret = p_locale_xhtml('norev'); } -- cgit v1.2.3 From 99ba9fe6e3cd8a1c51c481f04675e48dec842773 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 8 Jan 2014 17:19:59 +0100 Subject: php doc block --- inc/parserutils.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'inc/parserutils.php') diff --git a/inc/parserutils.php b/inc/parserutils.php index b67daaabb..4df273f11 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -158,6 +158,8 @@ function p_cached_instructions($file,$cacheonly=false,$id='') { * * @author Harry Fuecks * @author Andreas Gohr + * @param string $text raw wiki syntax text + * @return array a list of instruction arrays */ function p_get_instructions($text){ -- cgit v1.2.3 From 11ac6abdb90a812687d7db7df99aa02f843dd12a Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Tue, 25 Feb 2014 02:58:58 +0000 Subject: if configured renderer is not found, try to fallback to a bundled renderer --- inc/parserutils.php | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) (limited to 'inc/parserutils.php') diff --git a/inc/parserutils.php b/inc/parserutils.php index 4df273f11..2fb523d0c 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -631,27 +631,43 @@ function & p_get_renderer($mode) { return $Renderer; } - // try default renderer first: - $file = DOKU_INC."inc/parser/$rname.php"; - if(@file_exists($file)){ - require_once $file; - - if ( !class_exists($rclass) ) { - trigger_error("Unable to resolve render class $rclass",E_USER_WARNING); - msg("Renderer '$rname' for $mode not valid",-1); - return null; - } - $Renderer = new $rclass(); - }else{ - // Maybe a plugin/component is available? + // assuming the configured renderer is bundled, construct its file name + $default = DOKU_INC."inc/parser/$rname.php"; + if (!file_exists($default)) { + // not bundled, see if its an enabled plugin for rendering $mode $Renderer = $plugin_controller->load('renderer',$rname); + if (is_a($Renderer, 'Doku_Renderer') && ($mode == $Renderer->getFormat())) { + return $Renderer; + } - if(!isset($Renderer) || is_null($Renderer)){ + // there is a configuration error! + // not bundled, not an enabled plugin, try to fallback to a bundled renderer + $fallback = DOKU_INC."inc/parser/$mode.php"; + if (!file_exists($fallback)) { msg("No renderer '$rname' found for mode '$mode'",-1); return null; + } else { + $default = $fallback; + $rclass = "Doku_Renderer_$mode"; + + // viewers should see renderered output, so restrict the warning to admins only + $msg = "No renderer '$rname' found for mode '$mode', check your plugins"; + if ($mode == 'xhtml') { + $msg .= " and the 'renderer_xhtml' config setting"; + } + $msg .= ".
Attempting to fallback to the bundled renderer."; + msg($msg,-1,'','',MSG_ADMIN_ONLY); } } + require_once $default; + if ( !class_exists($rclass) ) { + trigger_error("Unable to resolve render class $rclass",E_USER_WARNING); + msg("Renderer '$rname' for $mode not valid",-1); + return null; + } + $Renderer = new $rclass(); + return $Renderer; } -- cgit v1.2.3 From 252398f08d0752fd17b25e4afab70a6d0b6455a7 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Tue, 25 Feb 2014 03:00:46 +0000 Subject: remove reference operator from p_get_renderer() declaration, not required for php5 --- inc/parserutils.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/parserutils.php') diff --git a/inc/parserutils.php b/inc/parserutils.php index 2fb523d0c..9420931eb 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -588,7 +588,7 @@ function p_sort_modes($a, $b){ function p_render($mode,$instructions,&$info){ if(is_null($instructions)) return ''; - $Renderer =& p_get_renderer($mode); + $Renderer = p_get_renderer($mode); if (is_null($Renderer)) return null; $Renderer->reset(); @@ -619,7 +619,7 @@ function p_render($mode,$instructions,&$info){ * @param $mode string Mode of the renderer to get * @return null|Doku_Renderer The renderer */ -function & p_get_renderer($mode) { +function p_get_renderer($mode) { /** @var Doku_Plugin_Controller $plugin_controller */ global $conf, $plugin_controller; -- 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/parserutils.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'inc/parserutils.php') diff --git a/inc/parserutils.php b/inc/parserutils.php index 9420931eb..11f044146 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -444,8 +444,6 @@ function p_render_metadata($id, $orig){ $evt = new Doku_Event('PARSER_METADATA_RENDER', $orig); if ($evt->advise_before()) { - require_once DOKU_INC."inc/parser/metadata.php"; - // get instructions $instructions = p_cached_instructions(wikiFN($id),false,$id); if(is_null($instructions)){ -- cgit v1.2.3 From 548d801fe28808c85529c4e396ccc563550d4634 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Tue, 25 Feb 2014 20:33:37 +0000 Subject: rework p_get_renderer() for use with autoloading bundled renderers --- inc/parserutils.php | 60 ++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'inc/parserutils.php') diff --git a/inc/parserutils.php b/inc/parserutils.php index 11f044146..7a85b64e3 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -614,8 +614,13 @@ function p_render($mode,$instructions,&$info){ } /** + * Figure out the correct renderer class to use for $mode, + * instantiate and return it + * * @param $mode string Mode of the renderer to get * @return null|Doku_Renderer The renderer + * + * @author Christopher Smith */ function p_get_renderer($mode) { /** @var Doku_Plugin_Controller $plugin_controller */ @@ -624,49 +629,44 @@ function p_get_renderer($mode) { $rname = !empty($conf['renderer_'.$mode]) ? $conf['renderer_'.$mode] : $mode; $rclass = "Doku_Renderer_$rname"; + // if requested earlier or a bundled renderer if( class_exists($rclass) ) { $Renderer = new $rclass(); return $Renderer; } - // assuming the configured renderer is bundled, construct its file name - $default = DOKU_INC."inc/parser/$rname.php"; - if (!file_exists($default)) { - // not bundled, see if its an enabled plugin for rendering $mode - $Renderer = $plugin_controller->load('renderer',$rname); + // not bundled, see if its an enabled plugin for rendering $mode + $Renderer = $plugin_controller->load('renderer',$rname); + if ($Renderer) { if (is_a($Renderer, 'Doku_Renderer') && ($mode == $Renderer->getFormat())) { return $Renderer; - } - - // there is a configuration error! - // not bundled, not an enabled plugin, try to fallback to a bundled renderer - $fallback = DOKU_INC."inc/parser/$mode.php"; - if (!file_exists($fallback)) { - msg("No renderer '$rname' found for mode '$mode'",-1); - return null; } else { - $default = $fallback; - $rclass = "Doku_Renderer_$mode"; - - // viewers should see renderered output, so restrict the warning to admins only - $msg = "No renderer '$rname' found for mode '$mode', check your plugins"; - if ($mode == 'xhtml') { - $msg .= " and the 'renderer_xhtml' config setting"; - } - $msg .= ".
Attempting to fallback to the bundled renderer."; - msg($msg,-1,'','',MSG_ADMIN_ONLY); + // plugin found, but not a renderer or not the right renderer for this $mode + msg("Renderer plugin '$rname' not valid for $mode",-1,'','',MSG_ADMINS_ONLY); } } - require_once $default; - if ( !class_exists($rclass) ) { - trigger_error("Unable to resolve render class $rclass",E_USER_WARNING); - msg("Renderer '$rname' for $mode not valid",-1); - return null; + // there is a configuration error! + // not bundled, not a valid enabled plugin, use $mode to try to fallback to a bundled renderer + $rclass = "Doku_Renderer_$mode"; + if ( class_exists($rclass) ) { + // viewers should see renderered output, so restrict the warning to admins only + $msg = "No renderer '$rname' found for mode '$mode', check your plugins"; + if ($mode == 'xhtml') { + $msg .= " and the 'renderer_xhtml' config setting"; + } + $msg .= ".
Attempting to fallback to the bundled renderer."; + msg($msg,-1,'','',MSG_ADMINS_ONLY); + + $Renderer = new $rclass; + $Renderer->nocache(); // fallback only (and may include admin alerts), don't cache + return $Renderer; } - $Renderer = new $rclass(); - return $Renderer; + // fallback failed, alert the world + trigger_error("Unable to resolve render class $rclass",E_USER_WARNING); + msg("No renderer '$rname' found for mode '$mode'",-1); + return null; } /** -- cgit v1.2.3 From 5b76ad9103ca8e25d29c5ce018859be6679b7b1c Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Tue, 25 Feb 2014 20:34:20 +0000 Subject: code cleaning - add some braces --- inc/parserutils.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'inc/parserutils.php') diff --git a/inc/parserutils.php b/inc/parserutils.php index 7a85b64e3..c12732e88 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -430,8 +430,9 @@ function p_render_metadata($id, $orig){ global $ID, $METADATA_RENDERERS; // avoid recursive rendering processes for the same id - if (isset($METADATA_RENDERERS[$id])) + if (isset($METADATA_RENDERERS[$id])) { return $orig; + } // store the original metadata in the global $METADATA_RENDERERS so p_set_metadata can use it $METADATA_RENDERERS[$id] =& $orig; -- cgit v1.2.3 From f3283f02766b2a2730b81c5a5a0b0a6240af054c Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Tue, 25 Feb 2014 21:15:43 +0000 Subject: change to an Exception and expect it --- inc/parserutils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/parserutils.php') diff --git a/inc/parserutils.php b/inc/parserutils.php index c12732e88..1c628a766 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -665,7 +665,7 @@ function p_get_renderer($mode) { } // fallback failed, alert the world - trigger_error("Unable to resolve render class $rclass",E_USER_WARNING); + throw new Exception("Unable to resolve render class $rclass",E_USER_WARNING); msg("No renderer '$rname' found for mode '$mode'",-1); return null; } -- cgit v1.2.3 From a049856df3f316114a9d936d830d5b6d419b11e6 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Wed, 26 Feb 2014 01:12:33 +0000 Subject: revert back to trigger error --- inc/parserutils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/parserutils.php') diff --git a/inc/parserutils.php b/inc/parserutils.php index 1c628a766..c12732e88 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -665,7 +665,7 @@ function p_get_renderer($mode) { } // fallback failed, alert the world - throw new Exception("Unable to resolve render class $rclass",E_USER_WARNING); + trigger_error("Unable to resolve render class $rclass",E_USER_WARNING); msg("No renderer '$rname' found for mode '$mode'",-1); return null; } -- cgit v1.2.3 From 5ee37844b9e6f852bf16da41e5c07f056ec376d1 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Fri, 28 Feb 2014 16:55:57 +0000 Subject: remove rendundant msg --- inc/parserutils.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'inc/parserutils.php') diff --git a/inc/parserutils.php b/inc/parserutils.php index c12732e88..b41e2d473 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -638,13 +638,8 @@ function p_get_renderer($mode) { // not bundled, see if its an enabled plugin for rendering $mode $Renderer = $plugin_controller->load('renderer',$rname); - if ($Renderer) { - if (is_a($Renderer, 'Doku_Renderer') && ($mode == $Renderer->getFormat())) { - return $Renderer; - } else { - // plugin found, but not a renderer or not the right renderer for this $mode - msg("Renderer plugin '$rname' not valid for $mode",-1,'','',MSG_ADMINS_ONLY); - } + if (is_a($Renderer, 'Doku_Renderer') && ($mode == $Renderer->getFormat())) { + return $Renderer; } // there is a configuration error! -- cgit v1.2.3 From 709fd92548efedbd4b4e5693097165d1dff072e4 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Sun, 2 Mar 2014 20:46:26 +0000 Subject: resolve scrutinizer issue, is_a type hint doesn't allow null --- inc/parserutils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/parserutils.php') diff --git a/inc/parserutils.php b/inc/parserutils.php index b41e2d473..06bd6dbb8 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -638,7 +638,7 @@ function p_get_renderer($mode) { // not bundled, see if its an enabled plugin for rendering $mode $Renderer = $plugin_controller->load('renderer',$rname); - if (is_a($Renderer, 'Doku_Renderer') && ($mode == $Renderer->getFormat())) { + if ($Renderer && is_a($Renderer, 'Doku_Renderer') && ($mode == $Renderer->getFormat())) { return $Renderer; } -- cgit v1.2.3 From 6e6d16edde50ed56a86641e03a8df3885f95ae2e Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Thu, 13 Mar 2014 19:58:05 +0000 Subject: Fix a couple of issues with PR#571 1. renderer validity checks were too stringent for plugins, format should only need to be checked when mode is 'xhtml' 2. E_USER_WARNING message should now be obsolete, its previous use was to generate a warning when 'xhtml' rendering failed. PR#571 insures 'xhtml' rendering always succeeds. --- inc/parserutils.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'inc/parserutils.php') diff --git a/inc/parserutils.php b/inc/parserutils.php index 06bd6dbb8..8244837e1 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -636,9 +636,9 @@ function p_get_renderer($mode) { return $Renderer; } - // not bundled, see if its an enabled plugin for rendering $mode + // not bundled, see if its an enabled renderer plugin & when $mode is 'xhtml', the renderer can supply that format. $Renderer = $plugin_controller->load('renderer',$rname); - if ($Renderer && is_a($Renderer, 'Doku_Renderer') && ($mode == $Renderer->getFormat())) { + if ($Renderer && is_a($Renderer, 'Doku_Renderer') && ($mode != 'xhtml' || $mode == $Renderer->getFormat())) { return $Renderer; } @@ -660,7 +660,6 @@ function p_get_renderer($mode) { } // fallback failed, alert the world - trigger_error("Unable to resolve render class $rclass",E_USER_WARNING); msg("No renderer '$rname' found for mode '$mode'",-1); return null; } -- cgit v1.2.3 From 59b1d9181358f31d8d65c38a64fb43a68c0fadb1 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Mon, 17 Mar 2014 01:33:46 +0000 Subject: adjust logic of caching comments for _nocache --- inc/parserutils.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'inc/parserutils.php') diff --git a/inc/parserutils.php b/inc/parserutils.php index 06bd6dbb8..281a93967 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -112,8 +112,7 @@ function p_cached_output($file, $format='xhtml', $id='') { } else { $parsed = p_render($format, p_cached_instructions($file,false,$id), $info); - if ($info['cache']) { - $cache->storeCache($parsed); //save cachefile + if ($info['cache'] && $cache->storeCache($parsed)) { // storeCache() attempts to save cachefile if($conf['allowdebug'] && $format=='xhtml') $parsed .= "\n\n"; }else{ $cache->removeCache(); //try to delete cachefile -- cgit v1.2.3 From 0440ca46b69be8a0fd706825f9d319299db892db Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sun, 28 Sep 2014 15:07:17 +0200 Subject: phpdocs parserutils --- inc/parserutils.php | 1 + 1 file changed, 1 insertion(+) (limited to 'inc/parserutils.php') diff --git a/inc/parserutils.php b/inc/parserutils.php index 9c2a0b570..eab3455a6 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -636,6 +636,7 @@ function p_get_renderer($mode) { } // not bundled, see if its an enabled renderer plugin & when $mode is 'xhtml', the renderer can supply that format. + /** @var Doku_Renderer $Renderer */ $Renderer = $plugin_controller->load('renderer',$rname); if ($Renderer && is_a($Renderer, 'Doku_Renderer') && ($mode != 'xhtml' || $mode == $Renderer->getFormat())) { return $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/parserutils.php | 49 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) (limited to 'inc/parserutils.php') diff --git a/inc/parserutils.php b/inc/parserutils.php index 9c2a0b570..791033e63 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -55,6 +55,11 @@ define('METADATA_RENDER_UNLIMITED', 4); * wasn't found * * @author Andreas Gohr + * + * @param string $id page id + * @param string|int $rev revision timestamp or empty string + * @param bool $excuse + * @return null|string */ function p_wiki_xhtml($id, $rev='', $excuse=true){ $file = wikiFN($id,$rev); @@ -89,6 +94,9 @@ function p_wiki_xhtml($id, $rev='', $excuse=true){ * Returns the specified local text in parsed format * * @author Andreas Gohr + * + * @param string $id page id + * @return null|string */ function p_locale_xhtml($id){ //fetch parsed locale @@ -101,6 +109,11 @@ function p_locale_xhtml($id){ * * @author Andreas Gohr * @author Chris Smith + * + * @param string $file filename, path to file + * @param string $format + * @param string $id page id + * @return null|string */ function p_cached_output($file, $format='xhtml', $id='') { global $conf; @@ -129,6 +142,11 @@ function p_cached_output($file, $format='xhtml', $id='') { * Uses and creates a serialized cache file * * @author Andreas Gohr + * + * @param string $file filename, path to file + * @param bool $cacheonly + * @param string $id page id + * @return array|null */ function p_cached_instructions($file,$cacheonly=false,$id='') { static $run = null; @@ -157,7 +175,8 @@ function p_cached_instructions($file,$cacheonly=false,$id='') { * * @author Harry Fuecks * @author Andreas Gohr - * @param string $text raw wiki syntax text + * + * @param string $text raw wiki syntax text * @return array a list of instruction arrays */ function p_get_instructions($text){ @@ -185,9 +204,9 @@ function p_get_instructions($text){ /** * returns the metadata of a page * - * @param string $id The id of the page the metadata should be returned from - * @param string $key The key of the metdata value that shall be read (by default everything) - separate hierarchies by " " like "date created" - * @param int $render If the page should be rendererd - possible values: + * @param string $id The id of the page the metadata should be returned from + * @param string $key The key of the metdata value that shall be read (by default everything) - separate hierarchies by " " like "date created" + * @param int $render If the page should be rendererd - possible values: * METADATA_DONT_RENDER, METADATA_RENDER_USING_SIMPLE_CACHE, METADATA_RENDER_USING_CACHE * METADATA_RENDER_UNLIMITED (also combined with the previous two options), * default: METADATA_RENDER_USING_CACHE @@ -360,6 +379,9 @@ function p_set_metadata($id, $data, $render=false, $persistent=true){ * used on page deletion * * @author Michael Klier + * + * @param string $id page id + * @return bool success / fail */ function p_purge_metadata($id) { $meta = p_read_metadata($id); @@ -423,6 +445,10 @@ function p_save_metadata($id, $meta) { * renders the metadata of a page * * @author Esther Brunner + * + * @param string $id page id + * @param array $orig the original metadata + * @return array|null array('current'=> array,'persistent'=> array); */ function p_render_metadata($id, $orig){ // make sure the correct ID is in global ID @@ -477,6 +503,8 @@ function p_render_metadata($id, $orig){ * returns all available parser syntax modes in correct order * * @author Andreas Gohr + * + * @return array[] with for each plugin the array('sort' => sortnumber, 'mode' => mode string, 'obj' => plugin object) */ function p_get_parsermodes(){ global $conf; @@ -569,6 +597,10 @@ function p_get_parsermodes(){ * Callback function for usort * * @author Andreas Gohr + * + * @param array $a + * @param array $b + * @return int $a is lower/equal/higher than $b */ function p_sort_modes($a, $b){ if($a['sort'] == $b['sort']) return 0; @@ -582,6 +614,11 @@ function p_sort_modes($a, $b){ * * @author Harry Fuecks * @author Andreas Gohr + * + * @param string $mode + * @param array $instructions + * @param array $info returns render info like enabled toc and cache + * @return null|string rendered output */ function p_render($mode,$instructions,&$info){ if(is_null($instructions)) return ''; @@ -673,8 +710,8 @@ function p_get_renderer($mode) { * METADATA_RENDER_USING_SIMPLE_CACHE, * METADATA_RENDER_USING_CACHE, * METADATA_RENDER_UNLIMITED - * * @return string|null The first heading + * * @author Andreas Gohr * @author Michael Hamann */ @@ -688,8 +725,8 @@ function p_get_first_heading($id, $render=METADATA_RENDER_USING_SIMPLE_CACHE){ * @param string $code source code to be highlighted * @param string $language language to provide highlighting * @param string $wrapper html element to wrap the returned highlighted text - * * @return string xhtml code + * * @author Christopher Smith * @author Andreas Gohr */ -- cgit v1.2.3 From e3710957c6b7e12293805a15d0624be7c7054092 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Wed, 1 Oct 2014 17:05:40 +0200 Subject: more phpdocs and minor check --- inc/parserutils.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'inc/parserutils.php') diff --git a/inc/parserutils.php b/inc/parserutils.php index 791033e63..ef62c8e49 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -616,12 +616,13 @@ function p_sort_modes($a, $b){ * @author Andreas Gohr * * @param string $mode - * @param array $instructions + * @param array|null|false $instructions * @param array $info returns render info like enabled toc and cache * @return null|string rendered output */ function p_render($mode,$instructions,&$info){ if(is_null($instructions)) return ''; + if($instructions === false) return ''; $Renderer = p_get_renderer($mode); if (is_null($Renderer)) return null; -- cgit v1.2.3 From 7e8500eea1e53b1de0e0f70400664afa442cd08d Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Thu, 2 Oct 2014 14:55:24 +0200 Subject: PHPDocs and some improvements --- inc/parserutils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/parserutils.php') diff --git a/inc/parserutils.php b/inc/parserutils.php index ef62c8e49..4371f1928 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -655,7 +655,7 @@ function p_render($mode,$instructions,&$info){ * Figure out the correct renderer class to use for $mode, * instantiate and return it * - * @param $mode string Mode of the renderer to get + * @param string $mode Mode of the renderer to get * @return null|Doku_Renderer The renderer * * @author Christopher Smith -- cgit v1.2.3 From 79e79377626799a77c11aa7849cb9c64305590c8 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 7 Jan 2015 10:47:45 +0100 Subject: Remove error supression for file_exists() In an older version of PHP a file_exists() call would issue a warning when the file did not exist. This was fixed in later PHP releases. Since we require PHP 5.3 now, there's no need to supress any error here anymore. This might even give a minor performance boost. --- inc/parserutils.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'inc/parserutils.php') diff --git a/inc/parserutils.php b/inc/parserutils.php index 3ef8138a7..17c331ef5 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -71,13 +71,13 @@ function p_wiki_xhtml($id, $rev='', $excuse=true,$date_at=''){ $ID = $id; if($rev || $date_at){ - if(@file_exists($file)){ + if(file_exists($file)){ $ret = p_render('xhtml',p_get_instructions(io_readWikiPage($file,$id,$rev)),$info,$date_at); //no caching on old revisions }elseif($excuse){ $ret = p_locale_xhtml('norev'); } }else{ - if(@file_exists($file)){ + if(file_exists($file)){ $ret = p_cached_output($file,'xhtml',$id); }elseif($excuse){ $ret = p_locale_xhtml('newpage'); @@ -156,7 +156,7 @@ function p_cached_instructions($file,$cacheonly=false,$id='') { if ($cacheonly || $cache->useCache() || (isset($run[$file]) && !defined('DOKU_UNITTEST'))) { return $cache->retrieveCache(); - } else if (@file_exists($file)) { + } else if (file_exists($file)) { // no cache - do some work $ins = p_get_instructions(io_readWikiPage($file,$id)); if ($cache->storeCache($ins)) { @@ -248,7 +248,7 @@ function p_get_metadata($id, $key='', $render=METADATA_RENDER_USING_CACHE){ if ($render & METADATA_RENDER_USING_SIMPLE_CACHE) { $pagefn = wikiFN($id); $metafn = metaFN($id, '.meta'); - if (!@file_exists($metafn) || @filemtime($pagefn) > @filemtime($cachefile->cache)) { + if (!file_exists($metafn) || @filemtime($pagefn) > @filemtime($cachefile->cache)) { $do_render = true; } } elseif (!$cachefile->useCache()){ @@ -414,7 +414,7 @@ function p_read_metadata($id,$cache=false) { if (isset($cache_metadata[(string)$id])) return $cache_metadata[(string)$id]; $file = metaFN($id, '.meta'); - $meta = @file_exists($file) ? unserialize(io_readFile($file, false)) : array('current'=>array(),'persistent'=>array()); + $meta = file_exists($file) ? unserialize(io_readFile($file, false)) : array('current'=>array(),'persistent'=>array()); if ($cache) { $cache_metadata[(string)$id] = $meta; -- cgit v1.2.3