Esempio n. 1
0
        internal static IHtmlString SnippetInternal(this HtmlHelper html, string snippetName, string editType = "html", bool htmlEncode = false, string tagName = "div", string cssClass = null, bool liquidEnabled = LiquidExtensions.LiquidEnabledDefault, Context liquidContext = null, string defaultValue = null, bool allowCreate = AllowCreateDefault, string displayName = null)
        {
            var snippet = PortalExtensions.GetPortalViewContext(html).Snippets.Select(snippetName);

            if (snippet != null)
            {
                return(SnippetInternal(html, snippet, editType, htmlEncode, tagName, cssClass, liquidEnabled, liquidContext, defaultValue));
            }

            if (allowCreate)
            {
                return(SnippetPlaceHolder(html, snippetName, editType, htmlEncode, tagName, cssClass, liquidEnabled, liquidContext, defaultValue, displayName));
            }

            if (defaultValue == null)
            {
                return(null);
            }

            if (liquidEnabled)
            {
                return(new HtmlString(liquidContext == null
                                        ? html.Liquid(defaultValue)
                                        : html.Liquid(defaultValue, liquidContext)));
            }

            return(new HtmlString(defaultValue));
        }
        public static IEnumerable <SiteMapNode> SiteMapChildNodes(this HtmlHelper html, string url)
        {
            if (url == null)
            {
                return(Enumerable.Empty <SiteMapNode>());
            }

            var portalViewContext = PortalExtensions.GetPortalViewContext(html);
            var siteMapProvider   = portalViewContext.SiteMapProvider;

            if (siteMapProvider == null)
            {
                return(Enumerable.Empty <SiteMapNode>());
            }

            var target = siteMapProvider.FindSiteMapNode(url);

            if (target == null)
            {
                return(Enumerable.Empty <SiteMapNode>());
            }

            var entityTarget = target as CrmSiteMapNode;

            if (entityTarget != null && entityTarget.StatusCode != HttpStatusCode.OK)
            {
                return(Enumerable.Empty <SiteMapNode>());
            }

            return(target.ChildNodes.Cast <SiteMapNode>());
        }
        public static IEnumerable <SiteMapNode> SiteMapChildNodes(this HtmlHelper html)
        {
            var portalViewContext = PortalExtensions.GetPortalViewContext(html);
            var siteMapProvider   = portalViewContext.SiteMapProvider;

            if (siteMapProvider == null)
            {
                return(Enumerable.Empty <SiteMapNode>());
            }

            var current = siteMapProvider.CurrentNode;

            if (current == null)
            {
                return(Enumerable.Empty <SiteMapNode>());
            }

            var entityCurrent = current as CrmSiteMapNode;

            if (entityCurrent != null && entityCurrent.StatusCode != HttpStatusCode.OK)
            {
                return(Enumerable.Empty <SiteMapNode>());
            }

            return(current.ChildNodes.Cast <SiteMapNode>());
        }
        public static bool IsRootSiteMapNode(this HtmlHelper html, string url)
        {
            var portalViewContext = PortalExtensions.GetPortalViewContext(html);
            var siteMapProvider   = portalViewContext.SiteMapProvider;

            if (siteMapProvider == null)
            {
                return(false);
            }

            var current = siteMapProvider.CurrentNode;

            if (current == null)
            {
                return(false);
            }

            var root = siteMapProvider.RootNode;

            if (root == null)
            {
                return(false);
            }

            return(root.Url == url);
        }
        /// <summary>
        /// Gets the target of a given Site Marker (adx_sitemarker), by site marker name.
        /// </summary>
        /// <param name="html">Extension method target, provides support for HTML rendering and access to view context/data.</param>
        /// <param name="siteMarkerName">The name of the site marker to retrieve.</param>
        /// <param name="requireTargetReadAccess">
        /// Whether the target of the named site marker should be tested for security read access. This is false by default, but if
        /// set to true, and the current user does not have read access to the target entity, this method will return null.
        /// </param>
        /// <returns>
        /// The <see cref="ISiteMarkerTarget">target</see> of the given site marker. If <paramref name="requireTargetReadAccess"/> is set
        /// to true, and the current user does not have read access to the target entity, returns null.
        /// </returns>
        public static ISiteMarkerTarget SiteMarker(this HtmlHelper html, string siteMarkerName, bool requireTargetReadAccess = false)
        {
            var siteMarkers = PortalExtensions.GetPortalViewContext(html).SiteMarkers;

            return(requireTargetReadAccess
                                ? siteMarkers.SelectWithReadAccess(siteMarkerName)
                                : siteMarkers.Select(siteMarkerName));
        }
        /// <summary>
        /// Gets the value of a Site Setting (adx_sitesetting), by name.
        /// </summary>
        /// <param name="html">Extension method target, provides support for HTML rendering and access to view context/data.</param>
        /// <param name="settingName">The name (adx_name) of the setting to retrieve.</param>
        /// <param name="defaultValue">An optional default value to be returned if the setting does not exist or has no value.</param>
        /// <returns>
        /// The value of the Site Setting specified by <paramref name="settingName"/>. If the setting is not found, and no
        /// <paramref name="defaultValue"/> is specified, returns an empty string.
        /// </returns>
        public static string Setting(this HtmlHelper html, string settingName, string defaultValue = null)
        {
            var setting = PortalExtensions.GetPortalViewContext(html).Settings.Select(settingName);

            return(setting == null
                                ? defaultValue ?? string.Empty
                                : Setting(html, setting, defaultValue));
        }
        public static IEnumerable <SiteMapNode> CurrentWebLinkChildNodes(this HtmlHelper html, string webLinkSetName, IEnumerable <string> entityLogicalNamesToExclude = null)
        {
            var webLinkSet = PortalExtensions.GetPortalViewContext(html).WebLinks.Select(webLinkSetName);

            return(webLinkSet == null
                                ? Enumerable.Empty <SiteMapNode>()
                                : CurrentWebLinkChildNodes(html, webLinkSet, entityLogicalNamesToExclude));
        }
        public static string SiteMapState(this HtmlHelper html)
        {
            var portalViewContext = PortalExtensions.GetPortalViewContext(html);

            var current = portalViewContext.CurrentSiteMapNode;

            return(current == null
                                ? null
                                : string.Join(":", new [] { current.Url }.Concat(portalViewContext.CurrentSiteMapNodeAncestors.Select(e => e.Url))));
        }
