From: Rob Church Date: Mon, 2 Jan 2006 13:03:14 +0000 (+0000) Subject: * (bug 1996) Special page to list redirects X-Git-Tag: 1.6.0~807 X-Git-Url: http://git.cyclocoop.org/%22.%24h.%22?a=commitdiff_plain;h=921530365fc6fc17219ae6017c2b9bedc94bb6b3;p=lhc%2Fweb%2Fwiklou.git * (bug 1996) Special page to list redirects --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index d900df7495..c000fa9630 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -390,6 +390,7 @@ fully support the editing toolbar, but was found to be too confusing. * (bug 4413) Update of Farsi language file (LanguageFa.php) * Update for LanguageSr (Serbian): magic words * (bug 4371) Disallow tilde character in signatures +* (bug 1996) Special page to list redirects === Caveats === diff --git a/includes/SpecialListredirects.php b/includes/SpecialListredirects.php new file mode 100644 index 0000000000..acd1a6de09 --- /dev/null +++ b/includes/SpecialListredirects.php @@ -0,0 +1,61 @@ + + * @copyright © 2006 Rob Church + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later + */ + +/* */ +require_once 'QueryPage.php'; + +/** + * @package MediaWiki + * @subpackage SpecialPage + */ + +class ListredirectsPage extends QueryPage { + + function getName() { return( 'listredirects' ); } + function isExpensive() { return( true ); } + function isSyndicated() { return( false ); } + function sortDescending() { return( false ); } + + function getSQL() { + $dbr =& wfGetDB( DB_SLAVE ); + extract( $dbr->tableNames( 'page' ) ); + return( 'SELECT page_title AS title, page_namespace AS namespace, page_namespace AS value FROM ' . $page . ' WHERE page_is_redirect = 1' ); + } + + function formatResult( $skin, $result ) { + global $wgContLang; + + # Make a link to the redirect itself + $rd_title = Title::makeTitle( $result->namespace, $result->title ); + $rd_link_text = htmlspecialchars( $wgContLang->convert( $rd_title->getPrefixedText() ) ); + $rd_link = $skin->makeKnownLink( $rd_title->getPrefixedText(), $rd_link_text, 'redirect=no' ); + + # Find out where the redirect leads + $rd_page = new Article( &$rd_title, 0 ); + $rd_text = $rd_page->getContent( true ); # Don't follow the redirect + + # Make a link to the destination page + $tp_title = Title::newFromRedirect( $rd_text ); + $tp_link_text = htmlspecialchars( $tp_title->getPrefixedText() ); + $tp_link = $skin->makeKnownLink( $tp_title->getPrefixedText(), $tp_link_text ); + + # Format the whole thing and return it + return( $rd_link . ' → ' . $tp_link ); + } + +} + +function wfSpecialListredirects() { + list( $limit, $offset ) = wfCheckLimits(); + $lrp = new ListredirectsPage(); + $lrp->doQuery( $offset, $limit ); +} + +?> \ No newline at end of file diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index 54e410e0df..ce8cb4d6c1 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -76,7 +76,8 @@ $wgSpecialPages = array( 'Unlockdb' => new SpecialPage( 'Unlockdb', 'siteadmin' ), 'Userrights' => new SpecialPage( 'Userrights', 'userrights' ), 'MIMEsearch' => new SpecialPage( 'MIMEsearch' ), - 'Unwatchedpages' => new SpecialPage( 'Unwatchedpages', 'unwatchedpages' ) + 'Unwatchedpages' => new SpecialPage( 'Unwatchedpages', 'unwatchedpages' ), + 'Listredirects' => new SpecialPage( 'Listredirects' ) ); if( !$wgDisableCounters ) { diff --git a/languages/Language.php b/languages/Language.php index 28e1801747..cd944025d4 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -1109,6 +1109,9 @@ this old version, (rev) = revert to this old version. # 'unwatchedpages' => 'Unwatched pages', +# List redirects +'listredirects' => 'List redirects', + # Statistics # 'statistics' => 'Statistics',