From 362a4f084345b496ab6b155db3ec50cad3939d0e Mon Sep 17 00:00:00 2001 From: Szymon Olewniczak Date: Tue, 10 Dec 2013 09:19:46 +0100 Subject: add TEMPLATE_SITETOOLS_DISPLAY and TEMPLATE_USERTOOLS_DISPLAY basing on Starter template --- inc/template.php | 19 +++++++++++++++++++ lib/tpl/dokuwiki/tpl_header.php | 19 ++++++++++++------- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/inc/template.php b/inc/template.php index 60e178d1a..fb468d041 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1786,5 +1786,24 @@ function tpl_classes() { return join(' ', $classes); } +/** + * Create event for tools menues + * + * @author Anika Henke + */ +function tpl_toolsevent($toolsname, $items, $view='main') { + $data = array( + 'view' => $view, + 'items' => $items + ); + + $hook = 'TEMPLATE_'.strtoupper($toolsname).'_DISPLAY'; + $evt = new Doku_Event($hook, $data); + if($evt->advise_before()){ + foreach($evt->data['items'] as $k => $html) echo $html; + } + $evt->advise_after(); +} + //Setup VIM: ex: et ts=4 : diff --git a/lib/tpl/dokuwiki/tpl_header.php b/lib/tpl/dokuwiki/tpl_header.php index a2bfd4346..547dd1401 100644 --- a/lib/tpl/dokuwiki/tpl_header.php +++ b/lib/tpl/dokuwiki/tpl_header.php @@ -46,10 +46,13 @@ if (!defined('DOKU_INC')) die(); tpl_userinfo(); /* 'Logged in as ...' */ echo ''; } - tpl_action('admin', 1, 'li'); - tpl_action('profile', 1, 'li'); - tpl_action('register', 1, 'li'); - tpl_action('login', 1, 'li'); + + tpl_toolsevent('usertools', array( + 'admin' => tpl_action('admin', 1, 'li', 1), + 'profile' => tpl_action('profile', 1, 'li', 1), + 'register' => tpl_action('register', 1, 'li', 1), + 'login' => tpl_action('login', 1, 'li', 1), + )); ?> @@ -64,9 +67,11 @@ if (!defined('DOKU_INC')) die(); -- cgit v1.2.3 From 1858e4d7685782550789fd8c228e55ae319bc37a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerry=20Wei=C3=9Fbach?= Date: Mon, 30 Jun 2014 09:13:10 +0200 Subject: Check for basedir and baseurl If these configuration values are not set php will throw an unnecessary NOTICE. --- inc/init.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/init.php b/inc/init.php index a937b934d..7340f4191 100644 --- a/inc/init.php +++ b/inc/init.php @@ -411,7 +411,7 @@ function getBaseURL($abs=null){ //if canonical url enabled always return absolute if(is_null($abs)) $abs = $conf['canonical']; - if($conf['basedir']){ + if(!empty($conf['basedir'])){ $dir = $conf['basedir']; }elseif(substr($_SERVER['SCRIPT_NAME'],-4) == '.php'){ $dir = dirname($_SERVER['SCRIPT_NAME']); @@ -438,7 +438,7 @@ function getBaseURL($abs=null){ if(!$abs) return $dir; //use config option if available, trim any slash from end of baseurl to avoid multiple consecutive slashes in the path - if($conf['baseurl']) return rtrim($conf['baseurl'],'/').$dir; + if(!empty($conf['baseurl'])) return rtrim($conf['baseurl'],'/').$dir; //split hostheader into host and port if(isset($_SERVER['HTTP_HOST'])){ -- cgit v1.2.3 From 04585e6c37e0352a5bc568fc8c938aeafa1c160e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerry=20Wei=C3=9Fbach?= Date: Fri, 29 Aug 2014 11:53:19 +0200 Subject: rfc2231 compatible encoding for header() This is only used in the filename header field and ensures correct interpretation of an encoded filename. This is will be needed especially for download of files with umlauts with an Internet Explorer. --- inc/fetch.functions.php | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/inc/fetch.functions.php b/inc/fetch.functions.php index c61c54503..55b31a454 100644 --- a/inc/fetch.functions.php +++ b/inc/fetch.functions.php @@ -71,9 +71,9 @@ function sendFile($file, $mime, $dl, $cache, $public = false, $orig = null) { //download or display? if($dl) { - header('Content-Disposition: attachment; filename="'.utf8_basename($orig).'";'); + header('Content-Disposition: attachment;'.rfc2231_encode('filename', utf8_basename($orig)).';'); } else { - header('Content-Disposition: inline; filename="'.utf8_basename($orig).'";'); + header('Content-Disposition: inline;'.rfc2231_encode('filename', utf8_basename($orig)).';'); } //use x-sendfile header to pass the delivery to compatible webservers @@ -89,6 +89,31 @@ function sendFile($file, $mime, $dl, $cache, $public = false, $orig = null) { } } +/** + * Try an rfc2231 compatible encoding. This ensures correct + * interpretation of filenames outside of the ASCII set. + * This seems to be needed for file names with e.g. umlauts that + * would otherwise decode wrongly in IE. + * + * There is no additional checking, just the encoding and setting the key=value for usage in headers + * + * @author Gerry Weissbach + * @param string $name name of the field to be set in the header() call + * @param string $value value of the field to be set in the header() call + * @param string $charset used charset for the encoding of value + * @param string $lang language used. + * @return string in the format " name=value" for values WITHOUT special characters + * @return string in the format " name*=charset'lang'value" for values WITH special characters + */ +function rfc2231_encode($name, $value, $charset='utf-8', $lang='en') { + $internal = preg_replace_callback('/[\x00-\x20*\'%()<>@,;:\\\\"\/[\]?=\x80-\xFF]/', function($match) { return rawurlencode($match[0]); }, $value); + if ( $value != $internal ) { + return ' '.$name.'*='.$charset."'".$lang."'".$internal; + } else { + return ' '.$name.'="'.$value.'"'; + } +} + /** * Check for media for preconditions and return correct status code * -- cgit v1.2.3 From de4634ec87b1a277c1686990d993dafc43db05ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerry=20Wei=C3=9Fbach?= Date: Fri, 12 Sep 2014 08:41:57 +0200 Subject: Additionally allow more media types They are generated from the default ones and any additional one given by the template. This allows to e.g. split admin styles from end user styles in a closed wiki. You can then deliver only the user styles using the metaheaders plugin. --- lib/exe/css.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/exe/css.php b/lib/exe/css.php index 6c1d60751..902996062 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -32,24 +32,25 @@ function css_out(){ global $config_cascade; global $INPUT; + // decide from where to get the template + $tpl = trim(preg_replace('/[^\w-]+/','',$INPUT->str('t'))); + if(!$tpl) $tpl = $conf['template']; + + // load styl.ini + $styleini = css_styleini($tpl); + + // find mediatypes if ($INPUT->str('s') == 'feed') { $mediatypes = array('feed'); $type = 'feed'; } else { - $mediatypes = array('screen', 'all', 'print'); + $mediatypes = array_unique(array_merge(array('screen', 'all', 'print'), array_keys($styleini['stylesheets']))); $type = ''; } - // decide from where to get the template - $tpl = trim(preg_replace('/[^\w-]+/','',$INPUT->str('t'))); - if(!$tpl) $tpl = $conf['template']; - // The generated script depends on some dynamic options $cache = new cache('styles'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'].DOKU_BASE.$tpl.$type,'.css'); - // load styl.ini - $styleini = css_styleini($tpl); - // if old 'default' userstyle setting exists, make it 'screen' userstyle for backwards compatibility if (isset($config_cascade['userstyle']['default'])) { $config_cascade['userstyle']['screen'] = $config_cascade['userstyle']['default']; -- cgit v1.2.3 From ece4159b488ee81a13b9122239c88d82ec1aa59c Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 27 Sep 2014 14:08:37 +0200 Subject: Send CRLF to Windows UAs for code blocks #863 --- inc/parser/code.php | 5 +++++ 1 file changed, 5 insertions(+) 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"); -- cgit v1.2.3 From e0c26282a603881e8d2f839d94c28dbbfc57d71b Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Mon, 29 Sep 2014 03:34:17 +0200 Subject: scrutinizer documentations issues --- feed.php | 6 +- inc/HTTPClient.php | 8 ++- inc/Sitemapper.php | 2 +- inc/actions.php | 2 +- inc/cache.php | 4 +- inc/common.php | 2 +- inc/html.php | 5 +- inc/media.php | 108 +++++++++++++++++++++++++--- inc/pageutils.php | 2 +- inc/parser/metadata.php | 2 +- inc/parser/xhtml.php | 2 +- inc/plugincontroller.class.php | 2 +- inc/subscription.php | 2 +- inc/template.php | 39 +++++++--- lib/exe/indexer.php | 5 +- lib/plugins/authldap/auth.php | 16 ++--- lib/plugins/authmysql/auth.php | 5 +- lib/plugins/authpgsql/auth.php | 2 +- lib/plugins/info/syntax.php | 2 +- lib/tpl/dokuwiki/detail.php | 4 +- lib/tpl/dokuwiki/images/pagetools-build.php | 2 +- lib/tpl/dokuwiki/main.php | 14 ++-- lib/tpl/dokuwiki/tpl_header.php | 14 ++-- 23 files changed, 181 insertions(+), 69 deletions(-) diff --git a/feed.php b/feed.php index a63e22164..aa00063a1 100644 --- a/feed.php +++ b/feed.php @@ -306,7 +306,7 @@ function rss_buildItems(&$rss, &$data, $opt) { $src_r = ''; $src_l = ''; - if($size = media_image_preview_size($id, false, new JpegMeta(mediaFN($id)), 300)) { + if($size = media_image_preview_size($id, '', new JpegMeta(mediaFN($id)), 300)) { $more = 'w='.$size[0].'&h='.$size[1].'&t='.@filemtime(mediaFN($id)); $src_r = ml($id, $more, true, '&', true); } @@ -355,7 +355,7 @@ function rss_buildItems(&$rss, &$data, $opt) { break; case 'html': if($ditem['media']) { - if($size = media_image_preview_size($id, false, new JpegMeta(mediaFN($id)))) { + if($size = media_image_preview_size($id, '', new JpegMeta(mediaFN($id)))) { $more = 'w='.$size[0].'&h='.$size[1].'&t='.@filemtime(mediaFN($id)); $src = ml($id, $more, true, '&', true); $content = ''.$id.''; @@ -386,7 +386,7 @@ function rss_buildItems(&$rss, &$data, $opt) { case 'abstract': default: if($ditem['media']) { - if($size = media_image_preview_size($id, false, new JpegMeta(mediaFN($id)))) { + if($size = media_image_preview_size($id, '', new JpegMeta(mediaFN($id)))) { $more = 'w='.$size[0].'&h='.$size[1].'&t='.@filemtime(mediaFN($id)); $src = ml($id, $more, true, '&', true); $content = ''.$id.''; diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index cd4c7c4c5..ea20e3e56 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -57,6 +57,12 @@ class DokuHTTPClient extends HTTPClient { * @triggers HTTPCLIENT_REQUEST_SEND * @author Andreas Gohr */ + /** + * @param string $url + * @param string|array $data the post data either as array or raw data + * @param string $method + * @return bool + */ function sendRequest($url,$data='',$method='GET'){ $httpdata = array('url' => $url, 'data' => $data, @@ -104,7 +110,7 @@ class HTTPClient { var $header_regexp; // if set this RE must match against the headers, else abort var $headers; var $debug; - var $start = 0; // for timings + var $start = 0.0; // for timings var $keep_alive = true; // keep alive rocks // don't set these, read on error diff --git a/inc/Sitemapper.php b/inc/Sitemapper.php index 6332746a6..33f6d7a36 100644 --- a/inc/Sitemapper.php +++ b/inc/Sitemapper.php @@ -53,7 +53,7 @@ class Sitemapper { foreach($pages as $id){ //skip hidden, non existing and restricted files if(isHiddenPage($id)) continue; - if(auth_aclcheck($id,'','') < AUTH_READ) continue; + if(auth_aclcheck($id,'',array()) < AUTH_READ) continue; $item = SitemapItem::createFromID($id); if ($item !== null) $items[] = $item; diff --git a/inc/actions.php b/inc/actions.php index ef09a0dc7..2b819a0d6 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -394,7 +394,7 @@ function act_save($act){ return 'conflict'; //save it - saveWikiText($ID,con($PRE,$TEXT,$SUF,1),$SUM,$INPUT->bool('minor')); //use pretty mode for con + saveWikiText($ID,con($PRE,$TEXT,$SUF,true),$SUM,$INPUT->bool('minor')); //use pretty mode for con //unlock it unlock($ID); diff --git a/inc/cache.php b/inc/cache.php index 6817e771b..191d54e45 100644 --- a/inc/cache.php +++ b/inc/cache.php @@ -316,7 +316,7 @@ class cache_instructions extends cache_parser { * retrieve the cached data * * @param bool $clean true to clean line endings, false to leave line endings alone - * @return string cache contents + * @return array cache contents */ public function retrieveCache($clean=true) { $contents = io_readFile($this->cache, false); @@ -326,7 +326,7 @@ class cache_instructions extends cache_parser { /** * cache $instructions * - * @param string $instructions the instruction to be cached + * @param array $instructions the instruction to be cached * @return bool true on success, false otherwise */ public function storeCache($instructions) { diff --git a/inc/common.php b/inc/common.php index e56285f62..95ea4e72d 100644 --- a/inc/common.php +++ b/inc/common.php @@ -968,7 +968,7 @@ function rawLocale($id, $ext = 'txt') { * @author Andreas Gohr * * @param string $id page id - * @param string $rev timestamp when a revision of wikitext is desired + * @param string|int $rev timestamp when a revision of wikitext is desired * @return string */ function rawWiki($id, $rev = '') { diff --git a/inc/html.php b/inc/html.php index bda6fb398..dd4a3d8da 100644 --- a/inc/html.php +++ b/inc/html.php @@ -422,6 +422,9 @@ function html_locked(){ * @author Andreas Gohr * @author Ben Coburn * @author Kate Arzamastseva + * + * @param int $first skip the first n changelog lines + * @param bool|string $media_id id of media, or false for current page */ function html_revisions($first=0, $media_id = false){ global $ID; @@ -926,7 +929,7 @@ function html_li_default($item){ * @param array $data array with item arrays * @param string $class class of ul wrapper * @param callable $func callback to print an list item - * @param string $lifunc callback to the opening li tag + * @param callable $lifunc callback to the opening li tag * @param bool $forcewrapper Trigger building a wrapper ul if the first level is 0 (we have a root object) or 1 (just the root content) * @return string html of an unordered list diff --git a/inc/media.php b/inc/media.php index 9022858e1..2b802a0ae 100644 --- a/inc/media.php +++ b/inc/media.php @@ -41,6 +41,11 @@ function media_filesinuse($data,$id){ * * @author Andreas Gohr * @author Kate Arzamastseva + * + * @param string $id media id + * @param int $auth permission level + * @param array $data + * @return bool */ function media_metasave($id,$auth,$data){ if($auth < AUTH_UPLOAD) return false; @@ -113,6 +118,10 @@ function media_ispublic($id){ * * @author Andreas Gohr * @author Kate Arzamastseva + * + * @param string $id media id + * @param int $auth permission level + * @return bool */ function media_metaform($id,$auth){ global $lang; @@ -175,6 +184,9 @@ function media_metaform($id,$auth){ * Convenience function to check if a media file is still in use * * @author Michael Klier + * + * @param string $id media id + * @return array|bool */ function media_inuse($id) { global $conf; @@ -367,9 +379,18 @@ function copy_uploaded_file($from, $to){ * $data[2] id: the future directory id of the uploaded file * $data[3] imime: the mimetype of the uploaded file * $data[4] overwrite: if an existing file is going to be overwritten + * $data[5] move: * * @triggers MEDIA_UPLOAD_FINISH */ +/** + * @param array $file + * @param string $id + * @param bool $ow + * @param int $auth permission level + * @param string $move function name + * @return array|mixed + */ function media_save($file, $id, $ow, $auth, $move) { if($auth < AUTH_UPLOAD) { return array("You don't have permissions to upload files.", -1); @@ -817,8 +838,13 @@ function media_tab_search($ns,$auth=null) { * Prints tab that displays mediafile details * * @author Kate Arzamastseva + * + * @param string $image media id + * @param string $ns + * @param null|int $auth permission level + * @param string|int $rev */ -function media_tab_view($image, $ns, $auth=null, $rev=false) { +function media_tab_view($image, $ns, $auth=null, $rev='') { global $lang; if(is_null($auth)) $auth = auth_quickaclcheck("$ns:*"); @@ -837,6 +863,10 @@ function media_tab_view($image, $ns, $auth=null, $rev=false) { * Prints tab that displays form for editing mediafile metadata * * @author Kate Arzamastseva + * + * @param string $image media id + * @param string $ns + * @param null|int $auth permission level */ function media_tab_edit($image, $ns, $auth=null) { if(is_null($auth)) $auth = auth_quickaclcheck("$ns:*"); @@ -851,6 +881,10 @@ function media_tab_edit($image, $ns, $auth=null) { * Prints tab that displays mediafile revisions * * @author Kate Arzamastseva + * + * @param string $image media id + * @param string $ns + * @param null|int $auth permission level */ function media_tab_history($image, $ns, $auth=null) { global $lang; @@ -875,7 +909,7 @@ function media_tab_history($image, $ns, $auth=null) { * Prints mediafile details * * @param string $image media id - * @param $auth + * @param int $auth permission level * @param int|bool $rev * @param JpegMeta|bool $meta * @author Kate Arzamastseva @@ -912,8 +946,12 @@ function media_preview($image, $auth, $rev=false, $meta=false) { * Prints mediafile action buttons * * @author Kate Arzamastseva + * + * @param string $image media id + * @param int $auth permission level + * @param string|int $rev revision timestamp, or empty string */ -function media_preview_buttons($image, $auth, $rev=false) { +function media_preview_buttons($image, $auth, $rev='') { global $lang, $conf; echo '
    '.NL; @@ -962,7 +1000,7 @@ function media_preview_buttons($image, $auth, $rev=false) { * * @author Kate Arzamastseva * @param string $image - * @param int $rev + * @param int|string $rev * @param JpegMeta $meta * @param int $size * @return array @@ -986,9 +1024,10 @@ function media_image_preview_size($image, $rev, $meta, $size = 500) { * Returns the requested EXIF/IPTC tag from the image meta * * @author Kate Arzamastseva - * @param array $tags + * + * @param array $tags * @param JpegMeta $meta - * @param string $alt + * @param string $alt * @return string */ function media_getTag($tags,$meta,$alt=''){ @@ -1002,6 +1041,7 @@ function media_getTag($tags,$meta,$alt=''){ * Returns mediafile tags * * @author Kate Arzamastseva + * * @param JpegMeta $meta * @return array */ @@ -1033,7 +1073,13 @@ function media_file_tags($meta) { * * @author Kate Arzamastseva */ -function media_details($image, $auth, $rev=false, $meta=false) { +/** + * @param string $image image id + * @param int $auth permission level + * @param string|int $rev revision timestamp, or empty string + * @param bool|JpegMeta $meta image object, or create one if false + */ +function media_details($image, $auth, $rev='', $meta=false) { global $lang; if (!$meta) $meta = new JpegMeta(mediaFN($image, $rev)); @@ -1057,6 +1103,13 @@ function media_details($image, $auth, $rev=false, $meta=false) { * * @author Kate Arzamastseva */ +/** + * @param string $image image id + * @param string $ns + * @param int $auth permission level + * @param bool $fromajax + * @return void|bool|string + */ function media_diff($image, $ns, $auth, $fromajax = false) { global $conf; global $INPUT; @@ -1135,6 +1188,13 @@ function _media_file_diff($data) { * Shows difference between two revisions of image * * @author Kate Arzamastseva + * + * @param string $image + * @param string|int $l_rev revision timestamp, or empty string + * @param string|int $r_rev revision timestamp, or empty string + * @param string $ns + * @param int $auth permission level + * @param bool $fromajax */ function media_file_diff($image, $l_rev, $r_rev, $ns, $auth, $fromajax){ global $lang; @@ -1256,8 +1316,8 @@ function media_file_diff($image, $l_rev, $r_rev, $ns, $auth, $fromajax){ * * @author Kate Arzamastseva * @param string $image - * @param int $l_rev - * @param int $r_rev + * @param int $l_rev revision timestamp, or empty string + * @param int $r_rev revision timestamp, or empty string * @param array $l_size * @param array $r_size * @param string $type @@ -1325,6 +1385,12 @@ function media_restore($image, $rev, $auth){ * @author Andreas Gohr * @author Kate Arzamastseva * @triggers MEDIA_SEARCH + * + * @param string $query + * @param string $ns + * @param null|int $auth + * @param bool $fullscreen + * @param string $sort */ function media_searchlist($query,$ns,$auth=null,$fullscreen=false,$sort='natural'){ global $conf; @@ -1375,10 +1441,14 @@ function media_searchlist($query,$ns,$auth=null,$fullscreen=false,$sort='natural /** * Formats and prints one file in the list + * + * @param array $item + * @param int $auth permission level + * @param string $jump item id + * @param bool $display_namespace */ function media_printfile($item,$auth,$jump,$display_namespace=false){ global $lang; - global $conf; // Prepare zebra coloring // I always wanted to use this variable name :-D @@ -1472,6 +1542,11 @@ function media_printicon($filename, $size=''){ * Formats and prints one file in the list in the thumbnails view * * @author Kate Arzamastseva + * + * @param array $item + * @param int $auth + * @param bool|string $jump + * @param bool $display_namespace */ function media_printfile_thumbs($item,$auth,$jump=false,$display_namespace=false){ @@ -1519,6 +1594,9 @@ function media_printfile_thumbs($item,$auth,$jump=false,$display_namespace=false /** * Prints a thumbnail and metainfo + * + * @param array $item + * @param bool $fullscreen */ function media_printimgdetail($item, $fullscreen=false){ // prepare thumbnail @@ -1621,6 +1699,10 @@ function media_managerURL($params=false, $amp='&', $abs=false, $params_array * * @author Andreas Gohr * @author Kate Arzamastseva + * + * @param string $ns + * @param int $auth permission level + * @param bool $fullscreen */ function media_uploadform($ns, $auth, $fullscreen = false){ global $lang; @@ -1708,6 +1790,10 @@ function media_getuploadsize(){ * * @author Tobias Sarnowski * @author Kate Arzamastseva + * + * @param string $ns + * @param string $query + * @param bool $fullscreen */ function media_searchform($ns,$query='',$fullscreen=false){ global $lang; @@ -1735,6 +1821,8 @@ function media_searchform($ns,$query='',$fullscreen=false){ * Build a tree outline of available media namespaces * * @author Andreas Gohr + * + * @param string $ns */ function media_nstree($ns){ global $conf; diff --git a/inc/pageutils.php b/inc/pageutils.php index 5f62926e4..adfb10cc7 100644 --- a/inc/pageutils.php +++ b/inc/pageutils.php @@ -265,7 +265,7 @@ function page_exists($id,$rev='',$clean=true) { * The filename is URL encoded to protect Unicode chars * * @param $raw_id string id of wikipage - * @param $rev string page revision, empty string for current + * @param $rev int|string page revision, empty string for current * @param $clean bool flag indicating that $raw_id should be cleaned. Only set to false * when $id is guaranteed to have been cleaned already. * @return string full path diff --git a/inc/parser/metadata.php b/inc/parser/metadata.php index 25bf3fe3d..4619c24ce 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 diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 44ead9d45..cd4b3d6e5 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -1571,7 +1571,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { * Returns HTML code for images used in link titles * * @author Andreas Gohr - * @param string $img + * @param array $img * @return string HTML img tag or similar */ function _imageTitle($img) { diff --git a/inc/plugincontroller.class.php b/inc/plugincontroller.class.php index d80cd4c9e..999f32937 100644 --- a/inc/plugincontroller.class.php +++ b/inc/plugincontroller.class.php @@ -66,7 +66,7 @@ class Doku_Plugin_Controller { * @param $name string name of the plugin to load * @param $new bool true to return a new instance of the plugin, false to use an already loaded instance * @param $disabled bool true to load even disabled plugins - * @return DokuWiki_Plugin|DokuWiki_Syntax_Plugin|null the plugin object or null on failure + * @return DokuWiki_Plugin|DokuWiki_Syntax_Plugin|DokuWiki_Auth_Plugin|DokuWiki_Admin_Plugin|DokuWiki_Action_Plugin|DokuWiki_Remote_Plugin|null the plugin object or null on failure */ public function load($type,$name,$new=false,$disabled=false){ diff --git a/inc/subscription.php b/inc/subscription.php index aab6de926..dbbcbe16a 100644 --- a/inc/subscription.php +++ b/inc/subscription.php @@ -515,7 +515,7 @@ class Subscription { * @author Adrian Lang * * @param string $subscriber_mail The target mail address - * @param array $id The ID + * @param string $id The ID * @param int $lastupdate Time of the last notification * @return bool */ diff --git a/inc/template.php b/inc/template.php index 7f3c68534..667e3db1c 100644 --- a/inc/template.php +++ b/inc/template.php @@ -204,7 +204,7 @@ function tpl_toc($return = false) { $toc = $TOC; } elseif(($ACT == 'show' || substr($ACT, 0, 6) == 'export') && !$REV && $INFO['exists']) { // get TOC from metadata, render if neccessary - $meta = p_get_metadata($ID, false, METADATA_RENDER_USING_CACHE); + $meta = p_get_metadata($ID, '', METADATA_RENDER_USING_CACHE); if(isset($meta['internal']['toc'])) { $tocok = $meta['internal']['toc']; } else { @@ -503,6 +503,10 @@ function tpl_getparent($id) { * * @author Adrian Lang * @see tpl_get_action + * + * @param string $type + * @param bool $return + * @return bool|string html, or false if no data, true if printed */ function tpl_button($type, $return = false) { $data = tpl_get_action($type); @@ -534,6 +538,13 @@ function tpl_button($type, $return = false) { * * @author Adrian Lang * @see tpl_get_action + * + * @param string $type + * @param string $pre prefix of link + * @param string $suf suffix of link + * @param string $inner innerHML of link + * @param bool $return + * @return bool|string html or false if no data, true if printed */ function tpl_actionlink($type, $pre = '', $suf = '', $inner = '', $return = false) { global $lang; @@ -571,7 +582,7 @@ function tpl_actionlink($type, $pre = '', $suf = '', $inner = '', $return = fals $linktarget, $pre.(($inner) ? $inner : $caption).$suf, 'class="action '.$type.'" '. $akey.$rel. - 'title="'.hsc($caption).$addTitle.'"', 1 + 'title="'.hsc($caption).$addTitle.'"', true ); } if($return) return $out; @@ -599,6 +610,7 @@ function tpl_actionlink($type, $pre = '', $suf = '', $inner = '', $return = fals * @author Andreas Gohr * @author Matthias Grimm * @author Adrian Lang + * * @param string $type * @return array|bool|string */ @@ -757,20 +769,20 @@ function tpl_get_action($type) { * * @author Anika Henke * @param - * @param bool $link link or form button? - * @param bool $wrapper HTML element wrapper - * @param bool $return return or print - * @param string $pre prefix for links - * @param string $suf suffix for links - * @param string $inner inner HTML for links + * @param bool $link link or form button? + * @param string|bool $wrapper HTML element wrapper + * @param bool $return return or print + * @param string $pre prefix for links + * @param string $suf suffix for links + * @param string $inner inner HTML for links * @return bool|string */ function tpl_action($type, $link = false, $wrapper = false, $return = false, $pre = '', $suf = '', $inner = '') { $out = ''; if($link) { - $out .= tpl_actionlink($type, $pre, $suf, $inner, 1); + $out .= tpl_actionlink($type, $pre, $suf, $inner, true); } else { - $out .= tpl_button($type, 1); + $out .= tpl_button($type, true); } if($out && $wrapper) $out = "<$wrapper>$out"; @@ -1029,7 +1041,7 @@ function tpl_pagetitle($id = null, $ret = false) { * @author Andreas Gohr * @param array $tags tags to try * @param string $alt alternative output if no data was found - * @param null $src the image src, uses global $SRC if not given + * @param null|string $src the image src, uses global $SRC if not given * @return string */ function tpl_img_getTag($tags, $alt = '', $src = null) { @@ -1613,6 +1625,11 @@ function tpl_license($img = 'badge', $imgonly = false, $return = false, $wrap = * * This function is useful to populate sidebars or similar features in a * template + * + * @param string $pageid + * @param bool $print + * @param bool $propagate + * @return bool|null|string */ function tpl_include_page($pageid, $print = true, $propagate = false) { if (!$pageid) return false; diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php index 3ab117736..d0a5e0463 100644 --- a/lib/exe/indexer.php +++ b/lib/exe/indexer.php @@ -51,8 +51,9 @@ exit; /** * Trims the recent changes cache (or imports the old changelog) as needed. * - * @param media_changes If the media changelog shall be trimmed instead of - * the page changelog + * @param bool $media_changes If the media changelog shall be trimmed instead of + * the page changelog + * @return bool * * @author Ben Coburn */ diff --git a/lib/plugins/authldap/auth.php b/lib/plugins/authldap/auth.php index b22b82ecc..a94c7a357 100644 --- a/lib/plugins/authldap/auth.php +++ b/lib/plugins/authldap/auth.php @@ -564,15 +564,13 @@ class auth_plugin_authldap extends DokuWiki_Auth_Plugin { * Wraps around ldap_search, ldap_list or ldap_read depending on $scope * * @author Andreas Gohr - * @param resource $link_identifier - * @param string $base_dn - * @param string $filter - * @param string $scope can be 'base', 'one' or 'sub' - * @param null $attributes - * @param int $attrsonly - * @param int $sizelimit - * @param int $timelimit - * @param int $deref + * @param resource $link_identifier + * @param string $base_dn + * @param string $filter + * @param string $scope can be 'base', 'one' or 'sub' + * @param null|array $attributes + * @param int $attrsonly + * @param int $sizelimit * @return resource */ protected function _ldapsearch($link_identifier, $base_dn, $filter, $scope = 'sub', $attributes = null, diff --git a/lib/plugins/authmysql/auth.php b/lib/plugins/authmysql/auth.php index 95c62f636..176eac679 100644 --- a/lib/plugins/authmysql/auth.php +++ b/lib/plugins/authmysql/auth.php @@ -284,7 +284,7 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin { $grpdel = array_diff($groups, $changes['grps']); foreach($grpadd as $group) { - if(($this->_addUserToGroup($user, $group, 1)) == false) { + if(($this->_addUserToGroup($user, $group, true)) == false) { $rc = false; } } @@ -612,7 +612,7 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin { if($uid) { foreach($grps as $group) { - $gid = $this->_addUserToGroup($user, $group, 1); + $gid = $this->_addUserToGroup($user, $group, true); if($gid === false) break; } @@ -777,7 +777,6 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin { * * @param string $user user's nick being updated * @param array $changes array of items to change as pairs of item and value - * @param mixed $uid user id of dataset to change, must be unique in DB * @return bool true on success or false on error * * @author Matthias Grimm diff --git a/lib/plugins/authpgsql/auth.php b/lib/plugins/authpgsql/auth.php index 99f3ed443..4f5e3346f 100644 --- a/lib/plugins/authpgsql/auth.php +++ b/lib/plugins/authpgsql/auth.php @@ -265,7 +265,7 @@ class auth_plugin_authpgsql extends auth_plugin_authmysql { if($uid) { foreach($grps as $group) { - $gid = $this->_addUserToGroup($user, $group, 1); + $gid = $this->_addUserToGroup($user, $group, true); if($gid === false) break; } diff --git a/lib/plugins/info/syntax.php b/lib/plugins/info/syntax.php index 9265f44d5..3e3f6b733 100644 --- a/lib/plugins/info/syntax.php +++ b/lib/plugins/info/syntax.php @@ -255,7 +255,7 @@ class syntax_plugin_info extends DokuWiki_Syntax_Plugin { if (($level >= $conf['toptoclevel']) && ($level <= $conf['maxtoclevel'])){ /** @var $renderer Doku_Renderer_xhtml */ - $hid = $renderer->_headerToLink($text, 'true'); + $hid = $renderer->_headerToLink($text, true); $renderer->toc[] = array( 'hid' => $hid, 'title' => $text, diff --git a/lib/tpl/dokuwiki/detail.php b/lib/tpl/dokuwiki/detail.php index 8fe2c88a2..4d0e984b1 100644 --- a/lib/tpl/dokuwiki/detail.php +++ b/lib/tpl/dokuwiki/detail.php @@ -82,8 +82,8 @@ header('X-UA-Compatible: IE=edge,chrome=1'); $data = array( 'view' => 'detail', 'items' => array( - 'mediaManager' => tpl_action('mediaManager', 1, 'li', 1, '', ''), - 'img_backto' => tpl_action('img_backto', 1, 'li', 1, '', ''), + 'mediaManager' => tpl_action('mediaManager', true, 'li', true, '', ''), + 'img_backto' => tpl_action('img_backto', true, 'li', true, '', ''), ) ); diff --git a/lib/tpl/dokuwiki/images/pagetools-build.php b/lib/tpl/dokuwiki/images/pagetools-build.php index 1b7262ad5..3cf35b2ea 100644 --- a/lib/tpl/dokuwiki/images/pagetools-build.php +++ b/lib/tpl/dokuwiki/images/pagetools-build.php @@ -92,7 +92,7 @@ function hex2rgb($hex) { /** * Scale (darken/lighten) a given image * - * @param ressource $img The truetype GD image to work on + * @param resource $img The truetype GD image to work on * @param float $scale Scale the colors by this value ( <1 darkens, >1 lightens) */ function imagecolorscale(&$img, $scale){ diff --git a/lib/tpl/dokuwiki/main.php b/lib/tpl/dokuwiki/main.php index 44fef81eb..10c0bf91e 100644 --- a/lib/tpl/dokuwiki/main.php +++ b/lib/tpl/dokuwiki/main.php @@ -41,7 +41,7 @@ $showSidebar = $hasSidebar && ($ACT=='show');
    - +
    @@ -77,12 +77,12 @@ $showSidebar = $hasSidebar && ($ACT=='show'); $data = array( 'view' => 'main', 'items' => array( - 'edit' => tpl_action('edit', 1, 'li', 1, '', ''), - 'revert' => tpl_action('revert', 1, 'li', 1, '', ''), - 'revisions' => tpl_action('revisions', 1, 'li', 1, '', ''), - 'backlink' => tpl_action('backlink', 1, 'li', 1, '', ''), - 'subscribe' => tpl_action('subscribe', 1, 'li', 1, '', ''), - 'top' => tpl_action('top', 1, 'li', 1, '', '') + 'edit' => tpl_action('edit', true, 'li', true, '', ''), + 'revert' => tpl_action('revert', true, 'li', true, '', ''), + 'revisions' => tpl_action('revisions', true, 'li', true, '', ''), + 'backlink' => tpl_action('backlink', true, 'li', true, '', ''), + 'subscribe' => tpl_action('subscribe', true, 'li', true, '', ''), + 'top' => tpl_action('top', true, 'li', true, '', '') ) ); diff --git a/lib/tpl/dokuwiki/tpl_header.php b/lib/tpl/dokuwiki/tpl_header.php index a2bfd4346..7d9c88347 100644 --- a/lib/tpl/dokuwiki/tpl_header.php +++ b/lib/tpl/dokuwiki/tpl_header.php @@ -46,10 +46,10 @@ if (!defined('DOKU_INC')) die(); tpl_userinfo(); /* 'Logged in as ...' */ echo ''; } - tpl_action('admin', 1, 'li'); - tpl_action('profile', 1, 'li'); - tpl_action('register', 1, 'li'); - tpl_action('login', 1, 'li'); + tpl_action('admin', true, 'li'); + tpl_action('profile', true, 'li'); + tpl_action('register', true, 'li'); + tpl_action('login', true, 'li'); ?>
