<?php
/**
+ * Implements Special:Brokenredirects
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup SpecialPage
*/
/**
- * A special page listing redirects tonon existent page. Those should be
+ * A special page listing redirects to non existent page. Those should be
* fixed to point to an existing page.
*
- * @file
* @ingroup SpecialPage
*/
class BrokenRedirectsPage extends PageQueryPage {
- var $targets = array();
- function getName() {
- return 'BrokenRedirects';
+ function __construct( $name = 'BrokenRedirects' ) {
+ parent::__construct( $name );
}
- function isExpensive( ) { return true; }
+ function isExpensive() { return true; }
function isSyndicated() { return false; }
+ function sortDescending() { return false; }
- function getPageHeader( ) {
- return wfMsgExt( 'brokenredirectstext', array( 'parse' ) );
+ function getPageHeader() {
+ return $this->msg( 'brokenredirectstext' )->parseAsBlock();
}
- function getSQL() {
- $dbr = wfGetDB( DB_SLAVE );
- list( $page, $redirect ) = $dbr->tableNamesN( 'page', 'redirect' );
-
- $sql = "SELECT 'BrokenRedirects' AS type,
- p1.page_namespace AS namespace,
- p1.page_title AS title,
- rd_namespace,
- rd_title
- FROM $redirect AS rd
- JOIN $page p1 ON (rd.rd_from=p1.page_id)
- LEFT JOIN $page AS p2 ON (rd_namespace=p2.page_namespace AND rd_title=p2.page_title )
- WHERE rd_namespace >= 0
- AND p2.page_namespace IS NULL";
- return $sql;
+ function getQueryInfo() {
+ return array(
+ 'tables' => array( 'redirect', 'p1' => 'page',
+ 'p2' => 'page' ),
+ 'fields' => array( 'p1.page_namespace AS namespace',
+ 'p1.page_title AS title',
+ 'p1.page_title AS value',
+ 'rd_namespace',
+ 'rd_title'
+ ),
+ 'conds' => array( 'rd_namespace >= 0',
+ 'p2.page_namespace IS NULL'
+ ),
+ 'join_conds' => array( 'p1' => array( 'JOIN', array(
+ 'rd_from=p1.page_id',
+ ) ),
+ 'p2' => array( 'LEFT JOIN', array(
+ 'rd_namespace=p2.page_namespace',
+ 'rd_title=p2.page_title'
+ ) )
+ )
+ );
}
- function getOrder() {
- return '';
+ /**
+ * @return array
+ */
+ function getOrderFields() {
+ return array ( 'rd_namespace', 'rd_title', 'rd_from' );
}
+ /**
+ * @param $skin Skin
+ * @param $result
+ * @return String
+ */
function formatResult( $skin, $result ) {
- global $wgUser, $wgContLang, $wgLang;
-
$fromObj = Title::makeTitle( $result->namespace, $result->title );
if ( isset( $result->rd_title ) ) {
$toObj = Title::makeTitle( $result->rd_namespace, $result->rd_title );
// $toObj may very easily be false if the $result list is cached
if ( !is_object( $toObj ) ) {
- return '<s>' . $skin->link( $fromObj ) . '</s>';
+ return '<del>' . Linker::link( $fromObj ) . '</del>';
}
- $from = $skin->linkKnown(
+ $from = Linker::linkKnown(
$fromObj,
null,
array(),
array( 'redirect' => 'no' )
);
$links = array();
- $links[] = $skin->linkKnown(
+ $links[] = Linker::linkKnown(
$fromObj,
- wfMsgHtml( 'brokenredirects-edit' ),
+ $this->msg( 'brokenredirects-edit' )->escaped(),
array(),
array( 'action' => 'edit' )
);
- $to = $skin->link(
+ $to = Linker::link(
$toObj,
null,
array(),
array(),
array( 'broken' )
);
- $arr = $wgContLang->getArrow();
+ $arr = $this->getLanguage()->getArrow();
- $out = $from . wfMsg( 'word-separator' );
+ $out = $from . $this->msg( 'word-separator' )->escaped();
- if( $wgUser->isAllowed( 'delete' ) ) {
- $links[] = $skin->linkKnown(
+ if( $this->getUser()->isAllowed( 'delete' ) ) {
+ $links[] = Linker::linkKnown(
$fromObj,
- wfMsgHtml( 'brokenredirects-delete' ),
+ $this->msg( 'brokenredirects-delete' )->escaped(),
array(),
array( 'action' => 'delete' )
);
}
- $out .= wfMsg( 'parentheses', $wgLang->pipeList( $links ) );
+ $out .= $this->msg( 'parentheses' )->rawParams( $this->getLanguage()->pipeList( $links ) )->escaped();
$out .= " {$arr} {$to}";
return $out;
}
}
-
-/**
- * constructor
- */
-function wfSpecialBrokenRedirects() {
- list( $limit, $offset ) = wfCheckLimits();
-
- $sbr = new BrokenRedirectsPage();
-
- return $sbr->doQuery( $offset, $limit );
-}