Index: trunk/phase3/includes/Article.php |
— | — | @@ -1580,7 +1580,7 @@ |
1581 | 1581 | * Builds trackback links for article display if $wgUseTrackbacks is set to true |
1582 | 1582 | */ |
1583 | 1583 | public function addTrackbacks() { |
1584 | | - global $wgOut, $wgUser; |
| 1584 | + global $wgOut; |
1585 | 1585 | |
1586 | 1586 | $dbr = wfGetDB( DB_SLAVE ); |
1587 | 1587 | $tbs = $dbr->select( 'trackbacks', |
— | — | @@ -1598,9 +1598,9 @@ |
1599 | 1599 | foreach ( $tbs as $o ) { |
1600 | 1600 | $rmvtxt = ""; |
1601 | 1601 | |
1602 | | - if ( $wgUser->isAllowed( 'trackback' ) ) { |
| 1602 | + if ( $wgOut->getUser()->isAllowed( 'trackback' ) ) { |
1603 | 1603 | $delurl = $this->mTitle->getFullURL( "action=deletetrackback&tbid=" . |
1604 | | - $o->tb_id . "&token=" . urlencode( $wgUser->editToken() ) ); |
| 1604 | + $o->tb_id . "&token=" . urlencode( $wgOut->getUser()->editToken() ) ); |
1605 | 1605 | $rmvtxt = wfMsg( 'trackbackremove', htmlspecialchars( $delurl ) ); |
1606 | 1606 | } |
1607 | 1607 | |
— | — | @@ -1620,15 +1620,15 @@ |
1621 | 1621 | * Removes trackback record for current article from trackbacks table |
1622 | 1622 | */ |
1623 | 1623 | public function deletetrackback() { |
1624 | | - global $wgUser, $wgRequest, $wgOut; |
| 1624 | + global $wgRequest, $wgOut; |
1625 | 1625 | |
1626 | | - if ( !$wgUser->matchEditToken( $wgRequest->getVal( 'token' ) ) ) { |
| 1626 | + if ( !$wgOut->getUser()->matchEditToken( $wgRequest->getVal( 'token' ) ) ) { |
1627 | 1627 | $wgOut->addWikiMsg( 'sessionfailure' ); |
1628 | 1628 | |
1629 | 1629 | return; |
1630 | 1630 | } |
1631 | 1631 | |
1632 | | - $permission_errors = $this->mTitle->getUserPermissionsErrors( 'delete', $wgUser ); |
| 1632 | + $permission_errors = $this->mTitle->getUserPermissionsErrors( 'delete', $wgOut->getUser() ); |
1633 | 1633 | |
1634 | 1634 | if ( count( $permission_errors ) ) { |
1635 | 1635 | $wgOut->showPermissionsErrorPage( $permission_errors ); |
— | — | @@ -1658,9 +1658,9 @@ |
1659 | 1659 | * Handle action=purge |
1660 | 1660 | */ |
1661 | 1661 | public function purge() { |
1662 | | - global $wgUser, $wgRequest, $wgOut; |
| 1662 | + global $wgRequest, $wgOut; |
1663 | 1663 | |
1664 | | - if ( $wgUser->isAllowed( 'purge' ) || $wgRequest->wasPosted() ) { |
| 1664 | + if ( $wgOut->getUser()->isAllowed( 'purge' ) || $wgRequest->wasPosted() ) { |
1665 | 1665 | //FIXME: shouldn't this be in doPurge()? |
1666 | 1666 | if ( wfRunHooks( 'ArticlePurge', array( &$this ) ) ) { |
1667 | 1667 | $this->doPurge(); |
— | — | @@ -2273,14 +2273,14 @@ |
2274 | 2274 | * Mark this particular edit/page as patrolled |
2275 | 2275 | */ |
2276 | 2276 | public function markpatrolled() { |
2277 | | - global $wgOut, $wgUser, $wgRequest; |
| 2277 | + global $wgOut, $wgRequest; |
2278 | 2278 | |
2279 | 2279 | $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
2280 | 2280 | |
2281 | 2281 | # If we haven't been given an rc_id value, we can't do anything |
2282 | 2282 | $rcid = (int) $wgRequest->getVal( 'rcid' ); |
2283 | 2283 | |
2284 | | - if ( !$wgUser->matchEditToken( $wgRequest->getVal( 'token' ), $rcid ) ) { |
| 2284 | + if ( !$wgOut->getUser()->matchEditToken( $wgRequest->getVal( 'token' ), $rcid ) ) { |
2285 | 2285 | $wgOut->showErrorPage( 'sessionfailure-title', 'sessionfailure' ); |
2286 | 2286 | return; |
2287 | 2287 | } |
— | — | @@ -2333,9 +2333,9 @@ |
2334 | 2334 | * User-interface handler for the "watch" action |
2335 | 2335 | */ |
2336 | 2336 | public function watch() { |
2337 | | - global $wgUser, $wgOut; |
| 2337 | + global $wgOut; |
2338 | 2338 | |
2339 | | - if ( $wgUser->isAnon() ) { |
| 2339 | + if ( $wgOut->getUser()->isAnon() ) { |
2340 | 2340 | $wgOut->showErrorPage( 'watchnologin', 'watchnologintext' ); |
2341 | 2341 | return; |
2342 | 2342 | } |
— | — | @@ -2380,9 +2380,9 @@ |
2381 | 2381 | * User interface handler for the "unwatch" action. |
2382 | 2382 | */ |
2383 | 2383 | public function unwatch() { |
2384 | | - global $wgUser, $wgOut; |
| 2384 | + global $wgOut; |
2385 | 2385 | |
2386 | | - if ( $wgUser->isAnon() ) { |
| 2386 | + if ( $wgOut->getUser()->isAnon() ) { |
2387 | 2387 | $wgOut->showErrorPage( 'watchnologin', 'watchnologintext' ); |
2388 | 2388 | return; |
2389 | 2389 | } |
— | — | @@ -2742,10 +2742,10 @@ |
2743 | 2743 | * UI entry point for page deletion |
2744 | 2744 | */ |
2745 | 2745 | public function delete() { |
2746 | | - global $wgUser, $wgOut, $wgRequest; |
| 2746 | + global $wgOut, $wgRequest; |
2747 | 2747 | |
2748 | 2748 | $confirm = $wgRequest->wasPosted() && |
2749 | | - $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ); |
| 2749 | + $wgOut->getUser()->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ); |
2750 | 2750 | |
2751 | 2751 | $this->DeleteReasonList = $wgRequest->getText( 'wpDeleteReasonList', 'other' ); |
2752 | 2752 | $this->DeleteReason = $wgRequest->getText( 'wpReason' ); |
— | — | @@ -2760,7 +2760,7 @@ |
2761 | 2761 | } |
2762 | 2762 | |
2763 | 2763 | # Flag to hide all contents of the archived revisions |
2764 | | - $suppress = $wgRequest->getVal( 'wpSuppress' ) && $wgUser->isAllowed( 'suppressrevision' ); |
| 2764 | + $suppress = $wgRequest->getVal( 'wpSuppress' ) && $wgOut->getUser()->isAllowed( 'suppressrevision' ); |
2765 | 2765 | |
2766 | 2766 | # This code desperately needs to be totally rewritten |
2767 | 2767 | |
— | — | @@ -2772,7 +2772,7 @@ |
2773 | 2773 | } |
2774 | 2774 | |
2775 | 2775 | # Check permissions |
2776 | | - $permission_errors = $this->mTitle->getUserPermissionsErrors( 'delete', $wgUser ); |
| 2776 | + $permission_errors = $this->mTitle->getUserPermissionsErrors( 'delete', $wgOut->getUser() ); |
2777 | 2777 | |
2778 | 2778 | if ( count( $permission_errors ) > 0 ) { |
2779 | 2779 | $wgOut->showPermissionsErrorPage( $permission_errors ); |
— | — | @@ -2818,7 +2818,7 @@ |
2819 | 2819 | if ( $confirm ) { |
2820 | 2820 | $this->doDelete( $reason, $suppress ); |
2821 | 2821 | |
2822 | | - if ( $wgRequest->getCheck( 'wpWatch' ) && $wgUser->isLoggedIn() ) { |
| 2822 | + if ( $wgRequest->getCheck( 'wpWatch' ) && $wgOut->getUser()->isLoggedIn() ) { |
2823 | 2823 | $this->doWatch(); |
2824 | 2824 | } elseif ( $this->mTitle->userIsWatching() ) { |
2825 | 2825 | $this->doUnwatch(); |
— | — | @@ -2837,7 +2837,7 @@ |
2838 | 2838 | if ( $hasHistory && !$confirm ) { |
2839 | 2839 | global $wgLang; |
2840 | 2840 | |
2841 | | - $skin = $wgUser->getSkin(); |
| 2841 | + $skin = $wgOut->getSkin(); |
2842 | 2842 | $revisions = $this->estimateRevisionCount(); |
2843 | 2843 | //FIXME: lego |
2844 | 2844 | $wgOut->addHTML( '<strong class="mw-delete-warning-revisions">' . |
— | — | @@ -2944,18 +2944,18 @@ |
2945 | 2945 | * @param $reason String: prefilled reason |
2946 | 2946 | */ |
2947 | 2947 | public function confirmDelete( $reason ) { |
2948 | | - global $wgOut, $wgUser; |
| 2948 | + global $wgOut; |
2949 | 2949 | |
2950 | 2950 | wfDebug( "Article::confirmDelete\n" ); |
2951 | 2951 | |
2952 | | - $deleteBackLink = $wgUser->getSkin()->linkKnown( $this->mTitle ); |
| 2952 | + $deleteBackLink = $wgOut->getSkin()->linkKnown( $this->mTitle ); |
2953 | 2953 | $wgOut->setSubtitle( wfMsgHtml( 'delete-backlink', $deleteBackLink ) ); |
2954 | 2954 | $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
2955 | 2955 | $wgOut->addWikiMsg( 'confirmdeletetext' ); |
2956 | 2956 | |
2957 | 2957 | wfRunHooks( 'ArticleConfirmDelete', array( $this, $wgOut, &$reason ) ); |
2958 | 2958 | |
2959 | | - if ( $wgUser->isAllowed( 'suppressrevision' ) ) { |
| 2959 | + if ( $wgOut->getUser()->isAllowed( 'suppressrevision' ) ) { |
2960 | 2960 | $suppress = "<tr id=\"wpDeleteSuppressRow\"> |
2961 | 2961 | <td></td> |
2962 | 2962 | <td class='mw-input'><strong>" . |
— | — | @@ -2966,7 +2966,7 @@ |
2967 | 2967 | } else { |
2968 | 2968 | $suppress = ''; |
2969 | 2969 | } |
2970 | | - $checkWatch = $wgUser->getBoolOption( 'watchdeletion' ) || $this->mTitle->userIsWatching(); |
| 2970 | + $checkWatch = $wgOut->getUser()->getBoolOption( 'watchdeletion' ) || $this->mTitle->userIsWatching(); |
2971 | 2971 | |
2972 | 2972 | $form = Xml::openElement( 'form', array( 'method' => 'post', |
2973 | 2973 | 'action' => $this->mTitle->getLocalURL( 'action=delete' ), 'id' => 'deleteconfirm' ) ) . |
— | — | @@ -2999,7 +2999,7 @@ |
3000 | 3000 | </tr>"; |
3001 | 3001 | |
3002 | 3002 | # Disallow watching if user is not logged in |
3003 | | - if ( $wgUser->isLoggedIn() ) { |
| 3003 | + if ( $wgOut->getUser()->isLoggedIn() ) { |
3004 | 3004 | $form .= " |
3005 | 3005 | <tr> |
3006 | 3006 | <td></td> |
— | — | @@ -3021,11 +3021,11 @@ |
3022 | 3022 | </tr>" . |
3023 | 3023 | Xml::closeElement( 'table' ) . |
3024 | 3024 | Xml::closeElement( 'fieldset' ) . |
3025 | | - Html::hidden( 'wpEditToken', $wgUser->editToken() ) . |
| 3025 | + Html::hidden( 'wpEditToken', $wgOut->getUser()->editToken() ) . |
3026 | 3026 | Xml::closeElement( 'form' ); |
3027 | 3027 | |
3028 | | - if ( $wgUser->isAllowed( 'editinterface' ) ) { |
3029 | | - $skin = $wgUser->getSkin(); |
| 3028 | + if ( $wgOut->getUser()->isAllowed( 'editinterface' ) ) { |
| 3029 | + $skin = $wgOut->getSkin(); |
3030 | 3030 | $title = Title::makeTitle( NS_MEDIAWIKI, 'Deletereason-dropdown' ); |
3031 | 3031 | $link = $skin->link( |
3032 | 3032 | $title, |
Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -193,6 +193,9 @@ |
194 | 194 | /// Stores a Title object (of the current page). |
195 | 195 | protected $mTitle = null; |
196 | 196 | |
| 197 | + /// Stores a User object (the one the page is being rendered for) |
| 198 | + protected $mUser = null; |
| 199 | + |
197 | 200 | /** |
198 | 201 | * An array of stylesheet filenames (relative from skins path), with options |
199 | 202 | * for CSS media, IE conditions, and RTL/LTR direction. |
— | — | @@ -549,7 +552,7 @@ |
550 | 553 | * @return Boolean: true iff cache-ok headers was sent. |
551 | 554 | */ |
552 | 555 | public function checkLastModified( $timestamp ) { |
553 | | - global $wgCachePages, $wgCacheEpoch, $wgUser, $wgRequest; |
| 556 | + global $wgCachePages, $wgCacheEpoch, $wgRequest; |
554 | 557 | |
555 | 558 | if ( !$timestamp || $timestamp == '19700101000000' ) { |
556 | 559 | wfDebug( __METHOD__ . ": CACHE DISABLED, NO TIMESTAMP\n" ); |
— | — | @@ -559,7 +562,7 @@ |
560 | 563 | wfDebug( __METHOD__ . ": CACHE DISABLED\n", false ); |
561 | 564 | return false; |
562 | 565 | } |
563 | | - if( $wgUser->getOption( 'nocache' ) ) { |
| 566 | + if( $this->getUser()->getOption( 'nocache' ) ) { |
564 | 567 | wfDebug( __METHOD__ . ": USER DISABLED CACHE\n", false ); |
565 | 568 | return false; |
566 | 569 | } |
— | — | @@ -567,7 +570,7 @@ |
568 | 571 | $timestamp = wfTimestamp( TS_MW, $timestamp ); |
569 | 572 | $modifiedTimes = array( |
570 | 573 | 'page' => $timestamp, |
571 | | - 'user' => $wgUser->getTouched(), |
| 574 | + 'user' => $this->getUser()->getTouched(), |
572 | 575 | 'epoch' => $wgCacheEpoch |
573 | 576 | ); |
574 | 577 | wfRunHooks( 'OutputPageCheckLastModified', array( &$modifiedTimes ) ); |
— | — | @@ -773,6 +776,40 @@ |
774 | 777 | } |
775 | 778 | |
776 | 779 | /** |
| 780 | + * Set the User object to use |
| 781 | + * |
| 782 | + * @param $u User object |
| 783 | + */ |
| 784 | + public function setUser( $u ) { |
| 785 | + $this->mUser = $u; |
| 786 | + } |
| 787 | + |
| 788 | + /** |
| 789 | + * Get the User object used in this instance |
| 790 | + * |
| 791 | + * @return User |
| 792 | + */ |
| 793 | + public function getUser() { |
| 794 | + if ( !isset($this->mUser) ) { |
| 795 | + wfDebug( __METHOD__ . " called and \$mUser is null. Return \$wgUser for sanity\n" ); |
| 796 | + global $wgUser; |
| 797 | + return $wgUser; |
| 798 | + } |
| 799 | + return $this->mUser; |
| 800 | + } |
| 801 | + |
| 802 | + /** |
| 803 | + * Get the Skin object used to render this instance |
| 804 | + * |
| 805 | + * @return Skin |
| 806 | + */ |
| 807 | + public function getSkin() { |
| 808 | + // For now we'll just proxy to the user. In the future a saner location for |
| 809 | + // organizing what skin to use may be chosen |
| 810 | + return $this->getUser()->getSkin(); |
| 811 | + } |
| 812 | + |
| 813 | + /** |
777 | 814 | * Replace the subtile with $str |
778 | 815 | * |
779 | 816 | * @param $str String: new value of the subtitle |
— | — | @@ -1009,7 +1046,7 @@ |
1010 | 1047 | * @param $categories Array mapping category name => sort key |
1011 | 1048 | */ |
1012 | 1049 | public function addCategoryLinks( $categories ) { |
1013 | | - global $wgUser, $wgContLang; |
| 1050 | + global $wgContLang; |
1014 | 1051 | |
1015 | 1052 | if ( !is_array( $categories ) || count( $categories ) == 0 ) { |
1016 | 1053 | return; |
— | — | @@ -1048,7 +1085,6 @@ |
1049 | 1086 | |
1050 | 1087 | # Add the remaining categories to the skin |
1051 | 1088 | if ( wfRunHooks( 'OutputPageMakeCategoryLinks', array( &$this, $categories, &$this->mCategoryLinks ) ) ) { |
1052 | | - $sk = $wgUser->getSkin(); |
1053 | 1089 | foreach ( $categories as $category => $type ) { |
1054 | 1090 | $origcategory = $category; |
1055 | 1091 | $title = Title::makeTitleSafe( NS_CATEGORY, $category ); |
— | — | @@ -1060,7 +1096,7 @@ |
1061 | 1097 | } |
1062 | 1098 | $text = $wgContLang->convertHtml( $title->getText() ); |
1063 | 1099 | $this->mCategories[] = $title->getText(); |
1064 | | - $this->mCategoryLinks[$type][] = $sk->link( $title, $text ); |
| 1100 | + $this->mCategoryLinks[$type][] = $this->getSkin()->link( $title, $text ); |
1065 | 1101 | } |
1066 | 1102 | } |
1067 | 1103 | } |
— | — | @@ -1768,7 +1804,7 @@ |
1769 | 1805 | * the object, let's actually output it: |
1770 | 1806 | */ |
1771 | 1807 | public function output() { |
1772 | | - global $wgUser, $wgOutputEncoding, $wgRequest; |
| 1808 | + global $wgOutputEncoding, $wgRequest; |
1773 | 1809 | global $wgLanguageCode, $wgDebugRedirects, $wgMimeType; |
1774 | 1810 | |
1775 | 1811 | if( $this->mDoNothing ) { |
— | — | @@ -1826,7 +1862,7 @@ |
1827 | 1863 | } else { |
1828 | 1864 | $this->addDefaultModules(); |
1829 | 1865 | |
1830 | | - $sk = $wgUser->getSkin( $this->getTitle() ); |
| 1866 | + $sk = $this->getSkin( $this->getTitle() ); |
1831 | 1867 | |
1832 | 1868 | // Hook that allows last minute changes to the output page, e.g. |
1833 | 1869 | // adding of CSS or Javascript by extensions. |
— | — | @@ -1868,29 +1904,29 @@ |
1869 | 1905 | * @return nothing |
1870 | 1906 | */ |
1871 | 1907 | function blockedPage( $return = true ) { |
1872 | | - global $wgUser, $wgContLang, $wgLang; |
| 1908 | + global $wgContLang, $wgLang; |
1873 | 1909 | |
1874 | 1910 | $this->setPageTitle( wfMsg( 'blockedtitle' ) ); |
1875 | 1911 | $this->setRobotPolicy( 'noindex,nofollow' ); |
1876 | 1912 | $this->setArticleRelated( false ); |
1877 | 1913 | |
1878 | | - $name = $wgUser->blockedBy(); |
1879 | | - $reason = $wgUser->blockedFor(); |
| 1914 | + $name = $this->getUser()->blockedBy(); |
| 1915 | + $reason = $this->getUser()->blockedFor(); |
1880 | 1916 | if( $reason == '' ) { |
1881 | 1917 | $reason = wfMsg( 'blockednoreason' ); |
1882 | 1918 | } |
1883 | 1919 | $blockTimestamp = $wgLang->timeanddate( |
1884 | | - wfTimestamp( TS_MW, $wgUser->mBlock->mTimestamp ), true |
| 1920 | + wfTimestamp( TS_MW, $this->getUser()->mBlock->mTimestamp ), true |
1885 | 1921 | ); |
1886 | 1922 | $ip = wfGetIP(); |
1887 | 1923 | |
1888 | 1924 | $link = '[[' . $wgContLang->getNsText( NS_USER ) . ":{$name}|{$name}]]"; |
1889 | 1925 | |
1890 | | - $blockid = $wgUser->mBlock->getId(); |
| 1926 | + $blockid = $this->getUser()->mBlock->getId(); |
1891 | 1927 | |
1892 | | - $blockExpiry = $wgLang->formatExpiry( $wgUser->mBlock->mExpiry ); |
| 1928 | + $blockExpiry = $wgLang->formatExpiry( $this->getUser()->mBlock->mExpiry ); |
1893 | 1929 | |
1894 | | - if ( $wgUser->mBlock->mAuto ) { |
| 1930 | + if ( $this->getUser()->mBlock->mAuto ) { |
1895 | 1931 | $msg = 'autoblockedtext'; |
1896 | 1932 | } else { |
1897 | 1933 | $msg = 'blockedtext'; |
— | — | @@ -1898,7 +1934,7 @@ |
1899 | 1935 | |
1900 | 1936 | /* $ip returns who *is* being blocked, $intended contains who was meant to be blocked. |
1901 | 1937 | * This could be a username, an IP range, or a single IP. */ |
1902 | | - $intended = $wgUser->mBlock->getTarget(); |
| 1938 | + $intended = $this->getUser()->mBlock->getTarget(); |
1903 | 1939 | |
1904 | 1940 | $this->addWikiMsg( |
1905 | 1941 | $msg, $link, $reason, $ip, $name, $blockid, $blockExpiry, |
— | — | @@ -2004,22 +2040,18 @@ |
2005 | 2041 | * Produce the stock "please login to use the wiki" page |
2006 | 2042 | */ |
2007 | 2043 | public function loginToUse() { |
2008 | | - global $wgUser; |
2009 | | - |
2010 | | - if( $wgUser->isLoggedIn() ) { |
| 2044 | + if( $this->getUser()->isLoggedIn() ) { |
2011 | 2045 | $this->permissionRequired( 'read' ); |
2012 | 2046 | return; |
2013 | 2047 | } |
2014 | 2048 | |
2015 | | - $skin = $wgUser->getSkin(); |
2016 | | - |
2017 | 2049 | $this->setPageTitle( wfMsg( 'loginreqtitle' ) ); |
2018 | 2050 | $this->setHtmlTitle( wfMsg( 'errorpagetitle' ) ); |
2019 | 2051 | $this->setRobotPolicy( 'noindex,nofollow' ); |
2020 | 2052 | $this->setArticleRelated( false ); |
2021 | 2053 | |
2022 | 2054 | $loginTitle = SpecialPage::getTitleFor( 'Userlogin' ); |
2023 | | - $loginLink = $skin->link( |
| 2055 | + $loginLink = $this->getSkin()->link( |
2024 | 2056 | $loginTitle, |
2025 | 2057 | wfMsgHtml( 'loginreqlink' ), |
2026 | 2058 | array(), |
— | — | @@ -2095,9 +2127,6 @@ |
2096 | 2128 | * @param $action String: action that was denied or null if unknown |
2097 | 2129 | */ |
2098 | 2130 | public function readOnlyPage( $source = null, $protected = false, $reasons = array(), $action = null ) { |
2099 | | - global $wgUser; |
2100 | | - $skin = $wgUser->getSkin(); |
2101 | | - |
2102 | 2131 | $this->setRobotPolicy( 'noindex,nofollow' ); |
2103 | 2132 | $this->setArticleRelated( false ); |
2104 | 2133 | |
— | — | @@ -2112,7 +2141,7 @@ |
2113 | 2142 | if( $source ) { |
2114 | 2143 | $this->setPageTitle( wfMsg( 'viewsource' ) ); |
2115 | 2144 | $this->setSubtitle( |
2116 | | - wfMsg( 'viewsourcefor', $skin->linkKnown( $this->getTitle() ) ) |
| 2145 | + wfMsg( 'viewsourcefor', $this->getSkin()->linkKnown( $this->getTitle() ) ) |
2117 | 2146 | ); |
2118 | 2147 | } else { |
2119 | 2148 | $this->setPageTitle( wfMsg( 'badaccess' ) ); |
— | — | @@ -2132,14 +2161,14 @@ |
2133 | 2162 | $params = array( |
2134 | 2163 | 'id' => 'wpTextbox1', |
2135 | 2164 | 'name' => 'wpTextbox1', |
2136 | | - 'cols' => $wgUser->getOption( 'cols' ), |
2137 | | - 'rows' => $wgUser->getOption( 'rows' ), |
| 2165 | + 'cols' => $this->getUser()->getOption( 'cols' ), |
| 2166 | + 'rows' => $this->getUser()->getOption( 'rows' ), |
2138 | 2167 | 'readonly' => 'readonly' |
2139 | 2168 | ); |
2140 | 2169 | $this->addHTML( Html::element( 'textarea', $params, $source ) ); |
2141 | 2170 | |
2142 | 2171 | // Show templates used by this article |
2143 | | - $skin = $wgUser->getSkin(); |
| 2172 | + $skin = $this->getSkin(); |
2144 | 2173 | $article = new Article( $this->getTitle() ); |
2145 | 2174 | $this->addHTML( "<div class='templatesUsed'> |
2146 | 2175 | {$skin->formatTemplates( $article->getUsedTemplates() )} |
— | — | @@ -2213,11 +2242,10 @@ |
2214 | 2243 | * @param $text String text of the link (input is not escaped) |
2215 | 2244 | */ |
2216 | 2245 | public function addReturnTo( $title, $query = array(), $text = null ) { |
2217 | | - global $wgUser; |
2218 | 2246 | $this->addLink( array( 'rel' => 'next', 'href' => $title->getFullURL() ) ); |
2219 | 2247 | $link = wfMsgHtml( |
2220 | 2248 | 'returnto', |
2221 | | - $wgUser->getSkin()->link( $title, $text, array(), $query ) |
| 2249 | + $this->getSkin()->link( $title, $text, array(), $query ) |
2222 | 2250 | ); |
2223 | 2251 | $this->addHTML( "<p id=\"mw-returnto\">{$link}</p>\n" ); |
2224 | 2252 | } |
— | — | @@ -2265,7 +2293,7 @@ |
2266 | 2294 | public function headElement( Skin $sk, $includeStyle = true ) { |
2267 | 2295 | global $wgOutputEncoding, $wgMimeType; |
2268 | 2296 | global $wgUseTrackbacks, $wgHtml5; |
2269 | | - global $wgUser, $wgRequest, $wgLang; |
| 2297 | + global $wgRequest, $wgLang; |
2270 | 2298 | |
2271 | 2299 | if ( $sk->commonPrintStylesheet() ) { |
2272 | 2300 | $this->addModuleStyles( 'mediawiki.legacy.wikiprintable' ); |
— | — | @@ -2310,7 +2338,7 @@ |
2311 | 2339 | if ( |
2312 | 2340 | $this->getTitle()->getNamespace() != NS_SPECIAL && |
2313 | 2341 | in_array( $action, array( 'view', 'purge' ) ) && |
2314 | | - $wgUser->getOption( 'editondblclick' ) |
| 2342 | + $this->getUser()->getOption( 'editondblclick' ) |
2315 | 2343 | ) |
2316 | 2344 | { |
2317 | 2345 | $bodyAttrs['ondblclick'] = "document.location = '" . Xml::escapeJsString( $this->getTitle()->getEditURL() ) . "'"; |
— | — | @@ -2339,7 +2367,7 @@ |
2340 | 2368 | * Add the default ResourceLoader modules to this object |
2341 | 2369 | */ |
2342 | 2370 | private function addDefaultModules() { |
2343 | | - global $wgUser, $wgIncludeLegacyJavaScript, |
| 2371 | + global $wgIncludeLegacyJavaScript, |
2344 | 2372 | $wgUseAjax, $wgAjaxWatch, $wgEnableMWSuggest; |
2345 | 2373 | |
2346 | 2374 | // Add base resources |
— | — | @@ -2354,16 +2382,16 @@ |
2355 | 2383 | |
2356 | 2384 | wfRunHooks( 'AjaxAddScript', array( &$this ) ); |
2357 | 2385 | |
2358 | | - if( $wgAjaxWatch && $wgUser->isLoggedIn() ) { |
| 2386 | + if( $wgAjaxWatch && $this->getUser()->isLoggedIn() ) { |
2359 | 2387 | $this->addModules( 'mediawiki.action.watch.ajax' ); |
2360 | 2388 | } |
2361 | 2389 | |
2362 | | - if ( $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ) { |
| 2390 | + if ( $wgEnableMWSuggest && !$this->getUser()->getOption( 'disablesuggest', false ) ) { |
2363 | 2391 | $this->addModules( 'mediawiki.legacy.mwsuggest' ); |
2364 | 2392 | } |
2365 | 2393 | } |
2366 | 2394 | |
2367 | | - if( $wgUser->getBoolOption( 'editsectiononrightclick' ) ) { |
| 2395 | + if( $this->getUser()->getBoolOption( 'editsectiononrightclick' ) ) { |
2368 | 2396 | $this->addModules( 'mediawiki.action.view.rightClickEdit' ); |
2369 | 2397 | } |
2370 | 2398 | } |
— | — | @@ -2389,7 +2417,7 @@ |
2390 | 2418 | * @return string html <script> and <style> tags |
2391 | 2419 | */ |
2392 | 2420 | protected function makeResourceLoaderLink( Skin $skin, $modules, $only, $useESI = false ) { |
2393 | | - global $wgUser, $wgLang, $wgLoadScript, $wgResourceLoaderUseESI, |
| 2421 | + global $wgLang, $wgLoadScript, $wgResourceLoaderUseESI, |
2394 | 2422 | $wgResourceLoaderInlinePrivateModules, $wgRequest; |
2395 | 2423 | // Lazy-load ResourceLoader |
2396 | 2424 | // TODO: Should this be a static function of ResourceLoader instead? |
— | — | @@ -2454,8 +2482,8 @@ |
2455 | 2483 | foreach ( $groups as $group => $modules ) { |
2456 | 2484 | $query = $baseQuery; |
2457 | 2485 | // Special handling for user-specific groups |
2458 | | - if ( ( $group === 'user' || $group === 'private' ) && $wgUser->isLoggedIn() ) { |
2459 | | - $query['user'] = $wgUser->getName(); |
| 2486 | + if ( ( $group === 'user' || $group === 'private' ) && $this->getUser()->isLoggedIn() ) { |
| 2487 | + $query['user'] = $this->getUser()->getName(); |
2460 | 2488 | } |
2461 | 2489 | |
2462 | 2490 | // Create a fake request based on the one we are about to make so modules return |
— | — | @@ -2541,7 +2569,7 @@ |
2542 | 2570 | * @return String: HTML fragment |
2543 | 2571 | */ |
2544 | 2572 | function getHeadScripts( Skin $sk ) { |
2545 | | - global $wgUser, $wgRequest, $wgUseSiteJs, $wgAllowUserJs; |
| 2573 | + global $wgRequest, $wgUseSiteJs, $wgAllowUserJs; |
2546 | 2574 | |
2547 | 2575 | // Startup - this will immediately load jquery and mediawiki modules |
2548 | 2576 | $scripts = $this->makeResourceLoaderLink( $sk, 'startup', ResourceLoaderModule::TYPE_SCRIPTS, true ); |
— | — | @@ -2571,13 +2599,13 @@ |
2572 | 2600 | // Add site JS if enabled |
2573 | 2601 | if ( $wgUseSiteJs ) { |
2574 | 2602 | $scripts .= $this->makeResourceLoaderLink( $sk, 'site', ResourceLoaderModule::TYPE_SCRIPTS ); |
2575 | | - if( $wgUser->isLoggedIn() ){ |
| 2603 | + if( $this->getUser()->isLoggedIn() ){ |
2576 | 2604 | $userScripts[] = 'user.groups'; |
2577 | 2605 | } |
2578 | 2606 | } |
2579 | 2607 | |
2580 | 2608 | // Add user JS if enabled |
2581 | | - if ( $wgAllowUserJs && $wgUser->isLoggedIn() ) { |
| 2609 | + if ( $wgAllowUserJs && $this->getUser()->isLoggedIn() ) { |
2582 | 2610 | $action = $wgRequest->getVal( 'action', 'view' ); |
2583 | 2611 | if( $this->mTitle && $this->mTitle->isJsSubpage() && $sk->userCanPreview( $action ) ) { |
2584 | 2612 | # XXX: additional security check/prompt? |
— | — | @@ -2602,7 +2630,7 @@ |
2603 | 2631 | * have to be purged on configuration changes. |
2604 | 2632 | */ |
2605 | 2633 | protected function getJSVars() { |
2606 | | - global $wgUser, $wgRequest, $wgUseAjax, $wgEnableMWSuggest, $wgContLang; |
| 2634 | + global $wgRequest, $wgUseAjax, $wgEnableMWSuggest, $wgContLang; |
2607 | 2635 | |
2608 | 2636 | $title = $this->getTitle(); |
2609 | 2637 | $ns = $title->getNamespace(); |
— | — | @@ -2624,8 +2652,8 @@ |
2625 | 2653 | 'wgArticleId' => $title->getArticleId(), |
2626 | 2654 | 'wgIsArticle' => $this->isArticle(), |
2627 | 2655 | 'wgAction' => $wgRequest->getText( 'action', 'view' ), |
2628 | | - 'wgUserName' => $wgUser->isAnon() ? null : $wgUser->getName(), |
2629 | | - 'wgUserGroups' => $wgUser->getEffectiveGroups(), |
| 2656 | + 'wgUserName' => $this->getUser()->isAnon() ? null : $this->getUser()->getName(), |
| 2657 | + 'wgUserGroups' => $this->getUser()->getEffectiveGroups(), |
2630 | 2658 | 'wgCategories' => $this->getCategories(), |
2631 | 2659 | 'wgBreakFrames' => $this->getFrameOptions() == 'DENY', |
2632 | 2660 | ); |
— | — | @@ -2635,8 +2663,8 @@ |
2636 | 2664 | foreach ( $title->getRestrictionTypes() as $type ) { |
2637 | 2665 | $vars['wgRestriction' . ucfirst( $type )] = $title->getRestrictions( $type ); |
2638 | 2666 | } |
2639 | | - if ( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ) { |
2640 | | - $vars['wgSearchNamespaces'] = SearchEngine::userNamespaces( $wgUser ); |
| 2667 | + if ( $wgUseAjax && $wgEnableMWSuggest && !$this->getUser()->getOption( 'disablesuggest', false ) ) { |
| 2668 | + $vars['wgSearchNamespaces'] = SearchEngine::userNamespaces( $this->getUser() ); |
2641 | 2669 | } |
2642 | 2670 | |
2643 | 2671 | // Allow extensions to add their custom variables to the global JS variables |
Index: trunk/phase3/includes/api/ApiParse.php |
— | — | @@ -252,6 +252,7 @@ |
253 | 253 | |
254 | 254 | if ( isset( $prop['headitems'] ) || isset( $prop['headhtml'] ) ) { |
255 | 255 | $out = new OutputPage; |
| 256 | + $out->setUser( $wgUser ); |
256 | 257 | $out->addParserOutputNoText( $p_result ); |
257 | 258 | $userSkin = $wgUser->getSkin(); |
258 | 259 | |
Index: trunk/phase3/includes/SpecialPage.php |
— | — | @@ -619,12 +619,13 @@ |
620 | 620 | * @return String: HTML fragment |
621 | 621 | */ |
622 | 622 | static function capturePath( &$title ) { |
623 | | - global $wgOut, $wgTitle; |
| 623 | + global $wgOut, $wgTitle, $wgUser; |
624 | 624 | |
625 | 625 | $oldTitle = $wgTitle; |
626 | 626 | $oldOut = $wgOut; |
627 | 627 | $wgOut = new OutputPage; |
628 | 628 | $wgOut->setTitle( $title ); |
| 629 | + $wgOut->setUser( $wgUser ); # for now, there may be a better idea in the future |
629 | 630 | |
630 | 631 | $ret = SpecialPage::executePath( $title, true ); |
631 | 632 | if ( $ret === true ) { |