Exemple #1
0
        /// <summary>
        /// Gets a list of the <see cref="Event"/>s for this module.  Does not take the <paramref name="listTag"/> or <paramref name="context"/> into account,
        /// effectively only supporting one data source.
        /// </summary>
        /// <remarks>
        /// The <paramref name="context"/> parameter should always be <c>null</c> unless the Engage:List tag is nested inside of another Engage:List.
        /// </remarks>
        /// <param name="listTag">The Engage:List <see cref="Tag"/> for which to return a data source</param>
        /// <param name="context">The current <see cref="Event"/> being processed, or <c>null</c> if no list is currently being processed</param>
        /// <returns>A list of the <see cref="Event"/>s over which the given <paramref name="listTag"/> should be processed</returns>
        private IEnumerable <ITemplateable> GetEvents(Tag listTag, ITemplateable context)
        {
            var dateRange = this.IsManageEvents
                                ? new DateRange(DateRangeBound.CreateUnboundedBound(), DateRangeBound.CreateUnboundedBound())
                                : ModuleSettings.GetDateRangeFor(this);

            var events = EventCollection.Load(
                this.PortalId,
                dateRange.GetStartDateUtc(),
                dateRange.GetEndDateUtc(),
                this.SortExpression,
                this.CurrentPageIndex - 1,
                this.RecordsPerPage,
                this.Status.Equals("All", StringComparison.OrdinalIgnoreCase),
                !this.IsManageEvents && this.IsFeatured,
                !this.IsManageEvents && this.HideFullEvents,
                IsLoggedIn ? this.UserInfo.Email : null,
                this.FilterCategoryIds ?? this.CategoryIds);

            this.TotalNumberOfEvents = events.TotalRecords;
            this.TemplateProvider.ItemPagingState = new ItemPagingState(this.CurrentPageIndex, events.TotalRecords, this.RecordsPerPage);

            return(((IEnumerable <Event>)events).Select(e =>
            {
                if (string.IsNullOrEmpty(e.Category.Name))
                {
                    e.Category.Name = this.Localize("DefaultCategory", this.LocalSharedResourceFile);
                }

                return (ITemplateable)e;
            }));
        }
Exemple #2
0
        /// <summary>
        /// Gets the search items for the given module.
        /// </summary>
        /// <param name="modInfo">The module for which to get search items.</param>
        /// <returns>A new <see cref="SearchItemInfoCollection"/> for the items in the module</returns>
        public SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo)
        {
            if (modInfo == null)
            {
                throw new ArgumentNullException("modInfo");
            }

            var detailDisplayTabId    = ModuleSettings.DetailsDisplayTabId.GetValueAsInt32For(Utility.DesktopModuleName, modInfo, ModuleSettings.DetailsDisplayTabId.DefaultValue);
            var detailDisplayModuleId = ModuleSettings.DetailsDisplayModuleId.GetValueAsInt32For(Utility.DesktopModuleName, modInfo, ModuleSettings.DetailsDisplayModuleId.DefaultValue);

            if ((detailDisplayTabId != null && detailDisplayTabId != modInfo.TabID) || detailDisplayModuleId == null)
            {
                // If it's set to display on another page, just show it in this module; there's no way to link a search result to another page
                detailDisplayModuleId = modInfo.ModuleID;
            }

            var isListingDisplay = ModuleSettings.DisplayType.GetValueAsStringFor(Utility.DesktopModuleName, modInfo, ModuleSettings.DisplayType.DefaultValue).Equals("LIST", StringComparison.OrdinalIgnoreCase);
            var dateRange        = isListingDisplay
                                ? ModuleSettings.GetDateRangeFor(new FakeModuleControlBase(Utility.DesktopModuleName, modInfo))
                                : new DateRange(DateRangeBound.CreateUnboundedBound(), DateRangeBound.CreateUnboundedBound());
            var featuredOnly           = ModuleSettings.FeaturedOnly.GetValueAsBooleanFor(Utility.DesktopModuleName, modInfo, ModuleSettings.FeaturedOnly.DefaultValue);
            var hideFullEvents         = ModuleSettings.HideFullEvents.GetValueAsBooleanFor(Utility.DesktopModuleName, modInfo, ModuleSettings.HideFullEvents.DefaultValue);
            var categoriesSettingValue = ModuleSettings.Categories.GetValueAsStringFor(Utility.DesktopModuleName, modInfo, ModuleSettings.Categories.DefaultValue);
            var categoryIds            = string.IsNullOrEmpty(categoriesSettingValue)
                                  ? Enumerable.Empty <int>()
                                  : categoriesSettingValue.Split(',').Select(id => int.Parse(id, CultureInfo.InvariantCulture));

            var querystringParameters = new[] { "modId=" + detailDisplayModuleId.Value.ToString(CultureInfo.InvariantCulture), "key=EventDetail" };

            var events = EventCollection.Load(
                modInfo.PortalID,
                dateRange.GetStartDateUtc(),
                dateRange.GetEndDateUtc(),
                isListingDisplay,
                featuredOnly,
                hideFullEvents,
                null,
                categoryIds);

            return(new SearchItemInfoCollection(events.Cast <Event>()
                                                .Select(e => new SearchItemInfo(
                                                            e.Title,
                                                            e.Overview,
                                                            e.CreatedBy,
                                                            e.RevisionDate,
                                                            modInfo.ModuleID,
                                                            e.Id.ToString(CultureInfo.InvariantCulture),
                                                            e.Title + ' ' + e.Overview + ' ' + e.Description,
                                                            string.Join("&", Utility.GetEventParameters(e, querystringParameters).ToArray())))
                                                .ToArray()));
        }