private void SaveTags(int iPostID)
    {
        string[] strTags = txtPostTags.Text.Split(',');
        for (int i = 0; i < strTags.Length; i++)
        {
            if (strTags[i].Trim() != "")
            {
                string code = BSHelper.CreateCode(strTags[i].Trim());
                string name = strTags[i].Trim();

                BSTerm bsTerm = BSTerm.GetTerm(code, TermTypes.Tag);
                if (bsTerm == null)
                {
                    bsTerm      = new BSTerm();
                    bsTerm.Name = name;
                    bsTerm.Code = code;
                    bsTerm.Type = TermTypes.Tag;
                    bsTerm.Save();
                }

                bsTerm.Objects.Add(iPostID);
                bsTerm.Save();
            }
        }
    }
    private void SavePost()
    {
        try
        {
            BSPost bsPost = new BSPost();
            bsPost.UserID       = Blogsa.ActiveUser.UserID;
            bsPost.Title        = txtTitle.Text;
            bsPost.Code         = BSHelper.CreateCode(txtTitle.Text);
            bsPost.Content      = tmcePostContent.Content;
            bsPost.State        = bucPostSettings.State;
            bsPost.AddComment   = bucPostSettings.AddComment;
            bsPost.LanguageCode = bucPostSettings.LanguageCode;

            bsPost.Date = bucPostSettings.Date;

            if (bsPost.Save())
            {
                bucPostSettings.Save(bsPost.PostID);

                Response.Redirect("Posts.aspx?PostID=" + bsPost.PostID + "&Message=1");
            }
            else
            {
                MessageBox1.Message = "Error";
                MessageBox1.Type    = MessageBox.ShowType.Error;
            }
        }
        catch (Exception ex)
        {
            MessageBox1.Message = ex.Message;
            MessageBox1.Type    = MessageBox.ShowType.Error;
        }
    }
Esempio n. 3
0
 protected override void OnPreInit(EventArgs e)
 {
     try
     {
         string strCurrentTheme = Blogsa.Settings["theme"] != null ? Blogsa.Settings["theme"].ToString() : null;
         if (Request["theme"] != null)
         {
             strCurrentTheme = Request["theme"];
         }
         strCurrentTheme    = BSHelper.CreateCode(strCurrentTheme);
         Blogsa.ActiveTheme = strCurrentTheme;
         if (System.IO.File.Exists(base.Server.MapPath("~/Themes/" + strCurrentTheme + "/Master.master")))
         {
             MasterPageFile = "~/Themes/" + strCurrentTheme + "/Master.master";
         }
         else
         {
             MasterPageFile = "~/Themes/Default/Master.master";
         }
         if (Blogsa.ActiveUser != null && Blogsa.ActiveUser.Role.Equals("admin"))
         {
             this.ClientScript.RegisterClientScriptInclude("Jquery", ResolveUrl("~/Admin/Js/jquery-1.6.4.min.js"));
             this.ClientScript.RegisterClientScriptInclude("Blogsa", ResolveUrl("~/Admin/Js/Blogsa.js"));
             this.ClientScript.RegisterStartupScript(GetType(), "BaseUrl", "Blogsa.BaseUrl='" + Blogsa.Url + "';", true);
         }
     }
     catch { }
     base.OnPreInit(e);
 }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (txtName.Text.Trim() != "")
        {
            string code = BSHelper.CreateCode(txtName.Text);

            BSTerm bsTerm = BSTerm.GetTerm(code, TermTypes.Tag);

            if (bsTerm == null)
            {
                bsTerm      = new BSTerm();
                bsTerm.Name = txtName.Text;
                bsTerm.Type = TermTypes.Tag;
                bsTerm.Code = code;
            }

            bsTerm.Save();

            if (bsTerm.Save())
            {
                MessageBox1.Message = Language.Admin["TagSaved"];
                MessageBox1.Type    = MessageBox.ShowType.Information;
                gvItems.DataBind();
                txtName.Text = string.Empty;
            }
            else
            {
                MessageBox1.Message = "Error";
            }
        }
    }
Esempio n. 5
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string TermID  = Request.QueryString["TermID"];
        int    iTermID = 0;

        int.TryParse(TermID, out iTermID);

        if (!String.IsNullOrEmpty(txtCatName.Text.Trim()) && iTermID > 0)
        {
            BSTerm bsTerm = BSTerm.GetTerm(iTermID);
            bsTerm.Name        = txtCatName.Text;
            bsTerm.Description = txtCatDescription.Text;
            bsTerm.Code        = BSHelper.CreateCode(txtCatName.Text);
            //term.SubID = int.Parse(ddlParentCategory.SelectedValue);

            if (bsTerm.Save())
            {
                MessageBox1.Message = Language.Admin["CategorySaved"];
                MessageBox1.Type    = MessageBox.ShowType.Information;
                gvItems.DataBind();
                txtName.Text        = string.Empty;
                txtDescription.Text = string.Empty;
            }
            else
            {
                MessageBox1.Message = Language.Admin["CategoryError"];
            }
        }
        else
        {
            Response.Redirect("Categories.aspx");
        }
    }
