cvs: pear /Pager_Sliding Sliding.php
| From: | Lorenzo Alberton | Date: | Fri, 13 Dec 2002 10:10:54 +0000 |
| Subject: | cvs: pear /Pager_Sliding Sliding.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-7871@lists.php.net to get a copy of this message | ||
quipo Fri Dec 13 05:10:54 2002 EDT
Modified files:
/pear/Pager_Sliding Sliding.php
Log:
Added a $pageID parameter to getLinks() method as suggested by Fabien Marty.
If you specify a page number to getLinks() method, now links are built according to that page,
taken as it were the current one.
Index: pear/Pager_Sliding/Sliding.php
diff -u pear/Pager_Sliding/Sliding.php:1.1 pear/Pager_Sliding/Sliding.php:1.2
--- pear/Pager_Sliding/Sliding.php:1.1 Sun Dec 8 07:08:40 2002
+++ pear/Pager_Sliding/Sliding.php Fri Dec 13 05:10:53 2002
@@ -15,7 +15,7 @@
// | Author: Lorenzo Alberton <l.alberton at quipo.it> |
// +----------------------------------------------------------------------+
//
-// $Id: Sliding.php,v 1.1 2002/12/08 12:08:40 quipo Exp $
+// $Id: Sliding.php,v 1.2 2002/12/13 10:10:53 quipo Exp $
/**
* Pager_Sliding - Sliding Window Pager
@@ -23,7 +23,7 @@
* Usage examples can be found in the doc provided
*
* @author Lorenzo Alberton <l.alberton at quipo.it>
- * @version $Id: Sliding.php,v 1.1 2002/12/08 12:08:40 quipo Exp $
+ * @version $Id: Sliding.php,v 1.2 2002/12/13 10:10:53 quipo Exp $
*/
define('CURRENT_FILENAME', basename($_SERVER['PHP_SELF']));
@@ -48,7 +48,7 @@
var $_altPage = 'page';
var $_prevImg = '«';
var $_nextImg = '»';
- var $_expanded = false;
+ var $_expanded = true;
var $_separator = '|';
var $_spacesBeforeSeparator = 3;
var $_spacesAfterSeparator = 3;
@@ -64,8 +64,6 @@
var $_itemData = null;
var $_clearIfVoid = true;
-
-
// }}}
/**
@@ -82,7 +80,6 @@
*/
var $range = array();
-
// {{{ Pager_Sliding()
/**
@@ -344,16 +341,38 @@
* Returns back/next/first/last and page links,
* both as ordered and associative array.
*
+ * @param integer $pageID Optional pageID. If specified, links
+ * for that page are provided instead of current one.
* @return array back/pages/next/first/last/all links
*/
- function getLinks()
+ function getLinks($pageID = null)
{
+ if ($pageID != null) {
+ $_sav = $this->_currentPage;
+ $this->_currentPage = $pageID;
+
+ $this->links = '';
+ if ($this->_totalPages > (2 * $this->_delta + 1)) {
+ $this->links .= $this->_printFirstPage();
+ }
+ $this->links .= $this->_getBackLink();
+ $this->links .= $this->_getPageLinks();
+ $this->links .= $this->_getNextLink();
+ if ($this->_totalPages > (2 * $this->_delta + 1)) {
+ $this->links .= $this->_printLastPage();
+ }
+ }
+
$back = str_replace(' ','', $this->_getBackLink());
$next = str_replace(' ','', $this->_getNextLink());
$pages = $this->_getPageLinks();
$first = $this->_printFirstPage();
$last = $this->_printLastPage();
$all = $this->links;
+
+ if ($pageID != null) {
+ $this->_currentPage = $_sav;
+ }
return array(
$back,