Changeset 1929 for MediaWiki/trunk/FCKeditor.body.php
- Timestamp:
- 2008-04-16 09:25:55 (6 months ago)
- Files:
-
- 1 modified
-
MediaWiki/trunk/FCKeditor.body.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
MediaWiki/trunk/FCKeditor.body.php
r1871 r1929 75 75 return true; 76 76 } 77 78 public function onEditPageShowEditFormFields($pageEditor, $wgOut) 79 { 80 global $wgUser, $wgFCKEditorIsCompatible, $wgTitle, $wgVersion; 81 82 /* 83 If FCKeditor extension is enabled, BUT it shouldn't appear (because it's disabled by user, we have incompatible browser etc.) 84 We must do this trick to show the original text as WikiText instead of HTML when conflict occurs 85 */ 86 if ( (!$wgUser->getOption( 'showtoolbar' ) || $wgUser->getOption( 'riched_disable' ) || !$wgFCKEditorIsCompatible) || 87 in_array($wgTitle->getNamespace(), $this->getExcludedNamespaces()) || 88 false !== strpos($pageEditor->textbox1, "__NORICHEDITOR__") 89 ) { 90 if ($pageEditor->isConflict) { 91 $pageEditor->textbox1 = $pageEditor->getWikiContent(); 92 } 93 } 94 /* 95 If FCKeditor extension is enabled, and it should appear 96 We must do this trick to show HTML instead of the original text when conflict occurs 97 This hack is only needed for MW 1.11 and below 98 */ 99 else if (version_compare("1.12", $wgVersion, ">")) { 100 if ($pageEditor->isConflict) { 101 $options = new FCKeditorParserOptions(); 102 $options->setTidy(true); 103 $parser = new FCKeditorParser(); 104 $parser->setOutputType(OT_HTML); 105 $pa = $parser->parse($pageEditor->textbox1, $pageEditor->mTitle, $options); 106 $pageEditor->textbox1 = $pa->mText; 107 } 108 } 109 110 return true; 111 } 112 113 public function onEditPageBeforeConflictDiff($pageEditor, $wgOut) 114 { 115 global $fckPageEditor, $wgRequest; 116 117 /* 118 Show WikiText instead of HTML when there is a conflict 119 http://dev.fckeditor.net/ticket/1385 120 */ 121 $pageEditor->textbox2 = $wgRequest->getVal( 'wpTextbox1' ); 122 $pageEditor->textbox1 = $pageEditor->getWikiContent(); 123 124 return true; 125 } 77 126 78 127 public function registerHooks() { … … 83 132 $wgHooks['ParserAfterTidy'][] = array($this, 'onParserAfterTidy'); 84 133 $wgHooks['EditPage::showEditForm:initial'][] = array($this, 'onEditPageShowEditFormInitial'); 134 $wgHooks['EditPage::showEditForm:fields'][] = array($this, 'onEditPageShowEditFormFields'); 85 135 $wgHooks['EditPageBeforePreviewText'][] = array($this, 'onEditPageBeforePreviewText'); 86 136 $wgHooks['EditPagePreviewTextEnd'][] = array($this, 'onEditPagePreviewTextEnd'); … … 88 138 $wgHooks['LanguageGetMagic'][] = array($this, "onLanguageGetMagic"); 89 139 $wgHooks['ParserBeforeInternalParse'][] = array($this, "onParserBeforeInternalParse"); 140 $wgHooks['EditPageBeforeConflictDiff'][] = array($this, 'onEditPageBeforeConflictDiff'); 90 141 91 142 if ($this->debug) { 143 /* 144 This is just an array of all available hooks, useful for debugging and learning 145 Add here all new hooks 146 */ 92 147 $opcje = array('ArticleSave', 93 148 'ArticleInsertComplete', 'ArticleSaveComplete', 'TitleMoveComplete', 'ArticleProtect', 'ArticleProtectComplete', 'ArticleDelete', 'ArticleDeleteComplete', 'AlternateEdit', 'ArticleFromTitle', 'ArticleAfterFetchContent', … … 209 264 global $wgFCKEditorExtDir, $wgFCKEditorDir, $wgFCKEditorHeight, $wgUser; 210 265 global $wgStylePath, $wgStyleVersion, $wgDefaultSkin, $wgExtensionFunctions; 266 global $wgFCKWikiTextBeforeParse; 211 267 212 268 if (!$wgUser->getOption( 'showtoolbar' ) || $wgUser->getOption( 'riched_disable' ) || !$wgFCKEditorIsCompatible) { … … 226 282 $parser = new FCKeditorParser(); 227 283 $parser->setOutputType(OT_HTML); 284 $wgFCKWikiTextBeforeParse = $form->textbox1; 228 285 $form->textbox1 = $parser->parse($form->textbox1, $wgTitle, $options)->getText(); 229 286 … … 315 372 } 316 373 addOnloadHook( onLoadFCKeditor ) ; 374 </script> 375 HEREDOC; 317 376 318 377 /* 378 $script .= <<<HEREDOC 379 <script type="text/javascript"> 319 380 function showSource() { 320 381 var wp = document.getElementById("wpDiff"); … … 346 407 347 408 addOnloadHook(showSource); 348 */349 409 </script> 350 410 HEREDOC; 411 */ 351 412 352 413 $wgOut->addScript($script);