Esempio n. 6
0
    protected void btnSavePage_Click(object sender, EventArgs e)
    {
        int iPostID = 0;

        int.TryParse(Request["PostID"], out iPostID);
        if (iPostID != 0)
        {
            BSPost bsPost = BSPost.GetPost(iPostID);

            bsPost.Title      = txtTitle.Text;
            bsPost.Code       = BSHelper.CreateCode(txtTitle.Text);
            bsPost.Content    = tmcePageContent.Content;
            bsPost.State      = (PostStates)short.Parse(ddState.SelectedValue);
            bsPost.AddComment = cblAddComment.Checked;
            bsPost.UpdateDate = DateTime.Now;

            if (bsPost.Save())
            {
                MessageBox1.Message = Language.Admin["PageSaved"];
                MessageBox1.Type    = MessageBox.ShowType.Information;
            }
            else
            {
                MessageBox1.Message = Language.Admin["PageError"];
            }
        }
    }
Esempio n. 7
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (txtName.Text.Trim() != "")
        {
            BSTerm bsTerm = new BSTerm();
            bsTerm.Name        = txtName.Text;
            bsTerm.Description = txtDescription.Text;
            bsTerm.Type        = BSTerm.GetTermType(CategoryType);
            bsTerm.Code        = BSHelper.CreateCode(bsTerm.Name);

            bsTerm.SubID = int.Parse(ddlParentCategory.SelectedValue);

            if (bsTerm.Save())
            {
                MessageBox1.Message = Language.Admin["CategorySaved"];
                MessageBox1.Type    = MessageBox.ShowType.Information;
                gvItems.DataBind();
                txtName.Text        = string.Empty;
                txtDescription.Text = string.Empty;
            }
            else
            {
                MessageBox1.Message = Language.Admin["CategoryError"];
            }
        }
    }
        protected override void OnInit(EventArgs e)
        {
            //Widget Preview
            if (HttpContext.Current.Request["widget"] != null && this.ID.Equals("Default"))
            {
                using (PlaceHolder ph = (PlaceHolder)BSHelper.FindChildControl(Page, "Default"))
                    ph.Controls.Add(Page.LoadControl("~/Widgets/" + BSHelper.CreateCode(HttpContext.Current.Request["widget"]) + "/" + "Widget.ascx"));
            }

            List <BSWidget> widgets = BSWidget.GetWidgetsByPlaceHolder(this.ID, true);

            if (widgets.Count > 0)
            {
                foreach (BSWidget widget in widgets)
                {
                    PlaceHolder ph = (PlaceHolder)BSHelper.FindChildControl(Page, widget.PlaceHolder);
                    if (ph != null)
                    {
                        WidgetBase wb = (WidgetBase)Page.LoadControl(Templates.Widget);
                        wb.Widget = widget;
                        wb.DataBind();
                        ph.Controls.Add(wb);
                    }
                }
            }

            base.OnInit(e);
        }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        int iTermID = 0;

        int.TryParse(Request["TermID"], out iTermID);

        if (iTermID > 0)
        {
            BSTerm bsTerm = BSTerm.GetTerm(iTermID);

            bsTerm.Name = txtCatName.Text;
            bsTerm.Code = BSHelper.CreateCode(txtCatName.Text);
            if (bsTerm.Save())
            {
                MessageBox1.Message = Language.Admin["TagSaved"];
                MessageBox1.Type    = MessageBox.ShowType.Information;
                gvItems.DataBind();
                txtName.Text = string.Empty;
            }
            else
            {
                MessageBox1.Message = "Error";
            }
        }
        else
        {
            Response.Redirect("Categories.aspx");
        }
    }
