Ejemplo n.º 1
0
 /// <summary>
 /// Deletes the page.
 /// </summary>
 private void DeletePage(Guid id)
 {
     if (System.Threading.Thread.CurrentPrincipal.Identity.IsAuthenticated)
     {
         BlogEngine.Core.Page page = BlogEngine.Core.Page.GetPage(id);
         page.Delete();
         page.Save();
         Response.Redirect("~/", true);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles the ItemDataBound event of the rep control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.RepeaterItemEventArgs"/> instance containing the event data.</param>
        void rep_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            HtmlGenericControl control    = (HtmlGenericControl)e.Item.FindControl("type");
            string             type       = "<strong>Type</strong>: {0}";
            string             categories = "<strong>" + Resources.labels.categories + "</strong> : {0}";
            string             tags       = "<strong>Tags</strong> : {0}";
            string             keywords   = "<strong>Keywords</strong> : {0}    ";

            if (e.Item.DataItem is Comment)
            {
                control.InnerHtml = string.Format(type, Resources.labels.comment);
            }
            else if (e.Item.DataItem is Post)
            {
                Post   post = (Post)e.Item.DataItem;
                string text = string.Format(type, Resources.labels.post);
                if (post.Categories.Count > 0)
                {
                    string cat = string.Empty;
                    foreach (Category category in post.Categories)
                    {
                        cat += category.Title + ", ";
                    }

                    text += "<br />" + string.Format(categories, cat.Substring(0, cat.Length - 2));
                }

                if (post.Tags.Count > 0)
                {
                    string t = string.Empty;
                    foreach (string tag in post.Tags)
                    {
                        t += tag + ", ";
                    }

                    text += "<br />" + string.Format(tags, t.Substring(0, t.Length - 2));
                }

                control.InnerHtml = text;
            }
            else if (e.Item.DataItem is BlogEngine.Core.Page)
            {
                BlogEngine.Core.Page page = (BlogEngine.Core.Page)e.Item.DataItem;
                string text = string.Format(type, Resources.labels.page);

                if (!string.IsNullOrEmpty(page.Keywords))
                {
                    text += "<br />" + string.Format(keywords, page.Keywords);
                }

                control.InnerHtml = text;
            }
        }
Ejemplo n.º 3
0
	private HtmlGenericControl BuildChildPageList(BlogEngine.Core.Page page)
	{
		HtmlGenericControl ul = new HtmlGenericControl("ul");
		foreach (Page cPage in BlogEngine.Core.Page.Pages.FindAll(delegate(BlogEngine.Core.Page p)
		{
			//p => (p.Parent == page.Id)))
			return p.Parent == page.Id;
		}))
		{
			HtmlGenericControl cLi = new HtmlGenericControl("li");
			cLi.Attributes.CssStyle.Add("font-weight", "normal");
			HtmlAnchor cA = new HtmlAnchor();
			cA.HRef = "?id=" + cPage.Id.ToString();
			cA.InnerHtml = cPage.Title;

			System.Web.UI.LiteralControl cText = new System.Web.UI.LiteralControl
			(" (" + cPage.DateCreated.ToString("yyyy-dd-MM HH:mm") + ") ");

			string deleteText = "Are you sure you want to delete the page?";
			HtmlAnchor delete = new HtmlAnchor();
			delete.InnerText = Resources.labels.delete;
			delete.Attributes["onclick"] = "if (confirm('" + deleteText + "')){location.href='?delete=" + cPage.Id + "'}";
			delete.HRef = "javascript:void(0);";
			delete.Style.Add(System.Web.UI.HtmlTextWriterStyle.FontWeight, "normal");

			cLi.Controls.Add(cA);
			cLi.Controls.Add(cText);
			cLi.Controls.Add(delete);

			if (cPage.HasChildPages)
			{
				cLi.Attributes.CssStyle.Remove("font-weight");
				cLi.Attributes.CssStyle.Add("font-weight", "bold");
				cLi.Controls.Add(BuildChildPageList(cPage));
			}

			ul.Controls.Add(cLi);

		}
		return ul;
	}
Ejemplo n.º 4
0
    /// <summary>
    /// Serves the page to the containing DIV tag on the page.
    /// </summary>
    /// <param name="id">
    /// The id of the page to serve.
    /// </param>
    private void ServePage(Guid id)
    {
        var pg = BlogEngine.Core.Page.GetPage(id);
        this.Page = pg;

        if (pg == null || (!pg.IsVisible))
        {
            this.Response.Redirect(string.Format("{0}error404.aspx", Utils.RelativeWebRoot), true);
            return; // WLF: ReSharper is stupid and doesn't know that redirect returns this method.... or does it not...?
        }

        this.h1Title.InnerHtml = System.Web.HttpContext.Current.Server.HtmlEncode(pg.Title);

        var arg = new ServingEventArgs(pg.Content, ServingLocation.SinglePage);
        BlogEngine.Core.Page.OnServing(pg, arg);

        if (arg.Cancel)
        {
            this.Response.Redirect("error404.aspx", true);
        }

        if (arg.Body.Contains("[usercontrol", StringComparison.OrdinalIgnoreCase))
        {
            Utils.InjectUserControls(this.divText, arg.Body);
           // this.InjectUserControls(arg.Body);
        }
        else
        {
            this.divText.InnerHtml = arg.Body;
        }
    }
Ejemplo n.º 5
0
    /// <summary>
    /// Serves the page to the containing DIV tag on the page.
    /// </summary>
    /// <param name="id">The id of the page to serve.</param>
    private void ServePage(Guid id)
    {
        this.Page = BlogEngine.Core.Page.GetPage(id);

        if (this.Page == null || (!this.Page.IsVisible))
            Response.Redirect(Utils.RelativeWebRoot + "error404.aspx", true);

        h1Title.InnerHtml = this.Page.Title;

        ServingEventArgs arg = new ServingEventArgs(this.Page.Content, ServingLocation.SinglePage);
        BlogEngine.Core.Page.OnServing(this.Page, arg);

        if (arg.Cancel)
            Response.Redirect("error404.aspx", true);

        if (arg.Body.ToLowerInvariant().Contains("[usercontrol"))
        {
            InjectUserControls(arg.Body);
        }
        else
        {
            divText.InnerHtml = arg.Body;
        }
    }
Ejemplo n.º 6
0
    /// <summary>
    /// On Post Served event handler will post to social networks
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void AddOGImageThumbnail(object sender, ServingEventArgs e)
    {
        var    s     = Settings;
        string title = string.IsNullOrEmpty(s.GetSingleValue("OGDataTitle")) ? "" : s.GetSingleValue("OGDataTitle");
        string image = string.IsNullOrEmpty(s.GetSingleValue("OGDataImage")) ? "" : s.GetSingleValue("OGDataImage");

        if (e.Location == ServingLocation.SinglePage)
        {
            BlogEngine.Core.Page p = (BlogEngine.Core.Page)sender;
            AddMetaData("og:title", p.Title + title);
            AddMetaData("og:type", "website");
            AddMetaData("og:url", p.AbsoluteLink.AbsoluteUri.ToLower());
            AddMetaData("og:description", p.Description);
            string      imgPath = string.Empty;
            HttpContext context = HttpContext.Current;

            if (context.CurrentHandler is System.Web.UI.Page)
            {
                System.Web.UI.Page page = (System.Web.UI.Page)context.CurrentHandler;
                imgPath = getImage(true, p.Content);

                if (!string.IsNullOrEmpty(imgPath))
                {
                    if (!imgPath.ToLower().Contains("http://"))
                    {
                        imgPath = context.Request.Url.Scheme + "://" + context.Request.Url.Authority + imgPath;
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(image))
                    {
                        imgPath = image;
                    }
                    else
                    {
                        imgPath = context.Request.Url.Scheme + "://" + context.Request.Url.Authority;
                    }
                }

                AddHeader(page, imgPath);
            }
        }

        if (e.Location == ServingLocation.SinglePost)
        {
            Post p = (Post)sender;
            AddMetaData("og:title", p.Title + title);
            AddMetaData("og:description", p.Description);
            AddMetaData("og:url", p.AbsoluteLink.AbsoluteUri.ToLower());
            AddMetaData("article:author", p.Author);

            string      imgPath = string.Empty;
            HttpContext context = HttpContext.Current;
            if (context.CurrentHandler is System.Web.UI.Page)
            {
                System.Web.UI.Page page = (System.Web.UI.Page)context.CurrentHandler;
                imgPath = getImage(true, p.Content);

                if (!string.IsNullOrEmpty(imgPath))
                {
                    if (!imgPath.ToLower().Contains("http://"))
                    {
                        imgPath = context.Request.Url.Scheme + "://" + context.Request.Url.Authority + imgPath;
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(image))
                    {
                        imgPath = image;
                    }
                    else
                    {
                        imgPath = context.Request.Url.Scheme + "://" + context.Request.Url.Authority;
                    }
                }

                AddHeader(page, imgPath);
            }
        }
    }
Ejemplo n.º 7
0
    /// <summary>
    /// Serves the page to the containing DIV tag on the page.
    /// </summary>
    /// <param name="id">
    /// The id of the page to serve.
    /// </param>
    private void ServePage(Guid id)
    {
        var pg = BlogEngine.Core.Page.GetPage(id);
        this.Page = pg;

        if (pg == null || (!pg.IsVisible))
        {
            this.Response.Redirect(string.Format("{0}error404.aspx", Utils.RelativeWebRoot), true);
            return; // WLF: ReSharper is stupid and doesn't know that redirect returns this method.... or does it not...?
        }

        this.h1Title.InnerHtml = pg.Title;

        var arg = new ServingEventArgs(pg.Content, ServingLocation.SinglePage);
        BlogEngine.Core.Page.OnServing(pg, arg);

        if (arg.Cancel)
        {
            this.Response.Redirect("error404.aspx", true);
        }

        if (arg.Body.Contains("[usercontrol", StringComparison.OrdinalIgnoreCase))
        {
            Utils.InjectUserControls(this.divText, arg.Body);
           // this.InjectUserControls(arg.Body);
        }
        else
        {
            this.divText.InnerHtml = arg.Body;
        }

        #region gerardo
        if (pg.Id == new Guid("ea3fe48717f64678b899412814e89a77"))
        {
            //const string s = "<a href=\"{0}\">{1}</a>";
            const string s = "<a href=\"http://www.sailingcanyonlake.com/?tag=/{0}\">{0}: </a>";
            var tags = new List<JsonTag>();
            foreach (var p in Post.Posts)
            {
                foreach (var t in p.Tags)
                {
                    string replacement = string.Format(s, t);
                    this.divText.InnerHtml = this.divText.InnerHtml.Replace(t + ": ", replacement);

                }
            }
        }
        #endregion
    }