| Under Construction This proposal is being merged with http://framework.zend.com/wiki/display/ZFPROP/Zend_Paginate+-+Jurriën+Stutterheim+and+Matthew+Ratzloff |
Zend Framework: Zend_Paginator - Matthew Ratzloff Component Proposal
| Proposed Component Name | Zend_Paginator - Matthew Ratzloff |
|---|---|
| Developer Notes | http://framework.zend.com/wiki/display/ZFDEV/Zend_Paginator - Matthew Ratzloff |
| Proposers | Matthew Ratzloff Darby Felton, Zend liaison |
| Revision | 0.1 - First version (wiki revision: 7) |
Table of Contents
1. Overview
Zend_Paginator is a pagination class for both database- and view-level pagination. Users supply a page number and an optional configuration object and the rest is handled more or less seamlessly. The database strategy is the default, but view-level pagination can be selected in the options. For database pagination, users should have their models implement Zend_Paginator_Pageable_Interface.
Disclaimer: This is something I threw together over a couple of hours on Christmas Eve. I haven't coded anything yet, so I'm not sure if everything would work exactly as currently described. I really should probably finish all my other proposals and not-yet-proposals before I create another proposal, but this is something that a lot of people probably need right away.
2. References
I really wasn't impressed with any other pagination implementations I came across. In general, they were just too limiting.
3. Component Requirements, Constraints, and Acceptance Criteria
- This component will paginate database and arbitrary result sets.
- This component will be flexible enough to allow users to implement any page-to-page navigation they like.
- This component will not be a one-size-fits-all solution. That means that there may be a little more work involved on the part of the user when initially incorporating this class into their project.
4. Dependencies on Other Framework Components
- Zend_Exception
- Zend_Db
- Probably not Zend_View (but we'll see)
5. Theory of Operation
6. Milestones / Tasks
- Milestone 1: Proposal is finished.
- Milestone 2: Working prototype checked into the incubator supporting use cases #1, #2, ...
- Milestone 3: Working prototype checked into the incubator supporting use cases #3 and #4.
- Milestone 4: Unit tests exist, work, and are checked into SVN.
- Milestone 5: Initial documentation exists.
7. Class Index
- Zend_Paginator
- Zend_Paginator_Exception
- Zend_Paginator_Page
- Zend_Paginator_Pageable_Interface
- Zend_Paginator_Strategy_Db
- Zend_Paginator_Strategy_View
8. Use Cases
| UC-01 |
|---|
Database-level pagination example
Controller:
Model (which implements Zend_Paginator_Pageable_Interface):
View (page_selector.php partial):
| UC-02 |
|---|
View-level pagination example
Controller:
View (page_selector.php partial):
9. Class Skeletons
Here's a partial list. This includes the public methods.
2 Comments
comments.show.hideDec 24, 2007
Matthew Ratzloff
Two comments to get any design discussion rolling:
1. I'd like the DB strategy to return a statement and the view strategy to return some sort of array-like object (like a Rowset). I'd like them to have the same name, but that might be unfeasible... so I may have to end up stretching the concept of the Strategy pattern and just pass through variously-named strategy methods with __call().
2. I don't like the fact that the Paginator object is implicitly modified by the view (and I especially don't like the fact that a change takes place to the object when calling a get*() method--see above for a possible solution).
Mar 17, 2008
Jurrien Stutterheim
For the Zym project (www.zym-project.com) I wrote a pagination component myself.
It exists of an abstract class and three concrete classes (for arrays, Iterator instances and Db_Table instances).
I didn't use a separate Page class for Zym_Paginate, because I didn't see any added value over an array/(Limit)Iterator or Row_Set. Please have a look at Zym_Paginate and let me know what you think.
As for the idea of a pagination component in general: it's got my vote