3 * Implements Special:Shortpages
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
21 * @ingroup SpecialPage
25 * SpecialShortpages extends QueryPage. It is used to return the shortest
26 * pages in the database.
28 * @ingroup SpecialPage
30 class ShortPagesPage
extends QueryPage
{
37 * This query is indexed as of 1.5
39 function isExpensive() {
43 function isSyndicated() {
48 global $wgContentNamespaces;
50 $dbr = wfGetDB( DB_SLAVE
);
51 $page = $dbr->tableName( 'page' );
52 $name = $dbr->addQuotes( $this->getName() );
54 $forceindex = $dbr->useIndexClause("page_len");
56 if ($wgContentNamespaces)
57 $nsclause = "page_namespace IN (" . $dbr->makeList($wgContentNamespaces) . ")";
59 $nsclause = "page_namespace = " . NS_MAIN
;
62 "SELECT $name as type,
63 page_namespace as namespace,
66 FROM $page $forceindex
67 WHERE $nsclause AND page_is_redirect=0";
70 function preprocessResults( $db, $res ) {
71 # There's no point doing a batch check if we aren't caching results;
72 # the page must exist for it to have been pulled out of the table
73 if( $this->isCached() ) {
74 $batch = new LinkBatch();
75 foreach ( $res as $row ) {
76 $batch->add( $row->namespace, $row->title
);
79 if ( $db->numRows( $res ) > 0 ) {
80 $db->dataSeek( $res, 0 );
85 function sortDescending() {
89 function formatResult( $skin, $result ) {
90 global $wgLang, $wgContLang;
91 $dm = $wgContLang->getDirMark();
93 $title = Title
::makeTitleSafe( $result->namespace, $result->title
);
95 return '<!-- Invalid title ' . htmlspecialchars( "{$result->namespace}:{$result->title}" ). '-->';
97 $hlink = $skin->linkKnown(
101 array( 'action' => 'history' )
103 $plink = $this->isCached()
104 ?
$skin->link( $title )
105 : $skin->linkKnown( $title );
106 $size = wfMessage( 'nbytes', $wgLang->formatNum( $result->value
) )->escaped();
108 return $title->exists()
109 ?
"({$hlink}) {$dm}{$plink} {$dm}[{$size}]"
110 : "<del>({$hlink}) {$dm}{$plink} {$dm}[{$size}]</del>";
117 function wfSpecialShortpages() {
118 list( $limit, $offset ) = wfCheckLimits();
120 $spp = new ShortPagesPage();
122 return $spp->doQuery( $offset, $limit );