1<?php
2
3/**
4 * Use the sidebar page from current namespace if available, if not use the global one
5 *
6 * @author Symon Bent hendrybadao@gmail.com
7 */
8
9function _tpl_sidebar() {
10    global $INFO, $conf;
11
12    $id = $conf['sidebar'];
13    $ns = $INFO['namespace'];
14
15    do {
16        $sidebar = $ns . ':' . $id;
17        if (page_exists($sidebar)) {
18            return $sidebar;
19        }
20        $ns = substr($ns, 0, strrpos($ns, ':'));
21    } while ( ! empty($ns));
22    return $id;
23}
24
25
26/**
27 * Custom styles to allow different site/sidebar widths per namespace
28 * Set in template's configuration (nsWidth).
29 *
30 * Syntax: "namespace site-width sidebar-width;namespace-2 site-width-2 sidebar-width-2"
31 * (semicolons between namespaces sections, spaces within a section)
32 * @author Symon Bent hendrybadao@gmail.com
33 */
34function _tpl_ns_styles() {
35    global $INFO;
36    $result = '';
37
38    $cur_ns = $INFO['namespace'];
39    $args = tpl_getConf('nsWidth');
40    if (empty($args)) return;
41    $args = explode(';', $args);
42    foreach ($args as $arg) {
43        list ($ns, $site_width, $sidebar_width) = explode(' ', $arg);
44        $ns = ltrim(trim($ns), ':');
45        $match = strpos($cur_ns, $ns);
46        if ($match == 0 && $match !== false) {
47            $result = '<style>' .
48                        '.mode_show #dokuwiki__aside { width: ' . $sidebar_width . '; }' . DOKU_LF .
49                        '.mode_show #dokuwiki__content { margin-left: -' . $sidebar_width . '; }' . DOKU_LF .
50                        '.mode_show #dokuwiki__content .pad { margin-left: ' . $sidebar_width . '; }' . DOKU_LF .
51                        '#dokuwiki__site .wrapper { max-width: ' . $site_width . '; }' . DOKU_LF .
52                      '</style>';
53            echo $result;
54            break;
55        }
56    }
57}
58
59/**
60 * Print info if the user is logged in
61 * and show full name in that case
62 *
63 * SB: removed the 'Logged in as:' message; too much fluff
64 *
65 * @author Andreas Gohr <andi@splitbrain.org>
66 * @author Symon Bent <hendrybadao@gmail.com>
67 * @return bool
68 */
69function _tpl_userinfo() {
70    global $INFO;
71    if(isset($_SERVER['REMOTE_USER'])) {
72        print hsc($INFO['userinfo']['name']).' ('.hsc($_SERVER['REMOTE_USER']).')';
73        return true;
74    }
75    return false;
76}