PHP Classes
elePHPant
Icontem

eoPaginator: Generate navigation for listings split among pages

Recommend this page to a friend!
  Info   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2009-11-23 (6 years ago) RSS 2.0 feedNot yet rated by the usersTotal: 278 All time: 7,175 This week: 1,486Up
Version License PHP version Categories
eopaginator 1.0BSD License5.2HTML, PHP 5
Description Author

This class can be used to generate navigation for listings split among pages.

It takes as parameters the total number of entries in the listing, the limit of entries displayed per page and the number of the current page.

The class generates HTML links to go to the next, previous, first, last and any intermediate pages.

Picture of Eugene Olkhovick
Name: Eugene Olkhovick <contact>
Classes: 1 package by
Country: Ukraine Ukraine

Details
@ Class: 	eoPaginator
@ Description:	Class provides pagination bar output in three diffrent manners.


    This is a small and simple class that can be used to compose navigation links 
bar for paginated displaying of some data arrays.The class provides three different 
modes of page links output: shifting mode, sliding mode and intersection mode, 
which require session mechanism is to be used.


     array make_pgr(int rec_total,int cur_page>) -
     
     function get two parameters: 
     rec_total - total amount of records in a table or array;
     cur_page -  curren page number;
         Function returns an array of <a> elements.      
	 
     All other variable described in class file.
     
     Little example file "example.php" shows how you can use eoPaginator class.
     

     It is necessary to describe conceptions of provided modes:

    
     Shift mode
     ==========
        For example you get first interval of available pages, limited by <max_pages> parameter. 
     In our case max_pages=5 (for example), so we have element range from 1 to 5:
     |1|2|3|4|5| > >>
        When you click on last element in this range, |5| in our case, the next range of links will appear: 
     << < |6|7|8|9|10| > >>
     So we have next 5 (max_pages, remember ???) elements, now from 6 to 10.
     And so on....

     
     Slide mode
     ==========
        That's trivial... Current page link will always been showed in the middle of the range, begining 
     from central element of the first page range. So, when you click on the next page link after the central,
     all range will be shifted right or left accordingly.
     |1|2|3|4|5| > >>
    	 ---        
	  ^ - central element of this range.
               -    	     
     << < |2|3|4|5|6| > >> - that's what you will see if you click on |4| element of previous range. 
     Current page is - 4. Now click to |5|
               -
	       -     
     << < |3|4|5|6|7| > >> - Current page is - 5.
	       -
      So, as you can see, current page is always in the middle position.

      
      Intersection mode
      =================
      Every following page diapason intersect with previous one with predefined overlap.
      For example, traditionally first range, <overlap> parameter = 2:
      |1|2|3|4|5| > >> - click on last range element |5| will couse appearence of the next range
      << < |4|5|6|7|8| > >> 
	    ---
	     | - first two elements of new range is in one's turn last two (2 - is our overlap value)
	         elements of previous one
	    	 Now let's click |8|.
      << < |7|8|9|10|11| > >> 
    	    ---
    	     | - first two elements equals to last elements of previous range.
	     
      Obviously, in a case when the same element can be in two ranges at one time, it is necessary
      to know wich one to show when this element will be clicked. Session variable is used for
      storing number of current page range. If selected page number is in the lowest range, 
      highest range will be shown and vice-versa.
      
	The class is not perferct, so I'm ready to comments, critic and suggestion about how to make
      it better.	       
        
			     
	     
	     
	     
	     
	     	
    

  Files folder image Files  
File Role Description
Accessible without login Plain text file db_example.php Example Example of eoPaginator+MySQL usage
Plain text file eoPaginator.php Class eoPaginator class file
Accessible without login Plain text file example.php Example Example of eoPaginator class usage
Accessible without login Plain text file readme Doc. Readme file about eoPaginator class
Accessible without login Plain text file tb_cars.sql Conf. SQL dump for playing with db_example.php

 Version Control Unique User Downloads Download Rankings  
 0%
Total:278
This week:0
All time:7,175
This week:1,486Up