/// <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, NameValueCollection queryStringParameters, IDictionary <string, object> htmlAttributes) { if (entity == null) { return(new HtmlString(string.Empty)); } var tag = new TagBuilder("a"); var url = EntityUrl(html, entity, queryStringParameters); if (url != null) { tag.Attributes["href"] = url; } if (htmlAttributes != null) { tag.MergeAttributes(htmlAttributes, true); } tag.SetInnerText(linkText); return(new HtmlString(tag.ToString())); }
public WebLinkSet(Entity entity, IPortalViewEntity viewEntity, IEnumerable <IWebLink> webLinks) { if (entity == null) { throw new ArgumentNullException("entity"); } if (viewEntity == null) { throw new ArgumentNullException("viewEntity"); } if (webLinks == null) { throw new ArgumentNullException("webLinks"); } Entity = entity; ViewEntity = viewEntity; WebLinks = webLinks.ToArray(); Copy = viewEntity.GetAttribute("adx_copy"); Name = entity.GetAttributeValue <string>("adx_name"); Title = viewEntity.GetAttribute("adx_title"); DisplayName = entity.GetAttributeValue <string>("adx_display_name"); }
public PageDrop(IPortalLiquidContext portalLiquidContext, IPortalViewEntity viewEntity, SiteMapNodeDrop siteMapNode) : base(portalLiquidContext, viewEntity) { if (siteMapNode == null) { throw new ArgumentNullException("siteMapNode"); } SiteMapNode = siteMapNode; var current = HttpContext.Current; var contextLanguageInfo = portalLiquidContext.ContextLanguageInfo; if (!contextLanguageInfo.IsCrmMultiLanguageEnabled) { this._availableLanguages = new Lazy <LanguageDrop[]>(() => new LanguageDrop[0]); this._languages = new Lazy <LanguageDrop[]>(() => new LanguageDrop[0]); } else { var previewPermission = new PreviewPermission(PortalContext.Current.ServiceContext, PortalContext.Current.Website); if (previewPermission.IsEnabledAndPermitted) { this._availableLanguages = new Lazy <LanguageDrop[]>(() => contextLanguageInfo.GetWebPageWebsiteLanguages(viewEntity.EntityReference, current).Select(websiteLanguage => new LanguageDrop(this, websiteLanguage)).ToArray()); this._languages = new Lazy <LanguageDrop[]>(() => contextLanguageInfo.ActiveWebsiteLanguages.Select(websiteLanguage => new LanguageDrop(this, websiteLanguage)).ToArray()); } else { this._availableLanguages = new Lazy <LanguageDrop[]>(() => contextLanguageInfo.GetWebPageWebsiteLanguages(viewEntity.EntityReference, current).Where(lang => lang.IsPublished).Select(websiteLanguage => new LanguageDrop(this, websiteLanguage)).ToArray()); this._languages = new Lazy <LanguageDrop[]>(() => contextLanguageInfo.ActiveWebsiteLanguages.Where(lang => lang.IsPublished).Select(websiteLanguage => new LanguageDrop(this, websiteLanguage)).ToArray()); } } this._isPageless = new Lazy <bool>(() => CrmSiteMapProvider.IsPageless(current)); }
public Snippet(Entity entity, IPortalViewEntity viewEntity, ContextLanguageInfo language) { if (entity == null) { throw new ArgumentNullException("entity"); } if (viewEntity == null) { throw new ArgumentNullException("viewEntity"); } if (language == null) { throw new ArgumentNullException("language"); } Entity = entity; Name = entity.GetAttributeValue <string>("adx_name"); Value = viewEntity.GetAttribute("adx_value"); DisplayName = entity.GetAttributeValue <string>("adx_display_name"); // set the language name value - fails if the solutions have not been updated, so set LanguageName to null this.LanguageName = GetLanguageName(entity, language); }
public Forum(Entity entity, IPortalViewEntity viewEntity, IForumInfo forumInfo, Func <ForumCounts> counts) { if (entity == null) { throw new ArgumentNullException("entity"); } if (viewEntity == null) { throw new ArgumentNullException("viewEntity"); } if (forumInfo == null) { throw new ArgumentNullException("forumInfo"); } if (counts == null) { throw new ArgumentNullException("counts"); } Entity = entity; _viewEntity = viewEntity; LatestPost = forumInfo.LatestPost; _counts = new Lazy <ForumCounts>(counts); Name = entity.GetAttributeValue <string>("adx_name"); Description = entity.GetAttributeValue <string>("adx_description"); }
public UserDrop(IPortalLiquidContext portalLiquidContext, IPortalViewEntity viewEntity) : base(portalLiquidContext, viewEntity) { _basicBadgesUrl = new Lazy <string>(GetBasicBadgesUrl, LazyThreadSafetyMode.None); _roles = new Lazy <string[]>(GetRolesForUser, LazyThreadSafetyMode.None); _roleKeys = new Lazy <string[]>(GetRoleKeysForUser, LazyThreadSafetyMode.None); _profileBadgesUrl = new Lazy <string>(GetProfileBadgesUrl, LazyThreadSafetyMode.None); _forumThreadSubscriptions = new Lazy <IEnumerable <ForumThreadDrop> >(() => GetForumThreadSubscriptions(portalLiquidContext), LazyThreadSafetyMode.None); }
public PortalViewEntityDrop(IPortalLiquidContext portalLiquidContext, IPortalViewEntity viewEntity) : base(portalLiquidContext) { if (viewEntity == null) { throw new ArgumentNullException("viewEntity"); } ViewEntity = viewEntity; }
public void RenderEditingMetadata(IPortalViewEntity entity, TagBuilder tag) { var metadataProvider = PortalCrmConfigurationManager.CreateDependencyProvider(PortalName).GetDependency <ICmsEntityEditingMetadataProvider>(); // If the entity is Weblinkset and a display name was given, show that otherwise use entity description (name) string displayName = entity is IWebLinkSet && ((IWebLinkSet)entity).DisplayName != null ? ((IWebLinkSet)entity).DisplayName : entity.Description; metadataProvider.AddEntityMetadata(new TagBuilderCmsEntityEditingMetadataContainer(tag), entity.EntityReference, PortalName, displayName); _enableEditing = true; }
public WebLink(Entity entity, IPortalViewEntity viewEntity, ApplicationPath applicationPath, IEnumerable <IWebLink> childWebLinks = null) { if (entity == null) { throw new ArgumentNullException("entity"); } if (viewEntity == null) { throw new ArgumentNullException("viewEntity"); } Entity = entity; Description = viewEntity.GetAttribute("adx_description"); Name = viewEntity.GetAttribute("adx_name"); if (applicationPath != null) { if (applicationPath.ExternalUrl != null) { Url = applicationPath.ExternalUrl; IsExternal = true; } else { Url = applicationPath.AbsolutePath; IsExternal = false; } } WebLinks = childWebLinks == null?Enumerable.Empty <IWebLink>() : childWebLinks.ToArray(); ImageAlternateText = entity.GetAttributeValue <string>("adx_imagealttext"); ImageUrl = entity.GetAttributeValue <string>("adx_imageurl"); ImageHeight = entity.GetAttributeValue <int?>("adx_imageheight"); ImageWidth = entity.GetAttributeValue <int?>("adx_imagewidth"); DisplayImageOnly = entity.GetAttributeValue <bool?>("adx_displayimageonly").GetValueOrDefault(false); Page = entity.GetAttributeValue <EntityReference>("adx_pageid"); HasImage = !string.IsNullOrEmpty(ImageUrl); NoFollow = !entity.GetAttributeValue <bool?>("adx_robotsfollowlink").GetValueOrDefault(true); OpenInNewWindow = entity.GetAttributeValue <bool?>("adx_openinnewwindow").GetValueOrDefault(false); ToolTip = entity.GetAttributeValue <string>("adx_name"); DisplayPageChildLinks = entity.GetAttributeValue <bool?>("adx_displaypagechildlinks").GetValueOrDefault(false); }
public ForumAnnouncement(Entity entity, IPortalViewEntity viewEntity) { if (entity == null) { throw new ArgumentNullException("entity"); } if (viewEntity == null) { throw new ArgumentNullException("viewEntity"); } Entity = entity; _viewEntity = viewEntity; Name = entity.GetAttributeValue <string>("adx_name"); Content = entity.GetAttributeValue <string>("adx_content"); PostedOn = entity.GetAttributeValue <DateTime?>("adx_date"); }
/// <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, NameValueCollection queryStringParameters) { if (entity == null) { return(null); } if (entity.Url == null) { return(null); } if (queryStringParameters == null || !queryStringParameters.HasKeys()) { return(entity.Url); } return(entity.Url.AppendQueryString(queryStringParameters)); }
public WebsiteDrop(IPortalLiquidContext portalLiquidContext, IPortalViewEntity viewEntity, IDataAdapterDependencies dependencies) : base(portalLiquidContext, viewEntity) { _dependencies = dependencies; _eventAggregationDataAdapter = new WebsiteEventDataAdapter(_dependencies); _events = new Lazy <EventDrop[]>(() => _eventAggregationDataAdapter.SelectEvents().Select(e => new EventDrop(this, _dependencies, new Event(e))).ToArray(), LazyThreadSafetyMode.None); var blogDependencies = new PortalConfigurationDataAdapterDependencies(); _blogAggregationDataAdapter = new WebsiteBlogAggregationDataAdapter(blogDependencies); var urlProvider = blogDependencies.GetUrlProvider(); var serviceContext = dependencies.GetServiceContext(); _blogs = new Lazy <BlogDrop[]>(() => _blogAggregationDataAdapter.SelectBlogs() .Select(e => new BlogDrop(this, blogDependencies, new Blog(e.Entity, urlProvider.GetApplicationPath(serviceContext, e.Entity)))) .ToArray(), LazyThreadSafetyMode.None); var contextLanguageInfo = portalLiquidContext.ContextLanguageInfo; if (!contextLanguageInfo.IsCrmMultiLanguageEnabled) { this._languages = new Lazy <LanguageDrop[]>(() => new LanguageDrop[0]); // Initialize _languages as an empty collection. } else { var previewPermission = new PreviewPermission(PortalContext.Current.ServiceContext, PortalContext.Current.Website); if (previewPermission.IsEnabledAndPermitted) { this._languages = new Lazy <LanguageDrop[]>(() => contextLanguageInfo.ActiveWebsiteLanguages.Select(websiteLanguage => new LanguageDrop(this, websiteLanguage)).ToArray()); } else { this._languages = new Lazy <LanguageDrop[]>(() => contextLanguageInfo.ActiveWebsiteLanguages.Where(lang => lang.IsPublished).Select(websiteLanguage => new LanguageDrop(this, websiteLanguage)).ToArray()); } this.SelectedLanguage = new LanguageDrop(this, contextLanguageInfo.ContextLanguage); } }
private static IHtmlString EntityEditingMetadata(IPortalViewEntity entity, IPortalViewContext portalViewContext, string cssClass = null) { if (entity == null) { return(new HtmlString(string.Empty)); } if (!entity.Editable) { return(new HtmlString(string.Empty)); } if (portalViewContext == null) { throw new ArgumentNullException("portalViewContext"); } var tag = new TagBuilder("div"); tag.Attributes["style"] = "display:none;"; tag.AddCssClass("xrm-entity"); tag.AddCssClass("xrm-editable-{0}".FormatWith(entity.EntityReference.LogicalName)); if (portalViewContext.IsCurrentSiteMapNode(entity)) { tag.AddCssClass("xrm-entity-current"); } if (!String.IsNullOrEmpty(cssClass)) { tag.AddCssClass(cssClass); } portalViewContext.RenderEditingMetadata(entity, tag); return(new HtmlString(tag.ToString())); }
public ForumPost(Entity entity, IPortalViewEntity viewEntity, IForumPostInfo postInfo, Lazy <ApplicationPath> getEditPath = null, Lazy <ApplicationPath> getDeletePath = null, Lazy <bool> editable = null, Lazy <bool> canMarkAsAnswer = null, string url = null, IForumThread thread = null, Lazy <bool> canEdit = null) { if (entity == null) { throw new ArgumentNullException("entity"); } if (viewEntity == null) { throw new ArgumentNullException("viewEntity"); } if (postInfo == null) { throw new ArgumentNullException("postInfo"); } Entity = entity; _viewEntity = viewEntity; _editable = editable; AttachmentInfo = postInfo.AttachmentInfo ?? new IForumPostAttachmentInfo[] { }; Author = postInfo.Author; _getEditPath = getEditPath ?? new Lazy <ApplicationPath>(() => null, LazyThreadSafetyMode.None); _getDeletePath = getDeletePath ?? new Lazy <ApplicationPath>(() => null, LazyThreadSafetyMode.None); _canMarkAsAnswer = canMarkAsAnswer ?? new Lazy <bool>(() => false, LazyThreadSafetyMode.None); _canEdit = canEdit ?? new Lazy <bool>(() => false, LazyThreadSafetyMode.None); _url = url; Thread = thread; Content = entity.GetAttributeValue <string>("adx_content"); IsAnswer = entity.GetAttributeValue <bool?>("adx_isanswer").GetValueOrDefault(); HelpfulVoteCount = entity.GetAttributeValue <int?>("adx_helpfulvotecount").GetValueOrDefault(); Name = entity.GetAttributeValue <string>("adx_name"); PostedOn = entity.GetAttributeValue <DateTime?>("adx_date").GetValueOrDefault(postInfo.PostedOn); }
internal PortalViewEntityAttribute(IPortalViewEntity entity, string logicalName, object value, Lazy <string> description) { if (entity == null) { throw new ArgumentNullException("entity"); } if (logicalName == null) { throw new ArgumentNullException("logicalName"); } if (description == null) { throw new ArgumentNullException("description"); } Entity = entity; LogicalName = logicalName; Value = value; EntityReference = Entity.EntityReference; _description = description; }
public ForumThread(Entity entity, IPortalViewEntity viewEntity, IForumThreadInfo threadInfo, Func <int> postCount, string url = null) { if (entity == null) { throw new ArgumentNullException("entity"); } if (viewEntity == null) { throw new ArgumentNullException("viewEntity"); } if (threadInfo == null) { throw new ArgumentNullException("threadInfo"); } if (postCount == null) { throw new ArgumentNullException("postCount"); } Entity = entity; _viewEntity = viewEntity; Author = threadInfo.Author; LatestPost = threadInfo.LatestPost; PostedOn = threadInfo.PostedOn; Tags = threadInfo.Tags; ThreadType = threadInfo.ThreadType; _postCount = new Lazy <int>(postCount); _url = url; Name = entity.GetAttributeValue <string>("adx_name"); IsAnswered = entity.GetAttributeValue <bool?>("adx_isanswered").GetValueOrDefault(); IsSticky = entity.GetAttributeValue <bool?>("adx_sticky").GetValueOrDefault(); Locked = entity.GetAttributeValue <bool?>("adx_locked").GetValueOrDefault(); }
public ForumThread(Entity entity, IPortalViewEntity viewEntity, IForumThreadInfo threadInfo, int postCount, string url = null) : this(entity, viewEntity, threadInfo, () => postCount, url) { }
public bool IsCurrentSiteMapNode(IPortalViewEntity entity) { var currentNode = CurrentSiteMapNode as CrmSiteMapNode; return(currentNode != null && currentNode.Entity != null && entity.EntityReference.Equals(currentNode.Entity.ToEntityReference())); }
public Forum(Entity entity, IPortalViewEntity viewEntity, IForumInfo forumInfo, ForumCounts counts) : this(entity, viewEntity, forumInfo, () => counts) { }
/// <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)); }
private static string GetTargetUrl(OrganizationServiceContext serviceContext, RelatedWebsite website, IPortalViewEntity current) { if (website.IsCurrent) { return(current.Url); } if (current.EntityReference.LogicalName == "adx_webpage") { if (website.IsMaster) { var masterWebPageQuery = serviceContext.CreateQuery("adx_webpage") .Join(serviceContext.CreateQuery("adx_webpage"), webPage => webPage.GetAttributeValue <Guid?>("adx_webpageid"), subscriberWebPage => subscriberWebPage.GetAttributeValue <EntityReference>("adx_masterwebpageid").Id, (webPage, subscriberWebPage) => new { webPage, subscriberWebPage }) .Where(@t => @t.subscriberWebPage.GetAttributeValue <Guid?>("adx_webpageid") == current.EntityReference.Id) .Where(@t => @t.webPage.GetAttributeValue <EntityReference>("adx_websiteid") == website.Entity.ToEntityReference()) .Where(@t => @t.webPage.GetAttributeValue <OptionSetValue>("statecode") != null && @t.webPage.GetAttributeValue <OptionSetValue>("statecode").Value == 0) .Select(@t => @t.webPage); var masterWebPage = masterWebPageQuery.FirstOrDefault(); if (masterWebPage != null) { return(serviceContext.GetUrl(masterWebPage)); } } else { var subscriberWebPage = serviceContext.CreateQuery("adx_webpage") .FirstOrDefault(e => e.GetAttributeValue <EntityReference>("adx_masterwebpageid") == current.EntityReference && e.GetAttributeValue <EntityReference>("adx_websiteid") == website.Entity.ToEntityReference() && e.GetAttributeValue <OptionSetValue>("statecode") != null && e.GetAttributeValue <OptionSetValue>("statecode").Value == 0); if (subscriberWebPage != null) { return(serviceContext.GetUrl(subscriberWebPage)); } } } var homePage = serviceContext.GetPageBySiteMarkerName(website.Entity, "Home"); return(homePage == null ? null : serviceContext.GetUrl(homePage)); }
/// <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))); }
public WebsiteDrop(IPortalLiquidContext portalLiquidContext, IPortalViewEntity viewEntity) : base(portalLiquidContext, viewEntity) { }
/// <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, NameValueCollection queryStringParameters, object htmlAttributes) { return(EntityLink(html, entity, linkText, queryStringParameters, HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes))); }
/// <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> /// <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) { return(EntityUrl(html, entity, new {})); }
/// <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)); }
/// <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> /// <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, NameValueCollection queryStringParameters) { return(EntityLink(html, entity, linkText, queryStringParameters, new {})); }
/// <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> /// <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) { return(EntityLink(html, entity, linkText, new {})); }
public SiteMarkerTarget(Entity entity, IPortalViewEntity viewEntity, ApplicationPath applicationPath) : this(entity, new Lazy <IPortalViewEntity>(() => viewEntity, LazyThreadSafetyMode.None), applicationPath) { }
public PortalViewEntityAttribute(IPortalViewEntity entity, string logicalName, object value, string description = null) : this(entity, logicalName, value, new Lazy <string>(() => description, LazyThreadSafetyMode.None)) { }