using System; using System.Threading; using System.Text; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Configuration; using System.IO; using PortalComponent; using PortalComponent.UI; using PortalComponent.UI.Admin; using PortalComponent.UI.Admin.Resource; using PortalComponent.UI.Menu; using PortalComponent.UI.Page; using PortalComponent.UI.PortalInput; using PortalComponent.BL; using PortalComponent.BL.Admin; using PortalComponent.BL.Admin.Resource; namespace Portal.Admin.Resource { //================================================= //==用于百度 UEditor 的图片管理页面,返回 /Writable/Resource/_Random_ 中各个目录中的图片列表,以 UEditor 要求的格式返回 //==锐商企业CMS - http://www.comsharp.com //================================================= public class UEditorImageManager : Portal.Admin.Template { //************************************************** //**本页的 Field (暂无) //************************************************** //************************************************** //**页面加载 //************************************************** private void Page_Load(object sender, System.EventArgs e) { //--------------------------------------------------- //--去掉本页的 Cache,本方法来自 Portal.Admin.Template //--------------------------------------------------- base.RemoveCache(); //--------------------------------------------------- //--本站后台图片存放在随机资源路径下 //--------------------------------------------------- string myStringRandomResourceLogicalPath=base.RandomResourceLogicalPath; //--------------------------------------------------- //--图片文件格式清单 //--------------------------------------------------- string[] myArrayStringFileType = {".gif",".png",".jpg",".jpeg",".bmp"}; //--------------------------------------------------- //--发布过来的 UEditor http 动作 (get) //--------------------------------------------------- string myStringAction = HttpContext.Current.Server.HtmlEncode(HttpContext.Current.Request["action"]); //--------------------------------------------------- //--返回的图片列表 //--------------------------------------------------- StringBuilder myStringBuilderReturnImageList=new StringBuilder(""); //--------------------------------------------------- //--遍历 RandomResourceLogicalPath 中的所有图片 //--------------------------------------------------- if (myStringAction.Trim().ToLower()=="get") { //--------------------------------------------------- //--创建 RandomResourceLogicalPath 目录对象 //--------------------------------------------------- DirectoryInfo myDirectoryInfoRandomResource=new DirectoryInfo(HttpContext.Current.Server.MapPath(myStringRandomResourceLogicalPath)); //--------------------------------------------------- //--如果 RandomResource 目录存在,则遍历其中的日期目录,继而遍历每个日期目录中的文件 //--------------------------------------------------- if (myDirectoryInfoRandomResource.Exists==true) { foreach (DirectoryInfo myDirectoryInfo in myDirectoryInfoRandomResource.GetDirectories()) { if (myDirectoryInfo!=null) { if (myDirectoryInfo.Exists==true) { foreach (FileInfo myFileInfo in myDirectoryInfo.GetFiles()) { //--------------------------------------------------- //--如果是指定的图片格式 //--------------------------------------------------- if (Array.IndexOf(myArrayStringFileType,myFileInfo.Extension)!=-1) { //--------------------------------------------------- //--最终将连接成以 ue_separate_ue 字符串间隔的文件 url 清单 //--------------------------------------------------- myStringBuilderReturnImageList.AppendFormat("{0}{1}/{2}ue_separate_ue",myStringRandomResourceLogicalPath,myDirectoryInfo.Name,myFileInfo.Name); } } } } } } } //--------------------------------------------------- //--返回文件 url 清单 //--------------------------------------------------- Response.ContentType = "text/plain"; Response.Write(myStringBuilderReturnImageList.ToString()); } //IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII #region Initialization //IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII //************************************************** //**调用页面初始化 //************************************************** override protected void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); } //************************************************** //**页面初始化 //************************************************** private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); } //IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII #endregion //IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII } }