Skip to content
Browse files

apply diff from zf1 r22300, and use ClassLoader's load IN factory ins…

…teadof broker's load
  • Loading branch information...
1 parent 721cd66 commit df53edde76e4ee96e7c09a3190666d112b56e9fd @sasezaki committed Jun 1, 2011
Showing with 39 additions and 4 deletions.
  1. +38 −4 library/Zend/Paginator/Paginator.php
  2. +1 −0 library/Zend/Paginator/SerializableLimitIterator.php
View
42 library/Zend/Paginator/Paginator.php
@@ -77,6 +77,15 @@ class Paginator implements \Countable, \IteratorAggregate
protected static $_defaultItemCountPerPage = 10;
/**
+ * Default number of local pages (i.e., the number of discretes
+ * page numbers that will be displayed, including the current
+ * page number)
+ *
+ * @var int
+ */
+ protected static $_defaultPageRange = 10;
+
+ /**
* Scrolling style plugin loader
*
* @var ScrollingStyleBroker
@@ -91,7 +100,7 @@ class Paginator implements \Countable, \IteratorAggregate
protected static $_cache;
/**
- * Enable or desable the cache by Zend_Paginator instance
+ * Enable or disable the cache by Zend_Paginator instance
*
* @var bool
*/
@@ -152,7 +161,7 @@ class Paginator implements \Countable, \IteratorAggregate
*
* @var integer
*/
- protected $_pageRange = 10;
+ protected $_pageRange = null;
/**
* Pages
@@ -201,7 +210,8 @@ public static function factory($data, $adapter = self::INTERNAL_ADAPTER,
}
$broker = self::getAdapterBroker();
- $adapter = $broker->load($adapter, array($data));
+ $adapterClass = $broker->getClassLoader()->load($adapter);
+ $adapter = new $adapterClass($data);
return new self($adapter);
}
@@ -300,6 +310,26 @@ public static function setDefaultItemCountPerPage($count)
}
/**
+ * Get the default page range
+ *
+ * @return int
+ */
+ public static function getDefaultPageRange()
+ {
+ return self::$_defaultPageRange;
+ }
+
+ /**
+ * Set the default page range
+ *
+ * @param int $count
+ */
+ public static function setDefaultPageRange($count)
+ {
+ self::$_defaultPageRange = (int) $count;
+ }
+
+ /**
* Sets a cache object
*
* @param \Zend\Cache\Frontend\Core $cache
@@ -719,6 +749,10 @@ public function getIterator()
*/
public function getPageRange()
{
+ if (null === $this->_pageRange) {
+ $this->_pageRange = self::getDefaultPageRange();
+ }
+
return $this->_pageRange;
}
@@ -939,7 +973,7 @@ protected function _getCacheId($page = null)
protected function _getCacheInternalId()
{
return md5(serialize(array(
- spl_object_hash($this->getAdapter()),
+ $this->getAdapter(),
$this->getItemCountPerPage()
)));
}
View
1 library/Zend/Paginator/SerializableLimitIterator.php
@@ -128,6 +128,7 @@ public function offsetExists($offset)
return null !== $current;
} catch (\OutOfBoundsException $e) {
// reset position in case of exception is assigned null
+ $this->rewind();
$this->seek($currentOffset);
return false;
}

0 comments on commit df53edd

Please sign in to comment.
Something went wrong with that request. Please try again.