ソースを参照

[svn r22389] FS#2867 - The online editor, the simple file manager, the Image manager: Implementing a dialog for ceation of new folders.

Ivan Tcholakov 15 年 前
コミット
32b934fe6d

+ 33 - 1
main/inc/lib/fckeditor/editor/filemanager/browser/default/frmcreatefolder.html

@@ -29,7 +29,9 @@
 		<script type="text/javascript" src="js/common.js"></script>
 		<script type="text/javascript">
 
+var FCK = null ;
 var FCKLang = [] ;
+var FCKDialog = null ;
 
 function SetCurrentFolder( resourceType, folderPath )
 {
@@ -39,6 +41,30 @@ function SetCurrentFolder( resourceType, folderPath )
 
 function CreateFolder()
 {
+	if ( !window.parent.opener && window.parent.parent && FCK )
+	{
+		if ( FCK.Plugins.IsLoaded && FCK.Plugins.IsLoaded( 'prompt' ) )
+		{
+			FCKDialog.Prompt( FCKLang['NewFoderName'], '',
+				function( sFolderName )
+				{
+					if ( sFolderName == null )
+					{
+						return ;
+					}
+					else if ( sFolderName.length == 0 )
+					{
+						alert( FCKLang['NewFoderNameRequest'] ) ;
+						return ;
+					}
+
+					oConnector.SendCommand( 'CreateFolder', 'NewFolderName=' + encodeURIComponent( sFolderName), CreateFolderCallBack ) ;
+				},
+				FCKLang['CreateNewFolder'] ) ;
+			return ;
+		}
+	}
+
 	var sFolderName ;
 
 	while ( true )
@@ -53,7 +79,7 @@ function CreateFolder()
 			break ;
 	}
 
-	oConnector.SendCommand( 'CreateFolder', 'NewFolderName=' + encodeURIComponent( sFolderName) , CreateFolderCallBack ) ;
+	oConnector.SendCommand( 'CreateFolder', 'NewFolderName=' + encodeURIComponent( sFolderName), CreateFolderCallBack ) ;
 }
 
 function CreateFolderCallBack( fckXml )
@@ -104,6 +130,12 @@ window.onload = function()
 
 	document.getElementById('btnCreateFolder').value = FCKLang['CreateNewFolder'] ;
 
+	if ( window.parent.oEditor )
+	{
+		FCK = window.parent.oEditor.FCK ;
+		FCKDialog = window.parent.oEditor.FCKDialog ;
+	}
+
 	window.parent.IsLoadedCreateFolder = true ;
 }
 		</script>

+ 8 - 1
main/inc/lib/fckeditor/editor/plugins/ImageManager/assets/images.js

@@ -21,7 +21,14 @@
 
 	function newFolder(dir, newDir) 
 	{
-		location.href = "images.php?dir="+dir+"&newDir="+newDir;
+		if ( !window.parent.opener && window.parent.oEditor )
+		{
+			location.href = window.parent.oEditor.FCKConfig.PluginsPath + 'ImageManager/images.php?dir=' + dir + '&newDir=' + newDir ;
+		}
+		else
+		{
+			location.href = 'images.php?dir=' + dir + '&newDir=' + newDir ;
+		}
 	}
 
 	//update the dir list in the parent window.

+ 23 - 0
main/inc/lib/fckeditor/editor/plugins/ImageManager/assets/manager.js

@@ -315,6 +315,29 @@
 		var selection = document.getElementById('dirPath');
 		var dir = selection.options[selection.selectedIndex].value;
 
