Index: trunk/phase3/includes/SpecialPage.php |
— | — | @@ -80,6 +80,7 @@ |
81 | 81 | 'Listredirects' => new SpecialPage( 'Listredirects' ), |
82 | 82 | 'Revisiondelete' => new SpecialPage( 'Revisiondelete', 'deleterevision' ), |
83 | 83 | 'Unusedtemplates' => new SpecialPage( 'Unusedtemplates' ), |
| 84 | + 'Randomredirect' => new SpecialPage( 'Randomredirect' ), |
84 | 85 | ); |
85 | 86 | |
86 | 87 | if( !$wgDisableCounters ) { |
Index: trunk/phase3/includes/SpecialRandomredirect.php |
— | — | @@ -0,0 +1,54 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Special page to direct the user to a random redirect page (minus the second redirect) |
| 6 | + * |
| 7 | + * @package MediaWiki |
| 8 | + * @subpackage Special pages |
| 9 | + * @author Rob Church <robchur@gmail.com> |
| 10 | + * @licence GNU General Public Licence 2.0 or later |
| 11 | + */ |
| 12 | + |
| 13 | +/** |
| 14 | + * Main execution point |
| 15 | + * @param $par Namespace to select the redirect from |
| 16 | + */ |
| 17 | +function wfSpecialRandomredirect( $par = NULL ) { |
| 18 | + global $wgOut, $wgExtraRandompageSQL, $wgContLang; |
| 19 | + $fname = 'wfSpecialRandomredirect'; |
| 20 | + |
| 21 | + # Validate the namespace |
| 22 | + $namespace = $wgContLang->getNsIndex( $par ); |
| 23 | + if( $namespace === false || $namespace < NS_MAIN ) |
| 24 | + $namespace = NS_MAIN; |
| 25 | + |
| 26 | + # Same logic as RandomPage |
| 27 | + $randstr = wfRandom(); |
| 28 | + |
| 29 | + $dbr =& wfGetDB( DB_SLAVE ); |
| 30 | + $use_index = $dbr->useIndexClause( 'page_random' ); |
| 31 | + $page = $dbr->tableName( 'page' ); |
| 32 | + |
| 33 | + $extra = $wgExtraRandompageSQL ? "AND ($wgExtraRandompageSQL)" : ''; |
| 34 | + $sql = "SELECT page_id,page_title |
| 35 | + FROM $page $use_index |
| 36 | + WHERE page_namespace = $namespace AND page_is_redirect = 1 $extra |
| 37 | + AND page_random > $randstr |
| 38 | + ORDER BY page_random"; |
| 39 | + |
| 40 | + $sql = $dbr->limitResult( $sql, 1, 0 ); |
| 41 | + $res = $dbr->query( $sql, $fname ); |
| 42 | + |
| 43 | + $title = NULL; |
| 44 | + if( $row = $dbr->fetchObject( $res ) ) |
| 45 | + $title = Title::makeTitleSafe( $namespace, $row->page_title ); |
| 46 | + |
| 47 | + # Catch dud titles and return to the main page |
| 48 | + if( is_null( $title ) ) |
| 49 | + $title = Title::newFromText( wfMsg( 'mainpage' ) ); |
| 50 | + |
| 51 | + $wgOut->reportTime(); |
| 52 | + $wgOut->redirect( $title->getFullUrl( 'redirect=no' ) ); |
| 53 | +} |
| 54 | + |
| 55 | +?> |
Property changes on: trunk/phase3/includes/SpecialRandomredirect.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 56 | + native |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -117,6 +117,7 @@ |
118 | 118 | * Treat "allmessagesnotsupporteddb" as wikitext when echoing; change default text |
119 | 119 | * (bug 5497) regeression in HTML normalization in 1.6 (unclosed <li>,<dd>,<dt>) |
120 | 120 | * (bug 5709) Allow customisation of separator for categories |
| 121 | +* (bug 5684) Introduce Special:Randomredirect |
121 | 122 | |
122 | 123 | == Compatibility == |
123 | 124 | |
Index: trunk/phase3/languages/Messages.php |
— | — | @@ -926,6 +926,9 @@ |
927 | 927 | 'unusedtemplatestext' => 'This page lists all pages in the template namespace which are not included in another page. Remember to check for other links to the templates before deleting them.', |
928 | 928 | 'unusedtemplateswlh' => 'other links', |
929 | 929 | |
| 930 | +# Random redirect |
| 931 | +'randomredirect' => 'Random redirect', |
| 932 | + |
930 | 933 | # Statistics |
931 | 934 | # |
932 | 935 | 'statistics' => 'Statistics', |