/// <summary> /// Gets the source meta data for the current context. /// </summary> /// <param name="sourceMetadata">User-defined metadata.</param> /// <returns>SourceMetadataDictionary for the current request.</returns> private static SourceMetadataDictionary GetSourceMetadata(IDictionary <string, object> sourceMetadata) { var result = new SourceMetadataDictionary(sourceMetadata); result.Add("HtmlHelper", typeof(SiteMapHelper).FullName); return(result); }
/// <summary> /// Gets the title of SiteMap.CurrentNode /// </summary> /// <param name="helper">MvcSiteMapHtmlHelper instance</param> /// <param name="templateName">Name of the template.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>The title of the CurrentNode or the RootNode (if CurrentNode is null)</returns> public static MvcHtmlString SiteMapTitle(this MvcSiteMapHtmlHelper helper, string templateName, SourceMetadataDictionary sourceMetadata) { var model = BuildModel(GetSourceMetadata(sourceMetadata), helper.SiteMap.CurrentNode ?? helper.SiteMap.RootNode); return helper .CreateHtmlHelperForModel(model) .DisplayFor(m => model, templateName); }
/// <summary> /// Builds the model. /// </summary> /// <param name="startingNode">The starting node.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>The model.</returns> private static SiteMapTitleHelperModel BuildModel(SourceMetadataDictionary sourceMetadata, ISiteMapNode startingNode) { // Map to model return(new SiteMapTitleHelperModel { CurrentNode = new SiteMapNodeModel(startingNode, sourceMetadata) }); }
/// <summary> /// Gets the source meta data for the current context. /// </summary> /// <param name="sourceMetadata">User-defined metadata.</param> /// <returns>SourceMetadataDictionary for the current request.</returns> private static SourceMetadataDictionary GetSourceMetadata(IDictionary <string, object> sourceMetadata) { var result = new SourceMetadataDictionary(sourceMetadata); if (!result.ContainsKey("HtmlHelper")) { result.Add("HtmlHelper", typeof(SiteMapTitleHelper).FullName); } return(result); }
/// <summary> /// Builds the model. /// </summary> /// <param name="helper">The helper.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <param name="startingNode">The starting node.</param> /// <param name="startingNodeInChildLevel">Renders startingNode in child level if set to <c>true</c>.</param> /// <returns>The model.</returns> private static SiteMapHelperModel BuildModel(MvcSiteMapHtmlHelper helper, SourceMetadataDictionary sourceMetadata, ISiteMapNode startingNode, bool startingNodeInChildLevel) { // Build model var model = new SiteMapHelperModel(); var node = startingNode; // Check visibility and ACL if (node != null && node.IsVisible(sourceMetadata) && node.IsAccessibleToUser()) { // Add node var nodeToAdd = new SiteMapNodeModel(node, sourceMetadata); model.Nodes.Add(nodeToAdd); // Add child nodes if (startingNodeInChildLevel) { model.Nodes.AddRange(nodeToAdd.Descendants); } } return(model); }
/// <summary> /// Builds the model. /// </summary> /// <param name="helper">The helper.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <param name="startingNode">The starting node.</param> /// <param name="startingNodeInChildLevel">Renders startingNode in child level if set to <c>true</c>.</param> /// <returns>The model.</returns> internal static SiteMapHelperModel BuildModel(MvcSiteMapHtmlHelper helper, SourceMetadataDictionary sourceMetadata, ISiteMapNode startingNode, bool startingNodeInChildLevel, bool visibilityAffectsDescendants) { // Build model var model = new SiteMapHelperModel(); var node = startingNode; // Check if a starting node has been given if (node == null) { return(model); } // Check ACL if (node.IsAccessibleToUser()) { // Add node? var nodeToAdd = new SiteMapNodeModel(node, sourceMetadata, Int32.MaxValue, false, startingNodeInChildLevel, visibilityAffectsDescendants); // Check visibility if (node.IsVisible(sourceMetadata)) { model.Nodes.Add(nodeToAdd); // Add child nodes if (visibilityAffectsDescendants && startingNodeInChildLevel) { model.Nodes.AddRange(nodeToAdd.Children); } } // Add child nodes if (!visibilityAffectsDescendants && startingNodeInChildLevel) { model.Nodes.AddRange(nodeToAdd.Children); } } return(model); }
/// <summary> /// Build a menu, based on the MvcSiteMap /// </summary> /// <param name="helper">The helper.</param> /// <param name="templateName">Name of the template.</param> /// <param name="startingNode">The starting node.</param> /// <param name="startingNodeInChildLevel">Show starting node in child level if set to <c>true</c>.</param> /// <param name="showStartingNode">Show starting node if set to <c>true</c>.</param> /// <param name="maxDepth">The max depth.</param> /// <param name="drillDownToCurrent">Should the model exceed the maxDepth to reach the current node</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>Html markup</returns> public static MvcHtmlString Menu(this MvcSiteMapHtmlHelper helper, string templateName, ISiteMapNode startingNode, bool startingNodeInChildLevel, bool showStartingNode, int maxDepth, bool drillDownToCurrent, SourceMetadataDictionary sourceMetadata) { var model = BuildModel(helper, GetSourceMetadata(sourceMetadata), startingNode, startingNodeInChildLevel, showStartingNode, maxDepth, drillDownToCurrent); return helper .CreateHtmlHelperForModel(model) .DisplayFor(m => model, templateName); }
/// <summary> /// Gets the CanonicalUrl of SiteMap.CurrentNode /// </summary> /// <param name="helper">MvcSiteMapHtmlHelper instance</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>The CanonicalUrl of the CurrentNode or the RootNode (if CurrentNode is null)</returns> public static MvcHtmlString CanonicalTag(this MvcSiteMapHtmlHelper helper, SourceMetadataDictionary sourceMetadata) { return CanonicalTag(helper, null, sourceMetadata); }
/// <summary> /// Gets next node in the document outline for the current request /// </summary> /// <param name="helper">MvcSiteMapHtmlHelper instance</param> /// <param name="templateName">Name of the template.</param> /// <param name="startingNode">The starting node (the "current node" for the desired view).</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>Next node for the current request</returns> public static MvcHtmlString Next(this MvcSiteMapHtmlHelper helper, string templateName, ISiteMapNode startingNode, SourceMetadataDictionary sourceMetadata) { return(Next(helper, "Next", templateName, startingNode, sourceMetadata)); }
/// <summary> /// Builds the model. /// </summary> /// <param name="helper">The helper.</param> /// <param name="startingNode">The starting node.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>The model.</returns> private static SiteMapPathHelperModel BuildModel(MvcSiteMapHtmlHelper helper, SourceMetadataDictionary sourceMetadata, ISiteMapNode startingNode) { // Build model var model = new SiteMapPathHelperModel(); var node = startingNode; while (node != null) { bool nodeVisible = node.IsVisible(sourceMetadata); if (nodeVisible && node.IsAccessibleToUser()) { var nodeToAdd = new SiteMapNodeModel(node, sourceMetadata); model.Nodes.Add(nodeToAdd); } node = node.ParentNode; } model.Nodes.Reverse(); return(model); }
/// <summary> /// Builds the model. /// </summary> /// <param name="helper">The helper.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <param name="startingNode">The starting node.</param> /// <param name="startingNodeInChildLevel">Renders startingNode in child level if set to <c>true</c>.</param> /// <returns>The model.</returns> private static SiteMapHelperModel BuildModel(MvcSiteMapHtmlHelper helper, SourceMetadataDictionary sourceMetadata, ISiteMapNode startingNode, bool startingNodeInChildLevel) { // Build model var model = new SiteMapHelperModel(); var node = startingNode; // Check visibility and ACL if (node != null && node.IsVisible(sourceMetadata) && node.IsAccessibleToUser()) { // Add node var nodeToAdd = new SiteMapNodeModel(node, sourceMetadata); model.Nodes.Add(nodeToAdd); // Add child nodes if (startingNodeInChildLevel) { model.Nodes.AddRange(nodeToAdd.Descendants); } } return model; }
/// <summary> /// Builds the model. /// </summary> /// <param name="helper">The helper.</param> /// <param name="text">The text to display for the node.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <param name="startingNode">The starting node.</param> /// <returns>The model.</returns> private static DocumentNavigationModel BuildModel(MvcSiteMapHtmlHelper helper, string text, SourceMetadataDictionary sourceMetadata, ISiteMapNode startingNode) { ISiteMapNode nextNode = GetNextNode(startingNode, sourceMetadata); var model = new DocumentNavigationModel(nextNode, text); return(model); }
/// <summary> /// Builds the model. /// </summary> /// <param name="helper">The helper.</param> /// <param name="startingNode">The starting node.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>The model.</returns> private static SiteMapPathHelperModel BuildModel(MvcSiteMapHtmlHelper helper, SourceMetadataDictionary sourceMetadata, SiteMapNode startingNode) { // Build model var model = new SiteMapPathHelperModel(); var node = startingNode; while (node != null) { bool nodeVisible = node.IsVisible(sourceMetadata); if (nodeVisible && node.IsAccessibleToUser()) { var nodeToAdd = new SiteMapNodeModel(helper.SiteMap, node, sourceMetadata); model.Nodes.Add(nodeToAdd); } node = node.GetParentNode(helper.SiteMap); } model.Nodes.Reverse(); return model; }
/// <summary> /// Build a menu, based on the MvcSiteMap /// </summary> /// <param name="helper">The helper.</param> /// <param name="templateName">Name of the template.</param> /// <param name="startingNodeLevel">The starting node level.</param> /// <param name="startingNodeInChildLevel">Show starting node in child level if set to <c>true</c>.</param> /// <param name="showStartingNode">Show starting node if set to <c>true</c>.</param> /// <param name="maxDepth">The max depth.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>Html markup</returns> public static MvcHtmlString Menu(this MvcSiteMapHtmlHelper helper, string templateName, int startingNodeLevel, bool startingNodeInChildLevel, bool showStartingNode, int maxDepth, SourceMetadataDictionary sourceMetadata) { return Menu(helper, templateName, startingNodeLevel, startingNodeInChildLevel, showStartingNode, maxDepth, false, false, sourceMetadata); }
/// <summary> /// Build a menu, based on the MvcSiteMap /// </summary> /// <param name="helper">The helper.</param> /// <param name="startingNodeLevel">The starting node level.</param> /// <param name="maxDepth">The max depth.</param> /// <param name="allowForwardSearch">if set to <c>true</c> allow forward search. Forward search will search all parent nodes and child nodes, where in other circumstances only parent nodes are searched.</param> /// <param name="drillDownToCurrent">Should the model exceed the maxDepth to reach the current node?</param> /// <param name="visibilityAffectsDescendants"><b>true</b> if the visibility provider should affect the current node as well as all descendant nodes; otherwise <b>false</b>.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>Html markup</returns> public static MvcHtmlString Menu(this MvcSiteMapHtmlHelper helper, int startingNodeLevel, int maxDepth, bool allowForwardSearch, bool drillDownToCurrent, bool visibilityAffectsDescendants, SourceMetadataDictionary sourceMetadata) { ISiteMapNode startingNode = GetStartingNode(GetCurrentNode(helper.SiteMap), startingNodeLevel, allowForwardSearch); if (startingNode == null) { return MvcHtmlString.Empty; } return Menu(helper, null, startingNode, true, false, maxDepth, drillDownToCurrent, visibilityAffectsDescendants, sourceMetadata); }
/// <summary> /// Gets SiteMap path for the current request /// </summary> /// <param name="helper">MvcSiteMapHtmlHelper instance</param> /// <param name="templateName">Name of the template.</param> /// <param name="startingNodeKey">The key of the starting node (the last node in the site map path).</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>SiteMap path for the current request</returns> public static MvcHtmlString SiteMapPath(this MvcSiteMapHtmlHelper helper, string templateName, string startingNodeKey, SourceMetadataDictionary sourceMetadata) { SiteMapNode startingNode = startingNode = helper.SiteMap.CurrentNode; return SiteMapPath(helper, templateName, startingNode, sourceMetadata); }
/// <summary> /// Build a menu, based on the MvcSiteMap /// </summary> /// <param name="helper">The helper.</param> /// <param name="startFromCurrentNode">Start from current node if set to <c>true</c>.</param> /// <param name="startingNodeInChildLevel">Show starting node in child level if set to <c>true</c>.</param> /// <param name="showStartingNode">Show starting node if set to <c>true</c>.</param> /// <param name="visibilityAffectsDescendants"><b>true</b> if the visibility provider should affect the current node as well as all descendant nodes; otherwise <b>false</b>.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>Html markup</returns> public static MvcHtmlString Menu(this MvcSiteMapHtmlHelper helper, bool startFromCurrentNode, bool startingNodeInChildLevel, bool showStartingNode, bool visibilityAffectsDescendants, SourceMetadataDictionary sourceMetadata) { ISiteMapNode startingNode = startFromCurrentNode ? GetCurrentNode(helper.SiteMap) : helper.SiteMap.RootNode; return Menu(helper, null, startingNode, startingNodeInChildLevel, showStartingNode, Int32.MaxValue, false, visibilityAffectsDescendants, sourceMetadata); }
/// <summary> /// Build a menu, based on the MvcSiteMap /// </summary> /// <param name="helper">The helper.</param> /// <param name="templateName">Name of the template.</param> /// <param name="startingNode">The starting node.</param> /// <param name="startingNodeInChildLevel">Show starting node in child level if set to <c>true</c>.</param> /// <param name="showStartingNode">Show starting node if set to <c>true</c>.</param> /// <param name="maxDepth">The max depth.</param> /// <param name="drillDownToCurrent">Should the model exceed the maxDepth to reach the current node</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>Html markup</returns> public static MvcHtmlString Menu(this MvcSiteMapHtmlHelper helper, string templateName, ISiteMapNode startingNode, bool startingNodeInChildLevel, bool showStartingNode, int maxDepth, bool drillDownToCurrent, SourceMetadataDictionary sourceMetadata) { return Menu(helper, templateName, startingNode, startingNodeInChildLevel, showStartingNode, maxDepth, drillDownToCurrent, helper.SiteMap.VisibilityAffectsDescendants, sourceMetadata); }
/// <summary> /// Gets the CanonicalUrl of SiteMap.CurrentNode /// </summary> /// <param name="helper">MvcSiteMapHtmlHelper instance</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>The CanonicalUrl of the CurrentNode or the RootNode (if CurrentNode is null)</returns> public static MvcHtmlString CanonicalTag(this MvcSiteMapHtmlHelper helper, SourceMetadataDictionary sourceMetadata) { return(CanonicalTag(helper, null, sourceMetadata)); }
/// <summary> /// Build a menu, based on the MvcSiteMap /// </summary> /// <param name="helper">The helper.</param> /// <param name="templateName">Name of the template.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>Html markup</returns> public static MvcHtmlString Menu(this MvcSiteMapHtmlHelper helper, string templateName, SourceMetadataDictionary sourceMetadata) { return Menu(helper, templateName, helper.SiteMap.RootNode, true, true, Int32.MaxValue, false, sourceMetadata); }
/// <summary> /// Gets SiteMap path for the current request /// </summary> /// <param name="helper">MvcSiteMapHtmlHelper instance</param> /// <param name="templateName">Name of the template.</param> /// <returns>SiteMap path for the current request</returns> public static MvcHtmlString SiteMapPath(this MvcSiteMapHtmlHelper helper, string templateName, SourceMetadataDictionary sourceMetadata) { return SiteMapPath(helper, templateName, string.Empty, sourceMetadata); }
/// <summary> /// Build a menu, based on the MvcSiteMap /// </summary> /// <param name="helper">The helper.</param> /// <param name="templateName">Name of the template.</param> /// <param name="startFromCurrentNode">Start from current node if set to <c>true</c>.</param> /// <param name="startingNodeInChildLevel">Show starting node in child level if set to <c>true</c>.</param> /// <param name="showStartingNode">Show starting node if set to <c>true</c>.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>Html markup</returns> public static MvcHtmlString Menu(this MvcSiteMapHtmlHelper helper, string templateName, bool startFromCurrentNode, bool startingNodeInChildLevel, bool showStartingNode, SourceMetadataDictionary sourceMetadata) { ISiteMapNode startingNode = startFromCurrentNode ? GetCurrentNode(helper.SiteMap) : helper.SiteMap.RootNode; return Menu(helper, templateName, startingNode, startingNodeInChildLevel, showStartingNode, Int32.MaxValue, false, sourceMetadata); }
/// <summary> /// Build a sitemap tree, based on the MvcSiteMap /// </summary> /// <param name="helper">The helper.</param> /// <param name="startingNode">The starting node.</param> /// <param name="rootInChildLevel">Renders startingNode in child level if set to <c>true</c>.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>Html markup</returns> public static MvcHtmlString SiteMap(this MvcSiteMapHtmlHelper helper, ISiteMapNode startingNode, bool rootInChildLevel, SourceMetadataDictionary sourceMetadata) { return(SiteMap(helper, null, startingNode, rootInChildLevel, sourceMetadata)); }
/// <summary> /// Build a sitemap tree, based on the MvcSiteMap /// </summary> /// <param name="helper">The helper.</param> /// <param name="templateName">Name of the template.</param> /// <param name="rootInChildLevel">Renders startingNode in child level if set to <c>true</c>.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>Html markup</returns> public static MvcHtmlString SiteMap(this MvcSiteMapHtmlHelper helper, string templateName, bool rootInChildLevel, SourceMetadataDictionary sourceMetadata) { return SiteMap(helper, templateName, helper.SiteMap.RootNode, rootInChildLevel, sourceMetadata); }
/// <summary> /// Build a sitemap tree, based on the MvcSiteMap /// </summary> /// <param name="helper">The helper.</param> /// <param name="templateName">Name of the template.</param> /// <param name="rootInChildLevel">Renders startingNode in child level if set to <c>true</c>.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>Html markup</returns> public static MvcHtmlString SiteMap(this MvcSiteMapHtmlHelper helper, string templateName, bool rootInChildLevel, SourceMetadataDictionary sourceMetadata) { return(SiteMap(helper, templateName, helper.SiteMap.RootNode, rootInChildLevel, sourceMetadata)); }
/// <summary> /// Build a sitemap tree, based on the MvcSiteMap /// </summary> /// <param name="helper">The helper.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>Html markup</returns> public static MvcHtmlString SiteMap(this MvcSiteMapHtmlHelper helper, SourceMetadataDictionary sourceMetadata) { return SiteMap(helper, helper.SiteMap.RootNode, sourceMetadata); }
/// <summary> /// Build a sitemap tree, based on the MvcSiteMap /// </summary> /// <param name="helper">The helper.</param> /// <param name="templateName">Name of the template.</param> /// <param name="startingNode">The starting node.</param> /// <param name="rootInChildLevel">Renders startingNode in child level if set to <c>true</c>.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>Html markup</returns> public static MvcHtmlString SiteMap(this MvcSiteMapHtmlHelper helper, string templateName, ISiteMapNode startingNode, bool rootInChildLevel, SourceMetadataDictionary sourceMetadata) { return(SiteMap(helper, templateName, startingNode, rootInChildLevel, helper.SiteMap.VisibilityAffectsDescendants, sourceMetadata)); }
/// <summary> /// Gets the title of SiteMap.CurrentNode /// </summary> /// <param name="helper">MvcSiteMapHtmlHelper instance</param> /// <param name="templateName">Name of the template.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>The title of the CurrentNode or the RootNode (if CurrentNode is null)</returns> public static MvcHtmlString SiteMapTitle(this MvcSiteMapHtmlHelper helper, string templateName, SourceMetadataDictionary sourceMetadata) { var model = BuildModel(GetSourceMetadata(sourceMetadata), helper.SiteMap.CurrentNode ?? helper.SiteMap.RootNode); return(helper .CreateHtmlHelperForModel(model) .DisplayFor(m => model, templateName)); }
/// <summary> /// Build a sitemap tree, based on the MvcSiteMap /// </summary> /// <param name="helper">The helper.</param> /// <param name="templateName">Name of the template.</param> /// <param name="startingNode">The starting node.</param> /// <param name="rootInChildLevel">Renders startingNode in child level if set to <c>true</c>.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>Html markup</returns> public static MvcHtmlString SiteMap(this MvcSiteMapHtmlHelper helper, string templateName, ISiteMapNode startingNode, bool rootInChildLevel, bool visibilityAffectsDescendants, SourceMetadataDictionary sourceMetadata) { var model = BuildModel(helper, GetSourceMetadata(sourceMetadata), startingNode, rootInChildLevel, visibilityAffectsDescendants); return(helper .CreateHtmlHelperForModel(model) .DisplayFor(m => model, templateName)); }
/// <summary> /// Gets SiteMap path for the current request /// </summary> /// <param name="helper">MvcSiteMapHtmlHelper instance</param> /// <param name="templateName">Name of the template.</param> /// <param name="startingNodeKey">The key of the starting node (the last node in the site map path).</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>SiteMap path for the current request</returns> public static MvcHtmlString SiteMapPath(this MvcSiteMapHtmlHelper helper, string templateName, ISiteMapNode startingNode, SourceMetadataDictionary sourceMetadata) { var model = BuildModel(helper, GetSourceMetadata(sourceMetadata), startingNode); return(helper .CreateHtmlHelperForModel(model) .DisplayFor(m => model, templateName)); }
/// <summary> /// Builds the model. /// </summary> /// <param name="helper">The helper.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <param name="startingNode">The starting node.</param> /// <param name="startingNodeInChildLevel">Renders startingNode in child level if set to <c>true</c>.</param> /// <param name="showStartingNode">Show starting node if set to <c>true</c>.</param> /// <param name="maxDepth">The max depth.</param> /// <returns>The model.</returns> private static MenuHelperModel BuildModel(MvcSiteMapHtmlHelper helper, SourceMetadataDictionary sourceMetadata, ISiteMapNode startingNode, bool startingNodeInChildLevel, bool showStartingNode, int maxDepth) { return BuildModel(helper, sourceMetadata, startingNode, startingNodeInChildLevel, showStartingNode, maxDepth, false); }
/// <summary> /// Gets SiteMap path for the current request /// </summary> /// <param name="helper">MvcSiteMapHtmlHelper instance</param> /// <param name="templateName">Name of the template.</param> /// <returns>SiteMap path for the current request</returns> public static MvcHtmlString SiteMapPath(this MvcSiteMapHtmlHelper helper, string templateName, SourceMetadataDictionary sourceMetadata) { return(SiteMapPath(helper, templateName, string.Empty, sourceMetadata)); }
/// <summary> /// Build a menu, based on the MvcSiteMap /// </summary> /// <param name="helper">The helper.</param> /// <param name="startingNodeLevel">The starting node level.</param> /// <param name="maxDepth">The max depth.</param> /// <param name="allowForwardSearch">if set to <c>true</c> allow forward search. Forward search will search all parent nodes and child nodes, where in other circumstances only parent nodes are searched.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>Html markup</returns> public static MvcHtmlString Menu(this MvcSiteMapHtmlHelper helper, int startingNodeLevel, int maxDepth, bool allowForwardSearch, SourceMetadataDictionary sourceMetadata) { return Menu(helper, startingNodeLevel, maxDepth, allowForwardSearch, false, sourceMetadata); }
/// <summary> /// Builds the model. /// </summary> /// <param name="helper">The helper.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <param name="startingNode">The starting node.</param> /// <param name="startingNodeInChildLevel">Renders startingNode in child level if set to <c>true</c>.</param> /// <param name="showStartingNode">Show starting node if set to <c>true</c>.</param> /// <param name="maxDepth">The max depth.</param> /// <param name="drillDownToCurrent">Should the model exceed the maxDepth to reach the current node</param> /// <returns>The model.</returns> private static MenuHelperModel BuildModel(MvcSiteMapHtmlHelper helper, SourceMetadataDictionary sourceMetadata, ISiteMapNode startingNode, bool startingNodeInChildLevel, bool showStartingNode, int maxDepth, bool drillDownToCurrent) { // Build model var model = new MenuHelperModel(); var node = startingNode; // Check if a starting node has been given if (node == null) { return model; } // Check ACL if (node.IsAccessibleToUser()) { // Add node? var nodeToAdd = new SiteMapNodeModel(node, sourceMetadata, maxDepth, drillDownToCurrent, startingNodeInChildLevel); // Check visibility if (node.IsVisible(sourceMetadata)) { if (showStartingNode || !startingNodeInChildLevel) { model.Nodes.Add(nodeToAdd); } // Add child nodes if (startingNodeInChildLevel) { model.Nodes.AddRange(nodeToAdd.Children); } } } return model; }
/// <summary> /// Builds the model. /// </summary> /// <param name="helper">The helper.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <param name="startingNode">The starting node.</param> /// <param name="startingNodeInChildLevel">Renders startingNode in child level if set to <c>true</c>.</param> /// <returns>The model.</returns> internal static SiteMapHelperModel BuildModel(MvcSiteMapHtmlHelper helper, SourceMetadataDictionary sourceMetadata, ISiteMapNode startingNode, bool startingNodeInChildLevel, bool visibilityAffectsDescendants) { // Build model var model = new SiteMapHelperModel(); var node = startingNode; // Check if a starting node has been given if (node == null) { return model; } // Check ACL if (node.IsAccessibleToUser()) { // Add node? var nodeToAdd = new SiteMapNodeModel(node, sourceMetadata, Int32.MaxValue, false, startingNodeInChildLevel, visibilityAffectsDescendants); // Check visibility if (node.IsVisible(sourceMetadata)) { model.Nodes.Add(nodeToAdd); // Add child nodes if (visibilityAffectsDescendants && startingNodeInChildLevel) { model.Nodes.AddRange(nodeToAdd.Children); } } // Add child nodes if (!visibilityAffectsDescendants && startingNodeInChildLevel) { model.Nodes.AddRange(nodeToAdd.Children); } } return model; }
/// <summary> /// Build a menu, based on the MvcSiteMap /// </summary> /// <param name="helper">The helper.</param> /// <param name="showStartingNode">Show starting node if set to <c>true</c>.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>Html markup</returns> public static MvcHtmlString Menu(this MvcSiteMapHtmlHelper helper, bool showStartingNode, SourceMetadataDictionary sourceMetadata) { return Menu(helper, helper.SiteMap.RootNode, true, showStartingNode, Int32.MaxValue, false, sourceMetadata); }
/// <summary> /// Build a sitemap tree, based on the MvcSiteMap /// </summary> /// <param name="helper">The helper.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>Html markup</returns> public static MvcHtmlString SiteMap(this MvcSiteMapHtmlHelper helper, SourceMetadataDictionary sourceMetadata) { return(SiteMap(helper, helper.SiteMap.RootNode, sourceMetadata)); }
/// <summary> /// Build a menu, based on the MvcSiteMap /// </summary> /// <param name="helper">The helper.</param> /// <param name="startingNode">The starting node.</param> /// <param name="startingNodeInChildLevel">Show starting node in child level if set to <c>true</c>.</param> /// <param name="showStartingNode">Show starting node if set to <c>true</c>.</param> /// <param name="maxDepth">The max depth.</param> /// <param name="drillDownToContent">if set to <c>true</c> [drill down to content].</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>Html markup</returns> public static MvcHtmlString Menu(this MvcSiteMapHtmlHelper helper, ISiteMapNode startingNode, bool startingNodeInChildLevel, bool showStartingNode, int maxDepth, bool drillDownToContent, SourceMetadataDictionary sourceMetadata) { return Menu(helper, null, startingNode, startingNodeInChildLevel, showStartingNode, maxDepth, drillDownToContent, sourceMetadata); }
/// <summary> /// Build a sitemap tree, based on the MvcSiteMap /// </summary> /// <param name="helper">The helper.</param> /// <param name="startingNode">The starting node.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>Html markup</returns> public static MvcHtmlString SiteMap(this MvcSiteMapHtmlHelper helper, ISiteMapNode startingNode, SourceMetadataDictionary sourceMetadata) { return(SiteMap(helper, startingNode, false, sourceMetadata)); }
/// <summary> /// Build a menu, based on the MvcSiteMap /// </summary> /// <param name="helper">The helper.</param> /// <param name="templateName">Name of the template.</param> /// <param name="startingNode">The starting node.</param> /// <param name="startingNodeInChildLevel">Show starting node in child level if set to <c>true</c>.</param> /// <param name="showStartingNode">Show starting node if set to <c>true</c>.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>Html markup</returns> public static MvcHtmlString Menu(this MvcSiteMapHtmlHelper helper, string templateName, ISiteMapNode startingNode, bool startingNodeInChildLevel, bool showStartingNode, SourceMetadataDictionary sourceMetadata) { return Menu(helper, templateName, startingNode, startingNodeInChildLevel, showStartingNode, Int32.MaxValue, false, sourceMetadata); }
/// <summary> /// Builds the model. /// </summary> /// <param name="helper">The helper.</param> /// <param name="startingNode">The starting node.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>The model.</returns> private static SiteMapPathHelperModel BuildModel(MvcSiteMapHtmlHelper helper, SourceMetadataDictionary sourceMetadata, ISiteMapNode startingNode) { // Build model var model = new SiteMapPathHelperModel(); var node = startingNode; // Check visibility and ACL if (node != null && node.IsVisible(sourceMetadata) && node.IsAccessibleToUser()) { // Add node model.Nodes.AddRange((new SiteMapNodeModel(node, sourceMetadata)).Ancestors); } return(model); }
/// <summary> /// Build a menu, based on the MvcSiteMap /// </summary> /// <param name="helper">The helper.</param> /// <param name="templateName">Name of the template.</param> /// <param name="startingNodeLevel">The starting node level.</param> /// <param name="startingNodeInChildLevel">Show starting node in child level if set to <c>true</c>.</param> /// <param name="showStartingNode">Show starting node if set to <c>true</c>.</param> /// <param name="maxDepth">The max depth.</param> /// <param name="allowForwardSearch">if set to <c>true</c> allow forward search. Forward search will search all parent nodes and child nodes, where in other circumstances only parent nodes are searched.</param> /// <param name="drillDownToCurrent">Should the model exceed the maxDepth to reach the current node</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>Html markup</returns> public static MvcHtmlString Menu(this MvcSiteMapHtmlHelper helper, string templateName, int startingNodeLevel, bool startingNodeInChildLevel, bool showStartingNode, int maxDepth, bool allowForwardSearch, bool drillDownToCurrent, SourceMetadataDictionary sourceMetadata) { ISiteMapNode startingNode = GetStartingNode(GetCurrentNode(helper.SiteMap), startingNodeLevel, allowForwardSearch); if (startingNode == null) { return MvcHtmlString.Empty; } return Menu(helper, templateName, startingNode, startingNodeInChildLevel, showStartingNode, maxDepth, drillDownToCurrent, sourceMetadata); }
/// <summary> /// Gets the content attribute value of the meta robots tag for the SiteMap.CurrentNode /// </summary> /// <param name="helper">MvcSiteMapHtmlHelper instance</param> /// <returns> /// The content attribute value for the meta robots tag of the CurrentNode or the RootNode (if CurrentNode is null) /// </returns> public static MvcHtmlString MetaRobotsTag(this MvcSiteMapHtmlHelper helper, SourceMetadataDictionary sourceMetadata) { return MetaRobotsTag(helper, null, sourceMetadata); }
/// <summary> /// Build a sitemap tree, based on the MvcSiteMap /// </summary> /// <param name="helper">The helper.</param> /// <param name="startingNode">The starting node.</param> /// <param name="rootInChildLevel">Renders startingNode in child level if set to <c>true</c>.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>Html markup</returns> public static MvcHtmlString SiteMap(this MvcSiteMapHtmlHelper helper, ISiteMapNode startingNode, bool rootInChildLevel, SourceMetadataDictionary sourceMetadata) { return SiteMap(helper, null, startingNode, rootInChildLevel, sourceMetadata); }
/// <summary> /// Gets SiteMap path for the current request /// </summary> /// <param name="helper">MvcSiteMapHtmlHelper instance</param> /// <param name="templateName">Name of the template.</param> /// <param name="startingNodeKey">The key of the starting node (the last node in the site map path).</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>SiteMap path for the current request</returns> public static MvcHtmlString SiteMapPath(this MvcSiteMapHtmlHelper helper, string templateName, string startingNodeKey, SourceMetadataDictionary sourceMetadata) { SiteMapNode startingNode = startingNode = helper.SiteMap.CurrentNode; return(SiteMapPath(helper, templateName, startingNode, sourceMetadata)); }
/// <summary> /// Build a sitemap tree, based on the MvcSiteMap /// </summary> /// <param name="helper">The helper.</param> /// <param name="templateName">Name of the template.</param> /// <param name="startingNode">The starting node.</param> /// <param name="rootInChildLevel">Renders startingNode in child level if set to <c>true</c>.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>Html markup</returns> public static MvcHtmlString SiteMap(this MvcSiteMapHtmlHelper helper, string templateName, ISiteMapNode startingNode, bool rootInChildLevel, SourceMetadataDictionary sourceMetadata) { var model = BuildModel(helper, GetSourceMetadata(sourceMetadata), startingNode, rootInChildLevel); return helper .CreateHtmlHelperForModel(model) .DisplayFor(m => model, templateName); }
/// <summary> /// Gets the title of SiteMap.CurrentNode /// </summary> /// <param name="helper">MvcSiteMapHtmlHelper instance</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>The title of the CurrentNode or the RootNode (if CurrentNode is null)</returns> public static MvcHtmlString SiteMapTitle(this MvcSiteMapHtmlHelper helper, SourceMetadataDictionary sourceMetadata) { return SiteMapTitle(helper, null, sourceMetadata); }
/// <summary> /// Gets the source meta data for the current context. /// </summary> /// <param name="sourceMetadata">User-defined metadata.</param> /// <returns>SourceMetadataDictionary for the current request.</returns> private static SourceMetadataDictionary GetSourceMetadata(IDictionary<string, object> sourceMetadata) { var result = new SourceMetadataDictionary(sourceMetadata); result.Add("HtmlHelper", typeof(SiteMapHelper).FullName); return result; }
/// <summary> /// Gets previous node in the document outline for the current request /// </summary> /// <param name="helper">MvcSiteMapHtmlHelper instance</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>SiteMap path for the current request</returns> public static MvcHtmlString Previous(this MvcSiteMapHtmlHelper helper, SourceMetadataDictionary sourceMetadata) { return(Previous(helper, null, sourceMetadata)); }
/// <summary> /// Build a sitemap tree, based on the MvcSiteMap /// </summary> /// <param name="helper">The helper.</param> /// <param name="startingNode">The starting node.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>Html markup</returns> public static MvcHtmlString SiteMap(this MvcSiteMapHtmlHelper helper, ISiteMapNode startingNode, SourceMetadataDictionary sourceMetadata) { return SiteMap(helper, startingNode, false, sourceMetadata); }
/// <summary> /// Builds the model. /// </summary> /// <param name="startingNode">The starting node.</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>The model.</returns> private static SiteMapTitleHelperModel BuildModel(SourceMetadataDictionary sourceMetadata, ISiteMapNode startingNode) { // Map to model return new SiteMapTitleHelperModel { CurrentNode = new SiteMapNodeModel(startingNode, sourceMetadata) }; }
/// <summary> /// Gets the title of SiteMap.CurrentNode /// </summary> /// <param name="helper">MvcSiteMapHtmlHelper instance</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>The title of the CurrentNode or the RootNode (if CurrentNode is null)</returns> public static MvcHtmlString SiteMapTitle(this MvcSiteMapHtmlHelper helper, SourceMetadataDictionary sourceMetadata) { return(SiteMapTitle(helper, null, sourceMetadata)); }
/// <summary> /// Gets SiteMap path for the current request /// </summary> /// <param name="helper">MvcSiteMapHtmlHelper instance</param> /// <param name="templateName">Name of the template.</param> /// <param name="startingNodeKey">The key of the starting node (the last node in the site map path).</param> /// <param name="sourceMetadata">User-defined meta data.</param> /// <returns>SiteMap path for the current request</returns> public static MvcHtmlString SiteMapPath(this MvcSiteMapHtmlHelper helper, string templateName, string startingNodeKey, SourceMetadataDictionary sourceMetadata) { ISiteMapNode startingNode; if (string.IsNullOrEmpty(startingNodeKey)) { startingNode = helper.SiteMap.CurrentNode; } else { startingNode = helper.SiteMap.FindSiteMapNodeFromKey(startingNodeKey); } return(SiteMapPath(helper, templateName, startingNode, sourceMetadata)); }
/// <summary> /// Gets previous node in the document outline for the current request /// </summary> /// <param name="helper">MvcSiteMapHtmlHelper instance</param> /// <param name="text">The text to display for the node.</param> /// <param name="templateName">Name of the template.</param> /// <returns>SiteMap path for the current request</returns> public static MvcHtmlString Previous(this MvcSiteMapHtmlHelper helper, string text, string templateName, SourceMetadataDictionary sourceMetadata) { return(Previous(helper, text, templateName, string.Empty, sourceMetadata)); }
/// <summary> /// Gets the content attribute value of the meta robots tag for the SiteMap.CurrentNode /// </summary> /// <param name="helper">MvcSiteMapHtmlHelper instance</param> /// <returns> /// The content attribute value for the meta robots tag of the CurrentNode or the RootNode (if CurrentNode is null) /// </returns> public static MvcHtmlString MetaRobotsTag(this MvcSiteMapHtmlHelper helper, SourceMetadataDictionary sourceMetadata) { return(MetaRobotsTag(helper, null, sourceMetadata)); }