Exemple #1
0
        private void Control_Init()
        {
            if (DataEval.IsEmptyQuery(_blogpostsid))
            {
                MultiView_BlogPosts.SetActiveView(View_New);
            }
            else
            {
                if (Request.QueryString["PageLink"] == "Disable")
                {
                    ListView_BlogPosts.Enabled      = false;
                    ListView_BlogPosts_List.Enabled = false;
                    btn_PostStatus_Show.Enabled     = false;

                    _ownership_userid             = "ALL";
                    ViewState["Ownership_UserID"] = _ownership_userid;
                }
                else
                {
                    if (DataEval.IsEmptyQuery(Request["NexusBlogUserID"]))
                    {
                        // Not valid Blog UserID
                        Invalid_BlogUserID();
                    }
                    else
                    {
                        // Check Blog UserID is valid
                        Security.Users.UserMgr myUserMgr = new Security.Users.UserMgr();

                        if (myUserMgr.Chk_UserID_Exist(Request["NexusBlogUserID"]))
                        {
                            _ownership_userid             = Request["NexusBlogUserID"];
                            ViewState["Ownership_UserID"] = _ownership_userid;

                            _maxnumberposts = -1;
                        }
                        else
                        {
                            // Not valid Blog UserID
                            Invalid_BlogUserID();
                        }
                    }
                }

                if (_view_stage == "view_add_post")
                {
                    MultiView_BlogPosts.SetActiveView(View_Add_Post);
                }
                else
                {
                    MultiView_BlogPosts.SetActiveView(View_Posts);

                    #region Bind Data to droplist
                    // Enable user edit mode

                    //Gets your enum names and adds it to a string array
                    Array enumNames = Enum.GetValues(typeof(Lib.Post_Status));

                    //Creates an ArrayList
                    ArrayList myPost_Statuses = new ArrayList();

                    //Loop through your string array and poppulates the ArrayList
                    foreach (Lib.Post_Status myPost_Status in enumNames)
                    {
                        myPost_Statuses.Add(new { Value = StringEnum.GetStringValue(myPost_Status), Name = myPost_Status.ToString() });
                    }


                    //Bind the ArrayList to your DropDownList
                    droplist_PostStatus_Show.DataSource     = myPost_Statuses;
                    droplist_PostStatus_Show.DataTextField  = "Name";
                    droplist_PostStatus_Show.DataValueField = "Value";
                    droplist_PostStatus_Show.DataBind();
                    #endregion

                    _view_stage            = "view_posts";
                    ViewState["ViewStage"] = _view_stage;

                    if (DataEval.IsEmptyQuery(_post_status_show))
                    {
                        _post_status_show = droplist_PostStatus_Show.SelectedValue;
                        //ViewState["PostStatus_Show"] = _post_status_show;
                    }
                    else
                    {
                        droplist_PostStatus_Show.SelectedValue = _post_status_show;
                    }

                    #region Check who can change the post

                    if (Security.Users.UserStatus.Validate_Ownership(this.Page, _ownership_userid) ||
                        Security.Users.UserStatus.Validate_PageAuth_Modify(this.Page))
                    {
                        if (_ownership_userid == "ALL")
                        {
                            lbtn_Add_Post.Visible            = false;
                            droplist_PostStatus_Show.Visible = false;
                            btn_PostStatus_Show.Visible      = false;
                        }
                        else
                        {
                            lbtn_Add_Post.Visible            = true;
                            droplist_PostStatus_Show.Visible = true;
                            btn_PostStatus_Show.Visible      = true;
                        }
                    }
                    else
                    {
                        lbtn_Add_Post.Visible            = false;
                        droplist_PostStatus_Show.Visible = false;
                        btn_PostStatus_Show.Visible      = false;
                    }

                    #endregion

                    Lib.BlogMgr myBlogMgr = new Lib.BlogMgr();

                    if (_showcontent)
                    {
                        ListView_BlogPosts.DataSource   = myBlogMgr.Get_mBlog_Posts(_ownership_userid, _post_status_show, _maxnumberposts);
                        ListView_BlogPosts.DataKeyNames = new string[] { "PostID" };
                        ListView_BlogPosts.DataBind();

                        DataPager_BlogPosts.PageSize = _numberperpage;

                        ListView_BlogPosts.Visible       = true;
                        DataPager_BlogPosts.Visible      = true;
                        ListView_BlogPosts_List.Visible  = false;
                        DataPager_BlogPosts_List.Visible = false;
                    }
                    else
                    {
                        ListView_BlogPosts_List.DataSource   = myBlogMgr.Get_mBlog_Posts(_ownership_userid, _post_status_show, _maxnumberposts);
                        ListView_BlogPosts_List.DataKeyNames = new string[] { "PostID" };
                        ListView_BlogPosts_List.DataBind();

                        DataPager_BlogPosts_List.PageSize = _numberperpage;

                        ListView_BlogPosts.Visible       = false;
                        DataPager_BlogPosts.Visible      = false;
                        ListView_BlogPosts_List.Visible  = true;
                        DataPager_BlogPosts_List.Visible = true;
                    }
                }
            }
        }
        private void Control_Init()
        {
            if (DataEval.IsEmptyQuery(_blogpostsid))
            {
                MultiView_BlogPosts.SetActiveView(View_New);
            }
            else
            {
                if (Request.QueryString["PageLink"] == "Disable")
                {
                    ListView_BlogPosts.Enabled  = false;
                    btn_PostStatus_Show.Enabled = false;
                }

                MultiView_BlogPosts.SetActiveView(View_Posts);

                #region Bind Data to droplist
                // Enable user edit mode

                //Gets your enum names and adds it to a string array
                Array enumNames = Enum.GetValues(typeof(Lib.Post_Status));

                //Creates an ArrayList
                ArrayList myPost_Statuses = new ArrayList();

                //Loop through your string array and poppulates the ArrayList
                foreach (Lib.Post_Status myPost_Status in enumNames)
                {
                    myPost_Statuses.Add(new { Value = StringEnum.GetStringValue(myPost_Status), Name = myPost_Status.ToString() });
                }


                //Bind the ArrayList to your DropDownList
                droplist_PostStatus_Show.DataSource     = myPost_Statuses;
                droplist_PostStatus_Show.DataTextField  = "Name";
                droplist_PostStatus_Show.DataValueField = "Value";
                droplist_PostStatus_Show.DataBind();
                #endregion


                if (Security.Users.UserStatus.Validate_Ownership(this.Page, _ownership_userid) ||
                    Security.Users.UserStatus.Validate_PageAuth_Modify(this.Page))
                {
                    lbtn_Add_Post.Visible            = true;
                    droplist_PostStatus_Show.Visible = true;
                    btn_PostStatus_Show.Visible      = true;
                }
                else
                {
                    lbtn_Add_Post.Visible            = false;
                    droplist_PostStatus_Show.Visible = false;
                    btn_PostStatus_Show.Visible      = false;
                }

                Lib.BlogMgr myBlogMgr = new Lib.BlogMgr();

                ListView_BlogPosts.DataSource   = myBlogMgr.Get_Blog_Posts(_ownership_userid, "Publish", _postviewurl);
                ListView_BlogPosts.DataKeyNames = new string[] { "PostID" };

                Core.Tools.AppItemTemplates myItemTemplate = new Core.Tools.AppItemTemplates();

                switch (_itemtemplate)
                {
                case "Default":
                    myItemTemplate.ItemTemplatePath = "~/App_Control_Style/Nexus_Blog/Templates/BlogPosts_Default.ascx";
                    break;

                case "TitleOnly":
                    myItemTemplate.ItemTemplatePath = "~/App_Control_Style/Nexus_Blog/Templates/BlogPosts_TitleOnly.ascx";
                    break;

                case "Custom":
                    myItemTemplate.ItemTemplatePath = _itemtemplateurl;
                    break;

                default:
                    myItemTemplate.ItemTemplatePath = "~/App_Control_Style/Nexus_Blog/Templates/BlogPosts_Default.ascx";
                    break;
                }

                myItemTemplate.Set_Separator("");
                myItemTemplate.Set_DataEmpty("");

                ListView_BlogPosts.ItemTemplate            = Page.LoadTemplate(myItemTemplate.ItemTemplatePath);
                ListView_BlogPosts.AlternatingItemTemplate = Page.LoadTemplate(myItemTemplate.AltPath);

                if (!DataEval.IsEmptyQuery(myItemTemplate.Separator))
                {
                    ListView_BlogPosts.ItemSeparatorTemplate = Page.LoadTemplate(myItemTemplate.Separator);
                }

                if (!DataEval.IsEmptyQuery(myItemTemplate.DataEmpty))
                {
                    ListView_BlogPosts.EmptyDataTemplate = Page.LoadTemplate(myItemTemplate.DataEmpty);
                }

                try
                {
                    ListView_BlogPosts.DataBind();
                }
                catch
                {
                    // Load Template Failed
                }


                DataPager_BlogPosts.PageSize = _numberperpage;
                DataPager_BlogPosts.Visible  = _enable_pager;
            }
        }