1<?php
2
3/**
4 * Template Functions
5 *
6 * This file provides template specific custom functions that are
7 * not provided by the DokuWiki core.
8 * It is common practice to start each function with an underscore
9 * to make sure it won't interfere with future core functions.
10 */
11
12// must be run from within DokuWiki
13if (!defined('DOKU_INC')) die();
14
15function _tpl_usertools()
16{
17    /* the optional second parameter of tpl_action() switches between a link and a button,
18     e.g. a button inside a <li> would be: tpl_action('edit', 0, 'li') */
19    tpl_toolsevent('usertools', array(
20
21        'profile'   => tpl_action('profile', 1, 'li', 1),
22        'register'  => tpl_action('register', 1, 'li', 1),
23        'login'     => tpl_action('login', 1, 'li', 1),
24    ));
25}
26
27function _tpl_sitetools()
28{
29    tpl_toolsevent('sitetools', array(
30        'recent'    => tpl_action('recent', 1, 'li', 1),
31        'media'     => tpl_action('media', 1, 'li', 1),
32        'index'     => tpl_action('index', 1, 'li', 1),
33        'admin'     => tpl_action('admin', 1, 'li', 1),
34    ));
35}
36
37function _tpl_pagetools()
38{
39    tpl_toolsevent('pagetools', array(
40        'edit'      => tpl_action('edit', 1, 'li', 1),
41        'revisions' => tpl_action('revisions', 1, 'li', 1),
42        'backlink'  => tpl_action('backlink', 1, 'li', 1),
43        'subscribe' => tpl_action('subscribe', 1, 'li', 1),
44        'revert'    => tpl_action('revert', 1, 'li', 1),
45        'top'       => tpl_action('top', 1, 'li', 1),
46    ));
47}
48
49function _tpl_detailtools()
50{
51    echo tpl_action('mediaManager', 1, 'li', 1);
52    echo tpl_action('img_backto', 1, 'li', 1);
53}
54
55//
56// Sidebar logo
57//
58function _tpl_logo($return = false)
59{
60    global $INFO;
61    global $conf;
62	global $ID;
63
64    $logoSize = array();
65    $logo = tpl_getMediaFile(array(':' . $INFO['namespace'] . ':logo.jpg', ':' . $INFO['namespace'] . ':logo.png',  ':logo.png', ':wiki:dokuwiki-128.png', ':wiki:logo.png', 'images/logo.png'), false, $logoSize);
66    $out = '<div><img class="logo" src="' . $logo . '" alt="' . $conf['title'] . '" id="dokuwiki__top" accesskey="h" title="[H]" ></div>';
67
68	$_nstartpage = $INFO['namespace'] . ':' . $conf['start'];
69	if (page_exists($_nstartpage) && ($_nstartpage!=$ID)) {
70		$out = tpl_link(wl($_nstartpage,'',true),  $out, '', 1);
71	} 		else {
72		$out = tpl_link(wl('','',true),  $out, '', 1);
73	}
74    if ($return) return $out;
75    echo $out;
76    return true;
77}
78
79//
80// Left upper corner Icon
81//
82function _tpl_icon($return = false)
83{
84    global $INFO;
85    global $conf;
86	global $ID;
87
88    $logoSize = array();
89    $logo = tpl_getMediaFile(array(':' . $INFO['namespace'] . ':icon.png',':' . $INFO['namespace'] . ':logo.jpg', ':' . $INFO['namespace'] . ':logo.png',  ':logo.png', ':wiki:dokuwiki-128.png', ':wiki:logo.png', 'images/logo.png'), false, $logoSize);
90    $out = '<div><img class="logo" src="' . $logo . '" alt="' . $conf['title'] . '" id="dokuwiki__top" accesskey="h" title="[H]" ></div>';
91	// if namespace_start_page exist then go there or go to home
92	$_nstartpage = $INFO['namespace'] . ':' . $conf['start'];
93	if (page_exists($_nstartpage) && ($_nstartpage!=$ID)) {
94		$out = tpl_link(wl($_nstartpage,'',true),  $out, '', 1);
95	} 		else {
96		$out = tpl_link(wl('','',true),  $out, '', 1);
97	}
98    if ($return) return $out;
99    echo $out;
100    return true;
101}
102
103//
104//  Background Image
105//
106
107function _tpl_background($return = false)
108{
109    global $INFO;
110    $bg = ('background.jpg');
111    $logoSize = array();
112    $img = tpl_getMediaFile(array(
113        ':'.$INFO['namespace'] . ':' . $bg,  // Namespace
114		':'.$bg,                             // Main
115		'images/background.jpg'              // Plugin default
116    ), true);
117    $out = $img;
118    if ($return) return $out;
119    echo $out;
120    return true;
121}
122
123
124
125
126function _tpl_title($return = false)
127{
128    global $INFO;
129    global $conf;
130    //strip_tags($conf['title'])
131    $out = '<div class="text-center" >' . tpl_link(wl($INFO['namespace'] . ':' . $conf['start']), p_get_first_heading(':' . $INFO['namespace'] . ':' . $conf['start']), 'accesskey="h" title="[H]"', 1) . '</div>';
132    if ($return) return $out;
133    echo $out;
134    return true;
135}
136
137function _tpl_userinfo($return = false)
138{
139    global $lang;
140    /** @var Input $INPUT */
141    global $INPUT;
142    if ($INPUT->server->str('REMOTE_USER')) {
143        // print $lang['loggedinas'].' '.userlink();
144        if ($return) {
145            return  userlink();
146        } else {
147            print userlink();
148            return true;
149        }
150    }
151    return false;
152}
153
154function  _tpl_smartbtn()
155{
156    global $INFO;
157    global $conf;
158    global $ACT;
159
160    //echo $ACT;
161
162    switch ($ACT) {
163        case 'edit':
164
165            tpl_actionlink('edit', '', '', ' &#xe909;'); // show
166
167            break;
168        case 'show':
169            if ($INFO['editable'])
170                tpl_actionlink('edit', '', '', ' &#xe907;'); //edit
171            else
172                tpl_actionlink('login', '', '', ' &#xe90f;'); //login
173            break;
174        default:
175            tpl_actionlink('edit', '', '', ' &#xe909;'); // show
176    }
177
178    return false;
179}
180