如何在FCKeditor 2.6中添加插入视频和音频功能

CKeditor 是现在用的最多的可视编辑器,阿飞也在使用该编辑器为客户开发程序,应客户要求,添加了插入视频和音频的功能,因为2.6版的修改可能和其他版本不一样,所以我把修改的地方列举出来。

修改前注意备份文件,以免造成不必要的麻烦。

一、分别打开:editor/js/fckeditorcode_ie.js和/editor/js/fckeditorcode_gecko.js

找到以下代码

以下是代码片段:
||/\.swf($|#|\?)/i.test(A.src)

 这段代码的主要用来判断后缀名,如果后缀名不是swf则返回,把它替换为:

以下是代码片段:
||/\.swf($|#|\?)/i.test(A.src)||/\.mpg($|#|\?)/i.test(A.src)||/\.asf($|#|\?)/i.test(A.src)||/\.wma($|#|\?)/i.test(A.src)||/\.wmv($|#|\?)/i.test(A.src)||/\.avi($|#|\?)/i.test(A.src)||/\.mov($|#|\?)/i.test(A.src)||/\.mp3($|#|\?)/i.test(A.src)||/\.rmvb($|#|\?)/i.test(A.src)||/\.mid($|#|\?)/i.test(A.src)||/\.flv($|#|\?)/i.test(A.src)

 文件格式可以根据情况来修改,但是注意要和其他的几个地方吻合

二、打开:/editor/dialog/fck_flash/fck_flash.js

1、增加程序代码,这段代码用来判断后缀名

以下是代码片段:
function WinPlayer(url){
 var r, re;
 re = /.(avi|wmv|asf|wma|mid|mp3|mpg)$/i;
 r = url.match(re);
 return r;
}
function RealPlayer(url){
 var r, re;
 re = /.(.rm|.ra|.rmvb|ram)$/i;
 r = url.match(re);
 return r;
}
function QuickTime(url){
 var r, re;
 re = /.(mov|qt)$/i;
 r = url.match(re);
 return r;
}
function FlashPlayer(url){
 var r, re;
 re = /.swf$/i;
 r = url.match(re);
 return r;
}

 2、替换程序代码,这段代码是在UpdatePreview中用来添加type属性

把以下代码

以下是代码片段:
SetAttribute( e, 'type', 'application/x-shockwave-flash' ) ;

 替换为

以下是代码片段:
  if(WinPlayer(GetE('txtUrl').value) != null){
   SetAttribute( e, 'type', 'application/x-mplayer2' ) ;
  }
  if(RealPlayer(GetE('txtUrl').value) != null){
   SetAttribute( e, 'type', 'audio/x-pn-realaudio-plugin' ) ;
  }
  if(QuickTime(GetE('txtUrl').value) != null){
   SetAttribute( e, 'type', 'application/video/quicktime' ) ;
  }
  if(FlashPlayer(GetE('txtUrl').value) != null){
   SetAttribute( e, 'type', 'application/x-shockwave-flash' ) ;
   SetAttribute( e, 'pluginspage', 'http://www.macromedia.com/go/getflashplayer' ) ;
  }

 3、替换程序代码,这段代码是在UpdateEmbed中用来添加type属性

将以下代码

以下是代码片段:
SetAttribute( e, 'type' , 'application/x-shockwave-flash' ) ;
SetAttribute( e, 'pluginspage' , 'http://www.macromedia.com/go/getflashplayer' ) ;

 替换为

以下是代码片段:
 if(WinPlayer(GetE('txtUrl').value) != null){
  SetAttribute( e, 'type' , 'application/x-mplayer2' ) ;
  SetAttribute( e, 'autostart', GetE('chkAutoPlay').checked ? 'true' : 'false' ) ;
 }
 if(RealPlayer(GetE('txtUrl').value) != null){
  SetAttribute( e, 'type' , 'audio/x-pn-realaudio-plugin' ) ;
  SetAttribute( e, 'autostart', GetE('chkAutoPlay').checked ? 'true' : 'false' ) ;
 }
 if(QuickTime(GetE('txtUrl').value) != null){
  SetAttribute( e, 'type' , 'video/quicktime' ) ;
  SetAttribute( e, 'autostart', GetE('chkAutoPlay').checked ? 'true' : 'false' ) ;
 }
 if(FlashPlayer(GetE('txtUrl').value) != null){
  SetAttribute( e, 'type' , 'application/x-shockwave-flash' ) ;
  SetAttribute( e, 'pluginspage' , 'http://www.macromedia.com/go/getflashplayer' ) ;
 }

 三、打开:/fckconfig.js,该文件为配置文件

替换程序代码,这个是在上传文件的时候检查后缀名

以下是代码片段:
FCKConfig.FlashUploadAllowedExtensions = ".(swf )$" ; // empty for all

 为

以下是代码片段:
FCKConfig.FlashUploadAllowedExtensions = ".(swf|flv|fla|mpg|asf|wma|wmv|avi|mov|mp3|rmvb|mid )$" ; // empty for all

 四、打开:/editor/filemanager/connectors/asp/config.asp,该文件为asp版配置文件

替换程序代码,这个是在上传文件的时候检查后缀名

以下是代码片段:
ConfigAllowedExtensions.Add "Flash", "swf"

 为

以下是代码片段:
ConfigAllowedExtensions.Add "Flash", "swf|flv|mpg|asf|wma|wmv|avi|mov|mp3|rmvb|mid "

 五、打开:/editor/lang/zh-cn.js 文件,该部分为语言文件,Flash替换掉就可以了

 六、然后整体修改完成,现在已经支持上传视频和音频文件,不过注意的是,如果视频文件太大,还是可能出现不能播放的情况

七。在服务器端进行配置

在src中建立一个属性文件fckeditor.properties,并在其中写入以下选项

connector.resourceType.flash.extensions.allowed = swf|flv|mpg|asf|wma|wmv|avi|mov|mp3|rmvb|mid

最近做了一个文章管理的系统,用到在线编辑器,修改了一下现在能实现音频视频,图片,附件,Flash等文件的上传。费了好大的功夫。。 FCKeditor应用在ASP.NET上,需要两组文件,一组是FCKeditor本身,另一个是用于ASP.NET的FCKeditor控件(分为1.1和2.0两个版本,这里使用2.0版本)。 1. 将FCKeditor加入到项目 解压FCKeditor编辑器,得到文件夹fckeditor,复制此文件夹到Web应用的项目下(也可以是子孙目录下)。 解压FCKeditor控件,在其子目录bin/Release/2.0下有一个程序集。在Web应用的项目引用该程序集。 2. 在页面使用FCKeditor 有两种方式。 (1)手工编码 在页面加入ASP.NET指令: 然后在需要的地方加入FCKeditor控件: (2)集成到Visual Studio工具箱 打开一ASP.NET页面,展开Toolbox,打开右键菜单,选择“Choose Items ...”,在出现的“Choose Toolbox Items”会话框的“.NET Framework Components”选项卡选择“Browse”,找到并选FCKeditor程序集,打开后回到“Choose Toolbox Items”窗口,点击“OK”,完成控件导入。 这时,在Toolbox的General分类下出现了一个名为FCKeditor的控件,可以像使用Visual Studio内置控件一样使用它。 3. 配置FCKeditor编辑器路径 在页面,使用的是FCKeditor控件,该控件需要知道FCKeditor编辑器文件组的路径。有两种配置方法。 (1)配置web.config 在appSettings配置节加入 使用这种配置方法后,对于项目任何一个页面用到的FCKeditor控件,都不用再配置其BasePath属性。 (2)直接对用到的FCKeditor控件进行配置 在页面代码设置FCKeditor的属性BasePath为FCKeditor编辑器文件组的路径,或者在Page_Init事件处理器设置其BasePath的值。 4. 配置FCKeditor编辑器文件上传路径 在web.config的appSettings配置节加入 或者 这样,就完成了FCKeditorASP.NET页面的集成工作。 二、配置FCKeditor 按照FCKeditor的默认配置,可以完成一些常用的HTML可视化编辑工作,但在实际应用,还需要对其做进一步的配置。FCKeditor控件的可配置属性不多,且配置后只能作用于一个单一实例。实际上,需要对FCKeditor编辑器文件组的通用配置文件/fckconfig.js和ASP.NET专用文件上传管理代码文件/editor/filemanager/connectors/aspx/config.ascx进行配置。 1. 配置控件语言 FCKeditor是自动探测浏览器所使用的语言编码的,其默认语言是英文。修改配置行"FCKConfig.DefaultLanguage = 'en';"为'zh-cn',采用文为默认语言。 2. 配置控件应用技术 FCKeditor默认是用于php技术的。修改配置行"var _FileBrowserLanguage = 'php';"和"var _
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值