Example #1
0
/**
 * print a list of page number links (eg [1 2 3])
 * @param string  $p_page           The Page URL.
 * @param integer $p_start          The first page number.
 * @param integer $p_end            The last page number.
 * @param integer $p_current        The current page number.
 * @param integer $p_temp_filter_id Temporary filter id.
 * @return void
 */
function print_page_links( $p_page, $p_start, $p_end, $p_current, $p_temp_filter_id = 0 ) {
	$t_items = array();

	# Check if we have more than one page,
	#  otherwise return without doing anything.

	if( $p_end - $p_start < 1 ) {
		return;
	}

	# Get localized strings
	$t_first = lang_get( 'first' );
	$t_last = lang_get( 'last' );
	$t_prev = lang_get( 'prev' );
	$t_next = lang_get( 'next' );

	$t_page_links = 10;

	print( '[ ' );

	# First and previous links
	print_page_link( $p_page, $t_first, 1, $p_current, $p_temp_filter_id );
	echo '&#160;';
	print_page_link( $p_page, $t_prev, $p_current - 1, $p_current, $p_temp_filter_id );
	echo '&#160;';

	# Page numbers ...

	$t_first_page = max( $p_start, $p_current - $t_page_links / 2 );
	$t_first_page = min( $t_first_page, $p_end - $t_page_links );
	$t_first_page = max( $t_first_page, $p_start );

	if( $t_first_page > 1 ) {
		print( ' ... ' );
	}

	$t_last_page = $t_first_page + $t_page_links;
	$t_last_page = min( $t_last_page, $p_end );

	for( $i = $t_first_page;$i <= $t_last_page;$i++ ) {
		if( $i == $p_current ) {
			array_push( $t_items, $i );
		} else {
			$t_delimiter = ( strpos( $p_page, '?' ) ? '&' : '?' ) ;
			if( $p_temp_filter_id !== 0 ) {
				array_push( $t_items, '<a href="' . $p_page . $t_delimiter . 'filter=' . $p_temp_filter_id . '&amp;page_number=' . $i . '">' . $i . '</a>' );
			} else {
				array_push( $t_items, '<a href="' . $p_page . $t_delimiter . 'page_number=' . $i . '">' . $i . '</a>' );
			}
		}
	}
	echo implode( '&#160;', $t_items );

	if( $t_last_page < $p_end ) {
		print( ' ... ' );
	}

	# Next and Last links
	echo '&#160;';
	if( $p_current < $p_end ) {
		print_page_link( $p_page, $t_next, $p_current + 1, $p_current, $p_temp_filter_id );
	} else {
		print_page_link( $p_page, $t_next, null, null, $p_temp_filter_id );
	}
	echo '&#160;';
	print_page_link( $p_page, $t_last, $p_end, $p_current, $p_temp_filter_id );

	print( ' ]' );
}
Example #2
0
function print_page_links($p_page, $p_start, $p_end, $p_current, $p_temp_filter_id = 0)
{
    $t_items = array();
    $t_link = '';
    # Check if we have more than one page,
    #  otherwise return without doing anything.
    if ($p_end - $p_start < 1) {
        return;
    }
    # Get localized strings
    $t_first = lang_get('first');
    $t_last = lang_get('last');
    $t_prev = lang_get('prev');
    $t_next = lang_get('next');
    $t_page_links = 10;
    print "[ ";
    # First and previous links
    print_page_link($p_page, $t_first, 1, $p_current, $p_temp_filter_id);
    echo '&#160;';
    print_page_link($p_page, $t_prev, $p_current - 1, $p_current, $p_temp_filter_id);
    echo '&#160;';
    # Page numbers ...
    $t_first_page = max($p_start, $p_current - $t_page_links / 2);
    $t_first_page = min($t_first_page, $p_end - $t_page_links);
    $t_first_page = max($t_first_page, $p_start);
    if ($t_first_page > 1) {
        print " ... ";
    }
    $t_last_page = $t_first_page + $t_page_links;
    $t_last_page = min($t_last_page, $p_end);
    for ($i = $t_first_page; $i <= $t_last_page; $i++) {
        if ($i == $p_current) {
            array_push($t_items, $i);
        } else {
            $t_delimiter = strpos($p_page, "?") ? "&" : "?";
            if ($p_temp_filter_id !== 0) {
                array_push($t_items, "<a href=\"{$p_page}{$t_delimiter}filter={$p_temp_filter_id}&amp;page_number={$i}\">{$i}</a>");
            } else {
                array_push($t_items, "<a href=\"{$p_page}{$t_delimiter}page_number={$i}\">{$i}</a>");
            }
        }
    }
    echo implode('&#160;', $t_items);
    if ($t_last_page < $p_end) {
        print ' ... ';
    }
    # Next and Last links
    echo '&#160;';
    if ($p_current < $p_end) {
        print_page_link($p_page, $t_next, $p_current + 1, $p_current, $p_temp_filter_id);
    } else {
        print_page_link($p_page, $t_next, null, null, $p_temp_filter_id);
    }
    echo '&#160;';
    print_page_link($p_page, $t_last, $p_end, $p_current, $p_temp_filter_id);
    print ' ]';
}
Example #3
0
function print_page_links($p_page, $p_start, $p_end, $p_current)
{
    $t_items = array();
    $t_link = '';
    # Check if we have more than one page,
    #  otherwise return without doing anything.
    if ($p_end - $p_start < 1) {
        return;
    }
    # Get localized strings
    $t_first = lang_get('first');
    $t_last = lang_get('last');
    $t_prev = lang_get('prev');
    $t_next = lang_get('next');
    $t_page_links = 10;
    print "[ ";
    # First and previous links
    print_page_link($p_page, $t_first, 1, $p_current);
    print_page_link($p_page, $t_prev, $p_current - 1, $p_current);
    # Page numbers ...
    $t_first_page = max($p_start, $p_current - $t_page_links / 2);
    $t_first_page = min($t_first_page, $p_end - $t_page_links);
    $t_first_page = max($t_first_page, $p_start);
    if ($t_first_page > 1) {
        print " ... ";
    }
    $t_last_page = $t_first_page + $t_page_links;
    $t_last_page = min($t_last_page, $p_end);
    for ($i = $t_first_page; $i <= $t_last_page; $i++) {
        if ($i == $p_current) {
            array_push($t_items, $i);
        } else {
            array_push($t_items, "<a href=\"{$p_page}?page_number={$i}\">{$i}</a>");
        }
    }
    print implode('&nbsp;', $t_items);
    if ($t_last_page < $p_end) {
        print " ... ";
    }
    # Next and Last links
    if ($p_current < $p_end) {
        print_page_link($p_page, $t_next, $p_current + 1, $p_current);
    } else {
        print_page_link($p_page, $t_next);
    }
    print_page_link($p_page, $t_last, $p_end, $p_current);
    print " ]";
}