MediaWiki  REL1_24
WantedQueryPage.php
Go to the documentation of this file.
00001 <?php
00029 abstract class WantedQueryPage extends QueryPage {
00030     function isExpensive() {
00031         return true;
00032     }
00033 
00034     function isSyndicated() {
00035         return false;
00036     }
00037 
00043     function preprocessResults( $db, $res ) {
00044         if ( !$res->numRows() ) {
00045             return;
00046         }
00047 
00048         $batch = new LinkBatch;
00049         foreach ( $res as $row ) {
00050             $batch->add( $row->namespace, $row->title );
00051         }
00052         $batch->execute();
00053 
00054         // Back to start for display
00055         $res->seek( 0 );
00056     }
00057 
00066     function forceExistenceCheck() {
00067         return false;
00068     }
00069 
00077     public function formatResult( $skin, $result ) {
00078         $title = Title::makeTitleSafe( $result->namespace, $result->title );
00079         if ( $title instanceof Title ) {
00080             if ( $this->isCached() || $this->forceExistenceCheck() ) {
00081                 $pageLink = $this->existenceCheck( $title )
00082                     ? '<del>' . Linker::link( $title ) . '</del>'
00083                     : Linker::link( $title );
00084             } else {
00085                 $pageLink = Linker::link(
00086                     $title,
00087                     null,
00088                     array(),
00089                     array(),
00090                     array( 'broken' )
00091                 );
00092             }
00093             return $this->getLanguage()->specialList( $pageLink, $this->makeWlhLink( $title, $result ) );
00094         } else {
00095             return $this->msg( 'wantedpages-badtitle', $result->title )->escaped();
00096         }
00097     }
00098 
00114     protected function existenceCheck( Title $title ) {
00115         return $title->isKnown();
00116     }
00117 
00125     private function makeWlhLink( $title, $result ) {
00126         $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() );
00127         $label = $this->msg( 'nlinks' )->numParams( $result->value )->escaped();
00128         return Linker::link( $wlh, $label );
00129     }
00130 }