public static bool UpdateSortMenu(dynamic parameters)
    {
        string MenuGroupID = parameters["GroupID"];

        dynamic[]  d     = (dynamic[])parameters["arraied"];
        Model_Menu cm    = new Model_Menu();
        int        x     = 0;
        int        count = 1;
        string     arrId = string.Empty;

        foreach (dynamic i in d)
        {
            if (x > 0)
            {
                string p  = (i["parent_id"] == null ?"0" : (string)i["parent_id"]);
                string ii = (i["id"] == null? "0":(string)i["id"]);


                cm.UpdateSort(int.Parse(ii), int.Parse(p), count);

                count = count + 1;

                arrId = arrId + "," + ii;
            }


            x = x + 1;
        }


        //cm.DeleteArr(arrId.Substring(1));
        return(true);
    }
    public static bool DeleteMenu(dynamic parameters)
    {
        int        MID = int.Parse((string)parameters);
        Model_Menu m   = new Model_Menu();

        m = m.GetMenuByID(MID);


        //Check Archive MAp
        if (m.MCategory == 2 && m.PostTypeID.HasValue || m.GetMenuAll_byMCat(m.MCategory).Count() == 0)
        {
            Model_Archive mc = new Model_Archive();
            mc.DeleteARchive((byte)m.PostTypeID);
        }



        if (m.DeleteMenu(MID))
        {
            List <Model_Menu> reflist = m.GetMenuAll_byRefID(MID);
            if (reflist.Count() > 0)
            {
                foreach (Model_Menu mr in reflist)
                {
                    m.UpdateTOParent(mr.MID);
                }
            }
        }



        return(true);
    }
예제 #3
0
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        string MID = Request.Form["menu_checked"];

        if (!string.IsNullOrEmpty(MID))
        {
            Model_Menu m      = new Model_Menu();
            string[]   arrArg = MID.Split(',');

            foreach (string ar in arrArg)
            {
                string Url      = Request.Form["custom_url_" + ar];
                string Title    = Request.Form["label_" + ar];
                string TitleTag = Request.Form["TagTitle_" + ar];

                string[] d = ar.Split('_');

                int  intMID = int.Parse(d[0]);
                byte bytCat = byte.Parse(d[1]);

                m.Title     = Title;
                m.TitleTag  = TitleTag;
                m.MID       = intMID;
                m.CustomUrl = (string.IsNullOrEmpty(Url)?string.Empty: Url);

                m.Update(m);
            }
        }


        Response.Redirect(Request.Url.ToString());
        Response.End();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //Response.Write(HttpUtility.UrlDecode(Request.Url.AbsolutePath)));Response.End();
        if (!this.Page.IsPostBack)
        {
            string Pagetitle       = string.Empty;
            string Pagedescription = string.Empty;
            string canonical       = string.Empty;
            string fb_localte      = string.Empty;
            string fb_type         = string.Empty;
            string fb_title        = string.Empty;
            string fb_des          = string.Empty;
            string fb_url          = string.Empty;
            string fb_site_name    = string.Empty;
            string fb_image        = string.Empty;

            string tw_card  = string.Empty;
            string tw_title = string.Empty;
            string tw_des   = string.Empty;
            string tw_image = string.Empty;


            string analytic        = string.Empty;
            bool   Metarobotfollow = false;

            Model_SiteInfo    st      = new Model_SiteInfo();
            Model_MainSetting setting = new Model_MainSetting();
            setting = setting.GetMainSetting();



            Model_PageEngine PageEngine = new Model_PageEngine();
            PageEngine.SiteInfo    = st.GetSiteInfo();
            PageEngine.MainSetting = setting;
            Model_PostType     cPostType   = new Model_PostType();
            Model_Post         post        = new Model_Post();
            Model_Menu         m           = new Model_Menu();
            Model_PostTaxonomy tax         = new Model_PostTaxonomy();
            List <Model_Post>  postArchive = new List <Model_Post>();
            Model_Archive      archive     = new Model_Archive();

            PageEngine.NavMenu    = m.GetMenuAll(1);
            PageEngine.FooterMenu = m.GetMenuAll(2);

            //string[] dd = { "fixed-sidebar", "no-skin-config", "full-height-layout" };
            //StyleCore dd = new StyleCore();
            //StyleCore.arrayClass = dd;


            //Set Setting to MasterPage Class
            Master.PageEngine = PageEngine;



            byte   bytPostTypeID = 0;
            string StrPost_slug  = string.Empty;
            int    intPostID     = 0;


            string RouteSlug_1       = Page.RouteData.Values["Param1"] as string;
            string RouteSlug_2       = Page.RouteData.Values["Param2"] as string;
            string RouteSlug_3       = Page.RouteData.Values["Param3"] as string;
            string RouteSlug_4       = Page.RouteData.Values["Param4"] as string;
            string RouteSlug_5       = Page.RouteData.Values["Param5"] as string;
            Model_PostCustomItem pct = new Model_PostCustomItem();

            //Case Route Slug
            if (!string.IsNullOrEmpty(RouteSlug_1))
            {
                //1. Check Is Archive

                archive = archive.GetPostArchive(RouteSlug_1);


                if (archive != null)
                {
                    //Is Archive
                    bytPostTypeID = archive.PostTypeID;
                    StrPost_slug  = (string.IsNullOrEmpty(archive.Slug) ? archive.PostTypeSlug : archive.Slug);

                    //postArchive = CmsController.GetPostArchive(bytPostTypeID);

                    //Check  PostType Archive
                    switch (StrPost_slug)
                    {
                    case "hotelworld-products":
                        //check Route Param2
                        if (string.IsNullOrEmpty(RouteSlug_2))
                        {
                            //Case Product Page Archive
                            SectionProductArchive.Visible = true;

                            cPostType = cPostType.GetPostTypeBySlug(StrPost_slug);
                            if (cPostType != null)
                            {
                                //product-type = 24
                                this.TaxForPostType = tax.FrontGetTaxonomyByID(24);

                                if (this.TaxForPostType != null)
                                {
                                    this.TaxList = tax.FrontGetTaxonomyByRefID(24);
                                }
                            }
                        }
                        else
                        {
                            //check Is Paging of Product Page Archive
                            if (RouteSlug_2 == "page")
                            {
                                //Case Archive Paging
                                SectionProductArchive.Visible = true;
                                string pageno = RouteSlug_3;
                            }
                            else if (RouteSlug_2 == "category" || RouteSlug_2 == "tag")
                            {
                                //Tax Archive

                                tax = tax.GetTaxBySlugAndPostType(RouteSlug_3, bytPostTypeID);
                                if (tax != null)
                                {
                                    //case Tax approve
                                    SectionProductTaxArchive.Visible = true;
                                    this.TaxForPostType = tax;
                                    this.TaxList        = tax.GetTaxonomyTaxTypeAndPostType_withcountpost(bytPostTypeID, (byte)PostTaxonomyType.Categories);
                                    this.ContentBody    = tax.BodyContent;
                                    //Case tax Archive Paging
                                    if (RouteSlug_4 == "page")
                                    {
                                        string pageno = RouteSlug_5;

                                        //Do something with paging
                                    }
                                }
                            }
                            else
                            {
                                //Check Product SinglePage
                                post = CmsController.GetPostSlug(RouteSlug_2, PostType.Products);
                                if (post != null)
                                {
                                    SectionProductSingle.Visible = true;
                                    this.PostDataUI       = post;
                                    this.ContentBody      = post.BodyContent;
                                    this.PageContentTitle = post.Title;
                                    this.CTF = pct.GetItemCustomByPostID(post.PostID);
                                }
                            }
                        }


                        break;

                    case "ข่าวสาร":

                        //check Route Param2
                        if (string.IsNullOrEmpty(RouteSlug_2))
                        {
                            //Case Product Page Archive
                            SectionBlogPageArchive.Visible = true;
                        }
                        else
                        {
                            //check Is Paging of Product Page Archive
                            if (RouteSlug_2 == "page")
                            {
                                //Case Archive Paging
                                SectionBlogPageArchive.Visible = true;
                                string pageno = RouteSlug_3;
                            }
                            else if (RouteSlug_2 == "category" || RouteSlug_2 == "tag")
                            {
                                //Tax Archive

                                tax = tax.GetTaxBySlugAndPostType(RouteSlug_3, bytPostTypeID);
                                if (tax != null)
                                {
                                    //case Tax approve
                                    //Same layout with blog archive
                                    // SectionBlogPageTaxArchive.Visible = true;
                                    SectionBlogPageArchive.Visible = true;

                                    //Case tax Archive Paging
                                    if (RouteSlug_4 == "page")
                                    {
                                        string pageno = RouteSlug_5;

                                        //Do something with paging
                                    }
                                }
                            }
                            else
                            {
                                //Check Product SinglePage
                                post = CmsController.GetPostSlug(RouteSlug_2, PostType.Blog);
                                if (post != null)
                                {
                                    SectionBlogPageSingle.Visible = true;
                                }
                            }
                        }

                        break;
                    }
                    HeaderSection.Text = GenerateHeaderBannerAndSlider(post, tax);
                }
                else
                {
                    //Case PostType Page
                    StrPost_slug = RouteSlug_1;
                    post         = CmsController.GetPostSlug(StrPost_slug, PostType.Pages);

                    if (post != null)
                    {
                        bytPostTypeID = post.PostTypeID;
                        intPostID     = post.PostID;

                        //page_header.Visible = true;

                        if (StrPost_slug == "checkout")
                        {
                            section_checkout_page.Visible = true;
                        }
                        else
                        {
                            page_content.Visible = true;
                        }



                        HeaderSection.Text    = GenerateHeaderBannerAndSlider(post);
                        this.PostDataUI       = post;
                        this.ContentBody      = post.BodyContent;
                        this.PageContentTitle = post.Title;
                    }
                }


                // content.Text = post.BodyContent;
            }
            else
            {
                //Case HomePage No Slug
                //Get PostID From Setting HomePage Slug

                intPostID = setting.HomePagePostID;
                post      = CmsController.GetPostByID(intPostID);

                if (post != null)
                {
                    StrPost_slug = post.Slug;

                    bytPostTypeID      = post.PostTypeID;
                    HeaderSection.Text = GenerateHeaderBannerAndSlider(post);


                    this.CTF = pct.GetItemCustomByPostID(intPostID);


                    // content.Text = post.BodyContent;
                    this.PostDataUI           = post;
                    this.ContentBody          = post.BodyContent;
                    this.PageContentTitle     = post.Title;
                    section_page_home.Visible = true;


                    home_content.Text = this.ContentBody;
                }
            }

            //= null;
            Model_PostSeo posttype_postseo = new Model_PostSeo();
            Model_PostSeo tax_postseo      = new Model_PostSeo();
            Model_PostSeo post_postseo     = new Model_PostSeo();
            if (bytPostTypeID != 0)
            {
                cPostType        = cPostType.GetPostTypeByID(bytPostTypeID);
                posttype_postseo = cPostType.PosTypetSEO;
            }


            if (tax != null)
            {
                tax_postseo = tax.TaxSEO;
            }

            if (post != null)
            {
                post_postseo = post.PostSEO;
            }


            Pagetitle       = checklv(posttype_postseo, tax_postseo, post_postseo, "SEOTitle");
            Pagedescription = checklv(posttype_postseo, tax_postseo, post_postseo, "MetaDescription");
            canonical       = checklv(posttype_postseo, tax_postseo, post_postseo, "CanonicalUrl");
            fb_localte      = setting.htmlTagSiteLang;
            fb_type         = "website";
            fb_title        = checklv(posttype_postseo, tax_postseo, post_postseo, "FaceBookTitle");
            fb_des          = checklv(posttype_postseo, tax_postseo, post_postseo, "FacebookDescription");
            fb_url          = Request.Url.ToString();
            fb_site_name    = PageEngine.SiteInfo.Slogan;
            fb_image        = checklv(posttype_postseo, tax_postseo, post_postseo, "FacebookImage");
            tw_card         = "summary";
            tw_title        = checklv(posttype_postseo, tax_postseo, post_postseo, "TwitterTitle");
            tw_des          = checklv(posttype_postseo, tax_postseo, post_postseo, "TwitterDescription");
            tw_image        = checklv(posttype_postseo, tax_postseo, post_postseo, "TwitterImages");

            analytic = checklv(posttype_postseo, tax_postseo, post_postseo, "GoogleAnalytic");

            Metarobotfollow = checklv_bool(posttype_postseo, tax_postseo, post_postseo, "Metarobotsfollow");

            this.Page.Title = string.IsNullOrEmpty(Pagetitle) ? setting.WebSiteTitle : Pagetitle;

            var MetaDescription = new HtmlMeta {
                Name = "description", Content = Pagedescription
            };
            Header.Controls.Add(MetaDescription);

            var MetaFB_locate = new HtmlMeta {
                Name = "og:locale", Content = fb_localte
            };
            Header.Controls.Add(MetaFB_locate);

            var MetaFB_Type = new HtmlMeta {
                Name = "og:type", Content = fb_type
            };
            Header.Controls.Add(MetaFB_Type);

            var MetaFB_title = new HtmlMeta {
                Name = "og:title", Content = !string.IsNullOrEmpty(fb_title)? fb_title :   string.IsNullOrEmpty(Pagetitle) ? setting.WebSiteTitle : Pagetitle
            };
            Header.Controls.Add(MetaFB_title);


            var MetaFB_Des = new HtmlMeta {
                Name = "og:description", Content = !string.IsNullOrEmpty(fb_des) ? fb_des: Pagedescription
            };
            Header.Controls.Add(MetaFB_Des);

            var MetaFB_Url = new HtmlMeta {
                Name = "og:url", Content = fb_url
            };
            Header.Controls.Add(MetaFB_Url);

            var MetaFB_SiteName = new HtmlMeta {
                Name = "og:site_name", Content = fb_site_name
            };
            Header.Controls.Add(MetaFB_SiteName);

            var MetaFB_image = new HtmlMeta {
                Name = "og:image", Content = fb_image
            };
            Header.Controls.Add(MetaFB_image);

            var MetaTW_Card = new HtmlMeta {
                Name = "twitter:card", Content = tw_card
            };
            Header.Controls.Add(MetaTW_Card);

            var MetaTW_Des = new HtmlMeta {
                Name = "twitter:description", Content = tw_des
            };
            Header.Controls.Add(MetaTW_Des);
            var MetaTW_Title = new HtmlMeta {
                Name = "twitter:title", Content = tw_title
            };
            Header.Controls.Add(MetaTW_Title);
            var Meta_Image = new HtmlMeta {
                Name = "twitter:image", Content = tw_image
            };
            Header.Controls.Add(Meta_Image);
        }
    }
    public static bool InsertMenu(dynamic parameters)
    {
        string cmd = parameters["cmd"];

        // int cmdarg = (int)parameters["cmdarg"];

        string strpost = parameters["strpost"];

        string strarch = parameters["strarch"];

        string strtax = parameters["strtax"];

        string CustomURl    = parameters["url"];
        string CustomURlTxt = parameters["txt"];

        string MenuGroupID = parameters["GroupID"];



        Model_PostType cpt = new Model_PostType();



        string Title = string.Empty;

        if (!string.IsNullOrEmpty(cmd))
        {
            switch (cmd)
            {
            case "menu_post":

                if (!string.IsNullOrEmpty(strarch))
                {
                    byte           PostTypeID = byte.Parse(strarch);
                    Model_PostType cPt        = new Model_PostType();
                    cpt = cpt.GetPostTypeByID(PostTypeID);

                    Model_Menu cme = new Model_Menu();
                    cme.MGID        = int.Parse(MenuGroupID);
                    cme.Title       = "All " + cpt.Title;
                    cme.TitleOrigin = cpt.Slug;
                    cme.Slug        = cpt.Slug;
                    cme.CustomUrl   = "";
                    cme.Status      = true;
                    cme.MenuRefID   = 0;
                    cme.Lv          = 1;
                    cme.Priority    = 1;
                    cme.MCategory   = (byte)MenuCategory.Archive;
                    cme.PostTypeID  = cpt.PostTypeID;
                    cme.InsertMenuFirst(cme);

                    Model_Archive ma = new Model_Archive();
                    ma.inSertArchiveMap(cpt.PostTypeID, cpt.Slug);
                }

                if (!string.IsNullOrEmpty(strpost))
                {
                    foreach (string post in strpost.Split(','))
                    {
                        int        postID = int.Parse(post);
                        Model_Post cP     = new Model_Post();
                        cP = cP.GetPostByID(postID);


                        Model_Menu cme = new Model_Menu();
                        cme.MGID        = int.Parse(MenuGroupID);
                        cme.Title       = cP.Slug;
                        cme.TitleOrigin = cP.Slug;
                        cme.Slug        = cP.Slug;
                        cme.CustomUrl   = "";
                        cme.Status      = true;
                        cme.MenuRefID   = 0;
                        cme.Lv          = 1;
                        cme.Priority    = 1;
                        cme.MCategory   = (byte)MenuCategory.Post;
                        cme.PostID      = cP.PostID;
                        cme.InsertMenuFirst(cme);
                    }
                }


                break;

            case "menu_Tax":

                if (!string.IsNullOrEmpty(strtax))
                {
                    foreach (string tax in strtax.Split(','))
                    {
                        int TaxId             = int.Parse(tax);
                        Model_PostTaxonomy mp = new Model_PostTaxonomy();
                        mp = mp.GetTaxonomyByID(TaxId);

                        //if Tax Need to Check PostypeParent and Make Defaul Archive Page as well
                        Model_PostType cPt = new Model_PostType();
                        cpt = cpt.GetPostTypeByID(mp.PostTypeID);

                        Model_Menu cme = new Model_Menu();
                        cme.MGID        = int.Parse(MenuGroupID);
                        cme.Title       = mp.Slug;
                        cme.TitleOrigin = mp.Slug;
                        cme.Slug        = mp.Slug;
                        cme.CustomUrl   = "";
                        cme.Status      = true;
                        cme.MenuRefID   = 0;
                        cme.Lv          = 1;
                        cme.Priority    = 1;
                        cme.MCategory   = (byte)MenuCategory.Taxonomy;
                        cme.TaxID       = mp.TaxID;
                        cme.PostTypeID  = mp.PostTypeID;
                        cme.InsertMenuFirst(cme);



                        Model_Archive ma = new Model_Archive();
                        ma.inSertArchiveMap(cpt.PostTypeID, cpt.Slug);
                    }
                }
                // mCat = MenuCategory.Taxonomy;
                break;

            case "menu_custom":

                if (!string.IsNullOrEmpty(CustomURl) && !string.IsNullOrEmpty(CustomURlTxt))
                {
                    Model_Menu cme = new Model_Menu();
                    cme.MGID        = int.Parse(MenuGroupID);
                    cme.Title       = CustomURlTxt;
                    cme.TitleOrigin = CustomURlTxt;
                    cme.Slug        = CustomURlTxt;
                    cme.CustomUrl   = CustomURl;
                    cme.Status      = true;
                    cme.MenuRefID   = 0;
                    cme.Lv          = 1;
                    cme.Priority    = 1;
                    cme.MCategory   = (byte)MenuCategory.CustomLink;
                    cme.PostTypeID  = cpt.PostTypeID;
                    cme.InsertMenuFirst(cme);
                }

                // mCat = MenuCategory.CustomLink;
                break;
            }
        }


        //Model_Menu cme = new Model_Menu
        //{

        //    Title = "",
        //    TitleOrigin = "",
        //    Slug="",
        //    CustomUrl = "",
        //    Status = true,
        //    MenuRefID= 0,
        //    Lv = 1,
        //    IsCustomUrl = true,
        //    Priority=1,
        //    MCategory = (byte)mCat,
        //    TaxID=1,
        //    PostTypeID=1,
        //    PostID = 1
        //};

        return(true);
    }