Index: trunk/phase3/maintenance/language/messages.inc |
— | — | @@ -398,6 +398,7 @@ |
399 | 399 | 'actionthrottledtext', |
400 | 400 | 'protectedpagetext', |
401 | 401 | 'viewsourcetext', |
| 402 | + 'viewyourtext', |
402 | 403 | 'protectedinterface', |
403 | 404 | 'editinginterface', |
404 | 405 | 'sqlhidden', |
— | — | @@ -587,8 +588,6 @@ |
588 | 589 | 'blockedtext', |
589 | 590 | 'autoblockedtext', |
590 | 591 | 'blockednoreason', |
591 | | - 'blockedoriginalsource', |
592 | | - 'blockededitsource', |
593 | 592 | 'whitelistedittitle', |
594 | 593 | 'whitelistedittext', |
595 | 594 | 'confirmedittext', |
Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -403,27 +403,6 @@ |
404 | 404 | $this->preview = true; |
405 | 405 | } |
406 | 406 | |
407 | | - $wgOut->addModules( array( 'mediawiki.action.edit' ) ); |
408 | | - |
409 | | - if ( $wgUser->getOption( 'uselivepreview', false ) ) { |
410 | | - $wgOut->addModules( 'mediawiki.legacy.preview' ); |
411 | | - } |
412 | | - // Bug #19334: textarea jumps when editing articles in IE8 |
413 | | - $wgOut->addStyle( 'common/IE80Fixes.css', 'screen', 'IE 8' ); |
414 | | - |
415 | | - $permErrors = $this->getEditPermissionErrors(); |
416 | | - if ( $permErrors ) { |
417 | | - // Auto-block user's IP if the account was "hard" blocked |
418 | | - $wgUser->spreadAnyEditBlock(); |
419 | | - |
420 | | - wfDebug( __METHOD__ . ": User can't edit\n" ); |
421 | | - $content = $this->getContent( null ); |
422 | | - $content = $content === '' ? null : $content; |
423 | | - $this->readOnlyPage( $content, true, $permErrors, 'edit' ); |
424 | | - wfProfileOut( __METHOD__ ); |
425 | | - return; |
426 | | - } |
427 | | - |
428 | 407 | if ( $this->save ) { |
429 | 408 | $this->formtype = 'save'; |
430 | 409 | } elseif ( $this->preview ) { |
— | — | @@ -439,6 +418,26 @@ |
440 | 419 | } |
441 | 420 | } |
442 | 421 | |
| 422 | + $permErrors = $this->getEditPermissionErrors(); |
| 423 | + if ( $permErrors ) { |
| 424 | + wfDebug( __METHOD__ . ": User can't edit\n" ); |
| 425 | + // Auto-block user's IP if the account was "hard" blocked |
| 426 | + $wgUser->spreadAnyEditBlock(); |
| 427 | + |
| 428 | + $this->displayPermissionsError( $permErrors ); |
| 429 | + |
| 430 | + wfProfileOut( __METHOD__ ); |
| 431 | + return; |
| 432 | + } |
| 433 | + |
| 434 | + $wgOut->addModules( array( 'mediawiki.action.edit' ) ); |
| 435 | + |
| 436 | + if ( $wgUser->getOption( 'uselivepreview', false ) ) { |
| 437 | + $wgOut->addModules( 'mediawiki.legacy.preview' ); |
| 438 | + } |
| 439 | + // Bug #19334: textarea jumps when editing articles in IE8 |
| 440 | + $wgOut->addStyle( 'common/IE80Fixes.css', 'screen', 'IE 8' ); |
| 441 | + |
443 | 442 | wfProfileIn( __METHOD__."-business-end" ); |
444 | 443 | |
445 | 444 | $this->isConflict = false; |
— | — | @@ -540,9 +539,68 @@ |
541 | 540 | } |
542 | 541 | |
543 | 542 | /** |
| 543 | + * Display a permissions error page, like OutputPage::showPermissionsErrorPage(), |
| 544 | + * but with the following differences: |
| 545 | + * - If redlink=1, the user will be redirect to the page |
| 546 | + * - If there is content to display or the error occurs while either saving, |
| 547 | + * previewing or showing the difference, it will be a |
| 548 | + * "View source for ..." page displaying the source code after the error message. |
| 549 | + * |
| 550 | + * @since 1.19 |
| 551 | + * @param $permErrors Array of permissions errors, as returned by |
| 552 | + * Title::getUserPermissionsErrors(). |
| 553 | + */ |
| 554 | + protected function displayPermissionsError( array $permErrors ) { |
| 555 | + global $wgRequest, $wgOut; |
| 556 | + |
| 557 | + if ( $wgRequest->getBool( 'redlink' ) ) { |
| 558 | + // The edit page was reached via a red link. |
| 559 | + // Redirect to the article page and let them click the edit tab if |
| 560 | + // they really want a permission error. |
| 561 | + $wgOut->redirect( $this->mTitle->getFullUrl() ); |
| 562 | + return; |
| 563 | + } |
| 564 | + |
| 565 | + $content = $this->getContent(); |
| 566 | + |
| 567 | + # Use the normal message if there's nothing to display |
| 568 | + if ( $this->firsttime && $content === '' ) { |
| 569 | + $action = $this->mTitle->exists() ? 'edit' : |
| 570 | + ( $permission = $this->mTitle->isTalkPage() ? 'createtalk' : 'createpage' ); |
| 571 | + throw new PermissionsError( $action, $permErrors ); |
| 572 | + } |
| 573 | + |
| 574 | + $wgOut->setPageTitle( wfMessage( 'viewsource' ) ); |
| 575 | + $wgOut->setSubtitle( |
| 576 | + wfMessage( 'viewsourcefor', Linker::linkKnown( $this->mTitle ) )->text() |
| 577 | + ); |
| 578 | + $wgOut->addWikiText( $wgOut->formatPermissionsErrorMessage( $permErrors, 'edit' ) ); |
| 579 | + $wgOut->addHTML( "<hr />\n" ); |
| 580 | + |
| 581 | + # If the user made changes, preserve them when showing the markup |
| 582 | + # (This happens when a user is blocked during edit, for instance) |
| 583 | + if ( !$this->firsttime ) { |
| 584 | + $content = $this->textbox1; |
| 585 | + $wgOut->addWikiMsg( 'viewyourtext' ); |
| 586 | + } else { |
| 587 | + $wgOut->addWikiMsg( 'viewsourcetext' ); |
| 588 | + } |
| 589 | + |
| 590 | + $this->showTextbox( $content, 'wpTextbox1', array( 'readonly' ) ); |
| 591 | + |
| 592 | + $wgOut->addHTML( Html::rawElement( 'div', array( 'class' => 'templatesUsed' ), |
| 593 | + Linker::formatTemplates( $this->getTemplates() ) ) ); |
| 594 | + |
| 595 | + if ( $this->mTitle->exists() ) { |
| 596 | + $wgOut->returnToMain( null, $this->mTitle ); |
| 597 | + } |
| 598 | + } |
| 599 | + |
| 600 | + /** |
544 | 601 | * Show a read-only error |
545 | 602 | * Parameters are the same as OutputPage:readOnlyPage() |
546 | 603 | * Redirect to the article page if redlink=1 |
| 604 | + * @deprecated in 1.19; use displayPermissionsError() instead |
547 | 605 | */ |
548 | 606 | function readOnlyPage( $source = null, $protected = false, $reasons = array(), $action = null ) { |
549 | 607 | global $wgRequest, $wgOut; |
— | — | @@ -2188,26 +2246,13 @@ |
2189 | 2247 | |
2190 | 2248 | /** |
2191 | 2249 | * Call the stock "user is blocked" page |
| 2250 | + * |
| 2251 | + * @deprecated in 1.19; throw an exception directly instead |
2192 | 2252 | */ |
2193 | 2253 | function blockedPage() { |
2194 | | - global $wgOut; |
2195 | | - $wgOut->blockedPage( false ); # Standard block notice on the top, don't 'return' |
| 2254 | + global $wgUser; |
2196 | 2255 | |
2197 | | - # If the user made changes, preserve them when showing the markup |
2198 | | - # (This happens when a user is blocked during edit, for instance) |
2199 | | - $first = $this->firsttime || ( !$this->save && $this->textbox1 == '' ); |
2200 | | - if ( $first ) { |
2201 | | - $source = $this->mTitle->exists() ? $this->getContent() : false; |
2202 | | - } else { |
2203 | | - $source = $this->textbox1; |
2204 | | - } |
2205 | | - |
2206 | | - # Spit out the source or the user's modified version |
2207 | | - if ( $source !== false ) { |
2208 | | - $wgOut->addHTML( '<hr />' ); |
2209 | | - $wgOut->addWikiMsg( $first ? 'blockedoriginalsource' : 'blockededitsource', $this->mTitle->getPrefixedText() ); |
2210 | | - $this->showTextbox1( array( 'readonly' ), $source ); |
2211 | | - } |
| 2256 | + throw new UserBlockedError( $wgUser->mBlock ); |
2212 | 2257 | } |
2213 | 2258 | |
2214 | 2259 | /** |
— | — | @@ -2216,6 +2261,8 @@ |
2217 | 2262 | function userNotLoggedInPage() { |
2218 | 2263 | global $wgOut; |
2219 | 2264 | |
| 2265 | + $wgOut->prepareErrorPage( wfMessage( 'whitelistedittitle' ) ); |
| 2266 | + |
2220 | 2267 | $loginTitle = SpecialPage::getTitleFor( 'Userlogin' ); |
2221 | 2268 | $loginLink = Linker::linkKnown( |
2222 | 2269 | $loginTitle, |
— | — | @@ -2223,25 +2270,28 @@ |
2224 | 2271 | array(), |
2225 | 2272 | array( 'returnto' => $this->getContextTitle()->getPrefixedText() ) |
2226 | 2273 | ); |
2227 | | - |
2228 | | - $wgOut->setPageTitle( wfMessage( 'whitelistedittitle' ) ); |
2229 | | - $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
2230 | | - $wgOut->setArticleRelated( false ); |
2231 | | - |
2232 | 2274 | $wgOut->addHTML( wfMessage( 'whitelistedittext' )->rawParams( $loginLink )->parse() ); |
2233 | 2275 | $wgOut->returnToMain( false, $this->getContextTitle() ); |
2234 | 2276 | } |
2235 | 2277 | |
2236 | 2278 | /** |
| 2279 | + * Show an error page saying to the user that he has insufficient permissions |
| 2280 | + * to create a new page |
| 2281 | + * |
| 2282 | + * @deprecated in 1.19; throw an exception directly instead |
| 2283 | + */ |
| 2284 | + function noCreatePermission() { |
| 2285 | + throw new MWException( 'nocreatetitle', 'nocreatetext' ); |
| 2286 | + } |
| 2287 | + |
| 2288 | + /** |
2237 | 2289 | * Creates a basic error page which informs the user that |
2238 | 2290 | * they have attempted to edit a nonexistent section. |
2239 | 2291 | */ |
2240 | 2292 | function noSuchSectionPage() { |
2241 | 2293 | global $wgOut; |
2242 | 2294 | |
2243 | | - $wgOut->setPageTitle( wfMessage( 'nosuchsectiontitle' ) ); |
2244 | | - $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
2245 | | - $wgOut->setArticleRelated( false ); |
| 2295 | + $wgOut->prepareErrorPage( wfMessage( 'nosuchsectiontitle' ) ); |
2246 | 2296 | |
2247 | 2297 | $res = wfMsgExt( 'nosuchsectiontext', 'parse', $this->section ); |
2248 | 2298 | wfRunHooks( 'EditPageNoSuchSection', array( &$this, &$res ) ); |
— | — | @@ -2259,9 +2309,7 @@ |
2260 | 2310 | static function spamPage( $match = false ) { |
2261 | 2311 | global $wgOut, $wgTitle; |
2262 | 2312 | |
2263 | | - $wgOut->setPageTitle( wfMessage( 'spamprotectiontitle' ) ); |
2264 | | - $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
2265 | | - $wgOut->setArticleRelated( false ); |
| 2313 | + $wgOut->prepareErrorPage( wfMessage( 'spamprotectiontitle' ) ); |
2266 | 2314 | |
2267 | 2315 | $wgOut->addHTML( '<div id="spamprotected">' ); |
2268 | 2316 | $wgOut->addWikiMsg( 'spamprotectiontext' ); |
— | — | @@ -2282,9 +2330,7 @@ |
2283 | 2331 | global $wgOut; |
2284 | 2332 | $this->textbox2 = $this->textbox1; |
2285 | 2333 | |
2286 | | - $wgOut->setPageTitle( wfMessage( 'spamprotectiontitle' ) ); |
2287 | | - $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
2288 | | - $wgOut->setArticleRelated( false ); |
| 2334 | + $wgOut->prepareErrorPage( wfMessage( 'spamprotectiontitle' ) ); |
2289 | 2335 | |
2290 | 2336 | $wgOut->addHTML( '<div id="spamprotected">' ); |
2291 | 2337 | $wgOut->addWikiMsg( 'spamprotectiontext' ); |
— | — | @@ -2841,12 +2887,6 @@ |
2842 | 2888 | return strtr( $result, array( "�" => "&#x" ) ); |
2843 | 2889 | } |
2844 | 2890 | |
2845 | | - function noCreatePermission() { |
2846 | | - global $wgOut; |
2847 | | - $wgOut->setPageTitle( wfMessage( 'nocreatetitle' ) ); |
2848 | | - $wgOut->addWikiMsg( 'nocreatetext' ); |
2849 | | - } |
2850 | | - |
2851 | 2891 | /** |
2852 | 2892 | * Attempt submission |
2853 | 2893 | * @return bool false if output is done, true if the rest of the form should be displayed |
— | — | @@ -2901,42 +2941,39 @@ |
2902 | 2942 | $wgOut->redirect( $this->mTitle->getFullURL( $extraQuery ) . $sectionanchor ); |
2903 | 2943 | return false; |
2904 | 2944 | |
| 2945 | + case self::AS_BLANK_ARTICLE: |
| 2946 | + $wgOut->redirect( $this->getContextTitle()->getFullURL() ); |
| 2947 | + return false; |
| 2948 | + |
2905 | 2949 | case self::AS_SPAM_ERROR: |
2906 | 2950 | $this->spamPageWithContent( $resultDetails['spam'] ); |
2907 | 2951 | return false; |
2908 | 2952 | |
2909 | 2953 | case self::AS_BLOCKED_PAGE_FOR_USER: |
2910 | | - $this->blockedPage(); |
2911 | | - return false; |
| 2954 | + throw new UserBlockedError( $wgUser->mBlock ); |
2912 | 2955 | |
2913 | 2956 | case self::AS_IMAGE_REDIRECT_ANON: |
2914 | | - $wgOut->showErrorPage( 'uploadnologin', 'uploadnologintext' ); |
2915 | | - return false; |
| 2957 | + throw new ErrorPageError( 'uploadnologin', 'uploadnologintext' ); |
2916 | 2958 | |
| 2959 | + case self::AS_IMAGE_REDIRECT_LOGGED: |
| 2960 | + throw new PermissionsError( 'upload' ); |
| 2961 | + |
2917 | 2962 | case self::AS_READ_ONLY_PAGE_ANON: |
2918 | 2963 | $this->userNotLoggedInPage(); |
2919 | 2964 | return false; |
2920 | 2965 | |
2921 | 2966 | case self::AS_READ_ONLY_PAGE_LOGGED: |
| 2967 | + throw new PermissionsError( 'edit' ); |
| 2968 | + |
2922 | 2969 | case self::AS_READ_ONLY_PAGE: |
2923 | | - $wgOut->readOnlyPage(); |
2924 | | - return false; |
| 2970 | + throw new ReadOnlyError; |
2925 | 2971 | |
2926 | 2972 | case self::AS_RATE_LIMITED: |
2927 | | - $wgOut->rateLimited(); |
2928 | | - return false; |
| 2973 | + throw new ThrottledError(); |
2929 | 2974 | |
2930 | 2975 | case self::AS_NO_CREATE_PERMISSION: |
2931 | | - $this->noCreatePermission(); |
2932 | | - return false; |
| 2976 | + throw new MWException( 'nocreatetitle', 'nocreatetext' ); |
2933 | 2977 | |
2934 | | - case self::AS_BLANK_ARTICLE: |
2935 | | - $wgOut->redirect( $this->getContextTitle()->getFullURL() ); |
2936 | | - return false; |
2937 | | - |
2938 | | - case self::AS_IMAGE_REDIRECT_LOGGED: |
2939 | | - $wgOut->permissionRequired( 'upload' ); |
2940 | | - return false; |
2941 | 2978 | } |
2942 | 2979 | return false; |
2943 | 2980 | } |
Index: trunk/phase3/languages/messages/MessagesQqq.php |
— | — | @@ -660,6 +660,7 @@ |
661 | 661 | |
662 | 662 | * $1: the protection type, e.g. "protect" for fully protected pages', |
663 | 663 | 'viewsourcetext' => 'The text shown when displaying the source of a page that the user has no permission to edit', |
| 664 | +'viewyourtext' => 'Same as {{msg-mw|viewsourcetext}} but when showing the text submitted by the user, this happens e.g. when the user was blocked while he is editing the page', |
664 | 665 | 'protectedinterface' => 'Message shown if a user without the "editinterface" right tries to edit a page in the MediaWiki namespace.', |
665 | 666 | 'editinginterface' => "A message shown when editing pages in the namespace MediaWiki:. In the [http://translatewiki.net/wiki/Main_Page?setlang=en URL], '''change \"setlang=en\" to your own language code.'''", |
666 | 667 | 'ns-specialprotected' => 'Error message displayed when trying to edit a page in the Special namespace', |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -1011,6 +1011,7 @@ |
1012 | 1012 | Please try again in a few minutes.', |
1013 | 1013 | 'protectedpagetext' => 'This page has been protected to prevent editing.', |
1014 | 1014 | 'viewsourcetext' => 'You can view and copy the source of this page:', |
| 1015 | +'viewyourtext' => "You can view and copy the source of '''your edits''' to this page:", |
1015 | 1016 | 'protectedinterface' => 'This page provides interface text for the software, and is protected to prevent abuse.', |
1016 | 1017 | 'editinginterface' => "'''Warning:''' You are editing a page which is used to provide interface text for the software. |
1017 | 1018 | Changes to this page will affect the appearance of the user interface for other users. |
— | — | @@ -1297,8 +1298,6 @@ |
1298 | 1299 | Your current IP address is $3, and the block ID is #$5. |
1299 | 1300 | Please include all above details in any queries you make.', |
1300 | 1301 | 'blockednoreason' => 'no reason given', |
1301 | | -'blockedoriginalsource' => "The source of '''$1''' is shown below:", |
1302 | | -'blockededitsource' => "The text of '''your edits''' to '''$1''' is shown below:", |
1303 | 1302 | 'whitelistedittitle' => 'Login required to edit', |
1304 | 1303 | 'whitelistedittext' => 'You have to $1 to edit pages.', |
1305 | 1304 | 'confirmedittext' => 'You must confirm your e-mail address before editing pages. |