diff options
author | Guy Brand <gb@unistra.fr> | 2015-08-10 10:03:27 +0200 |
---|---|---|
committer | Guy Brand <gb@unistra.fr> | 2015-08-10 10:03:27 +0200 |
commit | 53a57d16b9c741bb44099fd93bf79efa06796341 (patch) | |
tree | 24a90a50afe9325926c8ebaa2ed90f9fa093e5b9 /inc/html.php | |
parent | cf6e6645c31a9f185cef3fb9452fb188882ede47 (diff) | |
parent | a060d9973e7c1d5051f2cc426937881826e4972e (diff) | |
download | rpg-53a57d16b9c741bb44099fd93bf79efa06796341.tar.gz rpg-53a57d16b9c741bb44099fd93bf79efa06796341.tar.bz2 |
Merge branch master into stable
Diffstat (limited to 'inc/html.php')
-rw-r--r-- | inc/html.php | 148 |
1 files changed, 127 insertions, 21 deletions
diff --git a/inc/html.php b/inc/html.php index 495bdf919..0914a1762 100644 --- a/inc/html.php +++ b/inc/html.php @@ -83,6 +83,10 @@ function html_denied() { * inserts section edit buttons if wanted or removes the markers * * @author Andreas Gohr <andi@splitbrain.org> + * + * @param string $text + * @param bool $show show section edit buttons? + * @return string */ function html_secedit($text,$show=true){ global $INFO; @@ -101,8 +105,11 @@ function html_secedit($text,$show=true){ * prepares section edit button data for event triggering * used as a callback in html_secedit * - * @triggers HTML_SECEDIT_BUTTON * @author Andreas Gohr <andi@splitbrain.org> + * + * @param array $matches matches with regexp + * @return string + * @triggers HTML_SECEDIT_BUTTON */ function html_secedit_button($matches){ $data = array('secid' => $matches[1], @@ -121,6 +128,9 @@ function html_secedit_button($matches){ * used as default action form HTML_SECEDIT_BUTTON * * @author Adrian Lang <lang@cosmocode.de> + * + * @param array $data name, section id and target + * @return string html */ function html_secedit_get_button($data) { global $ID; @@ -147,6 +157,8 @@ function html_secedit_get_button($data) { * Just the back to top button (in its own form) * * @author Andreas Gohr <andi@splitbrain.org> + * + * @return string html */ function html_topbtn(){ global $lang; @@ -161,8 +173,17 @@ function html_topbtn(){ * If tooltip exists, the access key tooltip is replaced. * * @author Andreas Gohr <andi@splitbrain.org> + * + * @param string $name + * @param string $id + * @param string $akey access key + * @param string[] $params key-value pairs added as hidden inputs + * @param string $method + * @param string $tooltip + * @param bool|string $label label text, false: lookup btn_$name in localization + * @return string */ -function html_btn($name,$id,$akey,$params,$method='get',$tooltip='',$label=false){ +function html_btn($name, $id, $akey, $params, $method='get', $tooltip='', $label=false){ global $conf; global $lang; @@ -200,22 +221,34 @@ function html_btn($name,$id,$akey,$params,$method='get',$tooltip='',$label=false $tip = htmlspecialchars($label); } - $ret .= '<input type="submit" value="'.hsc($label).'" class="button" '; + $ret .= '<button type="submit" '; if($akey){ $tip .= ' ['.strtoupper($akey).']'; $ret .= 'accesskey="'.$akey.'" '; } $ret .= 'title="'.$tip.'" '; $ret .= '/>'; + $ret .= hsc($label); + $ret .= '</button>'; $ret .= '</div></form>'; return $ret; } +/** + * show a revision warning + * + * @author Szymon Olewniczak <dokuwiki@imz.re> + */ +function html_showrev() { + print p_locale_xhtml('showrev'); +} /** - * show a wiki page + * Show a wiki page * * @author Andreas Gohr <andi@splitbrain.org> + * + * @param null|string $txt wiki text or null for showing $ID */ function html_show($txt=null){ global $ID; @@ -242,7 +275,10 @@ function html_show($txt=null){ echo '</div></div>'; }else{ - if ($REV||$DATE_AT) print p_locale_xhtml('showrev'); + if ($REV||$DATE_AT){ + $data = array('rev' => &$REV, 'date_at' => &$DATE_AT); + trigger_event('HTML_SHOWREV_OUTPUT', $data, 'html_showrev'); + } $html = p_wiki_xhtml($ID,$REV,true,$DATE_AT); $html = html_secedit($html,$secedit); if($INFO['prependTOC']) $html = tpl_toc(true).$html; @@ -282,6 +318,10 @@ function html_draft(){ * * @author Andreas Gohr <andi@splitbrain.org> * @author Harry Fuecks <hfuecks@gmail.com> + * + * @param string $html + * @param array|string $phrases + * @return string html */ function html_hilight($html,$phrases){ $phrases = (array) $phrases; @@ -300,6 +340,9 @@ function html_hilight($html,$phrases){ * Callback used by html_hilight() * * @author Harry Fuecks <hfuecks@gmail.com> + * + * @param array $m matches + * @return string html */ function html_hilight_callback($m) { $hlight = unslash($m[0]); @@ -425,6 +468,9 @@ function html_locked(){ * @author Andreas Gohr <andi@splitbrain.org> * @author Ben Coburn <btcoburn@silicodon.net> * @author Kate Arzamastseva <pshns@ukr.net> + * + * @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; @@ -468,7 +514,7 @@ function html_revisions($first=0, $media_id = false){ $form->addElement(form_makeOpenTag('ul')); if (!$media_id) $exists = $INFO['exists']; - else $exists = @file_exists(mediaFN($id)); + 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; @@ -535,7 +581,7 @@ function html_revisions($first=0, $media_id = false){ $date = dformat($rev); $info = $changelog->getRevisionInfo($rev); if($media_id) { - $exists = @file_exists(mediaFN($id, $rev)); + $exists = file_exists(mediaFN($id, $rev)); } else { $exists = page_exists($id, $rev); } @@ -646,6 +692,9 @@ function html_revisions($first=0, $media_id = false){ * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> * @author Ben Coburn <btcoburn@silicodon.net> * @author Kate Arzamastseva <pshns@ukr.net> + * + * @param int $first + * @param string $show_changes */ function html_recent($first=0, $show_changes='both'){ global $conf; @@ -729,10 +778,16 @@ function html_recent($first=0, $show_changes='both'){ $href = ''; if (!empty($recent['media'])) { - $diff = (count(getRevisions($recent['id'], 0, 1, 8192, true)) && @file_exists(mediaFN($recent['id']))); + $changelog = new MediaChangeLog($recent['id']); + $revs = $changelog->getRevisions(0, 1); + $diff = (count($revs) && file_exists(mediaFN($recent['id']))); if ($diff) { - $href = media_managerURL(array('tab_details' => 'history', - 'mediado' => 'diff', 'image' => $recent['id'], 'ns' => getNS($recent['id'])), '&'); + $href = media_managerURL(array( + 'tab_details' => 'history', + 'mediado' => 'diff', + 'image' => $recent['id'], + 'ns' => getNS($recent['id']) + ), '&'); } } else { $href = wl($recent['id'],"do=diff", false, '&'); @@ -803,26 +858,28 @@ function html_recent($first=0, $show_changes='both'){ $first -= $conf['recent']; if ($first < 0) $first = 0; $form->addElement(form_makeOpenTag('div', array('class' => 'pagenav-prev'))); - $form->addElement(form_makeTag('input', array( + $form->addElement(form_makeOpenTag('button', array( 'type' => 'submit', 'name' => 'first['.$first.']', - 'value' => $lang['btn_newer'], 'accesskey' => 'n', 'title' => $lang['btn_newer'].' [N]', 'class' => 'button show' ))); + $form->addElement($lang['btn_newer']); + $form->addElement(form_makeCloseTag('button')); $form->addElement(form_makeCloseTag('div')); } if ($hasNext) { $form->addElement(form_makeOpenTag('div', array('class' => 'pagenav-next'))); - $form->addElement(form_makeTag('input', array( + $form->addElement(form_makeOpenTag('button', array( 'type' => 'submit', 'name' => 'first['.$last.']', - 'value' => $lang['btn_older'], 'accesskey' => 'p', 'title' => $lang['btn_older'].' [P]', 'class' => 'button show' ))); + $form->addElement($lang['btn_older']); + $form->addElement(form_makeCloseTag('button')); $form->addElement(form_makeCloseTag('div')); } $form->addElement(form_makeCloseTag('div')); @@ -833,6 +890,8 @@ function html_recent($first=0, $show_changes='both'){ * Display page index * * @author Andreas Gohr <andi@splitbrain.org> + * + * @param string $ns */ function html_index($ns){ global $conf; @@ -861,6 +920,9 @@ function html_index($ns){ * User function for html_buildlist() * * @author Andreas Gohr <andi@splitbrain.org> + * + * @param array $item + * @return string */ function html_list_index($item){ global $ID, $conf; @@ -891,10 +953,23 @@ function html_list_index($item){ * it gives different classes to opened or closed "folders" * * @author Andreas Gohr <andi@splitbrain.org> + * + * @param array $item + * @return string html */ function html_li_index($item){ + global $INFO; + + $class = ''; + $id = ''; + if($item['type'] == "f"){ - return '<li class="level'.$item['level'].'">'; + // scroll to the current item + if($item['id'] == $INFO['id']) { + $id = ' id="scroll__here"'; + $class = ' bounce'; + } + return '<li class="level'.$item['level'].$class.'" '.$id.'>'; }elseif($item['open']){ return '<li class="open">'; }else{ @@ -906,6 +981,9 @@ function html_li_index($item){ * Default List item * * @author Andreas Gohr <andi@splitbrain.org> + * + * @param array $item + * @return string html */ function html_li_default($item){ return '<li class="level'.$item['level'].'">'; @@ -929,9 +1007,9 @@ 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) + * 0 (we have a root object) or 1 (just the root content) * @return string html of an unordered list */ function html_buildlist($data,$class,$func,$lifunc='html_li_default',$forcewrapper=false){ @@ -1021,12 +1099,13 @@ 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 * @param bool $inline Return the header on a single line - * @return array HTML snippets for diff header + * @return string[] HTML snippets for diff header */ function html_diff_head($l_rev, $r_rev, $id = null, $media = false, $inline = false) { global $lang; @@ -1334,7 +1413,13 @@ function html_diff_navigation($pagelog, $type, $l_rev, $r_rev) { // last timestamp is not in changelog, retrieve timestamp from metadata // note: when page is removed, the metadata timestamp is zero - $r_rev = $r_rev ? $r_rev : $INFO['meta']['last_change']['date']; + if(!$r_rev) { + if(isset($INFO['meta']['last_change']['date'])) { + $r_rev = $INFO['meta']['last_change']['date']; + } else { + $r_rev = 0; + } + } //retrieve revisions with additional info list($l_revs, $r_revs) = $pagelog->getRevisionsAround($l_rev, $r_rev); @@ -1482,7 +1567,7 @@ function html_diff_navigationlink($difftype, $linktype, $lrev, $rrev = null) { /** * Insert soft breaks in diff html * - * @param $diffhtml + * @param string $diffhtml * @return string */ function html_insert_softbreaks($diffhtml) { @@ -1521,6 +1606,9 @@ REGEX; * show warning on conflict detection * * @author Andreas Gohr <andi@splitbrain.org> + * + * @param string $text + * @param string $summary */ function html_conflict($text,$summary){ global $ID; @@ -1681,7 +1769,6 @@ function html_edit(){ global $lang; global $conf; global $TEXT; - global $RANGE; if ($INPUT->has('changecheck')) { $check = $INPUT->str('changecheck'); @@ -1783,6 +1870,7 @@ function html_edit(){ * Display the default edit form * * Is the default action for HTML_EDIT_FORMSELECTION. + * * @param mixed[] $param */ function html_edit_form($param) { @@ -1802,6 +1890,8 @@ function html_edit_form($param) { * Adds a checkbox for minor edits for logged in users * * @author Andreas Gohr <andi@splitbrain.org> + * + * @return array|bool */ function html_minoredit(){ global $conf; @@ -1902,6 +1992,7 @@ function html_debug(){ print '</pre>'; if (function_exists('apache_get_version')) { + $apache = array(); $apache['version'] = apache_get_version(); if (function_exists('apache_get_modules')) { @@ -1989,6 +2080,13 @@ function html_admin(){ $menu['config']['prompt'].'</a></div></li>'); } unset($menu['config']); + + if($menu['styling']){ + ptln(' <li class="admin_styling"><div class="li">'. + '<a href="'.wl($ID, array('do' => 'admin','page' => 'styling')).'">'. + $menu['styling']['prompt'].'</a></div></li>'); + } + unset($menu['styling']); } ptln('</ul>'); @@ -2080,6 +2178,9 @@ function html_resendpwd() { * Return the TOC rendered to XHTML * * @author Andreas Gohr <andi@splitbrain.org> + * + * @param array $toc + * @return string html */ function html_TOC($toc){ if(!count($toc)) return ''; @@ -2098,6 +2199,9 @@ function html_TOC($toc){ /** * Callback for html_buildlist + * + * @param array $item + * @return string html */ function html_list_toc($item){ if(isset($item['hid'])){ @@ -2132,6 +2236,7 @@ function html_mktocitem($link, $text, $level, $hash='#'){ * Triggers an event with the form name: HTML_{$name}FORM_OUTPUT * * @author Tom N Harris <tnharris@whoopdedo.org> + * * @param string $name The name of the form * @param Doku_Form $form The form */ @@ -2144,6 +2249,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) { |