Index: /MediaWiki/trunk/extensions/FCKeditor/FCKeditor.body.php
===================================================================
--- /MediaWiki/trunk/extensions/FCKeditor/FCKeditor.body.php	(revision 564)
+++ /MediaWiki/trunk/extensions/FCKeditor/FCKeditor.body.php	(revision 565)
@@ -106,5 +106,5 @@
             self::$messagesLoaded = true;
         }
-        
+
         return true;
     }
@@ -120,6 +120,6 @@
         global $wgFCKEditorToolbarSet;
         global $wgFCKEditorExtDir, $wgFCKEditorDir, $wgFCKEditorHeight, $wgUser;
-        global $wgStylePath, $wgStyleVersion, $wgDefaultSkin;
-        
+        global $wgStylePath, $wgStyleVersion, $wgDefaultSkin, $wgExtensionFunctions;
+
         if (!$wgUser->getOption( 'showtoolbar' ) || $wgUser->getOption( 'riched_disable' )) {
             return true;
@@ -129,25 +129,29 @@
             return true;
         }
-        
+
         $options = new FCKeditorParserOptions();
         $options->setTidy(true);
         $parser = new FCKeditorParser();
+        if (in_array("wfCite", $wgExtensionFunctions)) {
+            $parser->setHook('ref', array($parser, 'ref'));
+            $parser->setHook('references', array($parser, 'references'));
+        }
         $parser->setOutputType(OT_HTML);
         $form->textbox1 = $parser->parse($form->textbox1, $wgTitle, $options)->getText();
-                
-		$printsheet = htmlspecialchars( "$wgStylePath/common/wikiprintable.css?$wgStyleVersion" );		
-		
-		//CSS trick,  we need to get user CSS stylesheets somehow... it must be done in a different way!
-		$skin = $wgUser->getSkin();
-		$skin->loggedin = $wgUser->isLoggedIn();
-		$skin->mTitle =& $wgTitle;
-		$skin->skinname = 'monobook';
-		$skin->userpage = $wgUser->getUserPage()->getPrefixedText();
-		$skin->setupUserCss();
-		
-		preg_match_all('/@import "([^"]+)";/', $skin->usercss, $matches);
+
+        $printsheet = htmlspecialchars( "$wgStylePath/common/wikiprintable.css?$wgStyleVersion" );
+
+        //CSS trick,  we need to get user CSS stylesheets somehow... it must be done in a different way!
+        $skin = $wgUser->getSkin();
+        $skin->loggedin = $wgUser->isLoggedIn();
+        $skin->mTitle =& $wgTitle;
+        $skin->skinname = 'monobook';
+        $skin->userpage = $wgUser->getUserPage()->getPrefixedText();
+        $skin->setupUserCss();
+
+        preg_match_all('/@import "([^"]+)";/', $skin->usercss, $matches);
         $userStyles = $matches[1];
         //End of CSS trick
-        
+
         $script = <<<HEREDOC
 <script type="text/javascript" src="$wgScriptPath/$wgFCKEditorDir/fckeditor.js"></script>
@@ -168,5 +172,5 @@
 </script>';
         }
-        
+
         $script .= <<<HEREDOC
 <script type="text/javascript"> 
Index: /MediaWiki/trunk/extensions/FCKeditor/FCKeditorParser.body.php
===================================================================
--- /MediaWiki/trunk/extensions/FCKeditor/FCKeditorParser.body.php	(revision 564)
+++ /MediaWiki/trunk/extensions/FCKeditor/FCKeditorParser.body.php	(revision 565)
@@ -108,4 +108,60 @@
         return parent::strip($text, $state, $stripcomments , $dontstrip );
     }
+    /**
+	* Callback function for <ref>
+	*
+	* @param string $str Input
+	* @param array $argv Arguments
+	* @return string
+	*/
+    function ref( $str, $argv, $parser ) {
+        if (empty($argv)) {
+            $ret = "<ref>";
+        }
+        else {
+            $ret = "<ref";
+            foreach ($argv as $key=>$value) {
+                $ret .= " ".$key."=\"".$value."\"";
+            }
+            $ret .=">";
+        }
+        if (is_null($str)) {
+            $ret = substr($ret, 0, -1) . " />";
+        }
+        else {
+            $ret .= htmlspecialchars($str);
+            $ret .= "</ref>";
+        }
+        return $ret;
+    }
+    /**
+	* Callback function for <references>
+	*
+	* @param string $str Input
+	* @param array $argv Arguments
+	* @return string
+	*/
+    function references( $str, $argv, $parser ) {
+        if (empty($argv)) {
+            $ret = "<references>";
+        }
+        else {
+            $ret = "<references";
+            foreach ($argv as $key=>$value) {
+                $ret .= " ".$key."=\"".$value."\"";
+            }
+            $ret .=">";
+        }
+        if (is_null($str)) {
+            $ret = substr($ret, 0, -1) . " />";
+        }
+        else {
+            $ret .= htmlspecialchars($str);
+            $ret .= "</references>";
+        }
+
+        return $ret;
+    }
+
     /*
     function replaceVariables( $text, $args = array(), $argsOnly = false ) {
Index: /MediaWiki/trunk/extensions/FCKeditor/FCKeditorSajax.body.php
===================================================================
--- /MediaWiki/trunk/extensions/FCKeditor/FCKeditorSajax.body.php	(revision 564)
+++ /MediaWiki/trunk/extensions/FCKeditor/FCKeditorSajax.body.php	(revision 565)
@@ -25,10 +25,10 @@
     $ret = "";
     $i=0;
-    while ( ( $row = $db->fetchObject( $res ) ) && ( ++$i <= $limit ) ) {        
+    while ( ( $row = $db->fetchObject( $res ) ) && ( ++$i <= $limit ) ) {
         $ret .= $row->page_title ."\n";
     }
 
-    $term = htmlspecialchars( $term );    
-    
+    $term = htmlspecialchars( $term );
+
     return $ret;
 }
@@ -58,10 +58,10 @@
     $ret = "";
     $i=0;
-    while ( ( $row = $db->fetchObject( $res ) ) && ( ++$i <= $limit ) ) {        
+    while ( ( $row = $db->fetchObject( $res ) ) && ( ++$i <= $limit ) ) {
         $ret .= $row->page_title ."\n";
     }
 
-    $term = htmlspecialchars( $term );    
-    
+    $term = htmlspecialchars( $term );
+
     return $ret;
 }
@@ -69,12 +69,18 @@
 function wfSajaxWikiToHTML( $wiki )
 {
-        global $wgOut, $wgTitle, $wgScriptPath;
-        global $wgFCKEditorToolbarSet;
-        global $wgFCKEditorDir, $wgFCKEditorHeight, $wgUser;
-        
-        $options = new FCKeditorParserOptions();
-        $options->setTidy(true);
-        $parser = new FCKeditorParser();
-        $parser->setOutputType(OT_HTML);
-        return $parser->parse($wiki, $wgTitle, $options)->getText();
+    global $wgOut, $wgTitle, $wgScriptPath;
+    global $wgFCKEditorToolbarSet;
+    global $wgFCKEditorDir, $wgFCKEditorHeight, $wgUser, $wgParser, $wgExtensionFunctions;
+
+    $options = new FCKeditorParserOptions();
+    $options->setTidy(true);
+    $parser = new FCKeditorParser();
+
+    if (in_array("wfCite", $wgExtensionFunctions)) {
+        $parser->setHook('ref', array($parser, 'ref'));
+        $parser->setHook('references', array($parser, 'references'));
+    }
+    $parser->setOutputType(OT_HTML);
+
+    return $parser->parse($wiki, $wgTitle, $options)->getText();
 }
