예제 #1
0
function perch_pages_navigation($opts = array(), $return = false)
{
    $Pages = new PerchContent_Pages();
    $Perch = Perch::fetch();
    // translate renamed options from Perch v1
    if (isset($opts['from_path'])) {
        $opts['from-path'] = $opts['from_path'];
    }
    if (isset($opts['hide_extensions'])) {
        $opts['hide-extensions'] = $opts['hide_extensions'];
    }
    $default_opts = array('from-path' => '/', 'levels' => 0, 'hide-extensions' => false, 'hide-default-doc' => true, 'flat' => false, 'template' => array('item.html'), 'include-parent' => false, 'skip-template' => false, 'siblings' => false, 'only-expand-selected' => false, 'add-trailing-slash' => false, 'navgroup' => false, 'access-tags' => false, 'include-hidden' => false, 'from-level' => false, 'use-attributes' => true);
    if (class_exists('PerchMembers_Session')) {
        $Session = PerchMembers_Session::fetch();
        if ($Session->logged_in) {
            $default_opts['access-tags'] = $Session->get_tags();
        }
    }
    if (is_array($opts)) {
        $opts = array_merge($default_opts, $opts);
    } else {
        $opts = $default_opts;
    }
    if ($opts['skip-template']) {
        $return = true;
    }
    $current_page = $Perch->get_page();
    if ($opts['from-path'] == '*') {
        $opts['from-path'] = $current_page;
    }
    $r = $Pages->get_navigation($opts, $current_page);
    if ($return) {
        return $r;
    }
    echo $r;
    PerchUtil::flush_output();
}