diff -r 000000000000 -r 4eba9c11703f web/Zend/Paginator/SerializableLimitIterator.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/Zend/Paginator/SerializableLimitIterator.php Mon Dec 13 18:29:26 2010 +0100 @@ -0,0 +1,142 @@ +_offset = $offset; + $this->_count = $count; + } + + /** + * @return string representation of the instance + */ + public function serialize() + { + return serialize(array( + 'it' => $this->getInnerIterator(), + 'offset' => $this->_offset, + 'count' => $this->_count, + 'pos' => $this->getPosition(), + )); + } + + /** + * @param string $data representation of the instance + */ + public function unserialize($data) + { + $dataArr = unserialize($data); + $this->__construct($dataArr['it'], $dataArr['offset'], $dataArr['count']); + $this->seek($dataArr['pos']+$dataArr['offset']); + } + + /** + * Returns value of the Iterator + * + * @param int $offset + * @return mixed + */ + public function offsetGet($offset) + { + $currentOffset = $this->key(); + $this->seek($offset); + $current = $this->current(); + $this->seek($currentOffset); + return $current; + } + + /** + * Does nothing + * Required by the ArrayAccess implementation + * + * @param int $offset + * @param mixed $value + */ + public function offsetSet($offset, $value) + { + } + + /** + * Determine if a value of Iterator is set and is not NULL + * + * @param int $offset + */ + public function offsetExists($offset) + { + if ($offset > 0 && $offset < $this->_count) { + try { + $currentOffset = $this->key(); + $this->seek($offset); + $current = $this->current(); + $this->seek($currentOffset); + return null !== $current; + } catch (OutOfBoundsException $e) { + // reset position in case of exception is assigned null + $this->rewind(); + $this->seek($currentOffset); + return false; + } + } + return false; + } + + /** + * Does nothing + * Required by the ArrayAccess implementation + * + * @param int $offset + */ + public function offsetUnset($offset) + { + } +}