Ejemplo n.º 1
0
        public override void LoadSettings()
        {
            try
            {
                if (!IsPostBack)
                {
                    rblSelectView.SelectedValue = (string)ModuleSettings["SelectView"] ?? "0";
                    rblSelectView_SelectedIndexChanged(this, null);

                    txtSimpleHeader.Text = (string)ModuleSettings["SimpleHeader"] ?? "";
                    txtSimpleFooter.Text = (string)ModuleSettings["SimpleFooter"] ?? "";

                    if (ModuleSettings["ProductsInRow"] != null)
                    {
                        txtProductsInRow.Text = (string)ModuleSettings["ProductsInRow"];
                    }
                    else
                    {
                        txtProductsInRow.Text = "3";
                    }

                    if (ModuleSettings["ProductsPerPage"] != null)
                    {
                        txtProductsPerPage.Text = (string)ModuleSettings["ProductsPerPage"];
                    }
                    else
                    {
                        txtProductsPerPage.Text = "25";
                    }

                    if (ModuleSettings["SetTitle"] != null)
                    {
                        chkSetTitle.Checked = Convert.ToBoolean(ModuleSettings["SetTitle"]);
                    }

                    if (ModuleSettings["TitleBreadcrumb"] != null)
                    {
                        chkTitleBreadcrumb.Checked = Convert.ToBoolean(ModuleSettings["TitleBreadcrumb"]);
                    }

                    if (ModuleSettings["ShowAllLinkPos"] != null)
                    {
                        cboShowAllLink.SelectedIndex = Convert.ToInt32(ModuleSettings["ShowAllLinkPos"]);
                    }

                    if (ModuleSettings["ShowListHead"] != null)
                    {
                        chkShowListHead.Checked = Convert.ToBoolean(ModuleSettings["ShowListHead"]);
                    }
                    else
                    {
                        chkShowListHead.Checked = true;
                    }

                    if (ModuleSettings["ShowPaging"] != null)
                    {
                        chkShowPaging.Checked = Convert.ToBoolean(ModuleSettings["ShowPaging"]);
                    }
                    else
                    {
                        chkShowPaging.Checked = true;
                    }

                    if (ModuleSettings["RandomSort"] != null)
                    {
                        chkRandomSort.Checked = Convert.ToBoolean(ModuleSettings["RandomSort"]);
                    }
                    else
                    {
                        chkRandomSort.Checked = false;
                    }

                    if (ModuleSettings["HideEmptyModule"] != null)
                    {
                        chkHideEmptyModule.Checked = Convert.ToBoolean(ModuleSettings["HideEmptyModule"]);
                    }
                    else
                    {
                        chkHideEmptyModule.Checked = false;
                    }

                    if (ModuleSettings["Template"] != null)
                    {
                        tplTemplate.Value = (string)ModuleSettings["Template"];
                    }

                    if (ModuleSettings["ProductModulePage"] != null)
                    {
                        urlProductModulePage.Url = (string)ModuleSettings["ProductModulePage"];
                    }

                    if (ModuleSettings["ProductListModulePage"] != null)
                    {
                        urlProductListModulePage.Url = (string)ModuleSettings["ProductListModulePage"];
                    }

                    rblSelection.Items.Add(new ListItem(Localization.GetString("rblSelectionDynamic.Text", this.LocalResourceFile), "0"));
                    rblSelection.Items.Add(new ListItem(Localization.GetString("rblSelectionStatic.Text", this.LocalResourceFile), "1"));

                    if (ModuleSettings["Selection"] != null)
                    {
                        rblSelection.SelectedValue = (string)ModuleSettings["Selection"];
                    }
                    else
                    {
                        rblSelection.SelectedIndex = 0;
                    }
                    rblSelection_SelectedIndexChanged(this, new EventArgs());

                    if (ModuleSettings["StaticFilterId"] != null)
                    {
                        int staticFilterId = Convert.ToInt32((string)ModuleSettings["StaticFilterId"]);
                        cboStaticFilter.SelectedValue = staticFilterId.ToString();

                        if (staticFilterId == -1)
                        {
                            cboStaticFilter.SelectedIndex = 0;
                            cmdSaveStaticFilter.Visible   = true;
                            cmdDeleteStaticFilter.Visible = false;
                            txtStaticFilterToken.Visible  = true;
                            lblStaticFilterToken.Visible  = true;
                            txtStaticFilter.Enabled       = true;
                            txtStaticFilter.Text          = "";
                        }
                        else
                        {
                            StaticFilterInfo fi = Controller.GetStaticFilterById(staticFilterId);
                            cboStaticFilter.SelectedValue = fi.StaticFilterId.ToString();
                            cmdSaveStaticFilter.Visible   = false;
                            cmdDeleteStaticFilter.Visible = true;
                            txtStaticFilterToken.Visible  = false;
                            txtStaticFilterToken.Text     = cboStaticFilter.SelectedItem.Text;
                            lblStaticFilterToken.Visible  = false;
                            txtStaticFilter.Enabled       = false;
                            txtStaticFilter.Text          = fi.FilterCondition;
                        }
                    }
                    else
                    {
                        cboStaticFilter.SelectedIndex = 0;
                        cmdSaveStaticFilter.Visible   = true;
                        cmdDeleteStaticFilter.Visible = false;
                        txtStaticFilterToken.Visible  = true;
                        lblStaticFilterToken.Visible  = true;
                        txtStaticFilter.Enabled       = true;
                        txtStaticFilter.Text          = "";
                    }

                    if (ModuleSettings["TopN"] != null)
                    {
                        txtTopN.Text = (string)ModuleSettings["TopN"];
                    }
                    else
                    {
                        txtTopN.Text = "0";
                    }
                }
            }
            catch (Exception exc)
            {
                //Module failed to load
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }