예제 #1
0
    protected void IcerikGetir()
    {
        foreach (KeyValuePair <string, PlaceHolder> item in Places)
        {
            ContainerleriGizle(item.Value.Parent);
        }

        try
        {
            #region parametreler
            Snlg_DBParameter[] DBPrms = new Snlg_DBParameter[3];
            DBPrms[0] = new Snlg_DBParameter("@isLogin", SqlDbType.Bit, !string.IsNullOrEmpty(Snlg_MemberInfo.s_UserId.ToString()));
            DBPrms[1] = new Snlg_DBParameter("@Dil", SqlDbType.SmallInt, Snlg_ConfigValues.s_ZDilId);
            DBPrms[2] = new Snlg_DBParameter("@SablonId", SqlDbType.SmallInt, Request.QueryString["sablon"]);

            if (string.IsNullOrEmpty(Request.QueryString["sablon"]))
            {
                DBPrms[2].Deger = DBNull.Value;
            }
            #endregion

            DataSet   DSSablonIcerik    = vt.DataSetOlustur("snlg_V1.zsp_SablondakiKontrolleriGetir", CommandType.StoredProcedure, DBPrms);
            DataTable DtKontroller      = DSSablonIcerik.Tables[0];
            DataTable DTBlockAttributes = DSSablonIcerik.Tables[1];
            foreach (DataRow drUc in DtKontroller.Select("", "Sira"))
            {
                HtmlGenericControl divBlokParent = new HtmlGenericControl("div");

                if (!string.IsNullOrEmpty(drUc["UCPath"].ToString()))
                {//demekk user control
                    try
                    {
                        Snlg_UserControlBaseClass uc = (Snlg_UserControlBaseClass)LoadControl("~/modules/" + drUc["UCPath"].ToString() + ".ascx");
                        //uc.ViewStateMode = System.Web.UI.ViewStateMode.Disabled;
                        uc.baslikGorunsun      = Convert.ToBoolean(drUc["BaslikGorunsun"]);
                        uc.baslik              = drUc["UCBaslik"].ToString();
                        uc.UserControlClientID = "UC-" + drUc["BlockPlaceID"].ToString();
                        ContainerGoster(Places[drUc["PHName"].ToString()].Parent);

                        foreach (DataRow drAttribute in DTBlockAttributes.Select("BlockPlaceID = " + drUc["BlockPlaceID"].ToString()))
                        {
                            if (!uc.BlockAttributes.ContainsKey(drAttribute["AttributeKey"].ToString()))
                            {
                                uc.BlockAttributes.Add(drAttribute["AttributeKey"].ToString(), drAttribute["AttributeValue"].ToString());
                            }
                        }

                        Literal ltrlUst = new Literal();
                        ltrlUst.ViewStateMode = System.Web.UI.ViewStateMode.Disabled;
                        ltrlUst.Text          = drUc["BlokUstBilgi"].ToString();

                        Literal ltrlAlt = new Literal();
                        ltrlAlt.ViewStateMode = System.Web.UI.ViewStateMode.Disabled;
                        ltrlAlt.Text          = drUc["BlokAltBilgi"].ToString();

                        divBlokParent.Attributes.Add("class", "modules " + uc.UserControlCssClass);
                        divBlokParent.Attributes.Add("id", uc.UserControlClientID);
                        divBlokParent.Controls.Add(ltrlUst);
                        divBlokParent.Controls.Add(uc);
                        divBlokParent.Controls.Add(ltrlAlt);
                        Places[drUc["PHName"].ToString()].Controls.Add(divBlokParent);
                    }
                    catch (Exception exc)
                    { Snlg_Hata.ziyaretci.ExceptionLogla(exc); }
                }
                else if (drUc["BlokType"].ToString() == "Content")
                {//demekki adminde oluşturulmuş bir içerik
                    try
                    {
                        StringBuilder SBBlokHtml = new StringBuilder();

                        if (Convert.ToBoolean(drUc["BaslikGorunsun"]))
                        {
                            SBBlokHtml.Append("<h4>" + drUc["UCBaslik"].ToString() + "</h4>");
                        }
                        SBBlokHtml.Append(drUc["UCIcerik"].ToString());

                        GeleriEmbed(SBBlokHtml, vt);
                        ContainerGoster(Places[drUc["PHName"].ToString()].Parent);
                        Literal ltrl = new Literal();
                        //ltrl.ViewStateMode = System.Web.UI.ViewStateMode.Disabled;
                        ltrl.Text = SBBlokHtml.ToString();

                        divBlokParent.Attributes.Add("class", "snlg-block-" + classReplace(drUc["Title"].ToString()));
                        divBlokParent.Controls.Add(ltrl);
                        Places[drUc["PHName"].ToString()].Controls.Add(divBlokParent);
                    }
                    catch (Exception exc)
                    { Snlg_Hata.ziyaretci.ExceptionLogla(exc); }
                }
                else if (drUc["BlokType"].ToString() == "Menu")
                {//demekki adminde oluşturulmuş bir içerik
                    try
                    {
                        Dictionary <string, string> BlockAttributes = new Dictionary <string, string>();
                        foreach (DataRow drAttribute in DTBlockAttributes.Select("BlockPlaceID = " + drUc["BlockPlaceID"].ToString()))
                        {
                            if (!BlockAttributes.ContainsKey(drAttribute["AttributeKey"].ToString()))
                            {
                                BlockAttributes.Add(drAttribute["AttributeKey"].ToString(), drAttribute["AttributeValue"].ToString());
                            }
                        }

                        string menuType = "Top";
                        try
                        { menuType = BlockAttributes["MenuType"]; }
                        catch { }

                        string menuClass = "snlg-block-menu-" + classReplace(menuType) + " " + classReplace(drUc["Title"].ToString());

                        //memülar alınıyor
                        DataTable DTMenu = vt.DataTableOlustur("snlg_V1.zsp_Menuler", CommandType.StoredProcedure, new Snlg_DBParameter[2] {
                            new Snlg_DBParameter("@Dil", SqlDbType.SmallInt, Snlg_ConfigValues.s_ZDilId), new Snlg_DBParameter("@UCID", SqlDbType.Int, drUc["UCId"].ToString())
                        });

                        //memü yoksa gizle
                        if (DTMenu.Rows.Count > 0)
                        {
                            //memülar listeleniyor
                            StringBuilder SBBlokHtml = new StringBuilder();
                            //ilk başta üst ID si null olanlar gönderiliyor.
                            MenuleriDoldur(DTMenu, SBBlokHtml, DTMenu.Select("UstId IS NULL", "Sira"), menuType);

                            ContainerGoster(Places[drUc["PHName"].ToString()].Parent);
                            Literal ltrl = new Literal();
                            ltrl.Text = SBBlokHtml.ToString();

                            divBlokParent.Attributes.Add("class", menuClass);
                            divBlokParent.Controls.Add(ltrl);

                            Places[drUc["PHName"].ToString()].Controls.Add(divBlokParent);
                        }
                    }
                    catch (Exception exc)
                    { Snlg_Hata.ziyaretci.ExceptionLogla(exc); }
                }
            }
        }
        catch (Exception exc)
        { Snlg_Hata.ziyaretci.ExceptionLogla(exc); }
    }