User:Robchurch/Integrating FCKeditor with 1.9.3

It's possible to use FCKeditor to edit MediaWiki pages which is a useful stop-gap measure until the implementation of a dedicated WYSIWYG editor. You'll still need to use wiki text for things like linking, etc. but FCKeditor doesn't care about most wiki markup, as far as I can tell.

As usual, following these instructions is done at your own risk, and I won't be responsible for death, destruction, mutilation, disembowelling, cuts, bruises, loss of job, loss of funds, loss of foreign assets, loss of marbles, loss of hair, loss of...well, you get the idea.

In true Blue Peter fashion, you will need:


 * FCKeditor : Download from http://www.fckeditor.net/download
 * MediaWiki : This integration was done against 1.9.3, although this should work for all later versions, too

You may also find sticky-backed plastic useful, but it is not essential for this particular operation.

Steps

 * 1) Install MediaWiki
 * 2) Place all FCKeditor files in /path/to/mediawiki/fckeditor
 * 3) Patch MediaWiki with the following patch

You should be done. Here's one I made earlier. Both Save buttons will work.

Patch
This patch adds the FCKeditor integration class for PHP to MediaWiki's autoloading framework, and patches the editor to render an FCKeditor control in place of the standard textbox.

Index: includes/AutoLoader.php

=
====================================================== --- includes/AutoLoader.php	(revision 22928) +++ includes/AutoLoader.php	(working copy) @@ -272,6 +272,10 @@ 		'ApiQuerySiteinfo' => 'includes/api/ApiQuerySiteinfo.php', 'ApiQueryWatchlist' => 'includes/api/ApiQueryWatchlist.php', 'ApiResult' => 'includes/api/ApiResult.php', +		+		# FCKeditor +		'FCKeditor' => 'fckeditor/fckeditor_php5.php', +		 	); 	if ( isset( $localClasses[$className] ) ) { Index: includes/EditPage.php

=
====================================================== --- includes/EditPage.php	(revision 22928) +++ includes/EditPage.php	(working copy) @@ -1195,6 +1195,12 @@ 			? "" 			: "\n"; +	# Prepare FCKeditor +	$fckeditor = new FCKeditor( 'wpTextbox1' ); +	$fckeditor->BasePath = $GLOBALS['wgScriptPath']. '/fckeditor/'; +	$fckeditor->Value = $this->safeUnicodeOutput( $this->textbox1 ); +	$editor = $fckeditor->CreateHtml; + 		$wgOut->addHTML( << @@ -1212,18 +1218,7 @@ edittime}\" name=\"wpEdittime\" />\n scrolltop}\" name=\"wpScrolltop\" id=\"wpScrolltop\" />\n" ); -		$wgOut->addHTML( << -END -. htmlspecialchars( $this->safeUnicodeOutput( $this->textbox1 ) ) . -" - -		" ); - +		$wgOut->addHtml( $recreate . $commentsubject . $subjectpreview . $editor ); 		$wgOut->addWikiText( $copywarn ); 		$wgOut->addHTML( $this->editFormTextAfterWarn ); 		$wgOut->addHTML( " Index: includes/Sanitizer.php

=
====================================================== --- includes/Sanitizer.php	(revision 22928) +++ includes/Sanitizer.php	(working copy) @@ -342,13 +342,13 @@ 					'h2', 'h3', 'h4', 'h5', 'h6', 'cite', 'code', 'em', 's', 'strike', 'strong', 'tt', 'var', 'div', 'center', 'blockquote', 'ol', 'ul', 'dl', 'table', 'caption', 'pre', -					'ruby', 'rt', 'rb' , 'rp', 'p', 'span', 'u' +					'ruby', 'rt' , 'rb' , 'rp', 'p', 'span', 'u', 'tbody', 'a', ); 				$htmlsingle = array( -					'br', 'hr', 'li', 'dt', 'dd' +					'br', 'hr', 'li', 'dt', 'dd', 'img', ); 				$htmlsingleonly = array( # Elements that cannot have close tags -					'br', 'hr' +					'br', 'hr', 'img', ); 				$htmlnest = array( # Tags that can be nested--?? 'table', 'tr', 'td', 'th', 'div', 'blockquote', 'ol', 'ul', @@ -1141,6 +1141,15 @@ 			# 11.2.6 			'td'        => array_merge( $common, $tablecell, $tablealign ), 'th'        => array_merge( $common, $tablecell, $tablealign ), +			+			# 12.2 +			'a'	=> array_merge( $common, array( 'charset', 'type', 'name', 'href', +				'hreflang', 'rel', 'rev', 'accesskey', 'shape', 'coords', 'tabindex', +				'onfocus', 'onblur' ) ), +				+			# 13.2 +			'img' => array_merge( $common, array( 'src', 'alt', 'longdesc', 'name', +				'height', 'width', 'usemap', 'ismap' ) ), # 15.2.1 			'tt'        => $common,