cvs: pear /Pager Pager.php package.xml
| From: | Richard Heyes | Date: | Sat, 01 Jun 2002 22:00:22 +0000 |
| Subject: | cvs: pear /Pager Pager.php package.xml | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-4343@lists.php.net to get a copy of this message | ||
richard Sat Jun 1 18:00:22 2002 EDT
Modified files:
/pear/Pager Pager.php package.xml
Log:
* Applied patch from Christian Dickmann adding getCurrentPage(), numItems()
and optional CSS class for links.
Index: pear/Pager/Pager.php
diff -u pear/Pager/Pager.php:1.2 pear/Pager/Pager.php:1.3
--- pear/Pager/Pager.php:1.2 Mon May 27 13:37:17 2002
+++ pear/Pager/Pager.php Sat Jun 1 18:00:22 2002
@@ -25,6 +25,12 @@
class Pager {
/**
+ * CSS class of the links
+ * @var string
+ */
+ var $_linkClass;
+
+ /**
* Current page
* @var integer
*/
@@ -68,6 +74,7 @@
* @param $params An associative array of parameters This can contain:
* currentPage Current Page number (optional)
* perPage Items per page (optional)
+ * linkClass CSS class of the links (optional)
* itemData Data to page
*/
function pager($params = array())
@@ -170,6 +177,26 @@
}
/**
+ * Returns number of current page
+ *
+ * @return int Number of current page
+ */
+ function getCurrentPage()
+ {
+ return $this->_currentPage;
+ }
+
+ /**
+ * Returns number of items
+ *
+ * @return int Number of items
+ */
+ function numItems()
+ {
+ return $this->_totalItems;
+ }
+
+ /**
* Returns number of pages
*
* @return int Number of pages
@@ -240,7 +267,7 @@
// Sort out query string to prevent messy urls
$querystring = array();
- $qs = array();
+ $qs = array();
if (!empty($HTTP_SERVER_VARS['QUERY_STRING'])) {
$qs = explode('&', $HTTP_SERVER_VARS['QUERY_STRING']);
for ($i = 0, $cnt = count($qs); $i < $cnt; $i++) {
@@ -270,7 +297,11 @@
{
// Back link
if ($this->_currentPage > 1) {
- $back = '<a href="' . $url . ($this->_currentPage - 1) .
'">' . $link . '</a>';
+ $back = sprintf('<a href="%s%d" %s>%s</a>',
+ $url,
+ $this->_currentPage - 1,
+ $this->_linkClass != '' ? 'class="' .
$this->_linkClass . '"' : '',
+ $link);
} else {
$back = '';
}
@@ -310,7 +341,11 @@
function _getNextLink($url, $link = 'Next >>')
{
if ($this->_currentPage < $this->_totalPages) {
- $next = '<a href="' . $url . ($this->_currentPage + 1) .
'">' . $link . '</a>';
+ $next = sprintf('<a href="%s%d" %s>%s</a>',
+ $url,
+ $this->_currentPage + 1,
+ $this->_linkClass != '' ? 'class="' .
$this->_linkClass . '"' : '',
+ $link);
} else {
$next = '';
}
Index: pear/Pager/package.xml
diff -u pear/Pager/package.xml:1.2 pear/Pager/package.xml:1.3
--- pear/Pager/package.xml:1.2 Sun Feb 17 09:47:29 2002
+++ pear/Pager/package.xml Sat Jun 1 18:00:22 2002
@@ -1,35 +1,76 @@
-<?xml version="1.0" encoding="ISO-8859-1" ?>
-<!DOCTYPE package SYSTEM "../package.dtd">
-<package version="1.0">
- <name>Pager</name>
- <summary>Generic data paging class</summary>
- <description>
- If you have data that needs paging (ie 1-10 on page one, 11-20 on page two)
- this class can help. Pass it an array of data and it will sort it into pages,
- picking up the current page id from the url. It can also give you back/next
- and page number links taking the current url and adding the correct page id
- to it.
- </description>
- <maintainers>
- <maintainer>
- <user>heyesr</user>
- <name>Richard Heyes</name>
- <email>heyesr@php.net</email>
- <role>lead</role>
- </maintainer>
- </maintainers>
- <release>
- <version>1.0</version>
- <date>2002-02-09</date>
- <state>stable</state>
- <notes>
- This is the initial release of the Pager package.
- </notes>
- <filelist>
- <dir name="/" baseinstalldir="Pager">
- <file role="php">Pager.php</file>
- <file role="php">example.php</file>
- </dir>
- </filelist>
- </release>
-</package>
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE package SYSTEM "../package.dtd">
+<package version="1.0">
+
+ <name>Pager</name>
+ <license>PHP</license>
+ <summary>Generic data paging class</summary>
+ <description>
+ If you have data that needs paging (ie 1-10 on page one, 11-20 on page two)
+ this class can help. Pass it an array of data and it will sort it into pages,
+ picking up the current page id from the url. It can also give you back/next
+ and page number links taking the current url and adding the correct page id
+ to it.
+ </description>
+
+ <maintainers>
+ <maintainer>
+ <user>richard</user>
+ <name>Richard Heyes</name>
+ <email>richard@php.net</email>
+ <role>lead</role>
+ </maintainer>
+ </maintainers>
+* No longer barfs with no querystring
+* Now works with associative data array
+
+ <release>
+ <version>1.0.2</version>
+ <date>2002-05-31</date>
+ <state>stable</state>
+ <notes>
+ Applied patch from Christian Dickmann adding getCurrentPage(), numItems()
+ and optional CSS class for links.
+ </notes>
+ <filelist>
+ <dir name="/" baseinstalldir="Pager">
+ <file role="php" name="Pager.php" />
+ <file role="php" name="example.php" />
+ </dir>
+ </filelist>
+ </release>
+
+ <changelog>
+ <release>
+ <version>1.0.1</version>
+ <date>2002-05-27</date>
+ <state>stable</state>
+ <notes>
+ o No longer barfs with no querystring
+ o Now works with associative data array
+ </notes>
+ <filelist>
+ <dir name="/" baseinstalldir="Pager">
+ <file role="php" name="Pager.php" />
+ <file role="php" name="example.php" />
+ </dir>
+ </filelist>
+ </release>
+
+ <release>
+ <version>1.0</version>
+ <date>2002-02-09</date>
+ <state>stable</state>
+ <notes>
+ This is the initial release of the Pager package.
+ </notes>
+ <filelist>
+ <dir name="/" baseinstalldir="Pager">
+ <file role="php" name="Pager.php" />
+ <file role="php" name="example.php" />
+ </dir>
+ </filelist>
+ </release>
+ </changelog>
+
+</package>