xref: /dokuwiki/inc/html.php (revision bab2b7f0bb724f0e6e184a1d777e778955f3b904)
1ed7b5f09Sandi<?php
215fae107Sandi/**
315fae107Sandi * HTML output functions
415fae107Sandi *
515fae107Sandi * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
615fae107Sandi * @author     Andreas Gohr <andi@splitbrain.org>
715fae107Sandi */
815fae107Sandi
90c3a5702SAndreas Gohruse dokuwiki\ChangeLog\MediaChangeLog;
100c3a5702SAndreas Gohruse dokuwiki\ChangeLog\PageChangeLog;
11e1d9dcc8SAndreas Gohruse dokuwiki\Extension\AuthPlugin;
12cbb44eabSAndreas Gohruse dokuwiki\Extension\Event;
130c3a5702SAndreas Gohr
142d3b082eSMichael Großeif (!defined('SEC_EDIT_PATTERN')) {
1537c80e0eSLarsDW223    define('SEC_EDIT_PATTERN', '#<!-- EDIT({.*?}) -->#');
162d3b082eSMichael Große}
172d3b082eSMichael Große
186bbae538Sandi
19f3f0262cSandi/**
20f3f0262cSandi * Convenience function to quickly build a wikilink
2115fae107Sandi *
2215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
238d5e837eSMichael Hamann * @param string  $id      id of the target page
248d5e837eSMichael Hamann * @param string  $name    the name of the link, i.e. the text that is displayed
258d5e837eSMichael Hamann * @param string|array  $search  search string(s) that shall be highlighted in the target page
268d5e837eSMichael Hamann * @return string the HTML code of the link
27f3f0262cSandi */
28db959ae3SAndreas Gohrfunction html_wikilink($id,$name=null,$search=''){
29a8397511SGerrit Uitslag    /** @var Doku_Renderer_xhtml $xhtml_renderer */
30db959ae3SAndreas Gohr    static $xhtml_renderer = null;
31723d78dbSandi    if(is_null($xhtml_renderer)){
327aea91afSChris Smith        $xhtml_renderer = p_get_renderer('xhtml');
33f3f0262cSandi    }
34f3f0262cSandi
35fe9ec250SChris Smith    return $xhtml_renderer->internallink($id,$name,$search,true,'navigation');
36f3f0262cSandi}
37f3f0262cSandi
38f3f0262cSandi/**
39f3f0262cSandi * The loginform
4015fae107Sandi *
4115fae107Sandi * @author   Andreas Gohr <andi@splitbrain.org>
42d1d904bbSMichael Große *
43d1d904bbSMichael Große * @param bool $svg Whether to show svg icons in the register and resendpwd links or not
44*bab2b7f0SSatoshi Sahara * @deprecated 2020-07-18
45f3f0262cSandi */
46d1d904bbSMichael Großefunction html_login($svg = false) {
47*bab2b7f0SSatoshi Sahara    (new dokuwiki\Ui\Login($svg))->show();
48f3f0262cSandi}
49f3f0262cSandi
50d59dea9fSGerrit Uitslag
51d59dea9fSGerrit Uitslag/**
52d59dea9fSGerrit Uitslag * Denied page content
53d59dea9fSGerrit Uitslag *
54d59dea9fSGerrit Uitslag * @return string html
55d59dea9fSGerrit Uitslag */
56d59dea9fSGerrit Uitslagfunction html_denied() {
57d1e9181eSGerrit Uitslag    print p_locale_xhtml('denied');
58f019ab46SGerrit Uitslag
590db7a50dSThammi    if(empty($_SERVER['REMOTE_USER']) && actionOK('login')){
60f019ab46SGerrit Uitslag        html_login();
61f019ab46SGerrit Uitslag    }
62d59dea9fSGerrit Uitslag}
63d59dea9fSGerrit Uitslag
64f3f0262cSandi/**
6515fae107Sandi * inserts section edit buttons if wanted or removes the markers
6615fae107Sandi *
6715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
6842ea7f44SGerrit Uitslag *
6942ea7f44SGerrit Uitslag * @param string $text
7042ea7f44SGerrit Uitslag * @param bool   $show show section edit buttons?
7142ea7f44SGerrit Uitslag * @return string
7215fae107Sandi */
73f3f0262cSandifunction html_secedit($text,$show=true){
74f3f0262cSandi    global $INFO;
7535dae8b0SBen Coburn
76aac83cd4SPhy    if((isset($INFO) && !$INFO['writable']) || !$show || (isset($INFO) && $INFO['rev'])){
772d3b082eSMichael Große        return preg_replace(SEC_EDIT_PATTERN,'',$text);
78f3f0262cSandi    }
7935dae8b0SBen Coburn
802d3b082eSMichael Große    return preg_replace_callback(SEC_EDIT_PATTERN,
8140868f2fSAdrian Lang                'html_secedit_button', $text);
8240868f2fSAdrian Lang}
8340868f2fSAdrian Lang
8440868f2fSAdrian Lang/**
8540868f2fSAdrian Lang * prepares section edit button data for event triggering
8640868f2fSAdrian Lang * used as a callback in html_secedit
8740868f2fSAdrian Lang *
8840868f2fSAdrian Lang * @author Andreas Gohr <andi@splitbrain.org>
8942ea7f44SGerrit Uitslag *
9042ea7f44SGerrit Uitslag * @param array $matches matches with regexp
9142ea7f44SGerrit Uitslag * @return string
9242ea7f44SGerrit Uitslag * @triggers HTML_SECEDIT_BUTTON
9340868f2fSAdrian Lang */
9440868f2fSAdrian Langfunction html_secedit_button($matches){
95ada0d779SMichael Hamann    $json = htmlspecialchars_decode($matches[1], ENT_QUOTES);
96ada0d779SMichael Hamann    $data = json_decode($json, true);
97ec57f119SLarsDW223    if ($data == NULL) {
98ec57f119SLarsDW223        return;
9906917fceSMichael Große    }
100ec57f119SLarsDW223    $data ['target'] = strtolower($data['target']);
101ec57f119SLarsDW223    $data ['hid'] = strtolower($data['hid']);
10240868f2fSAdrian Lang
103cbb44eabSAndreas Gohr    return Event::createAndTrigger('HTML_SECEDIT_BUTTON', $data,
10440868f2fSAdrian Lang                         'html_secedit_get_button');
10540868f2fSAdrian Lang}
10640868f2fSAdrian Lang
10740868f2fSAdrian Lang/**
10840868f2fSAdrian Lang * prints a section editing button
10940868f2fSAdrian Lang * used as default action form HTML_SECEDIT_BUTTON
11040868f2fSAdrian Lang *
11140868f2fSAdrian Lang * @author Adrian Lang <lang@cosmocode.de>
11242ea7f44SGerrit Uitslag *
11342ea7f44SGerrit Uitslag * @param array $data name, section id and target
11442ea7f44SGerrit Uitslag * @return string html
11540868f2fSAdrian Lang */
11640868f2fSAdrian Langfunction html_secedit_get_button($data) {
11740868f2fSAdrian Lang    global $ID;
11840868f2fSAdrian Lang    global $INFO;
11940868f2fSAdrian Lang
1206d9eab4dSMichael Hamann    if (!isset($data['name']) || $data['name'] === '') return '';
12140868f2fSAdrian Lang
12240868f2fSAdrian Lang    $name = $data['name'];
12340868f2fSAdrian Lang    unset($data['name']);
12440868f2fSAdrian Lang
125905fa971SAdrian Lang    $secid = $data['secid'];
126905fa971SAdrian Lang    unset($data['secid']);
127905fa971SAdrian Lang
12840868f2fSAdrian Lang    return "<div class='secedit editbutton_" . $data['target'] .
129defa93a1SAdrian Lang                       " editbutton_" . $secid . "'>" .
13040868f2fSAdrian Lang           html_btn('secedit', $ID, '',
13140868f2fSAdrian Lang                    array_merge(array('do'  => 'edit',
132b150cd2cSGina Haeussge                                      'rev' => $INFO['lastmod'],
133b150cd2cSGina Haeussge                                      'summary' => '['.$name.'] '), $data),
13440868f2fSAdrian Lang                    'post', $name) . '</div>';
135f3f0262cSandi}
136f3f0262cSandi
137f3f0262cSandi/**
138d6c9c552Smatthiasgrimm * Just the back to top button (in its own form)
1396b13307fSandi *
1406b13307fSandi * @author Andreas Gohr <andi@splitbrain.org>
14142ea7f44SGerrit Uitslag *
14242ea7f44SGerrit Uitslag * @return string html
1436b13307fSandi */
1446b13307fSandifunction html_topbtn(){
1456b13307fSandi    global $lang;
1466b13307fSandi
14764159a61SAndreas Gohr    $ret = '<a class="nolink" href="#dokuwiki__top">' .
14864159a61SAndreas Gohr        '<button class="button" onclick="window.scrollTo(0, 0)" title="' . $lang['btn_top'] . '">' .
14964159a61SAndreas Gohr        $lang['btn_top'] .
15064159a61SAndreas Gohr        '</button></a>';
151df7b6005Sandi
1526b13307fSandi    return $ret;
1536b13307fSandi}
1546b13307fSandi
1556b13307fSandi/**
156d67ca2c0Smatthiasgrimm * Displays a button (using its own form)
15735dae8b0SBen Coburn * If tooltip exists, the access key tooltip is replaced.
15815fae107Sandi *
15915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
16042ea7f44SGerrit Uitslag *
16142ea7f44SGerrit Uitslag * @param string         $name
16242ea7f44SGerrit Uitslag * @param string         $id
16342ea7f44SGerrit Uitslag * @param string         $akey   access key
164e3710957SGerrit Uitslag * @param string[] $params key-value pairs added as hidden inputs
16542ea7f44SGerrit Uitslag * @param string         $method
16642ea7f44SGerrit Uitslag * @param string         $tooltip
16742ea7f44SGerrit Uitslag * @param bool|string    $label  label text, false: lookup btn_$name in localization
168e824d633SMichael Große * @param string         $svg (optional) svg code, inserted into the button
16942ea7f44SGerrit Uitslag * @return string
170f3f0262cSandi */
171e824d633SMichael Großefunction html_btn($name, $id, $akey, $params, $method='get', $tooltip='', $label=false, $svg=null){
172f3f0262cSandi    global $conf;
173f3f0262cSandi    global $lang;
174f3f0262cSandi
175f5baf821SAnika Henke    if (!$label)
176f3f0262cSandi        $label = $lang['btn_'.$name];
177f3f0262cSandi
178f3f0262cSandi    $ret = '';
179f3f0262cSandi
18049c713a3Sandi    //filter id (without urlencoding)
18149c713a3Sandi    $id = idfilter($id,false);
182f3f0262cSandi
183f3f0262cSandi    //make nice URLs even for buttons
1846c7843b5Sandi    if($conf['userewrite'] == 2){
1856c7843b5Sandi        $script = DOKU_BASE.DOKU_SCRIPT.'/'.$id;
1866c7843b5Sandi    }elseif($conf['userewrite']){
1876c7843b5Sandi        $script = DOKU_BASE.$id;
1886c7843b5Sandi    }else{
1898b00ebcfSandi        $script = DOKU_BASE.DOKU_SCRIPT;
190f3f0262cSandi        $params['id'] = $id;
191f3f0262cSandi    }
192f3f0262cSandi
193b278f2deSAndreas Gohr    $ret .= '<form class="button btn_'.$name.'" method="'.$method.'" action="'.$script.'"><div class="no">';
194f3f0262cSandi
19506a4bf8fSAndreas Gohr    if(is_array($params)){
1969e491c01SAndreas Gohr        foreach($params as $key => $val) {
197f3f0262cSandi            $ret .= '<input type="hidden" name="'.$key.'" ';
19865cc1598SPhy            $ret .= 'value="'.hsc($val).'" />';
199f3f0262cSandi        }
20006a4bf8fSAndreas Gohr    }
201f3f0262cSandi
20235dae8b0SBen Coburn    if ($tooltip!='') {
20365cc1598SPhy        $tip = hsc($tooltip);
20411ea018fSAndreas Gohr    }else{
20565cc1598SPhy        $tip = hsc($label);
20611ea018fSAndreas Gohr    }
20711ea018fSAndreas Gohr
208ae614416SAnika Henke    $ret .= '<button type="submit" ';
20911ea018fSAndreas Gohr    if($akey){
21007493d05SAnika Henke        $tip .= ' ['.strtoupper($akey).']';
21187cb01b7SAnika Henke        $ret .= 'accesskey="'.$akey.'" ';
21235dae8b0SBen Coburn    }
2139c65e2a9SAndreas Gohr    $ret .= 'title="'.$tip.'">';
214e824d633SMichael Große    if ($svg) {
215679dba01SMichael Große        $ret .= '<span>' . hsc($label) . '</span>';
216e824d633SMichael Große        $ret .= inlineSVG($svg);
217679dba01SMichael Große    } else {
218ae614416SAnika Henke        $ret .= hsc($label);
219679dba01SMichael Große    }
220ae614416SAnika Henke    $ret .= '</button>';
2214beabca9SAnika Henke    $ret .= '</div></form>';
222f3f0262cSandi
223f3f0262cSandi    return $ret;
224f3f0262cSandi}
2250747f5d7Sghi/**
2260747f5d7Sghi * show a revision warning
2270747f5d7Sghi *
2280747f5d7Sghi * @author Szymon Olewniczak <dokuwiki@imz.re>
2290747f5d7Sghi */
230c8556525Sghifunction html_showrev() {
231c8556525Sghi    print p_locale_xhtml('showrev');
2320747f5d7Sghi}
233f3f0262cSandi
234f3f0262cSandi/**
23542ea7f44SGerrit Uitslag * Show a wiki page
23615fae107Sandi *
23715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
23842ea7f44SGerrit Uitslag *
23942ea7f44SGerrit Uitslag * @param null|string $txt wiki text or null for showing $ID
240*bab2b7f0SSatoshi Sahara * @deprecated 2020-07-18
24115fae107Sandi */
24211c78c94SAndreas Gohrfunction html_show($txt=null) {
243*bab2b7f0SSatoshi Sahara    (new dokuwiki\Ui\PageView($txt))->show();
244f3f0262cSandi}
245f3f0262cSandi
246f3f0262cSandi/**
247ee4c4a1bSAndreas Gohr * ask the user about how to handle an exisiting draft
248ee4c4a1bSAndreas Gohr *
249ee4c4a1bSAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org>
250*bab2b7f0SSatoshi Sahara * @deprecated 2020-07-18
251ee4c4a1bSAndreas Gohr */
252ee4c4a1bSAndreas Gohrfunction html_draft() {
253*bab2b7f0SSatoshi Sahara    (new dokuwiki\Ui\Draft)->show();
254ee4c4a1bSAndreas Gohr}
255ee4c4a1bSAndreas Gohr
256ee4c4a1bSAndreas Gohr/**
257f3f0262cSandi * Highlights searchqueries in HTML code
25815fae107Sandi *
25915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
2607209be23SAndreas Gohr * @author Harry Fuecks <hfuecks@gmail.com>
26142ea7f44SGerrit Uitslag *
26242ea7f44SGerrit Uitslag * @param string $html
26342ea7f44SGerrit Uitslag * @param array|string $phrases
26442ea7f44SGerrit Uitslag * @return string html
265f3f0262cSandi */
266546d3a99SAndreas Gohrfunction html_hilight($html,$phrases){
2678a803caeSAndreas Gohr    $phrases = (array) $phrases;
2688a803caeSAndreas Gohr    $phrases = array_map('preg_quote_cb', $phrases);
2698a803caeSAndreas Gohr    $phrases = array_map('ft_snippet_re_preprocess', $phrases);
2708a803caeSAndreas Gohr    $phrases = array_filter($phrases);
2718a803caeSAndreas Gohr    $regex = join('|',$phrases);
27260c15d7dSAndreas Gohr
27360c15d7dSAndreas Gohr    if ($regex === '') return $html;
2748cbc5ee8SAndreas Gohr    if (!\dokuwiki\Utf8\Clean::isUtf8($regex)) return $html;
27524a6c235SAndreas Gohr    $html = @preg_replace_callback("/((<[^>]*)|$regex)/ui",'html_hilight_callback',$html);
276f3f0262cSandi    return $html;
277f3f0262cSandi}
278f3f0262cSandi
279f3f0262cSandi/**
2807209be23SAndreas Gohr * Callback used by html_hilight()
2817209be23SAndreas Gohr *
2827209be23SAndreas Gohr * @author Harry Fuecks <hfuecks@gmail.com>
28342ea7f44SGerrit Uitslag *
28442ea7f44SGerrit Uitslag * @param array $m matches
28542ea7f44SGerrit Uitslag * @return string html
2867209be23SAndreas Gohr */
287*bab2b7f0SSatoshi Saharafunction html_hilight_callback($m) { // FIXME should be closure in html_highlight()?
2887209be23SAndreas Gohr    $hlight = unslash($m[0]);
2897209be23SAndreas Gohr    if ( !isset($m[2])) {
290688774a0SAnika Henke        $hlight = '<span class="search_hit">'.$hlight.'</span>';
2917209be23SAndreas Gohr    }
2927209be23SAndreas Gohr    return $hlight;
2937209be23SAndreas Gohr}
2947209be23SAndreas Gohr
2957209be23SAndreas Gohr/**
29615fae107Sandi * Display error on locked pages
29715fae107Sandi *
29815fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
29915fae107Sandi */
300ee20e7d1Sandifunction html_locked(){
301f3f0262cSandi    global $ID;
302f3f0262cSandi    global $conf;
303f3f0262cSandi    global $lang;
30488f522e9Sandi    global $INFO;
305f3f0262cSandi
306c9b4bd1eSBen Coburn    $locktime = filemtime(wikiLockFN($ID));
307f2263577SAndreas Gohr    $expire = dformat($locktime + $conf['locktime']);
308f3f0262cSandi    $min    = round(($conf['locktime'] - (time() - $locktime) )/60);
309f3f0262cSandi
310c112d578Sandi    print p_locale_xhtml('locked');
311f3f0262cSandi    print '<ul>';
312fde860beSGerrit Uitslag    print '<li><div class="li"><strong>'.$lang['lockedby'].'</strong> '.editorinfo($INFO['locked']).'</div></li>';
313fde860beSGerrit Uitslag    print '<li><div class="li"><strong>'.$lang['lockexpire'].'</strong> '.$expire.' ('.$min.' min)</div></li>';
314f3f0262cSandi    print '</ul>';
315f3f0262cSandi}
316f3f0262cSandi
31715fae107Sandi/**
31815fae107Sandi * list old revisions
31915fae107Sandi *
32015fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
32171726d78SBen Coburn * @author Ben Coburn <btcoburn@silicodon.net>
3228e69fd30SKate Arzamastseva * @author Kate Arzamastseva <pshns@ukr.net>
323e0c26282SGerrit Uitslag *
324e0c26282SGerrit Uitslag * @param int $first skip the first n changelog lines
325e0c26282SGerrit Uitslag * @param bool|string $media_id id of media, or false for current page
326*bab2b7f0SSatoshi Sahara * @deprecated 2020-07-18
32715fae107Sandi */
3288e69fd30SKate Arzamastsevafunction html_revisions($first=0, $media_id = false) {
329*bab2b7f0SSatoshi Sahara    (new dokuwiki\Ui\Revisions($first, $media_id))->show();
330f3f0262cSandi}
331f3f0262cSandi
33215fae107Sandi/**
33315fae107Sandi * display recent changes
33415fae107Sandi *
33515fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
3365749f1ceSmatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
33771726d78SBen Coburn * @author Ben Coburn <btcoburn@silicodon.net>
3388d40b4b6SKate Arzamastseva * @author Kate Arzamastseva <pshns@ukr.net>
33942ea7f44SGerrit Uitslag *
34042ea7f44SGerrit Uitslag * @param int $first
34142ea7f44SGerrit Uitslag * @param string $show_changes
342*bab2b7f0SSatoshi Sahara * @deprecated 2020-07-18
34315fae107Sandi */
3440739a638SKate Arzamastsevafunction html_recent($first = 0, $show_changes = 'both') {
345*bab2b7f0SSatoshi Sahara    (new dokuwiki\Ui\Recent($first, $show_changes))->show();
346f3f0262cSandi}
347f3f0262cSandi
34815fae107Sandi/**
34915fae107Sandi * Display page index
35015fae107Sandi *
35115fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
35242ea7f44SGerrit Uitslag *
35342ea7f44SGerrit Uitslag * @param string $ns
354*bab2b7f0SSatoshi Sahara * @deprecated 2020-07-18
35515fae107Sandi */
356f3f0262cSandifunction html_index($ns) {
357*bab2b7f0SSatoshi Sahara    (new dokuwiki\Ui\Index($ns))->show();
358f3f0262cSandi}
359f3f0262cSandi
360f3f0262cSandi/**
36115fae107Sandi * Index item formatter
36215fae107Sandi *
363f3f0262cSandi * User function for html_buildlist()
36415fae107Sandi *
36515fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
36642ea7f44SGerrit Uitslag *
36742ea7f44SGerrit Uitslag * @param array $item
36842ea7f44SGerrit Uitslag * @return string
369f3f0262cSandi */
370*bab2b7f0SSatoshi Saharafunction html_list_index($item) { // FIXME: also called from inc/Ajax.php
37174ef1778SChristopher Smith    global $ID, $conf;
37274ef1778SChristopher Smith
373b8bc53ceSChristopher Smith    // prevent searchbots needlessly following links
37474ef1778SChristopher Smith    $nofollow = ($ID != $conf['start'] || $conf['sitemap']) ? 'rel="nofollow"' : '';
37574ef1778SChristopher Smith
376f3f0262cSandi    $ret = '';
377f3f0262cSandi    $base = ':'.$item['id'];
378f3f0262cSandi    $base = substr($base,strrpos($base,':')+1);
379f3f0262cSandi    if($item['type']=='d'){
380b1af9014SChristopher Smith        // FS#2766, no need for search bots to follow namespace links in the index
38164159a61SAndreas Gohr        $link = wl($ID, 'idx=' . rawurlencode($item['id']));
38264159a61SAndreas Gohr        $ret .= '<a href="' . $link . '" title="' . $item['id'] . '" class="idx_dir" ' . $nofollow . '><strong>';
383f3f0262cSandi        $ret .= $base;
384ed7ecb79SAnika Henke        $ret .= '</strong></a>';
385f3f0262cSandi    }else{
3869aa38483SMichael Hamann        // default is noNSorNS($id), but we want noNS($id) when useheading is off FS#2605
3879aa38483SMichael Hamann        $ret .= html_wikilink(':'.$item['id'], useHeading('navigation') ? null : noNS($item['id']));
388f3f0262cSandi    }
389f3f0262cSandi    return $ret;
390f3f0262cSandi}
391f3f0262cSandi
392f3f0262cSandi/**
393cb70c441Sandi * Index List item
394cb70c441Sandi *
395a1dee2b9SAdrian Lang * This user function is used in html_buildlist to build the
396cb70c441Sandi * <li> tags for namespaces when displaying the page index
397cb70c441Sandi * it gives different classes to opened or closed "folders"
398cb70c441Sandi *
399cb70c441Sandi * @author Andreas Gohr <andi@splitbrain.org>
40042ea7f44SGerrit Uitslag *
40142ea7f44SGerrit Uitslag * @param array $item
40242ea7f44SGerrit Uitslag * @return string html
403cb70c441Sandi */
404*bab2b7f0SSatoshi Saharafunction html_li_index($item) { // FIXME: also called from inc/Ajax.php
405f7dbf175SAndreas Gohr    global $INFO;
40621b07cb4SAndreas Gohr    global $ACT;
407f7dbf175SAndreas Gohr
4086fa4721aSAndreas Gohr    $class = '';
4096fa4721aSAndreas Gohr    $id = '';
4106fa4721aSAndreas Gohr
411cb70c441Sandi    if($item['type'] == "f"){
412f7dbf175SAndreas Gohr        // scroll to the current item
413aac83cd4SPhy        if(isset($INFO) && $item['id'] == $INFO['id'] && $ACT == 'index') {
414f7dbf175SAndreas Gohr            $id = ' id="scroll__here"';
415772f3c51SDeathCamel57            $class = ' bounce';
416f7dbf175SAndreas Gohr        }
4176fa4721aSAndreas Gohr        return '<li class="level'.$item['level'].$class.'" '.$id.'>';
418cb70c441Sandi    }elseif($item['open']){
419cb70c441Sandi        return '<li class="open">';
420cb70c441Sandi    }else{
421cb70c441Sandi        return '<li class="closed">';
422cb70c441Sandi    }
423cb70c441Sandi}
424cb70c441Sandi
425cb70c441Sandi/**
426cb70c441Sandi * Default List item
427cb70c441Sandi *
428cb70c441Sandi * @author Andreas Gohr <andi@splitbrain.org>
42942ea7f44SGerrit Uitslag *
43042ea7f44SGerrit Uitslag * @param array $item
43142ea7f44SGerrit Uitslag * @return string html
432cb70c441Sandi */
433*bab2b7f0SSatoshi Saharafunction html_li_default($item) { // FIXME: should be closure in html_buildlist()?
434cb70c441Sandi    return '<li class="level'.$item['level'].'">';
435cb70c441Sandi}
436cb70c441Sandi
437cb70c441Sandi/**
43815fae107Sandi * Build an unordered list
43915fae107Sandi *
440f3f0262cSandi * Build an unordered list from the given $data array
441f3f0262cSandi * Each item in the array has to have a 'level' property
442f3f0262cSandi * the item itself gets printed by the given $func user
443cb70c441Sandi * function. The second and optional function is used to
444cb70c441Sandi * print the <li> tag. Both user function need to accept
445cb70c441Sandi * a single item.
44615fae107Sandi *
447c5a8fd96SAndreas Gohr * Both user functions can be given as array to point to
448c5a8fd96SAndreas Gohr * a member of an object.
449c5a8fd96SAndreas Gohr *
45015fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
45180679bafSGerrit Uitslag *
45280679bafSGerrit Uitslag * @param array    $data  array with item arrays
45380679bafSGerrit Uitslag * @param string   $class class of ul wrapper
45480679bafSGerrit Uitslag * @param callable $func  callback to print an list item
4555a9597bbSTakamura * @param callable $lifunc callback to the opening li tag
45680679bafSGerrit Uitslag * @param bool     $forcewrapper Trigger building a wrapper ul if the first level is
457ae614416SAnika Henke *                               0 (we have a root object) or 1 (just the root content)
45880679bafSGerrit Uitslag * @return string html of an unordered list
459f3f0262cSandi */
46087671313SHakan Sandellfunction html_buildlist($data,$class,$func,$lifunc='html_li_default',$forcewrapper=false){
461a1dee2b9SAdrian Lang    if (count($data) === 0) {
462a1dee2b9SAdrian Lang        return '';
463a1dee2b9SAdrian Lang    }
464a1dee2b9SAdrian Lang
4652689c55fSMichael Große    $firstElement = reset($data);
4662689c55fSMichael Große    $start_level = $firstElement['level'];
4679e4f7880SAdrian Lang    $level = $start_level;
468434f5921SHakan Sandell    $ret   = '';
469434f5921SHakan Sandell    $open  = 0;
4709e4f7880SAdrian Lang
471f3f0262cSandi    foreach ($data as $item){
472f3f0262cSandi
473f3f0262cSandi        if( $item['level'] > $level ){
474f3f0262cSandi            //open new list
475df52d0feSandi            for($i=0; $i<($item['level'] - $level); $i++){
476434f5921SHakan Sandell                if ($i) $ret .= "<li class=\"clear\">";
477f3f0262cSandi                $ret .= "\n<ul class=\"$class\">\n";
478434f5921SHakan Sandell                $open++;
479df52d0feSandi            }
480434f5921SHakan Sandell            $level = $item['level'];
481434f5921SHakan Sandell
482f3f0262cSandi        }elseif( $item['level'] < $level ){
483f3f0262cSandi            //close last item
484f3f0262cSandi            $ret .= "</li>\n";
485434f5921SHakan Sandell            while( $level > $item['level'] && $open > 0 ){
486f3f0262cSandi                //close higher lists
487f3f0262cSandi                $ret .= "</ul>\n</li>\n";
488434f5921SHakan Sandell                $level--;
489434f5921SHakan Sandell                $open--;
490f3f0262cSandi            }
491a1dee2b9SAdrian Lang        } elseif ($ret !== '') {
49287671313SHakan Sandell            //close previous item
493f3f0262cSandi            $ret .= "</li>\n";
494f3f0262cSandi        }
495f3f0262cSandi
496f3f0262cSandi        //print item
49734dbe711Schris        $ret .= call_user_func($lifunc,$item);
4980c6b58a8SAndreas Gohr        $ret .= '<div class="li">';
49934dbe711Schris
50034dbe711Schris        $ret .= call_user_func($func,$item);
5010c6b58a8SAndreas Gohr        $ret .= '</div>';
502f3f0262cSandi    }
503f3f0262cSandi
504f3f0262cSandi    //close remaining items and lists
505434f5921SHakan Sandell    $ret .= "</li>\n";
506434f5921SHakan Sandell    while($open-- > 0) {
507434f5921SHakan Sandell        $ret .= "</ul></li>\n";
508434f5921SHakan Sandell    }
509434f5921SHakan Sandell
510434f5921SHakan Sandell    if ($forcewrapper || $start_level < 2) {
511434f5921SHakan Sandell        // Trigger building a wrapper ul if the first level is
512434f5921SHakan Sandell        // 0 (we have a root object) or 1 (just the root content)
513434f5921SHakan Sandell        $ret = "\n<ul class=\"$class\">\n".$ret."</ul>\n";
514f3f0262cSandi    }
515f3f0262cSandi
516f3f0262cSandi    return $ret;
517f3f0262cSandi}
518f3f0262cSandi
51915fae107Sandi/**
52015fae107Sandi * display backlinks
52115fae107Sandi *
52215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
52311df47ecSMichael Klier * @author Michael Klier <chi@chimeric.de>
524*bab2b7f0SSatoshi Sahara * @deprecated 2020-07-18
52515fae107Sandi */
526f3f0262cSandifunction html_backlinks() {
527*bab2b7f0SSatoshi Sahara    (new dokuwiki\Ui\Backlinks)->show();
52895b451bcSAdrian Lang}
52995b451bcSAdrian Lang
53015fae107Sandi/**
53104e99fe1SGerrit Uitslag * Show diff
532baf0c3e5SGerrit Uitslag * between current page version and provided $text
533baf0c3e5SGerrit Uitslag * or between the revisions provided via GET or POST
53415fae107Sandi *
53515fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
536baf0c3e5SGerrit Uitslag * @param  string $text  when non-empty: compare with this text with most current version
53704e99fe1SGerrit Uitslag * @param  bool   $intro display the intro text
5388d5e837eSMichael Hamann * @param  string $type  type of the diff (inline or sidebyside)
539*bab2b7f0SSatoshi Sahara * @deprecated 2020-07-18
54015fae107Sandi */
54172165381SAndreas Gohrfunction html_diff($text = '', $intro = true, $type = null) {
542*bab2b7f0SSatoshi Sahara    (new dokuwiki\Ui\Diff($text, $intro, $type))->show();
543fcfecb69SChristopher Smith}
544fcfecb69SChristopher Smith
54515fae107Sandi/**
54615fae107Sandi * show warning on conflict detection
54715fae107Sandi *
54815fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
54942ea7f44SGerrit Uitslag *
55042ea7f44SGerrit Uitslag * @param string $text
55142ea7f44SGerrit Uitslag * @param string $summary
552*bab2b7f0SSatoshi Sahara * @deprecated 2020-07-18
55315fae107Sandi */
554f3f0262cSandifunction html_conflict($text, $summary) {
555*bab2b7f0SSatoshi Sahara    (new dokuwiki\Ui\Conflict($text, $summary))->show();
556f3f0262cSandi}
557f3f0262cSandi
558f3f0262cSandi/**
55915fae107Sandi * Prints the global message array
56015fae107Sandi *
56115fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
562f3f0262cSandi */
563f3f0262cSandifunction html_msgarea(){
564cc58224cSMichael Hamann    global $MSG, $MSG_shown;
5658d5e837eSMichael Hamann    /** @var array $MSG */
566cc58224cSMichael Hamann    // store if the global $MSG has already been shown and thus HTML output has been started
567cc58224cSMichael Hamann    $MSG_shown = true;
568cc58224cSMichael Hamann
569f3f0262cSandi    if(!isset($MSG)) return;
570f3f0262cSandi
5714af9f0d4SAndreas Gohr    $shown = array();
572f3f0262cSandi    foreach($MSG as $msg){
5734af9f0d4SAndreas Gohr        $hash = md5($msg['msg']);
5744af9f0d4SAndreas Gohr        if(isset($shown[$hash])) continue; // skip double messages
575f755f9abSChristopher Smith        if(info_msg_allowed($msg)){
576f3f0262cSandi            print '<div class="'.$msg['lvl'].'">';
577f3f0262cSandi            print $msg['msg'];
578f3f0262cSandi            print '</div>';
579d3bae478SChristopher Smith        }
5804af9f0d4SAndreas Gohr        $shown[$hash] = 1;
581f3f0262cSandi    }
582cc58224cSMichael Hamann
583cc58224cSMichael Hamann    unset($GLOBALS['MSG']);
584f3f0262cSandi}
585f3f0262cSandi
586f3f0262cSandi/**
587f3f0262cSandi * Prints the registration form
58815fae107Sandi *
58915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
590*bab2b7f0SSatoshi Sahara * @deprecated 2020-07-18
591f3f0262cSandi */
592f3f0262cSandifunction html_register() {
593*bab2b7f0SSatoshi Sahara    (new dokuwiki\Ui\UserRegister)->show();
594f3f0262cSandi}
595f3f0262cSandi
596f3f0262cSandi/**
5978b06d178Schris * Print the update profile form
5988b06d178Schris *
5998b06d178Schris * @author Christopher Smith <chris@jalakai.co.uk>
6008b06d178Schris * @author Andreas Gohr <andi@splitbrain.org>
601*bab2b7f0SSatoshi Sahara * @deprecated 2020-07-18
6028b06d178Schris */
6038b06d178Schrisfunction html_updateprofile() {
604*bab2b7f0SSatoshi Sahara    (new dokuwiki\Ui\UserProfile)->show();
6058b06d178Schris}
6068b06d178Schris
6078b06d178Schris/**
6087c4635c4SAdrian Lang * Preprocess edit form data
60915fae107Sandi *
61015fae107Sandi * @author   Andreas Gohr <andi@splitbrain.org>
6112ffea8f2SAdrian Lang *
6122ffea8f2SAdrian Lang * @triggers HTML_EDITFORM_OUTPUT
613*bab2b7f0SSatoshi Sahara * @deprecated 2020-07-18
614f3f0262cSandi */
6155a932e77SAdrian Langfunction html_edit() {
616*bab2b7f0SSatoshi Sahara    (new dokuwiki\Ui\Editor)->show();
617b6912aeaSAndreas Gohr}
618b6912aeaSAndreas Gohr
619b6912aeaSAndreas Gohr/**
620f3f0262cSandi * prints some debug info
62115fae107Sandi *
62215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
623f3f0262cSandi */
624f3f0262cSandifunction html_debug(){
625f3f0262cSandi    global $conf;
626d16a4edaSandi    global $lang;
627e1d9dcc8SAndreas Gohr    /** @var AuthPlugin $auth */
6285298a619SAndreas Gohr    global $auth;
629100a97e3SAndreas Gohr    global $INFO;
630100a97e3SAndreas Gohr
63128fb55ffSandi    //remove sensitive data
63228fb55ffSandi    $cnf = $conf;
63324297a69SAndreas Gohr    debug_guard($cnf);
634100a97e3SAndreas Gohr    $nfo = $INFO;
63524297a69SAndreas Gohr    debug_guard($nfo);
636100a97e3SAndreas Gohr    $ses = $_SESSION;
63724297a69SAndreas Gohr    debug_guard($ses);
638f3f0262cSandi
639f3f0262cSandi    print '<html><body>';
640f3f0262cSandi
641f3f0262cSandi    print '<p>When reporting bugs please send all the following ';
642f3f0262cSandi    print 'output as a mail to andi@splitbrain.org ';
643f3f0262cSandi    print 'The best way to do this is to save this page in your browser</p>';
644f3f0262cSandi
645100a97e3SAndreas Gohr    print '<b>$INFO:</b><pre>';
646100a97e3SAndreas Gohr    print_r($nfo);
647100a97e3SAndreas Gohr    print '</pre>';
648100a97e3SAndreas Gohr
649f3f0262cSandi    print '<b>$_SERVER:</b><pre>';
650f3f0262cSandi    print_r($_SERVER);
651f3f0262cSandi    print '</pre>';
652f3f0262cSandi
653f3f0262cSandi    print '<b>$conf:</b><pre>';
65428fb55ffSandi    print_r($cnf);
655f3f0262cSandi    print '</pre>';
656f3f0262cSandi
657ed7b5f09Sandi    print '<b>DOKU_BASE:</b><pre>';
658ed7b5f09Sandi    print DOKU_BASE;
659f3f0262cSandi    print '</pre>';
660f3f0262cSandi
661ed7b5f09Sandi    print '<b>abs DOKU_BASE:</b><pre>';
662ed7b5f09Sandi    print DOKU_URL;
663ed7b5f09Sandi    print '</pre>';
664ed7b5f09Sandi
665ed7b5f09Sandi    print '<b>rel DOKU_BASE:</b><pre>';
666f3f0262cSandi    print dirname($_SERVER['PHP_SELF']).'/';
667f3f0262cSandi    print '</pre>';
668f3f0262cSandi
669f3f0262cSandi    print '<b>PHP Version:</b><pre>';
670f3f0262cSandi    print phpversion();
671f3f0262cSandi    print '</pre>';
672f3f0262cSandi
673f3f0262cSandi    print '<b>locale:</b><pre>';
674f3f0262cSandi    print setlocale(LC_ALL,0);
675f3f0262cSandi    print '</pre>';
676f3f0262cSandi
677d16a4edaSandi    print '<b>encoding:</b><pre>';
678d16a4edaSandi    print $lang['encoding'];
679d16a4edaSandi    print '</pre>';
680d16a4edaSandi
6815298a619SAndreas Gohr    if($auth){
6825298a619SAndreas Gohr        print '<b>Auth backend capabilities:</b><pre>';
6832f46ade0SChristopher Smith        foreach ($auth->getCapabilities() as $cando){
6842f46ade0SChristopher Smith            print '   '.str_pad($cando,16) . ' => ' . (int)$auth->canDo($cando) . NL;
6852f46ade0SChristopher Smith        }
6865298a619SAndreas Gohr        print '</pre>';
6875298a619SAndreas Gohr    }
6885298a619SAndreas Gohr
6893aa54d7cSAndreas Gohr    print '<b>$_SESSION:</b><pre>';
690100a97e3SAndreas Gohr    print_r($ses);
6913aa54d7cSAndreas Gohr    print '</pre>';
6923aa54d7cSAndreas Gohr
693f3f0262cSandi    print '<b>Environment:</b><pre>';
694f3f0262cSandi    print_r($_ENV);
695f3f0262cSandi    print '</pre>';
696f3f0262cSandi
697f3f0262cSandi    print '<b>PHP settings:</b><pre>';
698f3f0262cSandi    $inis = ini_get_all();
699f3f0262cSandi    print_r($inis);
700f3f0262cSandi    print '</pre>';
701f3f0262cSandi
702e89b7c1eSChristopher Smith    if (function_exists('apache_get_version')) {
70359bc3b48SGerrit Uitslag        $apache = array();
704e89b7c1eSChristopher Smith        $apache['version'] = apache_get_version();
705e89b7c1eSChristopher Smith
706e89b7c1eSChristopher Smith        if (function_exists('apache_get_modules')) {
707e89b7c1eSChristopher Smith            $apache['modules'] = apache_get_modules();
708e89b7c1eSChristopher Smith        }
709e89b7c1eSChristopher Smith        print '<b>Apache</b><pre>';
710e89b7c1eSChristopher Smith        print_r($apache);
711e89b7c1eSChristopher Smith        print '</pre>';
712e89b7c1eSChristopher Smith    }
713e89b7c1eSChristopher Smith
714f3f0262cSandi    print '</body></html>';
715f3f0262cSandi}
716f3f0262cSandi
71710271ce4SAndreas Gohr/**
7188b06d178Schris * Form to request a new password for an existing account
7198b06d178Schris *
7208b06d178Schris * @author Benoit Chesneau <benoit@bchesneau.info>
721cc204bbdSAndreas Gohr * @author Andreas Gohr <gohr@cosmocode.de>
722*bab2b7f0SSatoshi Sahara * @deprecated 2020-07-18
72311e2ce22Schris */
7248b06d178Schrisfunction html_resendpwd() {
725*bab2b7f0SSatoshi Sahara    (new dokuwiki\Ui\UserResendPwd)->show();
726cc204bbdSAndreas Gohr}
727cc204bbdSAndreas Gohr
728fdb8d77bSTom N Harris/**
729b8595a66SAndreas Gohr * Return the TOC rendered to XHTML
730b8595a66SAndreas Gohr *
731b8595a66SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org>
73242ea7f44SGerrit Uitslag *
73342ea7f44SGerrit Uitslag * @param array $toc
73442ea7f44SGerrit Uitslag * @return string html
735b8595a66SAndreas Gohr */
736b8595a66SAndreas Gohrfunction html_TOC($toc){
737b8595a66SAndreas Gohr    if(!count($toc)) return '';
738b8595a66SAndreas Gohr    global $lang;
739b8595a66SAndreas Gohr    $out  = '<!-- TOC START -->'.DOKU_LF;
740158a5bffSDeathCamel57    $out .= '<div id="dw__toc" class="dw__toc">'.DOKU_LF;
74148722ac8SAnika Henke    $out .= '<h3 class="toggle">';
742b8595a66SAndreas Gohr    $out .= $lang['toc'];
743d5acc30dSAnika Henke    $out .= '</h3>'.DOKU_LF;
744d5acc30dSAnika Henke    $out .= '<div>'.DOKU_LF;
74587671313SHakan Sandell    $out .= html_buildlist($toc,'toc','html_list_toc','html_li_default',true);
746b8595a66SAndreas Gohr    $out .= '</div>'.DOKU_LF.'</div>'.DOKU_LF;
747b8595a66SAndreas Gohr    $out .= '<!-- TOC END -->'.DOKU_LF;
748db959ae3SAndreas Gohr    return $out;
749db959ae3SAndreas Gohr}
750b8595a66SAndreas Gohr
751b8595a66SAndreas Gohr/**
752b8595a66SAndreas Gohr * Callback for html_buildlist
75342ea7f44SGerrit Uitslag *
75442ea7f44SGerrit Uitslag * @param array $item
75542ea7f44SGerrit Uitslag * @return string html
756b8595a66SAndreas Gohr */
757b8595a66SAndreas Gohrfunction html_list_toc($item){
758c66972f2SAdrian Lang    if(isset($item['hid'])){
7597d91652aSAndreas Gohr        $link = '#'.$item['hid'];
7607d91652aSAndreas Gohr    }else{
7617d91652aSAndreas Gohr        $link = $item['link'];
7627d91652aSAndreas Gohr    }
7637d91652aSAndreas Gohr
764d5acc30dSAnika Henke    return '<a href="'.$link.'">'.hsc($item['title']).'</a>';
765b8595a66SAndreas Gohr}
766b8595a66SAndreas Gohr
767b8595a66SAndreas Gohr/**
768b8595a66SAndreas Gohr * Helper function to build TOC items
769b8595a66SAndreas Gohr *
770b8595a66SAndreas Gohr * Returns an array ready to be added to a TOC array
771b8595a66SAndreas Gohr *
772b8595a66SAndreas Gohr * @param string $link  - where to link (if $hash set to '#' it's a local anchor)
773b8595a66SAndreas Gohr * @param string $text  - what to display in the TOC
774b8595a66SAndreas Gohr * @param int    $level - nesting level
775b8595a66SAndreas Gohr * @param string $hash  - is prepended to the given $link, set blank if you want full links
7768d5e837eSMichael Hamann * @return array the toc item
777b8595a66SAndreas Gohr */
778b8595a66SAndreas Gohrfunction html_mktocitem($link, $text, $level, $hash='#'){
779b8595a66SAndreas Gohr    return  array( 'link'  => $hash.$link,
780b8595a66SAndreas Gohr            'title' => $text,
781b8595a66SAndreas Gohr            'type'  => 'ul',
7822bb0d541Schris            'level' => $level);
783b8595a66SAndreas Gohr}
784b8595a66SAndreas Gohr
785b8595a66SAndreas Gohr/**
786fdb8d77bSTom N Harris * Output a Doku_Form object.
787fdb8d77bSTom N Harris * Triggers an event with the form name: HTML_{$name}FORM_OUTPUT
788fdb8d77bSTom N Harris *
789fdb8d77bSTom N Harris * @author Tom N Harris <tnharris@whoopdedo.org>
79042ea7f44SGerrit Uitslag *
7918d5e837eSMichael Hamann * @param string     $name The name of the form
7928d5e837eSMichael Hamann * @param Doku_Form  $form The form
793fdb8d77bSTom N Harris */
794c29600d0SSatoshi Saharafunction html_form($name, $form) {
795fdb8d77bSTom N Harris    // Safety check in case the caller forgets.
796fdb8d77bSTom N Harris    $form->endFieldset();
797cbb44eabSAndreas Gohr    Event::createAndTrigger('HTML_'.strtoupper($name).'FORM_OUTPUT', $form, 'html_form_output', false);
798fdb8d77bSTom N Harris}
799fdb8d77bSTom N Harris
800fdb8d77bSTom N Harris/**
801fdb8d77bSTom N Harris * Form print function.
802c29600d0SSatoshi Sahara * Just calls printForm() on the form object.
80342ea7f44SGerrit Uitslag *
804c29600d0SSatoshi Sahara * @param Doku_Form $form The form
805fdb8d77bSTom N Harris */
80625dd2a2fSSatoshi Saharafunction html_form_output($form) {
80725dd2a2fSSatoshi Sahara    $form->printForm();
80825dd2a2fSSatoshi Sahara}
809340756e4Sandi
81007bf32b2SAndreas Gohr/**
81107bf32b2SAndreas Gohr * Embed a flash object in HTML
81207bf32b2SAndreas Gohr *
81307bf32b2SAndreas Gohr * This will create the needed HTML to embed a flash movie in a cross browser
81407bf32b2SAndreas Gohr * compatble way using valid XHTML
81507bf32b2SAndreas Gohr *
81607bf32b2SAndreas Gohr * The parameters $params, $flashvars and $atts need to be associative arrays.
81707bf32b2SAndreas Gohr * No escaping needs to be done for them. The alternative content *has* to be
81807bf32b2SAndreas Gohr * escaped because it is used as is. If no alternative content is given
81907bf32b2SAndreas Gohr * $lang['noflash'] is used.
82007bf32b2SAndreas Gohr *
82107bf32b2SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org>
82207bf32b2SAndreas Gohr * @link   http://latrine.dgx.cz/how-to-correctly-insert-a-flash-into-xhtml
82307bf32b2SAndreas Gohr *
82407bf32b2SAndreas Gohr * @param string $swf      - the SWF movie to embed
82507bf32b2SAndreas Gohr * @param int $width       - width of the flash movie in pixels
82607bf32b2SAndreas Gohr * @param int $height      - height of the flash movie in pixels
82707bf32b2SAndreas Gohr * @param array $params    - additional parameters (<param>)
82807bf32b2SAndreas Gohr * @param array $flashvars - parameters to be passed in the flashvar parameter
82907bf32b2SAndreas Gohr * @param array $atts      - additional attributes for the <object> tag
83007bf32b2SAndreas Gohr * @param string $alt      - alternative content (is NOT automatically escaped!)
831b3d1090eSMichael Hamann * @return string         - the XHTML markup
83207bf32b2SAndreas Gohr */
83307bf32b2SAndreas Gohrfunction html_flashobject($swf,$width,$height,$params=null,$flashvars=null,$atts=null,$alt=''){
83407bf32b2SAndreas Gohr    global $lang;
83507bf32b2SAndreas Gohr
83607bf32b2SAndreas Gohr    $out = '';
83707bf32b2SAndreas Gohr
83807bf32b2SAndreas Gohr    // prepare the object attributes
83907bf32b2SAndreas Gohr    if(is_null($atts)) $atts = array();
84007bf32b2SAndreas Gohr    $atts['width']  = (int) $width;
841d4c61e61SAndreas Gohr    $atts['height'] = (int) $height;
84207bf32b2SAndreas Gohr    if(!$atts['width'])  $atts['width']  = 425;
84307bf32b2SAndreas Gohr    if(!$atts['height']) $atts['height'] = 350;
84407bf32b2SAndreas Gohr
84507bf32b2SAndreas Gohr    // add object attributes for standard compliant browsers
84607bf32b2SAndreas Gohr    $std = $atts;
84707bf32b2SAndreas Gohr    $std['type'] = 'application/x-shockwave-flash';
84807bf32b2SAndreas Gohr    $std['data'] = $swf;
84907bf32b2SAndreas Gohr
85007bf32b2SAndreas Gohr    // add object attributes for IE
85107bf32b2SAndreas Gohr    $ie  = $atts;
85207bf32b2SAndreas Gohr    $ie['classid'] = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';
85307bf32b2SAndreas Gohr
85407bf32b2SAndreas Gohr    // open object (with conditional comments)
85507bf32b2SAndreas Gohr    $out .= '<!--[if !IE]> -->'.NL;
85607bf32b2SAndreas Gohr    $out .= '<object '.buildAttributes($std).'>'.NL;
85707bf32b2SAndreas Gohr    $out .= '<!-- <![endif]-->'.NL;
85807bf32b2SAndreas Gohr    $out .= '<!--[if IE]>'.NL;
85907bf32b2SAndreas Gohr    $out .= '<object '.buildAttributes($ie).'>'.NL;
86007bf32b2SAndreas Gohr    $out .= '    <param name="movie" value="'.hsc($swf).'" />'.NL;
8619ae41cdcSAndreas Gohr    $out .= '<!--><!-- -->'.NL;
86207bf32b2SAndreas Gohr
86307bf32b2SAndreas Gohr    // print params
86407bf32b2SAndreas Gohr    if(is_array($params)) foreach($params as $key => $val){
86507bf32b2SAndreas Gohr        $out .= '  <param name="'.hsc($key).'" value="'.hsc($val).'" />'.NL;
86607bf32b2SAndreas Gohr    }
86707bf32b2SAndreas Gohr
86807bf32b2SAndreas Gohr    // add flashvars
86907bf32b2SAndreas Gohr    if(is_array($flashvars)){
870d4c61e61SAndreas Gohr        $out .= '  <param name="FlashVars" value="'.buildURLparams($flashvars).'" />'.NL;
87107bf32b2SAndreas Gohr    }
87207bf32b2SAndreas Gohr
87307bf32b2SAndreas Gohr    // alternative content
87407bf32b2SAndreas Gohr    if($alt){
87507bf32b2SAndreas Gohr        $out .= $alt.NL;
87607bf32b2SAndreas Gohr    }else{
87707bf32b2SAndreas Gohr        $out .= $lang['noflash'].NL;
87807bf32b2SAndreas Gohr    }
87907bf32b2SAndreas Gohr
88007bf32b2SAndreas Gohr    // finish
88107bf32b2SAndreas Gohr    $out .= '</object>'.NL;
88207bf32b2SAndreas Gohr    $out .= '<!-- <![endif]-->'.NL;
88307bf32b2SAndreas Gohr
88407bf32b2SAndreas Gohr    return $out;
88507bf32b2SAndreas Gohr}
88607bf32b2SAndreas Gohr
8878d5e837eSMichael Hamann/**
8888d5e837eSMichael Hamann * Prints HTML code for the given tab structure
8898d5e837eSMichael Hamann *
8908d5e837eSMichael Hamann * @param array  $tabs        tab structure
8918d5e837eSMichael Hamann * @param string $current_tab the current tab id
8928d5e837eSMichael Hamann */
89395b451bcSAdrian Langfunction html_tabs($tabs, $current_tab = null) {
89494add303SAnika Henke    echo '<ul class="tabs">'.NL;
89595b451bcSAdrian Lang
89695b451bcSAdrian Lang    foreach($tabs as $id => $tab) {
89795b451bcSAdrian Lang        html_tab($tab['href'], $tab['caption'], $id === $current_tab);
89895b451bcSAdrian Lang    }
89995b451bcSAdrian Lang
90094add303SAnika Henke    echo '</ul>'.NL;
90195b451bcSAdrian Lang}
902cd2a4cfdSAnika Henke
90395b451bcSAdrian Lang/**
90495b451bcSAdrian Lang * Prints a single tab
90595b451bcSAdrian Lang *
90695b451bcSAdrian Lang * @author Kate Arzamastseva <pshns@ukr.net>
90795b451bcSAdrian Lang * @author Adrian Lang <mail@adrianlang.de>
90895b451bcSAdrian Lang *
90995b451bcSAdrian Lang * @param string $href - tab href
91095b451bcSAdrian Lang * @param string $caption - tab caption
91195b451bcSAdrian Lang * @param boolean $selected - is tab selected
91295b451bcSAdrian Lang */
91395b451bcSAdrian Lang
91495b451bcSAdrian Langfunction html_tab($href, $caption, $selected=false) {
91595b451bcSAdrian Lang    $tab = '<li>';
91695b451bcSAdrian Lang    if ($selected) {
91795b451bcSAdrian Lang        $tab .= '<strong>';
91895b451bcSAdrian Lang    } else {
91995b451bcSAdrian Lang        $tab .= '<a href="' . hsc($href) . '">';
92095b451bcSAdrian Lang    }
92195b451bcSAdrian Lang    $tab .= hsc($caption)
92295b451bcSAdrian Lang         .  '</' . ($selected ? 'strong' : 'a') . '>'
92394add303SAnika Henke         .  '</li>'.NL;
92495b451bcSAdrian Lang    echo $tab;
92595b451bcSAdrian Lang}
92695b451bcSAdrian Lang
927cd2a4cfdSAnika Henke/**
928cd2a4cfdSAnika Henke * Display size change
929cd2a4cfdSAnika Henke *
930cd2a4cfdSAnika Henke * @param int $sizechange - size of change in Bytes
931e34d6962SSatoshi Sahara * @param Doku_Form $form - (optional) form to add elements to
932e34d6962SSatoshi Sahara * @return void|string
933cd2a4cfdSAnika Henke */
934e34d6962SSatoshi Saharafunction html_sizechange($sizechange, $form = null) {
935cd2a4cfdSAnika Henke    if (isset($sizechange)) {
936cd2a4cfdSAnika Henke        $class = 'sizechange';
937cd2a4cfdSAnika Henke        $value = filesize_h(abs($sizechange));
938cd2a4cfdSAnika Henke        if ($sizechange > 0) {
939cd2a4cfdSAnika Henke            $class .= ' positive';
940cd2a4cfdSAnika Henke            $value = '+' . $value;
941cd2a4cfdSAnika Henke        } elseif ($sizechange < 0) {
942cd2a4cfdSAnika Henke            $class .= ' negative';
943cd2a4cfdSAnika Henke            $value = '-' . $value;
9440b78a6edSAnika Henke        } else {
9450b78a6edSAnika Henke            $value = '±' . $value;
946cd2a4cfdSAnika Henke        }
947e34d6962SSatoshi Sahara        if (!isset($form)) {
948e34d6962SSatoshi Sahara            return '<span class="'.$class.'">'.$value.'</span>';
949b0f23f4eSSatoshi Sahara        } else { // Doku_Form
950cd2a4cfdSAnika Henke            $form->addElement(form_makeOpenTag('span', array('class' => $class)));
951cd2a4cfdSAnika Henke            $form->addElement($value);
952cd2a4cfdSAnika Henke            $form->addElement(form_makeCloseTag('span'));
953cd2a4cfdSAnika Henke        }
954cd2a4cfdSAnika Henke    }
955b0f23f4eSSatoshi Sahara}
956