Ejemplo n.º 1
0
/**
 * right info boxes
 */
function _tpl_infobox()
{
    global $lang;
    global $conf;
    global $ID;
    if (!defined('DOKU_LF')) {
        define('DOKU_LF', "\n");
    }
    $boxfiles = explode(',', $conf['tpl']['dokukit']['boxfiles']);
    $infoboxes = array();
    if ($ID != $conf['start'] && $ID != $conf['lang'] . ':' . $conf['start'] || !$conf['tpl']['dokukit']['showboxes']) {
        unset($boxfiles);
    }
    if (count($boxfiles) > 0) {
        while (list(, $pname) = each($boxfiles)) {
            $ns_sb = _getNsSb($ID, $pname);
            if ($ns_sb && auth_quickaclcheck($ns_sb) >= AUTH_READ) {
                $infoboxes[] = '<div class="infobox"><div class="infobox-inner">' . p_sidebar_xhtml($ns_sb) . '</div></div>';
            } elseif (@file_exists(wikiFN($pname)) && auth_quickaclcheck($pname) >= AUTH_READ) {
                $infoboxes[] = '<div class="infobox"><div class="infobox-inner">' . p_sidebar_xhtml($pname) . '</div></div>';
            }
        }
    }
    if (count($infoboxes) > 0) {
        echo '<div id="right-row">', DOKU_LF;
        while (list(, $infobox) = each($infoboxes)) {
            echo $infobox, DOKU_LF;
        }
        echo '</div>', DOKU_LF;
    } else {
        echo '<style type="text/css">#middle-row, .tabelle3, .ptabelle, .ptabelleblank, .datentabelle { width:760px !important; }  </style>', DOKU_LF;
    }
}
/**
 * Dispatches the given sidebar type to return the right content
 *
 * @author Michael Klier <*****@*****.**>
 */
