Index: branches/querypage-work2/phase3/includes/QueryPage.php |
— | — | @@ -77,6 +77,13 @@ |
78 | 78 | */ |
79 | 79 | var $offset = 0; |
80 | 80 | var $limit = 0; |
| 81 | + |
| 82 | + /** |
| 83 | + * The number of rows returned by the query. Reading this variable |
| 84 | + * only makes sense in functions that are run after the query has been |
| 85 | + * done, such as preprocessResults() and formatRow(). |
| 86 | + */ |
| 87 | + protected $numRows; |
81 | 88 | |
82 | 89 | /** |
83 | 90 | * Wheter to show prev/next links |
— | — | @@ -443,7 +450,7 @@ |
444 | 451 | |
445 | 452 | } |
446 | 453 | |
447 | | - $num = $dbr->numRows($res); |
| 454 | + $this->numRows = $dbr->numRows( $res ); |
448 | 455 | |
449 | 456 | $this->preprocessResults( $dbr, $res ); |
450 | 457 | |
— | — | @@ -452,12 +459,12 @@ |
453 | 460 | # Top header and navigation |
454 | 461 | if( $this->shownavigation ) { |
455 | 462 | $wgOut->addHTML( $this->getPageHeader() ); |
456 | | - if( $num > 0 ) { |
457 | | - $wgOut->addHTML( '<p>' . wfShowingResults( $this->offset, $num ) . '</p>' ); |
| 463 | + if( $this->numRows > 0 ) { |
| 464 | + $wgOut->addHTML( '<p>' . wfShowingResults( $this->offset, $this->numRows ) . '</p>' ); |
458 | 465 | # Disable the "next" link when we reach the end |
459 | 466 | $paging = wfViewPrevNext( $this->offset, $this->limit, |
460 | 467 | $this->getTitle( $par ), |
461 | | - wfArrayToCGI( $this->linkParameters() ), ( $num < $this->limit ) ); |
| 468 | + wfArrayToCGI( $this->linkParameters() ), ( $this->numRows < $this->limit ) ); |
462 | 469 | $wgOut->addHTML( '<p>' . $paging . '</p>' ); |
463 | 470 | } else { |
464 | 471 | # No results to show, so don't bother with "showing X of Y" etc. |
— | — | @@ -475,7 +482,7 @@ |
476 | 483 | $wgUser->getSkin(), |
477 | 484 | $dbr, # Should use a ResultWrapper for this |
478 | 485 | $res, |
479 | | - $dbr->numRows( $res ), |
| 486 | + $this->numRows, |
480 | 487 | $this->offset ); |
481 | 488 | |
482 | 489 | # Repeat the paging links at the bottom |
— | — | @@ -485,7 +492,7 @@ |
486 | 493 | |
487 | 494 | $wgOut->addHTML( Xml::closeElement( 'div' ) ); |
488 | 495 | |
489 | | - return $num; |
| 496 | + return $this->numRows; |
490 | 497 | } |
491 | 498 | |
492 | 499 | /** |