r23308 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23307‎ | r23308 | r23309 >
Date:03:16, 24 June 2007
Author:simetrical
Status:old
Tags:
Comment:
Wrap comments at 79 characters, not the particular width the commenter happened to have his screen set to when writing it
Modified paths:
  • /trunk/phase3/includes/Pager.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Pager.php
@@ -12,42 +12,43 @@
1313 /**
1414 * IndexPager is an efficient pager which uses a (roughly unique) index in the
1515 * data set to implement paging, rather than a "LIMIT offset,limit" clause.
16 - * In MySQL, such a limit/offset clause requires counting through the specified number
17 - * of offset rows to find the desired data, which can be expensive for large offsets.
 16+ * In MySQL, such a limit/offset clause requires counting through the
 17+ * specified number of offset rows to find the desired data, which can be
 18+ * expensive for large offsets.
1819 *
19 - * ReverseChronologicalPager is a child class of the abstract IndexPager, and contains
20 - * some formatting and display code which is specific to the use of timestamps as
21 - * indexes. Here is a synopsis of its operation:
 20+ * ReverseChronologicalPager is a child class of the abstract IndexPager, and
 21+ * contains some formatting and display code which is specific to the use of
 22+ * timestamps as indexes. Here is a synopsis of its operation:
2223 *
23 - * * The query is specified by the offset, limit and direction (dir) parameters, in
24 - * addition to any subclass-specific parameters.
 24+ * * The query is specified by the offset, limit and direction (dir)
 25+ * parameters, in addition to any subclass-specific parameters.
 26+ * * The offset is the non-inclusive start of the DB query. A row with an
 27+ * index value equal to the offset will never be shown.
 28+ * * The query may either be done backwards, where the rows are returned by
 29+ * the database in the opposite order to which they are displayed to the
 30+ * user, or forwards. This is specified by the "dir" parameter, dir=prev
 31+ * means backwards, anything else means forwards. The offset value
 32+ * specifies the start of the database result set, which may be either
 33+ * the start or end of the displayed data set. This allows "previous"
 34+ * links to be implemented without knowledge of the index value at the
 35+ * start of the previous page.
 36+ * * An additional row beyond the user-specified limit is always requested.
 37+ * This allows us to tell whether we should display a "next" link in the
 38+ * case of forwards mode, or a "previous" link in the case of backwards
 39+ * mode. Determining whether to display the other link (the one for the
 40+ * page before the start of the database result set) can be done
 41+ * heuristically by examining the offset.
2542 *
26 - * * The offset is the non-inclusive start of the DB query. A row with an index value
27 - * equal to the offset will never be shown.
 43+ * * An empty offset indicates that the offset condition should be omitted
 44+ * from the query. This naturally produces either the first page or the
 45+ * last page depending on the dir parameter.
2846 *
29 - * * The query may either be done backwards, where the rows are returned by the database
30 - * in the opposite order to which they are displayed to the user, or forwards. This is
31 - * specified by the "dir" parameter, dir=prev means backwards, anything else means
32 - * forwards. The offset value specifies the start of the database result set, which
33 - * may be either the start or end of the displayed data set. This allows "previous"
34 - * links to be implemented without knowledge of the index value at the start of the
35 - * previous page.
 47+ * Subclassing the pager to implement concrete functionality should be fairly
 48+ * simple, please see the examples in PageHistory.php and
 49+ * SpecialIpblocklist.php. You just need to override formatRow(),
 50+ * getQueryInfo() and getIndexField(). Don't forget to call the parent
 51+ * constructor if you override it.
3652 *
37 - * * An additional row beyond the user-specified limit is always requested. This allows
38 - * us to tell whether we should display a "next" link in the case of forwards mode,
39 - * or a "previous" link in the case of backwards mode. Determining whether to
40 - * display the other link (the one for the page before the start of the database
41 - * result set) can be done heuristically by examining the offset.
42 - *
43 - * * An empty offset indicates that the offset condition should be omitted from the query.
44 - * This naturally produces either the first page or the last page depending on the
45 - * dir parameter.
46 - *
47 - * Subclassing the pager to implement concrete functionality should be fairly simple,
48 - * please see the examples in PageHistory.php and SpecialIpblocklist.php. You just need
49 - * to override formatRow(), getQueryInfo() and getIndexField(). Don't forget to call the
50 - * parent constructor if you override it.
51 - *
5253 * @addtogroup Pager
5354 */
5455 abstract class IndexPager implements Pager {
@@ -75,9 +76,9 @@
7677 global $wgRequest, $wgUser;
7778 $this->mRequest = $wgRequest;
7879
79 - # NB: the offset is quoted, not validated. It is treated as an arbitrary string
80 - # to support the widest variety of index types. Be careful outputting it into
81 - # HTML!
 80+ # NB: the offset is quoted, not validated. It is treated as an
 81+ # arbitrary string to support the widest variety of index types. Be
 82+ # careful outputting it into HTML!
8283 $this->mOffset = $this->mRequest->getText( 'offset' );
8384
8485 # Use consistent behavior for the limit options
@@ -131,9 +132,10 @@
132133 $lastIndex = $row[$this->mIndexField];
133134 } else {
134135 $this->mPastTheEndRow = null;
135 - # Setting indexes to an empty string means that they will be omitted
136 - # if they would otherwise appear in URLs. It just so happens that this
137 - # is the right thing to do in the standard UI, in all the relevant cases.
 136+ # Setting indexes to an empty string means that they will be
 137+ # omitted if they would otherwise appear in URLs. It just so
 138+ # happens that this is the right thing to do in the standard
 139+ # UI, in all the relevant cases.
138140 $this->mPastTheEndIndex = '';
139141 $res->seek( $numRows - 1 );
140142 $row = $res->fetchRow();
@@ -160,7 +162,8 @@
161163 }
162164
163165 /**
164 - * Do a query with specified parameters, rather than using the object context
 166+ * Do a query with specified parameters, rather than using the object
 167+ * context
165168 *
166169 * @param string $offset Index offset, inclusive
167170 * @param integer $limit Exact query limit
@@ -331,9 +334,10 @@
332335 }
333336
334337 /**
335 - * Get paging links. If a link is disabled, the item from $disabledTexts will
336 - * be used. If there is no such item, the unlinked text from $linkTexts will
337 - * be used. Both $linkTexts and $disabledTexts are arrays of HTML.
 338+ * Get paging links. If a link is disabled, the item from $disabledTexts
 339+ * will be used. If there is no such item, the unlinked text from
 340+ * $linkTexts will be used. Both $linkTexts and $disabledTexts are arrays
 341+ * of HTML.
338342 */
339343 function getPagingLinks( $linkTexts, $disabledTexts = array() ) {
340344 $queries = $this->getPagingQueries();
@@ -667,20 +671,22 @@
668672 }
669673
670674 /**
671 - * Return true if the named field should be sortable by the UI, false otherwise
 675+ * Return true if the named field should be sortable by the UI, false
 676+ * otherwise
 677+ *
672678 * @param string $field
673679 */
674680 abstract function isFieldSortable( $field );
675681
676682 /**
677 - * Format a table cell. The return value should be HTML, but use an empty string
678 - * not &nbsp; for empty cells. Do not include the <td> and </td>.
 683+ * Format a table cell. The return value should be HTML, but use an empty
 684+ * string not &nbsp; for empty cells. Do not include the <td> and </td>.
679685 *
 686+ * The current result row is available as $this->mCurrentRow, in case you
 687+ * need more context.
 688+ *
680689 * @param string $name The database field name
681690 * @param string $value The value retrieved from the database
682 - *
683 - * The current result row is available as $this->mCurrentRow, in case you need
684 - * more context.
685691 */
686692 abstract function formatValue( $name, $value );
687693
@@ -690,9 +696,9 @@
691697 abstract function getDefaultSort();
692698
693699 /**
694 - * An array mapping database field names to a textual description of the field
695 - * name, for use in the table header. The description should be plain text, it
696 - * will be HTML-escaped later.
 700+ * An array mapping database field names to a textual description of the
 701+ * field name, for use in the table header. The description should be plain
 702+ * text, it will be HTML-escaped later.
697703 */
698704 abstract function getFieldNames();
699705 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r23407Merged revisions 23203-23405 via svnmerge from...david23:00, 25 June 2007

Status & tagging log