From: Ævar Arnfjörð Bjarmason Date: Fri, 30 Sep 2005 23:34:50 +0000 (+0000) Subject: * Special:RandomFA for getting a random featured article X-Git-Tag: 1.6.0~1555 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=a41a6facbba529284a4ea469b0601598f87b1f51;p=lhc%2Fweb%2Fwiklou.git * Special:RandomFA for getting a random featured article --- diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index b379a608cc..99788b8e12 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -36,6 +36,7 @@ $wgSpecialPages = array( 'Listusers' => new SpecialPage( 'Listusers' ), 'Statistics' => new SpecialPage( 'Statistics' ), 'Random' => new SpecialPage( 'Randompage' ), + 'RandomFA' => new SpecialPage( 'RandomFA' ), 'Lonelypages' => new SpecialPage( 'Lonelypages' ), 'Uncategorizedpages'=> new SpecialPage( 'Uncategorizedpages' ), 'Uncategorizedcategories'=> new SpecialPage( 'Uncategorizedcategories' ), diff --git a/includes/SpecialRandomFA.php b/includes/SpecialRandomFA.php new file mode 100644 index 0000000000..bec471f993 --- /dev/null +++ b/includes/SpecialRandomFA.php @@ -0,0 +1,48 @@ +useIndexClause( 'page_random' ); + extract( $dbr->tableNames( 'page', 'pagelinks' ) ); + + $randstr = wfRandom(); + $ft = Title::newFromText( wfMsgForContent( 'featuredtemplate' ) ); + if ( is_null( $ft ) ) { + $title = Title::newFromText( wfMsgForContent( 'mainpage' ) ); + $wgOut->redirect( $title->getFullUrl() ); + return; + } + $template = $dbr->addQuotes( $ft->getDBkey() ); + $sql = " + SELECT page_title, page_random + FROM $pagelinks + LEFT JOIN $page $use_index ON page_id = pl_from + WHERE pl_title = $template AND pl_namespace = " . NS_TEMPLATE . " AND page_namespace = " . NS_TALK . " AND page_random > $randstr + ORDER BY page_random + "; + $sql = $dbr->limitResult($sql, 1, 0); + $res = $dbr->query( $sql, $fname ); + + $title = null; + if ( $s = $dbr->fetchObject( $res ) ) { + $title =& Title::makeTitle( NS_MAIN, $s->page_title ); + } + if ( is_null( $title ) ) { + # That's not supposed to happen :) + $title = Title::newFromText( wfMsgForContent( 'mainpage' ) ); + } + $wgOut->reportTime(); # for logfile + $wgOut->redirect( $title->getFullUrl() ); +} + +?> diff --git a/languages/Language.php b/languages/Language.php index ee3b63e637..53ae7d8637 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -1106,6 +1106,7 @@ That comes to '''$5''' average edits per page, and '''$6''' views per edit.", 'maintenancebacklink' => 'Back to Maintenance Page', 'disambiguations' => 'Disambiguation pages', 'disambiguationspage' => 'Template:disambig', +'featuredtemplate' => 'Template:Featured', 'disambiguationstext' => "The following pages link to a disambiguation page. They should link to the appropriate topic instead.
A page is treated as disambiguation if it is linked from $1.
Links from other namespaces are not listed here.", 'doubleredirects' => 'Double redirects', '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.",