3 function wfSpecialWhatlinkshere($par = NULL)
5 global $wgUser, $wgOut, $target;
6 $fname = "wfSpecialWhatlinkshere";
10 } else if (!empty($_REQUEST['target'])) {
11 $target = $_REQUEST['target'] ;
13 $wgOut->errorpage( "notargettitle", "notargettext" );
16 $nt = Title
::newFromURL( $target );
18 $wgOut->errorpage( "notargettitle", "notargettext" );
21 $wgOut->setPagetitle( $nt->getPrefixedText() );
22 $wgOut->setSubtitle( wfMsg( "linklistsub" ) );
24 $id = $nt->getArticleID();
25 $sk = $wgUser->getSkin();
26 $isredir = " (" . wfMsg( "isredirect" ) . ")\n";
28 $wgOut->addHTML("< ".$sk->makeKnownLinkObj($nt, "", "redirect=no" )."<br/>\n");
31 $sql = "SELECT cur_id,cur_namespace,cur_title,cur_is_redirect FROM brokenlinks,cur WHERE bl_to='" .
32 wfStrencode( $nt->getPrefixedDBkey() ) . "' AND bl_from=cur_id LIMIT 500";
33 $res = wfQuery( $sql, DB_READ
, $fname );
35 if ( 0 == wfNumRows( $res ) ) {
36 $wgOut->addHTML( wfMsg( "nolinkshere" ) );
38 $wgOut->addHTML( wfMsg( "linkshere" ) );
39 $wgOut->addHTML( "\n<ul>" );
41 while ( $row = wfFetchObject( $res ) ) {
42 $nt = Title
::makeTitle( $row->cur_namespace
, $row->cur_title
);
46 $link = $sk->makeKnownLinkObj( $nt, "", "redirect=no" );
47 $wgOut->addHTML( "<li>{$link}" );
49 if ( $row->cur_is_redirect
) {
50 $wgOut->addHTML( $isredir );
51 wfShowIndirectLinks( 1, $row->cur_id
);
53 $wgOut->addHTML( "</li>\n" );
55 $wgOut->addHTML( "</ul>\n" );
59 wfShowIndirectLinks( 0, $id );
63 function wfShowIndirectLinks( $level, $lid )
65 global $wgOut, $wgUser;
66 $fname = "wfShowIndirectLinks";
68 $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";
69 $res = wfQuery( $sql, DB_READ
, $fname );
71 if ( 0 == wfNumRows( $res ) ) {
73 $wgOut->addHTML( wfMsg( "nolinkshere" ) );
78 $wgOut->addHTML( wfMsg( "linkshere" ) );
80 $sk = $wgUser->getSkin();
81 $isredir = " (" . wfMsg( "isredirect" ) . ")\n";
83 $wgOut->addHTML( "<ul>" );
84 while ( $row = wfFetchObject( $res ) ) {
85 $nt = Title
::makeTitle( $row->cur_namespace
, $row->cur_title
);
87 $wgOut->addHTML( "<!-- bad backlink: " . htmlspecialchars( $row->l_from
) . " -->\n" );
91 if ( $row->cur_is_redirect
) {
92 $extra = "redirect=no";
97 $link = $sk->makeKnownLinkObj( $nt, "", $extra );
98 $wgOut->addHTML( "<li>{$link}" );
100 if ( $row->cur_is_redirect
) {
101 $wgOut->addHTML( $isredir );
103 wfShowIndirectLinks( $level +
1, $row->cur_id
);
106 $wgOut->addHTML( "</li>\n" );
108 $wgOut->addHTML( "</ul>\n" );