1<?php
2/**
3 * functions for simpleClean Template
4 *
5 * License: GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 *
7 * @author:   Tazman DeVille
8 * @homepage: http://tazmandevil.info
9 */
10
11require_once('conf.php');
12
13/**
14 * Displays the menu1
15 *
16 */
17function tpl_menu1()
18{
19    global $conf, $ID, $REV, $INFO;
20
21    $html = p_wiki_xhtml ('menu1', '', false );
22    $html = str_replace( '<p>', '', $html );
23    $html = str_replace( '</p>', '', $html );
24
25    $pos = strrpos($ID, ":");
26
27    if ($pos === false) {
28        $html = str_replace( '<a href="/'.$ID.'"', '<a href="/'.$ID.'" class="activepage"', $html );
29        }
30    else {
31        $IDLINK = str_replace (":", "/", $ID);
32        $html = str_replace( '<a href="/'.$IDLINK.'"', '<a href="/'.$IDLINK.'" class="activepage"', $html );
33    };
34
35    if ($pos !== false) {
36        $html = str_replace( '<a href="/'.$ID.'"', '<a href="/'.$ID.'" class="activepage"', $html );
37    };
38
39    echo $html;
40
41    if ( $INFO['perm'] > AUTH_READ )
42    {
43        print '<ul><li><a href="?id=menu1&amp;do=edit" class="wikilink2" title="Edit">Edit</a></li></ul>';
44    }
45}
46
47/**
48 * Displays the bottombar
49 *
50 */
51function tpl_bottombar()
52{
53    global $INFO,$ID,$lang;
54    $perm = $INFO['perm'];
55
56    echo '<a href="?do=recent" class="interwiki" title="'.$lang['btn_rec'].'">'.$lang['btn_recent'].'</a>'
57        .'&nbsp;&middot;&nbsp;';
58
59    if($perm > AUTH_READ) {
60        echo '<a href="?do=revisions" class="interwiki" title="'.$lang['btn_revs'].'">'.$lang['btn_revs'].'</a>'
61            .'&nbsp;&middot;&nbsp;';
62        if(file_exists(wikiFN($ID))) {
63            echo '<a href="?id='.$ID.'&amp;do=edit" class="interwiki" title="'.$lang['btn_edit'].'">'.$lang['btn_edit'].'</a>';
64        } else {
65            echo '<a href="?id='.$ID.'&amp;do=edit" class="interwiki" title="'.$lang['btn_create'].'">'.$lang['btn_create'].'</a>';
66        }
67        echo '&nbsp;&middot;&nbsp;';
68    } else {
69        echo '<a href="?id='.$ID.'&amp;do=edit" class="interwiki" title="'.$lang['btn_source'].'">'.$lang['btn_source'].'</a>'
70            .'&nbsp;&middot;&nbsp;';
71    }
72
73    if($perm > AUTH_WRITE) {
74        echo '<a href="?do=admin" class="interwiki" title="'.$lang['btn_admin'].'">'.$lang['btn_admin'].'</a>'
75            .'&nbsp;&middot;&nbsp;';
76    }
77
78    if(isset($INFO['userinfo']['name'])) {
79				echo '<a href="?do=profile" class="interwiki" title="'.$lang['btn_profile'].'">'.$lang['btn_profile'].'</a>'
80            .'&nbsp;&middot;&nbsp;';
81				echo '<a href="?do=logout" class="interwiki" title="'.$lang['btn_logout'].'">'.$lang['btn_logout'].'</a>';
82    } else {
83        echo '<a href="?do=login" class="interwiki" title="'.$lang['btn_login'].'">'.$lang['btn_login'].'</a>';
84    }
85}
86
87/**
88 * Displays the menu2
89 *
90 */
91function tpl_menu2()
92{
93	global $conf, $ID, $REV, $INFO, $lang;
94	$currID = false;
95
96	$pos = strrpos($ID, ":");
97    	if ($pos !== false) {
98        	$namespacechar = ":";
99        }
100	else {
101		$namespacechar = "/";
102	}
103
104
105	if ( $conf['tpl_simpleClean']['menu2Permanent'] )
106	{
107		$path = "";
108	}
109	else
110	{
111		if ( false != strpos($ID, $namespacechar) )
112		{
113			$path = substr($ID, 0, strpos($ID, $namespacechar));
114		}
115		else
116		{
117			$path = $ID;
118		}
119	}
120
121	if (  $INFO['perm'] >= AUTH_READ )
122	{
123		print "<h1>";
124		print $path;
125		print "</h1>";
126		print p_wiki_xhtml($path.$namespacechar."menu2", '', false);
127	}
128
129	if (  $INFO['perm'] > AUTH_READ )
130	{
131		print '<ul><li><a href="?id='.$path.$namespacechar.'menu2&amp;do=edit" class="wikilink1" title="Edit"><b>Edit</b></a></li></ul>';
132	}
133}
134
135/**
136 * Check if menu2 is present for this page
137 *
138 */
139function tpl_isMenu2()
140{
141	global $conf, $ID, $REV, $INFO, $ACT;
142
143	if ( $ACT == 'edit' || $ACT == 'preview' )
144	{
145		return false;
146	}
147
148	// Permanent Sidebar
149	if ( true == $conf['tpl_simpleClean']['menu2Permanent'] && true == file_exists( (wikiFN("menu2") ) ) )
150	{
151		return true;
152	}
153
154	if ( false != strpos($ID, ":") )
155	{
156		$path = substr($ID, 0, strpos($ID, ":"));
157	}
158	else
159	{
160		$path = $ID;
161	}
162	$path .= ":";
163
164	if ( file_exists(wikiFN($path."menu2")) )
165	{
166		return true;
167	}
168	else
169	{
170		return false;
171	}
172}
173
174?>
175