Esempio n. 10
0
    public void SaveTags(int ObjectID)
    {
        string strTags = txtTags.Value;
        Regex  rex     = new Regex("\\{(.*?)\\}");

        BSTerm.RemoveTo(TermTypes.Tag, ObjectID);

        foreach (Match item in rex.Matches(strTags))
        {
            Regex  rx       = new Regex("'(.*?)'");
            string strText  = rx.Matches(item.Value)[1].Value;
            string strValue = rx.Matches(item.Value)[0].Value;

            strText  = strText.Substring(1, strText.Length - 2);
            strValue = strValue.Substring(1, strValue.Length - 2);

            string code = BSHelper.CreateCode(strText);

            BSTerm bsTerm = BSTerm.GetTerm(code, TermTypes.Tag);
            if (bsTerm == null)
            {
                bsTerm      = new BSTerm();
                bsTerm.Name = strText;
                bsTerm.Code = code;
                bsTerm.Type = TermTypes.Tag;
                bsTerm.Objects.Add(ObjectID);
                bsTerm.Save();
            }
            else
            {
                bsTerm.Objects.Add(ObjectID);
                bsTerm.Save();
            }
        }
    }
Esempio n. 11
0
    protected void btnSaveMenu_Click(object sender, EventArgs e)
    {
        string p = Request["p"];

        if (!String.IsNullOrEmpty(p) && p.Equals("AddMenu"))
        {
            BSMenuGroup menuGroup = new BSMenuGroup();
            menuGroup.Default     = cbxDefault.Checked;
            menuGroup.Title       = txtTitle.Text;
            menuGroup.Description = txtDescription.Text;
            menuGroup.Code        = BSHelper.CreateCode(menuGroup.Title);

            if (menuGroup.Save())
            {
                Response.Redirect(String.Format("Menus.aspx?MenuID={0}", menuGroup.MenuGroupID));
            }
        }
        else
        {
            int iMenuGroupID = 0;
            int.TryParse(Request["MenuID"], out iMenuGroupID);

            if (iMenuGroupID > 0)
            {
                BSMenuGroup menuGroup = BSMenuGroup.GetMenuGroup(iMenuGroupID);
                if (menuGroup != null)
                {
                    string[] strSort = hfMenuItems.Value.Split(';');

                    for (int i = 0; i < strSort.Length; i++)
                    {
                        if (!String.IsNullOrEmpty(strSort[i]))
                        {
                            int menuID = Convert.ToInt32(strSort[i]);
                            foreach (BSMenu bsMenu in menuGroup.Menu)
                            {
                                if (bsMenu.MenuID == menuID)
                                {
                                    bsMenu.Sort = (short)(i + 1);
                                }
                            }
                        }
                    }

                    menuGroup.Default     = cbxDefault.Checked;
                    menuGroup.Title       = txtTitle.Text;
                    menuGroup.Code        = BSHelper.CreateCode(menuGroup.Title);
                    menuGroup.Description = txtDescription.Text;

                    if (menuGroup.Save())
                    {
                        GetMenuGroup(menuGroup.MenuGroupID);
                    }
                }
            }
        }
    }
    private void SavePost(PostStates state)
    {
        BSPost bsPost = new BSPost();

        bsPost.UserID  = Blogsa.ActiveUser.UserID;
        bsPost.Title   = txtPostTitle.Text;
        bsPost.Code    = BSHelper.CreateCode(txtPostTitle.Text);
        bsPost.Content = txtPostContent.Text;
        bsPost.State   = state;
        bsPost.Date    = DateTime.Now;

        if (bsPost.Save())
        {
            SaveTags(bsPost.PostID);
            Response.Redirect("Posts.aspx?PostID=" + bsPost.PostID + "&Message=1");
        }
    }
    protected void btnCreatePost_Click(object sender, EventArgs e)
    {
        int iCount = Convert.ToInt32(tbCount.Text);

        for (int i = 0; i < iCount; i++)
        {
            BSPost post = new BSPost();
            post.Title      = String.Format("{0}-{1}", tbTitle.Text, i + 1);
            post.Content    = tbContent.Text;
            post.AddComment = true;
            post.Code       = BSHelper.CreateCode(post.Title);
            post.Date       = DateTime.Now;
            post.Type       = PostTypes.Article;
            post.UserID     = 1;
            post.State      = PostStates.Published;
            post.Save();
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        string widget = Request["w"];

        if (!string.IsNullOrEmpty(widget))
        {
            widget = BSHelper.CreateCode(widget);
            BSWidget bsWidget = BSWidget.GetWidget(widget);
            if (bsWidget != null)
            {
                phWidget.Controls.Add(LoadControl("~/Widgets/" + bsWidget.FolderName + "/View.ascx"));
            }
            else if (BSTheme.Current.Widgets[widget] != null)
            {
                BSWidget w = BSTheme.Current.Widgets[widget];
                phWidget.Controls.Add(LoadControl(String.Format("~/Themes/{0}/Widgets/{1}/View.ascx", Blogsa.ActiveTheme, w.FolderName)));
            }
        }
    }
    /// <summary>
    /// Save Post(s) click action.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSavePost_Click(object sender, EventArgs e)
    {
        try
        {
            string PostID  = Request.QueryString["PostID"];
            int    iPostID = 0;

            int.TryParse(PostID, out iPostID);

            BSPost bsPost = BSPost.GetPost(iPostID);

            bsPost.Title      = txtTitle.Text;
            bsPost.Code       = BSHelper.CreateCode(txtTitle.Text);
            bsPost.Content    = tmceContent.Content;
            bsPost.State      = (PostStates)Convert.ToInt16(ddState.SelectedValue);
            bsPost.AddComment = cblAddComment.Checked;
            bsPost.UpdateDate = DateTime.Now;

            if (rblDate.SelectedValue == "1")
            {
                bsPost.Date = dtsDateTime.SelectedDateTime;
            }

            Categories1.SaveData(bsPost.PostID);
            Tags1.SaveTags(bsPost.PostID);

            if (bsPost.Save())
            {
                Response.Redirect("Posts.aspx?PostID=" + PostID + "&Message=1");
            }
            else
            {
                MessageBox1.Message = Language.Admin["PostError"];
                MessageBox1.Type    = MessageBox.ShowType.Error;
            }
        }
        catch (Exception ex)
        {
            MessageBox1.Message = ex.Message;
            MessageBox1.Type    = MessageBox.ShowType.Error;
        }
    }
Esempio n. 16
0
    public override void DataBind()
    {
        Post.Code = BSHelper.CreateCode(Post.Title);
        Post.Link = BSHelper.GetLink(Post);

        bool anyId = !String.IsNullOrEmpty(HttpContext.Current.Request["PostID"]) || !String.IsNullOrEmpty(HttpContext.Current.Request["Code"]);

        if (anyId)
        {
            Post.Content = Post.Content.Replace("<!--pagebreak -->", "<a id=\"continue\" name=\"continue\"></a>");
            Post.Content = Post.Content.Replace("<!-- pagebreak -->", "<a id=\"continue\" name=\"continue\"></a>");
        }
        else if (Post.Content.Contains("<!--pagebreak -->"))
        {
            Post.Content  = TagCloser(Post.Content.Substring(0, Post.Content.IndexOf("<!--pagebreak -->")));
            Post.Content += String.Format("<a id=\"continue_{0}\" class=\"continue\" href=\"{1}#continue\">{2}</a>", Post.PostID, Post.Link, Language.Get["Continue"]);
        }
        else if (Post.Content.Contains("<!-- pagebreak -->"))
        {
            Post.Content  = TagCloser(Post.Content.Substring(0, Post.Content.IndexOf("<!-- pagebreak -->")));
            Post.Content += String.Format("<a id=\"continue_{0}\" class=\"continue\" href=\"{1}#continue\">{2}</a>", Post.PostID, Post.Link, Language.Get["Continue"]);
        }

        if (Page.User != null && Page.User.IsInRole("admin"))
        {
            const string strHideStyle = "style=\"display:none;\"";
            Post.Content = "<div class=\"post-edit\"><div class=\"post-edit-box\">"
                           + "<a href=\"" + ResolveUrl("~/Admin/" + (Post.Type == 0 ? "Posts" : "Pages") + ".aspx?PostID=" + Post.PostID) + "\">" + Language.Get["Edit"] + "</a>"
                           + "<a " + (Post.State == PostStates.Removed ? strHideStyle : "") + " id=\"post_trash_" + Post.PostID + "\" href=\"javascript:;\" onclick=\"Blogsa.TrashPost(this," + Post.PostID + ");\">" + Language.Get["Trash"] + "</a>"
                           + "<a " + (Post.State == PostStates.Published ? strHideStyle : "") + " id=\"post_publish_" + Post.PostID + "\" href=\"javascript:;\" onclick=\"Blogsa.PublishPost(this," + Post.PostID + ");\">" + Language.Get["Publish"] + "</a>"
                           + "<a " + (Post.State == PostStates.Draft ? strHideStyle : "") + " id=\"post_draft_" + Post.PostID + "\" href=\"javascript:;\" onclick=\"Blogsa.DraftPost(this," + Post.PostID + ");\">" + Language.Get["Draft"] + "</a>"
                           + "<span></span>"
                           + "</div>"
                           + Post.Content + "</div>";
        }

        PlaceHolder ph = (PlaceHolder)this.FindControl("Content");

        if (ph != null)
        {
            Regex         rex         = new Regex("<!--widget-(\\w{0,120})-->");
            List <string> lstContents = new List <string>();

            foreach (Match item in rex.Matches(Post.Content))
            {
                int iStart = Post.Content.IndexOf(item.Value);
                lstContents.Add(Post.Content.Substring(0, iStart));
                lstContents.Add(item.Value);
                Post.Content = Post.Content.Substring(iStart + item.Value.Length, Post.Content.Length - iStart - item.Value.Length);
            }
            lstContents.Add(Post.Content);

            for (int i = 0; i < lstContents.Count; i++)
            {
                string str = lstContents[i];
                if (rex.Match(str).Success)
                {
                    ph.Controls.Add(this.LoadControl("~/Widgets/" + str.Substring(11, str.Length - 14) + "/View.ascx"));
                }
                else
                {
                    Literal lt = new Literal();
                    lt.Text = str;
                    ph.Controls.Add(lt);
                }
            }
        }

        BSPost.CurrentPost = this.Post;
        CancelEventArgs eventArgs = new CancelEventArgs();

        BSPost.OnShowing(this.Post, eventArgs);

        if (!eventArgs.Cancel)
        {
            base.DataBind();
            BSPost.OnShowed(this.Post, EventArgs.Empty);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        string tag      = Request["Tag"];
        string postID   = Request["PostID"];
        string postCode = Request["Code"];
        string category = Request["Category"];
        string fileID   = Request["FileID"];
        string langCode = Request["Language"];

        if (!string.IsNullOrEmpty(fileID))
        {
            postID = fileID;
        }

        int iPostID = 0;

        int.TryParse(postID, out iPostID);

        BSPost bsPost = null;

        if (iPostID != 0)
        {
            bsPost = BSPost.GetPost(iPostID);
        }
        else if (!string.IsNullOrEmpty(postCode))
        {
            bsPost = BSPost.GetPost(postCode);
        }

        if (bsPost != null)
        {
            if (bsPost.State == PostStates.Published && (bsPost.Type != PostTypes.AutoSave))
            {
                PostDetail = true;
                bsPost.ReadCount++;
                bsPost.Save();

                this.Page.Title = Blogsa.Title + " - " + bsPost.Title;
                BSHelper.AddHeader(this.Page, "keywords", bsPost.GetTagsWithComma());
                System.Web.UI.HtmlControls.HtmlGenericControl gc = new System.Web.UI.HtmlControls.HtmlGenericControl();
                gc.InnerHtml = bsPost.Content;

                BSHelper.AddHeader(this.Page, "description", gc.InnerText.Length > 160 ? gc.InnerText.Substring(0, 160) : gc.InnerText);
                BSHelper.AddHeader(this.Page, "robots", "index,follow");

                List <BSPost> posts = new List <BSPost>();
                posts.Add(bsPost);

                rpPosts.DataSource = posts;
                rpPosts.DataBind();
            }
        }
        else if (tag != null)
        {
            tag = BSHelper.CreateCode(tag);

            List <BSPost> posts     = BSPost.GetPostsByTerm(0, tag, TermTypes.Tag, PostTypes.Article, PostStates.Published);
            ObjectPager   pager     = new ObjectPager();
            int           pageCount = pager.PageCount(posts, 10);

            rpPosts.DataSource = pager.GetPage(posts, 0, 10);
            rpPosts.DataBind();
        }
        else if (category != null)
        {
            category = BSHelper.CreateCode(category);

            List <BSPost> posts     = BSPost.GetPostsByTerm(0, category, TermTypes.Category, PostTypes.Article, PostStates.Published);
            ObjectPager   pager     = new ObjectPager();
            int           pageCount = pager.PageCount(posts, 10);

            rpPosts.DataSource = pager.GetPage(posts, 0, 10);
            rpPosts.DataBind();
        }
        else
        {
            int iCurrentPage = 0;
            int.TryParse(Request["Page"], out iCurrentPage);
            if (iCurrentPage <= 0)
            {
                iCurrentPage = 1;
            }

            List <BSPost> posts = BSPost.GetPosts(PostTypes.Article, PostStates.Published, 0);

            Panel pnlPaging = new Panel();
            pnlPaging.CssClass = "paging";
            Literal ltPaging = new Literal();
            pnlPaging.Controls.Add(ltPaging);

            BSPlaceHolderPaging.Controls.Add(pnlPaging);

            rpPosts.DataSource = Data.Paging(posts, iCurrentPage, ltPaging);
            rpPosts.DataBind();
        }

        if (rpPosts.Items.Count == 0)
        {
            Literal l = new Literal();
            l.Text = Language.Get["NoWrite"];
            Controls.AddAt(0, l);
        }
    }