X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialRandompage.php;h=c94d2b3517b5b9ea8550b5dd8407f37ff7f838cd;hb=b95a775c9855f7b7d781240e1062cc014957d703;hp=2b25b78b7ae90b8373483326f3dd7ce9848108f2;hpb=bc9e97cd3f5af396b1901bd899bd82b2f8853d65;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialRandompage.php b/includes/specials/SpecialRandompage.php index 2b25b78b7a..c94d2b3517 100644 --- a/includes/specials/SpecialRandompage.php +++ b/includes/specials/SpecialRandompage.php @@ -42,7 +42,7 @@ class RandomPage extends SpecialPage { } public function setNamespace( $ns ) { - if( !$ns || $ns < NS_MAIN ) { + if ( !$ns || $ns < NS_MAIN ) { $ns = NS_MAIN; } $this->namespaces = array( $ns ); @@ -62,10 +62,12 @@ class RandomPage extends SpecialPage { $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; } @@ -83,13 +85,14 @@ class RandomPage extends SpecialPage { 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 ); } @@ -100,10 +103,14 @@ class RandomPage extends SpecialPage { 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 @@ -113,15 +120,15 @@ class RandomPage extends SpecialPage { * 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 ) {