3 First Previous 1 2 3 ... 22 23 24 25 26 [27] 28 29 30 31 32 ... 48 49 50 Next Last
6 // Number of page links in the begin and end of whole range
7 $count_out = ( ! empty($config['count_out'])) ?
(int) $config['count_out'] : 3;
8 // Number of page links on each side of current page
9 $count_in = ( ! empty($config['count_in'])) ?
(int) $config['count_in'] : 5;
11 // Beginning group of pages: $n1...$n2
13 $n2 = min($count_out, $total_pages);
15 // Ending group of pages: $n7...$n8
16 $n7 = max(1, $total_pages - $count_out +
1);
19 // Middle group of pages: $n4...$n5
20 $n4 = max($n2 +
1, $current_page - $count_in);
21 $n5 = min($n7 - 1, $current_page +
$count_in);
22 $use_middle = ($n5 >= $n4);
24 // Point $n3 between $n2 and $n4
25 $n3 = (int) (($n2 +
$n4) / 2);
26 $use_n3 = ($use_middle && (($n4 - $n2) > 1));
28 // Point $n6 between $n5 and $n7
29 $n6 = (int) (($n5 +
$n7) / 2);
30 $use_n6 = ($use_middle && (($n7 - $n5) > 1));
32 // Links to display as array(page => content)
35 // Generate links data in accordance with calculated numbers
36 for ($i = $n1; $i <= $n2; $i++
)
42 $links[$n3] = '…';
44 for ($i = $n4; $i <= $n5; $i++
)
50 $links[$n6] = '…';
52 for ($i = $n7; $i <= $n8; $i++
)
58 <p
class="pagination">
60 <?php
if ($first_page !== FALSE): ?
>
61 <a href
="<?php echo $page->url($first_page) ?>" rel
="first"><?php
echo __('First') ?
></a
>
63 <?php
echo __('First') ?
>
66 <?php
if ($previous_page !== FALSE): ?
>
67 <a href
="<?php echo $page->url($previous_page) ?>" rel
="prev"><?php
echo __('Previous') ?
></a
>
69 <?php
echo __('Previous') ?
>
72 <?php
foreach ($links as $number => $content): ?
>
74 <?php
if ($number === $current_page): ?
>
75 <strong
><?php
echo $content ?
></strong
>
77 <a href
="<?php echo $page->url($number) ?>"><?php
echo $content ?
></a
>
82 <?php
if ($next_page !== FALSE): ?
>
83 <a href
="<?php echo $page->url($next_page) ?>" rel
="next"><?php
echo __('Next') ?
></a
>
85 <?php
echo __('Next') ?
>
88 <?php
if ($last_page !== FALSE): ?
>
89 <a href
="<?php echo $page->url($last_page) ?>" rel
="last"><?php
echo __('Last') ?
></a
>
91 <?php
echo __('Last') ?
>
94 </p
><!-- .pagination
-->