xref: /template/kiwiki/main.php (revision 7e18f5b93ee2e91ceb8daf7522d1d57af632d5ed)
1<?php
2/**
3 * Kiwiki Template
4 *
5 * @link     http://dokuwiki.org/template:kiwiki
6 * @author   Anika Henke <anika@selfthinker.org>
7 * @author   Nicolas Prigent
8 * @license  GPL 2 (http://www.gnu.org/licenses/gpl.html)
9 */
10
11if (!defined('DOKU_INC')) die(); /* must be run from within DokuWiki */
12@require_once(dirname(__FILE__).'/tpl_functions.php'); /* include hook for template functions */
13
14$showTools = !tpl_getConf('hideTools') || ( tpl_getConf('hideTools') && !empty($_SERVER['REMOTE_USER']) );
15$showSidebar = page_findnearest($conf['sidebar']) && ($ACT=='show');
16$sidebar = $conf['sidebar'];
17$sidebarElement = tpl_getConf('sidebarIsNav') ? 'nav' : 'aside';
18$sidebarMaxHeight = tpl_getConf('SidebarMaxHeight');
19$sidebar_right = tpl_getConf('SidebarRight');
20$toc = tpl_toc(true);
21$tocMaxHeight = tpl_getConf('TocMaxHeight');
22$toc_right = tpl_getConf('TocRight');
23$contentMaxWidth = tpl_getConf('ContentMaxWidth');
24$themeMode = tpl_getConf('DefaultTheme');
25$forceTheme = tpl_getConf('ForceTheme');
26$contentWidth = '100%';
27$asideWidth = '20%';
28if(($toc!='' || ($ACT == 'show' && page_exists($sidebar))) && $sidebar_right == $toc_right){
29    $contentWidth = '80%';
30}
31if($sidebar_right != $toc_right ){
32    $contentWidth = '68%';
33    $asideWidth = '16%';
34}
35
36if (!empty($_COOKIE['theme'])){
37    if(!$forceTheme){
38        $themeMode = in_array($_COOKIE['theme'], ['darkmode', 'lightmode', 'system-color']) ? $_COOKIE['theme'] : $themeMode;
39    }else{
40        setcookie("theme",$themeMode);
41    }
42}
43if (!isset($_COOKIE['theme']) || empty($_COOKIE['theme'] || !in_array($_COOKIE['theme'], ['darkmode', 'lightmode', 'system-color']))){
44    setcookie("theme",$themeMode);
45}
46
47$logoSize = array();
48
49$logodark = tpl_getMediaFile(array(':wiki:logo-dark.png', ':logo-dark.png', 'images/logo-dark.png'), true, $logoSize, false);
50$logolight = tpl_getMediaFile(array(':wiki:logo-light.png', ':logo-light.png', 'images/logo-light.png'), true, $logoSize, false);
51$logo = tpl_getMediaFile(array(':wiki:logo.png', ':logo.png', 'images/logo.png'), true, $logoSize);
52
53
54?><!DOCTYPE html>
55<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $conf['lang'] ?>"
56  lang="<?php echo $conf['lang'] ?>" dir="<?php echo $lang['direction'] ?>" class="no-js">
57<head>
58    <meta charset="UTF-8" />
59    <title><?php tpl_pagetitle() ?> [<?php echo strip_tags($conf['title']) ?>]</title>
60    <script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script>
61    <?php tpl_metaheaders() ?>
62    <meta name="viewport" content="width=device-width,initial-scale=1" />
63    <?php echo tpl_favicon(array('favicon', 'mobile')) ?>
64    <?php tpl_includeFile('meta.html')?>
65    <style>body{
66        --kiwiki-sidebar-max-height:<?php echo $sidebarMaxHeight; ?>px;
67        --kiwiki-toc-max-height:<?php echo $tocMaxHeight; ?>px;
68        --kiwiki-content-max-width:<?php echo $contentMaxWidth; ?>;
69        --kiwiki-content-width:<?php echo $contentWidth; ?>;
70        --kiwiki-aside-width:<?php echo $asideWidth; ?>;
71        --kiwiki-logo-url:url(<?php echo $logo; ?>);
72        --kiwiki-logo-light-url:url(<?php echo $logolight ? $logolight : $logo; ?>);
73        --kiwiki-logo-dark-url:url(<?php echo $logodark ? $logodark : $logo; ?>);
74
75    }
76
77    label[for="tpl____KIWIKI_DARK__"], label[for="tpl____KIWIKI_LIGHT__"] {
78    font-weight: 700;
79    padding: 20px 0 10px;
80        display: block;
81        font-size: 30px;
82    }
83
84    #tpl____KIWIKI_LIGHT__,
85    #tpl____KIWIKI_DARK__ {
86    display: none !important;
87    }
88    </style>
89</head>
90
91
92<body id="kiwiki" class="<?php echo $themeMode; ?>">
93    <?php    /* the "dokuwiki__top" id is needed somewhere at the top, because that's where the "back to top" button/link links to */ ?>
94    <?php /* tpl_classes() provides useful CSS classes; if you choose not to use it, the 'dokuwiki' class at least
95             should always be in one of the surrounding elements (e.g. plugins and templates depend on it) */ ?>
96    <?php $admin_page = (($ACT == "admin") && (isset($_REQUEST['page']))) ? explode("#",$_REQUEST['page'])[0]: "" ;?>
97    <div id="dokuwiki__site">
98        <div id="dokuwiki__top" class="site <?php echo tpl_classes() ." " . $admin_page; ?>">
99        <!-- ********** HEADER ********** -->
100        <?php include('partial/header.php');?>
101
102        <?php include('partial/before_content.php'); ?>
103
104        <?php include('partial/content.php');?>
105
106        </div>
107        <!-- ********** FOOTER ********** -->
108    <?php include('partial/footer.php'); ?>
109    <!-- GO TOP -->
110    <div id="go">
111    <?php
112
113    $items = (new \dokuwiki\Menu\KiwikiGo())->getItems();
114    foreach ($items as $item){
115        if ($item -> getType() == 'bottom' && !tpl_getConf('GoBottomBtn')){
116            continue;
117        }else{
118            echo '<a href="'.$item->getLink().'" title="'.$item->getTitle().'">'
119            .'<span class="icon">'.inlineSVG($item->getSvg()).'</span>'
120            . '<span class="a11y">'.$item->getLabel().'</span>'
121            . '</a>';
122        }
123    }
124    ?>
125    </div>
126    </div><!-- /site -->
127    <div id="dokuwiki__bottom"></div>
128    <div class="no"><?php tpl_indexerWebBug() /* provide DokuWiki housekeeping, required in all templates */ ?></div>
129</body>
130</html>
131