function tpl_sidebar_dispatch($sb, $pos)
{
    global $lang;
    global $conf;
    global $ID;
    global $REV;
    global $INFO;
    global $TOC;
    $svID = $ID;
    // save current ID
    $svREV = $REV;
    // save current REV
    $svTOC = $TOC;
    // save current TOC
    $pname = tpl_getConf('pagename');
    switch ($sb) {
        case 'main':
            if (tpl_getConf('closedwiki') && !isset($_SERVER['REMOTE_USER'])) {
                return;
            }
            $main_sb = $pname;
            if (@page_exists($main_sb) && auth_quickaclcheck($main_sb) >= AUTH_READ) {
                $always = tpl_getConf('main_sidebar_always');
                if ($always or !$always && !getNS($ID)) {
                    print '<div class="main_sidebar sidebar_box">' . DOKU_LF;
                    print p_sidebar_xhtml($main_sb, $pos) . DOKU_LF;
                    print '</div>' . DOKU_LF;
                }
            } elseif (!@page_exists($main_sb) && auth_quickaclcheck($main_sb) >= AUTH_CREATE) {
                if (@file_exists(DOKU_TPLINC . 'lang/' . $conf['lang'] . '/nonidebar.txt')) {
                    $out = p_render('xhtml', p_get_instructions(io_readFile(DOKU_TPLINC . 'lang/' . $conf['lang'] . '/nosidebar.txt')), $info);
                } else {
                    $out = p_render('xhtml', p_get_instructions(io_readFile(DOKU_TPLINC . 'lang/en/nosidebar.txt')), $info);
                }
                $link = '<a href="' . wl($pname) . '" class="wikilink2">' . $pname . '</a>' . DOKU_LF;
                print '<div class="main_sidebar sidebar_box">' . DOKU_LF;
                print str_replace('LINK', $link, $out);
                print '</div>' . DOKU_LF;
            }
            break;
        case 'namespace':
            if (tpl_getConf('closedwiki') && !isset($_SERVER['REMOTE_USER'])) {
                return;
            }
            $user_ns = tpl_getConf('user_sidebar_namespace');
            $group_ns = tpl_getConf('group_sidebar_namespace');
            if (!preg_match("/^" . $user_ns . ":.*?\$|^" . $group_ns . ":.*?\$/", $svID)) {
                // skip group/user sidebars and current ID
                $ns_sb = _getNsSb($svID);
                if ($ns_sb && auth_quickaclcheck($ns_sb) >= AUTH_READ) {
                    print '<div class="namespace_sidebar sidebar_box">' . DOKU_LF;
                    print p_sidebar_xhtml($ns_sb, $pos) . DOKU_LF;
                    print '</div>' . DOKU_LF;
                }
            }
            break;
        case 'user':
            if (tpl_getConf('closedwiki') && !isset($_SERVER['REMOTE_USER'])) {
                return;
            }
            $user_ns = tpl_getConf('user_sidebar_namespace');
            if (isset($INFO['userinfo']['name'])) {
                $user = $_SERVER['REMOTE_USER'];
                $user_sb = $user_ns . ':' . $user . ':' . $pname;
                if (@page_exists($user_sb)) {
                    $subst = array('pattern' => array('/@USER@/'), 'replace' => array($user));
                    print '<div class="user_sidebar sidebar_box">' . DOKU_LF;
                    print p_sidebar_xhtml($user_sb, $pos, $subst) . DOKU_LF;
                    print '</div>';
                }
                // check for namespace sidebars in user namespace too
                if (preg_match('/' . $user_ns . ':' . $user . ':.*/', $svID)) {
                    $ns_sb = _getNsSb($svID);
                    if ($ns_sb && $ns_sb != $user_sb && auth_quickaclcheck($ns_sb) >= AUTH_READ) {
                        print '<div class="namespace_sidebar sidebar_box">' . DOKU_LF;
                        print p_sidebar_xhtml($ns_sb, $pos) . DOKU_LF;
                        print '</div>' . DOKU_LF;
                    }
                }
            }
            break;
        case 'group':
            if (tpl_getConf('closedwiki') && !isset($_SERVER['REMOTE_USER'])) {
                return;
            }
            $group_ns = tpl_getConf('group_sidebar_namespace');
            if (isset($INFO['userinfo']['name'], $INFO['userinfo']['grps'])) {
                foreach ($INFO['userinfo']['grps'] as $grp) {
                    $group_sb = $group_ns . ':' . $grp . ':' . $pname;
                    if (@page_exists($group_sb) && auth_quickaclcheck(cleanID($group_sb)) >= AUTH_READ) {
                        $subst = array('pattern' => array('/@GROUP@/'), 'replace' => array($grp));
                        print '<div class="group_sidebar sidebar_box">' . DOKU_LF;
                        print p_sidebar_xhtml($group_sb, $pos, $subst) . DOKU_LF;
                        print '</div>' . DOKU_LF;
                    }
                }
            }
            break;
        case 'index':
            if (tpl_getConf('closedwiki') && !isset($_SERVER['REMOTE_USER'])) {
                return;
            }
            print '<div class="index_sidebar sidebar_box">' . DOKU_LF;
            print '  ' . p_index_xhtml($svID, $pos) . DOKU_LF;
            print '</div>' . DOKU_LF;
            break;
        case 'toc':
            if (tpl_getConf('closedwiki') && !isset($_SERVER['REMOTE_USER'])) {
                return;
            }
            if (auth_quickaclcheck($svID) >= AUTH_READ) {
                $toc = tpl_toc(true);
                // replace ids to keep XHTML compliance
                if (!empty($toc)) {
                    $toc = preg_replace('/id="(.*?)"/', 'id="sb__' . $pos . '__\\1"', $toc);
                    print '<div class="toc_sidebar sidebar_box">' . DOKU_LF;
                    print $toc;
                    print '</div>' . DOKU_LF;
                }
            }
            break;
        case 'toolbox':
            if (tpl_getConf('hideactions') && !isset($_SERVER['REMOTE_USER'])) {
                return;
            }
            if (tpl_getConf('closedwiki') && !isset($_SERVER['REMOTE_USER'])) {
                print '<div class="toolbox_sidebar sidebar_box">' . DOKU_LF;
                print '  <div class="level1">' . DOKU_LF;
                print '    <ul>' . DOKU_LF;
                print '      <li><div class="li">';
                tpl_actionlink('login');
                print '      </div></li>' . DOKU_LF;
                print '    </ul>' . DOKU_LF;
                print '  </div>' . DOKU_LF;
                print '</div>' . DOKU_LF;
            } else {
                $actions = array('admin', 'revert', 'edit', 'history', 'recent', 'backlink', 'subscription', 'index', 'login', 'profile', 'top');
                print '<div class="toolbox_sidebar sidebar_box">' . DOKU_LF;
                print '  <div class="level1">' . DOKU_LF;
                print '    <ul>' . DOKU_LF;
                foreach ($actions as $action) {
                    if (!actionOK($action)) {
                        continue;
                    }
                    // start output buffering
                    if ($action == 'edit') {
                        // check if new page button plugin is available
                        if (!plugin_isdisabled('npd') && ($npd =& plugin_load('helper', 'npd'))) {
                            $npb = $npd->html_new_page_button(true);
                            if ($npb) {
                                print '    <li><div class="li">';
                                print $npb;
                                print '</div></li>' . DOKU_LF;
                            }
                        }
                    }
                    ob_start();
                    print '     <li><div class="li">';
                    if (tpl_actionlink($action)) {
                        print '</div></li>' . DOKU_LF;
                        ob_end_flush();
                    } else {
                        ob_end_clean();
                    }
                }
                print '    </ul>' . DOKU_LF;
                print '  </div>' . DOKU_LF;
                print '</div>' . DOKU_LF;
            }
            break;
        case 'trace':
            if (tpl_getConf('closedwiki') && !isset($_SERVER['REMOTE_USER'])) {
                return;
            }
            print '<div class="trace_sidebar sidebar_box">' . DOKU_LF;
            print '  <h1>' . $lang['breadcrumb'] . '</h1>' . DOKU_LF;
            print '  <div class="breadcrumbs">' . DOKU_LF;
            $conf['youarehere'] != 1 ? tpl_breadcrumbs() : tpl_youarehere();
            print '  </div>' . DOKU_LF;
            print '</div>' . DOKU_LF;
            break;
        case 'extra':
            if (tpl_getConf('closedwiki') && !isset($_SERVER['REMOTE_USER'])) {
                return;
            }
            print '<div class="extra_sidebar sidebar_box">' . DOKU_LF;
            @(include dirname(__FILE__) . '/' . $pos . '_sidebar.html');
            print '</div>' . DOKU_LF;
            break;
        default:
            if (tpl_getConf('closedwiki') && !isset($_SERVER['REMOTE_USER'])) {
                return;
            }
            // check for user defined sidebars
            if (@file_exists(DOKU_TPLINC . 'sidebars/' . $sb . '/sidebar.php')) {
                print '<div class="' . $sb . '_sidebar sidebar_box">' . DOKU_LF;
                @(require_once DOKU_TPLINC . 'sidebars/' . $sb . '/sidebar.php');
                print '</div>' . DOKU_LF;
            }
            break;
    }
    // restore ID, REV and TOC
    $ID = $svID;
    $REV = $svREV;
    $TOC = $svTOC;
}
/**
 * Dispatches the given sidebar type to return the right content
 *
 * @author Michael Klier <*****@*****.**>
 */
