xref: /template/kiwiki/main.php (revision de1938b7a10cd7674b43c5b5b7b8e71c962c7907)
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$sidebarElement = tpl_getConf('sidebarIsNav') ? 'nav' : 'aside';
17$menuMaxHeight = tpl_getConf('MenuMaxHeight');
18$tocMaxHeight = tpl_getConf('TocMaxHeight');
19$contentMaxWidth = tpl_getConf('ContentMaxWidth');
20$themeMode = tpl_getConf('DefaultTheme');
21$forceTheme = tpl_getConf('ForceTheme');
22
23
24
25if (!empty($_COOKIE['theme'])){
26    if(!$forceTheme){
27        $themeMode = in_array($_COOKIE['theme'], ['darkmode', 'lightmode', 'system-color']) ? $_COOKIE['theme'] : $themeMode;
28    }else{
29        setcookie("theme",$themeMode);
30    }
31}
32if (!isset($_COOKIE['theme']) || empty($_COOKIE['theme'] || !in_array($_COOKIE['theme'], ['darkmode', 'lightmode', 'system-color']))){
33    setcookie("theme",$themeMode);
34}
35
36$logoSize = array();
37
38$logodark = tpl_getMediaFile(array(':wiki:logo-dark.png', ':logo-dark.png', 'images/logo-dark.png'), true, $logoSize, false);
39$logolight = tpl_getMediaFile(array(':wiki:logo-light.png', ':logo-light.png', 'images/logo-light.png'), true, $logoSize, false);
40$logo = tpl_getMediaFile(array(':wiki:logo.png', ':logo.png', 'images/logo.png'), true, $logoSize);
41
42
43?><!DOCTYPE html>
44<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $conf['lang'] ?>"
45  lang="<?php echo $conf['lang'] ?>" dir="<?php echo $lang['direction'] ?>" class="no-js">
46<head>
47    <meta charset="UTF-8" />
48    <title><?php tpl_pagetitle() ?> [<?php echo strip_tags($conf['title']) ?>]</title>
49    <script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script>
50    <?php tpl_metaheaders() ?>
51    <meta name="viewport" content="width=device-width,initial-scale=1" />
52    <?php echo tpl_favicon(array('favicon', 'mobile')) ?>
53    <?php tpl_includeFile('meta.html')?>
54    <style>body{
55        --kiwiki-menu-max-height:<?php echo $menuMaxHeight; ?>px;
56        --kiwiki-toc-max-height:<?php echo $tocMaxHeight; ?>px;
57        --kiwiki-content-max-width:<?php echo $contentMaxWidth; ?>;
58        --kiwiki-logo-url:url(<?php echo $logo; ?>);
59        --kiwiki-logo-light-url:url(<?php echo $logolight ? $logolight : $logo; ?>);
60        --kiwiki-logo-dark-url:url(<?php echo $logodark ? $logodark : $logo; ?>);
61    }
62    </style>
63</head>
64
65
66<body id="kiwiki" class="<?php echo $themeMode; ?>">
67    <?php    /* the "dokuwiki__top" id is needed somewhere at the top, because that's where the "back to top" button/link links to */ ?>
68    <?php /* tpl_classes() provides useful CSS classes; if you choose not to use it, the 'dokuwiki' class at least
69             should always be in one of the surrounding elements (e.g. plugins and templates depend on it) */ ?>
70    <?php $admin_page = (($ACT == "admin") && (isset($_REQUEST['page']))) ? explode("#",$_REQUEST['page'])[0]: "" ;?>
71    <div id="dokuwiki__site">
72        <div id="dokuwiki__top" class="site <?php echo tpl_classes() ." " . $admin_page; ?>">
73        <!-- ********** HEADER ********** -->
74        <?php include('partial/header.php');?>
75
76        <?php include('partial/before_content.php'); ?>
77
78        <?php include('partial/content.php');?>
79
80        </div>
81        <!-- ********** FOOTER ********** -->
82    <?php include('partial/footer.php'); ?>
83    <!-- GO TOP -->
84    <div id="go">
85    <?php
86
87    $items = (new \dokuwiki\Menu\KiwikiGo())->getItems();
88    foreach ($items as $item){
89        if ($item -> getType() == 'bottom' && !tpl_getConf('GoBottomBtn')){
90            continue;
91        }else{
92            echo '<a href="'.$item->getLink().'" title="'.$item->getTitle().'">'
93            .'<span class="icon">'.inlineSVG($item->getSvg()).'</span>'
94            . '<span class="a11y">'.$item->getLabel().'</span>'
95            . '</a>';
96        }
97    }
98    ?>
99    </div>
100    </div><!-- /site -->
101    <div id="dokuwiki__bottom"></div>
102    <div class="no"><?php tpl_indexerWebBug() /* provide DokuWiki housekeeping, required in all templates */ ?></div>
103</body>
104</html>
105