* OutputPage::getRedirect public method added.
* (bug 11848) Allow URL parameters 'editintro' and 'preload' in Special:Mypage
and Special:Mytalk
-* Add special page for getting random page from category
-* Add link on Special:Randomincategory to sidebar
* Add ot=raw to Special:Allmessages
=== Bug fixes in 1.12 ===
'PreferencesForm' => 'includes/SpecialPreferences.php',
'SpecialPrefixindex' => 'includes/SpecialPrefixindex.php',
'RandomPage' => 'includes/SpecialRandompage.php',
- 'RandomPageInCategory' => 'includes/SpecialRandomincategory.php',
'PasswordResetForm' => 'includes/SpecialResetpass.php',
'RevisionDeleteForm' => 'includes/SpecialRevisiondelete.php',
'RevisionDeleter' => 'includes/SpecialRevisiondelete.php',
);
}
- if( $this->mTitle->getNamespace() == NS_CATEGORY || $this->mTitle->getNamespace() == NS_CATEGORY_TALK ) {
- $nav_urls['randomincategory'] = array(
- 'text' => wfMsg( 'randomincategory-toolbox' ),
- 'href' => self::makeSpecialUrlSubpage( 'Randomincategory', $this->mTitle->getText() ),
- );
- }
-
if( $this->mTitle->getNamespace() == NS_USER || $this->mTitle->getNamespace() == NS_USER_TALK ) {
$id = User::idFromName($this->mTitle->getText());
$ip = User::isIP($this->mTitle->getText());
}
+
'Listusers' => array( 'SpecialPage', 'Listusers' ),
'Statistics' => array( 'SpecialPage', 'Statistics' ),
'Randompage' => array( 'SpecialPage', 'Randompage' ),
- 'Randomincategory' => array( 'SpecialPage', 'Randomincategory' ),
'Lonelypages' => array( 'SpecialPage', 'Lonelypages' ),
'Uncategorizedpages' => array( 'SpecialPage', 'Uncategorizedpages' ),
'Uncategorizedcategories' => array( 'SpecialPage', 'Uncategorizedcategories' ),
+++ /dev/null
-<?php
-
-/**
- * Special page to direct the user to a random page in specified category
- *
- * @addtogroup SpecialPage
- * @author VasilievVV <vasilvv@gmail.com>, based on SpecialRandompage.php code
- * @license GNU General Public Licence 2.0 or later
- */
-
-/**
- * Main execution point
- * @param $par Category to select the page from
- */
-function wfSpecialRandomincategory( $par = null ) {
- global $wgOut, $wgRequest;
-
- if( is_null( $par ) ) {
- if ( $requestCategory = $wgRequest->getVal( 'category' ) ) {
- $par = $requestCategory;
- }
- else {
- $wgOut->addHTML( RandomPageInCategory::getForm() );
- return;
- }
- }
-
- $rnd = new RandomPageInCategory();
- if( !$rnd->setCategory( $par ) ) {
- $wgOut->addHTML( RandomPageInCategory::getForm( $par ) );
- return;
- }
-
- $title = $rnd->getRandomTitle();
-
- if( is_null( $title ) ) {
- $wgOut->addWikiText( wfMsg( 'randomincategory-nocategory', $par ) );
- $wgOut->addHTML( RandomPageInCategory::getForm( $par ) );
- return;
- }
-
- $wgOut->reportTime();
- $wgOut->redirect( $title->getFullUrl() );
-}
-
-
-/**
- * Special page to direct the user to a random page in specified category
- *
- * @addtogroup SpecialPage
- */
-class RandomPageInCategory {
- private $category = null;
-
- public function getCategory ( ) {
- return $this->namespace;
- }
- public function setCategory ( $cat ) {
- $category = Title::makeTitleSafe( NS_CATEGORY, $cat );
- //Invalid title
- if( !$category ) {
- return false;
- }
- $this->category = $category->getDBKey();
- return true;
- }
-
- /**
- * Choose a random title. Based on Special:Random
- * @return Title object (or null if nothing to choose from)
- */
- public function getRandomTitle ( ) {
- $randstr = wfRandom();
- $row = $this->selectRandomPageFromDB( $randstr );
-
- if( !$row )
- $row = $this->selectRandomPageFromDB( "0" );
-
- if( $row )
- return Title::newFromText( $row->page_title, $row->page_namespace );
- else
- return null;
- }
-
- private function selectRandomPageFromDB ( $randstr ) {
- global $wgExtraRandompageSQL, $wgOut;
- $fname = 'RandomPageInCategory::selectRandomPageFromDB';
-
- $dbr = wfGetDB( DB_SLAVE );
-
- $use_index = $dbr->useIndexClause( 'page_random' );
- $page = $dbr->tableName( 'page' );
- $categorylinks = $dbr->tableName( 'categorylinks' );
- $category = $dbr->addQuotes( $this->category );
-
- $extra = $wgExtraRandompageSQL ? "AND ($wgExtraRandompageSQL)" : "";
- $sql = "SELECT page_namespace, page_title
- FROM $page $use_index JOIN $categorylinks ON page_id = cl_from
- WHERE page_is_redirect = 0
- AND page_random >= $randstr
- AND cl_to = $category
- $extra
- ORDER BY page_random";
-
- $sql = $dbr->limitResult( $sql, 1, 0 );
- $res = $dbr->query( $sql, $fname );
- return $dbr->fetchObject( $res );
- }
-
- public static function getForm( $par = null ) {
- global $wgScript, $wgTitle, $wgRequest;
-
- if( !( $category = $par ) ) {
- $category = $wgRequest->getVal( 'category' );
- }
-
- $f =
- Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) .
- Xml::openElement( 'fieldset' ) .
- Xml::element( 'legend', array(), wfMsg( 'randomincategory' ) ) .
- Xml::hidden( 'title', $wgTitle->getPrefixedText() ) .
- Xml::openElement( 'p' ) .
- Xml::label( wfMsg( 'randomincategory-label' ), 'category' ) . ' ' .
- Xml::input( 'category', null, $category, array( 'id' => 'category' ) ) . ' ' .
- Xml::submitButton( wfMsg( 'randomincategory-submit' ) ) .
- Xml::closeElement( 'p' ) .
- Xml::closeElement( 'fieldset' ) .
- Xml::closeElement( 'form' );
- return $f;
- }
-}
-
-
-
'Listusers' => array( 'Listusers', 'Userlist' ),
'Statistics' => array( 'Statistics' ),
'Randompage' => array( 'Random', 'Randompage' ),
- 'Randomincategory' => array( 'Randomincategory' ),
'Lonelypages' => array( 'Lonelypages', 'Orphanedpages' ),
'Uncategorizedpages' => array( 'Uncategorizedpages' ),
'Uncategorizedcategories' => array( 'Uncategorizedcategories' ),
'randompage' => 'Random page',
'randompage-nopages' => 'There are no pages in this namespace.',
'randompage-url' => 'Special:Random', # don't translate or duplicate this message to other languages
-'randomincategory' => 'Random page in category',
-'randomincategory-toolbox' => 'Random page',
-'randomincategory-nocategory' => 'Category $1 doesn\'t exist or is empty',
-'randomincategory-label' => 'Category:',
-'randomincategory-submit' => 'Go',
# Random redirect
'randomredirect' => 'Random redirect',
'accesskey-n-sitesupport' => '', # don't translate or duplicate this message to other languages
'accesskey-t-whatlinkshere' => 'j', # don't translate or duplicate this message to other languages
'accesskey-t-recentchangeslinked' => 'k', # don't translate or duplicate this message to other languages
-'accesskey-t-random' => '', # don't translate or duplicate this message to other languages
'accesskey-feed-rss' => '', # don't translate or duplicate this message to other languages
'accesskey-feed-atom' => '', # don't translate or duplicate this message to other languages
'accesskey-t-contributions' => '', # don't translate or duplicate this message to other languages
'tooltip-n-sitesupport' => 'Support us',
'tooltip-t-whatlinkshere' => 'List of all wiki pages that link here',
'tooltip-t-recentchangeslinked' => 'Recent changes in pages linked from this page',
-'tooltip-t-random' => 'Random page in this category',
'tooltip-feed-rss' => 'RSS feed for this page',
'tooltip-feed-atom' => 'Atom feed for this page',
'tooltip-t-contributions' => 'View the list of contributions of this user',
# Random pages
'randompage' => 'Случайная страница',
'randompage-nopages' => 'В данном пространстве имён отсутствуют страницы.',
-'randomincategory' => 'Случайная страница в категории',
-'randomincategory-toolbox' => 'Случайная страница',
-'randomincategory-nocategory' => 'Категория "$1" пуста или не существует',
-'randomincategory-label' => 'Категория:',
-'randomincategory-submit' => 'Перейти',
-'randomredirect-nopages' => 'В данном пространстве имён нет перенаправлений.',
-'randomredirect' => 'Случайное перенаправление',
# Statistics
'statistics' => 'Статистика',
'accesskey-n-sitesupport',
'accesskey-t-whatlinkshere',
'accesskey-t-recentchangeslinked',
- 'accesskey-t-random',
'accesskey-feed-rss',
'accesskey-feed-atom',
'accesskey-t-contributions',
'randompage',
'randompage-nopages',
'randompage-url',
- 'randomincategory',
- 'randomincategory-toolbox',
- 'randomincategory-nocategory',
- 'randomincategory-label',
- 'randomincategory-submit',
),
'randomredirect' => array(
'randomredirect',
} elseif ($this->data['nav_urls']['permalink']['href'] === '') { ?>
<li id="t-ispermalink"<?php echo $skin->tooltip('t-ispermalink') ?>><?php $this->msg('permalink') ?></li><?php
}
-
- if(!empty($this->data['nav_urls']['randomincategory']['href'])) { ?>
- <li id="t-random"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['randomincategory']['href'])
- ?>"<?php echo $skin->tooltipAndAccesskey('t-random') ?>><?php $this->msg('randomincategory-toolbox') ?></a></li><?php
- }
wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
?>