<?php
/**
 * functions for arctic template
 *
 * License: GPL 2 (http://www.gnu.org/licenses/gpl.html)
 *
 * @version: 0.6 2005-01-18
 * 
 * @author:         Michael Klier <chi@chimeric.de>
 * @homepage:       http://www.chimeric.de
 * @modified-by:    Xan <DXpublica@telefonica.net>
 */

require_once('conf.php');

/**
 * fetches the sidebar-pages and displays the sidebar
 * 
 * @author Michael Klier <chi@chimeric.de>
 */
function tpl_sidebar($side='left') {
    global $conf, $ID, $REV, $INFO,$lang;
    
    $svID  = $ID;
    $svREV = $REV;

    if ($side=='left')
      {
        $nom = $ID.'_'.$conf['cherokee-based']['sidebar_pagename'].'_'.$side;
        $default_nom = $conf['cherokee-based']['default_leftsidebar_name'];
      }
    else
      {
        $nom = $ID.'_'.$conf['cherokee-based']['sidebar_pagename'].'_'.$side;
        $default_nom = $conf['cherokee-based']['default_rightsidebar_name'];
      }

    if (file_exists(wikiFN($nom)))
      {
        echo '<div class="'.$side.'bar">'.p_sidebar_xhtml($nom).'</div>';
      }
    else
      {
        if (file_exists(wikiFN($default_nom)))
        {
           print '<div class="'.$side.'bar">'.p_sidebar_xhtml($default_nom).'</div>';
        }
        else
        {
          print '&nbsp;';

        }
       }

    $ID = $svID;
    $REV = $svREV;


}

/**
 * removes the TOC of the sidebar-pages and shows a edit-button if user has enough rights
 * 
 * @author Michael Klier <chi@chimeric.de>
 */
function p_sidebar_xhtml($Sb) {
    $data = p_wiki_xhtml($Sb,'',false);
    if(auth_quickaclcheck($Sb) >= AUTH_EDIT) {
        $data .= '<div class="secedit">'.html_btn('secedit',$Sb,'',array('do'=>'edit','rev'=>'','post')).'</div>';
    }
    return preg_replace('/<div class="toc">.*?(<\/div>\n<\/div>)/s', '', $data);
}
?>
