Index: /MediaWiki/trunk/extensions/FCKeditor/plugins/mediawiki/fck_link.html
===================================================================
--- /MediaWiki/trunk/extensions/FCKeditor/plugins/mediawiki/fck_link.html	(revision 532)
+++ /MediaWiki/trunk/extensions/FCKeditor/plugins/mediawiki/fck_link.html	(revision 532)
@@ -0,0 +1,231 @@
+﻿<!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>Link Properties</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">
+
+// oLink: The actual selected link in the editor.
+var oLink = FCK.Selection.MoveToAncestorNode( 'A' ) ;
+if ( oLink )
+	FCK.Selection.SelectNode( oLink ) ;
+
+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 ( !oLink ) return ;
+
+	// Get the actual Link href.
+	var sHRef = oLink.getAttribute( '_fcksavedurl' ) ;
+	if ( sHRef == null )
+		sHRef = oLink.getAttribute( 'href' , 2 ) || '' ;
+
+	GetE('txtUrl').value = sHRef ;
+}
+
+var searchTimer ;
+
+//#### Called while the user types the URL.
+function OnUrlChange()
+{
+	var link = GetE('txtUrl').value.Trim() ;
+
+	if ( searchTimer )
+		window.clearTimeout( searchTimer ) ;
+		
+	if ( link.StartsWith( '#' ) )
+	{
+		SetSearchMessage( 'anchor link... no search for it' ) ;
+		return ;
+	} 
+	
+	if ( link.StartsWith( 'mailto:' ) )
+	{
+		SetSearchMessage( 'e-mail link... no search for it' ) ;
+		return ;
+	} 
+	
+	if( /^\w+:\/\//.test( link ) )
+	{
+		SetSearchMessage( 'external link... no search for it' ) ;
+		return ;
+	}
+
+	if ( link.length < 3  )
+	{
+		ClearSearch() ;
+
+		if ( link.length == 0 )
+			SetSearchMessage( 'start typing in the above field' ) ;
+		else
+			SetSearchMessage( 'too short... type more' ) ;
+		return ;
+	}
+	
+	SetSearchMessage( 'stop typing to search' ) ;
+	searchTimer = window.setTimeout( StartSearch, 500 ) ;
+}
+
+function StartSearch()
+{
+	var link = GetE('txtUrl').value.Trim() ;
+
+	if ( link.length < 3  )
+		return ;
+
+	SetSearchMessage( 'searching...' ) ;
+
+	// Make an Ajax search for the pages.
+	oEditor.window.parent.sajax_request_type = 'GET' ;
+	oEditor.window.parent.sajax_do_call( 'wfSajaxSearchArticleFCKeditor', [link], LoadSearchResults ) ;
+}
+
+function LoadSearchResults( result )
+{
+	var results = result.responseText.Trim().split( '\n' ) ;
+	var select = GetE( 'xWikiResults' ) ;
+	
+	ClearSearch() ;
+
+	if ( results.length == 0 || ( results.length == 1 && results[0].length == 0 ) )
+	{
+		SetSearchMessage( 'no articles found' ) ;
+	}
+	else
+	{
+		if ( results.length == 1 )
+			SetSearchMessage( 'one article found' ) ;
+		else
+			SetSearchMessage( results.length + ' articles found' ) ;
+
+		for ( var i = 0 ; i < results.length ; i++ )
+			FCKTools.AddSelectOption( select, results[i], results[i] ) ;
+	}
+}
+
+function ClearSearch()
+{
+	var select = GetE( 'xWikiResults' ) ;
+
+	while ( select.options.length > 0 )
+		select.remove( 0 ) 
+}
+
+function SetSearchMessage( message )
+{
+	GetE('xWikiSearchStatus').innerHTML = message ;
+}
+
+function SetUrl( url )
+{
+	GetE('txtUrl').value = url ;
+}
+
+//#### The OK button was hit.
+function Ok()
+{
+	var sUri = GetE('txtUrl').value ;
+	var sInnerHtml ;
+
+	// If no link is selected, create a new one (it may result in more than one link creation - #220).
+	var aLinks = oLink ? [ oLink ] : oEditor.FCK.CreateLink( sUri ) ;
+
+	// If no selection, no links are created, so use the uri as the link text (by dom, 2006-05-26)
+	var aHasSelection = ( aLinks.length > 0 ) ;
+	if ( !aHasSelection )
+	{
+		sInnerHtml = sUri;
+
+		var oLinkPathRegEx = new RegExp("//?([^?\"']+)([?].*)?$") ;
+		var asLinkPath = oLinkPathRegEx.exec( sUri ) ;
+		if (asLinkPath != null)
+			sInnerHtml = asLinkPath[1];  // use matched path
+		
+		// Create a new (empty) anchor.
+		aLinks = [ oEditor.FCK.InsertElement( 'a' ) ] ;
+	}
+
+	oEditor.FCKUndo.SaveUndoStep() ;
+
+	for ( var i = 0 ; i < aLinks.length ; i++ )
+	{
+		oLink = aLinks[i] ;
+
+		if ( aHasSelection )
+			sInnerHtml = oLink.innerHTML ;		// Save the innerHTML (IE changes it if it is like an URL).
+
+		oLink.href = sUri ;
+		SetAttribute( oLink, '_fcksavedurl', sUri ) ;
+
+		oLink.innerHTML = sInnerHtml ;		// Set (or restore) the innerHTML
+
+	}
+
+	// Select the (first) link.
+	oEditor.FCKSelection.SelectNode( aLinks[0] );
+
+	return true ;
+}
+
+	</script>
+</head>
+<body scroll="no" style="overflow: hidden">
+	<div id="divInfo">
+		<div id="divLinkTypeUrl">
+			<span>Link</span><br />
+			<input id="txtUrl" style="width: 100%" type="text" onkeyup="OnUrlChange();" />
+			<br />
+			Automatic search results (<span id="xWikiSearchStatus">start typing in the above field</span>)<br />
+			<select id="xWikiResults" size="10" style="width: 100%; height:150px" onclick="SetUrl( this.value );">
+			</select>
+		</div>
+	</div>
+</body>
+</html>
Index: /MediaWiki/trunk/extensions/FCKeditor/plugins/mediawiki/fckplugin.js
===================================================================
--- /MediaWiki/trunk/extensions/FCKeditor/plugins/mediawiki/fckplugin.js	(revision 531)
+++ /MediaWiki/trunk/extensions/FCKeditor/plugins/mediawiki/fckplugin.js	(revision 532)
@@ -28,4 +28,8 @@
 // Rename the "Source" buttom to "Wikitext".
 FCKToolbarItems.RegisterItem( 'Source', new FCKToolbarButton( 'Source', 'Wikitext', null, FCK_TOOLBARITEM_ICONTEXT, true, true, 1 ) ) ;
+
+// Override some dialogs.
+FCKCommands.RegisterCommand( 'Link', new FCKDialogCommand( 'Link', FCKLang.DlgLnkWindowTitle, FCKConfig.PluginsPath + 'mediawiki/fck_link.html', 400, 330 ) ) ;
+//FCKCommands.RegisterCommand( 'Image', new FCKDialogCommand( 'Image', FCKLang.DlgImgTitle, FCKConfig.PluginsPath + 'mediawiki/fck_image.html', 450, 400 ) ) ;
 
 // MediaWiki Wikitext Data Processor implementation.
@@ -429,2 +433,4 @@
 	}
 })() ;
+
+
