Beispiel #1
0
        protected virtual void LoadSettings()
        {
            config = new ProductConfiguration(Settings);

            if (this.ModuleConfiguration != null)
            {
                this.Title       = ModuleConfiguration.ModuleTitle;
                this.Description = ModuleConfiguration.FeatureName;
            }
        }
Beispiel #2
0
        private void Page_Load(object sender, EventArgs e)
        {
            if (!CurrentZone.AllowBrowserCache)
            {
                SecurityHelper.DisableBrowserCache();
            }

            bool redirected = RedirectIfNeeded();

            if (redirected)
            {
                return;
            }

            // Modified: 2015-01-30 Load all contents from Center Pane
            bool isAdmin        = WebUser.IsAdmin;
            bool isContentAdmin = false;
            bool isSiteEditor   = false;

            if (!isAdmin)
            {
                isContentAdmin = WebUser.IsContentAdmin;
                isSiteEditor   = SiteUtils.UserIsSiteEditor();
            }

            bool forceShowViewMode = false;
            bool forceShowWorkflow = false;
            bool enabledWorkflow   = WebConfigSettings.EnableContentWorkflow && siteSettings.EnableContentWorkflow;

            // hide filter module on product detail
            PageSettings         currentPage = CurrentPage;
            ProductConfiguration config      = null;

            foreach (Module module in currentPage.Modules)
            {
                if (StringHelper.IsCaseInsensitiveMatch(module.ControlSource, "Product/ProductFilterModule.ascx"))
                {
                    module.HideFromAuthenticated   = true;
                    module.HideFromUnauthenticated = true;
                }

                if (StringHelper.IsCaseInsensitiveMatch(module.PaneName, "contentpane") &&
                    StringHelper.IsCaseInsensitiveMatch(module.ControlSource, "Product/ProductModule.ascx"))
                {
                    Hashtable settings = CacheHelper.GetModuleSettings(module.ModuleId);
                    config = new ProductConfiguration(settings);
                    break;
                }
            }
            CurrentPage = currentPage;

            foreach (Module module in CurrentPage.Modules)
            {
                if (StringHelper.IsCaseInsensitiveMatch(module.PaneName, "contentpane"))
                {
                    if (config == null || !config.ShowHiddenContents)
                    {
                        if (!ModuleIsVisible(module))
                        {
                            continue;
                        }
                    }

                    if (
                        (!WebUser.IsInRoles(module.ViewRoles)) &&
                        (!isContentAdmin) &&
                        (!isSiteEditor)
                        )
                    {
                        continue;
                    }

                    if ((module.ViewRoles == "Admins;") && (!isAdmin))
                    {
                        continue;
                    }

                    if (!ShouldShowModule(module))
                    {
                        continue;
                    }

                    Control parent = this.MPContent;

                    if ((module.CacheTime == 0) || (WebConfigSettings.DisableContentCache))
                    {
                        try
                        {
                            Control c = Page.LoadControl("~/" + module.ControlSource);
                            if (c == null)
                            {
                                continue;
                            }

                            if (c is ProductModule)
                            {
                                ProductModule siteModule = (ProductModule)c;
                                siteModule.SiteId = siteSettings.SiteId;
                                siteModule.ModuleConfiguration = module;
                                siteModule.ForceLoadDetail     = true;

                                if (
                                    Request.IsAuthenticated &&
                                    siteModule.UserHasPermission()
                                    )
                                {
                                    forceShowViewMode = true;
                                    forceShowWorkflow = enabledWorkflow;
                                }

                                parent.Controls.Add(c);
                            }
                            else if (c is SiteModuleControl)
                            {
                                if (
                                    !(config != null && config.HideOtherContentsOnDetailPage) ||
                                    (config != null && config.ShowHiddenContents && module.HideFromAuthenticated && module.HideFromUnauthenticated)
                                    )
                                {
                                    SiteModuleControl siteModule = (SiteModuleControl)c;
                                    siteModule.SiteId = siteSettings.SiteId;
                                    siteModule.ModuleConfiguration = module;

                                    if (
                                        Request.IsAuthenticated &&
                                        siteModule.UserHasPermission()
                                        )
                                    {
                                        forceShowViewMode = true;
                                        if (enabledWorkflow && siteModule is IWorkflow)
                                        {
                                            forceShowWorkflow = true;
                                        }
                                    }

                                    parent.Controls.Add(c);
                                }
                            }
                        }
                        catch (HttpException ex)
                        {
                            log.Error("failed to load control " + module.ControlSource, ex);
                        }
                    }
                    else
                    {
                        CachedSiteModuleControl siteModule = new CachedSiteModuleControl();

                        siteModule.SiteId = siteSettings.SiteId;
                        siteModule.ModuleConfiguration = module;
                        parent.Controls.Add(siteModule);
                    }

                    parent.Visible        = true;
                    parent.Parent.Visible = true;
                }
            } //end foreach

            SetupViewModeControls(forceShowViewMode, forceShowWorkflow);

            AddClassToBody("product-detail-page");
        }