Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -1924,12 +1924,14 @@ |
1925 | 1925 | $wgOut->addHTML( implode( $this->getEditButtons( $tabindex ), "\n" ) . "\n" ); |
1926 | 1926 | |
1927 | 1927 | $cancel = $this->getCancelLink(); |
1928 | | - $separator = wfMsgExt( 'pipe-separator' , 'escapenoentities' ); |
| 1928 | + if ( $cancel !== '' ) { |
| 1929 | + $cancel .= wfMsgExt( 'pipe-separator' , 'escapenoentities' ); |
| 1930 | + } |
1929 | 1931 | $edithelpurl = Skin::makeInternalOrExternalUrl( wfMsgForContent( 'edithelppage' ) ); |
1930 | 1932 | $edithelp = '<a target="helpwindow" href="'.$edithelpurl.'">'. |
1931 | 1933 | htmlspecialchars( wfMsg( 'edithelp' ) ).'</a> '. |
1932 | 1934 | htmlspecialchars( wfMsg( 'newwindow' ) ); |
1933 | | - $wgOut->addHTML( " <span class='editHelp'>{$cancel}{$separator}{$edithelp}</span>\n" ); |
| 1935 | + $wgOut->addHTML( " <span class='editHelp'>{$cancel}{$edithelp}</span>\n" ); |
1934 | 1936 | $wgOut->addHTML( "</div><!-- editButtons -->\n</div><!-- editOptions -->\n" ); |
1935 | 1937 | } |
1936 | 1938 | |
Index: trunk/extensions/TalkHere/TalkHere.php |
— | — | @@ -32,6 +32,7 @@ |
33 | 33 | |
34 | 34 | ///// hook it up ///////////////////////////////////////////////////// |
35 | 35 | $wgAutoloadClasses['TalkHereHooks'] = $dir . 'TalkHereHooks.php'; |
| 36 | +$wgAutoloadClasses['TalkHereEditPage'] = $dir . 'TalkHereHooks.php'; |
36 | 37 | |
37 | 38 | $wgHooks['BeforePageDisplay'][] = 'TalkHereHooks::onBeforePageDisplay'; |
38 | 39 | $wgHooks['CustomEditor'][] = 'TalkHereHooks::onCustomEditor'; |
— | — | @@ -40,29 +41,11 @@ |
41 | 42 | |
42 | 43 | $wgAjaxExportList[] = 'wfTalkHereAjaxEditor'; |
43 | 44 | |
44 | | -function mangleEditForm( &$out, $returnto = false, $ajax = false ) { //HACK! too bad we need this :( |
45 | | - global $wgUser; |
46 | | - $sk = $wgUser->getSkin(); |
47 | | - |
48 | | - $html = $out->getHTML(); |
49 | | - |
50 | | - if ( $returnto ) { //re-target cancel link |
51 | | - $cancel = $sk->makeLinkObj( Title::newFromText( $returnto ), wfMsgExt('cancel', array( 'parseinline' ) ) ); |
52 | | - $html = preg_replace( '!<a[^<>]+>[^<>]+</a>( *\| *<a target=["\']helpwindow["\'])!smi', $cancel . '\1', $html ); |
53 | | - } |
54 | | - else { |
55 | | - $html = preg_replace( '!<a[^<>]+>[^<>]+</a> *\| *(<a target=["\']helpwindow["\'])!smi', '\1', $html ); |
56 | | - } |
57 | | - |
58 | | - $out->clearHTML(); |
59 | | - $out->addHTML($html); |
60 | | -} |
61 | | - |
62 | 45 | function wfTalkHereAjaxEditor( $page, $section, $returnto ) { |
63 | 46 | global $wgRequest, $wgTitle, $wgOut; |
64 | 47 | |
65 | | - $wgTitle = Title::newFromText( $page ); |
66 | | - if ( !$wgTitle ) { |
| 48 | + $title = Title::newFromText( $page ); |
| 49 | + if ( !$title ) { |
67 | 50 | return false; |
68 | 51 | } |
69 | 52 | |
— | — | @@ -75,15 +58,15 @@ |
76 | 59 | ); |
77 | 60 | |
78 | 61 | $wgRequest = new FauxRequest( $args ); |
79 | | - $article = MediaWiki::articleFromTitle( $wgTitle, RequestContext::getMain() ); |
80 | | - $editor = new EditPage( $article ); |
| 62 | + $wgTitle = $title; |
81 | 63 | |
| 64 | + $article = MediaWiki::articleFromTitle( $title, RequestContext::getMain() ); |
| 65 | + $editor = new TalkHereEditPage( $article ); |
| 66 | + |
82 | 67 | //generate form |
83 | 68 | $editor->importFormData( $wgRequest ); |
84 | 69 | $editor->showEditForm(); |
85 | 70 | |
86 | | - mangleEditForm( $wgOut, false, true ); //HACK. This sucks. |
87 | | - |
88 | 71 | $response = new AjaxResponse(); |
89 | 72 | $response->addText( $wgOut->getHTML() ); |
90 | 73 | $response->setCacheDuration( false ); //don't cache, because of tokens etc |
Index: trunk/extensions/TalkHere/TalkHereHooks.php |
— | — | @@ -279,6 +279,7 @@ |
280 | 280 | |
281 | 281 | //use a wrapper to override redirection target |
282 | 282 | $editor = new TalkHereEditPage( $article ); |
| 283 | + $editor->setReturnTo( $to ); |
283 | 284 | $editor->submit(); |
284 | 285 | $code = $editor->getCode(); |
285 | 286 | |
— | — | @@ -288,7 +289,6 @@ |
289 | 290 | $wgOut->redirect( $to->getFullURL() . $editor->getAnchor() ); |
290 | 291 | } |
291 | 292 | |
292 | | - mangleEditForm( $wgOut, $returnto ); //HACK. This sucks. |
293 | 293 | return false; |
294 | 294 | } |
295 | 295 | |
— | — | @@ -315,7 +315,22 @@ |
316 | 316 | class TalkHereEditPage extends EditPage { |
317 | 317 | private $code = 0; |
318 | 318 | private $sectionanchor = ''; |
| 319 | + private $returnto; |
319 | 320 | |
| 321 | + public function setReturnTo( $returnto ) { |
| 322 | + $this->returnto = $returnto; |
| 323 | + } |
| 324 | + |
| 325 | + public function getCancelLink() { |
| 326 | + global $wgUser; |
| 327 | + |
| 328 | + if ( $this->returnto ) { |
| 329 | + return $wgUser->getSkin()->link( $this->returnto, wfMsgExt('cancel', array( 'parseinline' ) ) ); |
| 330 | + } else { |
| 331 | + return ''; |
| 332 | + } |
| 333 | + } |
| 334 | + |
320 | 335 | public function internalAttemptSave( &$result, $bot = false ) { |
321 | 336 | $res = parent::internalAttemptSave( $result, $bot ); |
322 | 337 | $this->code = $res; |