Fixed quoting in contributors query.
[mediawiki.git] / includes / SpecialWhatlinkshere.php
blob083ff2a1f65ee203c60d945d0915c348f135c3eb
1 <?php
3 function wfSpecialWhatlinkshere($par = NULL)
5 global $wgUser, $wgOut, $target;
6 $fname = "wfSpecialWhatlinkshere";
8 if(!empty($par)) {
9 $target = $par;
10 } else if (!empty($_REQUEST['target'])) {
11 $target = $_REQUEST['target'] ;
12 } else {
13 $wgOut->errorpage( "notargettitle", "notargettext" );
14 return;
16 $nt = Title::newFromURL( $target );
17 if( !$nt ) {
18 $wgOut->errorpage( "notargettitle", "notargettext" );
19 return;
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("&lt; ".$sk->makeKnownLinkObj($nt, "", "redirect=no" )."<br/>\n");
30 if ( 0 == $id ) {
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" ) );
37 } else {
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 );
43 if( !$nt ) {
44 continue;
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" );
56 wfFreeResult( $res );
58 } else {
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 ) ) {
72 if ( 0 == $level ) {
73 $wgOut->addHTML( wfMsg( "nolinkshere" ) );
75 return;
77 if ( 0 == $level ) {
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 );
86 if( !$nt ) {
87 $wgOut->addHTML( "<!-- bad backlink: " . htmlspecialchars( $row->l_from ) . " -->\n" );
88 continue;
91 if ( $row->cur_is_redirect ) {
92 $extra = "redirect=no";
93 } else {
94 $extra = "";
97 $link = $sk->makeKnownLinkObj( $nt, "", $extra );
98 $wgOut->addHTML( "<li>{$link}" );
100 if ( $row->cur_is_redirect ) {
101 $wgOut->addHTML( $isredir );
102 if ( $level < 2 ) {
103 wfShowIndirectLinks( $level + 1, $row->cur_id );
106 $wgOut->addHTML( "</li>\n" );
108 $wgOut->addHTML( "</ul>\n" );