1<?php
2/**
3 * functions for r7throot3 template
4 *
5 * License: GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 *
7 * @author:         Michael Klier <chi@chimeric.de>
8 * @homepage:       http://www.chimeric.de
9 * @modified-by:    Xan <DXpublica@telefonica.net>
10 * @modified-by:    Oscar M. Lage <r0sk10@gmail.com>
11 */
12
13require_once('conf.php');
14
15/**
16 * fetches the page menu1 and displays it
17 *
18 * @author Oscar M. Lage <r0sk10@gmail.com>
19 */
20function tpl_menu1()
21{
22    global $conf, $ID, $REV, $INFO;
23    print p_wiki_xhtml("menu1", '', false);
24}
25
26/**
27 * fetches the sidebar-pages and displays the sidebar
28 *
29 * @author Michael Klier <chi@chimeric.de>
30 */
31function tpl_sidebar() {
32    global $conf, $ID, $REV, $INFO, $lang;
33
34    $svID  = $ID;
35    $svREV = $REV;
36
37        $nom = $ID.'_'.$conf['sidebar-theme']['sidebar_pagename'];
38        $default_nom = $conf['sidebar-theme']['default_sidebar_name'];
39        $other = $INFO[namespace].'_'.$conf['sidebar-theme']['sidebar_pagename'];
40
41    if (file_exists(wikiFN($nom)))
42      {
43        echo '<div class="sidebar"><div class="sidebar-top">&nbsp;</div><div class="sidebar-middle">'.p_sidebar_xhtml($nom).'</div><div class="sidebar-bottom">&nbsp;</div></div>';
44      }
45    else
46      {
47        if (file_exists(wikiFN($other)))
48        {
49           print '<div class="sidebar"><div class="sidebar-top">&nbsp;</div><div class="sidebar-middle">'.p_sidebar_xhtml($other).'</div><div class="sidebar-bottom">&nbsp;</div></div>';
50        }
51        else
52        {
53					if (file_exists(wikiFN($default_nom)))
54					{
55						print '<div class="sidebar"><div class="sidebar-top">&nbsp;</div><div class="sidebar-middle">'.p_sidebar_xhtml($default_nom).'</div><div class="sidebar-bottom">&nbsp;</div></div>';
56					}
57					else
58					{
59						print '&nbsp;';
60
61					}
62        }
63       }
64
65    $ID = $svID;
66    $REV = $svREV;
67
68}
69
70/**
71 * removes the TOC of the sidebar-pages and shows a edit-button if user has enough rights
72 *
73 * @author Michael Klier <chi@chimeric.de>
74 */
75function p_sidebar_xhtml($Sb) {
76    $data = p_wiki_xhtml($Sb,'',false);
77    if(auth_quickaclcheck($Sb) >= AUTH_EDIT) {
78        $data .= '<div class="secedit">'.html_btn('secedit',$Sb,'',array('do'=>'edit','rev'=>'','post')).'</div>';
79    }
80    return preg_replace('/<div class="toc">.*?(<\/div>\n<\/div>)/s', '', $data);
81}
82
83?>