@@ -514,7 +514,7 @@ public function create_links()
514
514
{
515
515
$ this ->cur_page = $ this ->CI ->input ->get ($ this ->query_string_segment );
516
516
}
517
- elseif ( empty ( $ this -> cur_page ))
517
+ else
518
518
{
519
519
// Default to the last segment number if one hasn't been defined.
520
520
if ($ this ->uri_segment === 0 )
@@ -530,10 +530,6 @@ public function create_links()
530
530
$ this ->cur_page = str_replace ([$ this ->prefix , $ this ->suffix ], '' , $ this ->cur_page );
531
531
}
532
532
}
533
- else
534
- {
535
- $ this ->cur_page = (string ) $ this ->cur_page ;
536
- }
537
533
538
534
// If something isn't quite right, back to the default base page.
539
535
// A fix for this is below [if ( ! ctype_digit($this->cur_page) OR ($this->use_page_numbers && (int) $this->cur_page === 0))
@@ -593,7 +589,7 @@ public function create_links()
593
589
{
594
590
$ i = ($ this ->use_page_numbers ) ? $ uri_page_number - 1 : $ uri_page_number - $ this ->per_page ;
595
591
596
- $ attributes = sprintf ('%s %s="%d" ' , $ this ->_attributes , $ this ->data_page_attr , ($ this -> cur_page - 1 ) );
592
+ $ attributes = sprintf ('%s %s="%d" ' , $ this ->_attributes , $ this ->data_page_attr , (int ) $ i );
597
593
598
594
if ($ i === $ base_page )
599
595
{
@@ -613,12 +609,47 @@ public function create_links()
613
609
// Render the pages
614
610
if ($ this ->display_pages !== false )
615
611
{
612
+ /*
613
+ * On page 4, show hidden page 2
614
+ */
615
+ if ($ start == 4 ) {
616
+ $ start --;
617
+ }
618
+
619
+ /*
620
+ * On pages after 4, show dots before pages
621
+ */
622
+ if (($ start ) > 4 ) {
623
+ $ output .= '<div class="continues">. . .</div> ' ;
624
+ }
625
+
626
+ /*
627
+ * On page 4th last, show hidden page 2nd last
628
+ */
629
+ if ($ start == ($ num_pages - 3 ) && $ start > 4 ) {
630
+ $ end ++;
631
+ }
632
+
633
+ /*
634
+ * On last page, show hidden page 3rd last
635
+ */
636
+ if ($ start == $ num_pages && $ start > 3 ) {
637
+ $ start --;
638
+ }
639
+
640
+ /*
641
+ * On page 1, show hidden page 3
642
+ */
643
+ if ($ start == 1 && $ end < $ num_pages -1 ) {
644
+ $ end ++;
645
+ }
646
+
616
647
// Write the digit links
617
648
for ($ loop = $ start - 1 ; $ loop <= $ end ; $ loop ++)
618
649
{
619
650
$ i = ($ this ->use_page_numbers ) ? $ loop : ($ loop * $ this ->per_page ) - $ this ->per_page ;
620
651
621
- $ attributes = sprintf ('%s %s="%d" ' , $ this ->_attributes , $ this ->data_page_attr , $ loop );
652
+ $ attributes = sprintf ('%s %s="%d" ' , $ this ->_attributes , $ this ->data_page_attr , ( int ) $ i );
622
653
623
654
if ($ i >= $ base_page )
624
655
{
@@ -636,19 +667,28 @@ public function create_links()
636
667
else
637
668
{
638
669
$ append = $ this ->prefix .$ i .$ this ->suffix ;
639
- $ output .= $ this ->num_tag_open .'<a href=" ' .$ base_url .$ append .'" ' .$ attributes .'> '
670
+ $ output .= $ this ->num_tag_open .'<a href=" ' .$ base_url .$ append .'" ' .$ attributes .$ this -> _attr_rel ( ' start ' ). '> '
640
671
.$ loop .'</a> ' .$ this ->num_tag_close ;
641
672
}
673
+
642
674
}
643
675
}
676
+
677
+ /*
678
+ * On pages before last, show dots
679
+ */
680
+ if ($ end < ($ num_pages -1 )) {
681
+ $ output .= '<div class="continues">. . .</div> ' ;
682
+ }
683
+
644
684
}
645
685
646
686
// Render the "next" link
647
687
if ($ this ->next_link !== false && $ this ->cur_page < $ num_pages )
648
688
{
649
689
$ i = ($ this ->use_page_numbers ) ? $ this ->cur_page + 1 : $ this ->cur_page * $ this ->per_page ;
650
690
651
- $ attributes = sprintf ('%s %s="%d" ' , $ this ->_attributes , $ this ->data_page_attr , $ this -> cur_page + 1 );
691
+ $ attributes = sprintf ('%s %s="%d" ' , $ this ->_attributes , $ this ->data_page_attr , ( int ) $ i );
652
692
653
693
$ output .= $ this ->next_tag_open .'<a href=" ' .$ base_url .$ this ->prefix .$ i .$ this ->suffix .'" ' .$ attributes
654
694
.$ this ->_attr_rel ('next ' ).'> ' .$ this ->next_link .'</a> ' .$ this ->next_tag_close ;
@@ -662,13 +702,12 @@ public function create_links()
662
702
663
703
}
664
704
665
-
666
- // Render the "Last" link
705
+ // Render the "last" link
667
706
if ($ this ->last_link !== false && ($ this ->cur_page + $ this ->num_links + ! $ this ->num_links ) < $ num_pages )
668
707
{
669
708
$ i = ($ this ->use_page_numbers ) ? $ num_pages : ($ num_pages * $ this ->per_page ) - $ this ->per_page ;
670
709
671
- $ attributes = sprintf ('%s %s="%d" ' , $ this ->_attributes , $ this ->data_page_attr , $ num_pages );
710
+ $ attributes = sprintf ('%s %s="%d" ' , $ this ->_attributes , $ this ->data_page_attr , ( int ) $ i );
672
711
673
712
$ output .= $ this ->last_tag_open .'<a href=" ' .$ base_url .$ this ->prefix .$ i .$ this ->suffix .'" ' .$ attributes .'> '
674
713
.$ this ->last_link .'</a> ' .$ this ->last_tag_close ;
0 commit comments