Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -1925,6 +1925,32 @@ |
1926 | 1926 | } |
1927 | 1927 | |
1928 | 1928 | /** |
| 1929 | + * Prepare this object to display an error page; disable caching and |
| 1930 | + * indexing, clear the current text and redirect, set the page's title |
| 1931 | + * and optionally an custom HTML title (content of the <title> tag). |
| 1932 | + * |
| 1933 | + * @param $pageTitle String|Message will be passed directly to setPageTitle() |
| 1934 | + * @param $htmlTitle String|Message will be passed directly to setHTMLTitle(); |
| 1935 | + * optional, if not passed the <title> attribute will be |
| 1936 | + * based on $pageTitle |
| 1937 | + */ |
| 1938 | + public function prepareErrorPage( $pageTitle, $htmlTitle = false ) { |
| 1939 | + if ( $this->getTitle() ) { |
| 1940 | + $this->mDebugtext .= 'Original title: ' . $this->getTitle()->getPrefixedText() . "\n"; |
| 1941 | + } |
| 1942 | + |
| 1943 | + $this->setPageTitle( $pageTitle ); |
| 1944 | + if ( $htmlTitle !== false ) { |
| 1945 | + $this->setHTMLTitle( $htmlTitle ); |
| 1946 | + } |
| 1947 | + $this->setRobotPolicy( 'noindex,nofollow' ); |
| 1948 | + $this->setArticleRelated( false ); |
| 1949 | + $this->enableClientCache( false ); |
| 1950 | + $this->mRedirect = ''; |
| 1951 | + $this->clearHTML(); |
| 1952 | + } |
| 1953 | + |
| 1954 | + /** |
1929 | 1955 | * Output a standard error page |
1930 | 1956 | * |
1931 | 1957 | * showErrorPage( 'titlemsg', 'pagetextmsg', array( 'param1', 'param2' ) ); |
— | — | @@ -1935,16 +1961,7 @@ |
1936 | 1962 | * @param $params Array: message parameters; ignored if $msg is a Message object |
1937 | 1963 | */ |
1938 | 1964 | public function showErrorPage( $title, $msg, $params = array() ) { |
1939 | | - if ( $this->getTitle() ) { |
1940 | | - $this->mDebugtext .= 'Original title: ' . $this->getTitle()->getPrefixedText() . "\n"; |
1941 | | - } |
1942 | | - $this->setPageTitle( $this->msg( $title ) ); |
1943 | | - $this->setHTMLTitle( $this->msg( 'errorpagetitle' ) ); |
1944 | | - $this->setRobotPolicy( 'noindex,nofollow' ); |
1945 | | - $this->setArticleRelated( false ); |
1946 | | - $this->enableClientCache( false ); |
1947 | | - $this->mRedirect = ''; |
1948 | | - $this->mBodytext = ''; |
| 1965 | + $this->prepareErrorPage( $this->msg( $title ), $this->msg( 'errorpagetitle' ) ); |
1949 | 1966 | |
1950 | 1967 | if ( $msg instanceof Message ){ |
1951 | 1968 | $this->addHTML( $msg->parse() ); |
— | — | @@ -1962,15 +1979,8 @@ |
1963 | 1980 | * @param $action String: action that was denied or null if unknown |
1964 | 1981 | */ |
1965 | 1982 | public function showPermissionsErrorPage( $errors, $action = null ) { |
1966 | | - $this->mDebugtext .= 'Original title: ' . |
1967 | | - $this->getTitle()->getPrefixedText() . "\n"; |
1968 | | - $this->setPageTitle( $this->msg( 'permissionserrors' ) ); |
1969 | | - $this->setHTMLTitle( $this->msg('permissionserrors' ) ); |
1970 | | - $this->setRobotPolicy( 'noindex,nofollow' ); |
1971 | | - $this->setArticleRelated( false ); |
1972 | | - $this->enableClientCache( false ); |
1973 | | - $this->mRedirect = ''; |
1974 | | - $this->mBodytext = ''; |
| 1983 | + $this->prepareErrorPage( $this->msg( 'permissionserrors' ), $this->msg( 'permissionserrors' ) ); |
| 1984 | + |
1975 | 1985 | $this->addWikiText( $this->formatPermissionsErrorMessage( $errors, $action ) ); |
1976 | 1986 | } |
1977 | 1987 | |
— | — | @@ -1981,11 +1991,7 @@ |
1982 | 1992 | * @param $version Mixed: the version of MediaWiki needed to use the page |
1983 | 1993 | */ |
1984 | 1994 | public function versionRequired( $version ) { |
1985 | | - $this->setPageTitle( $this->msg( 'versionrequired' ) ); |
1986 | | - $this->setHTMLTitle( $this->msg( 'versionrequired', $version ) ); |
1987 | | - $this->setRobotPolicy( 'noindex,nofollow' ); |
1988 | | - $this->setArticleRelated( false ); |
1989 | | - $this->mBodytext = ''; |
| 1995 | + $this->prepareErrorPage( $this->msg( 'versionrequired', $version ) ); |
1990 | 1996 | |
1991 | 1997 | $this->addWikiMsg( 'versionrequiredtext', $version ); |
1992 | 1998 | $this->returnToMain(); |
— | — | @@ -2008,14 +2014,10 @@ |
2009 | 2015 | throw new PermissionsError( 'read' ); |
2010 | 2016 | } |
2011 | 2017 | |
2012 | | - $this->setPageTitle( $this->msg( 'loginreqtitle' ) ); |
2013 | | - $this->setHTMLTitle( $this->msg( 'errorpagetitle' ) ); |
2014 | | - $this->setRobotPolicy( 'noindex,nofollow' ); |
2015 | | - $this->setArticleRelated( false ); |
| 2018 | + $this->prepareErrorPage( $this->msg( 'loginreqtitle' ), $this->msg( 'errorpagetitle' ) ); |
2016 | 2019 | |
2017 | | - $loginTitle = SpecialPage::getTitleFor( 'Userlogin' ); |
2018 | 2020 | $loginLink = Linker::linkKnown( |
2019 | | - $loginTitle, |
| 2021 | + SpecialPage::getTitleFor( 'Userlogin' ), |
2020 | 2022 | $this->msg( 'loginreqlink' )->escaped(), |
2021 | 2023 | array(), |
2022 | 2024 | array( 'returnto' => $this->getTitle()->getPrefixedText() ) |
— | — | @@ -2176,12 +2178,9 @@ |
2177 | 2179 | } |
2178 | 2180 | |
2179 | 2181 | public function showFatalError( $message ) { |
2180 | | - $this->setPageTitle( $this->msg( 'internalerror' ) ); |
2181 | | - $this->setRobotPolicy( 'noindex,nofollow' ); |
2182 | | - $this->setArticleRelated( false ); |
2183 | | - $this->enableClientCache( false ); |
2184 | | - $this->mRedirect = ''; |
2185 | | - $this->mBodytext = $message; |
| 2182 | + $this->prepareErrorPage( $this->msg( 'internalerror' ) ); |
| 2183 | + |
| 2184 | + $this->addHTML( $message ); |
2186 | 2185 | } |
2187 | 2186 | |
2188 | 2187 | public function showUnexpectedValueError( $name, $val ) { |
Index: trunk/phase3/includes/Exception.php |
— | — | @@ -138,8 +138,7 @@ |
139 | 139 | * @return String |
140 | 140 | */ |
141 | 141 | function getPageTitle() { |
142 | | - global $wgSitename; |
143 | | - return $this->msg( 'internalerror', "$wgSitename error" ); |
| 142 | + return $this->msg( 'internalerror', "Internal error" ); |
144 | 143 | } |
145 | 144 | |
146 | 145 | /** |
— | — | @@ -171,12 +170,7 @@ |
172 | 171 | function reportHTML() { |
173 | 172 | global $wgOut; |
174 | 173 | if ( $this->useOutputPage() ) { |
175 | | - $wgOut->setPageTitle( $this->getPageTitle() ); |
176 | | - $wgOut->setRobotPolicy( "noindex,nofollow" ); |
177 | | - $wgOut->setArticleRelated( false ); |
178 | | - $wgOut->enableClientCache( false ); |
179 | | - $wgOut->redirect( '' ); |
180 | | - $wgOut->clearHTML(); |
| 174 | + $wgOut->prepareErrorPage( $this->getPageTitle() ); |
181 | 175 | |
182 | 176 | $hookResult = $this->runHooks( get_class( $this ) ); |
183 | 177 | if ( $hookResult ) { |