public void HandleDownloadCsvRequest(int formId) { var httpContext = System.Web.HttpContext.Current; httpContext.Response.Clear(); httpContext.Response.Cache.SetLastModified(DateTime.Now); httpContext.Response.ContentType = "text/csv; name=\"Leaders.csv\""; httpContext.Response.AddHeader("Content-disposition", "inline; filename=\"Leaders.csv\""); httpContext.Response.Write(String.Format("\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\"\n", _translation.GetLanguageResourceValue("Rank"), _translation.GetLanguageResourceValue("Username"), _translation.GetLanguageResourceValue("DisplayName"), _translation.GetLanguageResourceValue("EmailAddress"), _translation.GetLanguageResourceValue("Points"))); httpContext.Response.Write(String.Format("\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\"\n", 1, "RichMercer", "Richard Mercer", "*****@*****.**", 1234)); httpContext.Response.End(); }
public string GetHeader(RenderTarget target) { var jsQuery = new NameValueCollection(); jsQuery["file"] = "js"; var cssQuery = new NameValueCollection(); cssQuery["file"] = "css"; return(string.Format(@" <script src=""{0}""></script> <link rel=""stylesheet"" href=""{1}"" type=""text/css"" /> <script type=""text/javascript""> (function($){{ $.telligent.evolution.ui.components.poll.configure({{deleteMessage:'{2}',voteMessage:'{3}',votingEndsMessage:'{4}',votingEndsResultsHiddenMessage:'{5}',votingEndedMessage:'{6}'}}); }}(jQuery)); </script> ", _callbackController.GetUrl(jsQuery), _callbackController.GetUrl(cssQuery), TEApi.Javascript.Encode(_translation.GetLanguageResourceValue("poll_vote_delete")), TEApi.Javascript.Encode(_translation.GetLanguageResourceValue("poll_vote")), TEApi.Javascript.Encode(_translation.GetLanguageResourceValue("poll_voting_ends")), TEApi.Javascript.Encode(_translation.GetLanguageResourceValue("poll_voting_ends_results_hidden")), TEApi.Javascript.Encode(_translation.GetLanguageResourceValue("poll_voting_ended")) )); }
public PropertyGroup[] GetConfigurationProperties(int groupId) { var group = new PropertyGroup("config", "", 1); var p = new Property("group", "", PropertyType.Custom, 1, "") { ControlType = typeof(GroupSelectionList) }; group.Properties.Add(p); if (groupId > 0) { p.Editable = false; p.DefaultValue = "Group=0"; p.Visible = false; p.Attributes["IncludeCurrentGroup"] = "true"; } p = new Property("label", "", PropertyType.String, 2, "") { Text = translationController.GetLanguageResourceValue("configuration_label"), ControlType = typeof(ContentFragmentTokenStringControl) }; group.Properties.Add(p); return(new[] { group }); }
public IEnumerable <IUserActionLink> GetActionLinks(int userId, int accessingUserId) { var links = new List <IUserActionLink>(); var user = PublicApi.Users.Get(new UsersGetOptions { Id = userId }); var accessingUser = userId == accessingUserId ? user : PublicApi.Users.Get(new UsersGetOptions() { Id = accessingUserId }); if (user != null && !string.Equals(user.Username, PublicApi.Users.AnonymousUserName, StringComparison.InvariantCulture) && accessingUser != null && !string.Equals(accessingUser.Username, PublicApi.Users.AnonymousUserName, StringComparison.InvariantCulture)) { links.Add(new UserActionLink { Html = string.Concat( "<a href=\"javascript:void(0)\" class=\"internal-link lync-status ui-lyncstatus disabled\" data-userid=\"", userId, "\" data-accessinguserid=\"", accessingUserId, "\" data-usersipuri=\"", user.SipUri(), "\">", _translation.GetLanguageResourceValue("recieving"), "</a>"), LinkTypeName = "LyncStatus" }); } return(links); }
IRestResponse GetRestResponse(IRestRequest request, bool requiresUser, Action <int?, string, DeviceType> action) { var token = request.Form["Token"]; var device = (DeviceType)Enum.Parse(typeof(DeviceType), request.Form["Device"] ?? "None", true); int?userId = request.UserId; var response = new RestResponse(); if (string.IsNullOrEmpty(token)) { response.Errors = new string[] { _translation.GetLanguageResourceValue("rest_invalid_token") }; return(response); } if (device == DeviceType.None) { response.Errors = new string[] { _translation.GetLanguageResourceValue("rest_invalid_device") }; return(response); } var user = PublicApi.Users.Get(new UsersGetOptions { Id = userId }); if (user == null || user.Errors.Count > 0) { if (requiresUser) { response.Errors = new string[] { _translation.GetLanguageResourceValue("rest_user_invalid") }; return(response); } else { userId = null; } } if (user.IsSystemAccount.HasValue && user.IsSystemAccount.Value) { // anonymous registration should be interpreted as an unregistration _deviceRegistrationService.UnregisterDevice(null, token, device); } else { action(userId, token, device); } return(response); }
private string RenderActivity(IActivityStory story) { var group = PublicApi.Groups.Get(story.ContentId.Value); if (group != null && group.Errors.Count() == 0) { User user = PublicApi.Users.Get(new UsersGetOptions() { Id = GetPrimaryUser(story) }); if (user != null) { var attributes = story.ExtendedAttributes.ToLookup(att => att.Key); Guid contentId = attributes.GetGuid("MentioningContentId" , Guid.Empty); Guid contentTypeId = attributes.GetGuid("MentioningContentTypeId", Guid.Empty); var content = PublicApi.Content.Get(contentId, contentTypeId); if (content != null && content.Errors.Count == 0) { return string.Format(_translatablePluginController.GetLanguageResourceValue("GroupMentioned"), PublicApi.Html.EncodeAttribute(user.Url) , user.DisplayName, PublicApi.Html.EncodeAttribute(content.Url), content.HtmlName("web")); } } } return string.Empty; }
public string GetPreviewHtml(IActivityStory story, Target target) { var poll = InternalApi.PollingService.GetPoll(story.ContentId.Value); if (poll == null) { return(_translation.GetLanguageResourceValue("activity_nopermission")); } var userId = GetPrimaryUser(story); if (userId == null) { return(null); } var user = TEApi.Users.Get(new UsersGetOptions { Id = userId }); if (user == null || user.HasErrors()) { return(null); } return(string.Format(_translation.GetLanguageResourceValue("activity_preview_format"), user.DisplayName, TEApi.Html.EncodeAttribute(user.ProfileUrl), poll.Name, TEApi.Html.EncodeAttribute(InternalApi.PollingUrlService.PollUrl(poll.Id)) )); }
public string GetUserLink(User user, ITranslatablePluginController translatablePluginController) { if (user == null) { return(null); } // if no access to profile url, just use the display name if (String.IsNullOrWhiteSpace(user.ProfileUrl)) { return(user.DisplayName); } // otherwise, template the user as a user link return(String.Format(translatablePluginController.GetLanguageResourceValue("html_user_link"), System.Web.HttpUtility.HtmlAttributeEncode(user.ProfileUrl), user.DisplayName)); }
public string GetContentMessage(Guid notificationId, string target, ITranslatablePluginController _translatablePluginController) { var notification = TEApi.Notifications.Get(notificationId); if (notification == null) { return(null); } var content = TEApi.Content.Get(notification.ContentId.GetValueOrDefault(), notification.ContentTypeId.GetValueOrDefault()); if (content == null) { return(null); } if (target == "ShortText") { if (notification.Actors.Count() == 1) { var latestUser = TEApi.Users.Get(new UsersGetOptions { Id = notification.Actors.First().UserId }); return(String.Format(_translatablePluginController.GetLanguageResourceValue("short_singular"), latestUser.DisplayName, TEApi.Language.Truncate(content.HtmlName("Web"), 30, "…"))); } return(String.Format(_translatablePluginController.GetLanguageResourceValue("short_multiple"), notification.Actors.Count().ToString(), TEApi.Language.Truncate(content.HtmlName("Web"), 30, "…"))); } if (notification.Actors == null || notification.Actors.Any()) { return(null); } var actors = notification.Actors.OrderByDescending(a => a.Date); var firstTwoActorUsers = actors .Take(2) .Select(a => TEApi.Users.Get(new UsersGetOptions { Id = a.UserId })) .ToList(); if (actors.Count() == 1) { return(String.Format(_translatablePluginController.GetLanguageResourceValue("html_one"), GetUserLink(firstTwoActorUsers[0], _translatablePluginController), System.Web.HttpUtility.HtmlAttributeEncode(content.Url), TEApi.Language.Truncate(content.HtmlName("Web"), 50, "…"))); } if (actors.Count() == 2) { return(String.Format(_translatablePluginController.GetLanguageResourceValue("html_two"), GetUserLink(firstTwoActorUsers[0], _translatablePluginController), GetUserLink(firstTwoActorUsers[1], _translatablePluginController), System.Web.HttpUtility.HtmlAttributeEncode(content.Url), TEApi.Language.Truncate(content.HtmlName("Web"), 50, "…"))); } if (actors.Count() == 3) { return(String.Format(_translatablePluginController.GetLanguageResourceValue("html_more_singular"), GetUserLink(firstTwoActorUsers[0], _translatablePluginController), GetUserLink(firstTwoActorUsers[1], _translatablePluginController), System.Web.HttpUtility.HtmlAttributeEncode(content.Url), TEApi.Language.Truncate(content.HtmlName("Web"), 50, "…"))); } if (actors.Count() > 3) { return(String.Format(_translatablePluginController.GetLanguageResourceValue("html_more_plural"), GetUserLink(firstTwoActorUsers[0], _translatablePluginController), GetUserLink(firstTwoActorUsers[1], _translatablePluginController), (actors.Count() - 2).ToString(), System.Web.HttpUtility.HtmlAttributeEncode(content.Url), TEApi.Language.Truncate(content.HtmlName("Web"), 50, "…"))); } return(null); }
void IApplicationNavigable.RegisterUrls(IUrlController controller) { controller.AddPage("forms.list", "", null, null, "forms-list", new PageDefinitionOptions { ParseContext = null, HasApplicationContext = false, TitleFunction = () => _translationController.GetLanguageResourceValue("page-forms-list"), DescriptionFunction = () => _translationController.GetLanguageResourceValue("page-forms-list-description"), DefaultPageXml = @"<contentFragmentPage pageName=""forms-list"" isCustom=""false"" layout=""Content"" themeType=""c6108064-af65-11dd-b074-de1a56d89593""> <regions> <region regionName=""Content""> <contentFragments> </contentFragments> </region> </regions> <contentFragmentTabs /> </contentFragmentPage>" }); controller.AddPage("forms.view", "{id}", null, null, "forms-view", new PageDefinitionOptions { ParseContext = null, HasApplicationContext = false, TitleFunction = () => _translationController.GetLanguageResourceValue("page-forms-list"), DescriptionFunction = () => _translationController.GetLanguageResourceValue("page-forms-list-description"), DefaultPageXml = @"<contentFragmentPage pageName=""forms-list"" isCustom=""false"" layout=""Content"" themeType=""c6108064-af65-11dd-b074-de1a56d89593""> <regions> <region regionName=""Content""> <contentFragments> </contentFragments> </region> </regions> <contentFragmentTabs /> </contentFragmentPage>" }); controller.AddPage("forms.new", "new", null, null, "forms-createedit", new PageDefinitionOptions { ParseContext = null, HasApplicationContext = false, TitleFunction = () => _translationController.GetLanguageResourceValue("page-forms-createedit"), DescriptionFunction = () => _translationController.GetLanguageResourceValue("page-forms-createedit-description"), DefaultPageXml = @"<contentFragmentPage pageName=""forms-createedit"" isCustom=""false"" layout=""Content"" themeType=""c6108064-af65-11dd-b074-de1a56d89593""> <regions> <region regionName=""Content""> <contentFragments> <contentFragment type=""Telligent.Evolution.ScriptedContentFragments.ScriptedContentFragment, Telligent.Evolution.ScriptedContentFragments::8e73f2dfbfa84f77b4b438831314f091"" showHeader=""True"" cssClassAddition=""with-spacing responsive-1"" isLocked=""False"" configuration=""fragmentHeader=%24%7Bresource%3ACore_ApiKeyList_Name%7D"" /> </contentFragments> </region> </regions> <contentFragmentTabs /> </contentFragmentPage>" }); controller.AddPage("forms.edit", "{id}/edit", null, null, "forms-createedit", new PageDefinitionOptions { ParseContext = null, HasApplicationContext = false, TitleFunction = () => _translationController.GetLanguageResourceValue("page-forms-createedit"), DescriptionFunction = () => _translationController.GetLanguageResourceValue("page-forms-createedit-description"), DefaultPageXml = @"<contentFragmentPage pageName=""forms-createedit"" isCustom=""false"" layout=""Content"" themeType=""c6108064-af65-11dd-b074-de1a56d89593""> <regions> <region regionName=""Content""> <contentFragments> <contentFragment type=""Telligent.Evolution.ScriptedContentFragments.ScriptedContentFragment, Telligent.Evolution.ScriptedContentFragments::8e73f2dfbfa84f77b4b438831314f091"" showHeader=""True"" cssClassAddition=""with-spacing responsive-1"" isLocked=""False"" configuration=""fragmentHeader=%24%7Bresource%3ACore_ApiKeyList_Name%7D"" /> </contentFragments> </region> </regions> <contentFragmentTabs /> </contentFragmentPage>" }); }
public SearchCategory[] GetCategories() { return(new SearchCategory[] { new SearchCategory("polls", _translation.GetLanguageResourceValue("search_category_name")) }); }
public string GetContentMessage(Guid notificationId, string target, ITranslatablePluginController _translatablePluginController) { var notification = TEApi.Notifications.Get(notificationId); if (notification == null) return null; var content = TEApi.Content.Get(notification.ContentId.GetValueOrDefault(), notification.ContentTypeId.GetValueOrDefault()); if (content == null) return null; if (target == "ShortText") { if (notification.Actors.Count() == 1) { var latestUser = TEApi.Users.Get(new UsersGetOptions { Id = notification.Actors.First().UserId }); return String.Format(_translatablePluginController.GetLanguageResourceValue("short_singular"), latestUser.DisplayName, TEApi.Language.Truncate(content.HtmlName("Web"), 30, "…")); } return String.Format(_translatablePluginController.GetLanguageResourceValue("short_multiple"), notification.Actors.Count().ToString(), TEApi.Language.Truncate(content.HtmlName("Web"), 30, "…")); } if (notification.Actors == null || notification.Actors.Any()) return null; var actors = notification.Actors.OrderByDescending(a => a.Date); var firstTwoActorUsers = actors .Take(2) .Select(a => TEApi.Users.Get(new UsersGetOptions { Id = a.UserId })) .ToList(); if (actors.Count() == 1) return String.Format(_translatablePluginController.GetLanguageResourceValue("html_one"), GetUserLink(firstTwoActorUsers[0], _translatablePluginController), System.Web.HttpUtility.HtmlAttributeEncode(content.Url), TEApi.Language.Truncate(content.HtmlName("Web"), 50, "…")); if (actors.Count() == 2) return String.Format(_translatablePluginController.GetLanguageResourceValue("html_two"), GetUserLink(firstTwoActorUsers[0], _translatablePluginController), GetUserLink(firstTwoActorUsers[1], _translatablePluginController), System.Web.HttpUtility.HtmlAttributeEncode(content.Url), TEApi.Language.Truncate(content.HtmlName("Web"), 50, "…")); if (actors.Count() == 3) return String.Format(_translatablePluginController.GetLanguageResourceValue("html_more_singular"), GetUserLink(firstTwoActorUsers[0], _translatablePluginController), GetUserLink(firstTwoActorUsers[1], _translatablePluginController), System.Web.HttpUtility.HtmlAttributeEncode(content.Url), TEApi.Language.Truncate(content.HtmlName("Web"), 50, "…")); if (actors.Count() > 3) return String.Format(_translatablePluginController.GetLanguageResourceValue("html_more_plural"), GetUserLink(firstTwoActorUsers[0], _translatablePluginController), GetUserLink(firstTwoActorUsers[1], _translatablePluginController), (actors.Count() - 2).ToString(), System.Web.HttpUtility.HtmlAttributeEncode(content.Url), TEApi.Language.Truncate(content.HtmlName("Web"), 50, "…")); return null; }
public string Render(ICentralizedFile file, IFileViewerOptions options) { var appData = Telligent.Evolution.Mobile.ServiceLocator.Get <Telligent.Evolution.Mobile.App.Services.IAppDataService>().Get(file); if (appData == null || appData.Image == null) { throw new FileViewerNotSupportedException(); } if (options.ViewType == FileViewerViewType.Preview) { return(Telligent.Evolution.Extensibility.Api.Version1.PublicApi.UI.GetResizedImageHtml(CentralizedFileStorage.GetGenericDownloadUrl(appData.Image), options.Width.HasValue ? options.Width.Value : 0, options.Height.HasValue ? options.Height.Value : 0, new UiGetResizedImageHtmlOptions { ResizeMethod = "ZoomAndCrop", OutputIsPersisted = options.OutputIsPersisted })); } else { StringBuilder html = new StringBuilder(); string installUrl = null; var installer = PluginManager.Get <AppInstaller>().FirstOrDefault(); if (installer != null) { installUrl = installer.FormatInstallationUrl(appData); } if (!string.IsNullOrEmpty(installUrl)) { html.Append("<a href=\""); html.Append(PublicApi.Html.Encode(installUrl)); html.Append("\" style=\"display:inline-block; background-color: #f3f3f3; color: #555; text-align: center; text-decoration: none; padding: 2px; border-radius: 10px;\" class=\"app-viewer with-install\">"); } else { html.Append("<span class=\"app-view without-install\">"); } html.Append(Telligent.Evolution.Extensibility.Api.Version1.PublicApi.UI.GetResizedImageHtml(CentralizedFileStorage.GetGenericDownloadUrl(appData.Image), options.Width.HasValue ? options.Width.Value : 0, options.Height.HasValue ? options.Height.Value : 0, new UiGetResizedImageHtmlOptions { ResizeMethod = "ScaleDown", OutputIsPersisted = options.OutputIsPersisted, HtmlAttributes = new Dictionary <string, string> { { "style", "border-radius: 10px; display: inline-block;" } } })); if (!string.IsNullOrEmpty(installUrl)) { html.Append("<div style=\"padding: 8px;\">"); if (appData.IsDirectlyInstallable) { html.Append(_translation.GetLanguageResourceValue("ota_install")); } else { html.Append(_translation.GetLanguageResourceValue("itunes_install")); } html.Append("</div></a>"); } else { html.Append("</span>"); } return(html.ToString()); } }
internal string Translate(string key) { return(translationController.GetLanguageResourceValue(key)); }
public void HandlePollVote(System.Web.HttpContext context) { var user = TEApi.Users.AccessingUser; if (user.IsSystemAccount.HasValue && user.IsSystemAccount.Value) { context.Response.RedirectLocation = TEApi.CoreUrls.LogIn(new CoreUrlLoginOptions() { ReturnToCurrentUrl = true }); context.Response.StatusCode = 302; context.Response.End(); } var pollContextItem = TEApi.Url.CurrentContext.ContextItems.GetItemByContentType(PublicApi.Polls.ContentTypeId); Telligent.BigSocial.Polling.InternalApi.Poll poll = null; if (pollContextItem != null && pollContextItem.ContentId.HasValue) { poll = InternalApi.PollingService.GetPoll(pollContextItem.ContentId.Value); } if (poll == null) { throw new PollException(_translatablePluginController.GetLanguageResourceValue("poll_NotFound")); } var pollAnswerIdObj = TEApi.Url.CurrentContext.GetTokenValue("PollAnswerId"); Guid pollAnswerId; if (pollAnswerIdObj != null && Guid.TryParse(pollAnswerIdObj.ToString(), out pollAnswerId)) { var answer = InternalApi.PollingService.GetPollAnswer(pollAnswerId); if (answer != null) { try { InternalApi.PollingService.AddUpdatePollVote(new Telligent.BigSocial.Polling.InternalApi.PollVote() { PollId = poll.Id, UserId = user.Id.Value, PollAnswerId = pollAnswerId }); var url = TEApi.Url.Adjust(InternalApi.PollingUrlService.PollUrl(poll.Id), "voted=" + pollAnswerId.ToString()); context.Response.RedirectLocation = url; context.Response.StatusCode = 302; context.Response.End(); } catch (Exception ex) { throw new PollException(_translatablePluginController.GetLanguageResourceValue("vote_UnknownError"), ex); } } else { var url = TEApi.Url.Adjust(InternalApi.PollingUrlService.PollUrl(poll.Id), "votefailed=true"); context.Response.RedirectLocation = url; context.Response.StatusCode = 302; context.Response.End(); } } }
public string GetViewHtml(IContent content, Target target) { if (content == null) { return(null); } var poll = InternalApi.PollingService.GetPoll(content.ContentId); if (poll == null) { return(string.Empty); } var user = TEApi.Users.Get(new UsersGetOptions { Id = poll.AuthorUserId }); var group = TEApi.Groups.Get(poll.ApplicationId); var sb = new StringBuilder(@"<div class=""content abbreviated rendered poll"">"); sb.Append(@"<div class=""author"">"); sb.Append(@"<div class=""avatar"">"); sb.AppendFormat(@"<a href=""{0}"" class=""internal-link view-user-profile"">{1}</a>", TEApi.Html.EncodeAttribute(user.Url), TEApi.UI.GetResizedImageHtml(user.AvatarUrl, 44, 44, new UiGetResizedImageHtmlOptions { OutputIsPersisted = false, ResizeMethod = "ZoomAndCrop" })); sb.Append(@"</div>"); sb.AppendFormat(@"<span class=""user-name""><a href=""{0}"" class=""internal-link view-user-profile"">{1}</a></span>", TEApi.Html.EncodeAttribute(user.Url), user.DisplayName); sb.Append(@"</a></div>"); sb.Append(@"<div class=""attributes""><ul class=""attribute-list"">"); sb.AppendFormat(@"<li class=""attribute-item date"">{0}</li>", TEApi.Language.FormatAgoDate(poll.CreatedDateUtc.ToLocalTime())); sb.AppendFormat(@"<li class=""attribute-item container"">{0} <a href=""{1}"">{2}</a></li>", _translation.GetLanguageResourceValue("In"), TEApi.Html.EncodeAttribute(group.Url), group.Name); sb.Append(@"</ul></div>"); sb.AppendFormat( @"<h3 class=""name""><a class=""internal-link"" title=""{0}"" href=""{1}"">{0}</a></h3>", content.HtmlName("Web"), TEApi.Html.EncodeAttribute((InternalApi.PollingUrlService.PollUrl(poll.Id)))); sb.AppendFormat(@"<div class=""content empty"">{0}</div>", TEApi.Language.Truncate(content.HtmlDescription("Web"), 200, "...")); //PublicApi.Polls.UI(poll.Id, true, false) sb.Append("</div>"); return(sb.ToString()); }
public string GetUserLink(User user, ITranslatablePluginController translatablePluginController) { if (user == null) return null; // if no access to profile url, just use the display name if (String.IsNullOrWhiteSpace(user.ProfileUrl)) return user.DisplayName; // otherwise, template the user as a user link return String.Format(translatablePluginController.GetLanguageResourceValue("html_user_link"), System.Web.HttpUtility.HtmlAttributeEncode(user.ProfileUrl), user.DisplayName); }
internal string Translate(string key, params object[] args) { return(String.Format(translationController.GetLanguageResourceValue(key), args)); }
public string GetResourceString(string resourceName) { return(translationController.GetLanguageResourceValue(resourceName)); }