From: Jens Frank Date: Tue, 20 Jan 2004 19:02:12 +0000 (+0000) Subject: Feature-Request #816659,#668443: No (next 50) link if there is no next page X-Git-Tag: 1.3.0beta1~1125 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22statistiques_visites%22%2C%22%22%29%20.%20%22?a=commitdiff_plain;h=58c8694cae51acc2d0e66c0b19657280d91d9de1;p=lhc%2Fweb%2Fwiklou.git Feature-Request #816659,#668443: No (next 50) link if there is no next page Implemented for: PageHistory, QueryPage and all derived from it, SpecialContributions --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index b0a0fd1650..afddeaa25c 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -583,7 +583,7 @@ function wfShowingResultsNum( $offset, $limit, $num ) return wfMsg( "showingresultsnum", $limit, $offset+1, $num ); } -function wfViewPrevNext( $offset, $limit, $link, $query = "" ) +function wfViewPrevNext( $offset, $limit, $link, $query = "", $atend = false ) { global $wgUser; $prev = wfMsg( "prevn", $limit ); @@ -602,7 +602,11 @@ function wfViewPrevNext( $offset, $limit, $link, $query = "" ) $q = "limit={$limit}&offset={$no}"; if ( "" != $query ) { $q .= "&{$query}"; } - $nlink = "{$next}"; + if ( $atend ) { + $nlink = $next; + } else { + $nlink = "{$next}"; + } $nums = wfNumLink( $offset, 20, $link , $query ) . " | " . wfNumLink( $offset, 50, $link, $query ) . " | " . wfNumLink( $offset, 100, $link, $query ) . " | " . diff --git a/includes/PageHistory.php b/includes/PageHistory.php index cca1d66fed..df5a580eb8 100644 --- a/includes/PageHistory.php +++ b/includes/PageHistory.php @@ -69,7 +69,7 @@ class PageHistory { $numbar = wfViewPrevNext( $offset, $limit, $this->mTitle->getPrefixedText(), - "action=history" ); + "action=history", $atend ); $s = $numbar; $s .= $this->beginHistoryList(); diff --git a/includes/QueryPage.php b/includes/QueryPage.php index 50f34c3405..cbb9e7e40d 100644 --- a/includes/QueryPage.php +++ b/includes/QueryPage.php @@ -60,7 +60,7 @@ class QueryPage { } } - $sql = $this->getSQL( $offset, $limit ); + $sql = $this->getSQL( $offset, $limit+1 ); $res = wfQuery( $sql, DB_READ, $fname ); @@ -69,13 +69,16 @@ class QueryPage { $top = wfShowingResults( $offset, $limit ); $wgOut->addHTML( "

{$top}\n" ); - $sl = wfViewPrevNext( $offset, $limit, $wgLang->specialPage( $sname ) ); + $sl = wfViewPrevNext( $offset, $limit, $wgLang->specialPage( $sname ), "", + wfNumRows( $res ) < ($limit+1) ); $wgOut->addHTML( "
{$sl}\n" ); $s = "

    "; - while ( $obj = wfFetchObject( $res ) ) { + $i = 0; + while ( ($i<$limit) && ($obj = wfFetchObject( $res )) ) { $format = $this->formatResult( $sk, $obj ); $s .= "
  1. {$format}
  2. \n"; + $i++; } wfFreeResult( $res ); $s .= "
"; diff --git a/includes/SpecialContributions.php b/includes/SpecialContributions.php index b5016de12f..ca206c71c2 100644 --- a/includes/SpecialContributions.php +++ b/includes/SpecialContributions.php @@ -17,6 +17,7 @@ function wfSpecialContributions( $par = "" ) } list( $limit, $offset ) = wfCheckLimits( 50, "" ); $offlimit = $limit + $offset; + $querylimit = $offlimit + 1; $hideminor = ($hideminor ? 1 : 0); $nt = Title::newFromURL( $target ); @@ -50,37 +51,39 @@ function wfSpecialContributions( $par = "" ) "&offset={$offset}&limit={$limit}&hideminor=1" ); } - $top = wfShowingResults( $offset, $limit ); - $wgOut->addHTML( "

{$top}\n" ); - - $sl = wfViewPrevNext( $offset, $limit, - $wgLang->specialpage( "Contributions" ), "hideminor={$hideminor}&target=" . wfUrlEncode( $target ) ); - - $shm = wfMsg( "showhideminor", $mlink ); - $wgOut->addHTML( "
{$sl} ($shm) \n"); - if ( 0 == $id ) { $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit FROM cur " . "WHERE cur_user_text='" . wfStrencode( $nt->getText() ) . "' {$cmq} " . - "ORDER BY inverse_timestamp LIMIT {$offlimit}"; + "ORDER BY inverse_timestamp LIMIT {$querylimit}"; $res1 = wfQuery( $sql, DB_READ, $fname ); $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit FROM old " . "WHERE old_user_text='" . wfStrencode( $nt->getText() ) . "' {$omq} " . - "ORDER BY inverse_timestamp LIMIT {$offlimit}"; + "ORDER BY inverse_timestamp LIMIT {$querylimit}"; $res2 = wfQuery( $sql, DB_READ, $fname ); } else { $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit FROM cur " . - "WHERE cur_user={$id} {$cmq} ORDER BY inverse_timestamp LIMIT {$offlimit}"; + "WHERE cur_user={$id} {$cmq} ORDER BY inverse_timestamp LIMIT {$querylimit}"; $res1 = wfQuery( $sql, DB_READ, $fname ); $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit FROM old " . - "WHERE old_user={$id} {$omq} ORDER BY inverse_timestamp LIMIT {$offlimit}"; + "WHERE old_user={$id} {$omq} ORDER BY inverse_timestamp LIMIT {$querylimit}"; $res2 = wfQuery( $sql, DB_READ, $fname ); } $nCur = wfNumRows( $res1 ); $nOld = wfNumRows( $res2 ); + $top = wfShowingResults( $offset, $limit ); + $wgOut->addHTML( "

{$top}\n" ); + + $sl = wfViewPrevNext( $offset, $limit, + $wgLang->specialpage( "Contributions" ), + "hideminor={$hideminor}&target=" . wfUrlEncode( $target ), + ($nCur + $nOld) <= $offlimit); + + $shm = wfMsg( "showhideminor", $mlink ); + $wgOut->addHTML( "
{$sl} ($shm) \n"); + if ( 0 == $nCur && 0 == $nOld ) { $wgOut->addHTML( "\n

" . wfMsg( "nocontribs" ) . "

\n" );