Ticket #2266: FCKed.patch
File FCKed.patch, 17.1 KB (added by , 15 years ago) |
---|
-
FCKeditor.body.php
1 1 <?php 2 2 3 class FCKeditor_MediaWiki 4 { 3 class FCKeditor_MediaWiki { 5 4 private $count = array(); 6 5 private $wgFCKBypassText = ""; 7 6 private $debug = 0; … … 28 27 29 28 static $messagesLoaded = false; 30 29 31 function __call($m,$a) 32 { 30 function __call($m, $a) { 33 31 print "\n#### " . $m . "\n"; 34 32 if (!isset($this->count[$m])) { 35 33 $this->count[$m] = 0; … … 38 36 return true; 39 37 } 40 38 41 function onMonoBookTemplateToolboxEnd() 42 { 39 function onMonoBookTemplateToolboxEnd() { 43 40 if ($this->debug) { 44 41 print_r($this->count); 45 42 } 46 43 } 47 44 48 private function getExcludedNamespaces() 49 { 45 private function getExcludedNamespaces() { 50 46 global $wgUser; 51 47 52 48 if ( is_null( $this->excludedNamespaces ) ) { … … 61 57 return $this->excludedNamespaces; 62 58 } 63 59 64 public function onLanguageGetMagic(&$magicWords, $langCode) 65 { 60 public function onLanguageGetMagic(&$magicWords, $langCode) { 66 61 $magicWords['NORICHEDITOR'] = array( 0, '__NORICHEDITOR__' ); 67 62 68 63 return true; 69 64 } 70 65 71 public function onParserBeforeInternalParse(&$parser, &$text, &$strip_state) 72 { 66 public function onParserBeforeInternalParse(&$parser, &$text, &$strip_state) { 73 67 MagicWord::get( 'NORICHEDITOR' )->matchAndRemove( $text ); 74 68 75 69 return true; 76 70 } 77 71 78 public function onEditPageShowEditFormFields($pageEditor, $wgOut) 79 { 72 public function onEditPageShowEditFormFields($pageEditor, $wgOut) { 80 73 global $wgUser, $wgFCKEditorIsCompatible, $wgTitle, $wgVersion; 81 74 82 75 /* … … 110 103 return true; 111 104 } 112 105 113 public function onEditPageBeforeConflictDiff($pageEditor, $wgOut) 114 { 106 public function onEditPageBeforeConflictDiff($pageEditor, $wgOut) { 115 107 global $fckPageEditor, $wgRequest; 116 108 117 109 /* … … 124 116 return true; 125 117 } 126 118 127 public function onSanitizerAfterFixTagAttributes($text, $element, &$attribs) 128 { 119 public function onSanitizerAfterFixTagAttributes($text, $element, &$attribs) { 129 120 $text = preg_match_all("/Fckmw\d+fckmw/", $text, $matches); 130 121 131 122 if (!empty($matches[0][0])) { … … 180 171 } 181 172 } 182 173 183 public function onCustomEditor(&$article, &$user) 184 { 174 public function onCustomEditor(&$article, &$user) { 185 175 global $wgRequest, $mediaWiki; 186 176 187 177 $action = $mediaWiki->getVal('Action'); … … 203 193 return false; 204 194 } 205 195 206 public function onEditPageBeforePreviewText(&$editPage, $previewOnOpen) 207 { 196 public function onEditPageBeforePreviewText(&$editPage, $previewOnOpen) { 208 197 global $wgUser, $wgRequest; 209 198 210 199 if ($wgUser->getOption( 'showtoolbar' ) && !$wgUser->getOption( 'riched_disable' ) && !$previewOnOpen ) { … … 215 204 return true; 216 205 } 217 206 218 public function onEditPagePreviewTextEnd(&$editPage, $previewOnOpen) 219 { 207 public function onEditPagePreviewTextEnd(&$editPage, $previewOnOpen) { 220 208 global $wgUser; 221 209 222 210 if ($wgUser->getOption( 'showtoolbar' ) && !$wgUser->getOption( 'riched_disable' ) && !$previewOnOpen ) { … … 226 214 return true; 227 215 } 228 216 229 public function onParserAfterTidy(&$parser, &$text) 230 { 217 public function onParserAfterTidy(&$parser, &$text) { 231 218 global $wgUseTeX, $wgUser, $wgTitle, $wgFCKEditorIsCompatible; 232 219 233 220 if (!$wgUser->getOption( 'showtoolbar' ) || $wgUser->getOption( 'riched_disable' ) || !$wgFCKEditorIsCompatible) { … … 247 234 return true; 248 235 } 249 236 250 public function onMessagesPreLoad() 251 { 237 public function onMessagesPreLoad() { 252 238 global $wgMessageCache, $wgUser, $wgContLanguageCode; 253 239 254 240 if ( !self::$messagesLoaded ) { … … 342 328 343 329 // Remove the mwSetupToolbar onload hook to avoid a JavaScript error with FF. 344 330 if ( window.removeEventListener ) 345 window.removeEventListener( 'load', mwSetupToolbar, false ) 331 window.removeEventListener( 'load', mwSetupToolbar, false ); 346 332 else if ( window.detachEvent ) 347 window.detachEvent( 'onload', mwSetupToolbar ) 333 window.detachEvent( 'onload', mwSetupToolbar ); 348 334 349 mwSetupToolbar = function() { return false ; } 335 mwSetupToolbar = function() { return false ; }; 350 336 351 function onLoadFCKeditor() 352 { 353 if ( document.getElementById('wpTextbox1') ) 354 { 355 var height = $wgFCKEditorHeight ; 337 function onLoadFCKeditor() { 338 if ( document.getElementById('wpTextbox1') ) { 339 var height = $wgFCKEditorHeight; 356 340 357 if ( height == 0 ) 358 { 341 if ( height == 0 ) { 359 342 // Get the window (inner) size. 360 var height = window.innerHeight || ( document.documentElement && document.documentElement.clientHeight ) || 550 343 var height = window.innerHeight || ( document.documentElement && document.documentElement.clientHeight ) || 550; 361 344 362 345 // Reduce the height to the offset of the toolbar. 363 var offset = document.getElementById('wikiPreview') || document.getElementById('toolbar') ; 364 while ( offset ) 365 { 366 height -= offset.offsetTop ; 367 offset = offset.offsetParent ; 346 var offset = document.getElementById('wikiPreview') || document.getElementById('toolbar'); 347 while ( offset ) { 348 height -= offset.offsetTop; 349 offset = offset.offsetParent; 368 350 } 369 351 370 352 // Add a small space to be left in the bottom. 371 height -= 20 353 height -= 20; 372 354 } 373 355 374 356 // Enforce a minimum height. 375 height = ( !height || height < 300 ) ? 300 : height 357 height = ( !height || height < 300 ) ? 300 : height; 376 358 377 359 // Create the editor instance and replace the textarea. 378 var oFCKeditor = new FCKeditor('wpTextbox1') 379 oFCKeditor.BasePath = '$wgScriptPath/$wgFCKEditorDir/' 380 oFCKeditor.Config['CustomConfigurationsPath'] = '$wgScriptPath/$wgFCKEditorExtDir/fckeditor_config.js' 381 oFCKeditor.Config['EditorAreaCSS'] = "$wgScriptPath/$wgFCKEditorExtDir/css/fckeditor.css" 382 oFCKeditor.Height = height 383 oFCKeditor.ToolbarSet = '$wgFCKEditorToolbarSet' 384 oFCKeditor.ReplaceTextarea() 360 var oFCKeditor = new FCKeditor('wpTextbox1'); 361 oFCKeditor.BasePath = '$wgScriptPath/$wgFCKEditorDir/'; 362 oFCKeditor.Config['CustomConfigurationsPath'] = '$wgScriptPath/$wgFCKEditorExtDir/fckeditor_config.js'; 363 oFCKeditor.Config['EditorAreaCSS'] = "$wgScriptPath/$wgFCKEditorExtDir/css/fckeditor.css"; 364 oFCKeditor.Height = height; 365 oFCKeditor.ToolbarSet = '$wgFCKEditorToolbarSet'; 366 oFCKeditor.ReplaceTextarea(); 385 367 386 368 // Hide the default toolbar. 387 document.getElementById('toolbar').style.cssText = 'display:none;' 369 document.getElementById('toolbar').style.cssText = 'display:none;'; 388 370 } 389 371 } 390 addOnloadHook( onLoadFCKeditor ) 372 addOnloadHook( onLoadFCKeditor ); 391 373 </script> 392 374 HEREDOC; 393 375 … … 411 393 var sajax_debug_mode = false; 412 394 var sajax_request_type = "GET"; 413 395 414 function WikiToHTML_Result(result) 415 { 396 function WikiToHTML_Result(result) { 416 397 var oEditor = FCKeditorAPI.GetInstance('wpTextbox1'); 417 398 oEditor.SetHTML(result.responseText); 418 399 } 419 function WikiToHTML_Call() 420 { 400 function WikiToHTML_Call() { 421 401 var oEditor = FCKeditorAPI.GetInstance('wpTextbox1'); 422 402 sajax_do_call('wfSajaxWikiToHTML', [oEditor.GetHTML()], WikiToHTML_Result); 423 403 } … … 437 417 $extraToggles = array_merge($extraToggles, self::$nsToggles); 438 418 return true; 439 419 } 440 } 420 } 421 No newline at end of file -
FCKeditor.php
3 3 # Not a valid entry point, skip unless MEDIAWIKI is defined 4 4 if (!defined('MEDIAWIKI')) { 5 5 echo <<<HEREDOC 6 To install my extension, put the following line in LocalSettings.php:6 To install FCKeditor, put the following line in LocalSettings.php: 7 7 require_once( "\$IP/extensions/FCKeditor/FCKeditor.php" ); 8 8 HEREDOC; 9 9 exit( 1 ); … … 30 30 require_once $IP . "/includes/EditPage.php"; 31 31 32 32 if (version_compare("1.12", $wgVersion, "<")) { 33 require_once $IP . "/includes/Parser_OldPP.php"; 34 require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "mw12/FCKeditorParser_OldPP.body.php"; 33 require_once $IP . "/includes/Parser_OldPP.php"; 34 require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "mw12/FCKeditorParser_OldPP.body.php"; 35 } else { 36 require_once $IP . "/includes/Parser.php"; 37 require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "FCKeditorParser.body.php"; 35 38 } 36 else {37 require_once $IP . "/includes/Parser.php";38 require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "FCKeditorParser.body.php";39 }40 39 41 40 require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "FCKeditorSajax.body.php"; 42 41 require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "FCKeditorParserOptions.body.php"; … … 46 45 require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "fckeditor" . DIRECTORY_SEPARATOR . "fckeditor.php"; 47 46 48 47 if (empty ($wgFCKEditorExtDir)) { 49 $wgFCKEditorExtDir = "extensions/FCKeditor";48 $wgFCKEditorExtDir = "extensions/FCKeditor"; 50 49 } 51 50 if (empty ($wgFCKEditorDir)) { 52 $wgFCKEditorDir = "extensions/FCKeditor/fckeditor";51 $wgFCKEditorDir = "extensions/FCKeditor/fckeditor"; 53 52 } 54 53 if (empty ($wgFCKEditorToolbarSet)) { 55 $wgFCKEditorToolbarSet = "Wiki";54 $wgFCKEditorToolbarSet = "Wiki"; 56 55 } 57 56 if (empty ($wgFCKEditorHeight)) { 58 $wgFCKEditorHeight = "0"; // "0" for automatic ("300" minimum).57 $wgFCKEditorHeight = "0"; // "0" for automatic ("300" minimum). 59 58 } 60 59 61 60 /** … … 71 70 $wgAjaxExportList[] = 'wfSajaxSearchSpecialTagFCKeditor'; 72 71 73 72 $wgExtensionCredits['other'][] = array( 74 "name" => "FCKeditor extension",75 "author" => "FCKeditor.net (inspired by the code written by Mafs [Meta])",76 "version"=> 'fckeditor/mw-extension $Rev$ 2008',77 "url" => "http://meta.wikimedia.org/wiki/FCKeditor",78 "description" => "FCKeditor extension" 73 'name' => 'FCKeditor', 74 'author' => array('FCKeditor.net', 'Wikia'), 75 'version' => 'fckeditor/mw-extension $Rev$ 2008', 76 'url' => 'http://www.mediawiki.org/wiki/Extension:FCKeditor_%28by_FCKeditor_and_Wikia%29', 77 'description' => 'FCKeditor (WYSIWYG editor) for editing wiki pages' 79 78 ); 80 79 81 80 $fckeditor = new FCKeditor("fake"); 82 81 $wgFCKEditorIsCompatible = $fckeditor->IsCompatible(); 83 82 84 83 $oFCKeditorExtension = new FCKeditor_MediaWiki(); 85 $oFCKeditorExtension->registerHooks(); 86 87 88 89 90 91 92 93 84 $oFCKeditorExtension->registerHooks(); 85 No newline at end of file -
FCKeditorEditPage.body.php
1 1 <?php 2 2 3 class FCKeditorEditPage extends EditPage 4 { 3 class FCKeditorEditPage extends EditPage { 5 4 /** 6 5 * Should we show a preview when the edit form is first shown? 7 6 * … … 75 74 $this->textbox1 = $_textbox1; 76 75 } 77 76 } 78 } 77 } 78 No newline at end of file -
FCKeditorParser.body.php
1 1 <?php 2 2 3 class FCKeditorParser extends Parser 4 { 3 class FCKeditorParser extends Parser { 5 4 public static $fkc_mw_makeImage_options; 6 5 protected $fck_mw_strtr_span; 7 6 protected $fck_mw_strtr_span_counter=1; -
FCKeditorParserOptions.body.php
1 1 <?php 2 2 3 class FCKeditorParserOptions extends ParserOptions 4 { 5 function getNumberHeadings() {return false;} 6 function getEditSection() {return false;} 3 class FCKeditorParserOptions extends ParserOptions { 4 function getNumberHeadings() { return false; } 5 function getEditSection() { return false; } 7 6 8 7 function getSkin() { 9 8 if ( !isset( $this->mSkin ) ) { -
FCKeditorSajax.body.php
1 1 <?php 2 2 3 function wfSajaxGetMathUrl( $term ) 4 { 3 function wfSajaxGetMathUrl( $term ) { 5 4 $originalLink = MathRenderer::renderMath( $term ); 6 5 7 6 if (false == strpos($originalLink, "src=\"")) { … … 14 13 return $url; 15 14 } 16 15 17 function wfSajaxGetImageUrl( $term ) 18 { 16 function wfSajaxGetImageUrl( $term ) { 19 17 global $wgExtensionFunctions, $wgTitle; 20 18 21 19 $options = new FCKeditorParserOptions(); … … 38 36 return $url; 39 37 } 40 38 41 function wfSajaxSearchSpecialTagFCKeditor($empty) 42 { 39 function wfSajaxSearchSpecialTagFCKeditor($empty) { 43 40 global $wgParser; 44 41 45 42 $ret = "nowiki\nincludeonly\nonlyinclude\nnoinclude\ngallery\n"; … … 51 48 return $ret; 52 49 } 53 50 54 function wfSajaxSearchImageFCKeditor( $term ) 55 { 51 function wfSajaxSearchImageFCKeditor( $term ) { 56 52 global $wgContLang, $wgOut; 57 53 $limit = 10; 58 54 … … 65 61 if ( strlen( str_replace( '_', '', $term ) )<3 ) 66 62 return ""; 67 63 68 $db = &wfGetDB( DB_SLAVE );64 $db = wfGetDB( DB_SLAVE ); 69 65 $res = $db->select( 'page', 'page_title', 70 66 array( 'page_namespace' => NS_IMAGE, 71 67 "LOWER(page_title) LIKE '%". $db->strencode( $term2 ) ."%'" ), … … 74 70 ); 75 71 76 72 $ret = ""; 77 $i =0;73 $i = 0; 78 74 while ( ( $row = $db->fetchObject( $res ) ) && ( ++$i <= $limit ) ) { 79 75 $ret .= $row->page_title ."\n"; 80 76 } … … 84 80 return $ret; 85 81 } 86 82 87 function wfSajaxSearchArticleFCKeditor( $term ) 88 { 83 function wfSajaxSearchArticleFCKeditor( $term ) { 89 84 global $wgContLang, $wgOut; 90 85 $limit = 10; 91 86 $ns = NS_MAIN; … … 112 107 return ""; 113 108 } 114 109 115 $db = &wfGetDB( DB_SLAVE );110 $db = wfGetDB( DB_SLAVE ); 116 111 $res = $db->select( 'page', 'page_title', 117 112 array( 'page_namespace' => $ns, 118 113 "LOWER(page_title) LIKE '%". $db->strencode( $term2 ) ."%'" ), … … 121 116 ); 122 117 123 118 $ret = ""; 124 $i =0;119 $i = 0; 125 120 while ( ( $row = $db->fetchObject( $res ) ) && ( ++$i <= $limit ) ) { 126 121 if (isset($prefix) && !is_null($prefix)) { 127 122 $ret .= $prefix; … … 134 129 return $ret; 135 130 } 136 131 137 function wfSajaxSearchTemplateFCKeditor($empty) 138 { 132 function wfSajaxSearchTemplateFCKeditor($empty) { 139 133 global $wgContLang, $wgOut; 140 134 $ns = NS_TEMPLATE; 141 135 142 $db = &wfGetDB( DB_SLAVE );136 $db = wfGetDB( DB_SLAVE ); 143 137 $res = $db->select( 'page', 'page_title', 144 array( 138 array( 'page_namespace' => $ns), 145 139 "wfSajaxSearch" 146 140 ); 147 141 … … 153 147 return $ret; 154 148 } 155 149 156 function wfSajaxWikiToHTML( $wiki ) 157 { 150 function wfSajaxWikiToHTML( $wiki ) { 158 151 global $wgTitle; 159 152 160 153 $options = new FCKeditorParserOptions(); … … 163 156 $parser->setOutputType(OT_HTML); 164 157 165 158 return $parser->parse($wiki, $wgTitle, $options)->getText(); 166 } 159 } 160 No newline at end of file -
FCKeditorSkin.body.php
1 1 <?php 2 2 3 class FCKeditorSkin 4 { 3 class FCKeditorSkin { 5 4 private $skin; 6 5 7 6 /** … … 19 18 * @return string * 20 19 */ 21 20 function makeImageLinkObj( $nt, $label, $alt, $align = '', $params = array(), $framed = false, 22 $thumb = false, $manual_thumb = '', $valign = '' ) 23 { 21 $thumb = false, $manual_thumb = '', $valign = '' ) { 24 22 $orginal = $nt->getText(); 25 23 $img = new Image( $nt ); 26 24 $imgName = $img->getName(); … … 37 35 38 36 if ($found) { 39 37 $ret .= "src=\"{$url}\" "; 40 } 41 else { 38 } else { 42 39 $ret .= "_fck_mw_valid=\"false"."\" "; 43 40 } 44 41 $ret .= "_fck_mw_filename=\"{$orginal}\" "; … … 83 80 84 81 if (!is_null($alt) && !empty($alt) && false !== strpos(FCKeditorParser::$fkc_mw_makeImage_options, $alt) && $alt != "Image:" . $orginal) { 85 82 $ret .= "alt=\"".htmlspecialchars($alt)."\" "; 86 } 87 else { 83 } else { 88 84 $ret .= "alt=\"\" "; 89 85 } 90 86 … … 151 147 152 148 if ($found) { 153 149 $ret .= "src=\"{$url}\" "; 154 } 155 else { 150 } else { 156 151 $ret .= "_fck_mw_valid=\"false"."\" "; 157 152 } 158 153 $ret .= "_fck_mw_filename=\"{$orginal}\" "; … … 201 196 202 197 if (isset($fp['alt']) && !empty($fp['alt']) && false !== strpos(FCKeditorParser::$fkc_mw_makeImage_options, $fp['alt']) && $fp['alt'] != "Image:" . $orginal) { 203 198 $ret .= "alt=\"".htmlspecialchars($fp['alt'])."\" "; 204 } 205 else { 199 } else { 206 200 $ret .= "alt=\"\" "; 207 201 } 208 202 … … 215 209 return $ret; 216 210 } 217 211 218 function makeKnownLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '', $style = '' ) 219 { 212 function makeKnownLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '', $style = '' ) { 220 213 $fname = 'FCKeditorSkin::makeKnownLinkObj'; 221 214 wfProfileIn( $fname ); 222 215 … … 257 250 return $r; 258 251 } 259 252 260 function makeBrokenLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) 261 { 253 function makeBrokenLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { 262 254 # Fail gracefully 263 255 if ( ! isset($nt) ) { 264 256 # throw new MWException(); … … 311 303 $url = $upload->getLocalUrl( 'wpDestFile=' . urlencode( $title->getDbKey() ) ); 312 304 $class = 'new'; 313 305 } 314 } 315 // Mediawiki 1.10 316 else { 306 } else { // MediaWiki 1.10 317 307 $img = new Image( $title ); 318 308 if( $img->exists() ) { 319 309 $url = $img->getURL(); … … 344 334 return '<a href="'.$url.'">'.$text.'</a>'; 345 335 } 346 336 347 function __call( $m, $a) 348 { 337 function __call( $m, $a) { 349 338 return call_user_func_array( array( $this->skin, $m ), $a ); 350 339 } 351 340 352 function __construct( &$skin ) 353 { 341 function __construct( &$skin ) { 354 342 $this->skin = $skin; 355 343 } 356 344 }