Esempio n. 1
0
        protected void cmdUpdate_Click(object sender, EventArgs e)
        {
            lngProductGroups.UpdateLangs();
            switch (EditState)
            {
            case "new":
                ProductGroupInfo pgNew = new ProductGroupInfo();
                pgNew.ParentId         = ProductGroupId;
                pgNew.PortalId         = PortalId;
                pgNew.Image            = BBStoreHelper.GetRelativeFilePath(ImageSelector.Url);
                pgNew.Icon             = BBStoreHelper.GetRelativeFilePath(IconSelector.Url);
                pgNew.ProductListTabId = Convert.ToInt32(urlTarget.Url);
                pgNew.Disabled         = chkDisabled.Checked;
                pgNew.ViewOrder        = Convert.ToInt32(txtViewOrder.Text);
                int productGroupId = Controller.NewProductGroup(pgNew);
                foreach (ProductGroupLangInfo pgl in lngProductGroups.Langs)
                {
                    pgl.ProductGroupId = productGroupId;
                    Controller.NewProductGroupLang(pgl);
                }
                ProductGroupId = productGroupId;
                EditState      = "update";
                break;

            case "update":
                ProductGroupInfo pgUpdate = Controller.GetProductGroup(PortalId, ProductGroupId);
                pgUpdate.Image            = BBStoreHelper.GetRelativeFilePath(ImageSelector.Url);
                pgUpdate.Icon             = BBStoreHelper.GetRelativeFilePath(IconSelector.Url);
                pgUpdate.ProductListTabId = Convert.ToInt32(urlTarget.Url);
                pgUpdate.Disabled         = chkDisabled.Checked;
                pgUpdate.ViewOrder        = Convert.ToInt32(txtViewOrder.Text);
                Controller.UpdateProductGroup(pgUpdate);
                Controller.DeleteProductGroupLangs(ProductGroupId);
                foreach (ProductGroupLangInfo pgl in lngProductGroups.Langs)
                {
                    pgl.ProductGroupId = ProductGroupId;
                    Controller.NewProductGroupLang(pgl);
                }
                break;

            default:
                break;
            }
            if (Request.QueryString["adminmode"] != null)
            {
                Response.Redirect(Globals.NavigateURL(TabId, "", "adminmode=productgroup"), true);
            }
            else
            {
                Response.Redirect(EditUrl(), true);
            }
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //TODO: Beim Aufruf der Seite ohne ProductGroupParameter wird der Breadcrumb nicht angezeigt (Info aus Filter)
            BBStoreController Controller = new BBStoreController();
            int ParentNode;

            if (Request["productgroup"] != null)
            {
                ParentNode = Convert.ToInt32(Request["productgroup"]);

                // We retrieve the treepath of the ParentNode
                string treePath = Controller.GetProductGroupPath(PortalSettings.PortalId, ParentNode);

                Label lbl = new Label();
                lbl.Text = Separator;
                phBreadCrumb.Controls.Add(lbl);

                // Now lets build the breadcrumb
                string[]   bread = treePath.Split('/');
                LinkButton cmdBread;

                for (int i = 0; i < bread.Length; i++)
                {
                    cmdBread = new LinkButton();
                    int productGroupId = Convert.ToInt32(bread[i].Substring(1));
                    cmdBread.Attributes.Add("productgroup", productGroupId.ToString());
                    ProductGroupInfo pgi = Controller.GetProductGroup(PortalSettings.PortalId, System.Threading.Thread.CurrentThread.CurrentCulture.Name, productGroupId);
                    cmdBread.Text     = pgi.ProductGroupName;
                    cmdBread.Click   += new EventHandler(cmdBread_Click);
                    cmdBread.CssClass = "SkinObject";
                    phBreadCrumb.Controls.Add(cmdBread);

                    if (i + 1 < bread.Length)
                    {
                        lbl      = new Label();
                        lbl.Text = Separator;
                        phBreadCrumb.Controls.Add(lbl);
                    }
                }
            }
        }
Esempio n. 3
0
        public override List <SitemapUrl> GetUrls(int portalId, PortalSettings ps, string version)
        {
            CultureInfo current   = Thread.CurrentThread.CurrentCulture;
            CultureInfo currentUI = Thread.CurrentThread.CurrentUICulture;

            BBStoreController controller = new BBStoreController();
            List <SitemapUrl> retVal     = new List <SitemapUrl>();

            ModuleController moduleController = new ModuleController();
            ArrayList        mods             = moduleController.GetModules(portalId);

            // Lets build the Languages Collection
            LocaleController            lc  = new LocaleController();
            Dictionary <string, Locale> loc = lc.GetLocales(PortalSettings.Current.PortalId);

            // Productgroups
            foreach (var mod in mods)
            {
                ModuleInfo modInfo = (ModuleInfo)mod;
                if (modInfo.ModuleDefinition.FriendlyName == "BBStore Product Groups")
                {
                    bool fixedRoot = (modInfo.ModuleSettings["RootLevelFixed"] != null && Convert.ToBoolean(modInfo.ModuleSettings["RootLevelFixed"]));
                    int  rootLevel = (modInfo.ModuleSettings["RootLevel"] != null ? Convert.ToInt32(modInfo.ModuleSettings["RootLevel"]) : -1);
                    List <ProductGroupInfo> productGroups = new List <ProductGroupInfo>();
                    if (rootLevel > -1 && fixedRoot)
                    {
                        productGroups.Add(controller.GetProductGroup(portalId, rootLevel));
                    }
                    else if (rootLevel > -1 && !fixedRoot)
                    {
                        productGroups = controller.GetProductSubGroupsByNode(portalId, "en-US", rootLevel, false, false, false);
                    }
                    else if (rootLevel == -1 && fixedRoot)
                    {
                        productGroups.Add(new ProductGroupInfo()
                        {
                            ProductGroupId = -1
                        });
                    }
                    else
                    {
                        productGroups = controller.GetProductGroups(portalId);
                    }

                    List <ProductGroupInfo> sortedGroups = productGroups.OrderBy(p => p.ProductGroupId).ToList();
                    foreach (ProductGroupInfo productGroup in sortedGroups)
                    {
                        foreach (KeyValuePair <string, Locale> lang in loc)
                        {
                            // Set language to product Language
                            Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(lang.Key);
                            Thread.CurrentThread.CurrentUICulture = new CultureInfo(lang.Key);

                            // Lets check if we already have this
                            string name = "", url = "";
                            ProductGroupLangInfo pgl = controller.GetProductGroupLang(productGroup.ProductGroupId, lang.Key);
                            if (pgl != null)
                            {
                                name = HttpUtility.UrlEncode(pgl.ProductGroupName);
                            }
                            if (name != String.Empty)
                            {
                                url = Globals.NavigateURL(modInfo.TabID, "", "productGroup=" + productGroup.ProductGroupId.ToString(), "name=" + name);
                            }
                            else
                            {
                                url = Globals.NavigateURL(modInfo.TabID, "", "productGroup=" + productGroup.ProductGroupId.ToString());
                            }
                            if (retVal.Find(r => r.Url == url) == null)
                            {
                                var pageUrl = new SitemapUrl
                                {
                                    Url             = url,
                                    Priority        = (float)0.5,
                                    LastModified    = DateTime.Now.AddDays(-1),
                                    ChangeFrequency = SitemapChangeFrequency.Daily
                                };
                                retVal.Add(pageUrl);
                            }
                        }
                    }
                }
            }

            foreach (var mod in mods)
            {
                // First we need to know where our ProductModule sits
                ModuleInfo modInfo = (ModuleInfo)mod;
                if (modInfo.ModuleDefinition.FriendlyName == "BBStore Product" || modInfo.ModuleDefinition.FriendlyName == "BBStore Simple Product")
                {
                    int tabId = modInfo.TabID;

                    int productId = -1;
                    if (modInfo.ModuleSettings["ProductId"] != null)
                    {
                        productId = Convert.ToInt32(modInfo.ModuleSettings["ProductId"]);
                    }

                    if (productId < 0)
                    {
                        // We've got a dynamic module ! Here we show all products that are not disbaled !
                        List <SimpleProductInfo> products = controller.GetSimpleProducts(portalId).FindAll(p => p.Disabled == false);
                        foreach (SimpleProductInfo product in products)
                        {
                            foreach (KeyValuePair <string, Locale> lang in loc)
                            {
                                // Set language to product Language
                                Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(lang.Key);
                                Thread.CurrentThread.CurrentUICulture = new CultureInfo(lang.Key);

                                // Lets check if we already have this
                                string name = "", url = "";
                                SimpleProductLangInfo spl = controller.GetSimpleProductLang(product.SimpleProductId, lang.Key);
                                if (spl != null)
                                {
                                    name = HttpUtility.UrlEncode(spl.Name);
                                }
                                if (name != string.Empty)
                                {
                                    url = Globals.NavigateURL(tabId, "", "productid=" + product.SimpleProductId.ToString(), "name=" + name);
                                }
                                else
                                {
                                    url = Globals.NavigateURL(tabId, "", "productid=" + product.SimpleProductId.ToString());
                                }

                                if (retVal.Find(r => r.Url == url) == null)
                                {
                                    var pageUrl = new SitemapUrl
                                    {
                                        Url             = url,
                                        Priority        = (float)0.3,
                                        LastModified    = product.LastModifiedOnDate,
                                        ChangeFrequency = SitemapChangeFrequency.Daily
                                    };
                                    retVal.Add(pageUrl);
                                }
                            }
                        }
                    }
                    else
                    {
                        // This is a fixed module !
                        SimpleProductInfo product = controller.GetSimpleProductByProductId(portalId, productId);
                        foreach (KeyValuePair <string, Locale> lang in loc)
                        {
                            // Set language to product Language
                            Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(lang.Key);
                            Thread.CurrentThread.CurrentUICulture = new CultureInfo(lang.Key);

                            // Lets check if we already have this
                            string name = "", url = "";
                            SimpleProductLangInfo spl = controller.GetSimpleProductLang(productId, lang.Key);
                            if (spl != null)
                            {
                                name = HttpUtility.UrlEncode(spl.Name);
                            }
                            if (name != string.Empty)
                            {
                                url = Globals.NavigateURL(tabId, "", "name=" + name);
                            }
                            else
                            {
                                url = Globals.NavigateURL(tabId);
                            }

                            if (retVal.Find(r => r.Url == url) == null)
                            {
                                var pageUrl = new SitemapUrl
                                {
                                    Url             = url,
                                    Priority        = (float)0.4,
                                    LastModified    = product.LastModifiedOnDate,
                                    ChangeFrequency = SitemapChangeFrequency.Daily
                                };
                                retVal.Add(pageUrl);
                            }
                        }
                    }
                }

                // Reset values
                Thread.CurrentThread.CurrentCulture   = current;
                Thread.CurrentThread.CurrentUICulture = currentUI;
            }
            return(retVal);
        }