Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

SpecialWhatlinkshere.php

Go to the documentation of this file.
00001 <?php 00002 00003 function wfSpecialWhatlinkshere($par = NULL) 00004 { 00005 global $wgUser, $wgOut, $wgRequest; 00006 $fname = "wfSpecialWhatlinkshere"; 00007 00008 $target = $wgRequest->getVal( 'target' ); 00009 $limit = $wgRequest->getInt( 'limit', 500 ); 00010 00011 if(!empty($par)) { 00012 $target = $par; 00013 } else if ( is_null( $target ) ) { 00014 $wgOut->errorpage( "notargettitle", "notargettext" ); 00015 return; 00016 } 00017 00018 $nt = Title::newFromURL( $target ); 00019 if( !$nt ) { 00020 $wgOut->errorpage( "notargettitle", "notargettext" ); 00021 return; 00022 } 00023 $wgOut->setPagetitle( $nt->getPrefixedText() ); 00024 $wgOut->setSubtitle( wfMsg( "linklistsub" ) ); 00025 00026 $id = $nt->getArticleID(); 00027 $sk = $wgUser->getSkin(); 00028 $isredir = " (" . wfMsg( "isredirect" ) . ")\n"; 00029 00030 $wgOut->addHTML("&lt; ".$sk->makeKnownLinkObj($nt, "", "redirect=no" )."<br />\n"); 00031 00032 if ( 0 == $id ) { 00033 $sql = "SELECT cur_id,cur_namespace,cur_title,cur_is_redirect FROM brokenlinks,cur WHERE bl_to='" . 00034 wfStrencode( $nt->getPrefixedDBkey() ) . "' AND bl_from=cur_id LIMIT $limit"; 00035 $res = wfQuery( $sql, DB_READ, $fname ); 00036 00037 if ( 0 == wfNumRows( $res ) ) { 00038 $wgOut->addHTML( wfMsg( "nolinkshere" ) ); 00039 } else { 00040 $wgOut->addHTML( wfMsg( "linkshere" ) ); 00041 $wgOut->addHTML( "\n<ul>" ); 00042 00043 while ( $row = wfFetchObject( $res ) ) { 00044 $nt = Title::makeTitle( $row->cur_namespace, $row->cur_title ); 00045 if( !$nt ) { 00046 continue; 00047 } 00048 $link = $sk->makeKnownLinkObj( $nt, "", "redirect=no" ); 00049 $wgOut->addHTML( "<li>{$link}" ); 00050 00051 if ( $row->cur_is_redirect ) { 00052 $wgOut->addHTML( $isredir ); 00053 wfShowIndirectLinks( 1, $row->cur_id, $limit ); 00054 } 00055 $wgOut->addHTML( "</li>\n" ); 00056 } 00057 $wgOut->addHTML( "</ul>\n" ); 00058 wfFreeResult( $res ); 00059 } 00060 } else { 00061 wfShowIndirectLinks( 0, $id, $limit ); 00062 } 00063 } 00064 00065 function wfShowIndirectLinks( $level, $lid, $limit ) 00066 { 00067 global $wgOut, $wgUser; 00068 $fname = "wfShowIndirectLinks"; 00069 00070 $sql = "SELECT cur_id,cur_namespace,cur_title,cur_is_redirect FROM links,cur WHERE l_to={$lid} AND l_from=cur_id LIMIT $limit"; 00071 $res = wfQuery( $sql, DB_READ, $fname ); 00072 00073 if ( 0 == wfNumRows( $res ) ) { 00074 if ( 0 == $level ) { 00075 $wgOut->addHTML( wfMsg( "nolinkshere" ) ); 00076 } 00077 return; 00078 } 00079 if ( 0 == $level ) { 00080 $wgOut->addHTML( wfMsg( "linkshere" ) ); 00081 } 00082 $sk = $wgUser->getSkin(); 00083 $isredir = " (" . wfMsg( "isredirect" ) . ")\n"; 00084 00085 $wgOut->addHTML( "<ul>" ); 00086 while ( $row = wfFetchObject( $res ) ) { 00087 $nt = Title::makeTitle( $row->cur_namespace, $row->cur_title ); 00088 if( !$nt ) { 00089 $wgOut->addHTML( "<!-- bad backlink: " . htmlspecialchars( $row->l_from ) . " -->\n" ); 00090 continue; 00091 } 00092 00093 if ( $row->cur_is_redirect ) { 00094 $extra = "redirect=no"; 00095 } else { 00096 $extra = ""; 00097 } 00098 00099 $link = $sk->makeKnownLinkObj( $nt, "", $extra ); 00100 $wgOut->addHTML( "<li>{$link}" ); 00101 00102 if ( $row->cur_is_redirect ) { 00103 $wgOut->addHTML( $isredir ); 00104 if ( $level < 2 ) { 00105 wfShowIndirectLinks( $level + 1, $row->cur_id, $limit ); 00106 } 00107 } 00108 $wgOut->addHTML( "</li>\n" ); 00109 } 00110 $wgOut->addHTML( "</ul>\n" ); 00111 } 00112 00113 ?>

Generated on Tue Jun 29 23:40:07 2004 for Mediawiki by doxygen 1.3.7