Loading

FCKEditor 自定义用户目录 (附源码) 2010年4月24日更新源码

 

转载请注明出处:http://qbit.cnblogs.com/

 

由于我这边的网络原因,没用从FCK的官网下载到源码...

这套源码是FCK2.2版反编译出来的 

 源码:点此下载 源码中主要修改的地方做了注释

大致的修改如下 :

 

获取用户目录的源码: FileWorkerBase.cs

这里主要是做了一些注释

在程序中可以直接在用户登录的时候指定

这个方案只是方便多用户使用的时候为用户指定不同的文件目录

Session["FCKeditor:UserFilesPath"]="用户文件相对目录";

代码
   /// <summary>
        
/// 用户文件目录
        
/// </summary>
        protected string UserFilesPath
        {
            
get
            {
                
if (this.sUserFilesPath == null)
                {
                    
//从APPlictaion 读取
                    this.sUserFilesPath = (string)base.Application["FCKeditor:UserFilesPath"];
                    
if ((this.sUserFilesPath == null|| (this.sUserFilesPath.Length == 0))
                    {
                        
//从Session读取
                        this.sUserFilesPath = (string)this.Session["FCKeditor:UserFilesPath"];
                        
if ((this.sUserFilesPath == null|| (this.sUserFilesPath.Length == 0))
                        {
                            
//从站点配置文件读取
                            this.sUserFilesPath = ConfigurationSettings.AppSettings["FCKeditor:UserFilesPath"];
                            
if ((this.sUserFilesPath == null|| (this.sUserFilesPath.Length == 0))
                            {
                                
this.sUserFilesPath = "/UpLoadFiles/";
                            }
                            
if ((this.sUserFilesPath == null|| (this.sUserFilesPath.Length == 0))
                            {
                                
//从URL读取
                                this.sUserFilesPath =  base.Request.QueryString["ServerPath"];
                            }
                        }
                    }
                    
if (!this.sUserFilesPath.EndsWith("/"))
                    {
                        
this.sUserFilesPath = this.sUserFilesPath + "/";
                    }
      
                }
                
return this.sUserFilesPath;
            }
        }

 

这样指定了之后会发现 FCK需要有Image,Files等文件夹

修改这个文件:Uploader .cs

修改过的上传文件操作类在这里:(如果你要修改原版的不必去把这个类文件搞到你的Web程序目录中来,我这里只是为了方便使用我项目中的APP_Code中的方法,下同不再赘述!)

Fckeditor\editor\filemanager\upload\aspx\upload.aspx.cs

修改的时候忘了做记录..这里貌似没改什么内容 只是做了点注释

 

呃找到了在这里 FileBrowserConnector

Fckeditor\editor\filemanager\browser\default\connectors\aspx\connector.aspx.cs(修改后的地址)

 

代码
        /// <summary>
        
/// 根据文件类型选择文件夹
        
/// </summary>
        
/// <param name="resourceType"></param>
        
/// <param name="folderPath"></param>
        
/// <returns></returns>
        private string ServerMapFolder(string resourceType, string folderPath)
        {
            
//2010-3-29 14:00:56
            
//string path = Path.Combine(base.UserFilesDirectory, resourceType);
            string path = base.UserFilesDirectory;
            Util.CreateDirectory(path);
            
return Path.Combine(path, folderPath.TrimStart(new char[] { '/' }));
        }

 

这里直接把那个resourceType给排除掉了(去掉判断文件类型)

这个方法将影响选定图片后的图片路径

代码
        private string GetUrlFromPath(string resourceType, string folderPath)
        {
            
if ((resourceType == null|| (resourceType.Length == 0))
            {
                
return (base.UserFilesPath.TrimEnd(new char[] { '/' }) + folderPath);
            }
            
//2010-3-29 14:00:20 HYZ
            
//return (base.UserFilesPath + resourceType + folderPath);
            string p=base.UserFilesPath  + folderPath;//新增
            p=p.Replace("//","/");//新增

            
return (p);//新增
        }

 

然后在其他的HTML文件中也修改有部分代码

1.翻译了提示信息

这东西就不说了..很简单你也可以根据提示信息全文搜索...

2.修改选定图片后的示例文本为中文

文件位于: 第52行

Fckeditor\editor\dialog\fck_image\fck_image_preview.html

3.修改文件浏览器增加了文件预览 (效果很粗糙)

高手们修改好看了还望能给小弟发一份儿..

文件位于:

Fckeditor\editor\filemanager\browser\default\frmresourceslist.html

我这里修改了第63行的js 显示预览效果

当然还有自定义表情之类的玩意儿..

但因为目前项目需要的就这么点儿东西.所以也懒得去搞了...

 源码:点此下载

 

转载请注明出处:http://Qbit.cnblogs.com 

posted @ 2010-03-29 23:08  韩严重  阅读(1684)  评论(3编辑  收藏  举报