r49527 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49526‎ | r49527 | r49528 >
Date:21:04, 15 April 2009
Author:catrope
Status:deferred
Tags:
Comment:
querypage-work: Merge r49489 from trunk
Modified paths:
  • /branches/querypage-work/phase3/includes/QueryPage.php (modified) (history)

Diff [purge]

Index: branches/querypage-work/phase3/includes/QueryPage.php
@@ -598,3 +598,73 @@
599599 return $title->getFullURL();
600600 }
601601 }
 602+
 603+/**
 604+ * Class definition for a wanted query page like
 605+ * WantedPages, WantedTemplates, etc
 606+ */
 607+abstract class WantedQueryPage extends QueryPage {
 608+
 609+ function isExpensive() {
 610+ return true;
 611+ }
 612+
 613+ function isSyndicated() {
 614+ return false;
 615+ }
 616+
 617+ /**
 618+ * Cache page existence for performance
 619+ */
 620+ function preprocessResults( $db, $res ) {
 621+ $batch = new LinkBatch;
 622+ while ( $row = $db->fetchObject( $res ) )
 623+ $batch->add( $row->namespace, $row->title );
 624+ $batch->execute();
 625+
 626+ // Back to start for display
 627+ if ( $db->numRows( $res ) > 0 )
 628+ // If there are no rows we get an error seeking.
 629+ $db->dataSeek( $res, 0 );
 630+ }
 631+
 632+ /**
 633+ * Format an individual result
 634+ *
 635+ * @param $skin Skin to use for UI elements
 636+ * @param $result Result row
 637+ * @return string
 638+ */
 639+ public function formatResult( $skin, $result ) {
 640+ $title = Title::makeTitleSafe( $result->namespace, $result->title );
 641+ if( $title instanceof Title ) {
 642+ if( $this->isCached() ) {
 643+ $pageLink = $title->exists()
 644+ ? '<s>' . $skin->makeLinkObj( $title ) . '</s>'
 645+ : $skin->makeBrokenLinkObj( $title );
 646+ } else {
 647+ $pageLink = $skin->makeBrokenLinkObj( $title );
 648+ }
 649+ return wfSpecialList( $pageLink, $this->makeWlhLink( $title, $skin, $result ) );
 650+ } else {
 651+ $tsafe = htmlspecialchars( $result->title );
 652+ return wfMsg( 'wantedpages-badtitle', $tsafe );
 653+ }
 654+ }
 655+
 656+ /**
 657+ * Make a "what links here" link for a given title
 658+ *
 659+ * @param Title $title Title to make the link for
 660+ * @param Skin $skin Skin to use
 661+ * @param object $result Result row
 662+ * @return string
 663+ */
 664+ private function makeWlhLink( $title, $skin, $result ) {
 665+ global $wgLang;
 666+ $wlh = SpecialPage::getTitleFor( 'Whatlinkshere' );
 667+ $label = wfMsgExt( 'nlinks', array( 'parsemag', 'escape' ),
 668+ $wgLang->formatNum( $result->value ) );
 669+ return $skin->link( $wlh, $label, array(), array( 'target' => $title->getPrefixedText() ) );
 670+ }
 671+}
Property changes on: branches/querypage-work/phase3/includes/QueryPage.php
___________________________________________________________________
Name: svn:mergeinfo
602672 + /trunk/phase3/includes/QueryPage.php:49489

Follow-up revisions

RevisionCommit summaryAuthorDate
r65311querypage-work2: Merge r49084 skip r49527 (already in trunk)reedy13:49, 20 April 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r49489(bug 18151) Clean up duplicate code between Special:WantedPages, WantedFiles,...demon03:35, 15 April 2009

Status & tagging log