r11166 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r11165‎ | r11166 | r11167 >
Date:23:34, 30 September 2005
Author:avar
Status:old
Tags:
Comment:
* Special:RandomFA for getting a random featured article
Modified paths:
  • /trunk/phase3/includes/SpecialPage.php (modified) (history)
  • /trunk/phase3/includes/SpecialRandomFA.php (added) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialPage.php
@@ -36,6 +36,7 @@
3737 'Listusers' => new SpecialPage( 'Listusers' ),
3838 'Statistics' => new SpecialPage( 'Statistics' ),
3939 'Random' => new SpecialPage( 'Randompage' ),
 40+ 'RandomFA' => new SpecialPage( 'RandomFA' ),
4041 'Lonelypages' => new SpecialPage( 'Lonelypages' ),
4142 'Uncategorizedpages'=> new SpecialPage( 'Uncategorizedpages' ),
4243 'Uncategorizedcategories'=> new SpecialPage( 'Uncategorizedcategories' ),
Index: trunk/phase3/includes/SpecialRandomFA.php
@@ -0,0 +1,48 @@
 2+<?php
 3+/**
 4+ * @package MediaWiki
 5+ * @subpackage SpecialPage
 6+ */
 7+
 8+/**
 9+ * Constructor
 10+ */
 11+function wfSpecialRandomFA() {
 12+ global $wgOut, $wgTitle, $wgArticle, $wgContLang;
 13+ $fname = 'wfSpecialRandomFA';
 14+
 15+ $dbr =& wfGetDB( DB_SLAVE );
 16+ $use_index = $dbr->useIndexClause( 'page_random' );
 17+ extract( $dbr->tableNames( 'page', 'pagelinks' ) );
 18+
 19+ $randstr = wfRandom();
 20+ $ft = Title::newFromText( wfMsgForContent( 'featuredtemplate' ) );
 21+ if ( is_null( $ft ) ) {
 22+ $title = Title::newFromText( wfMsgForContent( 'mainpage' ) );
 23+ $wgOut->redirect( $title->getFullUrl() );
 24+ return;
 25+ }
 26+ $template = $dbr->addQuotes( $ft->getDBkey() );
 27+ $sql = "
 28+ SELECT page_title, page_random
 29+ FROM $pagelinks
 30+ LEFT JOIN $page $use_index ON page_id = pl_from
 31+ WHERE pl_title = $template AND pl_namespace = " . NS_TEMPLATE . " AND page_namespace = " . NS_TALK . " AND page_random > $randstr
 32+ ORDER BY page_random
 33+ ";
 34+ $sql = $dbr->limitResult($sql, 1, 0);
 35+ $res = $dbr->query( $sql, $fname );
 36+
 37+ $title = null;
 38+ if ( $s = $dbr->fetchObject( $res ) ) {
 39+ $title =& Title::makeTitle( NS_MAIN, $s->page_title );
 40+ }
 41+ if ( is_null( $title ) ) {
 42+ # That's not supposed to happen :)
 43+ $title = Title::newFromText( wfMsgForContent( 'mainpage' ) );
 44+ }
 45+ $wgOut->reportTime(); # for logfile
 46+ $wgOut->redirect( $title->getFullUrl() );
 47+}
 48+
 49+?>
Property changes on: trunk/phase3/includes/SpecialRandomFA.php
___________________________________________________________________
Added: svn:eol-style
150 + native
Added: svn:keywords
251 + Author Date Id Revision
Index: trunk/phase3/languages/Language.php
@@ -1106,6 +1106,7 @@
11071107 'maintenancebacklink' => 'Back to Maintenance Page',
11081108 'disambiguations' => 'Disambiguation pages',
11091109 'disambiguationspage' => 'Template:disambig',
 1110+'featuredtemplate' => 'Template:Featured',
11101111 'disambiguationstext' => "The following pages link to a <i>disambiguation page</i>. They should link to the appropriate topic instead.<br />A page is treated as disambiguation if it is linked from $1.<br />Links from other namespaces are <i>not</i> listed here.",
11111112 'doubleredirects' => 'Double redirects',
11121113 'doubleredirectstext' => "Each row contains links to the first and second redirect, as well as the first line of the second redirect text, usually giving the \"real\" target page, which the first redirect should point to.",

Status & tagging log