Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -592,23 +592,7 @@ |
593 | 593 | } |
594 | 594 | $fname = 'OutputPage::output'; |
595 | 595 | wfProfileIn( $fname ); |
596 | | - $sk = $wgUser->getSkin(); |
597 | 596 | |
598 | | - if ( $wgUseAjax ) { |
599 | | - $this->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajax.js?$wgStyleVersion\"></script>\n" ); |
600 | | - |
601 | | - wfRunHooks( 'AjaxAddScript', array( &$this ) ); |
602 | | - |
603 | | - if( $wgAjaxSearch && $wgUser->getBoolOption( 'ajaxsearch' ) ) { |
604 | | - $this->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajaxsearch.js?$wgStyleVersion\"></script>\n" ); |
605 | | - $this->addScript( "<script type=\"{$wgJsMimeType}\">hookEvent(\"load\", sajax_onload);</script>\n" ); |
606 | | - } |
607 | | - |
608 | | - if( $wgAjaxWatch && $wgUser->isLoggedIn() ) { |
609 | | - $this->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajaxwatch.js?$wgStyleVersion\"></script>\n" ); |
610 | | - } |
611 | | - } |
612 | | - |
613 | 597 | if ( '' != $this->mRedirect ) { |
614 | 598 | if( substr( $this->mRedirect, 0, 4 ) != 'http' ) { |
615 | 599 | # Standards require redirect URLs to be absolute |
— | — | @@ -691,6 +675,25 @@ |
692 | 676 | $wgRequest->response()->header( 'HTTP/1.1 ' . $this->mStatusCode . ' ' . $statusMessage[$this->mStatusCode] ); |
693 | 677 | } |
694 | 678 | |
| 679 | + $sk = $wgUser->getSkin(); |
| 680 | + |
| 681 | + if ( $wgUseAjax ) { |
| 682 | + $this->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajax.js?$wgStyleVersion\"></script>\n" ); |
| 683 | + |
| 684 | + wfRunHooks( 'AjaxAddScript', array( &$this ) ); |
| 685 | + |
| 686 | + if( $wgAjaxSearch && $wgUser->getBoolOption( 'ajaxsearch' ) ) { |
| 687 | + $this->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajaxsearch.js?$wgStyleVersion\"></script>\n" ); |
| 688 | + $this->addScript( "<script type=\"{$wgJsMimeType}\">hookEvent(\"load\", sajax_onload);</script>\n" ); |
| 689 | + } |
| 690 | + |
| 691 | + if( $wgAjaxWatch && $wgUser->isLoggedIn() ) { |
| 692 | + $this->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajaxwatch.js?$wgStyleVersion\"></script>\n" ); |
| 693 | + } |
| 694 | + } |
| 695 | + |
| 696 | + |
| 697 | + |
695 | 698 | # Buffer output; final headers may depend on later processing |
696 | 699 | ob_start(); |
697 | 700 | |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -1370,8 +1370,12 @@ |
1371 | 1371 | * @todo fold these checks into userCan() |
1372 | 1372 | */ |
1373 | 1373 | public function userCanRead() { |
1374 | | - global $wgUser; |
1375 | | - |
| 1374 | + global $wgUser, $wgGroupPermissions; |
| 1375 | + |
| 1376 | + # Shortcut for public wikis, allows skipping quite a bit of code path |
| 1377 | + if ($wgGroupPermissions['*']['read']) |
| 1378 | + return true; |
| 1379 | + |
1376 | 1380 | $result = null; |
1377 | 1381 | wfRunHooks( 'userCan', array( &$this, &$wgUser, 'read', &$result ) ); |
1378 | 1382 | if ( $result !== null ) { |
Index: trunk/phase3/includes/SpecialPage.php |
— | — | @@ -89,7 +89,7 @@ |
90 | 90 | 'Newimages' => array( 'IncludableSpecialPage', 'Newimages' ), |
91 | 91 | 'Listusers' => array( 'SpecialPage', 'Listusers' ), |
92 | 92 | 'Statistics' => array( 'SpecialPage', 'Statistics' ), |
93 | | - 'Randompage' => array( 'SpecialPage', 'Randompage' ), |
| 93 | + 'Randompage' => 'Randompage', |
94 | 94 | 'Lonelypages' => array( 'SpecialPage', 'Lonelypages' ), |
95 | 95 | 'Uncategorizedpages' => array( 'SpecialPage', 'Uncategorizedpages' ), |
96 | 96 | 'Uncategorizedcategories' => array( 'SpecialPage', 'Uncategorizedcategories' ), |
— | — | @@ -408,7 +408,6 @@ |
409 | 409 | $par = $bits[1]; |
410 | 410 | } |
411 | 411 | $page = SpecialPage::getPageByAlias( $name ); |
412 | | - |
413 | 412 | # Nonexistent? |
414 | 413 | if ( !$page ) { |
415 | 414 | if ( !$including ) { |
Index: trunk/phase3/includes/SpecialRandompage.php |
— | — | @@ -9,40 +9,29 @@ |
10 | 10 | */ |
11 | 11 | |
12 | 12 | /** |
13 | | - * Main execution point |
14 | | - * @param $par Namespace to select the page from |
15 | | - */ |
16 | | -function wfSpecialRandompage( $par = null ) { |
17 | | - global $wgOut, $wgContLang; |
18 | | - |
19 | | - $rnd = new RandomPage(); |
20 | | - $rnd->setNamespace( $wgContLang->getNsIndex( $par ) ); |
21 | | - $rnd->setRedirect( false ); |
22 | | - |
23 | | - $title = $rnd->getRandomTitle(); |
24 | | - |
25 | | - if( is_null( $title ) ) { |
26 | | - $wgOut->addWikiText( wfMsg( 'randompage-nopages' ) ); |
27 | | - return; |
28 | | - } |
29 | | - |
30 | | - $wgOut->reportTime(); |
31 | | - $wgOut->redirect( $title->getFullUrl() ); |
32 | | -} |
33 | | - |
34 | | - |
35 | | -/** |
36 | 13 | * Special page to direct the user to a random page |
37 | 14 | * |
38 | 15 | * @addtogroup SpecialPage |
39 | 16 | */ |
40 | | -class RandomPage { |
| 17 | +class RandomPage extends SpecialPage { |
41 | 18 | private $namespace = NS_MAIN; // namespace to select pages from |
42 | 19 | private $redirect = false; // select redirects instead of normal pages? |
43 | 20 | |
44 | 21 | public function getNamespace ( ) { |
45 | 22 | return $this->namespace; |
46 | 23 | } |
| 24 | + |
| 25 | + function getTitle($par=null) { |
| 26 | + return SpecialPage::getTitleFor("Randompage"); |
| 27 | + } |
| 28 | + |
| 29 | + function getLocalName() { |
| 30 | + return SpecialPage::getLocalNameFor("Randompage"); |
| 31 | + } |
| 32 | + |
| 33 | + public function setHeaders() {} |
| 34 | + public function outputHeader() {} |
| 35 | + |
47 | 36 | public function setNamespace ( $ns ) { |
48 | 37 | if( $ns < NS_MAIN ) $ns = NS_MAIN; |
49 | 38 | $this->namespace = $ns; |
— | — | @@ -53,7 +42,25 @@ |
54 | 43 | public function setRedirect ( $redirect ) { |
55 | 44 | $this->redirect = $redirect; |
56 | 45 | } |
| 46 | + |
| 47 | + public function execute( $par = null ) { |
| 48 | + global $wgOut, $wgContLang; |
57 | 49 | |
| 50 | + if ($par) |
| 51 | + $this->setNamespace( $wgContLang->getNsIndex( $par ) ); |
| 52 | + $this->setRedirect( false ); |
| 53 | + |
| 54 | + $title = $this->getRandomTitle(); |
| 55 | + |
| 56 | + if( is_null( $title ) ) { |
| 57 | + $wgOut->addWikiText( wfMsg( 'randompage-nopages' ) ); |
| 58 | + return; |
| 59 | + } |
| 60 | + |
| 61 | + $wgOut->redirect( $title->getFullUrl() ); |
| 62 | + } |
| 63 | + |
| 64 | + |
58 | 65 | /** |
59 | 66 | * Choose a random title. |
60 | 67 | * @return Title object (or null if nothing to choose from) |