using framework_business; using framework_library; using System; using System.Collections; using System.Collections.Generic; using System.Configuration; using System.Linq; using System.Reflection; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class controls_module_content : ICanvasBase { private const string imagePath = "../upload/gallery/image/"; /// /// PAge Load Event /// /// /// protected void Page_Load(object sender, EventArgs e) { try { /* CVH 2016-04-07 Replace {WebAddress} and image links */ string content = ""; string contentName = ""; oCanvas canvas = new oCanvas(); if (base.CanvasContent != null) canvas = base.CanvasContent; else { string canvasTitle = handler.GetRoutedData("canvas-title"); foreach (oCanvas canvasFromTitle in xData.GetTypedByCriteriaSpecific("recId", typeof(oCanvas), "name", canvasTitle)) { canvas = canvasFromTitle; } } foreach (oCanvasMetaData met in xData.GetTypedByCriteriaSpecific("recId", typeof(oCanvasMetaData), "canvasId", canvas.recId.ToString())) { if (met.moduleId == pNums.Module.Content.GetHashCode()) { foreach (oContent page in xData.GetTypedByCriteriaSpecific("recId", typeof(oContent), "recId", met.entityId.ToString())) { content = page.contentHTML; contentName = page.title; } break; } } content = content.Replace("{WebAddress}", ConfigurationManager.AppSettings["WebAddy"]); //image reference in content html and gallery title will be content page title with a sequential number starting with 1. do until number not found (max 100) //html image reference cannot contain &, but title will. //eg. Html ref = "{Publications Testimonials 1}". oGallery.title = "Publications & Testimonials 1". int i = 1; bool found = true; do { found = false; string imageName = contentName + " " + i; ArrayList imgList = xData.GetTypedByCriteriaSpecific("recId", typeof(oGallery), "title,isActive", imageName + ",1"); if (imgList != null && imgList.Count > 0) { found = true; oGallery img = (oGallery)imgList[0]; //get image type string type = ""; foreach (pNums.PictureType typ in Enum.GetValues(typeof(pNums.PictureType))) { if ((int)typ == img.pictureTypeId) type = typ.ToString(); } content = content.Replace("{" + imageName.Replace(" &", "") + "}", imagePath + type + "/" + img.fileName); } i++; } while (i <= 100 && found); lblContent.Text = content; } catch (Exception ex) { //Handle Exception exception.HandleException("content:", MethodBase.GetCurrentMethod().Name, ex, 0); //Redirect to Error Page Response.Redirect("/error", false); } } }