Extension:TagCorrection

What can this extension do?
This extension helps to be able to use MediaWiki+FCKeditor with plugins like syntax highlighting etc. using. The extensions corrects for example &amp;lt;source lang="php"&amp;gt; to &lt;source lang="php"&gt;. So with this extension you can paste code into the WYSIWYG editor.

Changes to LocalSettings.php
add the following code to the end:

Code
Create the file TagCorrection.php in your extensions directory and put the below code into it.

<?php # TagCorrection MediaWiki Extention # Created by Johannes Perl #	# feel free to add additional tags you are using # the key of the array is the search string, the value is the replacement # $wgSimpleTagReplaces = array ('search', 'replacement') # the above code would let the hook replace the string search through the string replacement #register hook to be executed if an article is saved $wgHooks['ArticleSave'][] = 'correctTags'; #regulary expression and replacement $wgRegularyTagReplaces = array(				'/&amp;lt;source lang=\"([a-z\._0-9]{1,})\"&amp;gt;/U' => ' '); #simply char replaces $wgSimpleCharReplaces = array('&amp;quot;' => '"', '&amp;lt;' => '<', '&amp;gt;' => '>', ' ' => chr(13), 									'&amp;nbsp;' => ' ');	/**	 * replaces tags which are destroyed by the WYSIWYG editor	 */	function correctTags(&$article, &$user, &$text, &$summary, $minor, $watch, $sectionanchor, &$flags)	{				global $wgRegularyTagReplaces;		global $wgSimpleTagReplaces;		global $wgSimpleCharReplaces;		echo $text." \n\n\n\n";		foreach($wgSimpleTagReplaces as $search => $repl)			$text = str_replace($search, $repl, $text);		foreach($wgRegularyTagReplaces as $search => $repl)			$text = preg_replace($search, $repl, $text);		$ready = false;		while(!$ready)		{			$oldtext = $text;			foreach($wgSimpleCharReplaces as $search => $repl)			{				$text = preg_replace('/ ', $text);			}			if($oldtext == $text)				$ready = true;		}		return true;	} ?>

Parameter
To add more tags to be corrected by this extension, add the tagname to $wgTagnames. To have special HTML Codes replaced within a tag, add the tagname to $wgTagnamesHtmlReplace. Any other text you want to have replaced with all tags listed in $wgTagnamesHtmlReplace, have to be added in $wgHtmlCodeReplace in the form "code" => "replacement".

TODO

 * Convince FckEditor developers to built the functionality into their editor and make this extension unnecessary.
 * Add more tags.
 * Check my regulary expression if its ok.