Esempio n. 9
0
        /// <summary>
        /// Renders a a Snippet (adx_contentsnippet) value, with no encoding or other modification.
        /// </summary>
        /// <param name="html">Extension method target, provides support for HTML rendering and access to view context/data.</param>
        /// <param name="snippetName">The name (adx_name) of the Snippet (adx_contentsnippet) to be rendered.</param>
        /// <param name="defaultValue">An optional default value to be returned if the snippet does not exist or has no value.</param>
        /// <returns>
        /// A literal content snippet value, or <paramref name="defaultValue"/>, if the snippet is not found or has no value. If
        /// <paramref name="defaultValue"/> is also null, returns an empty string.
        /// </returns>
        public static string SnippetLiteral(this HtmlHelper html, string snippetName, string defaultValue = null, bool liquidEnabled = LiquidExtensions.LiquidEnabledDefault)
        {
            var snippet = PortalExtensions.GetPortalViewContext(html).Snippets.Select(snippetName);

            return(snippet == null
                                ? liquidEnabled && defaultValue != null
                                        ? html.Liquid(defaultValue)
                                        : defaultValue
                                : SnippetLiteral(html, snippet, defaultValue, liquidEnabled));
        }
        private static IHtmlString ContentStyles(HtmlHelper html, IEnumerable <string> except, IEnumerable <KeyValuePair <string, string> > only)
        {
            ADXTrace.Instance.TraceInfo(TraceCategory.Application, "Begin");

            var portalViewContext = PortalExtensions.GetPortalViewContext(html);

            var siteMapProvider = portalViewContext.SiteMapProvider as ContentMapCrmSiteMapProvider;

            var node = siteMapProvider == null
                                ? null
                                : siteMapProvider.CurrentNode ?? siteMapProvider.RootNode;

            if (siteMapProvider != null && (node == null || (((CrmSiteMapNode)node).StatusCode == System.Net.HttpStatusCode.Forbidden) && node.Equals(node.RootNode)))
            {
                // If home root node has been secured then we need to retrieve the root without security validation in order to get the content stylesheets to be referenced.
                node = siteMapProvider.FindSiteMapNodeWithoutSecurityValidation("/");
            }

            var hrefs = ContentStyles(portalViewContext, node, html.ViewContext.TempData, except, only)
                        .Distinct()
                        .ToArray();

            if (!hrefs.Any())
            {
                ADXTrace.Instance.TraceInfo(TraceCategory.Application, "End: No content styles found.");

                return(null);
            }

            var output = new StringBuilder();

            foreach (var href in hrefs)
            {
                var link = new TagBuilder("link");

                link.Attributes["rel"]  = "stylesheet";
                link.Attributes["href"] = href;

                output.AppendLine(link.ToString(TagRenderMode.SelfClosing));
            }

            ADXTrace.Instance.TraceInfo(TraceCategory.Application, "End");

            return(new HtmlString(output.ToString()));
        }
Esempio n. 11
0
        /// <summary>
        /// Renders a a Snippet (adx_contentsnippet) value, with no encoding or other modification.
        /// </summary>
        /// <param name="html">Extension method target, provides support for HTML rendering and access to view context/data.</param>
        /// <param name="snippetName">The name (adx_name) of the Snippet (adx_contentsnippet) to be rendered.</param>
        /// <param name="defaultValue">An optional default value to be returned if the snippet does not exist or has no value.</param>
        /// <returns>
        /// A literal content snippet value, or <paramref name="defaultValue"/>, if the snippet is not found or has no value. If
        /// <paramref name="defaultValue"/> is also null, returns an empty string.
        /// </returns>
        public static string SnippetLiteral(this HtmlHelper html, string snippetName, IHtmlString defaultValue, bool liquidEnabled = LiquidExtensions.LiquidEnabledDefault)
        {
            var snippet = PortalExtensions.GetPortalViewContext(html).Snippets.Select(snippetName);

            if (snippet != null)
            {
                return(SnippetLiteral(html, snippet, defaultValue == null ? null : defaultValue.ToString(), liquidEnabled));
            }

            if (defaultValue == null)
            {
                return(null);
            }

            return(liquidEnabled
                                ? html.Liquid(defaultValue)
                                : defaultValue.ToString());
        }
Esempio n. 12
0
        private static IEnumerable <Tuple <SiteMapNode, SiteMapNodeType> > SiteMapPath(HtmlHelper html, Func <SiteMapProvider, SiteMapNode> getCurrentNode, int?takeLast)
        {
            var portalViewContext = PortalExtensions.GetPortalViewContext(html);
            var siteMapProvider   = portalViewContext.SiteMapProvider;

            if (siteMapProvider == null)
            {
                return(Enumerable.Empty <Tuple <SiteMapNode, SiteMapNodeType> >());
            }

            var current = getCurrentNode(siteMapProvider);

            if (current == null)
            {
                return(Enumerable.Empty <Tuple <SiteMapNode, SiteMapNodeType> >());
            }

            var path = new Stack <Tuple <SiteMapNode, SiteMapNodeType> >();

            path.Push(new Tuple <SiteMapNode, SiteMapNodeType>(current, SiteMapNodeType.Current));

            current = current.ParentNode;

            while (current != null)
            {
                var parent = current.ParentNode;

                path.Push(new Tuple <SiteMapNode, SiteMapNodeType>(
                              current,
                              parent == null ? SiteMapNodeType.Root : SiteMapNodeType.Parent));

                current = parent;
            }

            var nodes = takeLast != null?path.Skip(Math.Max(0, path.Count() - takeLast.Value)) : path;

            return(nodes.ToList());
        }
Esempio n. 13
0
        public static bool IsFirstGenerationParentSiteMapNode(this HtmlHelper html, string url)
        {
            var portalViewContext = PortalExtensions.GetPortalViewContext(html);
            var siteMapProvider   = portalViewContext.SiteMapProvider;

            if (siteMapProvider == null)
            {
                return(false);
            }

            var node = siteMapProvider.FindSiteMapNode(url);

            if (node == null)
            {
                return(false);
            }

            if (node.ParentNode == null)
            {
                return(false);
            }

            return(node.RootNode.Key == node.ParentNode.Key);
        }