@@ -64,9 +64,9 @@ if (!defined('DOKU_INC')) die();
-- cgit v1.2.3 From 59bc3b48fdffb76ee65a4b630be3ffa1f6c20c80 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Mon, 29 Sep 2014 21:45:27 +0200 Subject: more scrutinizer issue improvements --- inc/IXR_Library.php | 3 ++- inc/JpegMeta.php | 10 ++++---- inc/Mailer.class.php | 10 ++++---- inc/RemoteAPICore.php | 1 + inc/Tar.class.php | 1 + inc/ZipLib.class.php | 7 ++++-- inc/actions.php | 1 - inc/auth.php | 1 + inc/common.php | 3 +++ inc/fulltext.php | 1 + inc/html.php | 1 + inc/infoutils.php | 3 ++- inc/media.php | 34 ++++++++++++++++------------ inc/parser/lexer.php | 25 ++++++++++++-------- inc/parser/metadata.php | 14 ++++++------ inc/parser/xhtml.php | 7 ++++-- inc/plugincontroller.class.php | 2 +- inc/remote.php | 2 +- inc/search.php | 1 + inc/subscription.php | 2 +- inc/template.php | 1 - lib/exe/indexer.php | 2 +- lib/plugins/acl/admin.php | 6 ++--- lib/plugins/acl/remote.php | 2 ++ lib/plugins/auth.php | 5 +++- lib/plugins/authad/adLDAP/adLDAP.php | 2 -- lib/plugins/authad/auth.php | 1 + lib/plugins/authldap/auth.php | 1 + lib/plugins/authmysql/auth.php | 2 +- lib/plugins/config/settings/config.class.php | 4 +++- lib/plugins/config/settings/extra.class.php | 7 +++--- lib/plugins/info/syntax.php | 13 +++++++---- lib/plugins/usermanager/admin.php | 6 +++-- 33 files changed, 110 insertions(+), 71 deletions(-) diff --git a/inc/IXR_Library.php b/inc/IXR_Library.php index 979dc4d16..2becf4a54 100644 --- a/inc/IXR_Library.php +++ b/inc/IXR_Library.php @@ -15,6 +15,7 @@ class IXR_Value { + /** @var IXR_Value[]|IXR_Date|IXR_Base64|int|bool|double|string */ var $data; var $type; function IXR_Value ($data, $type = false) { @@ -177,7 +178,7 @@ class IXR_Message { return true; } function tag_open($parser, $tag, $attr) { - $this->currentTag = $tag; + $this->_currentTag = $tag; $this->_currentTagContents = ''; switch($tag) { case 'methodCall': diff --git a/inc/JpegMeta.php b/inc/JpegMeta.php index a35ec3ed0..3b6c6694c 100644 --- a/inc/JpegMeta.php +++ b/inc/JpegMeta.php @@ -42,6 +42,7 @@ class JpegMeta { var $_fileName; var $_fp = null; + var $_fpout = null; var $_type = 'unknown'; var $_markers; @@ -527,12 +528,12 @@ class JpegMeta { /** * Get the image's title, tries various fields * - * @param int $max maximum number chars (keeps words) + * @param int $max maximum number chars (keeps words) + * @return bool|mixed|string + * * @author Andreas Gohr */ function getTitle($max=80){ - $cap = ''; - // try various fields $cap = $this->getField(array('Iptc.Headline', 'Iptc.Caption', @@ -560,6 +561,7 @@ class JpegMeta { $this->_parseAll(); if ($this->_markers == null) { if (@isset($this->_info['file']['UnixTime'])) { + $dates = array(); $dates['FileModified'] = $this->_info['file']['UnixTime']; $dates['Time'] = $this->_info['file']['UnixTime']; $dates['TimeSource'] = 'FileModified'; @@ -1334,7 +1336,6 @@ class JpegMeta { return false; } - $pos = 0; $this->_info['jfif'] = array(); $vmaj = $this->_getByte($data, 5); @@ -1420,7 +1421,6 @@ class JpegMeta { break; default: return false; - break; } $this->_info['sof']['Format'] = $format; diff --git a/inc/Mailer.class.php b/inc/Mailer.class.php index e90b45f99..fb9ed460c 100644 --- a/inc/Mailer.class.php +++ b/inc/Mailer.class.php @@ -130,7 +130,7 @@ class Mailer { * If an empy value is passed, the header is removed * * @param string $header the header name (no trailing colon!) - * @param string $value the value of the header + * @param string|string[] $value the value of the header * @param bool $clean remove all non-ASCII chars and line feeds? */ public function setHeader($header, $value, $clean = true) { @@ -177,7 +177,7 @@ class Mailer { * @param string $text plain text body * @param array $textrep replacements to apply on the text part * @param array $htmlrep replacements to apply on the HTML part, leave null to use $textrep - * @param array $html the HTML body, leave null to create it from $text + * @param string $html the HTML body, leave null to create it from $text * @param bool $wrap wrap the HTML in the default header/Footer */ public function setBody($text, $textrep = null, $htmlrep = null, $html = null, $wrap = true) { @@ -283,7 +283,7 @@ class Mailer { * Add the To: recipients * * @see cleanAddress - * @param string|array $address Multiple adresses separated by commas or as array + * @param string|string[] $address Multiple adresses separated by commas or as array */ public function to($address) { $this->setHeader('To', $address, false); @@ -293,7 +293,7 @@ class Mailer { * Add the Cc: recipients * * @see cleanAddress - * @param string|array $address Multiple adresses separated by commas or as array + * @param string|string[] $address Multiple adresses separated by commas or as array */ public function cc($address) { $this->setHeader('Cc', $address, false); @@ -303,7 +303,7 @@ class Mailer { * Add the Bcc: recipients * * @see cleanAddress - * @param string|array $address Multiple adresses separated by commas or as array + * @param string|string[] $address Multiple adresses separated by commas or as array */ public function bcc($address) { $this->setHeader('Bcc', $address, false); diff --git a/inc/RemoteAPICore.php b/inc/RemoteAPICore.php index ffa03ee93..8c7a0e846 100644 --- a/inc/RemoteAPICore.php +++ b/inc/RemoteAPICore.php @@ -681,6 +681,7 @@ class RemoteAPICore { $pagelog->setChunkSize(1024); $info = $pagelog->getRevisionInfo($time); if(!empty($info)) { + $data = array(); $data['user'] = $info['user']; $data['ip'] = $info['ip']; $data['type'] = $info['type']; diff --git a/inc/Tar.class.php b/inc/Tar.class.php index 903f7f35c..8c7d33fc1 100644 --- a/inc/Tar.class.php +++ b/inc/Tar.class.php @@ -536,6 +536,7 @@ class Tar { $header = @unpack("a100filename/a8perm/a8uid/a8gid/a12size/a12mtime/a8checksum/a1typeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor/a155prefix", $block); if(!$header) return false; + $return = array(); $return['checksum'] = OctDec(trim($header['checksum'])); if($return['checksum'] != $chks) return false; diff --git a/inc/ZipLib.class.php b/inc/ZipLib.class.php index 918d38579..cec518b05 100644 --- a/inc/ZipLib.class.php +++ b/inc/ZipLib.class.php @@ -24,10 +24,12 @@ class ZipLib { @rewind($zip); @fseek($zip, $centd['offset']); + $ret = array(); for ($i=0; $i<$centd['entries']; $i++) { $header = $this->ReadCentralFileHeaders($zip); $header['index'] = $i; + $info = array(); $info['filename'] = $header['filename']; $info['stored_filename'] = $header['stored_filename']; $info['size'] = $header['size']; @@ -48,6 +50,7 @@ class ZipLib { function Add($files,$compact) { if(!is_array($files[0])) $files=Array($files); + $ret = array(); for($i=0;$files[$i];$i++){ $fn = $files[$i]; if(!in_Array(dirname($fn[0]),$this->dirs)) @@ -189,7 +192,6 @@ class ZipLib { */ function Extract ( $zn, $to, $index = Array(-1) ) { if(!@is_dir($to)) $this->_mkdir($to); - $ok = 0; $zip = @fopen($zn,'rb'); if(!$zip) return(-1); $cdir = $this->ReadCentralDir($zip,$zn); @@ -203,6 +205,7 @@ class ZipLib { return(-1); } + $stat = array(); for ($i=0; $i<$cdir['entries']; $i++) { @fseek($zip, $pos_entry); $header = $this->ReadCentralFileHeaders($zip); @@ -320,6 +323,7 @@ class ZipLib { $data=unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', fread($zip, 18)); + $centd = array(); if ($data['comment_size'] != 0){ $centd['comment'] = fread($zip, $data['comment_size']); } else { @@ -421,7 +425,6 @@ class ZipLib { function ExtractStr($zn, $name) { - $ok = 0; $zip = @fopen($zn,'rb'); if(!$zip) return(null); $cdir = $this->ReadCentralDir($zip,$zn); diff --git a/inc/actions.php b/inc/actions.php index 2b819a0d6..5cf63a6ca 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -600,7 +600,6 @@ function act_export($act){ $pre = ''; $post = ''; - $output = ''; $headers = array(); // search engines: never cache exported docs! (Google only currently) diff --git a/inc/auth.php b/inc/auth.php index e938830ef..dc2b6cad8 100644 --- a/inc/auth.php +++ b/inc/auth.php @@ -1129,6 +1129,7 @@ function auth_deleteprofile(){ } } + $deleted = array(); $deleted[] = $INPUT->server->str('REMOTE_USER'); if($auth->triggerUserMod('delete', array($deleted))) { // force and immediate logout including removing the sticky cookie diff --git a/inc/common.php b/inc/common.php index 95ea4e72d..91a068bb0 100644 --- a/inc/common.php +++ b/inc/common.php @@ -120,6 +120,7 @@ function basicinfo($id, $htmlClient=true){ global $INPUT; // set info about manager/admin status. + $info = array(); $info['isadmin'] = false; $info['ismanager'] = false; if($INPUT->server->has('REMOTE_USER')) { @@ -685,6 +686,7 @@ function checkwordblock($text = '') { } if(count($re) && preg_match('#('.join('|', $re).')#si', $text, $matches)) { // prepare event data + $data = array(); $data['matches'] = $matches; $data['userinfo']['ip'] = $INPUT->server->str('REMOTE_ADDR'); if($INPUT->server->str('REMOTE_USER')) { @@ -1119,6 +1121,7 @@ function rawWikiSlices($range, $id, $rev = '') { $from = !$from ? 0 : ($from - 1); $to = !$to ? strlen($text) : ($to - 1); + $slices = array(); $slices[0] = substr($text, 0, $from); $slices[1] = substr($text, $from, $to - $from); $slices[2] = substr($text, $to); diff --git a/inc/fulltext.php b/inc/fulltext.php index aaef090e1..c1dc16e47 100644 --- a/inc/fulltext.php +++ b/inc/fulltext.php @@ -23,6 +23,7 @@ if(!defined('FT_SNIPPET_NUMBER')) define('FT_SNIPPET_NUMBER',15); */ function ft_pageSearch($query,&$highlight){ + $data = array(); $data['query'] = $query; $data['highlight'] =& $highlight; diff --git a/inc/html.php b/inc/html.php index dd4a3d8da..ce6360175 100644 --- a/inc/html.php +++ b/inc/html.php @@ -1902,6 +1902,7 @@ function html_debug(){ print ''; if (function_exists('apache_get_version')) { + $apache = array(); $apache['version'] = apache_get_version(); if (function_exists('apache_get_modules')) { diff --git a/inc/infoutils.php b/inc/infoutils.php index f9ba11560..9c297a28d 100644 --- a/inc/infoutils.php +++ b/inc/infoutils.php @@ -296,6 +296,7 @@ define('MSG_ADMINS_ONLY',4); */ function msg($message,$lvl=0,$line='',$file='',$allow=MSG_PUBLIC){ global $MSG, $MSG_shown; + $errors = array(); $errors[-1] = 'error'; $errors[0] = 'info'; $errors[1] = 'success'; @@ -452,7 +453,7 @@ function dbg_backtrace(){ }elseif(is_array($arg)){ $params[] = '[Array]'; }elseif(is_null($arg)){ - $param[] = '[NULL]'; + $params[] = '[NULL]'; }else{ $params[] = (string) '"'.$arg.'"'; } diff --git a/inc/media.php b/inc/media.php index 2b802a0ae..7770d3cc9 100644 --- a/inc/media.php +++ b/inc/media.php @@ -231,6 +231,7 @@ function media_delete($id,$auth){ $file = mediaFN($id); // trigger an event - MEDIA_DELETE_FILE + $data = array(); $data['id'] = $id; $data['name'] = utf8_basename($file); $data['path'] = $file; @@ -439,6 +440,7 @@ function media_save($file, $id, $ow, $auth, $move) { } // prepare event data + $data = array(); $data[0] = $file['name']; $data[1] = $fn; $data[2] = $id; @@ -910,11 +912,11 @@ function media_tab_history($image, $ns, $auth=null) { * * @param string $image media id * @param int $auth permission level - * @param int|bool $rev + * @param int|string $rev revision timestamp or empty string * @param JpegMeta|bool $meta * @author Kate Arzamastseva */ -function media_preview($image, $auth, $rev=false, $meta=false) { +function media_preview($image, $auth, $rev='', $meta=false) { $size = media_image_preview_size($image, $rev, $meta); @@ -999,11 +1001,11 @@ function media_preview_buttons($image, $auth, $rev='') { * Returns image width and height for mediamanager preview panel * * @author Kate Arzamastseva - * @param string $image - * @param int|string $rev - * @param JpegMeta $meta - * @param int $size - * @return array + * @param string $image + * @param int|string $rev + * @param JpegMeta|bool $meta + * @param int $size + * @return array|bool */ function media_image_preview_size($image, $rev, $meta, $size = 500) { if (!preg_match("/\.(jpe?g|gif|png)$/", $image) || !file_exists(mediaFN($image, $rev))) return false; @@ -1158,6 +1160,7 @@ function media_diff($image, $ns, $auth, $fromajax = false) { } // prepare event data + $data = array(); $data[0] = $image; $data[1] = $l_rev; $data[2] = $r_rev; @@ -1397,13 +1400,12 @@ function media_searchlist($query,$ns,$auth=null,$fullscreen=false,$sort='natural global $lang; $ns = cleanID($ns); - + $evdata = array( + 'ns' => $ns, + 'data' => array(), + 'query' => $query + ); if ($query) { - $evdata = array( - 'ns' => $ns, - 'data' => array(), - 'query' => $query - ); $evt = new Doku_Event('MEDIA_SEARCH', $evdata); if ($evt->advise_before()) { $dir = utf8_encodeFN(str_replace(':','/',$evdata['ns'])); @@ -2169,6 +2171,7 @@ function media_resize_imageGD($ext,$from,$from_w,$from_h,$to,$to_w,$to_h,$ofs_x= } // create an image of the given filetype + $image = false; if ($ext == 'jpg' || $ext == 'jpeg'){ if(!function_exists("imagecreatefromjpeg")) return false; $image = @imagecreatefromjpeg($from); @@ -2182,6 +2185,7 @@ function media_resize_imageGD($ext,$from,$from_w,$from_h,$to,$to_w,$to_h,$ofs_x= } if(!$image) return false; + $newimg = false; if(($conf['gdlib']>1) && function_exists("imagecreatetruecolor") && $ext != 'gif'){ $newimg = @imagecreatetruecolor ($to_w, $to_h); } @@ -2266,14 +2270,14 @@ function media_resize_imageGD($ext,$from,$from_w,$from_h,$to,$to_w,$to_h,$ofs_x= function media_alternativefiles($src, $exts){ $files = array(); - list($srcExt, $srcMime) = mimetype($src); + list($srcExt, /* $srcMime */) = mimetype($src); $filebase = substr($src, 0, -1 * (strlen($srcExt)+1)); foreach($exts as $ext) { $fileid = $filebase.'.'.$ext; $file = mediaFN($fileid); if(file_exists($file)) { - list($fileExt, $fileMime) = mimetype($file); + list(/* $fileExt */, $fileMime) = mimetype($file); $files[$fileMime] = $fileid; } } diff --git a/inc/parser/lexer.php b/inc/parser/lexer.php index 2e84eca7c..b46a5f505 100644 --- a/inc/parser/lexer.php +++ b/inc/parser/lexer.php @@ -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() { @@ -297,6 +298,7 @@ class Doku_Lexer { */ function Doku_Lexer(&$parser, $start = "accept", $case = false) { $this->_case = $case; + /** @var Doku_LexerParallelRegex[] _regexes */ $this->_regexes = array(); $this->_parser = &$parser; $this->_mode = new Doku_LexerStateStack($start); @@ -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 4619c24ce..3fc5d1c9a 100644 --- a/inc/parser/metadata.php +++ b/inc/parser/metadata.php @@ -421,8 +421,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 +458,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 +628,9 @@ class Doku_Renderer_metadata extends Doku_Renderer { * Construct a title and handle images in titles * * @author Harry Fuecks - * @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/xhtml.php b/inc/parser/xhtml.php index cd4b3d6e5..aa09058df 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -820,6 +820,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { // now first resolve and clean up the $id resolve_pageid(getNS($ID), $id, $exists); + $link = array(); $name = $this->_getLinkTitle($name, $default, $isImage, $id, $linktype); if(!$isImage) { if($exists) { @@ -904,6 +905,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } //prepare for formating + $link = array(); $link['target'] = $conf['target']['extern']; $link['style'] = ''; $link['pre'] = ''; @@ -981,6 +983,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { global $conf; //simple setup + $link = array(); $link['target'] = $conf['target']['windows']; $link['pre'] = ''; $link['suf'] = ''; @@ -1656,7 +1659,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, '&'); } @@ -1700,7 +1703,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { * @param array $atts - additional attributes for the