分享

四大 FCKeditor 实战应用技巧(3)

 WindySky 2007-03-28
 3、外联编辑条(多个编辑域共用一个编辑条)

  这个功能是2.3版本才开始提供的,以前版本的FCKeditor要在同一个页面里用多个编辑器的话,得一个个创建,现在有了这个外联功能,就不用那么麻烦了,只需要把工具条放在一个适当的位置,后面就可以无限制的创建编辑域了,如图:

  要实现这种功能呢,需要先在页面中定义一个工具条的容器:<divid="xToolbar"></div>,然后再根据这个容器的id属性进行设置。

  ASP实现代码

  

<div id="fckToolBar"></div> 
<% 
Dim oFCKeditor 
Set oFCKeditor = New FCKeditor 
with oFCKeditor 
.BasePath = fckPath 
.Config("ToolbarLocation") = "Out:fckToolBar" 

.ToolbarSet = "Basic" 
.Width = "100%" 
.Height = "200" 

.Value = "" 
.Create "jcontent" 

.Height = "150" 
.Value = "" 
.Create "jreach" 
end with 
%>

  JAVASCRIPT实现代码

  

<div id="xToolbar"></div> 
FCKeditor 1: 
<script type="text/javascript"> 
<!-- 
// Automatically calculates the editor base path based on the _samples directory. 
// This is usefull only for these samples. A real application should use something like this: 
// oFCKeditor.BasePath = ‘/fckeditor/‘ ; // ‘/fckeditor/‘ is the default value. 
var sBasePath = document.location.pathname.substring(0,document.location.pathname.lastIndexOf(‘_samples‘)) ; 

var oFCKeditor = new FCKeditor( ‘FCKeditor_1‘ ) ; 
oFCKeditor.BasePath = sBasePath ; 
oFCKeditor.Height = 100 ; 
oFCKeditor.Config[ ‘ToolbarLocation‘ ] = ‘Out:parent(xToolbar)‘ ; 
oFCKeditor.Value = ‘This is some <strong>sample text</strong>. You are using FCKeditor.‘ ; 
oFCKeditor.Create() ; 
//--> 
</script> 
<br /> 
FCKeditor 2: 
<script type="text/javascript"> 
<!-- 
oFCKeditor = new FCKeditor( ‘FCKeditor_2‘ ) ; 
oFCKeditor.BasePath = sBasePath ; 
oFCKeditor.Height = 100 ; 
oFCKeditor.Config[ ‘ToolbarLocation‘ ] = ‘Out:parent(xToolbar)‘ ; 
oFCKeditor.Value = ‘This is some <strong>sample text</strong>. You are using FCKeditor.‘ ; 
oFCKeditor.Create() ; 
//--> 
</script>

  此部分的详细DEMO请参照:
_samples/html/sample11.html
_samples/html/sample11_frame.html
4、文件管理功能、文件上传的权限问题

  一直以后FCKeditor的文件管理部分的安全是个值得注意,但很多人没注意到的地方,虽然FCKeditor在各个Release版本中一直存在的一个功能就是对上传文件类型进行过滤,但是她没考虑过另一个问题:到底允许谁能上传?到底谁能浏览服务器文件?

  之前刚开始用FCKeditor时,我就出现过这个问题,还好NetRube(FCKeditor中文化以及FCKeditor ASP版上传程序的作者)及时提醒了我,做法是去修改FCK上传程序,在里面进行权限判断,并且再在fckconfig.js里把相应的一些功能去掉。但随之FCK版本的不断升级,每升一次都要去改一次配置程序fckconfig.js,我发觉厌烦了,就没什么办法能更好的控制这种配置么?事实上,是有的。

  在fckconfig.js里面,有关于是否打开上传和浏览服务器的设置,在创建FCKeditor时,通过程序来判断是否创建有上传浏览功能的编辑器。首先,我先在fckconfig.js里面把所有的上传和浏览设置全设为false,接着我使用的代码如下:

  ASP版本:

<% 
Dim oFCKeditor 
Set oFCKeditor = New FCKeditor 
with oFCKeditor 
.BasePath = fckPath 
.Config("ToolbarLocation") = "Out:fckToolBar" 
if request.cookies(site_sn)("issuper")="yes" then 
.Config("LinkBrowser") = "true" 
.Config("ImageBrowser") = "true" 
.Config("FlashBrowser") = "true" 
.Config("LinkUpload") = "true" 
.Config("ImageUpload") = "true" 
.Config("FlashUpload") = "true" 
end if 
.ToolbarSet = "Basic" 
.Width = "100%" 
.Height = "200" 
.Value = "" 
.Create "jcontent" 
%> 

  JAVASCRIPT版本:

  

      var oFCKeditor = new FCKeditor( ‘fbContent‘ ) ;
      <%if power = powercode then%>
      oFCKeditor.Config[‘LinkBrowser‘] = true ;
      oFCKeditor.Config[‘ImageBrowser‘] = true ;
      oFCKeditor.Config[‘FlashBrowser‘] = true ;
      oFCKeditor.Config[‘LinkUpload‘] = true ;
      oFCKeditor.Config[‘ImageUpload‘] = true ;
      oFCKeditor.Config[‘FlashUpload‘] = true ;
      <%end if%>
      oFCKeditor.ToolbarSet = ‘Basic‘ ;
      oFCKeditor.Width = ‘100%‘ ;
      oFCKeditor.Height = ‘200‘ ;
      oFCKeditor.Value = ‘‘ ;
      oFCKeditor.Create() ;

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多