834d68cd7015f1de4dc770b6a1be30c118c7e218
[lhc/web/wiklou.git] / includes / SpecialWantedpages.php
1 <?
2
3 include_once ( "LogPage.php" ) ;
4
5 function wfSpecialWantedpages()
6 {
7 global $wgUser, $wgOut, $wgLang, $wgTitle;
8 $fname = "wfSpecialWantedpages";
9
10 # Cache
11 $vsp = $wgLang->getValidSpecialPages() ;
12 $log = new LogPage( $vsp["Wantedpages"] );
13 $log->mUpdateRecentChanges = false;
14
15 $wgOut->setRobotpolicy( "noindex,nofollow" );
16 global $wgMiserMode;
17 if ( $wgMiserMode ) {
18 $log->showAsDisabledPage();
19 return;
20 }
21
22 list( $limit, $offset ) = wfCheckLimits();
23
24 $cache = "" ; # To be saved, eventually
25
26 $sql = "SELECT bl_to, COUNT( DISTINCT bl_from ) as nlinks " .
27 "FROM brokenlinks GROUP BY bl_to HAVING nlinks > 1 " .
28 "ORDER BY nlinks DESC LIMIT {$offset}, {$limit}";
29 $res = wfQuery( $sql, DB_READ, $fname );
30
31 $sk = $wgUser->getSkin();
32
33 $top = wfShowingResults( $offset, $limit );
34 $wgOut->addHTML( "<p>{$top}\n" );
35
36 $sl = wfViewPrevNext( $offset, $limit,
37 $wgLang->specialpage( "Wantedpages" ) );
38 $wgOut->addHTML( "<br>{$sl}\n" );
39
40 $s = "<ol start=" . ( $offset + 1 ) . ">";
41 while ( $obj = wfFetchObject( $res ) ) {
42 $nt = Title::newFromDBkey( $obj->bl_to );
43
44 $plink = $sk->makeBrokenLink( $nt->getPrefixedText(), "" );
45 $nl = wfMsg( "nlinks", $obj->nlinks );
46 $nlink = $sk->makeKnownLink( $wgLang->specialPage(
47 "Whatlinkshere" ), $nl, "target=" . $nt->getPrefixedURL() );
48
49 $cache .= "* [[".$nt->getPrefixedText()."]] ({$nl})\n" ;
50
51 $s .= "<li>{$plink} ({$nlink})</li>\n";
52 }
53 wfFreeResult( $res );
54 $s .= "</ol>";
55 $wgOut->addHTML( $s );
56 $wgOut->addHTML( "<p>{$sl}\n" );
57
58 # Saving cache
59 if ( $offset > 0 OR $limit < 50 ) return ; #Not suitable
60 $log->replaceContent( $s );
61 }
62
63 ?>