+		if ( !window.opener && window.parent && oEditor )
+		{
+			if ( oEditor.FCK.Plugins.IsLoaded && oEditor.FCK.Plugins.IsLoaded( 'prompt' ) )
+			{
+				oEditor.FCKDialog.Prompt( i18n( 'Folder Name:' ), '',
+					function( folder )
+					{
+						if (folder == thumbdir)
+						{
+							alert(i18n('Invalid folder name, please choose another folder name.'));
+							return false;
+						}
+
+						if (folder && folder != '' && typeof imgManager != 'undefined')
+						{
+							imgManager.newFolder(dir, encodeURI(folder));
+						}
+					},
+					i18n( 'New Folder' ) ) ;
+				return ;
+			}
+		}
+
 		Dialog("newFolder.html", function(param) 
 		{
 			if (!param) // user must have pressed Cancel

+ 68 - 0
main/inc/lib/fckeditor/editor/plugins/prompt/fck_prompt.html

@@ -0,0 +1,68 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<!--
+ *	Dokeos - elearning and course management software
+ *
+ *	Copyright (c) 2008-2009 Dokeos SPRL
+ *	Copyright (c) 2009 Ivan Tcholakov <ivantcholakov@gmail.com>
+ *
+ *	For a full list of contributors, see "credits.txt".
+ *	The full license can be read in "license.txt".
+ *
+ *	This program is free software; you can redistribute it and/or
+ *	modify it under the terms of the GNU General Public License
+ *	as published by the Free Software Foundation; either version 2
+ *	of the License, or (at your option) any later version.
+ *
+ *	See the GNU General Public License for more details.
+ *
+ * Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
+ * Mail: info@dokeos.com
+-->
+<html xmlns="http://www.w3.org/1999/xhtml">
+	<head>
+		<title></title>
+		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+		<meta name="robots" content="noindex, nofollow" />
+		<script src="../../dialog/common/fck_dialog_common.js" type="text/javascript"></script>
+		<script type="text/javascript">
+
+var dialog = window.parent ;
+var oEditor = dialog.InnerDialogLoaded() ;
+var FCK = oEditor.FCK ;
+var FCKConfig = oEditor.FCKConfig ;
+var FCKTools = oEditor.FCKTools ;
+var FCKLang = oEditor.FCKLang ;
+
+window.document.dir = FCKLang.Dir ;
+document.write( FCKTools.GetStyleHtml( GetCommonDialogCss() ) ) ;
+
+function Ok()
+{
+	if ( typeof(window.parent.Args().CustomValue.action ) == 'function' )
+	{
+		window.parent.Args().CustomValue.action( document.getElementById('inputfield').value ) ;
+	}
+
+	return true ;
+}
+
+window.onload = function()
+{
+	message = dialog.Args().CustomValue.message ;
+	default_value = dialog.Args().CustomValue.default_value ;
+	document.getElementById( 'message' ).innerHTML = message ;
+	document.getElementById( 'inputfield' ).value = default_value ;
+
+	window.parent.SetOkButton( true ) ;
+	window.parent.SetAutoSize( true ) ;
+}
+
+		</script>
+	</head>
+	<body scroll="no" style="overflow: hidden;">
+		<div style="margin-top: 30px; margin-bottom: 30px; margin-right: auto; margin-left: auto; width: 90%;" align="center">
+			<span id="message"></span><br />
+			<input id="inputfield" type="text" style="width: 100%;"/>
+		</div>
+	</body>
+</html>

+ 53 - 0
main/inc/lib/fckeditor/editor/plugins/prompt/fckplugin.js

@@ -0,0 +1,53 @@
+/*
+ *	Dokeos - elearning and course management software
+ *
+ *	Copyright (c) 2008-2009 Dokeos SPRL
+ *	Copyright (c) 2009 Ivan Tcholakov <ivantcholakov@gmail.com>
+ *
+ *	For a full list of contributors, see "credits.txt".
+ *	The full license can be read in "license.txt".
+ *
+ *	This program is free software; you can redistribute it and/or
+ *	modify it under the terms of the GNU General Public License
+ *	as published by the Free Software Foundation; either version 2
+ *	of the License, or (at your option) any later version.
+ *
+ *	See the GNU General Public License for more details.
+ *
+ * Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
+ * Mail: info@dokeos.com
+ */
+FCKDialog.Prompt = function( message, default_value, action, title, width, height )
+{
+	if ( !message )
+	{
+		message = '&nbsp;';
+	}
+
+	if ( !title )
+	{
+		title = '&nbsp;';
+	}
+
+	if ( !default_value )
+	{
+		default_value = '';
+	}
+
+	if ( !width )
+	{
+		width = 500 ;
+	}
+
+	if ( !height )
+	{
+		height = 235 ;
+	}
+
+	var custom_value = {} ;
+	custom_value.default_value = default_value
+	custom_value.action = action ;
+	custom_value.message = message ;
+	
+	FCKDialog.OpenDialog( 'FCKDialog_Prompt', title, FCKConfig.PluginsPath + 'prompt/fck_prompt.html', width, height, custom_value ) ;
+}

+ 1 - 0
main/inc/lib/fckeditor/myconfig.js

@@ -60,6 +60,7 @@ for ( var i = 0 ; i < FCKConfig.LoadPlugin.length ; i++ ) {
 		case 'dragresizetable':
 		case 'tablecommands':
 		case 'ImageManager':
+		case 'prompt':
 			FCKConfig.Plugins.Add( FCKConfig.LoadPlugin[i] ) ;
 			break ;
 		default:

+ 4 - 0
main/inc/lib/fckeditor/myconfig.php

@@ -83,6 +83,10 @@ $config['LoadPlugin'][] = 'customizations';
 $config['LoadPlugin'][] = 'dragresizetable';
 $config['LoadPlugin'][] = 'tablecommands';
 
+// prompt : This plugin is a dialog implementation as a replacemet of the javascript function prompt().
+// It provides consistent appearance and avoiding activation of browser's blocking features.
+$config['LoadPlugin'][] = 'prompt';
+
 // audio: Adds a dialog for inserting audio files (.mp3).
 $config['LoadPlugin'][] = 'audio';