Skip to content

Commit

Permalink
apply diff from zf1 r22300, and use ClassLoader's load IN factory ins…
Browse files Browse the repository at this point in the history
…teadof broker's load
  • Loading branch information
sasezaki committed May 31, 2011
1 parent 721cd66 commit df53edd
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
42 changes: 38 additions & 4 deletions library/Zend/Paginator/Paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,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
*
Expand All @@ -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
*/
Expand Down Expand Up @@ -152,7 +161,7 @@ class Paginator implements \Countable, \IteratorAggregate
*
* @var integer
*/
protected $_pageRange = 10;
protected $_pageRange = null;

/**
* Pages
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -299,6 +309,26 @@ public static function setDefaultItemCountPerPage($count)
self::$_defaultItemCountPerPage = (int) $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
*
Expand Down Expand Up @@ -719,6 +749,10 @@ public function getIterator()
*/
public function getPageRange()
{
if (null === $this->_pageRange) {
$this->_pageRange = self::getDefaultPageRange();
}

return $this->_pageRange;
}

Expand Down Expand Up @@ -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()
)));
}
Expand Down
1 change: 1 addition & 0 deletions library/Zend/Paginator/SerializableLimitIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit df53edd

Please sign in to comment.