From c1f9b1f7b1b77776192048005dcc66dcf3df2bfb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 27 Dec 2014 15:41:37 +0100 Subject: Update to MediaWiki 1.24.1 --- includes/specialpage/WantedQueryPage.php | 130 +++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 includes/specialpage/WantedQueryPage.php (limited to 'includes/specialpage/WantedQueryPage.php') diff --git a/includes/specialpage/WantedQueryPage.php b/includes/specialpage/WantedQueryPage.php new file mode 100644 index 00000000..be2f1e8d --- /dev/null +++ b/includes/specialpage/WantedQueryPage.php @@ -0,0 +1,130 @@ +numRows() ) { + return; + } + + $batch = new LinkBatch; + foreach ( $res as $row ) { + $batch->add( $row->namespace, $row->title ); + } + $batch->execute(); + + // Back to start for display + $res->seek( 0 ); + } + + /** + * Should formatResult() always check page existence, even if + * the results are fresh? This is a (hopefully temporary) + * kluge for Special:WantedFiles, which may contain false + * positives for files that exist e.g. in a shared repo (bug + * 6220). + * @return bool + */ + function forceExistenceCheck() { + return false; + } + + /** + * Format an individual result + * + * @param Skin $skin Skin to use for UI elements + * @param object $result Result row + * @return string + */ + public function formatResult( $skin, $result ) { + $title = Title::makeTitleSafe( $result->namespace, $result->title ); + if ( $title instanceof Title ) { + if ( $this->isCached() || $this->forceExistenceCheck() ) { + $pageLink = $this->existenceCheck( $title ) + ? '' . Linker::link( $title ) . '' + : Linker::link( $title ); + } else { + $pageLink = Linker::link( + $title, + null, + array(), + array(), + array( 'broken' ) + ); + } + return $this->getLanguage()->specialList( $pageLink, $this->makeWlhLink( $title, $result ) ); + } else { + return $this->msg( 'wantedpages-badtitle', $result->title )->escaped(); + } + } + + /** + * Does the Title currently exists + * + * This method allows a subclass to override this check + * (For example, wantedfiles, would want to check if the file exists + * not just that a page in the file namespace exists). + * + * This will only control if the link is crossed out. Whether or not the link + * is blue vs red is controlled by if the title exists. + * + * @note This will only be run if the page is cached (ie $wgMiserMode = true) + * unless forceExistenceCheck() is true. + * @since 1.24 + * @return boolean + */ + protected function existenceCheck( Title $title ) { + return $title->isKnown(); + } + + /** + * Make a "what links here" link for a given title + * + * @param Title $title Title to make the link for + * @param object $result Result row + * @return string + */ + private function makeWlhLink( $title, $result ) { + $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() ); + $label = $this->msg( 'nlinks' )->numParams( $result->value )->escaped(); + return Linker::link( $wlh, $label ); + } +} -- cgit v1.2.3-54-g00ecf