Exemplo n.º 1
0
        /// <summary>
        /// Loads the specified node uid.
        /// </summary>
        /// <param name="NodeUid">The node uid.</param>
        /// <param name="ControlUid">The control uid.</param>
        void IPropertyPage.Load(string NodeUid, string ControlUid)
        {
            ControlSettings settings = new ControlSettings();

            DynamicNode dNode = PageDocument.Current.DynamicNodes.LoadByUID(NodeUid);

            if (dNode != null)
            {
                settings = dNode.GetSettings(NodeUid);
            }

            // Bind Meta Types
            // Bind Meta classes
            // MetaDataContext.Current = CatalogContext.MetaDataContext;
            MetaClass catalogEntry = MetaClass.Load(CatalogContext.MetaDataContext, "CatalogEntry");

            MetaClassList.Items.Clear();
            if (catalogEntry != null)
            {
                MetaClassCollection metaClasses = catalogEntry.ChildClasses;
                foreach (MetaClass metaClass in metaClasses)
                {
                    MetaClassList.Items.Add(new ListItem(metaClass.FriendlyName, metaClass.Name));
                }
                MetaClassList.DataBind();
            }

            // Bind templates
            DisplayTemplate.Items.Clear();
            DisplayTemplate.Items.Add(new ListItem("(use default)", ""));
            TemplateDto templates = DictionaryManager.GetTemplateDto();

            if (templates.main_Templates.Count > 0)
            {
                DataView view = templates.main_Templates.DefaultView;
                view.RowFilter = "TemplateType = 'search-index'";

                foreach (DataRowView row in view)
                {
                    DisplayTemplate.Items.Add(new ListItem(row["FriendlyName"].ToString(), row["Name"].ToString()));
                }

                DisplayTemplate.DataBind();
            }

            // Bind Types
            EntryTypeList.Items.Clear();
            EntryTypeList.Items.Add(new ListItem(EntryType.Product, EntryType.Product));
            EntryTypeList.Items.Add(new ListItem(EntryType.Package, EntryType.Package));
            EntryTypeList.Items.Add(new ListItem(EntryType.Bundle, EntryType.Bundle));
            EntryTypeList.Items.Add(new ListItem(EntryType.DynamicPackage, EntryType.DynamicPackage));
            EntryTypeList.Items.Add(new ListItem(EntryType.Variation, EntryType.Variation));
            EntryTypeList.DataBind();

            // Bind catalogs
            CatalogList.Items.Clear();
            CatalogDto catalogs = CatalogContext.Current.GetCatalogDto(CMSContext.Current.SiteId);

            if (catalogs.Catalog.Count > 0)
            {
                foreach (CatalogDto.CatalogRow row in catalogs.Catalog)
                {
                    if (row.IsActive && row.StartDate <= FrameworkContext.Current.CurrentDateTime && row.EndDate >= FrameworkContext.Current.CurrentDateTime)
                    {
                        CatalogList.Items.Add(new ListItem(row.Name, row.Name));
                    }
                }

                CatalogList.DataBind();
            }

            //Bind Depositories
            this.ddlDepository.DataSource = Enum.GetNames(typeof(NWTD.InfoManager.Depository));
            this.ddlDepository.DataBind();

            if (settings != null && settings.Params != null)
            {
                Param prm = settings.Params;

                CommonHelper.LoadTextBox(settings, "NodeCode", NodeCode);
                CommonHelper.LoadTextBox(settings, "RecordsPerPage", NumberOfRecords);

                /*
                 * CommonHelper.LoadTextBox(settings, "FTSPhrase", FTSPhrase);
                 * CommonHelper.LoadTextBox(settings, "AdvancedFTSPhrase", AdvancedFTSPhrase);
                 * CommonHelper.LoadTextBox(settings, "MetaSQLClause", MetaSQLClause);
                 * CommonHelper.LoadTextBox(settings, "SQLClause", SQLClause);
                 * */

                if ((prm["DisplayTemplate"] != null) && (prm["DisplayTemplate"] is string))
                {
                    CommonHelper.SelectListItem(DisplayTemplate, prm["DisplayTemplate"].ToString());
                }

                CommonHelper.SelectList(settings, "Catalogs", CatalogList);
                CommonHelper.SelectList(settings, "EntryClasses", MetaClassList);
                CommonHelper.SelectList(settings, "EntryTypes", EntryTypeList);

                // Orderby
                if ((prm["OrderBy"] != null) && (prm["OrderBy"] is string))
                {
                    string orderBy = prm["OrderBy"].ToString();
                    bool   isDesc  = orderBy.Contains("DESC");

                    string listOrderBy = orderBy.Replace(" DESC", "");
                    listOrderBy = listOrderBy.Replace(" ASC", "");

                    CommonHelper.SelectListItem(OrderByList, listOrderBy);

                    if (!String.IsNullOrEmpty(OrderByList.SelectedValue))
                    {
                        if (OrderByList.SelectedValue == "custom")
                        {
                            OrderBy.Text = orderBy;
                        }
                        else
                        {
                            OrderDesc.Checked = isDesc;
                        }
                    }
                }


                if (prm[DEPOSITORY_KEY] == null)
                {
                    prm[DEPOSITORY_KEY] = NWTD.InfoManager.Depository.NWTD.ToString();
                }
                this.ddlDepository.SelectedValue = settings.Params[DEPOSITORY_KEY].ToString();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Loads the specified node uid.
        /// </summary>
        /// <param name="NodeUid">The node uid.</param>
        /// <param name="ControlUid">The control uid.</param>
        void IPropertyPage.Load(string NodeUid, string ControlUid)
        {
            ControlSettings settings = new ControlSettings();

            DynamicNode dNode = PageDocument.Current.DynamicNodes.LoadByUID(NodeUid);

            if (dNode != null)
            {
                settings = dNode.GetSettings(NodeUid);
            }

            // Bind templates
            DisplayTemplate.Items.Clear();
            DisplayTemplate.Items.Add(new ListItem("(use default)", ""));
            TemplateDto templates = DictionaryManager.GetTemplateDto();

            if (templates.main_Templates.Count > 0)
            {
                DataView view = templates.main_Templates.DefaultView;
                view.RowFilter = "TemplateType = 'entry'";

                foreach (DataRowView row in view)
                {
                    DisplayTemplate.Items.Add(new ListItem(row["FriendlyName"].ToString(), row["Name"].ToString()));
                }

                DisplayTemplate.DataBind();
            }

            // Bind catalogs
            CatalogList.Items.Clear();
            CatalogList.Items.Add(new ListItem("(use default)", ""));
            CatalogDto catalogs = CatalogContext.Current.GetCatalogDto(CMSContext.Current.SiteId);

            if (catalogs.Catalog.Count > 0)
            {
                foreach (CatalogDto.CatalogRow row in catalogs.Catalog)
                {
                    if (row.IsActive && row.StartDate <= FrameworkContext.Current.CurrentDateTime && row.EndDate >= FrameworkContext.Current.CurrentDateTime)
                    {
                        CatalogList.Items.Add(new ListItem(row.Name, row.Name));
                    }
                }

                CatalogList.DataBind();
            }

            //Bind Depositories
            this.ddlDepository.DataSource = Enum.GetNames(typeof(NWTD.InfoManager.Depository));
            this.ddlDepository.DataBind();


            if (settings != null && settings.Params != null)
            {
                Param prm = settings.Params;
                if ((prm["NodeCode"] != null) && (prm["NodeCode"] is string))
                {
                    NodeCode.Text = prm["NodeCode"].ToString();
                }

                if ((prm["EntryCode"] != null) && (prm["EntryCode"] is string))
                {
                    EntryCode.Text = prm["EntryCode"].ToString();
                }

                if ((prm["DisplayTemplate"] != null) && (prm["DisplayTemplate"] is string))
                {
                    CommonHelper.SelectListItem(DisplayTemplate, prm["DisplayTemplate"].ToString());
                }

                if ((prm["CatalogName"] != null) && (prm["CatalogName"] is string))
                {
                    CommonHelper.SelectListItem(CatalogList, prm["CatalogName"].ToString());
                }

                if (prm[DEPOSITORY_KEY] == null)
                {
                    prm[DEPOSITORY_KEY] = NWTD.InfoManager.Depository.NWTD.ToString();
                }
                this.ddlDepository.SelectedValue = settings.Params[DEPOSITORY_KEY].ToString();
            }
        }