/// <summary> /// Tries to resolve parent filter mode. /// </summary> /// <param name="urlParams">The URL params.</param> /// <param name="requestContext">The request context.</param> /// <param name="manager">The LibrariesManager.</param> /// <returns></returns> protected virtual bool TryResolveParentFilterMode(string[] urlParams, RequestContext requestContext, LibrariesManager manager = null) { var libraryManager = manager ?? LibrariesManager.GetManager(this.Model.ProviderName); string param = RouteHelper.GetUrlParameterString(urlParams); string redirectUrl; var item = libraryManager.GetItemFromUrl(typeof(VideoLibrary), param, out redirectUrl); if (item != null) { requestContext.RouteData.Values["action"] = "Successors"; requestContext.RouteData.Values["parentItem"] = item; if (this.Request["page"] != null) { requestContext.RouteData.Values["page"] = int.Parse(this.Request["page"]); } return(true); } if (urlParams.Length > 1) { this.TryResolveParentFilterMode(urlParams.Take(urlParams.Length - 1).ToArray(), requestContext, manager); } return(false); }
/// <inheritdoc /> protected override bool TryMatchUrl(string[] urlParams, RequestContext requestContext) { if (urlParams == null || urlParams.Length == 0) { return(false); } var url = RouteHelper.GetUrlParameterString(urlParams); string redirectUrl; var providerName = this.providerNameResolver != null?this.providerNameResolver() : null; var contentItemResolver = new ContentDataItemResolver(); var item = contentItemResolver.GetItemByUrl(url, this.ItemType, providerName, out redirectUrl); if (item != null) { SystemManager.CurrentHttpContext.Items["detailItem"] = item; this.AddContentItemToRouteData(requestContext, redirectUrl, item); return(true); } else if (urlParams.Length > 1) { this.TryMatchUrl(urlParams.Take(urlParams.Length - 1).ToArray(), requestContext); return(false); } return(false); }
private bool TryMatchUrl(string[] urlParams, RequestContext requestContext, bool setUrlParametersResolved) { if (urlParams == null || urlParams.Length == 0) { return(false); } var url = RouteHelper.GetUrlParameterString(urlParams); string redirectUrl; var providerName = this.providerNameResolver != null?this.providerNameResolver() : null; var contentItemResolver = new ContentDataItemResolver(); foreach (var parentType in this.ParentTypes) { var item = contentItemResolver.GetItemByUrl(url, parentType, providerName, out redirectUrl); if (item != null) { this.AddParentContentItemToRouteData(requestContext, item, parentType, setUrlParametersResolved); return(true); } } if (urlParams.Length > 1) { this.TryMatchUrl(urlParams.Take(urlParams.Length - 1).ToArray(), requestContext, false); } return(false); }
private bool TryMatchUrl(string[] urlParams, RequestContext requestContext, bool setUrlParametersResolved) { if (urlParams == null || urlParams.Length == 0 || !this.IsDetailsModeSupported()) { return(false); } var url = RouteHelper.GetUrlParameterString(urlParams); string redirectUrl; var providerName = this.providerNameResolver != null?this.providerNameResolver() : null; var contentItemResolver = new ContentDataItemResolver(); var item = contentItemResolver.GetItemByUrl(url, this.ItemType, providerName, out redirectUrl); if (item != null) { SystemManager.CurrentHttpContext.Items["detailItem"] = item; this.AddContentItemToRouteData(requestContext, redirectUrl, item, setUrlParametersResolved); return(true); } else if (this.showDetailsViewOnChildDetailsView) { return(this.TryMatchUrl(urlParams.Take(urlParams.Length - 1).ToArray(), requestContext, setUrlParametersResolved)); } return(false); }
/// <inheritdoc /> protected override bool TryMatchUrl(string[] urlParams, RequestContext requestContext) { if (urlParams == null || urlParams.Length == 0) { return(false); } var url = RouteHelper.GetUrlParameterString(urlParams); string redirectUrl; var item = this.GetItemByUrl(url, out redirectUrl); if (item != null) { this.AddContentItemToRouteData(requestContext, redirectUrl, item); return(true); } else if (urlParams.Length > 1) { this.TryMatchUrl(urlParams.Take(urlParams.Length - 1).ToArray(), requestContext); return(false); } return(false); }
private bool TryMapSuccessorsRouteData(string[] urlParams, RequestContext requestContext, DynamicModuleManager manager, Type parentType) { string redirectUrl; var item = manager.Provider.GetItemFromUrl(parentType, RouteHelper.GetUrlParameterString(urlParams), true, out redirectUrl); if (item != null) { requestContext.RouteData.Values["action"] = "Successors"; requestContext.RouteData.Values["parentItem"] = item; if (this.Request["page"] != null) { requestContext.RouteData.Values["page"] = int.Parse(this.Request["page"]); } return(true); } if (urlParams.Length > 1) { this.TryMapSuccessorsRouteData(urlParams.Take(urlParams.Length - 1).ToArray(), requestContext, manager, parentType); } return(false); }
/// <inheritdoc /> public bool HideListView(RequestContext context) { if (this.HideListViewOnChildDetailsView) { var contentType = this.ContentType; var routeParams = MvcRequestContextBuilder.GetRouteParams(context); var urlParamsString = RouteHelper.GetUrlParameterString(routeParams); if (urlParamsString != null) { var manager = this.GetManager() as DynamicModuleManager; var allTypes = ModuleBuilderManager.GetModules().SelectMany(x => x.Types); var dynamicModuleType = allTypes.FirstOrDefault(x => x.TypeNamespace == contentType.Namespace && x.TypeName == contentType.Name); var dynamicModuleTypesForThisModule = allTypes.Where(x => x.ModuleId == dynamicModuleType.ModuleId).ToList(); var successorTypes = this.GetTypeSuccessors(dynamicModuleTypesForThisModule, dynamicModuleType).Select(c => c.GetFullTypeName()).ToList(); var item = manager.Provider.GetItemsFromUrl(urlParamsString, successorTypes, true).FirstOrDefault(); if (item != null) { return(successorTypes.Contains(item.GetType().FullName)); } } } return(false); }
private bool TryMapRelatedDataRouteData(string[] urlParams, RequestContext requestContext) { var manager = ManagerBase.GetMappedManager(this.Model.RelatedItemType, this.Model.RelatedItemProviderName); if (this.Model.RelatedItemProviderName.IsNullOrEmpty()) { this.Model.RelatedItemProviderName = manager.Provider.Name; } var urlProvider = manager.Provider as IUrlProvider; if (urlProvider == null) { return(false); } var relatedItemType = TypeResolutionService.ResolveType(this.Model.RelatedItemType, throwOnError: false); if (relatedItemType == null) { return(false); } string redirectUrl; var item = urlProvider.GetItemFromUrl(relatedItemType, RouteHelper.GetUrlParameterString(urlParams), out redirectUrl); if (item == null) { return(false); } requestContext.RouteData.Values["action"] = "RelatedData"; requestContext.RouteData.Values["relatedItem"] = item; if (this.Request["page"] != null) { requestContext.RouteData.Values["page"] = int.Parse(this.Request["page"]); } return(true); }
/// <summary> /// Gets the detail content item. /// </summary> /// <param name="controller">The controller.</param> /// <param name="routeParams">Contains information about the route parameters.</param> public IDataItem GetItemByController(ControllerBase controller, string[] routeParams) { string redirectUrl = null; IDataItem item = null; var url = RouteHelper.GetUrlParameterString(routeParams); var itemType = this.GetItemType(controller); if (itemType != null) { var providerNames = this.GetProviderNames(controller, itemType); foreach (var providerName in providerNames) { item = this.GetItemByUrl(url, itemType, providerName, out redirectUrl); if (item != null) { return(item); } } } return(item); }