Skip to content

Commit 0e86cad

Browse files
author
modbot
committed
2.0.0
1 parent 56a962f commit 0e86cad

17 files changed

+568
-2
lines changed

README.md

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
1-
# Flexible-PHP-Pagination
2-
1+
# Flexible PHP Pagination
2+
3+
The Flexible PHP pagination class was designed to be the easiest to use PHP Pagination system without losing any customization options.
4+
5+
## Get Started:
6+
- [Documentation](https://github.com/Modularr/Flexible-PHP-Pagination/wiki/Documentation "Flexible PHP Pagination Documentation")
7+
- [Demo](https://github.com/Modularr/Flexible-PHP-Pagination/blob/master/demo/alloptions.php)
8+
- [Changelog](https://github.com/Modularr/Flexible-PHP-Pagination/wiki/Changelog "Flexible PHP Pagination Changelog")
9+
10+
## Features
11+
- Flexible
12+
- Easy to use
13+
- Highly customizable
14+
- [Well documented](https://github.com/Modularr/Flexible-PHP-Pagination/wiki/Documentation "Flexible PHP Pagination Documentation")
15+
- [Themeable](https://github.com/Modularr/Flexible-PHP-Pagination/wiki/Documentation#themes)
16+
- [Languages](https://github.com/Modularr/Flexible-PHP-Pagination/wiki/Documentation#translated-text)
17+
- [SEO](https://github.com/Modularr/Flexible-PHP-Pagination/wiki/Documentation#search-engine-optimized-links)

composer.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "modularr/flexible-php-pagination",
3+
"type": "library",
4+
"description": "The Flexible PHP pagination class was designed to be the easiest to use PHP Pagination system without losing any customization options.",
5+
"keywords": ["php","pagination"],
6+
"license": "UNLICENSE",
7+
"autoload": {
8+
"classmap": ["pagination.php"]
9+
}
10+
}

demo/.htaccess

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
RewriteEngine On
2+
RewriteBase /pagination/
3+
4+
RewriteRule ^seo/page-(.*)/ seo.php?p=$1 [L]
5+
RewriteRule ^seo/ seo.php [L]

demo/alloptions.php

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
include('config.php');
3+
4+
$max = 6;
5+
$select = "SELECT * FROM test";
6+
$query1 = mysql_query($select) or die( mysql_error() );
7+
$total = mysql_num_rows($query1);
8+
9+
$nav = new Pagination($max, $total);
10+
$nav->page = $_GET['p'];
11+
12+
$query2 = mysql_query($select." LIMIT ".$nav->start().",".$max) or die(mysql_error());
13+
while($item = mysql_fetch_object($query2))
14+
{
15+
echo $item->id . ' - <b>' . $item->name . '</b><br />';
16+
}
17+
18+
$nav->url = 'alloptions.php?p=';
19+
20+
echo $nav->first(' <a href="{url}{nr}"><<</a> | ', ' << | ');
21+
22+
echo $nav->previous(' <a href="{url}{nr}">Previous</a> | ', ' Previous | ');
23+
24+
echo $nav->numbers(' <a href="{url}{nr}">{nr}</a> | ', ' <b>{nr}</b> | ');
25+
26+
echo $nav->next(' <a href="{url}{nr}">Next</a> | ', ' Next | ');
27+
28+
echo $nav->last(' <a href="{url}{nr}">>></a> | ', ' >> | ');
29+
30+
echo $nav->info('Result {start} to {end} of {total} - ');
31+
32+
echo $nav->info('Page {page} of {pages} ');

demo/arrays.php

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
# Function can be found at https://gist.github.com/3636901
3+
$topics = fetchTopics(1); # Returns an XML resultset using simplexml_load_string (works like an array)
4+
5+
$max = 5; # Set the maximum number of results per page
6+
$total = count($topics); # Count the amount of returned results
7+
$maxNum = 7;
8+
9+
# We Need to know for pagination, our Maximum per page, and our Total, and an optional Parameter
10+
$nav = new Pagination($max, $total, $maxNum, 'page');
11+
$link = 'forum.php?id='.htmlspecialchars($_GET['id']).'&page={nr}';
12+
?>
13+
<table cellspacing="0" width="100%">
14+
<thead>
15+
<tr>
16+
<th align="left">Subject</th>
17+
<th class="center">Autor</th>
18+
<th class="center">Replies</th>
19+
<th>Date</th>
20+
</tr>
21+
</thead>
22+
<tfoot>
23+
<tr>
24+
<td colspan="5">
25+
<span>Showing <?php echo $nav->info('{start} - {end} of {total}'); ?> threads</span>
26+
<?php
27+
echo $nav->first(' <a href="'.$link.'">First</a> ', ' <strong>First</strong> ');
28+
echo $nav->previous(' <a href="'.$link.'">&laquo;</a> ', ' <strong>&laquo;</strong> ');
29+
echo $nav->numbers(' <a href="'.$link.'">{nr}</a> ', ' <strong>{nr}</strong> ');
30+
echo $nav->next(' <a href="'.$link.'">&raquo;</a> ', ' <strong>&raquo;</strong> ');
31+
echo $nav->last(' <a href="'.$link.'">Last</a> ', ' <strong>Last</strong> ');
32+
?>
33+
</td>
34+
</tr>
35+
</tfoot>
36+
<tbody>
37+
<?php
38+
foreach($topics as $topic)
39+
{
40+
# This code limits the returned results to fit the navigation
41+
if( $nav->paginator() )
42+
{
43+
echo '<tr>
44+
<td> <img src="css/images/icons/knewstuff.png"> &nbsp; <strong><a class="title" href="topic.php?id='.$topic->id.'">'.$topic->title.'</a></strong></td>
45+
<td class="center"><font color="#FF0000">'.username($topic->author).'</font></td>
46+
<td class="center">0</td>
47+
<td class="thread_lastentry">
48+
<small>08-07-2012 12:28:57</small>
49+
</td>
50+
</tr>';
51+
}
52+
}
53+
?>
54+
</tbody>
55+
</table>

demo/config.php

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
error_reporting(E_WARNING);
3+
4+
# Connect To Database
5+
mysql_connect('localhost', 'root', 'root')or die(mysql_error());
6+
mysql_select_db('test')or die(mysql_error());
7+
8+
# Include Pagination Class
9+
include('../pagination.php');
10+
11+
# Display Links for Demo Purposes (not required)
12+
include('links.html');

demo/customdesign.php

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<style>
2+
#tnt_pagination {
3+
display:block;
4+
text-align:left;
5+
height:22px;
6+
line-height:21px;
7+
clear:both;
8+
padding-top:3px;
9+
font-family:Arial, Helvetica, sans-serif;
10+
font-size:12px;
11+
font-weight:normal;
12+
}
13+
14+
#tnt_pagination a:link, #tnt_pagination a:visited{
15+
padding:7px;
16+
padding-top:2px;
17+
padding-bottom:2px;
18+
border:1px solid #EBEBEB;
19+
margin-left:10px;
20+
text-decoration:none;
21+
background-color:#F5F5F5;
22+
color:#0072bc;
23+
width:22px;
24+
font-weight:normal;
25+
}
26+
27+
#tnt_pagination a:hover {
28+
background-color:#DDEEFF;
29+
border:1px solid #BBDDFF;
30+
color:#0072BC;
31+
}
32+
33+
#tnt_pagination .active_tnt_link {
34+
padding:7px;
35+
padding-top:2px;
36+
padding-bottom:2px;
37+
border:1px solid #BBDDFF;
38+
margin-left:10px;
39+
text-decoration:none;
40+
background-color:#DDEEFF;
41+
color:#0072BC;
42+
cursor:default;
43+
}
44+
45+
#tnt_pagination .disabled_tnt_pagination {
46+
padding:7px;
47+
padding-top:2px;
48+
padding-bottom:2px;
49+
border:1px solid #EBEBEB;
50+
margin-left:10px;
51+
text-decoration:none;
52+
background-color:#F5F5F5;
53+
color:#D7D7D7;
54+
cursor:default;
55+
}
56+
#embed {
57+
padding-top:7px;
58+
}
59+
</style>
60+
61+
Note: This CSS design is freely available here:<a href="http://www.thewebhelp.com/css/pagination-style-template/">Pagination Style Template</a><br />
62+
And does not belong to me. All credit for the design goes to this author.<br />
63+
<br />
64+
<?php
65+
include('config.php');
66+
67+
$max = 6;
68+
$select = "SELECT * FROM test";
69+
$query1 = mysql_query($select) or die( mysql_error() );
70+
$total = mysql_num_rows($query1);
71+
72+
$nav = new Pagination($max, $total);
73+
74+
$query2 = mysql_query($select." LIMIT ".$nav->start().",".$max) or die(mysql_error());
75+
while($item = mysql_fetch_object($query2))
76+
{
77+
echo $item->id . ' - <b>' . $item->name . '</b><br />';
78+
}
79+
80+
$link = 'customdesign.php?p=';
81+
82+
echo '<div id="tnt_pagination">';
83+
echo $nav->first('<a href="'.$link.'{nr}">First</a>') . $nav->previous('<a href="'.$link.'{nr}">&laquo; prev</a>');
84+
85+
echo $nav->numbers('<a href="'.$link.'{nr}">{nr}</a>', '<span class="active_tnt_link">{nr}</span>');
86+
87+
echo $nav->next('<a href="'.$link.'{nr}">Next &raquo;</a>') . $nav->last('<a href="'.$link.'{nr}">Last</a>') .
88+
$nav->info('<br /><div id="embed"><span class="active_tnt_link">Result {start} to {end} of {total}</span>') . $nav->info('<span class="active_tnt_link">Page {page} of {pages}</span></div>');
89+
90+
echo '</div>';

