protected override void RenderContents(HtmlTextWriter output) { var partialString = string.Empty; var gallery = new BetterImageGalleryService(ModuleId); gallery.Setup(); if (gallery.Error != null) { partialString = RazorBridge.RenderPartialToString(new RazorBridgePartialModel { CustomTemplate = "_BetterImageGallery_Error", DefaultTemplate = "_BetterImageGallery_Error", Controller = "BetterImageGallery", Data = gallery.Error, Page = Page }); } else { var items = gallery.GetImages(); partialString = RazorBridge.RenderPartialToString(new RazorBridgePartialModel { CustomTemplate = BigConfig.Layout, DefaultTemplate = "_BetterImageGallery", Controller = "BetterImageGallery", Data = items, Page = Page }); } output.Write(partialString); }
private void PopulateControls() { try { litMenu.Text = RazorBridge.RenderPartialToString(partialName, model, "Admin"); } catch (System.Web.HttpException ex) { log.Error($"layout ({partialName}) was not found in skin {SiteUtils.GetSkinBaseUrl(true, Page)}. perhaps it is in a different skin. Error was: {ex}"); } }
protected override void RenderContents(HtmlTextWriter output) { var dsBlogs = Blog.GetPageDataSet(config.BlogModuleId, DateTime.UtcNow, pageNumber, pageSize, out totalPages); StringBuilder posts = new StringBuilder(); //List<Blog> blogs = new List<Blog>(); List <BlogPostModel> models = new List <BlogPostModel>(); foreach (DataRow postRow in dsBlogs.Tables["posts"].Rows) { BlogPostModel model = new BlogPostModel(); if (useFriendlyUrls && (postRow["ItemUrl"].ToString().Length > 0)) { model.ItemUrl = postRow["ItemUrl"].ToString().Replace("~", string.Empty); } else { model.ItemUrl = postRow["ItemID"].ToString() + "&mid=" + postRow["ModuleID"].ToString(); } model.Title = postRow["Heading"].ToString(); model.SubTitle = postRow["SubTitle"].ToString(); model.Body = postRow["Description"].ToString(); model.AuthorAvatar = postRow["AvatarUrl"].ToString(); model.AuthorDisplayName = postRow["Name"].ToString(); model.AuthorFirstName = postRow["FirstName"].ToString(); model.AuthorLastName = postRow["LastName"].ToString(); model.AuthorBio = postRow["AuthorBio"].ToString(); model.Excerpt = postRow["Abstract"].ToString(); model.PostDate = Convert.ToDateTime(postRow["StartDate"].ToString()); model.HeadlineImageUrl = postRow["HeadlineImageUrl"].ToString(); model.CommentCount = Convert.ToInt32(postRow["CommentCount"]); model.AllowCommentsForDays = Convert.ToInt32(postRow["AllowCommentsForDays"]); model.ShowAuthorName = Convert.ToBoolean(postRow["ShowAuthorName"]); model.ShowAuthorAvatar = Convert.ToBoolean(postRow["ShowAuthorAvatar"]); model.ShowAuthorBio = Convert.ToBoolean(postRow["ShowAuthorBio"]); models.Add(model); } string text = string.Empty; try { text = RazorBridge.RenderPartialToString(config.Layout, models, "Blog"); } catch (System.Web.HttpException ex) { log.ErrorFormat("chosen layout ({0}) for _BlogPostList was not found in skin {1}. perhaps it is in a different skin. Error was: {2}", config.Layout, SiteUtils.GetSkinBaseUrl(true, this.Page), ex); text = RazorBridge.RenderPartialToString("_BlogPostList", models, "Blog"); } output.Write(text); }
private void PopulateControls() { Title = SiteUtils.FormatPageTitle(siteSettings, Resource.MemberListLink); if ((Page.Header != null) && (CurrentPage.Url.Length > 0)) { Literal link = new Literal { ID = "pageurl", Text = $"\n<link rel='canonical' href='{SiteRoot}/MemberList.aspx' />" }; Page.Header.Controls.Add(link); } if (canManageUsers && showUnApproved) { BindNotApprovedUsers(); } else if (canManageUsers && showLocked) { BindLockedUsers(); } else if (searchText.Length > 0 || ipSearchText.Length > 0) { BindForSearch(); } else { BindAlphaList(); } if (pageNumber > totalPages) { pageNumber = 1; } PopulateModel(); try { theLit.Text = RazorBridge.RenderPartialToString("MemberList", model, "Shared"); } catch (HttpException ex) { log.Error($"layout (MemberList) was not found in skin {SiteUtils.GetSkinBaseUrl(true, Page)}. perhaps it is in a different skin. Error was: {ex}"); } }
private void PopulateControls() { var letterInfoList = LetterInfo.GetAll(siteSettings.SiteGuid); try { litLetters.Text = RazorBridge.RenderPartialToString("_Admin", letterInfoList, "eletter"); } catch (System.Web.HttpException ex) { log.ErrorFormat( "layout for Newsletter _Admin was not found in skin {0}. perhaps it is in a different skin. Error was: {1}", SiteUtils.GetSkinBaseUrl(true, Page), ex ); } }
protected void Page_Load(object sender, EventArgs e) { AdditionalContentList model = new AdditionalContentList { GlobalContent = Module.GetGlobalContent(CacheHelper.GetCurrentSiteSettings().SiteId), ChosenContent = JsonConvert.DeserializeObject(hdnChosenModules.Value) as List <ChosenContent>, LocationOptions = new Dictionary <string, int> { { "AbovePosts", 0 }, { "BelowPosts", 1 }, { "AboveNav", 2 }, { "BelowNav", 3 } } }; try { litGlobalContentList.Text = RazorBridge.RenderPartialToString("_AdditionalContentList", model, "Admin"); } catch (System.Web.HttpException ex) { log.Error($"layout (_AdditionalContentList) was not found in skin {SiteUtils.GetSkinBaseUrl(true, Page)}. perhaps it is in a different skin. Error was: {ex}"); } }
private void PopulateControls() { string featuredImageUrl = string.Empty; featuredImageUrl = String.IsNullOrWhiteSpace(config.InstanceFeaturedImage) ? featuredImageUrl : SiteUtils.GetNavigationSiteRoot() + config.InstanceFeaturedImage; //dynamic expando = new ExpandoObject(); var itemModels = new List <dynamic>(); //var model = expando as IDictionary<string, object>; WidgetModel model = new WidgetModel(); model.ModuleGuid = module.ModuleGuid; model.ModuleId = module.ModuleId; model.ModuleTitle = module.ModuleTitle; model.ModuleFriendlyName = config.ModuleFriendlyName; model.SortDescending = config.DescendingSort; model.GlobalView = config.IsGlobalView; model.GlobalViewSortOrder = config.GlobalViewSortOrder; model.Header = config.HeaderContent; model.Footer = config.FooterContent; model.FeaturedImage = featuredImageUrl; model.PageId = pageSettings.PageId; model.PageUrl = pageSettings.Url; model.PageName = pageSettings.PageName; //dynamic dModel = model; foreach (Item item in items) { bool itemIsEditable = isEditable || WebUser.IsInRoles(item.EditRoles); bool itemIsViewable = WebUser.IsInRoles(item.ViewRoles) || itemIsEditable; if (!itemIsViewable) { continue; } string itemEditUrl = SiteUtils.GetNavigationSiteRoot() + "/SuperFlexi/Edit.aspx?pageid=" + pageId + "&mid=" + item.ModuleID + "&itemid=" + item.ItemID; //var itemModel = new ItemModel(); //itemModel.Id = item.ItemID; //itemModel.Guid = item.ItemGuid; //itemModel.SortOrder = item.SortOrder; //itemModel.EditUrl = itemEditUrl; dynamic itemModel = new ExpandoObject(); itemModel.Id = item.ItemID; itemModel.Guid = item.ItemGuid; itemModel.SortOrder = item.SortOrder; itemModel.EditUrl = itemEditUrl; //var itemModel = localexpando as IDictionary<string, object>; //itemModel.Add("Id", item.ItemID); //itemModel.Add("Guid", item.ItemGuid); //itemModel.Add("SortOrder", item.SortOrder); //itemModel.Add("EditUrl", itemEditUrl); List <ItemFieldValue> fieldValues = ItemFieldValue.GetItemValues(item.ItemGuid); //using item.ModuleID here because if we are using a 'global view' we need to be sure the item edit link uses the correct module id. //string itemEditLink = itemIsEditable ? String.Format(displaySettings.ItemEditLinkFormat, itemEditUrl) : string.Empty; foreach (Field field in fields) { foreach (ItemFieldValue fieldValue in fieldValues) { if (field.FieldGuid == fieldValue.FieldGuid) { ((IDictionary <String, String>)itemModel)[field.Name] = fieldValue.FieldValue; //var thisItem = itemModel; //itemModel.AddProperty(field.Name.ToString(), fieldValue.FieldValue); //itemModel = thisItem; //dItemModel[field.Name.ToString()] = fieldValue.FieldValue; //itemModel.Add(field.Name.ToString(), fieldValue.FieldValue); } } } itemModels.Add(itemModel); } //dModel["Items"] = itemModels; model.Items = itemModels; //model.AddProperty("Items", itemModels); //theLit.Text = RazorBridge.RenderPartialToString("_SuperFlexiRazor", model, "SuperFlexi"); theLit.Text = RazorBridge.RenderPartialToString("_SuperFlexiRazor", model, "SuperFlexi"); }
protected override void RenderContents(HtmlTextWriter output) { string featuredImageUrl = string.Empty; featuredImageUrl = String.IsNullOrWhiteSpace(config.InstanceFeaturedImage) ? featuredImageUrl : SiteUtils.GetNavigationSiteRoot() + config.InstanceFeaturedImage; //dynamic expando = new ExpandoObject(); var superFlexiItemClass = CreateClass(); var itemModels = new List <object> (); //var model = expando as IDictionary<string, object>; WidgetModel model = new WidgetModel { Module = new ModuleModel { Id = module.ModuleId, Guid = module.ModuleGuid, Title = module.ModuleTitle, TitleElement = module.HeadElement }, Config = Config, Page = new PageModel { Id = CurrentPage.PageId, Url = CurrentPage.Url, Name = CurrentPage.PageName }, Site = new SiteModel { Id = module.SiteId, SkinPath = SiteUtils.DetermineSkinBaseUrl(SiteUtils.GetSkinName(true, this.Page)) }, SiteRoot = SiteUtils.GetNavigationSiteRoot() }; //dynamic dModel = model; foreach (Item item in items) { var itemObject = Activator.CreateInstance(superFlexiItemClass); bool itemIsEditable = IsEditable || WebUser.IsInRoles(item.EditRoles); bool itemIsViewable = WebUser.IsInRoles(item.ViewRoles) || itemIsEditable; if (!itemIsViewable) { continue; } string itemEditUrl = SiteUtils.GetNavigationSiteRoot() + "/SuperFlexi/Edit.aspx?pageid=" + PageId + "&mid=" + item.ModuleID + "&itemid=" + item.ItemID; SetItemClassProperty(itemObject, "Id", item.ItemID); SetItemClassProperty(itemObject, "Guid", item.ItemGuid); SetItemClassProperty(itemObject, "SortOrder", item.SortOrder); SetItemClassProperty(itemObject, "EditUrl", itemEditUrl); //dynamic itemModel = new ExpandoObject(); //itemModel.Id = item.ItemID; //itemModel.Guid = item.ItemGuid; //itemModel.SortOrder = item.SortOrder; //itemModel.EditUrl = itemEditUrl; List <ItemFieldValue> fieldValues = ItemFieldValue.GetItemValues(item.ItemGuid); //foreach (Field field in fields) //{ // foreach (ItemFieldValue fieldValue in fieldValues) // { // if (field.FieldGuid == fieldValue.FieldGuid) // { // if (field.ControlType == "CheckBox") // { // ((IDictionary<string, object>)itemModel)[field.Name] = Convert.ToBoolean(fieldValue.FieldValue); // } // ((IDictionary<string, object>)itemModel)[field.Name] = fieldValue.FieldValue; // } // } //} //var itemModel = new //{ // Id = item.ItemID, // Guid = item.ItemGuid, // SortOrder = item.SortOrder, // EditUrl = itemEditUrl, //}; foreach (Field field in fields) { foreach (ItemFieldValue fieldValue in fieldValues) { if (field.FieldGuid == fieldValue.FieldGuid) { switch (field.ControlType) { case "CheckBox": SetItemClassProperty(itemObject, field.Name, Convert.ToBoolean(fieldValue.FieldValue)); break; case "CheckBoxList": case "DynamicCheckBoxList": SetItemClassProperty(itemObject, field.Name, fieldValue.FieldValue.SplitOnCharAndTrim(';')); break; case "DateTime": case "Date": if (!string.IsNullOrWhiteSpace(fieldValue.FieldValue)) { DateTime.TryParse(fieldValue.FieldValue, out DateTime dt); SetItemClassProperty(itemObject, field.Name, dt); } break; case "TextBox": default: SetItemClassProperty(itemObject, field.Name, fieldValue.FieldValue); break; } } } } itemModels.Add(itemObject); } model.Items = itemModels; var viewPath = config.RelativeSolutionLocation + "/" + config.ViewName; string text; try { text = RazorBridge.RenderPartialToString(viewPath, model, "SuperFlexi"); } catch (Exception ex) { renderDefaultView(ex.ToString()); } void renderDefaultView(string error = "") { if (!string.IsNullOrWhiteSpace(error)) { log.ErrorFormat( "chosen layout ({0}) for _SuperFlexiRazor was not found in skin {1} or SuperFlexi Solution. Perhaps it is in a different skin or Solution. Error was: {2}", config.ViewName, SiteUtils.GetSkinBaseUrl(true, Page), error ); } text = RazorBridge.RenderPartialToString("_SuperFlexiRazor", model, "SuperFlexi"); } output.Write(text); }
protected override void RenderContents(HtmlTextWriter output) { DataSet dsBlogs = null; // Check for Featured Post, if it exists grab one less post to keep the count correct if (blogConfig.FeaturedPostId == 0) { dsBlogs = Blog.GetPageDataSet(config.BlogModuleId, DateTime.UtcNow, pageNumber, pageSize, out totalPages); } else { dsBlogs = Blog.GetPageDataSet(config.BlogModuleId, DateTime.UtcNow, pageNumber, (pageSize - 1), out totalPages); } DataRow featuredRow = dsBlogs.Tables["Posts"].NewRow(); if (blogConfig.FeaturedPostId != 0 && pageNumber == 1) { using (IDataReader reader = Blog.GetSingleBlog(blogConfig.FeaturedPostId)) { while (reader.Read()) { featuredRow["ItemID"] = Convert.ToInt32(reader["ItemID"]); featuredRow["ModuleID"] = Convert.ToInt32(reader["ModuleID"]); featuredRow["BlogGuid"] = reader["BlogGuid"].ToString(); featuredRow["CreatedDate"] = Convert.ToDateTime(reader["CreatedDate"]); featuredRow["Heading"] = reader["Heading"].ToString(); featuredRow["SubTitle"] = reader["SubTitle"].ToString(); featuredRow["StartDate"] = Convert.ToDateTime(reader["StartDate"]); featuredRow["Description"] = reader["Description"].ToString(); featuredRow["Abstract"] = reader["Abstract"].ToString(); featuredRow["ItemUrl"] = reader["ItemUrl"].ToString(); featuredRow["Location"] = reader["Location"].ToString(); featuredRow["MetaKeywords"] = reader["MetaKeywords"].ToString(); featuredRow["MetaDescription"] = reader["MetaDescription"].ToString(); featuredRow["LastModUtc"] = Convert.ToDateTime(reader["LastModUtc"]); featuredRow["IsPublished"] = true; featuredRow["IncludeInFeed"] = Convert.ToBoolean(reader["IncludeInFeed"]); featuredRow["CommentCount"] = Convert.ToInt32(reader["CommentCount"]); featuredRow["CommentCount"] = 0; featuredRow["UserID"] = Convert.ToInt32(reader["UserID"]); featuredRow["UserID"] = -1; featuredRow["Name"] = reader["Name"].ToString(); featuredRow["FirstName"] = reader["FirstName"].ToString(); featuredRow["LastName"] = reader["LastName"].ToString(); featuredRow["LoginName"] = reader["LoginName"].ToString(); featuredRow["Email"] = reader["Email"].ToString(); featuredRow["AvatarUrl"] = reader["AvatarUrl"].ToString(); featuredRow["AuthorBio"] = reader["AuthorBio"].ToString(); featuredRow["AllowCommentsForDays"] = Convert.ToInt32(reader["AllowCommentsForDays"]); if (reader["ShowAuthorName"] != DBNull.Value) { featuredRow["ShowAuthorName"] = Convert.ToBoolean(reader["ShowAuthorName"]); } else { featuredRow["ShowAuthorName"] = true; } if (reader["ShowAuthorAvatar"] != DBNull.Value) { featuredRow["ShowAuthorAvatar"] = Convert.ToBoolean(reader["ShowAuthorAvatar"]); } else { featuredRow["ShowAuthorAvatar"] = true; } if (reader["ShowAuthorBio"] != DBNull.Value) { featuredRow["ShowAuthorBio"] = Convert.ToBoolean(reader["ShowAuthorBio"]); } else { featuredRow["ShowAuthorBio"] = true; } if (reader["UseBingMap"] != DBNull.Value) { featuredRow["UseBingMap"] = Convert.ToBoolean(reader["UseBingMap"]); } else { featuredRow["UseBingMap"] = false; } featuredRow["MapHeight"] = reader["MapHeight"].ToString(); featuredRow["MapWidth"] = reader["MapWidth"].ToString(); featuredRow["MapType"] = reader["MapType"].ToString(); if (reader["MapZoom"] != DBNull.Value) { featuredRow["MapZoom"] = Convert.ToInt32(reader["MapZoom"]); } else { featuredRow["MapZoom"] = 13; } if (reader["ShowMapOptions"] != DBNull.Value) { featuredRow["ShowMapOptions"] = Convert.ToBoolean(reader["ShowMapOptions"]); } else { featuredRow["ShowMapOptions"] = false; } if (reader["ShowZoomTool"] != DBNull.Value) { featuredRow["ShowZoomTool"] = Convert.ToBoolean(reader["ShowZoomTool"]); } else { featuredRow["ShowZoomTool"] = false; } if (reader["ShowLocationInfo"] != DBNull.Value) { featuredRow["ShowLocationInfo"] = Convert.ToBoolean(reader["ShowLocationInfo"]); } else { featuredRow["ShowLocationInfo"] = false; } if (reader["UseDrivingDirections"] != DBNull.Value) { featuredRow["UseDrivingDirections"] = Convert.ToBoolean(reader["UseDrivingDirections"]); } else { featuredRow["UseDrivingDirections"] = false; } if (reader["ShowDownloadLink"] != DBNull.Value) { featuredRow["ShowDownloadLink"] = Convert.ToBoolean(reader["ShowDownloadLink"]); } else { featuredRow["ShowDownloadLink"] = false; } featuredRow["HeadlineImageUrl"] = reader["HeadlineImageUrl"].ToString(); if (reader["IncludeImageInExcerpt"] != DBNull.Value) { featuredRow["IncludeImageInExcerpt"] = Convert.ToBoolean(reader["IncludeImageInExcerpt"]); } else { featuredRow["IncludeImageInExcerpt"] = true; } if (reader["IncludeImageInPost"] != DBNull.Value) { featuredRow["IncludeImageInPost"] = Convert.ToBoolean(reader["IncludeImageInPost"]); } else { featuredRow["IncludeImageInPost"] = true; } } } } //look for featured post in datable DataRow found = dsBlogs.Tables["Posts"].Rows.Find(blogConfig.FeaturedPostId); if (found != null) { //remove featured post from datatable so we can insert it at the top if we're on "page" number 1 dsBlogs.Tables["Posts"].Rows.Remove(found); } if (blogConfig.FeaturedPostId != 0 && pageNumber == 1) { //insert the featured post into the datatable at the top //we only want to do this if the current "page" is number 1, don't want the featured post on other pages. dsBlogs.Tables["Posts"].Rows.InsertAt(featuredRow, 0); } List <PageModule> pageModules = PageModule.GetPageModulesByModule(config.BlogModuleId); string blogPageUrl = string.Empty; if (pageModules.Count > 0) { blogPageUrl = pageModules[0].PageUrl; } List <BlogPostModel> models = new List <BlogPostModel>(); foreach (DataRow postRow in dsBlogs.Tables["posts"].Rows) { BlogPostModel model = new BlogPostModel(); if (useFriendlyUrls && (postRow["ItemUrl"].ToString().Length > 0)) { model.ItemUrl = navigationSiteRoot + postRow["ItemUrl"].ToString().Replace("~", string.Empty); } else { model.ItemUrl = postRow["ItemID"].ToString() + "&mid=" + postRow["ModuleID"].ToString(); } if (blogConfig.FeaturedPostId == Convert.ToInt32(postRow["ItemID"]) && pageNumber == 1) { model.FeaturedPost = true; } else { model.FeaturedPost = false; } model.Title = postRow["Heading"].ToString(); model.SubTitle = postRow["SubTitle"].ToString(); model.Body = postRow["Description"].ToString(); model.AuthorAvatar = postRow["AvatarUrl"].ToString(); model.AuthorDisplayName = postRow["Name"].ToString(); model.AuthorFirstName = postRow["FirstName"].ToString(); model.AuthorLastName = postRow["LastName"].ToString(); model.AuthorBio = postRow["AuthorBio"].ToString(); model.Excerpt = postRow["Abstract"].ToString(); model.PostDate = Convert.ToDateTime(postRow["StartDate"].ToString()); model.HeadlineImageUrl = postRow["HeadlineImageUrl"].ToString(); model.CommentCount = Convert.ToInt32(postRow["CommentCount"]); model.AllowCommentsForDays = Convert.ToInt32(postRow["AllowCommentsForDays"]); model.ShowAuthorName = Convert.ToBoolean(postRow["ShowAuthorName"]); model.ShowAuthorAvatar = Convert.ToBoolean(postRow["ShowAuthorAvatar"]); model.ShowAuthorBio = Convert.ToBoolean(postRow["ShowAuthorBio"]); model.AuthorUserId = Convert.ToInt32(postRow["UserID"]); models.Add(model); } PostListModel postListObject = new PostListModel(); if (module != null) { postListObject.ModuleTitle = module.ModuleTitle; postListObject.Module = module; } else { postListObject.ModuleTitle = ""; } //postListObject.ModuleTitle = module == null ? "" : module.ModuleTitle; postListObject.ModulePageUrl = Page.ResolveUrl(blogPageUrl); postListObject.Posts = models; string text = string.Empty; try { text = RazorBridge.RenderPartialToString(config.Layout, postListObject, "Blog"); } //catch (System.Web.HttpException ex) //{ // renderDefaultView(ex.ToString()); //} //catch (ArgumentNullException ex) //{ // renderDefaultView(ex.ToString()); //} catch (Exception ex) { renderDefaultView(ex.ToString()); } void renderDefaultView(string error = "") { if (!string.IsNullOrWhiteSpace(error)) { log.ErrorFormat( "chosen layout ({0}) for _BlogPostList was not found in skin {1}. perhaps it is in a different skin. Error was: {2}", config.Layout, SiteUtils.GetSkinBaseUrl(true, Page), error ); } text = RazorBridge.RenderPartialToString("_BlogPostList", postListObject, "Blog"); } output.Write(text); }