Example #1
0
function create_tabs($items, $curr_page, $total_pages, $template)
{
    global $xoopsModuleConfig;
    if (function_exists('theme_create_tabs')) {
        theme_create_tabs($items, $curr_page, $total_pages, $template);
        return;
    }
    $maxTab = $xoopsModuleConfig['max_tabs'];
    $tabs = sprintf($template['left_text'], $items, $total_pages, 1);
    if ($total_pages == 1) {
        return $tabs;
    }
    $tabs .= $template['tab_header'];
    if ($curr_page == 1) {
        $tabs .= sprintf($template['active_tab'], 1);
    } else {
        $tabs .= sprintf($template['inactive_tab'], 1, 1);
    }
    if ($total_pages > $maxTab) {
        $start = max(2, $curr_page - floor(($maxTab - 2) / 2));
        $start = min($start, $total_pages - $maxTab + 2);
        $end = $start + $maxTab - 3;
    } else {
        $start = 2;
        $end = $total_pages - 1;
    }
    for ($page = $start; $page <= $end; $page++) {
        if ($page == $curr_page) {
            $tabs .= sprintf($template['active_tab'], $page);
        } else {
            $tabs .= sprintf($template['inactive_tab'], $page, $page);
        }
    }
    if ($total_pages > 1) {
        if ($curr_page == $total_pages) {
            $tabs .= sprintf($template['active_tab'], $total_pages);
        } else {
            $tabs .= sprintf($template['inactive_tab'], $total_pages, $total_pages);
        }
    }
    return $tabs . $template['tab_trailer'];
}
Example #2
0
/**
 * create_tabs()
 *
 * @param $items
 * @param $curr_page
 * @param $total_pages
 * @param $template
 * @return
 **/
function create_tabs($items, $curr_page, $total_pages, $template)
{
    global $CONFIG, $lang_create_tabs;
    // TO-DO: Need to add theme_create_tabs() to sample/theme.php
    // Maybe this function create_tabs() should be moved to themes.inc.php and renamed theme_create_tabs()?
    if (function_exists('theme_create_tabs')) {
        return theme_create_tabs($items, $curr_page, $total_pages, $template);
    }
    // Code for future: to implement 'previous' and 'next' tabs
    // Everything is set - just need to put in correct place and use correct prev & next page numbers
    // $tabs .= strtr( sprintf($template['inactive_prev_tab'],#PREV_PAGE_NUMBER#) , array('{PREV}' => $lang_create_tabs['previous']) );
    // $tabs .= strtr( sprintf($template['inactive_next_tab'],#NEXT_PAGE_NUMBER#) , array('{NEXT}' => $lang_create_tabs['next']) );
    $maxTab = $CONFIG['max_tabs'];
    $tabs = sprintf($template['left_text'], $items, $total_pages);
    if ($total_pages == 1) {
        return $tabs;
    }
    $tabs .= $template['tab_header'];
    if ($curr_page == 1) {
        $tabs .= sprintf($template['active_tab'], 1);
    } else {
        $tabs .= sprintf($template['inactive_tab'], 1, 1);
    }
    if ($total_pages > $maxTab) {
        $start = max(2, $curr_page - floor(($maxTab - 2) / 2));
        $start = min($start, $total_pages - $maxTab + 2);
        $end = $start + $maxTab - 3;
    } else {
        $start = 2;
        $end = $total_pages - 1;
    }
    for ($page = $start; $page <= $end; $page++) {
        if ($page == $curr_page) {
            $tabs .= sprintf($template['active_tab'], $page);
        } else {
            $tabs .= sprintf($template['inactive_tab'], $page, $page);
        }
    }
    if ($total_pages > 1) {
        if ($curr_page == $total_pages) {
            $tabs .= sprintf($template['active_tab'], $total_pages);
        } else {
            $tabs .= sprintf($template['inactive_tab'], $total_pages, $total_pages);
        }
    }
    return $tabs . $template['tab_trailer'];
}
/**
 * create_tabs()
 *
 * @param $items
 * @param $curr_page
 * @param $total_pages
 * @param $template
 * @return
 **/
function create_tabs($items, $curr_page, $total_pages, $template)
{
    return theme_create_tabs($items, $curr_page, $total_pages, $template);
}