}
public function setNamespace( $ns ) {
- if( !$ns || $ns < NS_MAIN ) {
+ if ( !$ns || $ns < NS_MAIN ) {
$ns = NS_MAIN;
}
$this->namespaces = array( $ns );
$title = $this->getRandomTitle();
- if( is_null( $title ) ) {
+ if ( is_null( $title ) ) {
$this->setHeaders();
+ // Message: randompage-nopages, randomredirect-nopages
$this->getOutput()->addWikiMsg( strtolower( $this->getName() ) . '-nopages',
$this->getNsList(), count( $this->namespaces ) );
+
return;
}
private function getNsList() {
global $wgContLang;
$nsNames = array();
- foreach( $this->namespaces as $n ) {
- if( $n === NS_MAIN ) {
+ foreach ( $this->namespaces as $n ) {
+ if ( $n === NS_MAIN ) {
$nsNames[] = $this->msg( 'blanknamespace' )->plain();
} else {
$nsNames[] = $wgContLang->getNsText( $n );
}
}
+
return $wgContLang->commaList( $nsNames );
}
public function getRandomTitle() {
$randstr = wfRandom();
$title = null;
- if ( !wfRunHooks( 'SpecialRandomGetRandomTitle', array( &$randstr, &$this->isRedir, &$this->namespaces,
- &$this->extra, &$title ) ) ) {
+
+ if ( !wfRunHooks(
+ 'SpecialRandomGetRandomTitle',
+ array( &$randstr, &$this->isRedir, &$this->namespaces, &$this->extra, &$title )
+ ) ) {
return $title;
}
+
$row = $this->selectRandomPageFromDB( $randstr );
/* If we picked a value that was higher than any in
* any more bias than what the page_random scheme
* causes anyway. Trust me, I'm a mathematician. :)
*/
- if( !$row ) {
+ if ( !$row ) {
$row = $this->selectRandomPageFromDB( "0" );
}
- if( $row ) {
+ if ( $row ) {
return Title::makeTitleSafe( $row->page_namespace, $row->page_title );
- } else {
- return null;
}
+
+ return null;
}
protected function getQueryInfo( $randstr ) {