r23365 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23364‎ | r23365 | r23366 >
Date:07:14, 25 June 2007
Author:robchurch
Status:old
Tags:
Comment:
Use a gallery when outputting pure image results
Modified paths:
  • /branches/robchurch/reports/includes/reports/Report.php (modified) (history)
  • /branches/robchurch/reports/includes/reports/ReportPager.php (modified) (history)

Diff [purge]

Index: branches/robchurch/reports/includes/reports/ReportPager.php
@@ -21,7 +21,6 @@
2222 public function __construct( Report $report ) {
2323 $this->report = $report;
2424 parent::__construct();
25 - $this->mLimitsShown = array( 50, 100, 250, 500, 1000 );
2625 }
2726
2827 /**
@@ -107,11 +106,46 @@
108107 }
109108
110109 /**
 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+ /**
111142 * Build the navigation bar with paging and limit links
112143 *
113144 * @return string
114145 */
115146 public function getNavigationBar() {
 147+ $this->mLimitsShown = $this->getNamespace() === NS_IMAGE
 148+ ? array( 12, 24, 48, 96, 192 )
 149+ : array( 50, 100, 250, 500, 1000 );
116150 foreach( array( 'first', 'last', 'prev', 'next' ) as $link )
117151 $labels[$link] = wfMsgHtml( 'report-paging-' . $link );
118152 return '( ' . implode( ' | ', $this->getPagingLinks( $labels ) ) . ' ) ( '
Index: branches/robchurch/reports/includes/reports/Report.php
@@ -237,7 +237,11 @@
238238 # Report results
239239 if( ( $count = $pager->getNumRows() ) > 0 ) {
240240 $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+ }
242246 $wgOut->addHtml( $pager->getNavigationBar() );
243247 } else {
244248 $wgOut->addHtml( '<p>' . wfMsgHtml( 'report-no-results' ) . '</p>' );

Status & tagging log