art-web r519 - branches/art-hub/lib
- From: thos svn gnome org
- To: svn-commits-list gnome org
- Subject: art-web r519 - branches/art-hub/lib
- Date: Sun, 15 Jun 2008 21:52:55 +0000 (UTC)
Author: thos
Date: Sun Jun 15 21:52:55 2008
New Revision: 519
URL: http://svn.gnome.org/viewvc/art-web?rev=519&view=rev
Log:
* Add pagination and template classes
Added:
branches/art-hub/lib/
branches/art-hub/lib/pagination.php
branches/art-hub/lib/template.php
Added: branches/art-hub/lib/pagination.php
==============================================================================
--- (empty file)
+++ branches/art-hub/lib/pagination.php Sun Jun 15 21:52:55 2008
@@ -0,0 +1,70 @@
+<?php
+
+class Paginator
+{
+ var $limit;
+ var $start;
+ var $total;
+
+ function Paginator ($total, $limit, $start)
+ {
+ $this->total = $total;
+ $this->limit = $limit;
+ $this->start = $start;
+ }
+
+ function print_pagination ()
+ {
+ $context = 8;
+
+ $num_pages = $this->total / $this->limit;
+
+ if ($context > $num_pages)
+ $context = $num_pages;
+
+ $cur_page = ceil ($this->start / $this->limit);
+
+ $prev_page = $cur_page - 1;
+ if ($cur_page > 1)
+ {
+ print ("<a href=\"?page=1\">First</a> · ");
+ print ("<a href=\"?page=$prev_page\">Previous</a>");
+ }
+ else
+ {
+ print ("First · ");
+ print ('Previous');
+ }
+
+ $first = max (1, $cur_page - $context / 2);
+ $last = min ($first + $context, $this->total / $this->limit);
+
+ if ($last - $first < $context)
+ $first = max (1, $last - $context);
+
+ for ($i = $first; $i <= $last; $i++)
+ {
+ if ($i == $cur_page)
+ print (" · $i ");
+ else
+ print (" · <a href=\"?page=$i\">$i</a>");
+ }
+
+
+ $next_page = $cur_page + 1;
+ if ($cur_page < $num_pages)
+ {
+ print (" · <a href=\"?page=${next_page}\">Next</a>");
+ print (" · <a href=\"?page=${num_pages}\">Last</a>");
+ }
+ else
+ {
+ print (' · Next');
+ print (" · Last");
+ }
+
+
+ }
+}
+
+?>
Added: branches/art-hub/lib/template.php
==============================================================================
--- (empty file)
+++ branches/art-hub/lib/template.php Sun Jun 15 21:52:55 2008
@@ -0,0 +1,24 @@
+<?php
+
+class Template
+{
+ var $page;
+
+ function Template ($page)
+ {
+ $this->page = $page;
+ }
+
+ function print_header ()
+ {
+ $page = $this->page;
+ include ("templates/header.php");
+ }
+
+ function print_footer ()
+ {
+ include ("templates/footer.php");
+ }
+}
+
+?>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]