X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSpecialWhatlinkshere.php;h=4d5bfa0564d75d98f04d0ad76a633fe522d8c5e5;hb=027030d18104525bd9c3e7b6fb68251e9ead6820;hp=d7bfa3d69f8659645554aab40ad858a965c06a63;hpb=ffd7f8d72470bf5f39c8f768a7e0ca2399494419;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SpecialWhatlinkshere.php b/includes/SpecialWhatlinkshere.php index d7bfa3d69f..4d5bfa0564 100644 --- a/includes/SpecialWhatlinkshere.php +++ b/includes/SpecialWhatlinkshere.php @@ -1,122 +1,127 @@ -errorpage( "notargettitle", "notargettext" ); +getVal( 'target' ); + list( $limit, $offset ) = $wgRequest->getLimitOffset(); + + if (is_null($target)) { + $wgOut->errorpage( 'notargettitle', 'notargettext' ); return; } + $nt = Title::newFromURL( $target ); if( !$nt ) { - $wgOut->errorpage( "notargettitle", "notargettext" ); + $wgOut->errorpage( 'notargettitle', 'notargettext' ); return; } $wgOut->setPagetitle( $nt->getPrefixedText() ); - $wgOut->setSubtitle( wfMsg( "linklistsub" ) ); + $wgOut->setSubtitle( wfMsg( 'linklistsub' ) ); - $id = $nt->getArticleID(); $sk = $wgUser->getSkin(); - $isredir = " (" . wfMsg( "isredirect" ) . ")\n"; + $isredir = ' (' . wfMsg( 'isredirect' ) . ")\n"; - if ( 0 == $id ) { - $sql = "SELECT DISTINCT bl_from FROM brokenlinks WHERE bl_to='" . - wfStrencode( $nt->getPrefixedDBkey() ) . "' LIMIT 500"; - $res = wfQuery( $sql, DB_READ, $fname ); + $wgOut->addHTML('< '.$sk->makeKnownLinkObj($nt, '', 'redirect=no' )."
\n"); - if ( 0 == wfNumRows( $res ) ) { - $wgOut->addHTML( wfMsg( "nolinkshere" ) ); - } else { - $wgOut->addHTML( wfMsg( "linkshere" ) ); - $wgOut->addHTML( "\n\n" ); - wfFreeResult( $res ); - } - } else { - wfShowIndirectLinks( 0, $id ); - } + wfShowIndirectLinks( 0, $nt, $limit, $offset ); } -function wfShowIndirectLinks( $level, $lid ) -{ +/** + * @param int $level + * @param Title $target + * @param int $limit + * @param int $offset + * @access private + */ +function wfShowIndirectLinks( $level, $target, $limit, $offset = 0 ) { global $wgOut, $wgUser; - $fname = "wfShowIndirectLinks"; - - $sql = "SELECT DISTINCT l_from FROM links WHERE l_to={$lid} ORDER BY l_from LIMIT 500"; - $res = wfQuery( $sql, DB_READ, $fname ); - - if ( 0 == wfNumRows( $res ) ) { + $fname = 'wfShowIndirectLinks'; + + $dbr =& wfGetDB( DB_READ ); + + // Read one extra row as an at-end check + $queryLimit = $limit + 1; + $limitSql = ( $level == 0 ) + ? "$offset,$queryLimit" + : $queryLimit; + + $res = $dbr->select( array( 'pagelinks', 'page' ), + array( 'page_id', 'page_namespace', 'page_title', 'page_is_redirect' ), + array( + 'pl_from=page_id', + 'pl_namespace' => $target->getNamespace(), + 'pl_title' => $target->getDbKey() ), + $fname, + array( 'LIMIT' => $limitSql ) ); + + if ( 0 == $dbr->numRows( $res ) ) { if ( 0 == $level ) { - $wgOut->addHTML( wfMsg( "nolinkshere" ) ); + $wgOut->addWikiText( wfMsg( 'nolinkshere' ) ); } return; } if ( 0 == $level ) { - $wgOut->addHTML( wfMsg( "linkshere" ) ); + $wgOut->addWikiText( wfMsg( 'linkshere' ) ); } $sk = $wgUser->getSkin(); - $isredir = " (" . wfMsg( "isredirect" ) . ")\n"; - - $wgOut->addHTML( "