demo/dutch.php

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
include('config.php');
3+
4+
$max = 6;
5+
$select = "SELECT * FROM test";
6+
$query1 = mysql_query($select) or die( mysql_error() );
7+
$total = mysql_num_rows($query1);
8+
9+
$nav = new Pagination($max, $total);
10+
11+
$query2 = mysql_query($select." LIMIT ".$nav->start().",".$max) or die(mysql_error());
12+
while($item = mysql_fetch_object($query2))
13+
{
14+
echo $item->id . ' - <b>' . $item->name . '</b><br />';
15+
}
16+
17+
$link = 'dutch.php?p=';
18+
19+
//echo $nav->first(' <a href="'.$link.'{nr}">First</a> | ');
20+
21+
echo $nav->previous(' <a href="'.$link.'{nr}">Vorige</a> | ');
22+
23+
echo $nav->numbers(' <a href="'.$link.'{nr}">{nr}</a> | ', ' <b>{nr}</b> | ');
24+
25+
echo $nav->next(' <a href="'.$link.'{nr}">Volgende</a> | ');
26+
27+
//echo $nav->last(' <a href="'.$link.'{nr}">Last</a>');
28+
29+
echo $nav->info('Pagina {page} van de {pages} ');

demo/index.php

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
include('links.html');

demo/links.html

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Examples of Flexible PHP Pagination<br />
2+
<br />
3+
- <a href="normal.php">Normal</a>
4+
- <a href="seo/">Seo Optimized Links</a>
5+
- <a href="dutch.php">Translated Links</a>
6+
- <a href="alloptions.php">All Options</a>
7+
- <a href="customdesign.php">Custom Design</a>
8+
- <a href="theme.php">Themes</a><br />
9+
<br /><br />

demo/normal.php

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
include('config.php');
3+
4+
$max = 6;
5+
$select = "SELECT * FROM test";
6+
$query1 = mysql_query($select) or die( mysql_error() );
7+
$total = mysql_num_rows($query1);
8+
9+
$nav = new Pagination($max, $total, $_GET['p']);
10+
11+
$nav->url = 'normal.php?p=';
12+
13+
$query2 = mysql_query($select." LIMIT ".$nav->start().",".$max) or die(mysql_error());
14+
while($item = mysql_fetch_object($query2))
15+
{
16+
echo $item->id . ' - <b>' . $item->name . '</b><br />';
17+
}
18+
19+
echo $nav->get_html();

demo/seo.php

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<base href="http://demo.reconnect-inc.com/pagination/seo/">
2+
<?php
3+
include('config.php');
4+
5+
$max = 6;
6+
$select = "SELECT * FROM test";
7+
$query1 = mysql_query($select) or die( mysql_error() );
8+
$total = mysql_num_rows($query1);
9+
10+
$nav = new Pagination($max, $total);
11+
12+
$query2 = mysql_query($select." LIMIT ".$nav->start().",".$max) or die(mysql_error());
13+
while($item = mysql_fetch_object($query2))
14+
{
15+
echo $item->id . ' - <b>' . $item->name . '</b><br />';
16+
}
17+
18+
$link = './page-{nr}/';
19+
20+
echo $nav->previous(' <a href="'.$link.'">Previous</a> | ');
21+
22+
echo $nav->numbers(' <a href="'.$link.'">{nr}</a> | ', ' <b>{nr}</b> | ');
23+
24+
echo $nav->next(' <a href="'.$link.'">Next</a> | ');

demo/theme.php

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
include('config.php');
3+
4+
echo '<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
5+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
6+
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>';
7+
8+
$max = 6;
9+
$select = "SELECT * FROM test";
10+
$query1 = mysql_query($select) or die( mysql_error() );
11+
$total = mysql_num_rows($query1);
12+
13+
$nav = new Pagination($max, $total, $_GET['p']);
14+
15+
$nav->url = 'theme.php?p=';
16+
17+
$query2 = mysql_query($select." LIMIT ".$nav->start().",".$max) or die(mysql_error());
18+
while($item = mysql_fetch_object($query2))
19+
{
20+
echo $item->id . ' - <b>' . $item->name . '</b><br />';
21+
}
22+
23+
echo $nav->get_html('../themes/bootstrap');

0 commit comments

Comments
 (0)