📄 contenttype.cs
字号:
namespace PowerEasy.WebSite.Controls.FieldControl
{
using PowerEasy.Common;
using PowerEasy.Components;
using PowerEasy.Controls;
using PowerEasy.Controls.Editor;
using PowerEasy.Web.UI;
using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class ContentType : BaseFieldControl
{
protected CheckBox ChkSaveRemotePic;
protected PEeditor EditorContent;
protected Literal LitSaveRemotePic;
private string m_DefaultPicUrl = "";
private bool m_IsUpload;
public string m_UploadDir = VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.UploadDir);
protected HtmlGenericControl Tab;
protected FckEditorValidator ValrContent;
protected void Page_Load(object sender, EventArgs e)
{
if (!base.IsAdminManage)
{
this.LitSaveRemotePic.Visible = false;
this.ChkSaveRemotePic.Visible = false;
}
if (base.EnableNull)
{
this.ValrContent.Visible = true;
}
this.EditorContent.Width = new Unit(DataConverter.CLng(base.Settings[0]));
this.EditorContent.Height = new Unit(DataConverter.CLng(base.Settings[1]));
if (base.Settings.Count > 9)
{
if (!string.IsNullOrEmpty(base.Settings[6]))
{
this.EditorContent.ImageUploadAllowedExtensions = base.Settings[6];
}
if (!string.IsNullOrEmpty(base.Settings[7]))
{
this.EditorContent.FlashUploadAllowedExtensions = base.Settings[7];
}
if (!string.IsNullOrEmpty(base.Settings[8]))
{
this.EditorContent.LinkUploadAllowedExtensions = base.Settings[8];
}
if (!string.IsNullOrEmpty(base.Settings[9]))
{
this.EditorContent.IsWatermark = base.Settings[9];
}
if (!string.IsNullOrEmpty(base.Settings[10]))
{
this.EditorContent.IsThumb = base.Settings[10];
}
}
else if (base.Settings.Count != 6)
{
this.EditorContent.ImageUploadAllowedExtensions = base.Settings[2];
this.EditorContent.FlashUploadAllowedExtensions = base.Settings[3];
this.EditorContent.LinkUploadAllowedExtensions = base.Settings[4];
this.EditorContent.IsWatermark = base.Settings[5];
this.EditorContent.IsThumb = base.Settings[6];
}
if (base.Settings.Count != 6)
{
this.EditorContent.ModelId = BaseUserControl.RequestInt32("ModelID").ToString();
this.EditorContent.FieldName = base.FieldName;
}
this.EditorContent.ImgPreview = "true";
if (this.IsUpload)
{
this.EditorContent.IsUpload = "true";
}
if ((!base.IsPostBack && !string.IsNullOrEmpty(this.m_DefaultPicUrl)) && !this.Page.ClientScript.IsStartupScriptRegistered(base.GetType(), "initDefaultPicUrl"))
{
StringBuilder builder = new StringBuilder();
builder.Append("<script language=\"JavaScript\">\n");
builder.Append("<!--\n");
builder.Append("setTimeout(\"setpic('" + this.DefaultPicurl + "')\",1000);\n");
builder.Append("//-->\n");
builder.Append("</script>\n");
this.Page.ClientScript.RegisterStartupScript(base.GetType(), "initDefaultPicUrl", builder.ToString());
}
}
private string PathLableReplace(string content)
{
content = content.Replace(SiteConfig.SiteOption.UploadDir, "{PE.SiteConfig.uploaddir/}");
if (SiteConfig.SiteInfo.VirtualPath.CompareTo("/") != 0)
{
content = content.Replace(SiteConfig.SiteInfo.VirtualPath, "{PE.SiteConfig.ApplicationPath/}");
}
return content;
}
private string PathReplaceLable(string content)
{
string input = content;
string pattern = @"{PE\.SiteConfig\.ApplicationPath\/}";
foreach (Match match in Regex.Matches(input, pattern, RegexOptions.IgnoreCase))
{
input = input.Replace(match.Value, SiteConfig.SiteInfo.VirtualPath);
}
pattern = @"{PE\.SiteConfig\.uploaddir\/}";
foreach (Match match2 in Regex.Matches(input, pattern, RegexOptions.IgnoreCase))
{
input = input.Replace(match2.Value, SiteConfig.SiteOption.UploadDir);
}
return input;
}
public string Content
{
get
{
if (base.IsAdminManage)
{
return this.PathLableReplace(this.EditorContent.Value);
}
return StringHelper.RemoveXss(this.PathLableReplace(this.EditorContent.Value));
}
set
{
this.EditorContent.Value = this.PathReplaceLable(value);
}
}
public string DefaultPicurl
{
get
{
return StringHelper.RemoveXss(this.m_DefaultPicUrl);
}
set
{
this.m_DefaultPicUrl = value;
}
}
public PEeditor Editor
{
get
{
return this.EditorContent;
}
}
public bool IsUpload
{
get
{
return this.m_IsUpload;
}
set
{
this.m_IsUpload = value;
}
}
public bool SaveRemotePic
{
get
{
if (!base.IsAdminManage)
{
return false;
}
return this.ChkSaveRemotePic.Checked;
}
set
{
this.ChkSaveRemotePic.Checked = value;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -