/// <summary>
        /// Initializes the controls.
        /// </summary>
        /// <param name="container">The controls container.</param>
        /// <param name="definition">The content view definition.</param>
        protected override void InitializeControls(GenericContainer container, IContentViewDefinition definition)
        {
            var masterDefinition = definition as IContentViewMasterDefinition;

            if (masterDefinition != null)
            {
                var query = this.Manager.GetProducts();
                if (masterDefinition.AllowUrlQueries.HasValue && masterDefinition.AllowUrlQueries.Value)
                {
                    query = this.EvaluateUrl(query, "Date", "PublicationDate", this.Host.UrlEvaluationMode, this.Host.UrlKeyPrefix);
                    query = this.EvaluateUrl(query, "Author", "Owner", this.Host.UrlEvaluationMode, this.Host.UrlKeyPrefix);
                    query = this.EvaluateUrl(query, "Taxonomy", string.Empty, typeof(ProductItem), this.Host.UrlEvaluationMode, this.Host.UrlKeyPrefix);
                }

                int?totalCount  = 0;
                int?itemsToSkip = 0;
                if (masterDefinition.AllowPaging.HasValue && masterDefinition.AllowPaging.Value)
                {
                    itemsToSkip = this.GetItemsToSkipCount(masterDefinition.ItemsPerPage, this.Host.UrlEvaluationMode, this.Host.UrlKeyPrefix);
                }

                CultureInfo uiCulture = null;
                if (AppSettings.CurrentSettings.Multilingual)
                {
                    uiCulture = System.Globalization.CultureInfo.CurrentUICulture;
                }
                //the filter is adapted to the implementation of ILifecycleDataItemGeneric, so the culture is taken in advance when filtering published items.
                this.FilterExpression = ContentHelper.AdaptMultilingualFilterExpression(this.FilterExpression);
                var filterExpression = DefinitionsHelper.GetFilterExpression(this.FilterExpression, this.AdditionalFilter);
                query = Telerik.Sitefinity.Data.DataProviderBase.SetExpressions(
                    query,
                    filterExpression,
                    masterDefinition.SortExpression,
                    uiCulture,
                    itemsToSkip,
                    masterDefinition.ItemsPerPage,
                    ref totalCount);

                this.IsEmptyView = (totalCount == 0);

                if (totalCount == 0)
                {
                    this.NewsList.Visible = false;
                }
                else
                {
                    this.ConfigurePager(totalCount.Value, masterDefinition);
                    this.NewsList.DataSource = query.ToList();
                    this.NewsList.PreRender += new EventHandler(NewsList_PreRender);
                }
            }
        }
        /// <summary>
        /// Initializes the controls.
        /// </summary>
        /// <param name="container">The controls container.</param>
        /// <param name="definition">The content view definition.</param>
        protected override void InitializeControls(GenericContainer container, IContentViewDefinition definition)
        {
            var masterDefinition = definition as IContentViewMasterDefinition;

            if (masterDefinition != null)
            {
                var query = this.Manager.GetAgents();
                if (masterDefinition.AllowUrlQueries.HasValue && masterDefinition.AllowUrlQueries.Value)
                {
                    query = this.EvaluateUrl(query, "Date", "PublicationDate", this.Host.UrlEvaluationMode, this.Host.UrlKeyPrefix);
                    query = this.EvaluateUrl(query, "Author", "Owner", this.Host.UrlEvaluationMode, this.Host.UrlKeyPrefix);
                    query = this.EvaluateUrl(query, "Taxonomy", "", typeof(AgentItem), this.Host.UrlEvaluationMode, this.Host.UrlKeyPrefix);
                }

                int?totalCount  = 0;
                int?itemsToSkip = 0;
                if (masterDefinition.AllowPaging.HasValue && masterDefinition.AllowPaging.Value)
                {
                    itemsToSkip = this.GetItemsToSkipCount(masterDefinition.ItemsPerPage, this.Host.UrlEvaluationMode, this.Host.UrlKeyPrefix);
                }

                CultureInfo uiCulture = null;
                if (Config.Get <ResourcesConfig>().Multilingual)
                {
                    uiCulture = System.Globalization.CultureInfo.CurrentUICulture;
                }
                var filterExpression = DefinitionsHelper.GetFilterExpression(masterDefinition);
                query = Telerik.Sitefinity.Data.DataProviderBase.SetExpressions(
                    query,
                    filterExpression,
                    masterDefinition.SortExpression,
                    uiCulture,
                    itemsToSkip,
                    masterDefinition.ItemsPerPage,
                    ref totalCount);

                this.IsEmptyView = (totalCount == 0);

                if (totalCount == 0)
                {
                    this.AgentsListControl.Visible = false;
                }
                else
                {
                    this.ConfigurePager(totalCount.Value, masterDefinition);
                    this.librariesManager.Provider.SuppressSecurityChecks = true;
                    this.AgentsListControl.ItemDataBound += new EventHandler <RadListViewItemEventArgs>(AgentsListControl_ItemDataBound);
                    this.AgentsListControl.DataSource     = query.ToList();
                }
            }
        }
