From b4ac098b9e7b77085d1b01d50d930411ecb870bf Mon Sep 17 00:00:00 2001 From: Rob Church Date: Sat, 22 Apr 2006 02:36:54 +0000 Subject: [PATCH] (bug 1922) When Special:Wantedpages is cached, mark links to pages which have since been created --- RELEASE-NOTES | 2 ++ includes/SpecialWantedpages.php | 45 +++++++++++++++++++++++++-------- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 97d7048ffc..329f29b331 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -109,6 +109,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Fix linktrail for LanguageSr * (bug 5664) Fix Bosnian linktrail * (bug 3825) Namespace filtering on Special:Newpages +* (bug 1922) When Special:Wantedpages is cached, mark links to pages + which have since been created == Compatibility == diff --git a/includes/SpecialWantedpages.php b/includes/SpecialWantedpages.php index f4a8f30f8d..8d878694f1 100644 --- a/includes/SpecialWantedpages.php +++ b/includes/SpecialWantedpages.php @@ -70,17 +70,42 @@ class WantedPagesPage extends QueryPage { function formatResult( $skin, $result ) { global $wgContLang; - $nt = Title::makeTitle( $result->namespace, $result->title ); - $text = $wgContLang->convert( $nt->getPrefixedText() ); - $plink = $this->isCached() ? - $skin->makeLinkObj( $nt, $text ) : - $skin->makeBrokenLink( $nt->getPrefixedText(), $text ); - - $nl = wfMsg( 'nlinks', $result->value ); - $nlink = $skin->makeKnownLink( $wgContLang->specialPage( 'Whatlinkshere' ), $nl, 'target=' . $nt->getPrefixedURL() ); - - return $this->nlinks ? "$plink ($nlink)" : $plink; + $title = Title::makeTitleSafe( $result->namespace, $result->title ); + + if( $this->isCached() ) { + # Check existence; which is stored in the link cache + if( !$title->exists() ) { + # Make a redlink + $pageLink = $skin->makeBrokenLinkObj( $title ); + } else { + # Make a struck-out blue link + $pageLink = "" . $skin->makeKnownLinkObj( $title ) . ""; + } + } else { + # Not cached? Don't bother checking existence; it can't + $pageLink = $skin->makeBrokenLinkObj( $title ); + } + + # Make a link to "what links here" if it's required + $wlhLink = $this->nlinks + ? " (" . $this->makeWlhLink( $title, $skin, wfMsgHtml( 'nlinks', $result->value ) ) . ")" + : ""; + + return "{$pageLink}{$wlhLink}"; + } + + /** + * Make a "what links here" link for a specified title + * @param $title Title to make the link for + * @param $skin Skin to use + * @param $text Link text + * @return string + */ + function makeWlhLink( &$title, &$skin, $text ) { + $wlhTitle = Title::makeTitle( NS_SPECIAL, 'Whatlinkshere' ); + return $skin->makeKnownLinkObj( $wlhTitle, $text, 'target=' . $title->getPrefixedUrl() ); } + } /** -- 2.20.1