Index: /MediaWiki/trunk/extensions/FCKeditor/fckeditor_config.js
===================================================================
--- /MediaWiki/trunk/extensions/FCKeditor/fckeditor_config.js	(revision 584)
+++ /MediaWiki/trunk/extensions/FCKeditor/fckeditor_config.js	(revision 585)
@@ -13,5 +13,5 @@
 	['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
 	['SpecialChar','Table','Image','Rule'],
-	['MW_Template', 'MW_Ref'],
+	['MW_Template','MW_Ref','MW_Math'],
 	'/',
 	['FontFormat'],
Index: /MediaWiki/trunk/extensions/FCKeditor/plugins/mediawiki/dialogs/math.html
===================================================================
--- /MediaWiki/trunk/extensions/FCKeditor/plugins/mediawiki/dialogs/math.html	(revision 585)
+++ /MediaWiki/trunk/extensions/FCKeditor/plugins/mediawiki/dialogs/math.html	(revision 585)
@@ -0,0 +1,127 @@
+﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<!--
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2007 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ *  - GNU General Public License Version 2 or later (the "GPL")
+ *    http://www.gnu.org/licenses/gpl.html
+ *
+ *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ *    http://www.gnu.org/licenses/lgpl.html
+ *
+ *  - Mozilla Public License Version 1.1 or later (the "MPL")
+ *    http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ *
+ * Link dialog window.
+-->
+<html>
+<head>
+	<title>Formula Editor</title>
+	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+	<meta name="robots" content="noindex, nofollow" />
+	<script type="text/javascript">
+
+var oEditor		= window.parent.InnerDialogLoaded() ;
+var FCK			= oEditor.FCK ;
+var FCKLang		= oEditor.FCKLang ;
+var FCKConfig	= oEditor.FCKConfig ;
+var FCKRegexLib	= oEditor.FCKRegexLib ;
+var FCKTools	= oEditor.FCKTools ;
+
+document.write( '<script src="' + FCKConfig.BasePath + 'dialog/common/fck_dialog_common.js" type="text/javascript"><\/script>' ) ;
+
+	</script>
+	<script type="text/javascript">
+
+// Get the selected flash embed (if available).
+var oMathImage = FCK.Selection.GetSelectedElement() ;
+
+if ( oMathImage )
+{
+	if ( oMathImage.tagName != 'IMG' || !oMathImage.getAttribute('_fck_mw_math') )
+		oMathImage = null ;
+}
+
+window.onload = function()
+{
+	// Translate the dialog box texts.
+	oEditor.FCKLanguageManager.TranslatePage(document) ;
+
+	// Load the selected link information (if any).
+	LoadSelection() ;
+
+	// Activate the "OK" button.
+	window.parent.SetOkButton( true ) ;
+	window.parent.SetAutoSize( true ) ;
+}
+
+function LoadSelection()
+{
+	if ( !oMathImage ) return ;
+
+	GetE('xTemplateRaw').value = oMathImage.getAttribute( '_fck_mw_math' ) ;
+}
+
+//#### The OK button was hit.
+function Ok()
+{
+	var formula = GetE('xTemplateRaw').value.Trim() ;
+	
+	if ( formula.length == 0 )
+	{
+		alert( 'Please type the formula' ) ;
+		return false ;
+	}
+
+	window.parent.document.getElementById( 'btnOk' ).disabled = true ;
+	window.parent.document.getElementById( 'btnCancel' ).disabled = true ;
+
+	oEditor.window.parent.sajax_request_type = 'GET' ;
+	oEditor.window.parent.sajax_do_call( 'wfSajaxGetMathUrl', [formula], UpdateImageFromAjax ) ;
+	
+	return false ;
+}
+
+function UpdateImageFromAjax( response )
+{
+	if ( !oMathImage )
+		oMathImage = FCK.CreateElement( 'IMG' ) ;
+	else
+		oEditor.FCKUndo.SaveUndoStep() ;
+	
+	SetAttribute( oMathImage, "_fck_mw_math", GetE('xTemplateRaw').value.Trim() ) ;
+
+	oMathImage.src = response.responseText ;
+	SetAttribute( oMathImage, "_fcksavedurl", response.responseText ) ;
+
+	// Call it using setTimeout to avoid a strange behavior in Firefox.
+	window.setTimeout( window.parent.Cancel, 0 ) ;
+}
+
+	</script>
+</head>
+<body style="overflow: hidden">
+	<div id="divInfo">
+		<table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">
+			<tr>
+				<td>
+					<span>Formula (TeX markup)</span>
+				</td>
+			</tr>
+			<tr>
+				<td height="100%">
+					<textarea id="xTemplateRaw" style="width: 100%; height: 100%; font-family: Monospace"
+						cols="50" rows="10" wrap="off"></textarea>
+				</td>
+			</tr>
+		</table>
+	</div>
+</body>
+</html>
Index: /MediaWiki/trunk/extensions/FCKeditor/plugins/mediawiki/fckplugin.js
===================================================================
--- /MediaWiki/trunk/extensions/FCKeditor/plugins/mediawiki/fckplugin.js	(revision 584)
+++ /MediaWiki/trunk/extensions/FCKeditor/plugins/mediawiki/fckplugin.js	(revision 585)
@@ -41,7 +41,12 @@
 FCKToolbarItems.RegisterItem( 'MW_Ref', tbButton ) ;
 
+tbButton = new FCKToolbarButton( 'MW_Math', 'Formula', 'Insert/Edit Formula' ) ;
+tbButton.IconPath = FCKConfig.PluginsPath + 'mediawiki/images/tb_icon_math.gif' ;
+FCKToolbarItems.RegisterItem( 'MW_Math', tbButton ) ;
+
 // Override some dialogs.
 FCKCommands.RegisterCommand( 'MW_Template', new FCKDialogCommand( 'MW_Template', 'Template Properties', FCKConfig.PluginsPath + 'mediawiki/dialogs/template.html', 400, 330 ) ) ;
 FCKCommands.RegisterCommand( 'MW_Ref', new FCKDialogCommand( 'MW_Ref', 'Reference Properties', FCKConfig.PluginsPath + 'mediawiki/dialogs/ref.html', 400, 250 ) ) ;
+FCKCommands.RegisterCommand( 'MW_Math', new FCKDialogCommand( 'MW_Math', 'Formula', FCKConfig.PluginsPath + 'mediawiki/dialogs/math.html', 400, 300 ) ) ;
 FCKCommands.RegisterCommand( 'Link', new FCKDialogCommand( 'Link', FCKLang.DlgLnkWindowTitle, FCKConfig.PluginsPath + 'mediawiki/dialogs/link.html', 400, 250 ) ) ;
 FCKCommands.RegisterCommand( 'Image', new FCKDialogCommand( 'Image', FCKLang.DlgImgTitle, FCKConfig.PluginsPath + 'mediawiki/dialogs/image.html', 450, 300 ) ) ;
@@ -293,5 +298,13 @@
 						case 'img' :
 
-							// <img alt="Blue Flower Image" _fck_mw_type="frame" _fck_mw_width="150" _fck_mw_filename="Blue Flower.jpg" _fcksavedurl="/images/b/b3/Blue_Flower.jpg" src="/images/b/b3/Blue_Flower.jpg"/>
+							var formula = htmlNode.getAttribute( '_fck_mw_math' ) ;
+							
+							if ( formula && formula.length > 0 )
+							{
+								stringBuilder.push( '<math>' ) ;
+								stringBuilder.push( formula ) ;
+								stringBuilder.push( '</math>' ) ;
+								return ;
+							}
 
 							var imgName		= htmlNode.getAttribute( '_fck_mw_filename' ) ;
