From a3dbd2377a8cad6d93e13e50a9d94bd0e246bf93 Mon Sep 17 00:00:00 2001 From: Victor Vasiliev Date: Mon, 12 Nov 2007 16:03:34 +0000 Subject: [PATCH] * Remove Special:Randomincategory. Domas said that it will work slowly on big categories (like "Living persons"). --- RELEASE-NOTES | 2 - includes/AutoLoader.php | 1 - includes/SkinTemplate.php | 8 +- includes/SpecialPage.php | 1 - includes/SpecialRandomincategory.php | 134 -------------------------- languages/messages/MessagesEn.php | 8 -- languages/messages/MessagesRu.php | 7 -- maintenance/language/messageTypes.inc | 1 - maintenance/language/messages.inc | 5 - skins/MonoBook.php | 5 - 10 files changed, 1 insertion(+), 171 deletions(-) delete mode 100644 includes/SpecialRandomincategory.php diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 3a20a41825..4d5d108e6a 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -61,8 +61,6 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * 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 === diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index e1930c325b..828be04a9a 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -207,7 +207,6 @@ function __autoload($className) { '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', diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 6145e9dccc..791137b31f 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -893,13 +893,6 @@ class SkinTemplate extends Skin { ); } - 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()); @@ -1204,3 +1197,4 @@ class QuickTemplate { } + diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index effea32dc3..1676626a36 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -90,7 +90,6 @@ class SpecialPage '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' ), diff --git a/includes/SpecialRandomincategory.php b/includes/SpecialRandomincategory.php deleted file mode 100644 index 5d50c97bcf..0000000000 --- a/includes/SpecialRandomincategory.php +++ /dev/null @@ -1,134 +0,0 @@ -, 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; - } -} - - - diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index c87541b54b..dd108e7943 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -360,7 +360,6 @@ $specialPageAliases = array( 'Listusers' => array( 'Listusers', 'Userlist' ), 'Statistics' => array( 'Statistics' ), 'Randompage' => array( 'Random', 'Randompage' ), - 'Randomincategory' => array( 'Randomincategory' ), 'Lonelypages' => array( 'Lonelypages', 'Orphanedpages' ), 'Uncategorizedpages' => array( 'Uncategorizedpages' ), 'Uncategorizedcategories' => array( 'Uncategorizedcategories' ), @@ -1555,11 +1554,6 @@ PICT # misc. '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', @@ -2294,7 +2288,6 @@ All transwiki import actions are logged at the [[Special:Log/import|import log]] '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 @@ -2356,7 +2349,6 @@ All transwiki import actions are logged at the [[Special:Log/import|import log]] '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', diff --git a/languages/messages/MessagesRu.php b/languages/messages/MessagesRu.php index 45b43de035..64d63691d9 100644 --- a/languages/messages/MessagesRu.php +++ b/languages/messages/MessagesRu.php @@ -1215,13 +1215,6 @@ $3 указал следующую причину: ''$2''", # Random pages 'randompage' => 'Случайная страница', 'randompage-nopages' => 'В данном пространстве имён отсутствуют страницы.', -'randomincategory' => 'Случайная страница в категории', -'randomincategory-toolbox' => 'Случайная страница', -'randomincategory-nocategory' => 'Категория "$1" пуста или не существует', -'randomincategory-label' => 'Категория:', -'randomincategory-submit' => 'Перейти', -'randomredirect-nopages' => 'В данном пространстве имён нет перенаправлений.', -'randomredirect' => 'Случайное перенаправление', # Statistics 'statistics' => 'Статистика', diff --git a/maintenance/language/messageTypes.inc b/maintenance/language/messageTypes.inc index de1d198a4f..3cb8e90079 100644 --- a/maintenance/language/messageTypes.inc +++ b/maintenance/language/messageTypes.inc @@ -42,7 +42,6 @@ $wgIgnoredMessages = array( 'accesskey-n-sitesupport', 'accesskey-t-whatlinkshere', 'accesskey-t-recentchangeslinked', - 'accesskey-t-random', 'accesskey-feed-rss', 'accesskey-feed-atom', 'accesskey-t-contributions', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index fc301ac7de..88984d13a2 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -947,11 +947,6 @@ $wgMessageStructure = array( 'randompage', 'randompage-nopages', 'randompage-url', - 'randomincategory', - 'randomincategory-toolbox', - 'randomincategory-nocategory', - 'randomincategory-label', - 'randomincategory-submit', ), 'randomredirect' => array( 'randomredirect', diff --git a/skins/MonoBook.php b/skins/MonoBook.php index 1ebe71df02..d0148a701f 100644 --- a/skins/MonoBook.php +++ b/skins/MonoBook.php @@ -221,11 +221,6 @@ class MonoBookTemplate extends QuickTemplate { } elseif ($this->data['nav_urls']['permalink']['href'] === '') { ?> data['nav_urls']['randomincategory']['href'])) { ?> -
  • tooltipAndAccesskey('t-random') ?>>msg('randomincategory-toolbox') ?>
  • -- 2.20.1