FCKeditor的服务端开发

Server Side Integration  服务端集成

This document offers some guidelines that must be considered when developing server side integration for FCKeditor (alias Server Side Integration Pack). There are a few points of integration that every server side technology should have to be completely ready for FCKeditor. These are the main features:
该文档提供了当开发服务端集成FCKeditor的时候要遵循的准则(也就是开发服务端集成包的时候)。下面是每个服务端技术要考虑的要点:

This document will present the basic (minimum) features the integration must accomplish to. Any other feature is a welcome surplus. The scope of this document is to provide a generic pattern in the way the editor can have a homogeneous programming style even when being used from different languages.
这个文档将描述集成语言所要完成的基本功能。任何其他的功能都是次要。这篇文档主要提供使用不同语言来加载编辑器时的通用编程模式。

FCKeditor Creator  FCKeditor的创造器

This is the main integration feature needed. It makes it possible to create an instance of FCKeditor in a page using the desired server side language. Object oriented programming (OOP) should be used wherever is possible. The Integration Pack should offer this functionality to the end user programmer:
这是所需的最主要的功能。这样才能使用所需的编程语言在页面中创造一个FCKeditor的实例,尽可能的使用面向对象技术,服务端的集成开发包需要给终端编程者提供下面的功能:

  • Editor Instance Creation   可以通过构造器的形式来创建编辑器的实例。
  • Configuration and Settings   可以方便的对编辑器进行配置。
  • Automatic Browser Compatibility Detection:   自动检测浏览器的兼容性:
    • Output HTML of the editor IFRAME for compatible browsers.    对于兼容的浏览器则输出编辑器的IFRAME 框架的HTML 代码。
    • Output HTML of a simple TEXTAREA for not compatible browsers.  对于不兼容的浏览器则输出一个简单的TEXTAREA文本域的HTML代码。

Suppose the editor instance is called "MyEditor". For compatible browsers the Integration Pack should output HTML like this: 假设编辑器的实例名为“MyEditor” 。对于兼容的浏览器,集成包必须输出如下所示的类似的代码:

<div>
<input type="hidden" id="MyEditor" name="MyEditor" value="initial value (HTML encoded) ">
<input type="hidden" id="MyEditor___Config" value="Key1=Value1&Key2=Value2&... (Key/Value:HTML encoded)">
<iframe id="MyEditor___Frame" src="/FCKeditor/editor/fckeditor.html?InstanceName=MyEditor&Toolbar=Default" width="100%" height="200" frameborder="no" scrolling="no"></iframe>
</div>

While non compatible browsers should get:  对于非兼容的浏览器则输出如下:

<div>
<textarea name="MyEditor" rows="4" cols="40" style="WIDTH: 100%; HEIGHT: 200px" wrap="virtual">initial value (HTML encoded)</textarea>
</div>

FCKeditor Class  FCKeditor的类

The Integration pack should usually offer a main class, called "FCKeditor", in a file called "fckeditor.ext" placed in the root of the editor's distribution package. To be able to use the class the end user should just include a "link" to that file and then easily create an instance of it. Obviously this is the common scenario for scripting languages. Other languages should just reflect this behaviour in the best way possible.
集成包通常需要提供一个主类,叫做"FCKeditor" ,可以将该类放到"fckeditor.ext"里(该文件的ext扩展名为相关的服务端编程语言),然后将该文件放到编辑器发行包的根目录下。这样终端用户只需要包含这个文件的链接,就可以轻松的创建编辑器的实例了,这是脚本语言的最常见的方式,其他的语言可以以最佳的方式来实现这一行为。

