8 * A querypage to list the most wanted templates - implements Special:Wantedtemplates
9 * based on SpecialWantedcategories.php by Ævar Arnfjörð Bjarmason <avarab@gmail.com>
10 * makeWlhLink() taken from SpecialMostlinkedtemplates by Rob Church <robchur@gmail.com>
12 * @ingroup SpecialPage
15 * @copyright Copyright © 2008, Danny B.
16 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
18 class WantedTemplatesPage
extends QueryPage
{
21 return 'Wantedtemplates';
24 function isExpensive() {
28 function isSyndicated() {
33 $dbr = wfGetDB( DB_SLAVE
);
34 list( $templatelinks, $page ) = $dbr->tableNamesN( 'templatelinks', 'page' );
35 $name = $dbr->addQuotes( $this->getName() );
39 tl_namespace as namespace,
42 FROM $templatelinks LEFT JOIN
43 $page ON tl_title = page_title AND tl_namespace = page_namespace
44 WHERE page_title IS NULL AND tl_namespace = ". NS_TEMPLATE
."
45 GROUP BY tl_namespace, tl_title
49 function sortDescending() { return true; }
52 * Fetch user page links and cache their existence
54 function preprocessResults( $db, $res ) {
55 $batch = new LinkBatch
;
56 while ( $row = $db->fetchObject( $res ) )
57 $batch->add( $row->namespace, $row->title
);
60 // Back to start for display
61 if ( $db->numRows( $res ) > 0 )
62 // If there are no rows we get an error seeking.
63 $db->dataSeek( $res, 0 );
66 function formatResult( $skin, $result ) {
67 global $wgLang, $wgContLang;
69 $nt = Title
::makeTitle( $result->namespace, $result->title
);
70 $text = $wgContLang->convert( $nt->getText() );
72 $plink = $this->isCached() ?
73 $skin->makeLinkObj( $nt, htmlspecialchars( $text ) ) :
74 $skin->makeBrokenLinkObj( $nt, htmlspecialchars( $text ) );
78 $this->makeWlhLink( $nt, $skin, $result )
83 * Make a "what links here" link for a given title
85 * @param Title $title Title to make the link for
86 * @param Skin $skin Skin to use
87 * @param object $result Result row
90 private function makeWlhLink( $title, $skin, $result ) {
92 $wlh = SpecialPage
::getTitleFor( 'Whatlinkshere' );
93 $label = wfMsgExt( 'nlinks', array( 'parsemag', 'escape' ),
94 $wgLang->formatNum( $result->value
) );
95 return $skin->link( $wlh, $label, array(), array( 'target' => $title->getPrefixedText() ) );
102 function wfSpecialWantedTemplates() {
103 list( $limit, $offset ) = wfCheckLimits();
105 $wpp = new WantedTemplatesPage();
107 $wpp->doQuery( $offset, $limit );