r18263 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r18262‎ | r18263 | r18264 >
Date:19:29, 11 December 2006
Author:hashar
Status:old
Tags:
Comment:
Implements bug #4673 : Special:Allpages should display "previous" link
Notes: added a 'prevpage' message, you might want to review database queries
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/SpecialAllpages.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialAllpages.php
@@ -231,8 +231,6 @@
232232 )
233233 );
234234
235 - ### FIXME: side link to previous
236 -
237235 $n = 0;
238236 $out = '<table style="background: inherit;" border="0" width="100%">';
239237
@@ -263,15 +261,52 @@
264262 if ( $including ) {
265263 $out2 = '';
266264 } else {
 265+
 266+ # Get the last title from previous chunk
 267+ $res_prev = $dbr->select(
 268+ 'page',
 269+ 'page_title',
 270+ array( 'page_namespace' => $namespace, 'page_title < '.$dbr->addQuotes($from) ),
 271+ $fname,
 272+ array( 'ORDER BY' => 'page_title DESC', 'LIMIT' => $this->maxPerPage, 'OFFSET' => ($this->maxPerPage - 1 ) )
 273+ );
 274+
 275+ # Get first title of previous complete chunk
 276+ if( $dbr->numrows( $res_prev ) >= $this->maxPerPage ) {
 277+ $pt = $dbr->fetchObject( $res_prev );
 278+ $prevTitle = Title::makeTitle( $namespace, $pt->page_title );
 279+ } else {
 280+ # The previous chunk is not complete, need to link to the very first title
 281+ # available in the database
 282+ $reallyFirstPage_title = $dbr->selectField( 'page', 'page_title', array( 'page_namespace' => $namespace ), $fname, array( 'LIMIT' => 1) );
 283+
 284+ # Show the previous link if it s not the current requested chunk
 285+ if( $from != $reallyFirstPage_title ) {
 286+ $prevTitle = Title::makeTitle( $namespace, $reallyFirstPage_title );
 287+ } else {
 288+ $prevTitle = null;
 289+ }
 290+ }
 291+
267292 $nsForm = $this->namespaceForm ( $namespace, $from );
268293 $out2 = '<table style="background: inherit;" width="100%" cellpadding="0" cellspacing="0" border="0">';
269294 $out2 .= '<tr valign="top"><td align="left">' . $nsForm;
270295 $out2 .= '</td><td align="right" style="font-size: smaller; margin-bottom: 1em;">' .
271296 $sk->makeKnownLink( $wgContLang->specialPage( "Allpages" ),
272297 wfMsgHtml ( 'allpages' ) );
273 - if ( isset($dbr) && $dbr && ($n == $this->maxPerPage) && ($s = $dbr->fetchObject( $res )) ) {
274 - $t = Title::MakeTitle( $s->page_namespace, $s->page_title );
275 - $self = SpecialPage::getTitleFor( 'Allpages' );
 298+
 299+ $self = SpecialPage::getTitleFor( 'Allpages' );
 300+
 301+ # Do we put a previous link ?
 302+ if( isset( $prevTitle ) && $pt = $prevTitle->getText() ) {
 303+ $q = 'from=' . $prevTitle->getPartialUrl() . ( $namespace ? '&namespace=' . $namespace : '' );
 304+ $prevLink = $sk->makeKnownLinkObj( $self, wfMsgHTML( 'prevpage', $pt ), $q );
 305+ $out2 .= ' | ' . $prevLink;
 306+ }
 307+
 308+ if( $n == $this->maxPerPage && $s = $dbr->fetchObject($res) ) {
 309+ # $s is the first link of the next chunk
 310+ $t = Title::MakeTitle($namespace, $s->page_title);
276311 $q = 'from=' . $t->getPartialUrl() . ( $namespace ? '&namespace=' . $namespace : '' );
277312 $nextLink = $sk->makeKnownLinkObj( $self, wfMsgHtml( 'nextpage', $t->getText() ), $q );
278313 $out2 .= ' | ' . $nextLink;
@@ -280,8 +315,15 @@
281316 }
282317
283318 $wgOut->addHtml( $out2 . $out );
284 - if( isset( $nextLink ) )
285 - $wgOut->addHtml( '<p style="font-size: smaller; float: right;">' . $nextLink . '</p>' );
 319+ if( isset($prevLink) or isset($nextLink) ) {
 320+ $wgOut->addHtml( '<hr/><p style="font-size: smaller; float: right;">' );
 321+ if( isset( $prevLink ) )
 322+ $wgOut->addHTML( $prevLink . ' | ');
 323+ if( isset( $nextLink ) )
 324+ $wgOut->addHTML( $nextLink );
 325+ $wgOut->addHTML( '</p>' );
 326+
 327+ }
286328
287329 }
288330
Index: trunk/phase3/RELEASE-NOTES
@@ -268,8 +268,8 @@
269269 Duplicated code merged into wfResetOutputBuffers() and wfClearOutputBuffers()
270270 * Special:AllPages : 'next page' link now point to the first title of the next
271271 chunk instead of pointing to the last title of current chunk.
 272+* (bug 4673) Special:AllPages : add a 'previous' link (new message 'prevpage')
272273
273 -
274274 == Languages updated ==
275275
276276 * Bishnupriya Manipuri (bpy)
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1525,6 +1525,7 @@
15261526
15271527 # Special:Allpages
15281528 'nextpage' => 'Next page ($1)',
 1529+'prevpage' => 'Previous page ($1)',
15291530 'allpagesfrom' => 'Display pages starting at:',
15301531 'allarticles' => 'All articles',
15311532 'allinnamespace' => 'All pages ($1 namespace)',