Beispiel #1
0
        /// <summary>
        /// Returns the full unique url for a Tree
        /// </summary>
        /// <param name="url"></param>
        /// <param name="action"></param>
        /// <param name="id"></param>
        /// <param name="treeId"></param>
        /// <param name="queryStrings"></param>
        /// <returns></returns>
        public static string GetTreeUrl(this UrlHelper url, string action, HiveId id, Guid treeId, FormCollection queryStrings)
        {
            var treeMetaData = DependencyResolver.Current.GetService <ComponentRegistrations>()
                               .TreeControllers
                               .Where(x => x.Metadata.Id == treeId)
                               .SingleOrDefault();

            if (treeMetaData == null)
            {
                throw new InvalidOperationException("Could not find the tree controller with id " + treeId);
            }

            var area = url.GetBackOfficeArea();

            //now, need to figure out what area this tree belongs too...
            var pluginDefition = treeMetaData.Metadata.PluginDefinition;

            if (pluginDefition.HasRoutablePackageArea())
            {
                area = pluginDefition.PackageName;
            }

            var genUrl = url.Action(action, treeMetaData.Metadata.ControllerName,
                                    new
            {
                area,
                id     = GetIdVal(id),
                treeId = treeId.ToString("N")
            });

            return(genUrl + (genUrl.Contains("?") ? "&" : "?") + queryStrings.ToQueryString());
        }
        public static string GetMenuUrl(this IUrlHelper urlHelper, UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, Type treeType, string nodeId, FormCollection?queryStrings)
        {
            var actionUrl = urlHelper.GetUmbracoApiService(umbracoApiControllerTypeCollection, "GetMenu", treeType)?
                            .EnsureEndsWith('?');

            //now we need to append the query strings
            actionUrl += "id=" + nodeId.EnsureEndsWith('&') + queryStrings?.ToQueryString("id");
            return(actionUrl);
        }
        public static string GetTreeUrl(this IUrlHelper urlHelper, UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, Type treeType, string nodeId, FormCollection?queryStrings)
        {
            var actionUrl = urlHelper.GetUmbracoApiService(umbracoApiControllerTypeCollection, "GetNodes", treeType)?
                            .EnsureEndsWith('?');

            //now we need to append the query strings
            actionUrl += "id=" + nodeId.EnsureEndsWith('&') + queryStrings?.ToQueryString("id",
                                                                                          //Always ignore the custom start node id when generating URLs for tree nodes since this is a custom once-only parameter
                                                                                          // that should only ever be used when requesting a tree to render (root), not a tree node
                                                                                          TreeQueryStringParameters.StartNodeId);
            return(actionUrl);
        }