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";
29 $wgOut->addHTML("< ".$sk->makeKnownLinkObj($nt, "", "redirect=no" )."<br>\n");
32 $sql = "SELECT cur_id,cur_namespace,cur_title,cur_is_redirect FROM brokenlinks,cur WHERE bl_to='" .
33 wfStrencode( $nt->getPrefixedDBkey() ) . "' AND bl_from=cur_id LIMIT 500";
34 $res = wfQuery( $sql, DB_READ
, $fname );
36 if ( 0 == wfNumRows( $res ) ) {
37 $wgOut->addHTML( wfMsg( "nolinkshere" ) );
39 $wgOut->addHTML( wfMsg( "linkshere" ) );
40 $wgOut->addHTML( "\n<ul>" );
42 while ( $row = wfFetchObject( $res ) ) {
43 $nt = Title
::makeTitle( $row->cur_namespace
, $row->cur_title
);
47 $link = $sk->makeKnownLinkObj( $nt, "", "redirect=no" );
48 $wgOut->addHTML( "<li>{$link}" );
50 if ( $row->cur_is_redirect
) {
51 $wgOut->addHTML( $isredir );
52 wfShowIndirectLinks( 1, $row->cur_id
);
54 $wgOut->addHTML( "</li>\n" );
56 $wgOut->addHTML( "</ul>\n" );
60 wfShowIndirectLinks( 0, $id );
64 function wfShowIndirectLinks( $level, $lid )
66 global $wgOut, $wgUser;
67 $fname = "wfShowIndirectLinks";
69 $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";
70 $res = wfQuery( $sql, DB_READ
, $fname );
72 if ( 0 == wfNumRows( $res ) ) {
74 $wgOut->addHTML( wfMsg( "nolinkshere" ) );
79 $wgOut->addHTML( wfMsg( "linkshere" ) );
81 $sk = $wgUser->getSkin();
82 $isredir = " (" . wfMsg( "isredirect" ) . ")\n";
84 $wgOut->addHTML( "<ul>" );
85 while ( $row = wfFetchObject( $res ) ) {
86 $nt = Title
::makeTitle( $row->cur_namespace
, $row->cur_title
);
88 $wgOut->addHTML( "<!-- bad backlink: " . htmlspecialchars( $row->l_from
) . " -->\n" );
92 if ( $row->cur_is_redirect
) {
93 $extra = "redirect=no";
98 $link = $sk->makeKnownLinkObj( $nt, "", $extra );
99 $wgOut->addHTML( "<li>{$link}" );
101 if ( $row->cur_is_redirect
) {
102 $wgOut->addHTML( $isredir );
104 wfShowIndirectLinks( $level +
1, $row->cur_id
);
107 $wgOut->addHTML( "</li>\n" );
109 $wgOut->addHTML( "</ul>\n" );