}
public function execute( $par ) {
+ global $wgScript;
+
$cat = false;
$categoryStr = $this->getRequest()->getText( 'category', $par );
$cat = Title::newFromText( $categoryStr, NS_CATEGORY );
}
+ if ( $cat && $cat->getNamespace() !== NS_CATEGORY ) {
+ // Someone searching for something like "Wikipedia:Foo"
+ $cat = Title::makeTitleSafe( NS_CATEGORY, $categoryStr );
+ }
+
if ( $cat ) {
$this->setCategory( $cat );
}
-
if ( !$this->category && $categoryStr ) {
$this->setHeaders();
$this->getOutput()->addWikiMsg( 'randomincategory-invalidcategory',
$submit = Html::input( '', $submitText, 'submit' );
$msg = $this->msg( 'randomincategory-selectcategory' );
- $form = Html::rawElement( 'form', array( 'action' => $this->getTitle()->getLocalUrl() ),
+ $form = Html::rawElement( 'form', array( 'action' => $wgScript ),
+ Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
$msg->rawParams( $input, $submit )->parse()
);
$this->getOutput()->addHtml( $form );
*/
public function getRandomTitle() {
// Convert to float, since we do math with the random number.
- $rand = (float) wfRandom();
+ $rand = (float)wfRandom();
$title = null;
// Given that timestamps are rather unevenly distributed, we also