Index: branches/robchurch/reports/includes/reports/ReportPager.php |
— | — | @@ -21,7 +21,6 @@ |
22 | 22 | public function __construct( Report $report ) { |
23 | 23 | $this->report = $report; |
24 | 24 | parent::__construct(); |
25 | | - $this->mLimitsShown = array( 50, 100, 250, 500, 1000 ); |
26 | 25 | } |
27 | 26 | |
28 | 27 | /** |
— | — | @@ -107,11 +106,46 @@ |
108 | 107 | } |
109 | 108 | |
110 | 109 | /** |
| 110 | + * Build results into a large image gallery; suitable |
| 111 | + * for reports which are returning items from the |
| 112 | + * image namespace |
| 113 | + * |
| 114 | + * @return string |
| 115 | + */ |
| 116 | + public function getGalleryBody() { |
| 117 | + if( !$this->mQueryDone ) |
| 118 | + $this->doQuery(); |
| 119 | + $numRows = min( $this->mResult->numRows(), $this->mLimit ); |
| 120 | + if( $numRows ) { |
| 121 | + $gallery = new ImageGallery(); |
| 122 | + if( $this->mIsBackwards ) { |
| 123 | + for( $i = $numRows - 1; $i >= 0; $i-- ) { |
| 124 | + $this->mResult->seek( $i ); |
| 125 | + $row = $this->mResult->fetchObject(); |
| 126 | + $gallery->add( Title::makeTitleSafe( $row->rp_namespace, $row->rp_title ) ); |
| 127 | + } |
| 128 | + } else { |
| 129 | + $this->mResult->seek( 0 ); |
| 130 | + for( $i = 0; $i < $numRows; $i++ ) { |
| 131 | + $row = $this->mResult->fetchObject(); |
| 132 | + $gallery->add( Title::makeTitleSafe( $row->rp_namespace, $row->rp_title ) ); |
| 133 | + } |
| 134 | + } |
| 135 | + return $gallery->toHtml(); |
| 136 | + } else { |
| 137 | + return $this->getEmptyBody(); |
| 138 | + } |
| 139 | + } |
| 140 | + |
| 141 | + /** |
111 | 142 | * Build the navigation bar with paging and limit links |
112 | 143 | * |
113 | 144 | * @return string |
114 | 145 | */ |
115 | 146 | public function getNavigationBar() { |
| 147 | + $this->mLimitsShown = $this->getNamespace() === NS_IMAGE |
| 148 | + ? array( 12, 24, 48, 96, 192 ) |
| 149 | + : array( 50, 100, 250, 500, 1000 ); |
116 | 150 | foreach( array( 'first', 'last', 'prev', 'next' ) as $link ) |
117 | 151 | $labels[$link] = wfMsgHtml( 'report-paging-' . $link ); |
118 | 152 | return '( ' . implode( ' | ', $this->getPagingLinks( $labels ) ) . ' ) ( ' |
Index: branches/robchurch/reports/includes/reports/Report.php |
— | — | @@ -237,7 +237,11 @@ |
238 | 238 | # Report results |
239 | 239 | if( ( $count = $pager->getNumRows() ) > 0 ) { |
240 | 240 | $wgOut->addHtml( $pager->getNavigationBar() ); |
241 | | - $wgOut->addHtml( $pager->getBody() ); |
| 241 | + if( $namespace === NS_IMAGE ) { |
| 242 | + $wgOut->addHtml( $pager->getGalleryBody() ); |
| 243 | + } else { |
| 244 | + $wgOut->addHtml( $pager->getBody() ); |
| 245 | + } |
242 | 246 | $wgOut->addHtml( $pager->getNavigationBar() ); |
243 | 247 | } else { |
244 | 248 | $wgOut->addHtml( '<p>' . wfMsgHtml( 'report-no-results' ) . '</p>' ); |