3 function wfSpecialWhatlinkshere($par = NULL)
5 global $wgUser, $wgOut, $target;
6 $fname = "wfSpecialWhatlinkshere";
11 $target = $_REQUEST['target'] ;
13 if ( "" == $target ) {
14 $wgOut->errorpage( "notargettitle", "notargettext" );
17 $nt = Title
::newFromURL( $target );
19 $wgOut->errorpage( "notargettitle", "notargettext" );
22 $wgOut->setPagetitle( $nt->getPrefixedText() );
23 $wgOut->setSubtitle( wfMsg( "linklistsub" ) );
25 $id = $nt->getArticleID();
26 $sk = $wgUser->getSkin();
27 $isredir = " (" . wfMsg( "isredirect" ) . ")\n";
30 $sql = "SELECT cur_id,cur_namespace,cur_title,cur_is_redirect FROM brokenlinks,cur WHERE bl_to='" .
31 wfStrencode( $nt->getPrefixedDBkey() ) . "' AND bl_from=cur_id LIMIT 500";
32 $res = wfQuery( $sql, DB_READ
, $fname );
34 if ( 0 == wfNumRows( $res ) ) {
35 $wgOut->addHTML( wfMsg( "nolinkshere" ) );
37 $wgOut->addHTML( wfMsg( "linkshere" ) );
38 $wgOut->addHTML( "\n<ul>" );
40 while ( $row = wfFetchObject( $res ) ) {
41 $nt = Title
::makeTitle( $row->cur_namespace
, $row->cur_title
);
45 $link = $sk->makeKnownLinkObj( $nt, "", "redirect=no" );
46 $wgOut->addHTML( "<li>{$link}" );
48 if ( $row->cur_is_redirect
) {
49 $wgOut->addHTML( $isredir );
50 wfShowIndirectLinks( 1, $row->cur_id
);
52 $wgOut->addHTML( "</li>\n" );
54 $wgOut->addHTML( "</ul>\n" );
58 wfShowIndirectLinks( 0, $id );
62 function wfShowIndirectLinks( $level, $lid )
64 global $wgOut, $wgUser;
65 $fname = "wfShowIndirectLinks";
67 $sql = "SELECT cur_id,cur_namespace,cur_title,cur_is_redirect FROM links,cur WHERE l_to={$lid} AND l_from=cur_id LIMIT 500";
68 $res = wfQuery( $sql, DB_READ
, $fname );
70 if ( 0 == wfNumRows( $res ) ) {
72 $wgOut->addHTML( wfMsg( "nolinkshere" ) );
77 $wgOut->addHTML( wfMsg( "linkshere" ) );
79 $sk = $wgUser->getSkin();
80 $isredir = " (" . wfMsg( "isredirect" ) . ")\n";
82 $wgOut->addHTML( "<ul>" );
83 while ( $row = wfFetchObject( $res ) ) {
84 $nt = Title
::makeTitle( $row->cur_namespace
, $row->cur_title
);
86 $wgOut->addHTML( "<!-- bad backlink: " . htmlspecialchars( $row->l_from
) . " -->\n" );
90 if ( $row->cur_is_redirect
) {
91 $extra = "redirect=no";
96 $link = $sk->makeKnownLinkObj( $nt, "", $extra );
97 $wgOut->addHTML( "<li>{$link}" );
99 if ( $row->cur_is_redirect
) {
100 $wgOut->addHTML( $isredir );
102 wfShowIndirectLinks( $level +
1, $row->cur_id
);
105 $wgOut->addHTML( "</li>\n" );
107 $wgOut->addHTML( "</ul>\n" );