This is the basic structure of the FCKeditor Class: FCKeditor 类 的基本结构:

  • Constructor  构造器:
    • FCKeditor( instanceName )  使用FCKeditor(instanceName)函数作为构造器,instanceName参数为该编辑器的实例名。
  • Properties  属性:
    • InstanceName  实例名
    • Width  编辑器的宽
    • Height  编辑器的高
    • ToolbarSet  工具条集
    • Value   编辑器的初始化值。
    • BasePath   编辑器安装时的路径。
  • Collections  集合(一般是数组的形式)
    • Config (Only if possible to use collections)  Config (当可以使用集合时,就需要设置该集合,像PHP和JS里的Config数组可以用来改变编辑器的配置)。
  • Methods 函数方法
    • Create()    创建编辑器时一般就是调用的这个方法。
    • CreateHtml() - return the HTML code to generate create the editor (if you don't want to Create it directly) 如果你不想直接创建编辑器的话,可以使用该方法来返回生成编辑器时用的HTML代码,像js里的Create()方法就是在内部调用 CreateHtml() 方法得到编辑器的HTML代码,再生成编辑器的。
    • SetConfig( key, value ) (Only when not possible to use collections) 设置编辑器的配置,当无法使用前面提到的集合的时候。

The implementation should be based on the Javascript implementation (see fckeditor.js file). See "JavaScript Integration" for a complete explanation of the class elements.
这些服务端集成包的实现可以参考 fckeditor.js文件里的js实现方式。

File Browser Connector 文件浏览器的连接器

The editor gives the end user the flexibility to create a custom file browser that can be integrated with it. This is a powerful feature, because every case is a different case and so different and specific problems must be solved. In any case, the editor package offers a default implementation of the File Browser so the user has a ready to use software without having to develop anything.
以前提到过,编辑器允许终端用户创建一个自定义的文件浏览器,并且可以加载该自定义的浏览器。这个功能的强大之处就在于它可以满足不同应用程序的各种需求。同时,编辑器又给用户提供了一个默认的文件浏览器,这样用户也可以不用进行任何开发就可以直接使用该文件浏览器。

On prior versions, a sample File Browser was available for each server side technology supported by the editor. The problem with that approach was that each sample had a different implementation and worked completely different from each other. And worst, on some of them were really poor.
在以前的版本中,每种服务端语言对应的文件浏览器都是不同的,这样导致每个程序都有不同的实现方式,工作的效果也大相径庭,有时,工作效果还很糟糕。

To solve those problems the current version offers a unique interface that can be used by all server side languages. The interface was developed completely on Javascript DHTML and the integration is available byXML. In this way the developer that wants to integrate with it doesn't have to be worried about the presentation layer of it.
在当前的版本中提供了一种唯一的接口方式,这样所有的服务端语言都与同一个接口进行交互,该接口是使用JAVASCRIPT DHTML开发的,并且支持XML 。这样开发端就只用专注于自己的连接器的服务端实现即可,不用担忧客户端显示层的工作效果。

Architecture  结构

The following image shows how the File Browser Integration works:  下面这幅图显示了文件浏览器集成的工作原理:

Image:FCKeditor_FileBrowserConnector.gif

The "Connector" is the main file to be developed in this case regarding the server side integration with the File Browser. The following tasks must be done by the Connector:
在本例中,"Connector" 是服务端编程语言所关注的主要文件,他负责与客户端的文件浏览器接口的通信。他需要完成以下的任务:

  • Receive the File Manager requests.  接收文件管理器的请求。
  • Execute operations in the File System, like folder and files creations and listings.   通过服务端的文件系统执行相关操作,像文件和文件夹的创建和列举显示。
  • Build the XML response in the right format and syntax.    以正确的格式和语法来构建XML的响应。
  • Receive and handle file uploads from the File Browser.   接收和操作从文件浏览器上传过来的文件。
File Browser Requests  文件浏览器的请求

All requests are simply made by the File Browser using the normal HTTP channel. The request info is always passed by QueryString in the URL that uses the following format:
文件浏览器所产生的所有请求都使用普通的HTTP协议。请求的信息是通过URL中的查询字符串来传递的。通常是下面这样的查询格式:

  connector.ext?Command=CommandName&Type=ResourceType&CurrentFolder=FolderPath  //ext为服务端编程语言的扩展

     ● CommandName - is the command the Connector must execute. For now there are four commands that must be handled: "GetFolders", "GetFoldersAndFiles", "CreateFolder" and "FileUpload".
这个CommandName是告诉连接器必须执行的命令。目前有四个命令必须要实现的: "GetFolders" , "GetFoldersAndFiles" , "CreateFolder" 和 "FileUpload" 分别是 获取目录列表,获取目录以及文件的列表,创建目录 和 文件上传 四个命令。

posted @ 2010-09-04 07:54  夜壶  阅读(223)  评论(0编辑  收藏  举报