From c07091b7bc4f20c5d5a196f9c09ac9dff0b6d7dd Mon Sep 17 00:00:00 2001 From: Victor Vasiliev Date: Sun, 11 Nov 2007 14:52:31 +0000 Subject: [PATCH] * Add ot=raw to Special:Allmessages * Handle invalid titles correctly in Special:Randomincategory --- RELEASE-NOTES | 1 + includes/SpecialAllmessages.php | 19 +++++++++++++++++-- includes/SpecialRandomincategory.php | 10 +++++++++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 089e798fdb..e93411ec28 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -59,6 +59,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN 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/SpecialAllmessages.php b/includes/SpecialAllmessages.php index 4ba01e2980..d8b6acc27f 100644 --- a/includes/SpecialAllmessages.php +++ b/includes/SpecialAllmessages.php @@ -45,9 +45,12 @@ function wfSpecialAllmessages() { wfProfileIn( __METHOD__ . '-output' ); if ( $ot == 'php' ) { $navText .= makePhp( $messages ); - $wgOut->addHTML( 'PHP | HTML
' . htmlspecialchars( $navText ) . '
' ); + $wgOut->addHTML( 'PHP | HTML | Raw
' . htmlspecialchars( $navText ) . '
' ); + } else if ( $ot == 'raw' ) { + $wgOut->disable(); + echo makeRaw( $messages ); } else { - $wgOut->addHTML( 'PHP | HTML' ); + $wgOut->addHTML( 'PHP | HTML | Raw' ); $wgOut->addWikiText( $navText ); $wgOut->addHTML( makeHTMLText( $messages ) ); } @@ -56,6 +59,18 @@ function wfSpecialAllmessages() { wfProfileOut( __METHOD__ ); } +function makeRaw( $messages ) { + global $wgLang; + $lang = $wgLang->getCode(); + $txt = "\n"; + $txt .= "\n"; + foreach( $messages as $key => $m ) { + $txt .= "\t" . htmlspecialchars( "{$m['msg']}" ) . "\n"; + } + $txt .= ""; + return $txt; +} + /** * Create the messages array, formatted in PHP to copy to language files. * @param $messages Messages array. diff --git a/includes/SpecialRandomincategory.php b/includes/SpecialRandomincategory.php index ba5ebe387b..2461ef3c89 100644 --- a/includes/SpecialRandomincategory.php +++ b/includes/SpecialRandomincategory.php @@ -26,7 +26,10 @@ function wfSpecialRandomincategory( $par = null ) { } $rnd = new RandomPageInCategory(); - $rnd->setCategory( $par ); + if( !$rnd->setCategory( $par ) ) { + $wgOut->addHTML( RandomPageInCategory::getForm( $par ) ); + return; + } $title = $rnd->getRandomTitle(); @@ -54,7 +57,12 @@ class RandomPageInCategory { } public function setCategory ( $cat ) { $category = Title::makeTitleSafe( NS_CATEGORY, $cat ); + //Invalid title + if( !$category ) { + return false; + } $this->category = $category->getDBKey(); + return false; } /** -- 2.20.1