public VelocityHelper(BaseModule _bpm, EffectDBEntity _Theme) { Theme = _Theme; bpm = _bpm; Init(_bpm); }
/// <Description> /// 绑定页面项 /// </Description> private void BindPageItem() { EffectDBEntity EffectDB = Setting_EffectDB; hlAddGroups.NavigateUrl = xUrl("Groups"); hlAddGroups.Attributes.Add("onclick", String.Format("return confirm('{0}');", Localization.GetString("hlAddGroups.Confirm", this.LocalResourceFile))); divGroups.Visible = EffectDB.Groups; divCustomModels.Visible = EffectDB.CustomModels; divNumbers.Visible = EffectDB.Downloads; //增加权限用户 DotNetNuke.Security.Roles.RoleController rc = new DotNetNuke.Security.Roles.RoleController(); WebHelper.BindList(cblPermissionsRoles, rc.GetPortalRoles(PortalId), "RoleName", "RoleName"); //构造增加按钮 if (EffectDB.Layers && SliderID > 0) { liTitle_Layers.Text = String.Format("{0} List", EffectDB.LayerName); StringBuilder AddNewBuilder = new StringBuilder(); //通用按钮 AddNewBuilder.Append(AddNewLayerHtml("")); if (!String.IsNullOrEmpty(EffectDB.LayerType)) { List <String> AddNewList = Common.GetList(EffectDB.LayerType); foreach (String AddNew in AddNewList) { if (!String.IsNullOrEmpty(AddNew)) { AddNewBuilder.Append(AddNewLayerHtml(AddNew)); } } } liAddNewLink_List.Text = AddNewBuilder.ToString(); div_Layers.Visible = true; } else { div_Layers.Visible = false; } ////插入用户按钮的连接 //hlCreateUser.NavigateUrl = String.Format("{0}Resource_UserList.aspx?ModuleId={1}&PortalId={2}&UserId={3}&HomeDirectory={4}&TB_iframe=true&keepThis=true&height=400&width=600", ModulePath, ModuleId, PortalId, UserId, HttpUtility.UrlEncode(PortalSettings.HomeDirectory)); //绑定状态代码 WebHelper.BindList(ddlArticleStatus, typeof(EnumStatus)); }
/// <summary> /// 绑定数据 /// </summary> private void BindDataToPage() { EffectDBEntity XmlDB = Setting_EffectDB; if (!(XmlDB != null && String.IsNullOrEmpty(XmlDB.Name))) { lblEffectName.Text = XmlDB.Name; lblEffectDescription.Text = XmlDB.Description; //绑定效果的主题 String EffectDirPath = String.Format("{0}Effects/{1}/Themes/", Server.MapPath(ModulePath), XmlDB.Name); DirectoryInfo EffectDir = new DirectoryInfo(EffectDirPath); if (!EffectDir.Exists) { EffectDir.Create(); } DirectoryInfo[] ThemeDirs = EffectDir.GetDirectories(); List <KeyValueEntity> dirs = new List <KeyValueEntity>(); if (ThemeDirs != null && ThemeDirs.Length > 0) { foreach (DirectoryInfo dir in ThemeDirs) { KeyValueEntity dirEntity = new KeyValueEntity(); dirEntity.Key = dir.Name; FileInfo imgFile = new FileInfo(MapPath(String.Format("{0}Effects/{1}/Themes/{2}/image.jpg", ModulePath, XmlDB.Name, dir.Name))); if (imgFile.Exists) { dirEntity.Value = String.Format("{0}Effects/{1}/Themes/{2}/image.jpg", ModulePath, XmlDB.Name, dir.Name); } else { dirEntity.Value = String.Format("http://www.dnngo.net/DesktopModules/DNNGo_DNNGalleryPro/Effects/{0}/Themes/{1}/image.jpg", XmlDB.Name, dir.Name); } dirs.Add(dirEntity); } WebHelper.BindList <KeyValueEntity>(ddlThemeName, dirs, "Key", "Value"); } WebHelper.SelectedListByText(ddlThemeName, Settings_EffectThemeName); // hfThemeThumbnails.Value = String.Format("{0}Effects/{1}/Themes/[EffectThemeName]/image.jpg", ModulePath, XmlDB.Name); if (!String.IsNullOrEmpty(Settings_EffectThemeName)) { imgThemeThumbnails.Attributes.Add("onError", String.Format("this.src='{0}Resource/images/no_image.png'", ModulePath)); imgThemeThumbnails.ToolTip = Settings_EffectThemeName; KeyValueEntity dirEntity = dirs.Find(r1 => r1.Key.IndexOf(Settings_EffectThemeName, StringComparison.CurrentCultureIgnoreCase) >= 0); imgThemeThumbnails.ImageUrl = dirEntity != null?dirEntity.Value.ToString() : ""; imgThemeThumbnails.Visible = true; } } }
/// <summary> /// 绑定数据 /// </summary> private void BindDataToPage() { EffectDBEntity XmlDB = Setting_EffectDB; if (!(XmlDB != null && String.IsNullOrEmpty(XmlDB.Name))) { //绑定样式表到内容框 String StyleFile = Server.MapPath(String.Format("{0}Effects/{1}/Themes/{2}/Style.css", ModulePath, XmlDB.Name, Settings_EffectThemeName)); using (StreamReader m_streamReader = File.OpenText(StyleFile)) { this.txtContent.Value = m_streamReader.ReadToEnd(); m_streamReader.Close(); } } }
/// <summary> /// 页面加载 /// </summary> protected void Page_Init(object sender, EventArgs e) { try { if (!String.IsNullOrEmpty(Settings_EffectName)) { if (!String.IsNullOrEmpty(Settings_EffectThemeName)) { EffectDBEntity EffectDB = Setting_EffectDB; if (!IsPostBack) { //绑定数据项到前台 BindDataItem(EffectDB); } //是否支持谷歌地图 if (EffectDB.GoogleMap) { BindJavaScriptFile("GoogleMap", "https://maps.google.com/maps/api/js?sensor=false"); } //需要载入当前设置效果的主题CSS文件 String ThemeName = String.Format("{0}_{1}", Settings_EffectName, Settings_EffectThemeName); String ThemePath = String.Format("{0}Effects/{1}/Themes/{2}/Style.css", ModulePath, Settings_EffectName, Settings_EffectThemeName); BindStyleFile(ThemeName, ThemePath); //绑定效果中配置的样式和脚本 BindXmlDBToPage(EffectDB, "Effect"); } else { //未定义效果对应的主题 liContent.Text = ""; } } else { //未绑定效果 liContent.Text = ""; } } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex); } }
/// <summary> /// 绑定数据项到前台 /// </summary> public void BindDataItem(EffectDBEntity EffectDB) { Hashtable Puts = new Hashtable(); TemplateFormat xf = new TemplateFormat(this); xf.PhContent = PhContent; DNNGo_DNNGalleryPro_Slider SliderItem = DNNGo_DNNGalleryPro_Slider.FindByKeyForEdit(SliderID); Puts.Add("ThemeName", Settings_EffectThemeName); Puts.Add("SliderItem", SliderItem); Puts.Add("EffectName", Settings_EffectName); Puts.Add("LayerList", EffectDB.Layers ? GetLayerList() : new List <DNNGo_DNNGalleryPro_Layer>()); liContent.Text = HttpUtility.HtmlDecode(ViewTemplate(EffectDB, "Layer.html", Puts, xf)); }
/// <summary> /// 效果列表行绑定 /// </summary> protected void gvEffectList_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DirectoryInfo EffectDir = e.Row.DataItem as DirectoryInfo; if (!EffectDir.Exists) { EffectDir.Create(); } //获取效果数据的XML String EffectDBPath = String.Format("{0}\\EffectDB.xml", EffectDir.FullName); if (File.Exists(EffectDBPath)) { XmlFormat xf = new XmlFormat(EffectDBPath); EffectDBEntity EffectDB = xf.ToItem <EffectDBEntity>(); //构造图片的路径 Image imgPicture = e.Row.FindControl("imgPicture") as Image; imgPicture.Attributes.Add("onError", String.Format("this.src='{0}Resource/images/no_image.png'", ModulePath)); if (!String.IsNullOrEmpty(EffectDB.Thumbnails)) { if (EffectDB.Thumbnails.IndexOf("http://", StringComparison.CurrentCultureIgnoreCase) >= 0) { imgPicture.ImageUrl = EffectDB.Thumbnails; } else { imgPicture.ImageUrl = String.Format("{0}Effects/{1}/{2}", ModulePath, EffectDB.Name, EffectDB.Thumbnails); } } //构造效果标题描述 Label labName = e.Row.FindControl("labName") as Label; Label labDescription = e.Row.FindControl("labDescription") as Label; Label labVersion = e.Row.FindControl("labVersion") as Label; labName.Text = EffectDB.Name; labDescription.Text = EffectDB.Description; labVersion.Text = EffectDB.Version; //演示地址 if (!String.IsNullOrEmpty(EffectDB.DemoUrl)) { Literal LiDemoUrl = e.Row.FindControl("LiDemoUrl") as Literal; LiDemoUrl.Text = String.Format("<a href=\"{0}\" target=\"_blank\" class=\"btn btn-default btn-sm\"><i class=\"fa clip-link\"></i> {1}</a>", EffectDB.DemoUrl, ViewResourceText("labDemoUrl", "Demo Url")); } //响应式 if (EffectDB.Responsive) { Literal LiResponsive = e.Row.FindControl("LiResponsive") as Literal; LiResponsive.Text = String.Format("<a class=\"btn btn-default btn-sm\"><i class=\"fa clip-embed\"></i> {0}</a>", ViewResourceText("labResponsive", "Responsive")); } //带分页 if (EffectDB.Pager) { Literal LiPager = e.Row.FindControl("LiPager") as Literal; LiPager.Text = String.Format("<a class=\"btn btn-default btn-sm\"><i class=\"fa clip-arrow-3\"></i> {0}</a>", ViewResourceText("labPager", "Pager")); } if (EffectDB.Layers) { Literal LiLayers = e.Row.FindControl("LiLayers") as Literal; LiLayers.Text = String.Format("<a class=\"btn btn-default btn-sm\"><i class=\"fa clip-stack\"></i> {0}</a>", ViewResourceText("labLayers", "Layers")); } if (EffectDB.Ajax) { Literal LiAjax = e.Row.FindControl("LiAjax") as Literal; LiAjax.Text = String.Format("<a class=\"btn btn-default btn-sm\"><i class=\"fa fa-globe\"></i> {0}</a>", ViewResourceText("labAjax", "Ajax")); } if (EffectDB.Groups) { Literal LiGroups = e.Row.FindControl("LiGroups") as Literal; LiGroups.Text = String.Format("<a class=\"btn btn-default btn-sm\"><i class=\"fa fa-group\"></i> {0}</a>", ViewResourceText("labGroups", "Groups")); } if (EffectDB.Downloads) { Literal liDownloads = e.Row.FindControl("liDownloads") as Literal; liDownloads.Text = String.Format("<a class=\"btn btn-default btn-sm\"><i class=\"fa clip-folder-download\"></i> {0}</a>", ViewResourceText("labDownloads", "Downloads")); } //应用效果的按钮 LinkButton btnApply = e.Row.FindControl("btnApply") as LinkButton; HyperLink hlThemeName = e.Row.FindControl("hlThemeName") as HyperLink; btnApply.CommandArgument = EffectDB.Name; if (!String.IsNullOrEmpty(Settings_EffectName) && Settings_EffectName == EffectDB.Name)//判断设置效果是否为当前效果 { btnApply.Text = String.Format("<i class=\"fa fa-stop\"></i> {1}", ModulePath, Localization.GetString("btnApply_Stop", this.LocalResourceFile)); btnApply.Enabled = false; btnApply.CssClass = "btn btn-danger"; hlThemeName.Text = String.Format("<i class=\"fa clip-cogs\"></i> {0}", Settings_EffectThemeName); hlThemeName.NavigateUrl = xUrl("Effect_Options"); } else { btnApply.Text = String.Format("<i class=\"fa fa-play-circle-o\"></i> {1}", ModulePath, Localization.GetString("btnApply_Play", this.LocalResourceFile)); btnApply.CssClass = "btn btn-success"; hlThemeName.Visible = false; } } else { e.Row.Visible = false; } } }
/// <summary> /// 绑定数据项到前台 /// </summary> public void BindDataItem(EffectDBEntity EffectDB) { List <DNNGo_DNNGalleryPro_Slider> SliderList = new List <DNNGo_DNNGalleryPro_Slider>(); Hashtable Puts = new Hashtable(); TemplateFormat xf = new TemplateFormat(this); xf.PhContent = PhContent; //读取需要载入的参数 QueryParam qp = new QueryParam(); qp = BindSearch(qp); int RecordCount = 0; qp.OrderType = 0; if (EffectDB.Pager)//传入分页的数量 { qp.PageSize = xf.ViewXmlSettingT <Int32>("PageSize", 9999); qp.PageSize = qp.PageSize <= 0 ? 9999 : qp.PageSize; qp.PageIndex = PageIndex; Puts.Add("PageIndex", PageIndex); } if (String.IsNullOrEmpty(SortName)) { if (Settings_Sortby == (Int32)EnumSortby.Time) { qp.Orderfld = DNNGo_DNNGalleryPro_Slider._.StartTime; SliderList = DNNGo_DNNGalleryPro_Slider.FindAll(qp, out RecordCount); } else if (Settings_Sortby == (Int32)EnumSortby.Time_Desc) { qp.OrderType = 1; qp.Orderfld = DNNGo_DNNGalleryPro_Slider._.StartTime; SliderList = DNNGo_DNNGalleryPro_Slider.FindAll(qp, out RecordCount); } else if (Settings_Sortby == (Int32)EnumSortby.Title) { qp.Orderfld = DNNGo_DNNGalleryPro_Slider._.Title; SliderList = DNNGo_DNNGalleryPro_Slider.FindAll(qp, out RecordCount); } else if (Settings_Sortby == (Int32)EnumSortby.Title_Desc) { qp.OrderType = 1; qp.Orderfld = DNNGo_DNNGalleryPro_Slider._.Title; SliderList = DNNGo_DNNGalleryPro_Slider.FindAll(qp, out RecordCount); } else if (Settings_Sortby == (Int32)EnumSortby.Random) { qp.Orderfld = " newid() "; SliderList = DNNGo_DNNGalleryPro_Slider.FindRandomAll(qp, out RecordCount); } else { qp.Orderfld = DNNGo_DNNGalleryPro_Slider._.Sort; SliderList = DNNGo_DNNGalleryPro_Slider.FindAll(qp, out RecordCount); } } else { qp.OrderType = SortType; qp.Orderfld = SortName; SliderList = DNNGo_DNNGalleryPro_Slider.FindAll(qp, out RecordCount); } Puts.Add("ThemeName", Settings_EffectThemeName); Puts.Add("SliderList", SliderList); Puts.Add("EffectName", Settings_EffectName); Puts.Add("SortName", SortName); Puts.Add("SortType", SortType); if (Settings_Sortby == (Int32)EnumSortby.Random) { Puts.Add("IsRandom", true); } else { Puts.Add("IsRandom", false); } //是否开启分组 Puts.Add("GroupList", EffectDB.Groups ? GetGroupList() : new List <DNNGo_DNNGalleryPro_Group>()); Puts.Add("GroupID", GroupID); //Puts.Add("LayerList", EffectDB.Layers ? GetLayerList() : new List<DNNGo_DNNGalleryPro_Layer>()); if (EffectDB.Pager && RecordCount > qp.PageSize) { Puts.Add("Pager", new Pager(qp.PageIndex, qp.PageSize, Settings_ModuleID, RecordCount, EnumPageType.DnnURL).CreateHtml());//分页 } else { Puts.Add("Pager", ""); } liContent.Text = ViewTemplate(EffectDB, "Effect.html", Puts, xf); }
/// <summary> /// Layer列表的HTML生成 /// </summary> public void PushAjaxSliders() { EffectDBEntity EffectDB = Setting_EffectDB; QueryParam qp = new QueryParam(); qp.OrderType = 0; qp.PageIndex = WebHelper.GetIntParam(Request, "PageIndex", 2); if (qp.PageIndex <= 1) { qp.PageSize = WebHelper.GetIntParam(Request, "FirstScreen", 10); if (qp.PageSize <= 0) { qp.PageSize = WebHelper.GetIntParam(Request, "LoadDisplay", 10); } } else { qp.PageSize = WebHelper.GetIntParam(Request, "LoadDisplay", 10); qp.FirstScreen = WebHelper.GetIntParam(Request, "FirstScreen", 10); } qp.Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Slider._.ModuleId, Settings_ModuleID, SearchType.Equal)); qp.Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Slider._.Status, (Int32)EnumStatus.Activated, SearchType.Equal)); Int32 Search_GroupID = WebHelper.GetIntParam(HttpContext.Current.Request, "GroupID", 0); if (Search_GroupID > 0) { qp.Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Slider._.ID, DNNGo_DNNGalleryPro_Slider_Group.BuilderArticleIDs(Search_GroupID), SearchType.In)); } int RecordCount = 0; List <DNNGo_DNNGalleryPro_Slider> SliderList = new List <DNNGo_DNNGalleryPro_Slider>(); Int32 Sortby = Settings_Sortby; String Orderfld = WebHelper.GetStringParam(Request, "Order", ""); Int32 OrderType = WebHelper.GetIntParam(Request, "OrderBy", -1); if (!String.IsNullOrEmpty(Orderfld)) { if (Orderfld.ToLower() == "title") { Sortby = OrderType == 1 ? (Int32)EnumSortby.Title_Desc : (Int32)EnumSortby.Title; } else if (Orderfld.ToLower() == "starttime") { Sortby = OrderType == 1 ? (Int32)EnumSortby.Time_Desc : (Int32)EnumSortby.Time; } } if (Sortby == (Int32)EnumSortby.Time) { qp.Orderfld = DNNGo_DNNGalleryPro_Slider._.StartTime; SliderList = DNNGo_DNNGalleryPro_Slider.FindAll(qp, out RecordCount); } else if (Sortby == (Int32)EnumSortby.Time_Desc) { qp.OrderType = 1; qp.Orderfld = DNNGo_DNNGalleryPro_Slider._.StartTime; SliderList = DNNGo_DNNGalleryPro_Slider.FindAll(qp, out RecordCount); } else if (Sortby == (Int32)EnumSortby.Title) { qp.Orderfld = DNNGo_DNNGalleryPro_Slider._.Title; SliderList = DNNGo_DNNGalleryPro_Slider.FindAll(qp, out RecordCount); } else if (Sortby == (Int32)EnumSortby.Title_Desc) { qp.OrderType = 1; qp.Orderfld = DNNGo_DNNGalleryPro_Slider._.Title; SliderList = DNNGo_DNNGalleryPro_Slider.FindAll(qp, out RecordCount); } else if (Sortby == (Int32)EnumSortby.Random) { qp.Orderfld = " newid() "; SliderList = DNNGo_DNNGalleryPro_Slider.FindRandomAll(qp, out RecordCount); } else { qp.Orderfld = DNNGo_DNNGalleryPro_Slider._.Sort; SliderList = DNNGo_DNNGalleryPro_Slider.FindAll(qp, out RecordCount); } if (qp.Pages < qp.PageIndex) //索引数大于总页面数时不返回记录 { SliderList = new List <DNNGo_DNNGalleryPro_Slider>(); } Dictionary <String, Object> jsonSliders = new Dictionary <string, Object>(); TemplateFormat xf = new TemplateFormat(); foreach (var SliderItem in SliderList) { int index = SliderList.IndexOf(SliderItem); //index 为索引值 Dictionary <String, Object> jsonSlider = new Dictionary <String, Object>(); jsonSlider.Add("ID", SliderItem.ID); jsonSlider.Add("Sort", SliderItem.Sort); jsonSlider.Add("CreateTime", SliderItem.CreateTime); jsonSlider.Add("StartTime", SliderItem.StartTime); jsonSlider.Add("EndTime", SliderItem.EndTime); jsonSlider.Add("CreateTimeUS", SliderItem.CreateTime.ToString("MM/dd/yyy HH:mm:ss")); jsonSlider.Add("StartTimeUS", SliderItem.StartTime.ToString("MM/dd/yyy HH:mm:ss")); jsonSlider.Add("EndTimeUS", SliderItem.EndTime.ToString("MM/dd/yyy HH:mm:ss")); jsonSlider.Add("Status", SliderItem.Status == 1 ? "checked=\"checked\"" : ""); jsonSlider.Add("Pages", qp.Pages); foreach (var SliderSetting in Setting_SliderSettingDB) { String SliderName = SliderSetting.Name; String SliderValue = xf.ViewSliderSettingT <String>(SliderItem, SliderName, SliderSetting.DefaultValue); if (SliderSetting.ControlType == EnumControlType.Urls.ToString()) { jsonSlider.Add(SliderName, ViewLinkUrl(SliderValue, false)); } else { jsonSlider.Add(SliderName, SliderValue); } } //加载分组 if (EffectDB.Groups) { jsonSlider.Add("Groups", xf.ToGroups(SliderItem)); } //取出Layers数据 if (EffectDB.Layers) { Dictionary <String, Object> jsonLayers = new Dictionary <String, Object>(); List <DNNGo_DNNGalleryPro_Layer> LayerList = SliderItem.LayerList; if (LayerList != null && LayerList.Count > 0) { foreach (var Layer in LayerList) { int indexLayer = LayerList.IndexOf(Layer); Dictionary <String, Object> jsonLayer = new Dictionary <String, Object>(); foreach (var LayerSetting in Setting_LayerSettingDB) { String LayerName = LayerSetting.Name; String LayerValue = xf.ViewLayerSettingT <String>(Layer, LayerName, LayerSetting.DefaultValue); if (LayerSetting.ControlType == EnumControlType.Urls.ToString()) { jsonLayer.Add(LayerName, ViewLinkUrl(LayerValue, false)); } else { jsonLayer.Add(LayerName, LayerValue); } } jsonLayer.Add("ID", Layer.ID); jsonLayer.Add("Sort", Layer.Sort); jsonLayer.Add("Clicks", Layer.Clicks); jsonLayer.Add("Views", Layer.Views); jsonLayer.Add("Heats", Layer.Heats); jsonLayer.Add("CreateTime", Layer.CreateTime); jsonLayers.Add((10000 - indexLayer).ToString(), jsonLayer); } } jsonSlider.Add("Layers", jsonLayers); } //取出扩展项 Dictionary <String, Object> jsonExtension = new Dictionary <String, Object>(); if (!String.IsNullOrEmpty(SliderItem.Extension)) { List <KeyValueEntity> ExtensionSettings = ConvertTo.Deserialize <List <KeyValueEntity> >(SliderItem.Extension); foreach (KeyValueEntity kv in ExtensionSettings) { if (!jsonExtension.ContainsKey(kv.Key)) { jsonExtension.Add(kv.Key, kv.Value); } } } jsonSlider.Add("Extensions", jsonExtension); jsonSliders.Add(index.ToString(), jsonSlider); } //转换数据为json JavaScriptSerializer jsSerializer = new JavaScriptSerializer(); Response.Clear(); Response.Write(jsSerializer.Serialize(jsonSliders)); Response.End(); }