//https://developers.google.com/maps/documentation/staticmaps/ //http://msdn.microsoft.com/en-us/library/ff701724.aspx //bing private string BuildStaticMapMarkup(DataRow dr) { if (siteSettings == null) { return(string.Empty); } if (siteSettings.GmapApiKey.Length == 0) { return(string.Empty); } string location = dr["Location"].ToString(); if (location.Length == 0) { return(location); } string mapHeight = dr["MapHeight"].ToString().Replace("px", string.Empty); string mapWidth = dr["MapWidth"].ToString().Replace("px", string.Empty).Replace("%", string.Empty); string mapType; string mapZoom = Convert.ToInt32(dr["MapZoom"]).ToInvariantString(); // this experiment did not work it returns a json result not a static image //bool useBing = Convert.ToBoolean(dr["UseBingMap"]); //if (useBing && !WebConfigSettings.DisableBingStaticMaps && (WebConfigSettings.BingMapsApiKey.Length > 0)) //{ // mapType = BlogConfiguration.GetBingStaticMapType(dr["MapType"].ToString()); // return "<img src='http://dev.virtualearth.net/REST/v1/Imagery/Map/" // + mapType + "/" // + Server.UrlEncode(location) // + "?mapsize=" + mapWidth + "," + mapHeight // + "&zoomLevel=" + mapZoom // + "&key=" + WebConfigSettings.BingMapsApiKey // + "' />" // ; //} if (siteSettings.GmapApiKey.Length == 0) { return(string.Empty); } mapType = BlogConfiguration.GetGoogleStaticMapType(dr["MapType"].ToString()); return("<img src='http://maps.googleapis.com/maps/api/staticmap?center=" + Server.UrlEncode(location) + "&zoom=" + mapZoom + "&size=" + mapWidth + "x" + mapHeight + "&maptype=" + mapType + "&key=" + siteSettings.GmapApiKey + "&sensor=false" + "' />" ); }
protected virtual void LoadSettings() { //pnlContainer.ModuleId = ModuleId; config = new BlogConfiguration(Settings); if (config.InstanceCssClass.Length > 0) { pnlOuterWrap.SetOrAppendCss(config.InstanceCssClass); } if (this.ModuleConfiguration != null) { this.Title = ModuleConfiguration.ModuleTitle; this.Description = ModuleConfiguration.FeatureName; } if (!WebConfigSettings.DisableMetaWeblogApi) { AddWindowsLiveWriterManifestLink(); } searchBoxTop.Visible = config.ShowBlogSearchBox && !displaySettings.HideSearchBoxInPostList && !displaySettings.ShowSearchInNav; //if (IsEditable) //{ // countOfDrafts = Blog.CountOfDrafts(ModuleId); //} }
protected virtual void LoadSettings() { //pnlContainer.ModuleId = ModuleId; config = new BlogConfiguration(Settings); if (config.InstanceCssClass.Length > 0) { pnlOuterWrap.SetOrAppendCss(config.InstanceCssClass); } if (this.ModuleConfiguration != null) { this.Title = ModuleConfiguration.ModuleTitle; this.Description = ModuleConfiguration.FeatureName; } if (!WebConfigSettings.DisableMetaWeblogApi) { AddWindowsLiveWriterManifestLink(); } searchBoxTop.Visible = config.ShowBlogSearchBox && !displaySettings.HideSearchBoxInPostList && !displaySettings.ShowSearchInNav; //if (IsEditable) //{ // countOfDrafts = Blog.CountOfDrafts(ModuleId); //} }
private void LoadSettings() { moduleSettings = ModuleSettings.GetModuleSettings(moduleId); config = new BlogConfiguration(moduleSettings); blogModule = GetModule(moduleId, Blog.FeatureGuid); postList.ModuleId = moduleId; postList.PageId = pageId; postList.DisplayMode = "ByMonth"; postList.IsEditable = UserCanEditModule(moduleId, Blog.FeatureGuid); postList.Config = config; postList.SiteRoot = SiteRoot; postList.ImageSiteRoot = ImageSiteRoot; if (config.InstanceCssClass.Length > 0) { pnlOuterWrap.SetOrAppendCss(config.InstanceCssClass); } LoadSideContent(config.ShowLeftContent, config.ShowRightContent); LoadAltContent(BlogConfiguration.ShowTopContent, BlogConfiguration.ShowBottomContent); if ((CurrentPage != null) && (CurrentPage.BodyCssClass.Length > 0)) { AddClassToBody(CurrentPage.BodyCssClass); } AddClassToBody("blogviewarchive"); if (BlogConfiguration.UseNoIndexFollowMetaOnLists) { SiteUtils.AddNoIndexFollowMeta(Page); } }
private void LoadSettings() { moduleSettings = ModuleSettings.GetModuleSettings(moduleId); config = new BlogConfiguration(moduleSettings); postList.ModuleId = moduleId; postList.PageId = pageId; postList.DisplayMode = "ByCategory"; postList.ShowFeaturedPost = false; postList.IsEditable = UserCanEditModule(moduleId, Blog.FeatureGuid); postList.Config = config; postList.SiteRoot = SiteRoot; postList.ImageSiteRoot = ImageSiteRoot; if (config.InstanceCssClass.Length > 0) { pnlOuterWrap.SetOrAppendCss(config.InstanceCssClass); } if ((CurrentPage != null) && (CurrentPage.BodyCssClass.Length > 0)) { AddClassToBody(CurrentPage.BodyCssClass); } AddClassToBody("blogviewcategory"); if (BlogConfiguration.UseNoIndexFollowMetaOnLists) { SiteUtils.AddNoIndexFollowMeta(Page); } }
private void LoadSettings() { moduleSettings = ModuleSettings.GetModuleSettings(moduleId); config = new BlogConfiguration(moduleSettings); blogModule = GetModule(moduleId, Blog.FeatureGuid); postList.ModuleId = moduleId; postList.PageId = pageId; postList.DisplayMode = "ByMonth"; postList.IsEditable = UserCanEditModule(moduleId, Blog.FeatureGuid); postList.Config = config; postList.SiteRoot = SiteRoot; postList.ImageSiteRoot = ImageSiteRoot; if (config.InstanceCssClass.Length > 0) { pnlOuterWrap.SetOrAppendCss(config.InstanceCssClass); } LoadSideContent(config.ShowLeftContent, config.ShowRightContent); LoadAltContent(BlogConfiguration.ShowTopContent, BlogConfiguration.ShowBottomContent); if ((CurrentPage != null) && (CurrentPage.BodyCssClass.Length > 0)) { AddClassToBody(CurrentPage.BodyCssClass); } AddClassToBody("blogviewarchive"); if (BlogConfiguration.UseNoIndexFollowMetaOnLists) { SiteUtils.AddNoIndexFollowMeta(Page); } }
private void LoadSettings() { pageId = WebUtils.ParseInt32FromQueryString("pageid", pageId); moduleId = WebUtils.ParseInt32FromQueryString("mid", moduleId); itemId = WebUtils.ParseInt32FromQueryString("ItemID", itemId); commentGuid = WebUtils.ParseGuidFromQueryString("c", commentGuid); if (commentGuid == Guid.Empty) { return; } blog = new Blog(itemId); module = GetModule(moduleId, Blog.FeatureGuid); commentRepository = new CommentRepository(); if (blog.ModuleId != module.ModuleId) { blog = null; module = null; return; } comment = commentRepository.Fetch(commentGuid); if ((comment.ContentGuid != blog.BlogGuid) || (comment.ModuleGuid != module.ModuleGuid)) { blog = null; module = null; return; } moduleSettings = ModuleSettings.GetModuleSettings(moduleId); config = new BlogConfiguration(moduleSettings); currentUser = SiteUtils.GetCurrentSiteUser(); userCanEdit = UserCanEditComment(); commentEditor.SiteGuid = CurrentSite.SiteGuid; commentEditor.SiteId = CurrentSite.SiteId; commentEditor.SiteRoot = SiteRoot; commentEditor.CommentsClosed = false; //commentEditor.CommentUrl = Request.RawUrl; commentEditor.ContentGuid = blog.BlogGuid; //commentEditor.DefaultCommentTitle = defaultCommentTitle; commentEditor.FeatureGuid = Blog.FeatureGuid; commentEditor.ModuleGuid = module.ModuleGuid; //commentEditor.NotificationAddresses = notificationAddresses; //commentEditor.NotificationTemplateName = notificationTemplateName; commentEditor.RequireCaptcha = false; commentEditor.UserCanModerate = userCanEdit; //commentEditor.Visible = !commentsClosed; commentEditor.CurrentUser = currentUser; commentEditor.UserComment = comment; commentEditor.ShowRememberMe = false; //commentEditor.IncludeIpAddressInNotification = includeIpAddressInNotification; //commentEditor.ContainerControl = this; }
private void PopulateControls() { Title = SiteUtils.FormatPageTitle(siteSettings, BlogResources.PostList); moduleTitle.EditUrl = SiteRoot + "/Blog/EditPost.aspx"; moduleTitle.EditText = BlogResources.BlogAddPostLabel; moduleTitle.ModuleInstance = GetModule(moduleId); moduleTitle.CanEdit = userCanEdit; //if ((userCanEdit) && (countOfDrafts > 0)) //{ // moduleTitle.LiteralExtraMarkup = // " <a href='" // + SiteRoot // + "/Blog/EditCategory.aspx?pageid=" + pageId.ToInvariantString() // + "&mid=" + moduleId.ToInvariantString() // + "' class='ModuleEditLink' title='" + BlogResources.BlogEditCategoriesLabel + "'>" + BlogResources.BlogEditCategoriesLabel + "</a>" // + " <a href='" // + SiteRoot // + "/Blog/Drafts.aspx?pageid=" + pageId.ToInvariantString() // + "&mid=" + moduleId.ToInvariantString() // + "' class='ModuleEditLink' title='" + BlogResources.BlogDraftsLink + "'>" + BlogResources.BlogDraftsLink + "</a>"; //} //else if (userCanEdit) { moduleTitle.LiteralExtraMarkup = " <a href='" + SiteRoot + "/Blog/Manage.aspx?pageid=" + pageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString() + "' class='ModuleEditLink' title='" + BlogResources.Administration + "'>" + BlogResources.Administration + "</a>" ; } postList.ModuleId = moduleId; postList.PageId = pageId; postList.IsEditable = userCanEdit; BlogConfiguration config = new BlogConfiguration(ModuleSettings.GetModuleSettings(moduleId)); postList.Config = config; postList.SiteRoot = SiteRoot; postList.ImageSiteRoot = ImageSiteRoot; if (config.InstanceCssClass.Length > 0) { pnlOuterWrap.SetOrAppendCss(config.InstanceCssClass); } searchBoxTop.Visible = config.ShowBlogSearchBox && !displaySettings.HideSearchBoxInPostList; //make this page look as close as possible to the way a cms page with the blog module on it looks LoadSideContent(true, true); LoadAltContent(BlogConfiguration.ShowTopContent, BlogConfiguration.ShowBottomContent); }
private void LoadSettings() { TimeOffset = SiteUtils.GetUserTimeOffset(); timeZone = SiteUtils.GetUserTimeZone(); config = new BlogConfiguration(ModuleSettings.GetModuleSettings(moduleId)); currentUser = SiteUtils.GetCurrentSiteUser(); useFriendlyUrls = BlogConfiguration.UseFriendlyUrls(moduleId); if (!WebConfigSettings.UseUrlReWriting) { useFriendlyUrls = false; } }
private void LoadSettings() { timeOffset = SiteUtils.GetUserTimeOffset(); timeZone = SiteUtils.GetUserTimeZone(); pageId = WebUtils.ParseInt32FromQueryString("pageid", pageId); moduleId = WebUtils.ParseInt32FromQueryString("mid", moduleId); pageNumber = WebUtils.ParseInt32FromQueryString("pagenumber", pageNumber); currentUser = SiteUtils.GetCurrentSiteUser(); config = new BlogConfiguration(ModuleSettings.GetModuleSettings(moduleId)); AddClassToBody("blogdrafts"); }
protected virtual void LoadSettings() { config = new BlogPostListAdvancedConfiguration(Settings); blogConfig = new BlogConfiguration(ModuleSettings.GetModuleSettings(config.BlogModuleId)); if (config.InstanceCssClass.Length > 0) { pnlOuterWrap.SetOrAppendCss(config.InstanceCssClass); } if (this.ModuleConfiguration != null) { this.Title = ModuleConfiguration.ModuleTitle; this.Description = ModuleConfiguration.FeatureName; } }
private void LoadSettings() { currentUser = SiteUtils.GetCurrentSiteUser(); config = new BlogConfiguration(ModuleSettings.GetModuleSettings(moduleId)); lnkCategories.NavigateUrl = SiteRoot + "/Blog/EditCategory.aspx?pageid=" + pageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString(); lnkNewPost.NavigateUrl = SiteRoot + "/Blog/EditPost.aspx?pageid=" + pageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString(); lnkDrafts.NavigateUrl = SiteRoot + "/Blog/Drafts.aspx?pageid=" + pageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString(); lnkClosedPosts.NavigateUrl = SiteRoot + "/Blog/ClosedPosts.aspx?pageid=" + pageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString(); if (currentUser == null) { return; } if (BlogConfiguration.SecurePostsByUser) { if (WebUser.IsInRoles(config.ApproverRoles)) { countOfDrafts = Blog.GetCountOfDrafts(moduleId, Guid.Empty); } else { countOfDrafts = Blog.GetCountOfDrafts(moduleId, currentUser.UserGuid); } } else { countOfDrafts = Blog.GetCountOfDrafts(moduleId, Guid.Empty); } countOfExpiredPosts = Blog.GetCountClosed(moduleId); }
public void ProcessRequest(HttpContext context) { base.Initialize(context); if (!UserCanEditModule(ModuleId, Blog.FeatureGuid)) { log.Info("User has no edit permission so returning 404"); Response.StatusCode = 404; return; } if (CurrentSite == null) { log.Info("CurrentSite is null so returning 404"); Response.StatusCode = 404; return; } if (CurrentUser == null) { log.Info("CurrentUser is null so returning 404"); Response.StatusCode = 404; return; } if (FileSystem == null) { log.Info("FileSystem is null so returning 404"); Response.StatusCode = 404; return; } if (Request.Files.Count == 0) { log.Info("Posted File Count is zero so returning 404"); Response.StatusCode = 404; return; } if (Request.Files.Count > BlogConfiguration.MaxAttachmentsToUploadAtOnce) { log.Info("Posted File Count is higher than allowed so returning 404"); Response.StatusCode = 404; return; } itemId = WebUtils.ParseInt32FromQueryString("ItemID", itemId); if (itemId == -1) { log.Info("No ItemID provided so returning 404"); Response.StatusCode = 404; return; } module = GetModule(ModuleId, Blog.FeatureGuid); if (module == null) { log.Info("Module is null so returning 404"); Response.StatusCode = 404; return; } blog = new Blog(itemId); if (blog.ModuleId != ModuleId) { log.Info("Invalid ItemID for module so returning 404"); Response.StatusCode = 404; return; } Hashtable moduleSettings = ModuleSettings.GetModuleSettings(ModuleId); config = new BlogConfiguration(moduleSettings); context.Response.ContentType = "text/plain";//"application/json"; var r = new System.Collections.Generic.List<UploadFilesResult>(); JavaScriptSerializer js = new JavaScriptSerializer(); SiteUtils.EnsureFileAttachmentFolder(CurrentSite); string upLoadPath = SiteUtils.GetFileAttachmentUploadPath(); for (int f = 0; f < Request.Files.Count; f++) { HttpPostedFile file = Request.Files[f]; string ext = System.IO.Path.GetExtension(file.FileName); if (!SiteUtils.IsAllowedUploadBrowseFile(ext, WebConfigSettings.AllowedMediaFileExtensions)) { log.Info("file extension was " + ext + " so discarding file " + file.FileName); r.Add(new UploadFilesResult() { Name = file.FileName, Length = file.ContentLength, Type = file.ContentType, ErrorMessage = string.Format( CultureInfo.InvariantCulture, GalleryResources.InvalidUploadExtensionFormat, file.FileName, WebConfigSettings.AllowedMediaFileExtensions.Replace("|", " ")) }); continue; } string mimeType = IOHelper.GetMimeType(ext).ToLower(); FileAttachment a = new FileAttachment(); a.CreatedBy = CurrentUser.UserGuid; a.FileName = System.IO.Path.GetFileName(file.FileName); a.ServerFileName = blog.ItemId.ToInvariantString() + a.FileName.ToCleanFileName(WebConfigSettings.ForceLowerCaseForUploadedFiles); a.ModuleGuid = blog.ModuleGuid; a.SiteGuid = CurrentSite.SiteGuid; a.ItemGuid = blog.BlogGuid; a.ContentLength = file.ContentLength; a.ContentType = mimeType; a.Save(); string destPath = upLoadPath + a.ServerFileName; using (Stream s = file.InputStream) { FileSystem.SaveFile(destPath, s, mimeType, true); } r.Add(new UploadFilesResult() { //Thumbnail_url = Name = a.FileName, Length = file.ContentLength, Type = mimeType }); if (WebConfigSettings.LogAllFileServiceRequests) { string userName = "******"; if (CurrentUser != null) { userName = CurrentUser.Name; } log.Info("File " + file.FileName + " uploaded by " + userName + " as a media attachment in the Blog"); } } var uploadedFiles = new { files = r.ToArray() }; var jsonObj = js.Serialize(uploadedFiles); context.Response.Write(jsonObj.ToString()); }
private void LoadSettings() { pageId = WebUtils.ParseInt32FromQueryString("pageid", pageId); moduleId = WebUtils.ParseInt32FromQueryString("mid", moduleId); itemId = WebUtils.ParseInt32FromQueryString("ItemID", itemId); commentGuid = WebUtils.ParseGuidFromQueryString("c", commentGuid); if (commentGuid == Guid.Empty) { return; } blog = new Blog(itemId); module = GetModule(moduleId, Blog.FeatureGuid); commentRepository = new CommentRepository(); if (blog.ModuleId != module.ModuleId) { blog = null; module = null; return; } comment = commentRepository.Fetch(commentGuid); if ((comment.ContentGuid != blog.BlogGuid)||(comment.ModuleGuid != module.ModuleGuid)) { blog = null; module = null; return; } moduleSettings = ModuleSettings.GetModuleSettings(moduleId); config = new BlogConfiguration(moduleSettings); currentUser = SiteUtils.GetCurrentSiteUser(); userCanEdit = UserCanEditComment(); commentEditor.SiteGuid = CurrentSite.SiteGuid; commentEditor.SiteId = CurrentSite.SiteId; commentEditor.SiteRoot = SiteRoot; commentEditor.CommentsClosed = false; //commentEditor.CommentUrl = Request.RawUrl; commentEditor.ContentGuid = blog.BlogGuid; //commentEditor.DefaultCommentTitle = defaultCommentTitle; commentEditor.FeatureGuid = Blog.FeatureGuid; commentEditor.ModuleGuid = module.ModuleGuid; //commentEditor.NotificationAddresses = notificationAddresses; //commentEditor.NotificationTemplateName = notificationTemplateName; commentEditor.RequireCaptcha = false; commentEditor.UserCanModerate = userCanEdit; //commentEditor.Visible = !commentsClosed; commentEditor.CurrentUser = currentUser; commentEditor.UserComment = comment; commentEditor.ShowRememberMe = false; //commentEditor.IncludeIpAddressInNotification = includeIpAddressInNotification; //commentEditor.ContainerControl = this; }
protected virtual void PopulateNavigation() { bool isDetailPage = (Page is BlogView); litUpperSidebar.Text = config.UpperSidebar; litLowerSidebar.Text = config.LowerSidebar; Feeds.Config = config; Feeds.PageId = PageId; Feeds.ModuleId = ModuleId; bool showFeeds = config.ShowFeedLinks && !displaySettings.HideFeedLinks; if (isDetailPage && displaySettings.ShowFeedLinksInPostDetail) { showFeeds = true; } Feeds.Visible = showFeeds; bool showCategories = config.ShowCategories && !displaySettings.DisableShowCategories; if (isDetailPage && displaySettings.ShowCategoriesInPostDetail) { showCategories = true; } if (showCategories) { tags.CanEdit = IsEditable; tags.PageId = PageId; tags.ModuleId = ModuleId; tags.SiteRoot = SiteRoot; tags.RenderAsTagCloud = config.UseTagCloudForCategories; } else { tags.Visible = false; pnlCategories.Visible = false; } bool showArchives = config.ShowArchives && !displaySettings.DisableShowArchives; if (isDetailPage && displaySettings.ShowArchivesInPostDetail) { showArchives = true; } if (showArchives) { archive.PageId = PageId; archive.ModuleId = ModuleId; archive.SiteRoot = SiteRoot; archive.HeadingElement = displaySettings.ArchiveListHeadingElement; archive.OverrideHeadingText = displaySettings.ArchiveListOverrideHeadingText; } else { archive.Visible = false; pnlArchives.Visible = false; } bool showStats = config.ShowStatistics && !displaySettings.DisableShowStatistics; if (isDetailPage && displaySettings.ShowStatisticsInPostDetail) { showStats = true; } stats.PageId = PageId; stats.ModuleId = ModuleId; stats.ModuleGuid = ModuleGuid; stats.CountOfDrafts = countOfDrafts; stats.Visible = showStats; stats.HeadingElement = displaySettings.StatsHeadingElement; stats.OverrideHeadingText = displaySettings.StatsOverrideHeadingText; pnlStatistics.Visible = showStats; if ((config.RelatedItemsToShow > 0) && (displaySettings.RelatedPostsPosition == "Side") && (Page is BlogView)) { relatedPosts.PageId = pageId; relatedPosts.ModuleId = moduleId; relatedPosts.ItemId = WebUtils.ParseInt32FromQueryString("ItemID", -1); relatedPosts.SiteRoot = siteRoot; relatedPosts.MaxItems = config.RelatedItemsToShow; relatedPosts.UseFriendlyUrls = BlogConfiguration.UseFriendlyUrls(moduleId); relatedPosts.HeadingElement = displaySettings.RelatedPostsHeadingElement; relatedPosts.OverrideHeadingText = displaySettings.RelatedPostsOverrideHeadingText; } if (showFeeds || showCategories || showStats || showArchives) { divNav.Visible = true; } }
private void LoadSettings() { siteSettings = CacheHelper.GetCurrentSiteSettings(); //moduleSettings = ModuleSettings.GetModuleSettings(ModuleId); if (Request.IsAuthenticated) { if (basePage.UserCanEditModule(ModuleId, Blog.FeatureGuid)) { IsEditable = true; } } //config = new BlogConfiguration(moduleSettings); if (config.DisqusSiteShortName.Length > 0) { DisqusSiteShortName = config.DisqusSiteShortName; } else { DisqusSiteShortName = siteSettings.DisqusSiteShortName; } AllowComments = config.AllowComments && !displaySettings.ArchiveViewHideFeedbackLink; if ((DisqusSiteShortName.Length > 0) && (config.CommentSystem == "disqus")) { navTop.ShowCommentCount = false; navBottom.ShowCommentCount = false; } navTop.ModuleId = ModuleId; navTop.PageId = PageId; navTop.IsEditable = IsEditable; navTop.Config = config; navTop.SiteRoot = SiteRoot; navTop.ImageSiteRoot = ImageSiteRoot; navBottom.ModuleId = ModuleId; navBottom.PageId = PageId; navBottom.IsEditable = IsEditable; navBottom.Config = config; navBottom.SiteRoot = SiteRoot; navBottom.ImageSiteRoot = ImageSiteRoot; navTop.Visible = false; if (config.ShowArchives || config.ShowAddFeedLinks || config.ShowCategories || config.ShowFeedLinks || config.ShowStatistics || (config.UpperSidebar.Length > 0) || (config.LowerSidebar.Length > 0) ) { navTop.Visible = true; } if (!navTop.Visible) { divblog.CssClass = "blogcenter-nonav"; } navBottom.Visible = false; if ((navTop.Visible) && (displaySettings.UseBottomNavigation)) { navTop.Visible = false; navBottom.Visible = true; } //countOfDrafts = Blog.CountOfDrafts(ModuleId); useFriendlyUrls = BlogConfiguration.UseFriendlyUrls(ModuleId); if (!WebConfigSettings.UseUrlReWriting) { useFriendlyUrls = false; } }
private void LoadSettings() { blog = new Blog(ItemId); module = basePage.GetModule(ModuleId); useFriendlyUrls = BlogConfiguration.UseFriendlyUrls(ModuleId); if (!WebConfigSettings.UseUrlReWriting) { useFriendlyUrls = false; } attachmentBaseUrl = SiteUtils.GetFileAttachmentUploadPath(); currentUser = SiteUtils.GetCurrentSiteUser(); comments = InternalCommentSystem as CommentsWidget; if ( (module.ModuleId == -1) || (blog.ModuleId == -1) || (blog.ModuleId != module.ModuleId) || (basePage.SiteInfo == null) ) { // query string params have been manipulated pnlInnerWrap.Visible = false; AllowComments = false; parametersAreInvalid = true; return; } else { if (Request.IsAuthenticated) { if (basePage.UserCanEditModule(ModuleId, Blog.FeatureGuid)) { IsEditable = true; } } } RegexRelativeImageUrlPatern = SecurityHelper.RegexRelativeImageUrlPatern; moduleSettings = ModuleSettings.GetModuleSettings(ModuleId); config = new BlogConfiguration(moduleSettings); blogAuthor = config.BlogAuthor; divTopPager.Visible = config.ShowNextPreviousLinks; divBottomPager.Visible = config.ShowNextPreviousLinks; GmapApiKey = SiteUtils.GetGmapApiKey(); if (config.InstanceCssClass.Length > 0) { pnlInnerWrap.SetOrAppendCss(config.InstanceCssClass); } searchBoxTop.Visible = config.ShowBlogSearchBox && !displaySettings.HideSearchBoxInPostDetail && !displaySettings.ShowSearchInNav; //if (config.AddThisCustomBrand.Length > 0) //{ // addThisCustomBrand = config.AddThisCustomBrand; //} //else //{ // addThisCustomBrand = basePage.SiteInfo.SiteName; //} lblCopyright.Text = config.Copyright; //litAuthor.Visible = config.ShowPostAuthor; navTop.ModuleId = ModuleId; navTop.ModuleGuid = module.ModuleGuid; navTop.PageId = PageId; navTop.IsEditable = IsEditable; navTop.Config = config; navTop.SiteRoot = SiteRoot; navTop.ImageSiteRoot = ImageSiteRoot; navTop.OverrideDate = blog.StartDate; navTop.ShowCalendar = config.ShowCalendarOnPostDetail; navBottom.ModuleId = ModuleId; navBottom.ModuleGuid = module.ModuleGuid; navBottom.PageId = PageId; navBottom.IsEditable = IsEditable; navBottom.Config = config; navBottom.SiteRoot = SiteRoot; navBottom.ImageSiteRoot = ImageSiteRoot; navBottom.OverrideDate = blog.StartDate; navBottom.ShowCalendar = config.ShowCalendarOnPostDetail; //pnlStatistics.Visible = config.ShowStatistics; if (!config.NavigationOnRight) { //this.divNav.CssClass = "blognavleft"; this.divblog.CssClass = "blogcenter-leftnav"; } //divNav.Visible = false; navTop.Visible = false; if (config.ShowArchives || config.ShowAddFeedLinks || displaySettings.ShowArchivesInPostDetail || config.ShowCategories || displaySettings.ShowCategoriesInPostDetail || config.ShowFeedLinks || displaySettings.ShowFeedLinksInPostDetail || config.ShowStatistics || displaySettings.ShowStatisticsInPostDetail || (config.UpperSidebar.Length > 0) || (config.LowerSidebar.Length > 0) ) { //divNav.Visible = true; navTop.Visible = true; } if (!navTop.Visible) { divblog.CssClass = "blogcenter-nonav"; } navBottom.Visible = false; if ((navTop.Visible) && (displaySettings.UseBottomNavigation)) { navTop.Visible = false; navBottom.Visible = true; } if (!Request.IsAuthenticated) { //if ((config.HideDetailsFromUnauthencticated) && (blog.Description.Length > config.ExcerptLength)) if (config.HideDetailsFromUnauthencticated) { pnlDetails.Visible = false; pnlExcerpt.Visible = true; AllowComments = false; divAddThis.Visible = false; tweetThis1.Visible = false; fblike.Visible = false; btnPlusOne.Visible = false; bsocial.Visible = false; } } if (!pnlExcerpt.Visible) { if (config.AddThisAccountId.Length > 0) { addThisAccountId = config.AddThisAccountId; } else { addThisAccountId = basePage.SiteInfo.AddThisDotComUsername; } if (config.EnableContentRating && !displaySettings.DetailViewDisableContentRating) { if (displaySettings.UseBottomContentRating) { ((mojoRating)RatingBottom).Enabled = true; ((mojoRating)RatingBottom).AllowFeedback = config.EnableRatingComments; ((mojoRating)RatingBottom).ContentGuid = blog.BlogGuid; } else { ((mojoRating)Rating).Enabled = true; ((mojoRating)Rating).AllowFeedback = config.EnableRatingComments; ((mojoRating)Rating).ContentGuid = blog.BlogGuid; } } } if (displaySettings.BlogViewUseBottomDate) { pnlDateTop.Visible = false; pnlBottomDate.Visible = true; } if (displaySettings.BlogViewHideTopPager) { divTopPager.Visible = false; } if (displaySettings.BlogViewHideBottomPager) { divBottomPager.Visible = false; } if (displaySettings.BlogViewInnerWrapElement.Length > 0) { pnlInnerWrap.Element = displaySettings.BlogViewInnerWrapElement; } if (displaySettings.BlogViewInnerBodyExtraCss.Length > 0) { pnlInnerBody.ExtraCssClasses = displaySettings.BlogViewInnerBodyExtraCss; pnlInnerBody.RenderContentsOnly = false; } if (displaySettings.BlogViewDivBlogExtraCss.Length > 0) { divblog.CssClass += " " + displaySettings.BlogViewDivBlogExtraCss; } if (displaySettings.BlogViewHeaderLiteralTopContent.Length > 0) { heading.LiteralExtraTopContent = displaySettings.BlogViewHeaderLiteralTopContent; } if (displaySettings.BlogViewHeaderLiteralBottomContent.Length > 0) { heading.LiteralExtraBottomContent = displaySettings.BlogViewHeaderLiteralBottomContent; } if (displaySettings.OverridePostDetailHeadingElement.Length > 0) { heading.HeadingTag = displaySettings.OverridePostDetailHeadingElement; } if ((config.RelatedItemsToShow > 0) && (displaySettings.RelatedPostsPosition == "Bottom") && (Page is BlogView)) { relatedPosts.PageId = PageId; relatedPosts.ModuleId = ModuleId; relatedPosts.ItemId = ItemId; relatedPosts.SiteRoot = SiteRoot; relatedPosts.MaxItems = config.RelatedItemsToShow; relatedPosts.UseFriendlyUrls = BlogConfiguration.UseFriendlyUrls(ModuleId); relatedPosts.HeadingElement = displaySettings.RelatedPostsHeadingElement; relatedPosts.OverrideHeadingText = displaySettings.RelatedPostsOverrideHeadingText; } switch (basePage.SiteInfo.AvatarSystem) { case "gravatar": allowGravatars = true; disableAvatars = false; break; case "internal": allowGravatars = false; disableAvatars = false; break; case "none": default: allowGravatars = false; disableAvatars = true; break; } if (!blog.ShowAuthorAvatar) { disableAvatars = true; } if (displaySettings.HideAvatarInPostDetail) { disableAvatars = true; } pnlAuthorInfo.Visible = (!disableAvatars) ||( blog.ShowAuthorBio && displaySettings.ShowAuthorBioInPostDetail &&(!pnlExcerpt.Visible)); userAvatar.Email = blog.UserEmail; userAvatar.UserName = blog.UserName; userAvatar.UserId = blog.UserId; userAvatar.AvatarFile = blog.UserAvatar; userAvatar.MaxAllowedRating = MaxAllowedGravatarRating; userAvatar.Disable = disableAvatars; userAvatar.UseGravatar = allowGravatars; userAvatar.SiteId = basePage.SiteInfo.SiteId; userAvatar.UserNameTooltipFormat = displaySettings.AvatarUserNameTooltipFormat; userAvatar.UseLink = UseProfileLinkForAvatar(); userAvatar.SiteRoot = SiteRoot; // if (pnlExcerpt.Visible) { userAvatar.Visible = false; } SetupCommentSystem(); }
public void ProcessRequest(HttpContext context) { base.Initialize(context); if (!UserCanEditModule(ModuleId, Blog.FeatureGuid)) { log.Info("User has no edit permission so returning 404"); Response.StatusCode = 404; return; } if (CurrentSite == null) { log.Info("CurrentSite is null so returning 404"); Response.StatusCode = 404; return; } if (CurrentUser == null) { log.Info("CurrentUser is null so returning 404"); Response.StatusCode = 404; return; } if (FileSystem == null) { log.Info("FileSystem is null so returning 404"); Response.StatusCode = 404; return; } if (Request.Files.Count == 0) { log.Info("Posted File Count is zero so returning 404"); Response.StatusCode = 404; return; } if (Request.Files.Count > BlogConfiguration.MaxAttachmentsToUploadAtOnce) { log.Info("Posted File Count is higher than allowed so returning 404"); Response.StatusCode = 404; return; } itemId = WebUtils.ParseInt32FromQueryString("ItemID", itemId); if (itemId == -1) { log.Info("No ItemID provided so returning 404"); Response.StatusCode = 404; return; } module = GetModule(ModuleId, Blog.FeatureGuid); if (module == null) { log.Info("Module is null so returning 404"); Response.StatusCode = 404; return; } blog = new Blog(itemId); if (blog.ModuleId != ModuleId) { log.Info("Invalid ItemID for module so returning 404"); Response.StatusCode = 404; return; } Hashtable moduleSettings = ModuleSettings.GetModuleSettings(ModuleId); config = new BlogConfiguration(moduleSettings); context.Response.ContentType = "text/plain";//"application/json"; var r = new System.Collections.Generic.List <UploadFilesResult>(); JavaScriptSerializer js = new JavaScriptSerializer(); SiteUtils.EnsureFileAttachmentFolder(CurrentSite); string upLoadPath = SiteUtils.GetFileAttachmentUploadPath(); for (int f = 0; f < Request.Files.Count; f++) { HttpPostedFile file = Request.Files[f]; string ext = System.IO.Path.GetExtension(file.FileName); if (!SiteUtils.IsAllowedUploadBrowseFile(ext, WebConfigSettings.AllowedMediaFileExtensions)) { log.Info("file extension was " + ext + " so discarding file " + file.FileName); r.Add(new UploadFilesResult() { Name = file.FileName, Length = file.ContentLength, Type = file.ContentType, ErrorMessage = string.Format( CultureInfo.InvariantCulture, GalleryResources.InvalidUploadExtensionFormat, file.FileName, WebConfigSettings.AllowedMediaFileExtensions.Replace("|", " ")) }); continue; } string mimeType = IOHelper.GetMimeType(ext).ToLower(); FileAttachment a = new FileAttachment(); a.CreatedBy = CurrentUser.UserGuid; a.FileName = System.IO.Path.GetFileName(file.FileName); a.ServerFileName = blog.ItemId.ToInvariantString() + a.FileName.ToCleanFileName(WebConfigSettings.ForceLowerCaseForUploadedFiles); a.ModuleGuid = blog.ModuleGuid; a.SiteGuid = CurrentSite.SiteGuid; a.ItemGuid = blog.BlogGuid; a.ContentLength = file.ContentLength; a.ContentType = mimeType; a.Save(); string destPath = upLoadPath + a.ServerFileName; using (Stream s = file.InputStream) { FileSystem.SaveFile(destPath, s, mimeType, true); } r.Add(new UploadFilesResult() { //Thumbnail_url = Name = a.FileName, Length = file.ContentLength, Type = mimeType }); if (WebConfigSettings.LogAllFileServiceRequests) { string userName = "******"; if (CurrentUser != null) { userName = CurrentUser.Name; } log.Info("File " + file.FileName + " uploaded by " + userName + " as a media attachment in the Blog"); } } var uploadedFiles = new { files = r.ToArray() }; var jsonObj = js.Serialize(uploadedFiles); context.Response.Write(jsonObj.ToString()); }
private void LoadSettings() { pageID = WebUtils.ParseInt32FromQueryString("pageid", -1); moduleId = WebUtils.ParseInt32FromQueryString("mid", -1); categoryId = WebUtils.ParseInt32FromQueryString("cat", categoryId); siteSettings = CacheHelper.GetCurrentSiteSettings(); // newer implementation combines params as p=pageid~moduleid~categoryid string f = WebUtils.ParseStringFromQueryString("p", string.Empty); if ((f.Length > 0) && (f.Contains("~"))) { List <string> parms = f.SplitOnCharAndTrim('~'); if (parms.Count >= 1) { int.TryParse(parms[0], NumberStyles.Integer, CultureInfo.InvariantCulture, out pageID); } if (parms.Count >= 2) { int.TryParse(parms[1], NumberStyles.Integer, CultureInfo.InvariantCulture, out moduleId); } if (parms.Count >= 3) { int.TryParse(parms[2], NumberStyles.Integer, CultureInfo.InvariantCulture, out categoryId); } } securityBypassGuid = WebUtils.ParseGuidFromQueryString("g", securityBypassGuid); attachmentBaseUrl = SiteUtils.GetFileAttachmentUploadPath(); pageSettings = CacheHelper.GetPage(pageID); module = GetModule(); if ((moduleId == -1) || (module == null)) { return; } bool bypassPageSecurity = false; if ((securityBypassGuid != Guid.Empty) && (securityBypassGuid == WebConfigSettings.InternalFeedSecurityBypassKey)) { bypassPageSecurity = true; } if ( (bypassPageSecurity) || (WebUser.IsInRoles(pageSettings.AuthorizedRoles)) || (WebUser.IsInRoles(module.ViewRoles)) ) { canView = true; } if (!canView) { return; } if (WebConfigSettings.UseFolderBasedMultiTenants) { navigationSiteRoot = SiteUtils.GetNavigationSiteRoot(); blogBaseUrl = navigationSiteRoot; imageSiteRoot = WebUtils.GetSiteRoot(); cssBaseUrl = imageSiteRoot; } else { navigationSiteRoot = WebUtils.GetHostRoot(); blogBaseUrl = SiteUtils.GetNavigationSiteRoot(); imageSiteRoot = navigationSiteRoot; cssBaseUrl = WebUtils.GetSiteRoot(); } moduleSettings = ModuleSettings.GetModuleSettings(moduleId); config = new BlogConfiguration(moduleSettings); if (config.FeedIsDisabled) { canView = false; } if ((config.FeedburnerFeedUrl.Length > 0) && (config.FeedburnerFeedUrl.StartsWith("http")) && (BlogConfiguration.UseRedirectForFeedburner)) { shouldRedirectToFeedburner = true; if ((Request.UserAgent != null) && (Request.UserAgent.Contains("FeedBurner"))) { shouldRedirectToFeedburner = false; // don't redirect if the feedburner bot is reading the feed } Guid redirectBypassToken = WebUtils.ParseGuidFromQueryString("r", Guid.Empty); if (redirectBypassToken == Global.FeedRedirectBypassToken) { shouldRedirectToFeedburner = false; // allows time for user to subscribe to autodiscovery links without redirecting } } }
protected virtual void LoadSettings() { siteSettings = CacheHelper.GetCurrentSiteSettings(); siteId = siteSettings.SiteId; currentUser = SiteUtils.GetCurrentSiteUser(); TimeOffset = SiteUtils.GetUserTimeOffset(); timeZone = SiteUtils.GetUserTimeZone(); GmapApiKey = SiteUtils.GetGmapApiKey(); addThisAccountId = siteSettings.AddThisDotComUsername; if (blogConfig.AddThisAccountId.Length > 0) { addThisAccountId = blogConfig.AddThisAccountId; } pageNumber = WebUtils.ParseInt32FromQueryString("pagenumber", pageNumber); categoryId = WebUtils.ParseInt32FromQueryString("cat", categoryId); Month = WebUtils.ParseInt32FromQueryString("month", Month); Year = WebUtils.ParseInt32FromQueryString("year", Year); attachmentBaseUrl = SiteUtils.GetFileAttachmentUploadPath(); if (Page is mojoBasePage) { basePage = Page as mojoBasePage; module = basePage.GetModule(moduleId, config.FeatureGuid); } if (module == null) { return; } MaxAllowedGravatarRating = SiteUtils.GetMaxAllowedGravatarRating(); switch (siteSettings.AvatarSystem) { case "gravatar": allowGravatars = true; disableAvatars = false; break; case "internal": allowGravatars = false; disableAvatars = false; break; case "none": default: allowGravatars = false; disableAvatars = true; break; } CalendarDate = WebUtils.ParseDateFromQueryString("blogdate", DateTime.UtcNow).Date; if (CalendarDate > DateTime.UtcNow.Date) { CalendarDate = DateTime.UtcNow.Date; } if ((blogConfig.UseExcerpt) && (!blogConfig.GoogleMapIncludeWithExcerpt)) { ShowGoogleMap = false; } if (blogConfig.UseExcerpt) { EnableContentRating = false; } if (blogConfig.DisqusSiteShortName.Length > 0) { DisqusSiteShortName = blogConfig.DisqusSiteShortName; } else { DisqusSiteShortName = siteSettings.DisqusSiteShortName; } if (blogConfig.IntenseDebateAccountId.Length > 0) { IntenseDebateAccountId = blogConfig.IntenseDebateAccountId; } else { IntenseDebateAccountId = siteSettings.IntenseDebateAccountId; } ShowTweetThisLink = blogConfig.ShowTweetThisLink && !blogConfig.UseExcerpt; ShowPlusOneButton = blogConfig.ShowPlusOneButton && !blogConfig.UseExcerpt; UseFacebookLikeButton = blogConfig.UseFacebookLikeButton && !blogConfig.UseExcerpt; pageSize = blogConfig.PageSize; useFriendlyUrls = BlogConfiguration.UseFriendlyUrls(moduleId); if (!WebConfigSettings.UseUrlReWriting) { useFriendlyUrls = false; } }
protected virtual void LoadSettings() { siteSettings = CacheHelper.GetCurrentSiteSettings(); SiteId = siteSettings.SiteId; currentUser = SiteUtils.GetCurrentSiteUser(); TimeOffset = SiteUtils.GetUserTimeOffset(); timeZone = SiteUtils.GetUserTimeZone(); GmapApiKey = SiteUtils.GetGmapApiKey(); addThisAccountId = siteSettings.AddThisDotComUsername; if (config.AddThisAccountId.Length > 0) { addThisAccountId = config.AddThisAccountId; } pageNumber = WebUtils.ParseInt32FromQueryString("pagenumber", pageNumber); categoryId = WebUtils.ParseInt32FromQueryString("cat", categoryId); Month = WebUtils.ParseInt32FromQueryString("month", Month); Year = WebUtils.ParseInt32FromQueryString("year", Year); attachmentBaseUrl = SiteUtils.GetFileAttachmentUploadPath(); if (Page is mojoBasePage) { basePage = Page as mojoBasePage; module = basePage.GetModule(ModuleId, Blog.FeatureGuid); } if (module == null) { return; } MaxAllowedGravatarRating = SiteUtils.GetMaxAllowedGravatarRating(); UserNameTooltipFormat = displaySettings.AvatarUserNameTooltipFormat; switch (siteSettings.AvatarSystem) { case "gravatar": allowGravatars = true; disableAvatars = false; break; case "internal": allowGravatars = false; disableAvatars = false; break; case "none": default: allowGravatars = false; disableAvatars = true; break; } //if (!config.ShowAuthorAvatar) { disableAvatars = true; } if (config.UseExcerpt && !displaySettings.ShowAvatarWithExcerpt) { disableAvatars = true; } CalendarDate = WebUtils.ParseDateFromQueryString("blogdate", DateTime.UtcNow).Date; if (CalendarDate > DateTime.UtcNow.Date) { CalendarDate = DateTime.UtcNow.Date; } if ((config.UseExcerpt) && (!config.GoogleMapIncludeWithExcerpt)) { ShowGoogleMap = false; } EnableContentRating = config.EnableContentRating && !displaySettings.PostListDisableContentRating; if (config.UseExcerpt) { EnableContentRating = false; } //if (config.AddThisCustomBrand.Length > 0) //{ // addThisCustomBrand = config.AddThisCustomBrand; //} if (config.DisqusSiteShortName.Length > 0) { DisqusSiteShortName = config.DisqusSiteShortName; } else { DisqusSiteShortName = siteSettings.DisqusSiteShortName; } if (config.IntenseDebateAccountId.Length > 0) { IntenseDebateAccountId = config.IntenseDebateAccountId; } else { IntenseDebateAccountId = siteSettings.IntenseDebateAccountId; } Control cNav = Page.LoadControl("~/Blog/Controls/BlogNav.ascx"); BlogNav nav = (BlogNav)cNav; nav.ModuleId = ModuleId; nav.ModuleGuid = module.ModuleGuid; nav.PageId = PageId; nav.IsEditable = IsEditable; nav.Config = config; nav.SiteRoot = SiteRoot; nav.ImageSiteRoot = ImageSiteRoot; TitleOnly = config.TitleOnly || displaySettings.PostListForceTitleOnly; ShowTweetThisLink = config.ShowTweetThisLink && !config.UseExcerpt; ShowPlusOneButton = config.ShowPlusOneButton && !config.UseExcerpt; UseFacebookLikeButton = config.UseFacebookLikeButton && !config.UseExcerpt; useExcerpt = config.UseExcerpt || displaySettings.PostListForceExcerptMode; pageSize = config.PageSize; AllowComments = Config.AllowComments && ShowCommentCounts; //TODO: should we use separate settings for each displaymode? switch (DisplayMode) { case "ByCategory": if (displaySettings.CategoryListForceTitleOnly) { TitleOnly = true; } if (displaySettings.CategoryListOverridePageSize > 0) { pageSize = displaySettings.CategoryListOverridePageSize; } if (displaySettings.ArchiveViewHideFeedbackLink) { AllowComments = false; } if (displaySettings.OverrideCategoryListItemHeadingElement.Length > 0) { itemHeadingElement = displaySettings.OverrideCategoryListItemHeadingElement; } break; case "ByMonth": if (displaySettings.ArchiveListForceTitleOnly) { TitleOnly = true; } if (displaySettings.ArchiveListOverridePageSize > 0) { pageSize = displaySettings.ArchiveListOverridePageSize; } if (displaySettings.OverrideArchiveListItemHeadingElement.Length > 0) { itemHeadingElement = displaySettings.OverrideArchiveListItemHeadingElement; } break; case "DescendingByDate": default: if (displaySettings.PostListOverridePageSize > 0) { pageSize = displaySettings.PostListOverridePageSize; } if (displaySettings.OverrideListItemHeadingElement.Length > 0) { itemHeadingElement = displaySettings.OverrideListItemHeadingElement; } break; } if (config.AllowComments) { if ((DisqusSiteShortName.Length > 0) && (config.CommentSystem == "disqus")) { disqusFlag = "#disqus_thread"; disqus.SiteShortName = DisqusSiteShortName; disqus.RenderCommentCountScript = true; nav.ShowCommentCount = false; } if ((IntenseDebateAccountId.Length > 0) && (config.CommentSystem == "intensedebate")) { ShowCommentCounts = false; nav.ShowCommentCount = false; } if (config.CommentSystem == "facebook") { ShowCommentCounts = false; nav.ShowCommentCount = false; } } else { nav.ShowCommentCount = false; } bool showNav = false; if ( config.ShowCalendar || config.ShowArchives || ((config.ShowFeedLinks == true && displaySettings.HideFeedLinks == false) ? true : false) || config.ShowCategories || config.ShowStatistics || !string.IsNullOrWhiteSpace(config.UpperSidebar) || !string.IsNullOrWhiteSpace(config.LowerSidebar) ) { showNav = true; } divBlog.CssClass = displaySettings.ListViewCenterClass; if (showNav) { if (config.NavigationOnRight) { phNavRight.Controls.Add(nav); divBlog.CssClass += " " + displaySettings.ListViewCenterRightNavClass; } else { phNavLeft.Controls.Add(nav); divBlog.CssClass += " " + displaySettings.ListViewCenterLeftNavClass; } } else { divBlog.CssClass += " " + displaySettings.ListViewCenterNoNavClass; } if (displaySettings.PostListExtraCss.Length > 0) { divBlog.CssClass += " " + displaySettings.PostListExtraCss; } pnlLayoutRow.RenderId = false; pnlLayoutRow.RenderContentsOnly = true; pnlLayoutRow.CssClass = displaySettings.LayoutRowClass; if (showNav && displaySettings.LayoutRowRender) { pnlLayoutRow.RenderContentsOnly = false; } useFriendlyUrls = BlogConfiguration.UseFriendlyUrls(ModuleId); if (!WebConfigSettings.UseUrlReWriting) { useFriendlyUrls = false; } if (config.Copyright.Length > 0) { litCopyright.Text = config.Copyright; pnlCopyright.Visible = true; } pnlCopyright.CssClass = displaySettings.CopyrightPanelClass; pnlPager.CssClass = displaySettings.PagerPanelClass; }
/// <summary> /// metaWeblog.newPost method /// </summary> /// <param name="blogId"> /// always 1000 in BlogEngine since it is a singlar blog instance /// </param> /// <param name="userName"> /// login username /// </param> /// <param name="password"> /// login password /// </param> /// <param name="sentPost"> /// struct with post details /// </param> /// <param name="publish"> /// mark as published? /// </param> /// <returns> /// postID as string /// </returns> internal string NewPost(string blogId, string userName, string password, MWAPost sentPost, bool publish) { int moduleId = Convert.ToInt32(blogId); if (!UserCanPostToBlog(userName, moduleId)) { throw new MetaWeblogException("11", MetaweblogResources.AccessDenied); } try { Module module = new Module(moduleId); Blog post = new Blog(); post.ModuleId = module.ModuleId; post.ModuleGuid = module.ModuleGuid; post.UserGuid = siteUser.UserGuid; post.LastModUserGuid = siteUser.UserGuid; if ((sentPost.postDate != null) && (sentPost.postDate > DateTime.MinValue) && (sentPost.postDate < DateTime.MaxValue)) { if (!WebConfigSettings.DisableUseOfPassedInDateForMetaWeblogApi) { post.StartDate = sentPost.postDate; } } post.Title = sentPost.title; post.Description = SiteUtils.ChangeFullyQualifiedLocalUrlsToRelative(navigationSiteRoot, imageSiteRoot, sentPost.description); if (!string.IsNullOrEmpty(sentPost.excerpt)) { if (BlogConfiguration.UseExcerptFromMetawblogAsMetaDescription) { post.MetaDescription = UIHelper.CreateExcerpt(sentPost.excerpt, BlogConfiguration.MetaDescriptionMaxLengthToGenerate); } post.Excerpt = SiteUtils.ChangeFullyQualifiedLocalUrlsToRelative(navigationSiteRoot, imageSiteRoot, sentPost.excerpt); } post.IncludeInFeed = true; post.IsPublished = publish; //post.Slug = sentPost.slug; //string author = String.IsNullOrEmpty(sentPost.author) ? userName : sentPost.author; switch (sentPost.commentPolicy) { //closed case "2": post.AllowCommentsForDays = -1; // closed break; // open case "1": default: Hashtable moduleSettings = ModuleSettings.GetModuleSettings(post.ModuleId); BlogConfiguration config = new BlogConfiguration(moduleSettings); post.AllowCommentsForDays = config.DefaultCommentDaysAllowed; break; } string newUrl = SiteUtils.SuggestFriendlyUrl(post.Title, siteSettings); post.ItemUrl = "~/" + newUrl; if (!post.Title.Contains("Theme Detection")) // don't index a temp post from livewriter that will be deleted { post.ContentChanged += new ContentChangedEventHandler(blog_ContentChanged); } post.Save(); int pageId = GetPageIdForModule(moduleId); FriendlyUrl newFriendlyUrl = new FriendlyUrl(); newFriendlyUrl.SiteId = siteSettings.SiteId; newFriendlyUrl.SiteGuid = siteSettings.SiteGuid; newFriendlyUrl.PageGuid = post.BlogGuid; newFriendlyUrl.Url = newUrl; newFriendlyUrl.RealUrl = "~/Blog/ViewPost.aspx?pageid=" + pageId.ToInvariantString() + "&mid=" + post.ModuleId.ToInvariantString() + "&ItemID=" + post.ItemId.ToInvariantString(); if (pageId > -1) { newFriendlyUrl.Save(); } SetCategories(post, sentPost); //post.Tags.Clear(); //foreach (var item in sentPost.tags.Where(item => item != null && item.Trim() != string.Empty)) //{ // post.Tags.Add(item); //} if (!post.Title.Contains("Theme Detection")) // don't index a temp post from livewriter that will be deleted { SiteUtils.QueueIndexing(); } return post.ItemId.ToString(); } catch (Exception ex) { log.Error(ex); throw new MetaWeblogException("12", string.Format("Create new post failed. Error: {0}", ex.Message)); } }
private void LoadSettings() { if ((WebUser.IsAdminOrContentAdmin) || (SiteUtils.UserIsSiteEditor())) { isAdmin = true; } txtTitle.MaxLength = BlogConfiguration.PostTitleMaxLength; currentUser = SiteUtils.GetCurrentSiteUser(); ScriptConfig.IncludeColorBox = true; Hashtable moduleSettings = ModuleSettings.GetModuleSettings(moduleId); config = new BlogConfiguration(moduleSettings); useFriendlyUrls = BlogConfiguration.UseFriendlyUrls(moduleId); if (!useFriendlyUrls) { divUrl.Attributes.Add("style", "display:none;"); } lnkCancel.NavigateUrl = SiteUtils.GetCurrentPageUrl(); lnkCancel2.NavigateUrl = lnkCancel.NavigateUrl; lnkCancel3.NavigateUrl = lnkCancel.NavigateUrl; lnkCancel5.NavigateUrl = lnkCancel.NavigateUrl; enableContentVersioning = config.EnableContentVersioning; if ((siteSettings.ForceContentVersioning) || (WebConfigSettings.EnforceContentVersioningGlobally)) { enableContentVersioning = true; } SiteUtils.EnsureFileAttachmentFolder(siteSettings); upLoadPath = SiteUtils.GetFileAttachmentUploadPath(); if (itemId > -1) { blog = new Blog(itemId); if (blog.ModuleId != moduleId) { SiteUtils.RedirectToAccessDeniedPage(this); return; } uploader.MaxFilesAllowed = BlogConfiguration.MaxAttachmentsToUploadAtOnce; //uploader.AcceptFileTypes = SecurityHelper.GetRegexValidationForAllowedExtensionsJqueryFileUploader(WebConfigSettings.AllowedMediaFileExtensions); uploader.UploadButtonClientId = btnUpload.ClientID; uploader.ServiceUrl = SiteRoot + "/Blog/upload.ashx?pageid=" + pageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString() + "&ItemID=" + itemId.ToInvariantString(); uploader.FormFieldClientId = hdnState.ClientID; // not really used but prevents submitting all the form string refreshFunction = "function refresh" + moduleId.ToInvariantString() + " () { window.location.reload(true); } "; uploader.UploadCompleteCallback = "refresh" + moduleId.ToInvariantString(); ScriptManager.RegisterClientScriptBlock( this, this.GetType(), "refresh" + moduleId.ToInvariantString(), refreshFunction, true); } btnUpload.Enabled = (blog != null); litAttachmentWarning.Visible = (blog == null); pnlMetaData.Visible = (blog != null); divHistoryDelete.Visible = (enableContentVersioning && isAdmin); pnlHistory.Visible = enableContentVersioning; if (enableContentVersioning) { SetupHistoryRestoreScript(); } try { // this keeps the action from changing during ajax postback in folder based sites SiteUtils.SetFormAction(Page, Request.RawUrl); } catch (MissingMethodException) { //this method was introduced in .NET 3.5 SP1 } FileSystemProvider p = FileSystemManager.Providers[WebConfigSettings.FileSystemProvider]; if (p == null) { return; } fileSystem = p.GetFileSystem(); }
/// <summary> /// metaWeblog.editPost method /// </summary> /// <param name="postId"> /// post guid in string format /// </param> /// <param name="userName"> /// login username /// </param> /// <param name="password"> /// login password /// </param> /// <param name="sentPost"> /// struct with post details /// </param> /// <param name="publish"> /// mark as published? /// </param> /// <returns> /// 1 if successful /// </returns> internal bool EditPost(string postId, string userName, string password, MWAPost sentPost, bool publish) { int blogid = Convert.ToInt32(postId); if (!UserCanEditPost(userName, blogid)) { throw new MetaWeblogException("11", MetaweblogResources.AccessDenied); } string author = String.IsNullOrEmpty(sentPost.author) ? userName : sentPost.author; Blog post = new Blog(blogid); if (post.ItemId == -1) { //not found throw new MetaWeblogException("11", MetaweblogResources.PostNotFound); } try { Hashtable moduleSettings = ModuleSettings.GetModuleSettings(post.ModuleId); BlogConfiguration config = new BlogConfiguration(moduleSettings); post.LastModUserGuid = siteUser.UserGuid; post.Title = sentPost.title; post.Description = SiteUtils.ChangeFullyQualifiedLocalUrlsToRelative(navigationSiteRoot, imageSiteRoot, sentPost.description); post.IsPublished = publish; //post.Slug = sentPost.slug; if (!string.IsNullOrEmpty(sentPost.excerpt)) { if (BlogConfiguration.UseExcerptFromMetawblogAsMetaDescription) { post.MetaDescription = UIHelper.CreateExcerpt(sentPost.excerpt, BlogConfiguration.MetaDescriptionMaxLengthToGenerate); } post.Excerpt = SiteUtils.ChangeFullyQualifiedLocalUrlsToRelative(navigationSiteRoot, imageSiteRoot, sentPost.excerpt); } switch (sentPost.commentPolicy) { //closed case "2": post.AllowCommentsForDays = -1; // closed break; // open case "1": // if the post was previously closed to comments // re-open it using the default allowed days if (post.AllowCommentsForDays < 0) { post.AllowCommentsForDays = config.DefaultCommentDaysAllowed; } break; //else unspecified, no change } post.ContentChanged += new ContentChangedEventHandler(blog_ContentChanged); bool enableContentVersioning = config.EnableContentVersioning; if ((siteSettings.ForceContentVersioning) || (WebConfigSettings.EnforceContentVersioningGlobally)) { enableContentVersioning = true; } if (enableContentVersioning) { post.CreateHistory(siteSettings.SiteGuid); } post.Save(); SetCategories(post, sentPost); SiteUtils.QueueIndexing(); return true; } catch (Exception ex) { log.Error(ex); throw new MetaWeblogException("12", string.Format("EditPost failed. Error: {0}", ex.Message)); } }
private void PopulateControls() { Title = SiteUtils.FormatPageTitle(siteSettings, BlogResources.PostList); moduleTitle.EditUrl = SiteRoot + "/Blog/EditPost.aspx"; moduleTitle.EditText = BlogResources.BlogAddPostLabel; moduleTitle.ModuleInstance = GetModule(moduleId); moduleTitle.CanEdit = userCanEdit; //if ((userCanEdit) && (countOfDrafts > 0)) //{ // moduleTitle.LiteralExtraMarkup = // " <a href='" // + SiteRoot // + "/Blog/EditCategory.aspx?pageid=" + pageId.ToInvariantString() // + "&mid=" + moduleId.ToInvariantString() // + "' class='ModuleEditLink' title='" + BlogResources.BlogEditCategoriesLabel + "'>" + BlogResources.BlogEditCategoriesLabel + "</a>" // + " <a href='" // + SiteRoot // + "/Blog/Drafts.aspx?pageid=" + pageId.ToInvariantString() // + "&mid=" + moduleId.ToInvariantString() // + "' class='ModuleEditLink' title='" + BlogResources.BlogDraftsLink + "'>" + BlogResources.BlogDraftsLink + "</a>"; //} //else if (userCanEdit) { moduleTitle.LiteralExtraMarkup = " <a href='" + SiteRoot + "/Blog/Manage.aspx?pageid=" + pageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString() + "' class='ModuleEditLink' title='" + BlogResources.Administration + "'>" + BlogResources.Administration + "</a>" ; } postList.ModuleId = moduleId; postList.PageId = pageId; postList.IsEditable = userCanEdit; BlogConfiguration config = new BlogConfiguration(ModuleSettings.GetModuleSettings(moduleId)); postList.Config = config; postList.SiteRoot = SiteRoot; postList.ImageSiteRoot = ImageSiteRoot; if (config.InstanceCssClass.Length > 0) { pnlOuterWrap.SetOrAppendCss(config.InstanceCssClass); } searchBoxTop.Visible = config.ShowBlogSearchBox && !displaySettings.HideSearchBoxInPostList; //make this page look as close as possible to the way a cms page with the blog module on it looks LoadSideContent(true, true); LoadAltContent(BlogConfiguration.ShowTopContent, BlogConfiguration.ShowBottomContent); }
private void LoadSettings() { currentUser = SiteUtils.GetCurrentSiteUser(); config = new BlogConfiguration(ModuleSettings.GetModuleSettings(moduleId)); lnkCategories.NavigateUrl = SiteRoot + "/Blog/EditCategory.aspx?pageid=" + pageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString(); lnkNewPost.NavigateUrl = SiteRoot + "/Blog/EditPost.aspx?pageid=" + pageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString(); lnkDrafts.NavigateUrl = SiteRoot + "/Blog/Drafts.aspx?pageid=" + pageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString(); lnkClosedPosts.NavigateUrl = SiteRoot + "/Blog/ClosedPosts.aspx?pageid=" + pageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString(); if (currentUser == null) { return; } if (BlogConfiguration.SecurePostsByUser) { if (WebUser.IsInRoles(config.ApproverRoles)) { countOfDrafts = Blog.GetCountOfDrafts(moduleId, Guid.Empty); } else { countOfDrafts = Blog.GetCountOfDrafts(moduleId, currentUser.UserGuid); } } else { countOfDrafts = Blog.GetCountOfDrafts(moduleId, Guid.Empty); } countOfExpiredPosts = Blog.GetCountClosed(moduleId); }
private void LoadSettings() { pageID = WebUtils.ParseInt32FromQueryString("pageid", -1); moduleId = WebUtils.ParseInt32FromQueryString("mid", -1); categoryId = WebUtils.ParseInt32FromQueryString("cat", categoryId); siteSettings = CacheHelper.GetCurrentSiteSettings(); // newer implementation combines params as p=pageid~moduleid~categoryid string f = WebUtils.ParseStringFromQueryString("p", string.Empty); if ((f.Length > 0) && (f.Contains("~"))) { List<string> parms = f.SplitOnCharAndTrim('~'); if (parms.Count >= 1) { int.TryParse(parms[0], NumberStyles.Integer, CultureInfo.InvariantCulture, out pageID); } if (parms.Count >= 2) { int.TryParse(parms[1], NumberStyles.Integer, CultureInfo.InvariantCulture, out moduleId); } if (parms.Count >= 3) { int.TryParse(parms[2], NumberStyles.Integer, CultureInfo.InvariantCulture, out categoryId); } } securityBypassGuid = WebUtils.ParseGuidFromQueryString("g", securityBypassGuid); attachmentBaseUrl = SiteUtils.GetFileAttachmentUploadPath(); pageSettings = CacheHelper.GetPage(pageID); module = GetModule(); if ((moduleId == -1) || (module == null)) { return; } bool bypassPageSecurity = false; if ((securityBypassGuid != Guid.Empty) && (securityBypassGuid == WebConfigSettings.InternalFeedSecurityBypassKey)) { bypassPageSecurity = true; } if ( (bypassPageSecurity) || (WebUser.IsInRoles(pageSettings.AuthorizedRoles)) || (WebUser.IsInRoles(module.ViewRoles)) ) { canView = true; } if (!canView) { return; } if (WebConfigSettings.UseFoldersInsteadOfHostnamesForMultipleSites) { navigationSiteRoot = SiteUtils.GetNavigationSiteRoot(); blogBaseUrl = navigationSiteRoot; imageSiteRoot = WebUtils.GetSiteRoot(); cssBaseUrl = imageSiteRoot; } else { navigationSiteRoot = WebUtils.GetHostRoot(); blogBaseUrl = SiteUtils.GetNavigationSiteRoot(); imageSiteRoot = navigationSiteRoot; cssBaseUrl = WebUtils.GetSiteRoot(); } moduleSettings = ModuleSettings.GetModuleSettings(moduleId); config = new BlogConfiguration(moduleSettings); if (config.FeedIsDisabled) { canView = false; } if ((config.FeedburnerFeedUrl.Length > 0) && (config.FeedburnerFeedUrl.StartsWith("http")) && (BlogConfiguration.UseRedirectForFeedburner)) { shouldRedirectToFeedburner = true; if ((Request.UserAgent != null) && (Request.UserAgent.Contains("FeedBurner"))) { shouldRedirectToFeedburner = false; // don't redirect if the feedburner bot is reading the feed } Guid redirectBypassToken = WebUtils.ParseGuidFromQueryString("r", Guid.Empty); if (redirectBypassToken == Global.FeedRedirectBypassToken) { shouldRedirectToFeedburner = false; // allows time for user to subscribe to autodiscovery links without redirecting } } }
private void LoadSettings() { moduleSettings = ModuleSettings.GetModuleSettings(moduleId); config = new BlogConfiguration(moduleSettings); postList.ModuleId = moduleId; postList.PageId = pageId; postList.DisplayMode = "ByCategory"; postList.IsEditable = UserCanEditModule(moduleId, Blog.FeatureGuid); postList.Config = config; postList.SiteRoot = SiteRoot; postList.ImageSiteRoot = ImageSiteRoot; if (config.InstanceCssClass.Length > 0) { pnlOuterWrap.SetOrAppendCss(config.InstanceCssClass); } if ((CurrentPage != null) && (CurrentPage.BodyCssClass.Length > 0)) { AddClassToBody(CurrentPage.BodyCssClass); } AddClassToBody("blogviewcategory"); if (BlogConfiguration.UseNoIndexFollowMetaOnLists) { SiteUtils.AddNoIndexFollowMeta(Page); } }
protected virtual void LoadSettings() { siteSettings = CacheHelper.GetCurrentSiteSettings(); siteId = siteSettings.SiteId; currentUser = SiteUtils.GetCurrentSiteUser(); TimeOffset = SiteUtils.GetUserTimeOffset(); timeZone = SiteUtils.GetUserTimeZone(); GmapApiKey = SiteUtils.GetGmapApiKey(); addThisAccountId = siteSettings.AddThisDotComUsername; if (blogConfig.AddThisAccountId.Length > 0) { addThisAccountId = blogConfig.AddThisAccountId; } pageNumber = WebUtils.ParseInt32FromQueryString("pagenumber", pageNumber); categoryId = WebUtils.ParseInt32FromQueryString("cat", categoryId); Month = WebUtils.ParseInt32FromQueryString("month", Month); Year = WebUtils.ParseInt32FromQueryString("year", Year); attachmentBaseUrl = SiteUtils.GetFileAttachmentUploadPath(); //if (Page is mojoBasePage) //{ // basePage = Page as mojoBasePage; // module = basePage.GetModule(moduleId, config.FeatureGuid); //} module = new Module(moduleId); //if (module == null) //{ // return; //} CalendarDate = WebUtils.ParseDateFromQueryString("blogdate", DateTime.UtcNow).Date; if (CalendarDate > DateTime.UtcNow.Date) { CalendarDate = DateTime.UtcNow.Date; } if (blogConfig.UseExcerpt && !blogConfig.GoogleMapIncludeWithExcerpt) { ShowGoogleMap = false; } if (blogConfig.UseExcerpt) { EnableContentRating = false; } if (blogConfig.DisqusSiteShortName.Length > 0) { DisqusSiteShortName = blogConfig.DisqusSiteShortName; } else { DisqusSiteShortName = siteSettings.DisqusSiteShortName; } if (blogConfig.IntenseDebateAccountId.Length > 0) { IntenseDebateAccountId = blogConfig.IntenseDebateAccountId; } else { IntenseDebateAccountId = siteSettings.IntenseDebateAccountId; } ShowTweetThisLink = blogConfig.ShowTweetThisLink && !blogConfig.UseExcerpt; ShowPlusOneButton = blogConfig.ShowPlusOneButton && !blogConfig.UseExcerpt; UseFacebookLikeButton = blogConfig.UseFacebookLikeButton && !blogConfig.UseExcerpt; pageSize = config.ItemsPerPage; useFriendlyUrls = BlogConfiguration.UseFriendlyUrls(moduleId); if (!WebConfigSettings.UseUrlReWriting) { useFriendlyUrls = false; } if (WebConfigSettings.UseFolderBasedMultiTenants) { navigationSiteRoot = SiteUtils.GetNavigationSiteRoot(); imageSiteRoot = WebUtils.GetSiteRoot(); } else { navigationSiteRoot = WebUtils.GetHostRoot(); imageSiteRoot = navigationSiteRoot; } }
private void LoadSettings() { timeOffset = SiteUtils.GetUserTimeOffset(); timeZone = SiteUtils.GetUserTimeZone(); pageId = WebUtils.ParseInt32FromQueryString("pageid", pageId); moduleId = WebUtils.ParseInt32FromQueryString("mid", moduleId); pageNumber = WebUtils.ParseInt32FromQueryString("pagenumber", pageNumber); currentUser = SiteUtils.GetCurrentSiteUser(); config = new BlogConfiguration(ModuleSettings.GetModuleSettings(moduleId)); AddClassToBody("blogdrafts"); }
private void LoadSettings() { TimeOffset = SiteUtils.GetUserTimeOffset(); timeZone = SiteUtils.GetUserTimeZone(); config = new BlogConfiguration(ModuleSettings.GetModuleSettings(moduleId)); currentUser = SiteUtils.GetCurrentSiteUser(); useFriendlyUrls = BlogConfiguration.UseFriendlyUrls(moduleId); if (!WebConfigSettings.UseUrlReWriting) { useFriendlyUrls = false; } }