function tpl_sidebar_dispatch($sb, $pos)
{
    global $lang;
    global $conf;
    global $ID;
    global $REV;
    global $INFO;
    $svID = $ID;
    // save current ID
    $svREV = $REV;
    // save current REV
    $pname = tpl_getConf('pagename');
    switch ($sb) {
        case 'main':
            $main_sb = _getTransSb($pname);
            if ($main_sb && auth_quickaclcheck($main_sb) >= AUTH_READ) {
                $always = tpl_getConf('main_sidebar_always');
                if ($always or !$always && !getNS($ID)) {
                    print '<div class="main_sidebar sidebar_box">' . DOKU_LF;
                    print p_sidebar_xhtml($main_sb, $pos) . DOKU_LF;
                    print '</div>' . DOKU_LF;
                }
            }
            break;
        case 'namespace':
            $user_ns = tpl_getConf('user_sidebar_namespace');
            $group_ns = tpl_getConf('group_sidebar_namespace');
            if (!preg_match("/^" . $user_ns . ":.*?\$|^" . $group_ns . ":.*?\$/", $svID)) {
                // skip group/user sidebars and current ID
                $ns_sb = _getNsSb($svID);
                if ($ns_sb && auth_quickaclcheck($ns_sb) >= AUTH_READ) {
                    print '<div class="namespace_sidebar sidebar_box">' . DOKU_LF;
                    print p_sidebar_xhtml($ns_sb, $pos) . DOKU_LF;
                    print '</div>' . DOKU_LF;
                }
            }
            break;
        case 'user':
            $user_ns = tpl_getConf('user_sidebar_namespace');
            if (isset($INFO['userinfo']['name'])) {
                $user = $_SERVER['REMOTE_USER'];
                $user_sb = _getTransSb($user_ns . ':' . $user . ':' . $pname);
                if (@file_exists(wikiFN($user_sb))) {
                    $subst = array('pattern' => array('/@USER@/'), 'replace' => array($user));
                    print '<div class="user_sidebar sidebar_box">' . DOKU_LF;
                    print p_sidebar_xhtml($user_sb, $pos, $subst) . DOKU_LF;
                    print '</div>';
                }
                // check for namespace sidebars in user namespace too
                if (preg_match('/' . $user_ns . ':' . $user . ':.*/', $svID)) {
                    $ns_sb = _getNsSb($svID);
                    if ($ns_sb && $ns_sb != $user_sb && auth_quickaclcheck($ns_sb) >= AUTH_READ) {
                        print '<div class="namespace_sidebar sidebar_box">' . DOKU_LF;
                        print p_sidebar_xhtml($ns_sb, $pos) . DOKU_LF;
                        print '</div>' . DOKU_LF;
                    }
                }
            }
            break;
        case 'group':
            $group_ns = tpl_getConf('group_sidebar_namespace');
            if (isset($INFO['userinfo']['name'], $INFO['userinfo']['grps'])) {
                foreach ($INFO['userinfo']['grps'] as $grp) {
                    $group_sb = $group_ns . ':' . $grp . ':' . $pname;
                    $group_sb = _getTransSb($group_sb);
                    if ($group_sb && auth_quickaclcheck(cleanID($group_sb)) >= AUTH_READ) {
                        $subst = array('pattern' => array('/@GROUP@/'), 'replace' => array($grp));
                        print '<div class="group_sidebar sidebar_box">' . DOKU_LF;
                        print p_sidebar_xhtml($group_sb, $pos, $subst) . DOKU_LF;
                        print '</div>' . DOKU_LF;
                    }
                }
            }
            break;
        case 'index':
            print '<div class="index_sidebar sidebar_box">' . DOKU_LF;
            print '  ' . p_index_xhtml($svID, $pos) . DOKU_LF;
            print '</div>' . DOKU_LF;
            break;
        case 'toc':
            if (auth_quickaclcheck($svID) >= AUTH_READ) {
                $toc = tpl_toc(true);
                // replace ids to keep XHTML compliance
                if (!empty($toc)) {
                    $toc = preg_replace('/id="(.*?)"/', 'id="sb__' . $pos . '__\\1"', $toc);
                    print '<div class="toc_sidebar sidebar_box">' . DOKU_LF;
                    print $toc;
                    print '</div>' . DOKU_LF;
                }
            }
            break;
        case 'toolbox':
            $act_content = explode(',', tpl_getConf('toolbox_content'));
            $act_order = explode(',', tpl_getConf('toolbox_order'));
            print '<div class="toolbox_sidebar sidebar_box">' . DOKU_LF;
            print '<h1>' . $lang['kunlaborejo_toolbox'] . '</h1>' . DOKU_LF;
            print '  <div class="level1">' . DOKU_LF;
            print '    <ul>' . DOKU_LF;
            tpl_dispatch_ordered_content($act_order, $act_content, "tpl_dispatch_toolbox_item");
            print '    </ul>' . DOKU_LF;
            print '  </div>' . DOKU_LF;
            print '</div>' . DOKU_LF;
            break;
        case 'trace':
            print '<div class="trace_sidebar sidebar_box">' . DOKU_LF;
            print '  <h1>' . $lang['breadcrumb'] . '</h1>' . DOKU_LF;
            print '  <div class="breadcrumbs">' . DOKU_LF;
            $conf['youarehere'] != 1 ? tpl_breadcrumbs() : tpl_youarehere();
            print '  </div>' . DOKU_LF;
            print '</div>' . DOKU_LF;
            break;
        case 'translation':
            print '<div class="translation_sidebar sidebar_box">' . DOKU_LF;
            print '  <h1>' . $lang['kunlaborejo_translations'] . '</h1>' . DOKU_LF;
            $translation =& plugin_load('syntax', 'translation');
            echo $translation->_showTranslations();
            print '</div>' . DOKU_LF;
            break;
        case 'extra':
            print '<div class="extra_sidebar sidebar_box">' . DOKU_LF;
            @(include dirname(__FILE__) . '/' . $pos . '_sidebar.html');
            print '</div>' . DOKU_LF;
            break;
        default:
            // check for user defined sidebars
            if (@file_exists(DOKU_TPLINC . 'sidebars/' . $sb . '/sidebar.php')) {
                print '<div class="' . $sb . '_sidebar sidebar_box">' . DOKU_LF;
                @(require_once DOKU_TPLINC . 'sidebars/' . $sb . '/sidebar.php');
                print '</div>' . DOKU_LF;
            }
            break;
    }
    // restore ID and REV
    $ID = $svID;
    $REV = $svREV;
}