From 6d9eab4daacb2af47b0d8c19af63f9420d4c1ee1 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Fri, 24 Aug 2012 14:44:32 +0200 Subject: Prevent access to undefined variables and make returns consistent in html.php --- inc/html.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index af047a107..0a976e562 100644 --- a/inc/html.php +++ b/inc/html.php @@ -121,7 +121,7 @@ function html_secedit_get_button($data) { global $ID; global $INFO; - if (!isset($data['name']) || $data['name'] === '') return; + if (!isset($data['name']) || $data['name'] === '') return ''; $name = $data['name']; unset($data['name']); @@ -718,6 +718,9 @@ function html_recent($first=0, $show_changes='both'){ $form->addElement($date); $form->addElement(form_makeCloseTag('span')); + $diff = false; + $href = ''; + if ($recent['media']) { $diff = (count(getRevisions($recent['id'], 0, 1, 8192, true)) && @file_exists(mediaFN($recent['id']))); if ($diff) { @@ -1116,7 +1119,7 @@ function html_diff($text='',$intro=true,$type=null){ $r_text = cleanText($text); $r_head = $lang['yours']; }else{ - if($rev1 && $rev2){ // two specific revisions wanted + if($rev1 && isset($rev2) && $rev2){ // two specific revisions wanted // make sure order is correct (older on the left) if($rev1 < $rev2){ $l_rev = $rev1; -- cgit v1.2.3 From 8d5e837e4415e24f64439be7c9ecc15f402560a9 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Fri, 24 Aug 2012 14:52:00 +0200 Subject: Fix/add some PHPDoc comments in inc/html.php --- inc/html.php | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index 0a976e562..d2c82becf 100644 --- a/inc/html.php +++ b/inc/html.php @@ -13,6 +13,10 @@ if(!defined('NL')) define('NL',"\n"); * Convenience function to quickly build a wikilink * * @author Andreas Gohr + * @param string $id id of the target page + * @param string $name the name of the link, i.e. the text that is displayed + * @param string|array $search search string(s) that shall be highlighted in the target page + * @return string the HTML code of the link */ function html_wikilink($id,$name=null,$search=''){ static $xhtml_renderer = null; @@ -1000,6 +1004,14 @@ function html_backlinks(){ } } +/** + * Get header of diff HTML + * @param string $l_rev Left revisions + * @param string $r_rev Right revision + * @param string $id Page id, if null $ID is used + * @param bool $media If it is for media files + * @return array HTML snippets for diff header + */ function html_diff_head($l_rev, $r_rev, $id = null, $media = false) { global $lang; if ($id === null) { @@ -1075,7 +1087,8 @@ function html_diff_head($l_rev, $r_rev, $id = null, $media = false) { * * @author Andreas Gohr * @param string $text - compare with this text with most current version - * @param bool $intr - display the intro text + * @param bool $intro - display the intro text + * @param string $type type of the diff (inline or sidebyside) */ function html_diff($text='',$intro=true,$type=null){ global $ID; @@ -1233,6 +1246,7 @@ function html_conflict($text,$summary){ */ function html_msgarea(){ global $MSG, $MSG_shown; + /** @var array $MSG */ // store if the global $MSG has already been shown and thus HTML output has been started $MSG_shown = true; @@ -1294,6 +1308,7 @@ function html_updateprofile(){ global $INPUT; global $ID; global $INFO; + /** @var auth_basic $auth */ global $auth; print p_locale_xhtml('updateprofile'); @@ -1492,6 +1507,7 @@ function html_minoredit(){ function html_debug(){ global $conf; global $lang; + /** @var auth_basic $auth */ global $auth; global $INFO; @@ -1578,12 +1594,14 @@ function html_admin(){ global $INFO; global $lang; global $conf; + /** @var auth_basic $auth */ global $auth; // build menu of admin functions from the plugins that handle them $pluginlist = plugin_list('admin'); $menu = array(); foreach ($pluginlist as $p) { + /** @var DokuWiki_Admin_Plugin $obj */ if($obj =& plugin_load('admin',$p) === null) continue; // check permissions @@ -1765,6 +1783,7 @@ function html_list_toc($item){ * @param string $text - what to display in the TOC * @param int $level - nesting level * @param string $hash - is prepended to the given $link, set blank if you want full links + * @return array the toc item */ function html_mktocitem($link, $text, $level, $hash='#'){ global $conf; @@ -1779,6 +1798,8 @@ function html_mktocitem($link, $text, $level, $hash='#'){ * Triggers an event with the form name: HTML_{$name}FORM_OUTPUT * * @author Tom N Harris + * @param string $name The name of the form + * @param Doku_Form $form The form */ function html_form($name, &$form) { // Safety check in case the caller forgets. @@ -1789,6 +1810,7 @@ function html_form($name, &$form) { /** * Form print function. * Just calls printForm() on the data object. + * @param Doku_Form $data The form */ function html_form_output($data) { $data->printForm(); @@ -1871,6 +1893,12 @@ function html_flashobject($swf,$width,$height,$params=null,$flashvars=null,$atts return $out; } +/** + * Prints HTML code for the given tab structure + * + * @param array $tabs tab structure + * @param string $current_tab the current tab id + */ function html_tabs($tabs, $current_tab = null) { echo '
    '.NL; -- cgit v1.2.3 From c0f0f1f84f62ba4ddd9175b1768d22b2d2fbacc0 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Fri, 24 Aug 2012 14:57:38 +0200 Subject: Remove unused/directly overwritten variable declarations in inc/html.php --- inc/html.php | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index d2c82becf..da89d60ed 100644 --- a/inc/html.php +++ b/inc/html.php @@ -150,7 +150,6 @@ function html_secedit_get_button($data) { function html_topbtn(){ global $lang; - $ret = ''; $ret = ''; return $ret; @@ -170,7 +169,6 @@ function html_btn($name,$id,$akey,$params,$method='get',$tooltip='',$label=false $label = $lang['btn_'.$name]; $ret = ''; - $tip = ''; //filter id (without urlencoding) $id = idfilter($id,false); @@ -260,7 +258,6 @@ function html_draft(){ global $INFO; global $ID; global $lang; - global $conf; $draft = unserialize(io_readFile($INFO['draft'],false)); $text = cleanText(con($draft['prefix'],$draft['text'],$draft['suffix'],true)); @@ -316,9 +313,7 @@ function html_hilight_callback($m) { * @author Andreas Gohr */ function html_search(){ - global $conf; global $QUERY; - global $ID; global $lang; $intro = p_locale_xhtml('searchpage'); @@ -339,8 +334,6 @@ function html_search(){ flush(); //do quick pagesearch - $data = array(); - $data = ft_pageLookup($QUERY,true,useHeading('navigation')); if(count($data)){ print '
    '; @@ -834,7 +827,6 @@ function html_recent($first=0, $show_changes='both'){ function html_index($ns){ global $conf; global $ID; - $dir = $conf['datadir']; $ns = cleanID($ns); #fixme use appropriate function if(empty($ns)){ @@ -984,7 +976,6 @@ function html_buildlist($data,$class,$func,$lifunc='html_li_default',$forcewrapp */ function html_backlinks(){ global $ID; - global $conf; global $lang; print p_locale_xhtml('backlinks'); @@ -1094,7 +1085,6 @@ function html_diff($text='',$intro=true,$type=null){ global $ID; global $REV; global $lang; - global $conf; global $INPUT; if(!$type) $type = $INPUT->str('difftype'); @@ -1273,7 +1263,6 @@ function html_msgarea(){ function html_register(){ global $lang; global $conf; - global $ID; global $INPUT; print p_locale_xhtml('register'); @@ -1306,7 +1295,6 @@ function html_updateprofile(){ global $lang; global $conf; global $INPUT; - global $ID; global $INFO; /** @var auth_basic $auth */ global $auth; @@ -1592,7 +1580,6 @@ function html_debug(){ function html_admin(){ global $ID; global $INFO; - global $lang; global $conf; /** @var auth_basic $auth */ global $auth; @@ -1703,7 +1690,6 @@ function html_admin(){ function html_resendpwd() { global $lang; global $conf; - global $ID; global $INPUT; $token = preg_replace('/[^a-f0-9]+/','',$INPUT->str('pwauth')); @@ -1786,7 +1772,6 @@ function html_list_toc($item){ * @return array the toc item */ function html_mktocitem($link, $text, $level, $hash='#'){ - global $conf; return array( 'link' => $hash.$link, 'title' => $text, 'type' => 'ul', -- cgit v1.2.3 From ff5a286c36a02bf81e4f8117cedda6803eaf7dfc Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Mon, 17 Sep 2012 23:05:51 +0200 Subject: Fix revisions title for pages without title with useheading on FS#2597 --- inc/html.php | 1 + 1 file changed, 1 insertion(+) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index da89d60ed..f4010b447 100644 --- a/inc/html.php +++ b/inc/html.php @@ -464,6 +464,7 @@ function html_revisions($first=0, $media_id = false){ else $exists = @file_exists(mediaFN($id)); $display_name = (!$media_id && useHeading('navigation')) ? hsc(p_get_first_heading($id)) : $id; + if (!$display_name) $display_name = $id; if($exists && $first==0){ if (!$media_id && isset($INFO['meta']) && isset($INFO['meta']['last_change']) && $INFO['meta']['last_change']['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) -- cgit v1.2.3 From 9aa38483ceebb96c92d630550c000fc324738d0e Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Mon, 17 Sep 2012 23:43:37 +0200 Subject: Fix link names of start pages in sitemap/index FS#2605 --- inc/html.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'inc/html.php') diff --git a/inc/html.php b/inc/html.php index f4010b447..f4e6af663 100644 --- a/inc/html.php +++ b/inc/html.php @@ -863,7 +863,8 @@ function html_list_index($item){ $ret .= $base; $ret .= ''; }else{ - $ret .= html_wikilink(':'.$item['id']); + // default is noNSorNS($id), but we want noNS($id) when useheading is off FS#2605 + $ret .= html_wikilink(':'.$item['id'], useHeading('navigation') ? null : noNS($item['id'])); } return $ret; } -- cgit v1.2.3