Index: trunk/extensions/Commentbox/SpecialAddComment_body.php |
— | — | @@ -75,37 +75,15 @@ |
76 | 76 | // Append <br /> after each newline, except if the user started a new paragraph |
77 | 77 | $Comment = preg_replace( '/(?<!\n)\n(?!\n)/', "<br />\n", $Comment ); |
78 | 78 | $text .= "\n\n" . $subject . $Comment . "\n<br />" . $sig; |
79 | | - try { |
80 | | - $req = new FauxRequest( array( |
81 | | - 'action' => 'edit', |
82 | | - 'title' => $title->getPrefixedText(), |
83 | | - 'text' => $text, |
84 | | - 'summary' => wfMsgForContent( 'commentbox-log' ), |
85 | | - 'token' => $wgUser->editToken(), |
86 | | - ), true ); |
87 | | - $api = new ApiMain( $req, true ); |
88 | | - $api->execute(); |
89 | | - wfDebug( "Completed API-Save\n" ); |
90 | | - // we only reach this point if Api doesn't throw an exception |
91 | | - $data = $api->getResultData(); |
92 | | - if ( $data['edit']['result'] == 'Failure' ) { |
93 | | - $spamurl = $data['edit']['spamblacklist']; |
94 | | - if ( $spamurl != '' ) |
95 | | - throw new Exception( "Die Seite enthaelt die Spam-Url ``{$spamurl}''" ); |
96 | | - else |
97 | | - throw new Exception( "Unbekannter Fehler" ); |
98 | | - } |
99 | | - } catch ( Exception $e ) { |
100 | | - global $wgOut; |
| 79 | + $status = $article->doEdit( $text, wfMsgForContent( 'commentbox-log' ) ); |
| 80 | + |
| 81 | + if ( $status->isOK() ) { |
| 82 | + $wgOut->redirect( $title->getFullURL() ); |
| 83 | + } else { |
101 | 84 | $wgOut->setPageTitle( wfMsg( 'commentbox-errorpage-title' ) ); |
102 | | - $wgOut->addHTML( "<div class='errorbox'>" . htmlspecialchars( $e->getMessage() ) . "</div><br clear='both' />" ); |
103 | | - if ( $title != null ) |
104 | | - $wgOut->returnToMain( false, $title ); |
105 | | - return; |
| 85 | + $wgOut->addWikiText( $status->getWikiText() ); |
| 86 | + $wgOut->returnToMain( false, $title ); |
106 | 87 | } |
107 | | - |
108 | | - $wgOut->redirect( $title->getFullURL() ); |
109 | | - return; |
110 | 88 | } |
111 | 89 | |
112 | 90 | function fail( $str, $title = null ) { |