FCKeidtor部分配置的记录

来源:互联网 发布:淘宝女装店铺装修素材 编辑:程序博客网 时间:2024/05/17 02:42

最近在开发公司微信后台,需要用到FCKeidtor来生成HTML,这个控件本身功能十分强大,但是我们的应用不需要太多的功能,摆在上面反而显得有些凌乱,所以就打算去掉这些用不到的功能,首先是控件的界面

去掉这里多余功能在fckconfig.js里找到

看自己项目的需求选择去掉那些多余的功能。

其次是上传图片功能,默认是这样的其中链接和高级功能我的项目暂时不需要用到,留在这里只会增加用户操作失误的几率,那么在哪里修改呢?fckeditor\editor\dialog\fck_image这个目录下面找到fck_image.js注释掉下面的代码就行了。//#### Dialog Tabs


// Set the dialog tabs.
dialog.AddTab( 'Info', FCKLang.DlgImgInfoTab ) ;


//if ( !bImageButton && !FCKConfig.ImageDlgHideLink )
// dialog.AddTab( 'Link', FCKLang.DlgImgLinkTab ) ;


if ( FCKConfig.ImageUpload )
dialog.AddTab( 'Upload', FCKLang.DlgLnkUpload ) ;


//if ( !FCKConfig.ImageDlgHideAdvanced )
// dialog.AddTab( 'Advanced', FCKLang.DlgAdvancedTag ) ;


// Function called when a dialog tag is selected.
function OnDialogTabChange( tabCode )
{
ShowE('divInfo', ( tabCode == 'Info' ) ) ;
//ShowE('divLink', ( tabCode == 'Link' ) ) ;
ShowE('divUpload', ( tabCode == 'Upload' ) ) ;
//ShowE('divAdvanced', ( tabCode == 'Advanced' ) ) ;
}


还有一个问题就是这个控件上传附件存储的问题,它默认是直接保存上传文件的文件名,这样容易造成重名及项目上线后,存放上传文件的文件夹过于的凌乱,所以我对这里稍微了修改了一下,在文件上传时按上传日期创建文件夹及文件名,以便归类。但注意了改这个是在FCKeditor.Net_2.6.4里面修改的,打开项目之后找到FileWorkerBase这个类在protected void FileUpload( string resourceType, string currentFolder, bool isQuickUpload )
{
HttpPostedFile oFile = Request.Files[ "NewFile" ];


string sFileName = "";


if ( oFile == null )
{
this.SendFileUploadResponse( 202, isQuickUpload );
return;
}


// Map the virtual path to the local server path.
string sServerDir = this.ServerMapFolder( resourceType, currentFolder, isQuickUpload );


// Get the uploaded file name.
            sFileName = System.IO.Path.GetFileNameWithoutExtension(oFile.FileName);
            sFileName = this.SanitizeFileName(sFileName);

            //string sFileName2 = sFileName1.TrimEnd('.');


            string sExtension = System.IO.Path.GetExtension( oFile.FileName );
            sExtension = sExtension.TrimStart( '.' );


            //Random Rnd = new Random();
            //int strRnd = Rnd.Next(1, 99);
            sFileName = sFileName + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
            sFileName = sFileName + "." + sExtension.ToLower();
这个方法里面加上红色的代码可以实现文件名+日期命名的方式,按日期生成文件夹则在Config.cs这个类里面的这个方法里面internal void LoadConfig()
{
DefaultSettings();


// Call the setConfig() function for the configuration file (config.ascx).
SetConfig();


// Look for possible UserFilesPath override options.


// Session
string userFilesPath = Session[ "FCKeditor:UserFilesPath" ] as string;
            


// Application
if ( userFilesPath == null || userFilesPath.Length == 0 )
userFilesPath = Application[ "FCKeditor:UserFilesPath" ] as string;


// Web.config file.
if ( userFilesPath == null || userFilesPath.Length == 0 )
userFilesPath = System.Configuration.ConfigurationSettings.AppSettings[ "FCKeditor:UserFilesPath" ];


// config.asxc
if ( userFilesPath == null || userFilesPath.Length == 0 )
userFilesPath = this.UserFilesPath;


if ( userFilesPath == null || userFilesPath.Length == 0 )
userFilesPath = DEFAULT_USER_FILES_PATH;


// Check that the user path ends with slash ("/")
if ( !userFilesPath.EndsWith( "/" ) )
userFilesPath += "/";


            userFilesPath += DateTime.Now.Year.ToString() + "/" + DateTime.Now.Month.ToString() + "/";
userFilesPath = this.ResolveUrl( userFilesPath );


this.UserFilesPath = userFilesPath;
            
} 效果如图

最后大家如果有什么要交流的欢迎给我微博发私信,微博名:1条咸鱼

0 0
原创粉丝点击