Esempio n. 14
0
 /// <summary>
 /// Renders hidden metadata to the HTML DOM to support client-side editing of a given portal entity, for users with
 /// permission.
 /// </summary>
 /// <param name="html">Extension method target, provides support for HTML rendering and access to view context/data.</param>
 /// <param name="entity">The entity whose metadata will be rendered.</param>
 /// <param name="cssClass">An optional class attribute value to be added to the root element rendered by this method.</param>
 /// <returns>Editing metadata, as HTML.</returns>
 public static IHtmlString EntityEditingMetadata(this HtmlHelper html, IPortalViewEntity entity, string cssClass = null)
 {
     return(EntityEditingMetadata(entity, PortalExtensions.GetPortalViewContext(html), cssClass));
 }
Esempio n. 15
0
        /// <summary>
        /// Renders a link to the current portal context entity.
        /// </summary>
        /// <param name="html">Extension method target, provides support for HTML rendering and access to view context/data.</param>
        /// <param name="linkText">The text of the link.</param>
        /// <param name="queryStringParameters">Query string parameter values that will be appended to the link URL.</param>
        /// <param name="htmlAttributes">HTML attributes that will be added to the link tag.</param>
        /// <returns>
        /// Returns an HTML A tag linking to the current portal context entity.
        /// </returns>
        public static IHtmlString EntityLink(this HtmlHelper html, string linkText, NameValueCollection queryStringParameters, IDictionary <string, object> htmlAttributes)
        {
            var portalViewContext = PortalExtensions.GetPortalViewContext(html);

            return(EntityLink(html, portalViewContext.Entity, linkText, queryStringParameters, htmlAttributes));
        }
Esempio n. 16
0
        /// <summary>
        /// Renders hidden metadata to the HTML DOM to support client-side editing of a given portal entity, for users with
        /// permission. Implicitly uses the current portal context entity as its source entity.
        /// </summary>
        /// <param name="html">Extension method target, provides support for HTML rendering and access to view context/data.</param>
        /// <param name="cssClass">An optional class attribute value to be added to the root element rendered by this method.</param>
        /// <returns>Editing metadata, as HTML.</returns>
        public static IHtmlString EntityEditingMetadata(this HtmlHelper html, string cssClass = null)
        {
            var portalViewContext = PortalExtensions.GetPortalViewContext(html);

            return(EntityEditingMetadata(portalViewContext.Entity, portalViewContext, cssClass));
        }
Esempio n. 17
0
 /// <summary>
 /// Return a URL for a given entity.
 /// </summary>
 /// <param name="html">Extension method target, provides support for HTML rendering and access to view context/data.</param>
 /// <param name="entity">The <see cref="IPortalViewEntity"/> whose URL will be returned.</param>
 /// <param name="queryStringParameters">Query string parameter values that will be appended to the link URL.</param>
 /// <returns>
 /// Returns a URL for the given entity. Returns a null if <paramref name="entity"/> is null, or <paramref name="entity"/> does not have
 /// a URL.
 /// </returns>
 public static string EntityUrl(this HtmlHelper html, IPortalViewEntity entity, object queryStringParameters)
 {
     return(EntityUrl(html, entity, PortalExtensions.AnonymousObjectToQueryStringParameters(queryStringParameters)));
 }
Esempio n. 18
0
        /// <summary>
        /// Return a URL for a given entity.
        /// </summary>
        /// <param name="html">Extension method target, provides support for HTML rendering and access to view context/data.</param>
        /// <param name="serviceContext">
        /// The <see cref="OrganizationServiceContext"/> to which <paramref name="entity"/> is attached, and which will be used to load
        /// any additional data required to render the attribute (e.g., performing security assertions).
        /// </param>
        /// <param name="entity">The <see cref="Microsoft.Xrm.Sdk.Entity"/> whose URL will be returned.</param>
        /// <param name="queryStringParameters">Query string parameter values that will be appended to the link URL.</param>
        /// <returns>
        /// Returns a URL for the given entity. Returns a null if <paramref name="entity"/> is null, or <paramref name="entity"/> does not have
        /// a URL.
        /// </returns>
        public static string EntityUrl(this HtmlHelper html, OrganizationServiceContext serviceContext, Entity entity, NameValueCollection queryStringParameters)
        {
            var portalViewContext = PortalExtensions.GetPortalViewContext(html);

            return(EntityUrl(html, portalViewContext.GetEntity(serviceContext, entity), queryStringParameters));
        }
