本手册由zengl开源网的站长提供 首页:www.zengl.com Custom File Browser   自定义文件浏览器 在前面的章节中提到了如何使用文件浏览器,这一章介绍如何自定义文件浏览器。 To replace th...

本手册由zengl开源网的站长提供 首页:www.zengl.com

Custom File Browser   自定义文件浏览器

在前面的章节中提到了如何使用文件浏览器,这一章介绍如何自定义文件浏览器。

To replace the default image file browser with, for instance a custom image gallery, edit the fckconfig.js or your custom Configuration File and set (for example):  要替换默认的图片文件浏览器,例如自定义一个图片浏览的访问文件,只需修改配置文件,并设置 ImageBrowserURL 的路径即可,如下所示:

FCKConfig.ImageBrowserURL = '/myfilebrowserpath/browser.php' ;

这里的 ‘/myfilebrowserpath/browser.php’就是你自定义的处理文件。当我们点击'插入/编辑图像'按钮后,在弹出的图像属性对话 框中点击 “浏览服务器” 的按钮后,会弹出图像浏览器,在该浏览器的顶端的URL 地址里面的一长串地址就是 在配置文件中设置的ImageBrowserURL路径值。 像一些CMS,比如dedecms 他就去掉了fck 配置里的ImageBrowserURL ,因为他的文件浏览功能都是用自己的代码来完成的,所以他的'插入/编辑图像'按钮点开后,对话框的界面都和默认的不一样,但是这样可以和自己的程序更好 的融合在一起。

 

Function SetUrl     SetUrl 函数

When a file is selected on your custom File Browser implementation, you must simply call the "SetUrl" JavaScript function in the window.opener (the FCKeditor dialog that opened the File Browser), passing the URL of the file. 
当在你自定义的文件浏览器中选中一个文件时,你必须调用window.opener 的"SetUrl" js 脚本函数(window.opener代表打开文件浏览器的FCK对话框),以便传递文件的URL路径。

A very simple implementation (with no server side integration) could be something like this: 一个简单的实现如下(没有使用服务端的脚本程序,一个简单的静态文件):

<html>
<head>
<title>My File Browser</title>
<script type="text/javascript">
function SelectFile( fileUrl )
{
// window.opener.SetUrl( url, width, height, alt);
window.opener.SetUrl( fileUrl ) ;
window.close() ;
}
</script>
</head>
<body>
<a href="javascript:selectfile('file1.jpg');">File 1</a><br />
<a href="javascript:selectfile('file2.jpg');">File 2</a>
</body>
</html>

在上面的例子中,如果选中了 File 1 那么会通过 window.opener.SetUrl 函数设置文件的URL路径,这样在文件浏览对话框关闭后,在 "浏览服务器" 按钮的左边的源文件对应的input输入框中就会出现该文件的路径。

UploadURL  上传URL

If your custom browser handles uploading of images, flash objects or links in a radically different way you might want to remember to change the standard image,flash and links uploading tab in fckconfig.js file or in you custom Configuration File.   如果你自定义的文件浏览器使用不同的方式来处理图像,flash 或链接的上传时,要记得在配置文件里改变标准的图像,flash等的上传标签的设置。

Examples: 例如:

       ● Images 图像

FCKConfig.ImageUploadURL = '/your_file_browser_directory/upload.php'

其实这里的上传路径就是以前在内置文件浏览器中提到过的快速上传的路径,点击"插入/编辑图像" 按钮后,在打开的图像属性对话框中有个 上传标签,该上传标签就是快速上传用的,在点击里面的"发送到服务器上" 的按钮后,就会将图像文件交给 ImageUploadURL 中设置的文件去处理。

       ● Flash objects   flash 对象

FCKConfig.FlashUploadURL = '/your_file_browser_directory/upload.php'

       ● Links  超链接

FCKConfig.LinkUploadURL = '/your_file_browser_directory/upload.php'


NOTE: For all the information about the functions written in the example view: ImageUploadURL  , FlashUploadURL  and LinkUploadURL configuration options.   注意:有关上面提到的各个配置选项的作用和用法等信息可以查看下面的链接:

ImageUploadURL

  ,

FlashUploadURL

  以及

LinkUploadURL

如果本文有翻译不周的地方,或有其他方面的评论,可以到下方发表评论。

上下篇

下一篇: FCKeditor的调试

上一篇: FCKeditor的皮肤设置

相关文章

FCKeditor的开发精简

FCKeditor的拼写检查器

FCKeditor中文使用手册前言

PHP脚本加载fckeditor编辑器

FCKeditor的调试

JavaScript脚本加载fckeditor编辑器