也来说说FCKeditor2.5
个人感觉FCKeditor还是非常不错的,看了很多人对她的使用、配置方面的文章,都非常详细,这两天下了个2.5.1版本的玩玩,稍微有些变化,今天就来说说。
首先下载了2.5.1的完全版,接着发现对于.NET也给出了2.5的源码,其他使用的地方就不多说了,只说说配置上注意的地方以及对代码的一些个人分析。
一、配置:
大体上跟以往版本差不多,注意到一个区别,最起码跟2.2不同,就是在connector目录下的aspx里,多了个config.ascx文件,没玩过2.4版,不知道里面有没有,反正也是配置性质的文件,其中有个关键地方要说一下:
//读取设置。
internal void LoadConfig()
{
DefaultSettings();

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

// 从以下几个可能的地方找用户文件路径。

// 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;

// 检查用户路径后面是否有反斜杠,如果没有就自动加上。
if ( !userFilesPath.EndsWith( "/" ) )
userFilesPath += "/";

userFilesPath = this.ResolveUrl( userFilesPath );

this.UserFilesPath = userFilesPath;
}
先是通过SetConfig看用户配置,接着照例从几个地方读,所以首先要在那个配置文件里true!
二、想在上传图片上做点文章的注意FileWorkerBase.cs里的FileUpload( string resourceType, string currentFolder, bool isQuickUpload ),思路是判断是否是图片,然后比如处理图片(缩小点,加水引或者形成缩略图等等)。
首先下载了2.5.1的完全版,接着发现对于.NET也给出了2.5的源码,其他使用的地方就不多说了,只说说配置上注意的地方以及对代码的一些个人分析。
一、配置:
大体上跟以往版本差不多,注意到一个区别,最起码跟2.2不同,就是在connector目录下的aspx里,多了个config.ascx文件,没玩过2.4版,不知道里面有没有,反正也是配置性质的文件,其中有个关键地方要说一下:
1
public override void SetConfig()
2
{
3
Enabled = true;
4



5



6



7
}
我自己后来就卡在这了,源码看了几遍没问题,web.config配置也没问题,仍然在上传文件以及打开她的资源浏览窗口时报路径错误,最后发现是这个配置文件那里没有写成true,默认的是false,只有在这里true了以后她才读我们在web.config里的设置的路径,因为(观察她的源码不难发现,在Config.cs中):
public override void SetConfig()2
{3
Enabled = true;4



5



6



7
}
//读取设置。
internal void LoadConfig()
{
DefaultSettings();
// Call the setConfig() function for the configuration file (config.ascx).
SetConfig();
// 从以下几个可能的地方找用户文件路径。
// 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;
// 检查用户路径后面是否有反斜杠,如果没有就自动加上。
if ( !userFilesPath.EndsWith( "/" ) )
userFilesPath += "/";
userFilesPath = this.ResolveUrl( userFilesPath );
this.UserFilesPath = userFilesPath;
}二、想在上传图片上做点文章的注意FileWorkerBase.cs里的FileUpload( string resourceType, string currentFolder, bool isQuickUpload ),思路是判断是否是图片,然后比如处理图片(缩小点,加水引或者形成缩略图等等)。

浙公网安备 33010602011771号