string GetProfilePath() { SharedBasePage requestPage = this.Page as SharedBasePage; string profileFilename = string.Format("{0}.format.html", requestPage.User.Identity.Name); return(SiteUtilities.MapPath(Path.Combine(requestPage.SiteConfig.ProfilesDir, profileFilename))); }
void GravatarPopulateConfig() { SharedBasePage requestPage = Page as SharedBasePage; SiteConfig siteConfig = requestPage.SiteConfig; siteConfig.CommentsAllowGravatar = checkEnableGravatar.Checked; siteConfig.CommentsGravatarNoImgPath = textNoGravatarPath.Text.Trim(); siteConfig.CommentsGravatarBorder = textGravatarBorderColor.Text.Trim(); siteConfig.CommentsGravatarRating = dropGravatarRating.SelectedValue; try { int gpix = Convert.ToInt32(textGravatarSize.Text.Trim()); if (gpix > 0 && gpix <= 80) { siteConfig.CommentsGravatarSize = gpix.ToString(); } else { siteConfig.CommentsGravatarSize = defaultGravatarSize; } } catch (FormatException) { siteConfig.CommentsGravatarSize = String.Empty; } }
protected override EntryCollection LoadEntries() { SharedBasePage requestPage = this.Page as SharedBasePage; string userName = Request.QueryString["user"]; return(DataService.GetEntriesForUser(userName)); }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); SharedBasePage requestPage = Page as SharedBasePage; if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "script")) { string script; using (StreamReader rs = new StreamReader(GetType().Assembly.GetManifestResourceStream(GetType().Namespace + ".SearchHighlightJS.txt"))) { script = rs.ReadToEnd(); } script = script.Replace("<%siteRoot%>", requestPage.SiteConfig.Root); Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "script", String.Format("<script type=\"text/javascript\">\n<!--\n{0}\n// -->\n</script>", script)); } if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "style")) { string script; using (StreamReader rs = new StreamReader(GetType().Assembly.GetManifestResourceStream(GetType().Namespace + ".SearchHighlightCSS.txt"))) { script = rs.ReadToEnd(); } Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "style", ""); requestPage.InsertInPageHeader(String.Format("<style type=\"text/css\">{0}</style>", script)); } }
protected void buttonSave_Click(object sender, EventArgs e) { if (Page.IsValid) { SharedBasePage requestPage = Page as SharedBasePage; SiteConfig siteConfig = requestPage.SiteConfig; string userName = requestPage.User.Identity.Name; User user = SiteSecurity.GetUser(userName); // failed to retrieve the user if (user != null) { if (textPassword.Text.Length > 0 && textPassword.Text != passwordPlaceHolder) { user.Password = textPassword.Text; } user.EmailAddress = textEMail.Text; user.NotifyOnNewPost = checkboxNewPost.Checked; user.NotifyOnAllComment = checkboxAllComment.Checked; user.NotifyOnOwnComment = checkboxOwnComment.Checked; user.DisplayName = textDisplayName.Text; user.OpenIDUrl = textOpenIdIdentifier.Text; SiteSecurity.UpdateUser(user); } SetProfileContent(editControl.Text); requestPage.Redirect(Page.Request.Url.AbsoluteUri); } }
protected void Page_Load(object sender, EventArgs e) { SharedBasePage requestPage = this.Page as SharedBasePage; if (!SiteSecurity.IsValidContributor()) { Response.Redirect("~/FormatPage.aspx?path=SiteConfig/accessdenied.format.html"); } this.ID = "EditUserBox"; editControl.Text = GetProfileContent(); editControl.Width = Unit.Percentage(99d); editControl.Height = Unit.Pixel(400); editControl.SetLanguage(CultureInfo.CurrentUICulture.Name); editControl.SetTextDirection(requestPage.ReadingDirection); if (!IsPostBack) { SiteConfig siteConfig = requestPage.SiteConfig; User currentUser = SiteSecurity.GetUser(requestPage.User.Identity.Name); textEMail.Text = currentUser.EmailAddress; textDisplayName.Text = currentUser.DisplayName; checkboxNewPost.Checked = currentUser.NotifyOnNewPost; checkboxAllComment.Checked = currentUser.NotifyOnAllComment; checkboxOwnComment.Checked = currentUser.NotifyOnOwnComment; textPassword.Text = passwordPlaceHolder; textConfirmPassword.Text = passwordPlaceHolder; textOpenIdIdentifier.Text = currentUser.OpenIDUrl; DataBind(); } }
protected void Page_Load(object sender, System.EventArgs e) { requestPage = Page as SharedBasePage; // if you are commenting on your own blog, no need for Captha if (SiteSecurity.IsValidContributor()) { CaptchaControl1.Enabled = CaptchaControl1.Visible = false; } else { CaptchaControl1.Enabled = CaptchaControl1.Visible = requestPage.SiteConfig.EnableCaptcha; } resmgr = ApplicationResourceTable.Get(); if (!IsPostBack) { if (Request.Cookies["name"] != null) { string nameStr = HttpUtility.UrlDecode(Request.Cookies["name"].Value, Encoding.UTF8); //truncate at 32 chars to avoid abuse... name.Text = nameStr.Substring(0,Math.Min(32,nameStr.Length)); } if (Request.Cookies["email"] != null) { email.Text = HttpUtility.UrlDecode(Request.Cookies["email"].Value, Encoding.UTF8); } } DataBind(); }
protected void Page_Load(object sender, System.EventArgs e) { requestPage = Page as SharedBasePage; // if you are commenting on your own blog, no need for Captha if (SiteSecurity.IsValidContributor()) { CaptchaControl1.Enabled = CaptchaControl1.Visible = false; } else { CaptchaControl1.Enabled = CaptchaControl1.Visible = requestPage.SiteConfig.EnableCaptcha; } resmgr = ApplicationResourceTable.Get(); if (!IsPostBack) { if (Request.Cookies["name"] != null) { string nameStr = HttpUtility.UrlDecode(Request.Cookies["name"].Value, Encoding.UTF8); //truncate at 32 chars to avoid abuse... name.Text = nameStr.Substring(0, Math.Min(32, nameStr.Length)); } if (Request.Cookies["email"] != null) { email.Text = HttpUtility.UrlDecode(Request.Cookies["email"].Value, Encoding.UTF8); } } DataBind(); }
protected void Page_Load(object sender, System.EventArgs e) { if (SiteSecurity.IsInRole("admin") == false) { Response.Redirect("~/FormatPage.aspx?path=SiteConfig/accessdenied.format.html"); } if (!IsPostBack || Session["newtelligence.DasBlog.Web.EditBlogRollBox.OpmlTree"] == null) { SharedBasePage requestPage = Page as SharedBasePage; foreach (string file in Directory.GetFiles(SiteConfig.GetConfigPathFromCurrentContext(), "*.opml")) { listFiles.Items.Add(Path.GetFileName(file)); } if (listFiles.Items.Count == 0) { listFiles.Items.Add("blogroll.opml"); } Session["newtelligence.DasBlog.Web.EditBlogRollBox.baseFileName"] = baseFileName = listFiles.Items[0].Text; string fileName = Path.Combine(SiteConfig.GetConfigPathFromCurrentContext(), baseFileName); LoadOutline(fileName); } else { baseFileName = Session["newtelligence.DasBlog.Web.EditBlogRollBox.baseFileName"] as string; opmlTree = Session["newtelligence.DasBlog.Web.EditBlogRollBox.OpmlTree"] as Opml; } BindGrid(); }
void ArchiveMonthList_Load(object sender, EventArgs e) { DateTime[] daysWithEntries; _requestPage = this.Page as SharedBasePage; daysWithEntries = _requestPage.DataService.GetDaysWithEntries(DateTimeZone.Utc); _monthTable = new Dictionary <string, int>(); _monthList = new List <DateTime>(); string languageFilter = Page.Request.Headers["Accept-Language"]; foreach (DateTime date in daysWithEntries) { if (date <= DateTime.UtcNow) { DateTime month = new DateTime(date.Year, date.Month, 1, 0, 0, 0); string monthKey = month.ToString("MMMM, yyyy"); if (!_monthTable.ContainsKey(monthKey)) { EntryCollection entries = _requestPage.DataService.GetEntriesForMonth(month, DateTimeZone.Utc, languageFilter); if (entries != null) { _monthTable.Add(monthKey, entries.Count); _monthList.Add(month); } } } } _monthList.Sort(); _monthList.Reverse(); }
protected void Page_Load(object sender, EventArgs e) { lblTheme.Text = ApplicationResourceTable.Get().GetString("text_pick_theme"); SharedBasePage page = Page as SharedBasePage; if (!page.SiteConfig.EnableStartPageCaching) { ThemeDictionary themes; themes = page.DataCache["Themes"] as ThemeDictionary; if (themes != null && themes.Count > 1) { foreach (BlogTheme theme in themes.Values) { listThemes.Items.Add(new ListItem(theme.Title, theme.Name)); } } else { this.Visible = false; } } else { this.Visible = false; } if (page.BlogTheme.Name != null && page.BlogTheme.Name.Length > 0) { listThemes.SelectedValue = page.BlogTheme.Name; } }
void DayRenderHandler(Object source, DayRenderEventArgs e) { SharedBasePage requestPage = this.Page as SharedBasePage; e.Day.IsSelectable = false; foreach (DateTime day in daysWithEntries) { if (e.Day.Date == day) { e.Cell.Controls.Clear(); HyperLink link = new HyperLink(); link.Text = e.Day.DayNumberText; link.NavigateUrl = SiteUtilities.GetDayViewUrl(requestPage.SiteConfig, e.Day.Date); e.Cell.Controls.Add(link); e.Day.IsSelectable = true; break; } } // Because we are using the CssClass property, we explicitely want to check // whether a day is both weekend _and_ lastmonth. // Otherwise this day would show up either // with 'hCalendarOtherMonthStyle' or with 'hCalendarWeekendStyle'. if ((e.Day.IsWeekend) && (e.Day.IsOtherMonth)) { e.Cell.CssClass = "hCalendarOtherMonthWeekendStyle"; } }
protected void Page_Init(object sender, EventArgs e) { resmgr = ApplicationResourceTable.Get(); requestPage = Page as SharedBasePage; if (Request.QueryString["q"] != null && Page.IsPostBack == false) { string searchQuery = System.Web.HttpUtility.UrlDecode(Request.QueryString["q"]); EntryCollection entries = SearchEntries(searchQuery); requestPage.WeblogEntries.AddRange(entries); foreach (Entry entry in requestPage.WeblogEntries) { requestPage.ProcessItemTemplate(entry, contentPlaceHolder); } } else { requestPage.WeblogEntries.AddRange(new EntryCollection()); } labelSearchQuery.Text = String.Format("{0}: {1}", resmgr.GetString("text_search_query_title"), Request.QueryString["q"]); DataBind(); }
void GravatarPopulateForm() { SharedBasePage requestPage = Page as SharedBasePage; SiteConfig siteConfig = requestPage.SiteConfig; checkEnableGravatar.Checked = siteConfig.CommentsAllowGravatar; if (!String.IsNullOrEmpty(siteConfig.CommentsGravatarSize)) { int gpix = Convert.ToInt32(siteConfig.CommentsGravatarSize); if (gpix > 0) { textGravatarSize.Text = gpix.ToString(); } else { textGravatarSize.Text = defaultGravatarSize; } } if (siteConfig.CommentsGravatarNoImgPath != null) { textNoGravatarPath.Text = siteConfig.CommentsGravatarNoImgPath; } if (siteConfig.CommentsGravatarBorder != null) { textGravatarBorderColor.Text = siteConfig.CommentsGravatarBorder; } if (siteConfig.CommentsGravatarRating != null) { dropGravatarRating.SelectedValue = siteConfig.CommentsGravatarRating; } }
protected override void OnPreRender(EventArgs e) { SharedBasePage requestPage = Page as SharedBasePage; base.OnPreRender(e); if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "script")) { string prefix = String.Format("var ct_img_expanded = '{0}';\nvar ct_img_collapsed = '{1}';", requestPage.GetThemedImageUrl("outlinedown"), requestPage.GetThemedImageUrl("outlinearrow")); string script; using (StreamReader rs = new StreamReader(GetType().Assembly.GetManifestResourceStream(GetType().Namespace + ".CategoryListJS.txt"))) { script = rs.ReadToEnd(); } Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "script", String.Format("<script type=\"text/javascript\">\n<!--\n{0}\n{1}\n// --></script>", prefix, script)); } if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "style")) { string script; using (StreamReader rs = new StreamReader(GetType().Assembly.GetManifestResourceStream(GetType().Namespace + ".CategoryListCSS.txt"))) { script = rs.ReadToEnd(); } Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "style", ""); requestPage.InsertInPageHeader(String.Format("<style type=\"text/css\">{0}</style>", script)); } }
protected void add_Click(object sender, System.EventArgs e) { SharedBasePage requestPage = Page as SharedBasePage; // validate base entries Captcha and Comment Page.Validate("Base"); bool baseValid = Page.IsValid; // check the openid controls Page.Validate("OpenId"); bool openIdValid = Page.IsValid; // check the classic controls Name and Email Page.Validate("Classic"); bool classicValid = Page.IsValid; if (baseValid && openIdValid) { if (String.IsNullOrEmpty(openid_identifier.Text) == false && openid_identifier.Text != "Click to Sign In") { Session["pendingComment"] = comment.Text; Session["pendingEntryId"] = ViewState["entryId"].ToString().ToUpper(); OpenIdRelyingParty openid = new OpenIdRelyingParty(); try { IAuthenticationRequest req = openid.CreateRequest(openid_identifier.Text); ClaimsRequest sregRequest = new ClaimsRequest(); sregRequest.Email = DemandLevel.Require; sregRequest.Nickname = DemandLevel.Require; sregRequest.FullName = DemandLevel.Request; req.AddExtension(sregRequest); // Also add AX request explicitly so we can request first and last name individually. FetchRequest axRequest = new FetchRequest(); axRequest.Attributes.AddRequired(WellKnownAttributes.Name.First); axRequest.Attributes.AddRequired(WellKnownAttributes.Name.Last); req.AddExtension(axRequest); SaveCookies(); req.RedirectToProvider(); return; } catch (UriFormatException ue) //They've entered something that's not a URI! { requestPage.LoggingService.AddEvent(new EventDataItem(EventCodes.Error, "ERROR: " + openid_identifier.Text + " is not a valid URL. " + ue.Message, "")); } } } if (baseValid && classicValid) { //Why isn't Page.Validate("Normal") working? It returns false. Hm. if (!String.IsNullOrEmpty(name.Text.Trim())) { SaveCookies(); AddNewComment(name.Text, email.Text, homepage.Text, comment.Text, ViewState["entryId"].ToString().ToUpper(), /* openid */ false); } } }
private void blogRollGrid_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { enteringEditMode = true; SharedBasePage requestPage = Page as SharedBasePage; StoreEditItemIndexInViewState(blogRollGrid.EditItemIndex = e.Item.ItemIndex); Bind(); }
private void calendarMonth_SelectionChanged(object sender, EventArgs e) { //If we post back because of a Select Day click then redirect to the Day view with that day. // TODO: It'd be cleaner to override the Day rendering and make the link direct // and avoid this silly postback. SharedBasePage requestPage = this.Page as SharedBasePage; Response.Redirect(SiteUtilities.GetDayViewUrl(requestPage.SiteConfig, calendarMonth.SelectedDate)); }
private void cvCaptcha_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args) { SharedBasePage requestPage = Page as SharedBasePage; if (CaptchaControl1.Enabled && requestPage.SiteConfig.EnableCaptcha) { args.IsValid = CaptchaControl1.UserValidated; } }
protected void listProfiles_SelectedIndexChanged(object sender, System.EventArgs e) { SharedBasePage page = Page as SharedBasePage; string profileName = listProfiles.SelectedValue; if (profileName != null && profileName != string.Empty) { page.Redirect(string.Format("~/Profile.aspx?user={0}", profileName)); } }
protected override EntryCollection LoadEntries() { SharedBasePage requestPage = Page as SharedBasePage; EntryCollection entryCollection = DataService.GetEntriesForCategory(categoryName, Request.Headers["Accept-Language"]); if (!requestPage.SiteConfig.CategoryAllEntries) { // Do some paging if we are NOT showing all entries in category view. string pageString = Request.QueryString.Get("page"); int page; if (!int.TryParse(pageString, out page)) { page = 1; } if (page != 0) { int count = entryCollection.Count; if (count == 0) { Response.Redirect(SiteUtilities.GetBaseUrl()); } int entriesPerPage = SiteConfig.EntriesPerPage; int maxPage = (int)Math.Ceiling((double)count / (double)entriesPerPage); if (page > maxPage) { page = maxPage; } int lastEntryToInclude = page * entriesPerPage; // page = 1, remove everything after. // page = maxPage, remove everything before. // 1 < page < maxPage, remove left and right. if (page == maxPage) { entryCollection.RemoveRange(0, lastEntryToInclude - entriesPerPage); } else { // Remove to the right. entryCollection.RemoveRange(lastEntryToInclude, count - lastEntryToInclude); // Remove to the left. entryCollection.RemoveRange(0, lastEntryToInclude - entriesPerPage); } HttpContext.Current.Items["page"] = page; HttpContext.Current.Items["maxpage"] = maxPage; } } return(entryCollection); }
public override void SetTextDirection(SharedBasePage.TextDirection textDirection) { if (textDirection == SharedBasePage.TextDirection.RightToLeft) { _Control.ContentLangDirection = LanguageDirection.RightToLeft; } else // default to LTR { _Control.ContentLangDirection = LanguageDirection.LeftToRight; } }
override protected void OnInit(EventArgs e) { resmgr = ((System.Resources.ResourceManager)ApplicationResourceTable.Get()); SharedBasePage requestPage = Page as SharedBasePage; siteConfig = requestPage.SiteConfig; // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); }
void HandleCommands(object sender, CommandEventArgs e) { SharedBasePage page = Page as SharedBasePage; if ((string)e.CommandArgument == "") { page.UserTheme = ""; } else { page.UserTheme = (string)e.CommandArgument; } page.Redirect(page.Request.RawUrl); }
public int GetEditItemIndexFromViewState() { SharedBasePage requestPage = Page as SharedBasePage; object eii = requestPage.PageViewState[this.UniqueID + ":eii"]; if (eii != null && eii is int) { return((int)eii); } else { return(-1); } }
public int GetCurrentPageIndexFromViewState() { SharedBasePage requestPage = Page as SharedBasePage; object cpi = requestPage.PageViewState[this.UniqueID + ":cpi"]; if (cpi != null && cpi is int) { return((int)cpi); } else { return(0); } }
protected void listThemes_SelectedIndexChanged(object sender, EventArgs e) { SharedBasePage page = Page as SharedBasePage; string theme = listThemes.SelectedValue; if (theme == "") { page.UserTheme = ""; } else { page.UserTheme = theme; } page.Redirect(page.Request.RawUrl); }
protected void buttonTestSMTP_Click(object sender, EventArgs e) { SharedBasePage requestPage = Page as SharedBasePage; SiteConfig siteConfig = requestPage.SiteConfig; if (textSmtpServer.Text != "" & textNotificationEmailAddress.Text != "") { MailMessage emailMessage = new MailMessage(); emailMessage.To.Add(textNotificationEmailAddress.Text); emailMessage.Subject = String.Format("dasBlog test message"); emailMessage.Body = String.Format("This is a test message from dasBlog. If you are reading this then everything is working properly."); emailMessage.IsBodyHtml = false; emailMessage.BodyEncoding = Encoding.UTF8; emailMessage.From = new MailAddress(siteConfig.Contact); SendMailInfo sendMailInfo = new SendMailInfo(emailMessage, textSmtpServer.Text, checkEnableSmtpAuthentication.Checked, checkUseSSLForSMTP.Checked, textSmtpUsername.Text, textSmtpPassword.Text, int.Parse(textSmtpPort.Text)); try { sendMailInfo.SendMyMessage(); } catch (Exception ex) { //RyanG: Decode the real reason the error occured by looking at the inner exceptions StringBuilder exceptionMessage = new StringBuilder(); Exception lastException = ex; while (lastException != null) { if (exceptionMessage.Length > 0) { exceptionMessage.Append("; "); } exceptionMessage.Append(lastException.Message); lastException = lastException.InnerException; } ILoggingDataService logService = requestPage.LoggingService; logService.AddEvent( new EventDataItem(EventCodes.SmtpError, "", exceptionMessage.ToString())); Response.Redirect("FormatPage.aspx?path=SiteConfig/pageerror.format.html", true); } } }
private string HandleUpload(HtmlInputFile fileInput, string entryId, out string type, out long numBytes, out string savedFileName) { type = fileInput.PostedFile.ContentType; numBytes = fileInput.PostedFile.InputStream.Length; SharedBasePage requestPage = this.Page as SharedBasePage; string postedFileName = Path.GetFileName(fileInput.PostedFile.FileName); string filename = Path.Combine(entryId ?? "", postedFileName); string absUrl = requestPage.BinaryDataService.SaveFile(fileInput.PostedFile.InputStream, ref filename); savedFileName = Path.GetFileName(filename); return(absUrl); }
protected void Page_Load(object sender, EventArgs e) { SharedBasePage requestPage = this.Page as SharedBasePage; if (SiteSecurity.IsInRole("admin") == false) { Response.Redirect("~/FormatPage.aspx?path=SiteConfig/accessdenied.format.html"); } resmgr = ((ResourceManager)ApplicationResourceTable.Get()); if (!IsPostBack || contentFilters == null) { LoadFilters(); UpdateTestBox(); } BindGrid(); }
protected void Page_Load(object sender, EventArgs e) { SharedBasePage page = this.Page as SharedBasePage; if (!page.SiteConfig.EnableStartPageCaching) { UserCollection users = SiteSecurity.GetSecurity().Users; if (users != null && users.Count > 0) { listProfiles.Items.Add(new ListItem("(select)", string.Empty)); users.Sort(new UserSorter()); foreach (User user in users) { string profileName = string.Empty; if (user.DisplayName != null && user.DisplayName.Length > 0) { profileName = user.DisplayName; } else { profileName = user.Name; } listProfiles.Items.Add(new ListItem(profileName, user.Name)); } } else { this.Visible = false; } } else { this.Visible = false; } listProfiles.SelectedValue = string.Empty; }
void ArchiveMonthList_Load(object sender, EventArgs e) { DateTime[] daysWithEntries; _requestPage = this.Page as SharedBasePage; TimeZone timezone = null; if (_requestPage.SiteConfig.AdjustDisplayTimeZone) { timezone = _requestPage.SiteConfig.GetConfiguredTimeZone(); } else { timezone = new newtelligence.DasBlog.Util.UTCTimeZone(); } daysWithEntries = _requestPage.DataService.GetDaysWithEntries(timezone); _monthTable = new Dictionary <string, int>(); _monthList = new List <DateTime>(); string languageFilter = Page.Request.Headers["Accept-Language"]; foreach (DateTime date in daysWithEntries) { if (date <= DateTime.UtcNow) { DateTime month = new DateTime(date.Year, date.Month, 1, 0, 0, 0); string monthKey = month.ToString("MMMM, yyyy"); if (!_monthTable.ContainsKey(monthKey)) { EntryCollection entries = _requestPage.DataService.GetEntriesForMonth(month, timezone, languageFilter); if (entries != null) { _monthTable.Add(monthKey, entries.Count); _monthList.Add(month); } } } } _monthList.Sort(); _monthList.Reverse(); }
void ArchiveMonthList_Load(object sender, EventArgs e) { DateTime[] daysWithEntries; _requestPage = this.Page as SharedBasePage; TimeZone timezone = null; if (_requestPage.SiteConfig.AdjustDisplayTimeZone) { timezone = _requestPage.SiteConfig.GetConfiguredTimeZone(); } else { timezone = new newtelligence.DasBlog.Util.UTCTimeZone(); } daysWithEntries = _requestPage.DataService.GetDaysWithEntries(timezone); _monthTable = new Dictionary<string, int>(); _monthList = new List<DateTime>(); string languageFilter = Page.Request.Headers["Accept-Language"]; foreach (DateTime date in daysWithEntries) { if (date <= DateTime.UtcNow) { DateTime month = new DateTime(date.Year, date.Month, 1, 0, 0, 0); string monthKey = month.ToString("MMMM, yyyy"); if (!_monthTable.ContainsKey(monthKey)) { EntryCollection entries = _requestPage.DataService.GetEntriesForMonth(month, timezone, languageFilter); if (entries != null) { _monthTable.Add(monthKey, entries.Count); _monthList.Add(month); } } } } _monthList.Sort(); _monthList.Reverse(); }
protected void Page_Load(object sender, System.EventArgs e) { requestPage = this.Page as SharedBasePage; resmgr = ((System.Resources.ResourceManager) ApplicationResourceTable.Get()); DataBind(); }
public override void SetTextDirection(SharedBasePage.TextDirection textDirection) { if (textDirection == SharedBasePage.TextDirection.RightToLeft) { freeTextBox.TextDirection = FreeTextBoxControls.TextDirection.RightToLeft; } else // default to LTR { freeTextBox.TextDirection = FreeTextBoxControls.TextDirection.LeftToRight; } }
/// <summary> /// Sets the direction of the text in the Text property. /// </summary> /// <param name="textDirection">The direction of the text in the Text property</param> public virtual void SetTextDirection(SharedBasePage.TextDirection textDirection) { }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); requestPage = this.Page as SharedBasePage; // get lite-entries EntryCollection entries = requestPage.DataService.GetEntries(false); // sort entries foreach (Entry entry in entries) { if (!entry.IsPublic) { continue; } if (entry.Categories == null || entry.Categories.Length == 0) { EnsureCategory(NoCategory); sorted[NoCategory].Add(entry); } else { string[] catArray = entry.GetSplitCategories(); foreach (string cat in catArray) { EnsureCategory(cat); sorted[cat].Add(entry); } } } categories.Sort(StringComparer.InvariantCultureIgnoreCase); // Build the archive navigator StringBuilder catNav = new StringBuilder(); catNav.Append("<p>"); foreach (string cat in categories) { if (cat != NoCategory) { catNav.AppendFormat("<a href=\"archives.aspx#{0}\">{1} ({2})</a> • ", HttpUtility.UrlEncode(cat), cat, sorted[cat].Count); } } // add the no-category category last if (categories.Contains(NoCategory)) { ResourceManager resmgr = ApplicationResourceTable.Get(); ; string translatedNone = resmgr.GetString("text_no_category"); catNav.AppendFormat("<a href=\"archives.aspx#{0}\">{1} ({2})</a> • ", NoCategory, translatedNone, sorted[NoCategory].Count); } catNav.Append("</p>"); contentPlaceHolder.Controls.Add(new LiteralControl(catNav.ToString())); // render the categories with the post titles foreach (string cat in categories) { // render No Category last if (cat == NoCategory) { continue; } contentPlaceHolder.Controls.Add(RenderCategoryHeader(cat)); contentPlaceHolder.Controls.Add(RenderCategory(sorted[cat])); } // "no category" category if (categories.Contains(NoCategory)) { ResourceManager resmgr = ApplicationResourceTable.Get(); ; string none = resmgr.GetString("text_no_category"); // no link, since it's not possible to subscribe to contentPlaceHolder.Controls.Add(RenderCategoryHeader(NoCategory, none, false)); contentPlaceHolder.Controls.Add(RenderCategory(sorted[NoCategory])); } DataBind(); }
public void ProcessTemplate(SharedBasePage page, string templateString, Control contentPlaceHolder, Macros macros) { ProcessTemplate(page, null, templateString, contentPlaceHolder, macros); }
public void ProcessTemplate(SharedBasePage page, Entry entry, string templateString, Control contentPlaceHolder, Macros macros) { int lastIndex = 0; MatchCollection matches = templateFinder.Matches(templateString); foreach( Match match in matches ) { if ( match.Index > lastIndex ) { contentPlaceHolder.Controls.Add(new LiteralControl(templateString.Substring(lastIndex,match.Index-lastIndex))); } Group g = match.Groups["macro"]; Capture c = g.Captures[0]; Control ctrl = null; object targetMacroObj = macros; string captureValue = c.Value; //Check for a string like: <%foo("bar", "bar")|assemblyConfigName%> int assemblyNameIndex = captureValue.IndexOf(")|"); if (assemblyNameIndex != -1) //use the default Macros { //The QN minus the )| string macroAssemblyName = captureValue.Substring(assemblyNameIndex+2); //The method, including the ) captureValue = captureValue.Substring(0,assemblyNameIndex+1); try { targetMacroObj = MacrosFactory.CreateCustomMacrosInstance(page, entry, macroAssemblyName); } catch (Exception ex) { string ExToString = ex.ToString(); if (ex.InnerException != null) { ExToString += ex.InnerException.ToString(); } page.LoggingService.AddEvent(new EventDataItem(EventCodes.Error,String.Format("Error executing Macro: {0}",ExToString),string.Empty)); } } try { ctrl = InvokeMacro(targetMacroObj,captureValue) as Control; if (ctrl != null) { contentPlaceHolder.Controls.Add(ctrl); } else { page.LoggingService.AddEvent(new EventDataItem(EventCodes.Error,String.Format("Error executing Macro: {0} returned null.",captureValue),string.Empty)); } } catch (Exception ex) { string error = String.Format("Error executing macro: {0}. Make sure it you're calling it in your BlogTemplate with parentheses like 'myMacro()'. Macros with parameter lists and overloads must be called in this way. Exception: {1}",c.Value, ex.ToString()); page.LoggingService.AddEvent(new EventDataItem(EventCodes.Error,error,string.Empty)); } lastIndex = match.Index+match.Length; } if ( lastIndex < templateString.Length) { contentPlaceHolder.Controls.Add(new LiteralControl(templateString.Substring(lastIndex,templateString.Length-lastIndex))); } }
protected void Page_Load(object sender, System.EventArgs e) { resmgr = ((System.Resources.ResourceManager)ApplicationResourceTable.Get()); requestPage = Page as SharedBasePage; #region Setup Year Hyperlinks DateTime[] daysWithEntries = null; //Print out a list of all the years that have entries // with links to the Year View if ( requestPage.SiteConfig.AdjustDisplayTimeZone ) { daysWithEntries = requestPage.DataService.GetDaysWithEntries(requestPage.SiteConfig.GetConfiguredTimeZone()); } else { daysWithEntries = requestPage.DataService.GetDaysWithEntries(new newtelligence.DasBlog.Util.UTCTimeZone()); } var years = new SortedSet<int>(); foreach (DateTime date in daysWithEntries) years.Add(date.Year); foreach(int year in years.Reverse<int>()) { HyperLink h = new HyperLink(); h.NavigateUrl = GetUrlWithYear(year); h.Text = year.ToString(); contentPlaceHolder.Controls.Add(h); Literal l = new Literal(); l.Text = " "; contentPlaceHolder.Controls.Add(l); } Literal l2 = new Literal(); l2.Text = "<br /><br />"; contentPlaceHolder.Controls.Add(l2); #endregion #region Year View //I know this could be cleaner and the Year viewing code could better share the Month viewing code // but they are sufficiently different that I chose to keep them fairly separate if (Request.QueryString["year"] != null) { int year = int.Parse(Request.QueryString["year"]); int monthsInYear = System.Globalization.DateTimeFormatInfo.CurrentInfo.Calendar.GetMonthsInYear(year); for(int i = 1; i <= monthsInYear; i++) { MonthViewCalendar c = new MonthViewCalendar(); ApplyCalendarStyles(c); c.DayRender += new DayRenderEventHandler(calendarMonth_DayRender); c.VisibleMonthChanged += new MonthChangedEventHandler(calendarMonth_VisibleMonthChanged); c.SelectionChanged += new EventHandler(calendarMonth_SelectionChanged); c.PreRender += new EventHandler(calendarMonth_PreRender); //Don't show the Next/Prev for the Year Calendar c.ShowNextPrevMonth = false; //Tell this Calendar to show a specific month c.VisibleDate = new DateTime(year, i, 1); contentPlaceHolder.Controls.Add(c); } requestPage.TitleOverride = year.ToString(); } #endregion else //Month View #region Month View { //Setup the Event Handlers for the Calendar calendarMonth.DayRender += new DayRenderEventHandler(calendarMonth_DayRender); calendarMonth.VisibleMonthChanged += new MonthChangedEventHandler(calendarMonth_VisibleMonthChanged); calendarMonth.SelectionChanged += new EventHandler(calendarMonth_SelectionChanged); calendarMonth.PreRender += new EventHandler(calendarMonth_PreRender); ApplyCalendarStyles(calendarMonth); contentPlaceHolder.Controls.Add(calendarMonth); //Default to this month, otherwise parse out a yyyy-MM if ( Request.QueryString["month"] == null ) { _month = DateTime.Now.Date; } else { try { _month = DateTime.ParseExact(Request.QueryString["month"],"yyyy-MM", System.Globalization.CultureInfo.InvariantCulture); } catch { } } //Set the title, and tell the calendar to show today requestPage.TitleOverride = _month.ToString("MMMM, yyyy"); calendarMonth.VisibleDate = _month; } #endregion }
/// <summary> /// Gets the entries for this month that we will be rendering /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void calendarMonth_PreRender(object sender, EventArgs e) { Control root = contentPlaceHolder; SiteConfig siteConfig = SiteConfig.GetSiteConfig(); string languageFilter = Request.Headers["Accept-Language"]; MonthViewCalendar eventSource = sender as MonthViewCalendar; requestPage = Page as SharedBasePage; // if we adjust for time zones (we don't show everything in UTC), we get the entries // using the configured time zone. eventSource.EntriesThisMonth = new EntryCollection(); if ( siteConfig.AdjustDisplayTimeZone ) { //Store away these Entries for the DayRender step... eventSource.EntriesThisMonth = requestPage.DataService.GetEntriesForMonth( eventSource.VisibleDate, siteConfig.GetConfiguredTimeZone(), languageFilter); } else { //Store away these Entries for the DayRender step... eventSource.EntriesThisMonth = requestPage.DataService.GetEntriesForMonth( eventSource.VisibleDate, new Util.UTCTimeZone(), languageFilter); } }
public FooMacros(SharedBasePage page, Entry item) { requestPage = page; currentItem = item; }