Esempio n. 19
0
        /// <summary>
        /// Return a URL for the current portal context entity.
        /// </summary>
        /// <param name="html">Extension method target, provides support for HTML rendering and access to view context/data.</param>
        /// <param name="queryStringParameters">Query string parameter values that will be appended to the link URL.</param>
        /// <returns>
        /// Returns a URL for the current portal context entity.
        /// </returns>
        public static string EntityUrl(this HtmlHelper html, NameValueCollection queryStringParameters)
        {
            var portalViewContext = PortalExtensions.GetPortalViewContext(html);

            return(EntityUrl(html, portalViewContext.Entity, queryStringParameters));
        }
Esempio n. 20
0
        /// <summary>
        /// Renders an HTML structure that will allow for the creation of a new Snippet (adx_contentsnippet) record upon edit, for
        /// users with permission.
        /// </summary>
        internal static IHtmlString SnippetPlaceHolder(this HtmlHelper html, string snippetName, string editType = "html", bool htmlEncode = false, string tagName = "div", string cssClass = null, bool liquidEnabled = LiquidExtensions.LiquidEnabledDefault, Context liquidContext = null, string defaultValue = null, string displayName = null)
        {
            if (string.IsNullOrWhiteSpace(snippetName))
            {
                throw new ArgumentException("Value can't be null or whitespace.", "snippetName");
            }

            var tag = new TagBuilder(tagName ?? "div");

            if (!string.IsNullOrEmpty(cssClass))
            {
                tag.AddCssClass(cssClass);
            }

            if (defaultValue == null)
            {
                tag.AddCssClass("no-value");
            }

            tag.AddCssClass("xrm-attribute");
            tag.AddCssClass("xrm-editable-{0}".FormatWith(editType));

            var valueContainer = new TagBuilder(tagName ?? "div");

            valueContainer.AddCssClass("xrm-attribute-value");

            var stringValue = defaultValue ?? string.Empty;

            stringValue = liquidEnabled
                                ? liquidContext == null
                                        ? html.Liquid(stringValue)
                                        : html.Liquid(stringValue, liquidContext)
                                : stringValue;

            if (htmlEncode)
            {
                valueContainer.AddCssClass("xrm-attribute-value-encoded");
                valueContainer.SetInnerText(stringValue);
            }
            else
            {
                valueContainer.InnerHtml = stringValue;
            }

            tag.InnerHtml += valueContainer.ToString();

            var portalViewContext = PortalExtensions.GetPortalViewContext(html);
            var langContext       = HttpContext.Current.GetContextLanguageInfo();

            if (portalViewContext.WebsiteAccessPermissionProvider.TryAssert(portalViewContext.CreateServiceContext(), WebsiteRight.ManageContentSnippets))
            {
                if (defaultValue != null)
                {
                    tag.MergeAttribute("data-default", defaultValue);
                }

                JObject languageJson = null;

                tag.MergeAttribute("data-encoded", htmlEncode ? "true" : "false", true);
                tag.MergeAttribute("data-liquid", liquidEnabled ? "true" : "false", true);

                if (langContext.IsCrmMultiLanguageEnabled)
                {
                    tag.MergeAttribute("data-languageContext", langContext.ContextLanguage.DisplayName);
                    languageJson = new JObject
                    {
                        { "Id", langContext.ContextLanguage.EntityReference.Id.ToString() },
                        { "LogicalName", langContext.ContextLanguage.EntityReference.LogicalName }
                    };

                    portalViewContext.RenderEditingMetadata("adx_contentsnippet", tag, snippetName, new JObject
                    {
                        { "adx_name", snippetName },
                        { "adx_display_name", displayName },
                        { "adx_contentsnippetlanguageid", languageJson }
                    });
                }

                else
                {
                    portalViewContext.RenderEditingMetadata("adx_contentsnippet", tag, snippetName, new JObject
                    {
                        { "adx_name", snippetName },
                        { "adx_display_name", displayName }
                    });
                }
            }

            return(new HtmlString(tag.ToString()));
        }
Esempio n. 21
0
 /// <summary>
 /// Return a URL for a given entity.
 /// </summary>
 /// <param name="html">Extension method target, provides support for HTML rendering and access to view context/data.</param>
 /// <param name="serviceContext">
 /// The <see cref="OrganizationServiceContext"/> to which <paramref name="entity"/> is attached, and which will be used to load
 /// any additional data required to render the attribute (e.g., performing security assertions).
 /// </param>
 /// <param name="entity">The <see cref="Microsoft.Xrm.Sdk.Entity"/> whose URL will be returned.</param>
 /// <param name="queryStringParameters">Query string parameter values that will be appended to the link URL.</param>
 /// <returns>
 /// Returns a URL for the given entity. Returns a null if <paramref name="entity"/> is null, or <paramref name="entity"/> does not have
 /// a URL.
 /// </returns>
 public static string EntityUrl(this HtmlHelper html, OrganizationServiceContext serviceContext, Entity entity, object queryStringParameters)
 {
     return(EntityUrl(html, serviceContext, entity, PortalExtensions.AnonymousObjectToQueryStringParameters(queryStringParameters)));
 }
 /// <summary>
 /// Returns a URL for the target of a given Site Marker (adx_sitemarker).
 /// </summary>
 /// <param name="html">Extension method target, provides support for HTML rendering and access to view context/data.</param>
 /// <param name="target">The <see cref="ISiteMarkerTarget"/> whose URL will be returned.</param>
 /// <param name="queryStringParameters">Query string parameter values that will be appended to the URL.</param>
 /// <returns>
 /// Returns a URL for a <paramref name="target"/>. Returns null if <paramref name="target"/> is null.
 /// is not found.
 /// </returns>
 public static string SiteMarkerUrl(this HtmlHelper html, ISiteMarkerTarget target, object queryStringParameters)
 {
     return(SiteMarkerUrl(html, target, PortalExtensions.AnonymousObjectToQueryStringParameters(queryStringParameters)));
 }
 /// <summary>
 /// Renders a link the target of a given Site Marker (adx_sitemarker), by site marker name.
 /// </summary>
 /// <param name="html">Extension method target, provides support for HTML rendering and access to view context/data.</param>
 /// <param name="siteMarkerName">The name of the site marker to retrieve.</param>
 /// <param name="queryStringParameters">Query string parameter values that will be appended to the link URL.</param>
 /// <param name="htmlAttributes">HTML attributes that will be added to the link tag.</param>
 /// <param name="linkText">The text of the link.</param>
 /// <param name="requireTargetReadAccess">
 /// Whether the target of the named site marker should be tested for security read access. This is false by default, but if
 /// set to true, and the current user does not have read access to the target entity, this method will return null.
 /// </param>
 /// <returns>
 /// Returns an HTML A tag linking to the target of a given site marker. Returns an empty string if a target for
 /// <paramref name="siteMarkerName"/> is not found. If <paramref name="requireTargetReadAccess"/> is set to true, and the current user
 /// does not have read access to the target entity, returns an empty string.
 /// </returns>
 public static IHtmlString SiteMarkerLink(this HtmlHelper html, string siteMarkerName, object queryStringParameters, object htmlAttributes, string linkText = null, bool requireTargetReadAccess = false)
 {
     return(SiteMarkerLink(html, siteMarkerName, PortalExtensions.AnonymousObjectToQueryStringParameters(queryStringParameters), htmlAttributes, linkText, requireTargetReadAccess));
 }
Esempio n. 24
0
        public static bool IsCurrentSiteMapNode(this HtmlHelper html, SiteMapNode siteMapNode)
        {
            var portalViewContext = PortalExtensions.GetPortalViewContext(html);

            return(portalViewContext.IsCurrentSiteMapNode(siteMapNode));
        }
Esempio n. 25
0
 /// <summary>
 /// Renders a link to the current portal context entity.
 /// </summary>
 /// <param name="html">Extension method target, provides support for HTML rendering and access to view context/data.</param>
 /// <param name="linkText">The text of the link.</param>
 /// <param name="queryStringParameters">Query string parameter values that will be appended to the link URL.</param>
 /// <param name="htmlAttributes">HTML attributes that will be added to the link tag.</param>
 /// <returns>
 /// Returns an HTML A tag linking to the current portal context entity.
 /// </returns>
 public static IHtmlString EntityLink(this HtmlHelper html, string linkText, object queryStringParameters, object htmlAttributes)
 {
     return(EntityLink(html, linkText, PortalExtensions.AnonymousObjectToQueryStringParameters(queryStringParameters), htmlAttributes));
 }
