1<?php
2/**
3 * Conditional display of sidebar and toc
4 */
5
6// must be run from within DokuWiki
7if (!defined('DOKU_INC')) die();
8
9if ((page_exists($sidebar) && $ACT == 'show' && $sidebar_right == $right) || ($toc!="" && $toc_right == $right)){
10?>
11<div class="kiwiki_aside <?php echo ($right == 1) ? 'right' : 'left'; ?>">
12        <div class="dokuwiki__aside_wrapper">
13        <?php
14        /* sidebar */
15        if ($ACT == 'show' && page_exists($sidebar) && $sidebar_right == $right) {
16
17            ?>
18            <div class="kiwiki-sidebar">
19                <div class="sidebar-content">
20                <?php
21                tpl_include_page($sidebar, true, true);
22                echo Kiwiki_Functions::_edit_icon($sidebar);
23                ?>
24                </div>
25            </div>
26
27        <?php
28        }
29        /*toc*/
30        if ($toc!="" && $toc_right == $right){
31            // Capture the TOC output
32            ob_start();
33            echo tpl_toc();
34            $toc_html = ob_get_clean();
35
36            // Add role="button" to the first <h3> tag
37            $toc_html = preg_replace('/<h3([^>]*)>/', '<h3$1 role="button">', $toc_html, 1);
38
39            echo $toc_html;
40        }
41        ?>
42        </div>
43</div>
44<?php
45}
46?>