1、修改web.config ,增加下面的,
<add verb="GET" path="FtbWebResource.axd" type="FreeTextBoxControls.AssemblyResourceHandler, FreeTextBox" />
要加在
<!-- Can not see to load asmx like .aspx, since we will grap all requests later, make sure these are processed by their default factory -->
<add verb="*" path="*.asmx" type="System.Web.Services.Protocols.WebServiceHandlerFactory, System.Web.Services, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
validate="false" />
的上面。
2、移除admin和dottextweb引用中的freetextbox。
3、下载freetextbox,并覆盖freetextbox目录。
4、在DottextWeb\Emoticons目录建立一个msn目录,把msn表情放到此目录下面。
5、把FreeTextBox.dll拷贝到bin目录下。在admin和dottextweb添加freetextbox引用。
修改EntryEditor.ascx.cs和LoginPostComment.ascx.cs文件。
在namespace Dottext.Web.Admin.UserControls添加两行:
using FreeTextBoxControls;
using System.Text;
并用下面的代码替换SetFreeTextBox部分。
SetFreeTextBox#region SetFreeTextBox
插入QQ/MSN表情#region 插入QQ/MSN表情
protected FreeTextBoxControls.ToolbarButton FTB_InsertFlash()
{
FreeTextBoxControls.ToolbarButton FTB_InsertFlashButton = new FreeTextBoxControls.ToolbarButton("插入Flash","FTB_InsertFlash","flash");
return FTB_InsertFlashButton;
}
protected FreeTextBoxControls.ToolbarButton CreateQQEmoticon()
{
FreeTextBoxControls.ToolbarButton qqButton = new FreeTextBoxControls.ToolbarButton("插入QQ表情","FTB_InsertQQEmoticon","qq");
return qqButton;
}
protected FreeTextBoxControls.ToolbarButton CreateMSNEmoticon()
{
FreeTextBoxControls.ToolbarButton msnButton = new FreeTextBoxControls.ToolbarButton("插入MSN表情","FTB_InsertMSNEmoticon","msn");
return msnButton;
}
protected void CreateEmoticon()
{
FreeTextBoxControls.Toolbar tb=new FreeTextBoxControls.Toolbar();
tb.Items.Add(CreateMSNEmoticon());
tb.Items.Add(CreateQQEmoticon());
tb.Items.Add(FTB_InsertFlash());
// ftbBody.Toolbars.Add(tb);
}
#endregion
插入msn表情#region 插入msn表情
protected void CreateMSNEmoticonOld()
{
FreeTextBoxControls.ToolbarButton tbButton;
string imageName;
FreeTextBoxControls.Toolbar msntb=new FreeTextBoxControls.Toolbar();
XmlDocument myxml=new XmlDocument();
myxml.Load(Server.MapPath("~/Emoticons/")+"emoticons.xml");
XmlNodeList nodes=myxml.SelectNodes("/emoticons/emoticon");
foreach(XmlNode node in nodes)
{
tbButton=new FreeTextBoxControls.ToolbarButton();
tbButton.Title=node.Attributes["title"].InnerText;
tbButton.ButtonImage="Emoticons/"+node.Attributes["name"].InnerText;
imageName = Globals.WebPathCombine(Request.ApplicationPath,"/Emoticons/")+node.Attributes["name"].InnerText+".gif";
tbButton.FunctionName="FTB_InsertMSNEmoticon_"+node.Attributes["name"].InnerText;
tbButton.ScriptBlock = @"<script language=""JavaScript"">
function "+tbButton.FunctionName+@"(ftbName) {
editor=eval(ftbName + '_Editor');
}
</script>";
msntb.Items.Add(tbButton);
}
ftbBody.Toolbars.Add(msntb);
}
#endregion
public void SetFreeTextBox()
{
string app=Request.ApplicationPath;
if(!app.EndsWith("/"))
{
app+="/";
}
FreeTextBoxControls.Toolbar tb=new FreeTextBoxControls.Toolbar();
ftbBody.SupportFolder = app+"FreeTextBox/";
ftbBody.ImageGalleryPath="~/Images/";
string rif = "";
string cif = "";
rif = System.Text.RegularExpressions.Regex.Replace(Dottext.Framework.Configuration.Config.CurrentBlog(Context).ImagePath,Dottext.Framework.Configuration.Config.Settings.AggregateUrl,string.Empty,System.Text.RegularExpressions.RegexOptions.IgnoreCase);
rif="~/"+rif;
rif = rif.Replace("//","/");
if(rif.EndsWith("/"))
{
rif = rif.Substring(0,rif.Length-1);
}
cif = rif;
if (cif != "" && rif != "")
{
ftbBody.ImageGalleryPath=rif;
// RootImagesFolder.Value = rif;
// CurrentImagesFolder.Value = cif;
}
else
{
// RootImagesFolder.Value = DefaultImageFolder;
// CurrentImagesFolder.Value = DefaultImageFolder;
}
FreeTextBoxControls.Toolbar myToolbar = new Toolbar();
FreeTextBoxControls.ToolbarButton myButton = new ToolbarButton("插入代码", "code", "Code");
StringBuilder scriptBlock = new StringBuilder();
scriptBlock.AppendFormat("var codescript = '{0}';", ftbBody.SupportFolder + "ftb.insertcode.aspx");
scriptBlock.Append("code = showModalDialog(codescript,window,'dialogWidth:500px; dialogHeight:400px;help:0;status:0;resizeable:1;');");
scriptBlock.Append("if (code != null) {");
scriptBlock.Append(" this.ftb.InsertHtml(code);");
scriptBlock.Append("}");
myButton.ScriptBlock = scriptBlock.ToString();
FreeTextBoxControls.ToolbarButton qqButton = new ToolbarButton("插入QQ表情", "qq", "qq");
StringBuilder qqscriptBlock = new StringBuilder();
qqscriptBlock.Append("var folder = 'Emoticons/qq';");
qqscriptBlock.AppendFormat("var galleryscript ='../../EmoticonsGallery.aspx?rif='+folder+'&cif='+folder;");
qqscriptBlock.Append("imgArr = showModalDialog(galleryscript,window,'dialogWidth:200px; dialogHeight:200px;help:0;status:0;resizeable:1;');");
qqscriptBlock.Append("if (imgArr != null&&typeof(imgArr)=='object') {");
qqscriptBlock.Append(" this.ftb.InsertHtml('<img src='+imgArr['filename']+' BORDER=0>');");
qqscriptBlock.Append("}");
qqButton.ScriptBlock = qqscriptBlock.ToString();
FreeTextBoxControls.ToolbarButton msnButton = new ToolbarButton("插入msn表情", "msn", "msn");
StringBuilder msnscriptBlock = new StringBuilder();
msnscriptBlock.Append("var folder = 'Emoticons/msn';");
msnscriptBlock.AppendFormat("var galleryscript ='../../EmoticonsGallery.aspx?rif='+folder+'&cif='+folder;");
msnscriptBlock.Append("imgArr = showModalDialog(galleryscript,window,'dialogWidth:200px; dialogHeight:200px;help:0;status:0;resizeable:1;');");
msnscriptBlock.Append("if (imgArr != null&&typeof(imgArr)=='object') {");
msnscriptBlock.Append(" this.ftb.InsertHtml('<img src='+imgArr['filename']+' BORDER=0>');");
msnscriptBlock.Append("}");
msnButton.ScriptBlock = msnscriptBlock.ToString();
myToolbar.Items.Add(qqButton);
myToolbar.Items.Add(msnButton);
myToolbar.Items.Add(myButton);
ftbBody.Toolbars.Add(myToolbar);
// string code = @"
// returnstr=showModalDialog( '../../InsertCode.aspx',window,'dialogWidth:500px; dialogHeight:400px;help:0;status:0;resizeable:1;');
// if(returnstr!=null&&returnstr!='')
// {
// FTB_InsertText('"+ftbBody.ClientID+"',returnstr)}";
// FreeTextBoxControls.ToolbarButton CodeButton = new FreeTextBoxControls.ToolbarButton("插入代码",code,"Code");
// CodeButton.ButtonImage="Code";
// tb.Items.Add(CodeButton);
// FreeTextBoxControls.ToolbarButton RestoreButton = new FreeTextBoxControls.ToolbarButton("恢复上次提交","Restore","Restore");
// tb.Items.Add(RestoreButton);
// CreateEmoticon();
// ftbBody.Toolbars.Add(tb);
}
#endregion
6、修改EntryEditor.ascx
<ftb:FreeTextBox....>部分。
<ftb:FreeTextBox language="zh-cn" id="ftbComment" runat="server" Visible="true" ToolbarStyleConfiguration="Office2003"
Height="400" Width="98%" ToolbarLayout="ParagraphMenu,FontFacesMenu,FontSizesMenu,FontForeColorsMenu,Cut,Copy,Paste,Undo,Redo,Print;Bold,Italic,Underline,fontforecolorpicker,fontbackcolorpicker,Strikethrough;Superscript,Subscript,RemoveFormat|JustifyLeft,JustifyRight,JustifyCenter,JustifyFull;BulletedList,NumberedList,Indent,Outdent;CreateLink,Unlink,insertdate,inserttime,WordClean,preview,InsertRule"></ftb:FreeTextBox>
7、替换LoginPostComment.ascx里面:
<ftb:FreeTextBox language="zh-cn" id="ftbComment" runat="server" Visible="true" ToolbarStyleConfiguration="Office2003"
Height="400" Width="98%" ToolbarLayout="ParagraphMenu,FontFacesMenu,FontSizesMenu,FontForeColorsMenu,Cut,Copy,Paste,Undo,Redo,Print;Bold,Italic,Underline,fontforecolorpicker,fontbackcolorpicker,Strikethrough;Superscript,Subscript,RemoveFormat|JustifyLeft,JustifyRight,JustifyCenter,JustifyFull;BulletedList,NumberedList,Indent,Outdent;CreateLink,Unlink,insertdate,inserttime,WordClean,preview,InsertRule"></ftb:FreeTextBox>
8、替换admin目录下ftb.imagegallery.aspx里面的
<iframe style="width:100%;height:100%;border:0;" border=0 frameborder=0 src="ftb.imagegallery.aspx?frame=1&<%=Request.QueryString%>"></iframe>
为
<form id="Form1" runat="server" enctype="multipart/form-data">
<FTB:ImageGallery id="ImageGallery1" AllowImageUpload=true AllowImageDelete=true AllowDirectoryCreate=true AllowDirectoryDelete=true runat="Server" />
</form>
并在最上部添加:
<%@ Register TagPrefix="FTB" Namespace="FreeTextBoxControls" Assembly="FreeTextBox" %>
编译之后,如果没有意外即可升级到FreeTextBox 3.0。