Esempio n. 26
0
        public static bool IsAncestorSiteMapNode(this HtmlHelper html, string url, bool excludeRootNodes = false)
        {
            var portalViewContext = PortalExtensions.GetPortalViewContext(html);

            return(portalViewContext.IsAncestorSiteMapNode(url, excludeRootNodes));
        }
 /// <summary>
 /// Returns a URL for the target of a given Site Marker (adx_sitemarker), by site marker name.
 /// </summary>
 /// <param name="html">Extension method target, provides support for HTML rendering and access to view context/data.</param>
 /// <param name="siteMarkerName">The name of the site marker to retrieve.</param>
 /// <param name="queryStringParameters">Query string parameter values that will be appended to the URL.</param>
 /// <param name="requireTargetReadAccess">
 /// Whether the target of the named site marker should be tested for security read access. This is false by default, but if
 /// set to true, and the current user does not have read access to the target entity, this method will return null.
 /// </param>
 /// <returns>
 /// Returns a URL for the target of a given site marker. Returns an empty string if a target for <paramref name="siteMarkerName"/>
 /// is not found. If <paramref name="requireTargetReadAccess"/> is set to true, and the current user does not have read access to
 /// the target entity, returns null.
 /// </returns>
 public static string SiteMarkerUrl(this HtmlHelper html, string siteMarkerName, object queryStringParameters, bool requireTargetReadAccess = false)
 {
     return(SiteMarkerUrl(html, siteMarkerName, PortalExtensions.AnonymousObjectToQueryStringParameters(queryStringParameters), requireTargetReadAccess));
 }
Esempio n. 28
0
 /// <summary>
 /// Renders a link to a given entity.
 /// </summary>
 /// <param name="html">Extension method target, provides support for HTML rendering and access to view context/data.</param>
 /// <param name="entity">The <see cref="IPortalViewEntity"/> for which a link will be rendered.</param>
 /// <param name="linkText">The text of the link.</param>
 /// <param name="queryStringParameters">Query string parameter values that will be appended to the link URL.</param>
 /// <param name="htmlAttributes">HTML attributes that will be added to the link tag.</param>
 /// <returns>
 /// Returns an HTML A tag linking to the given entity. Returns an empty string if <paramref name="entity"/> is null.
 /// </returns>
 public static IHtmlString EntityLink(this HtmlHelper html, IPortalViewEntity entity, string linkText, object queryStringParameters, IDictionary <string, object> htmlAttributes)
 {
     return(EntityLink(html, entity, linkText, PortalExtensions.AnonymousObjectToQueryStringParameters(queryStringParameters), htmlAttributes));
 }
Esempio n. 29
0
 /// <summary>
 /// Gets the current portal context <see cref="IPortalViewEntity"/>.
 /// </summary>
 /// <param name="html">Extension method target, provides support for HTML rendering and access to view context/data.</param>
 /// <returns>The current portal context <see cref="IPortalViewEntity"/>.</returns>
 public static IPortalViewEntity Entity(this HtmlHelper html)
 {
     return(PortalExtensions.GetPortalViewContext(html).Entity);
 }
Esempio n. 30
0
 /// <summary>
 /// Gets a <see cref="IPortalViewEntity"/> associated with a given key, from the portal view context.
 /// </summary>
 /// <param name="html">Extension method target, provides support for HTML rendering and access to view context/data.</param>
 /// <param name="entityKey">The key with which the target entity is associated, in the current view context.</param>
 /// <returns>
 /// The <see cref="IPortalViewEntity"/> corresponding to <paramref name="entityKey"/>. If an entity with that key is not found in
 /// the current view context, returns null.
 /// </returns>
 public static IPortalViewEntity Entity(this HtmlHelper html, string entityKey)
 {
     return(PortalExtensions.GetPortalViewContext(html)[entityKey]);
 }