* (bug 13922) Fix bad HTML on empty Special:Prefixindex and Special:Allpages

Ugh! Somebody please clean up this duplicated code.... allpages and prefixindex have lots of duplicated bits. I swear one used to be a subclass of the other, did they get copied? Or did I do that years ago and forget? :D
This commit is contained in:
Brion Vibber 2008-05-01 22:07:24 +00:00
parent dadf1388a1
commit 40da2bd661
3 changed files with 49 additions and 40 deletions

View file

@ -234,6 +234,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
* (bug 13915) Undefined variable $wltsfield in includes/SpecialWatchlist.php * (bug 13915) Undefined variable $wltsfield in includes/SpecialWatchlist.php
* (bug 13913) Special:Whatlinkshere now has correct HTML markup * (bug 13913) Special:Whatlinkshere now has correct HTML markup
* (bug 13905) Blacklist Mac IE from HttpOnly cookies; it eats them sometimes * (bug 13905) Blacklist Mac IE from HttpOnly cookies; it eats them sometimes
* (bug 13922) Fix bad HTML on empty Special:Prefixindex and Special:Allpages
=== API changes in 1.13 === === API changes in 1.13 ===

View file

@ -257,30 +257,34 @@ function showChunk( $namespace = NS_MAIN, $from, $including = false ) {
) )
); );
$out = '<table style="background: inherit;" border="0" width="100%">'; if( $res->numRows() > 0 ) {
$out = '<table style="background: inherit;" border="0" width="100%">';
while( ($n < $this->maxPerPage) && ($s = $dbr->fetchObject( $res )) ) {
$t = Title::makeTitle( $s->page_namespace, $s->page_title ); while( ($n < $this->maxPerPage) && ($s = $dbr->fetchObject( $res )) ) {
if( $t ) { $t = Title::makeTitle( $s->page_namespace, $s->page_title );
$link = ($s->page_is_redirect ? '<div class="allpagesredirect">' : '' ) . if( $t ) {
$sk->makeKnownLinkObj( $t, htmlspecialchars( $t->getText() ), false, false ) . $link = ($s->page_is_redirect ? '<div class="allpagesredirect">' : '' ) .
($s->page_is_redirect ? '</div>' : '' ); $sk->makeKnownLinkObj( $t, htmlspecialchars( $t->getText() ), false, false ) .
} else { ($s->page_is_redirect ? '</div>' : '' );
$link = '[[' . htmlspecialchars( $s->page_title ) . ']]'; } else {
$link = '[[' . htmlspecialchars( $s->page_title ) . ']]';
}
if( $n % 3 == 0 ) {
$out .= '<tr>';
}
$out .= "<td width=\"33%\">$link</td>";
$n++;
if( $n % 3 == 0 ) {
$out .= '</tr>';
}
} }
if( $n % 3 == 0 ) { if( ($n % 3) != 0 ) {
$out .= '<tr>';
}
$out .= "<td width=\"33%\">$link</td>";
$n++;
if( $n % 3 == 0 ) {
$out .= '</tr>'; $out .= '</tr>';
} }
$out .= '</table>';
} else {
$out = '';
} }
if( ($n % 3) != 0 ) {
$out .= '</tr>';
}
$out .= '</table>';
} }
if ( $including ) { if ( $including ) {

View file

@ -96,30 +96,34 @@ class SpecialPrefixindex extends SpecialAllpages {
### FIXME: side link to previous ### FIXME: side link to previous
$n = 0; $n = 0;
$out = '<table style="background: inherit;" border="0" width="100%">'; if( $res->numRows() > 0 ) {
$out = '<table style="background: inherit;" border="0" width="100%">';
while( ($n < $this->maxPerPage) && ($s = $dbr->fetchObject( $res )) ) {
$t = Title::makeTitle( $s->page_namespace, $s->page_title ); while( ($n < $this->maxPerPage) && ($s = $dbr->fetchObject( $res )) ) {
if( $t ) { $t = Title::makeTitle( $s->page_namespace, $s->page_title );
$link = ($s->page_is_redirect ? '<div class="allpagesredirect">' : '' ) . if( $t ) {
$sk->makeKnownLinkObj( $t, htmlspecialchars( $t->getText() ), false, false ) . $link = ($s->page_is_redirect ? '<div class="allpagesredirect">' : '' ) .
($s->page_is_redirect ? '</div>' : '' ); $sk->makeKnownLinkObj( $t, htmlspecialchars( $t->getText() ), false, false ) .
} else { ($s->page_is_redirect ? '</div>' : '' );
$link = '[[' . htmlspecialchars( $s->page_title ) . ']]'; } else {
$link = '[[' . htmlspecialchars( $s->page_title ) . ']]';
}
if( $n % 3 == 0 ) {
$out .= '<tr>';
}
$out .= "<td>$link</td>";
$n++;
if( $n % 3 == 0 ) {
$out .= '</tr>';
}
} }
if( $n % 3 == 0 ) { if( ($n % 3) != 0 ) {
$out .= '<tr>';
}
$out .= "<td>$link</td>";
$n++;
if( $n % 3 == 0 ) {
$out .= '</tr>'; $out .= '</tr>';
} }
$out .= '</table>';
} else {
$out = '';
} }
if( ($n % 3) != 0 ) {
$out .= '</tr>';
}
$out .= '</table>';
} }
if ( $including ) { if ( $including ) {