Пример #3
0
        private void BindItems()
        {
            isThumbView = this.IsThumbView();
            int    itemsPerPage = ItemsPerPage();
            string sortBy       = SortBy();
            string sortDir      = SortDir();

            lbnItemPerPage_Nine.CssClass        = string.Empty;
            lbnItemPerPage_Eighteen.CssClass    = string.Empty;
            lbnItemPerPage_Twentyseven.CssClass = string.Empty;

            switch (itemsPerPage)
            {
            case 9:
                lbnItemPerPage_Nine.CssClass = "current";
                break;

            case 18:
                lbnItemPerPage_Eighteen.CssClass = "current";
                break;

            case 27:
                lbnItemPerPage_Twentyseven.CssClass = "current";
                break;
            }

            if (sortBy.Equals("price", StringComparison.OrdinalIgnoreCase))
            {
                if (sortDir.Equals("desc", StringComparison.OrdinalIgnoreCase))
                {
                    lbnSortBy_Price.CssClass = "arrow-down current";
                }
                else
                {
                    lbnSortBy_Price.CssClass = "arrow-up current";
                }
            }

            var masterDefinition = this.MasterViewDefinition as IContentViewMasterDefinition;

            if (masterDefinition != null)
            {
                var query = this.Manager.GetItems();
                if (masterDefinition.AllowUrlQueries.HasValue && masterDefinition.AllowUrlQueries.Value)
                {
                    query = this.EvaluateUrl(query, "Date", "PublicationDate", this.Host.UrlEvaluationMode, this.Host.UrlKeyPrefix);
                    query = this.EvaluateUrl(query, "Author", "Owner", this.Host.UrlEvaluationMode, this.Host.UrlKeyPrefix);
                    query = this.EvaluateUrl(query, "Taxonomy", "", typeof(RealEstateItem), this.Host.UrlEvaluationMode, this.Host.UrlKeyPrefix);
                }

                int?totalCount  = 0;
                int?itemsToSkip = 0;
                if (masterDefinition.AllowPaging.HasValue && masterDefinition.AllowPaging.Value)
                {
                    itemsToSkip = this.GetItemsToSkipCount(ItemsPerPage(), this.Host.UrlEvaluationMode, this.Host.UrlKeyPrefix);
                }

                CultureInfo uiCulture = null;
                if (Config.Get <ResourcesConfig>().Multilingual)
                {
                    uiCulture = System.Globalization.CultureInfo.CurrentUICulture;
                }

                string sortExpression = "Price ";

                if (sortBy.Equals("location", StringComparison.OrdinalIgnoreCase))
                {
                    sortExpression = "Locations ";
                }

                sortExpression += sortDir;

                var filterExpression = DefinitionsHelper.GetFilterExpression(masterDefinition);
                query = Telerik.Sitefinity.Data.DataProviderBase.SetExpressions(
                    query,
                    filterExpression,
                    SortBy() + " " + SortDir(),
                    uiCulture,
                    itemsToSkip,
                    itemsPerPage,
                    ref totalCount);

                this.IsEmptyView = (totalCount == 0);

                if (totalCount == 0)
                {
                    this.ItemsList_Flow.Visible  = false;
                    this.ItemsList_Thumb.Visible = false;
                }
                else
                {
                    this.ConfigurePager(totalCount.Value, masterDefinition);
                    this.librariesManager.Provider.SuppressSecurityChecks = true;


                    if (this.IsThumbView())
                    {
                        this.ItemsList_Thumb.ItemDataBound += new EventHandler <RadListViewItemEventArgs>(ItemsListControl_ItemDataBound);
                        this.ItemsList_Thumb.DataSource     = query;
                        this.ItemsList_Thumb.Visible        = true;
                        this.ItemsList_Flow.Visible         = false;

                        lbnThumbnailView.CssClass = "thumbnails current";
                        lbnListView.CssClass      = "list";
                    }
                    else
                    {
                        this.ItemsList_Flow.ItemDataBound += new EventHandler <RadListViewItemEventArgs>(ItemsListControl_ItemDataBound);
                        this.ItemsList_Flow.DataSource     = query;
                        this.ItemsList_Flow.Visible        = true;
                        this.ItemsList_Thumb.Visible       = false;

                        lbnListView.CssClass      = "list current";
                        lbnThumbnailView.CssClass = "thumbnails";
                    }
                }
            }
        }