X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSpecialShortpages.php;h=973656ddaa930109d9733ec1eaf5bfc3e6d319d5;hb=2771512dbeba455572f5935fe0a3b80720dae9af;hp=ae230239023f5bc1839a5e651269f5d58741334d;hpb=8f22cb45b1ccd2d18bb4ef1247a18efbb9a87e2d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SpecialShortpages.php b/includes/SpecialShortpages.php index ae23023902..973656ddaa 100644 --- a/includes/SpecialShortpages.php +++ b/includes/SpecialShortpages.php @@ -1,33 +1,87 @@ tableName( 'page' ); + $name = $dbr->addQuotes( $this->getName() ); + + $forceindex = $dbr->useIndexClause("page_len"); + return + "SELECT $name as type, + page_namespace as namespace, + page_title as title, + page_len AS value + FROM $page $forceindex + WHERE page_namespace=".NS_MAIN." AND page_is_redirect=0"; + } + + function preprocessResults( &$db, &$res ) { + # There's no point doing a batch check if we aren't caching results; + # the page must exist for it to have been pulled out of the table + if( $this->isCached() ) { + $batch = new LinkBatch(); + while( $row = $db->fetchObject( $res ) ) + $batch->addObj( Title::makeTitleSafe( $row->namespace, $row->title ) ); + $batch->execute(); + if( $db->numRows( $res ) > 0 ) + $db->dataSeek( $res, 0 ); + } + } + + function sortDescending() { + return false; } function formatResult( $skin, $result ) { - global $wgLang; - $nb = wfMsg( "nbytes", $wgLang->formatNum( $result->len ) ); - $link = $skin->makeKnownLink( $result->cur_title, "" ); - return "{$link} ({$nb})"; + global $wgLang, $wgContLang; + $dm = $wgContLang->getDirMark(); + + $title = Title::makeTitleSafe( $result->namespace, $result->title ); + if ( !$title ) { + return ''; + } + $hlink = $skin->makeKnownLinkObj( $title, wfMsgHtml( 'hist' ), 'action=history' ); + $plink = $this->isCached() + ? $skin->makeLinkObj( $title ) + : $skin->makeKnownLinkObj( $title ); + $size = wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ), $wgLang->formatNum( htmlspecialchars( $result->value ) ) ); + + return $title->exists() + ? "({$hlink}) {$dm}{$plink} {$dm}[{$size}]" + : "({$hlink}) {$dm}{$plink} {$dm}[{$size}]"; } } -function wfSpecialShortpages() -{ +/** + * constructor + */ +function wfSpecialShortpages() { list( $limit, $offset ) = wfCheckLimits(); $spp = new ShortPagesPage(); @@ -35,4 +89,4 @@ function wfSpecialShortpages() return $spp->doQuery( $offset, $limit ); } -?> +