[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Implements Special:Brokenredirects 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License along 16 * with this program; if not, write to the Free Software Foundation, Inc., 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 * http://www.gnu.org/copyleft/gpl.html 19 * 20 * @file 21 * @ingroup SpecialPage 22 */ 23 24 /** 25 * A special page listing redirects to non existent page. Those should be 26 * fixed to point to an existing page. 27 * 28 * @ingroup SpecialPage 29 */ 30 class BrokenRedirectsPage extends QueryPage { 31 function __construct( $name = 'BrokenRedirects' ) { 32 parent::__construct( $name ); 33 } 34 35 function isExpensive() { 36 return true; 37 } 38 39 function isSyndicated() { 40 return false; 41 } 42 43 function sortDescending() { 44 return false; 45 } 46 47 function getPageHeader() { 48 return $this->msg( 'brokenredirectstext' )->parseAsBlock(); 49 } 50 51 function getQueryInfo() { 52 $dbr = wfGetDB( DB_SLAVE ); 53 54 return array( 55 'tables' => array( 56 'redirect', 57 'p1' => 'page', 58 'p2' => 'page', 59 ), 60 'fields' => array( 61 'namespace' => 'p1.page_namespace', 62 'title' => 'p1.page_title', 63 'value' => 'p1.page_title', 64 'rd_namespace', 65 'rd_title', 66 ), 67 'conds' => array( 68 // Exclude pages that don't exist locally as wiki pages, 69 // but aren't "broken" either. 70 // Special pages and interwiki links 71 'rd_namespace >= 0', 72 'rd_interwiki IS NULL OR rd_interwiki = ' . $dbr->addQuotes( '' ), 73 'p2.page_namespace IS NULL', 74 ), 75 'join_conds' => array( 76 'p1' => array( 'JOIN', array( 77 'rd_from=p1.page_id', 78 ) ), 79 'p2' => array( 'LEFT JOIN', array( 80 'rd_namespace=p2.page_namespace', 81 'rd_title=p2.page_title' 82 ) ), 83 ), 84 ); 85 } 86 87 /** 88 * @return array 89 */ 90 function getOrderFields() { 91 return array( 'rd_namespace', 'rd_title', 'rd_from' ); 92 } 93 94 /** 95 * @param Skin $skin 96 * @param object $result Result row 97 * @return string 98 */ 99 function formatResult( $skin, $result ) { 100 $fromObj = Title::makeTitle( $result->namespace, $result->title ); 101 if ( isset( $result->rd_title ) ) { 102 $toObj = Title::makeTitle( $result->rd_namespace, $result->rd_title ); 103 } else { 104 $blinks = $fromObj->getBrokenLinksFrom(); # TODO: check for redirect, not for links 105 if ( $blinks ) { 106 $toObj = $blinks[0]; 107 } else { 108 $toObj = false; 109 } 110 } 111 112 // $toObj may very easily be false if the $result list is cached 113 if ( !is_object( $toObj ) ) { 114 return '<del>' . Linker::link( $fromObj ) . '</del>'; 115 } 116 117 $from = Linker::linkKnown( 118 $fromObj, 119 null, 120 array(), 121 array( 'redirect' => 'no' ) 122 ); 123 $links = array(); 124 $links[] = Linker::linkKnown( 125 $fromObj, 126 $this->msg( 'brokenredirects-edit' )->escaped(), 127 array(), 128 array( 'action' => 'edit' ) 129 ); 130 $to = Linker::link( 131 $toObj, 132 null, 133 array(), 134 array(), 135 array( 'broken' ) 136 ); 137 $arr = $this->getLanguage()->getArrow(); 138 139 $out = $from . $this->msg( 'word-separator' )->escaped(); 140 141 if ( $this->getUser()->isAllowed( 'delete' ) ) { 142 $links[] = Linker::linkKnown( 143 $fromObj, 144 $this->msg( 'brokenredirects-delete' )->escaped(), 145 array(), 146 array( 'action' => 'delete' ) 147 ); 148 } 149 150 $out .= $this->msg( 'parentheses' )->rawParams( $this->getLanguage() 151 ->pipeList( $links ) )->escaped(); 152 $out .= " {$arr} {$to}"; 153 154 return $out; 155 } 156 157 protected function getGroupName() { 158 return 'maintenance'; 159 } 160 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |