public void DeleteNewsEntry(INewsEntry newsEntry) { // delete content item, related news entry and text records will be deleted by foreign key rules NewsDataProvider.Instance.ContentController.DeleteContentItem(newsEntry.ContentItem); DataCache.ClearCache(NewsCacheKeyPrefix); }
public void DeleteNewsEntry(INewsEntry newsEntry) { // delete content item, related news entry will be deleted by foreign key rule NewsDataProvider.Instance.ContentController.DeleteContentItem(newsEntry.ContentItem); CacheHelper.RemoveCacheByPrefix(NewsCacheKeyPrefix); }
public static INewsEntry WithText(this INewsEntry newsEntry) { if (newsEntry.EntryTextId != null) { newsEntry.Text = NewsDataProvider.Instance.Get <NewsEntryText, int> (newsEntry.EntryTextId.Value).Text; } return(newsEntry); }
public static INewsEntry WithAgentModule(this INewsEntry newsEntry, ModuleController moduleController) { if (newsEntry.AgentModuleId != null) { newsEntry.AgentModule = GetAgentModule(moduleController, newsEntry.AgentModuleId.Value); } return(newsEntry); }
protected string FormatMessage(INewsEntry newsEntry, int tabId, int moduleId) { var resourceFile = Path.Combine(Const.LibraryInstallPath, "App_LocalResources", "SharedResources.resx"); var publishedOnDateText = Localization.GetString("PublishedOnDate.Text", resourceFile); var readMoreText = Localization.GetString("ReadMore.Text", resourceFile); return(HtmlUtils.StripTags(HttpUtility.HtmlDecode(newsEntry.Description), true) + $" / {publishedOnDateText}: {newsEntry.PublishedOnDate ().ToShortDateString ()}" + $" / {readMoreText}: {newsEntry.GetFullUrl (tabId, moduleId)}"); }
protected string FormatMessage(INewsEntry newsEntry, int tabId, int moduleId) { var resourceFile = Path.Combine(Const.LibraryInstallPath, "App_LocalResources", "SharedResources.resx"); var publishedOnDateText = Localization.GetString("PublishedOnDate.Text", resourceFile); var readMoreText = Localization.GetString("ReadMore.Text", resourceFile); return(newsEntry.Description + HttpUtility.HtmlEncode($"<p>{publishedOnDateText}: {newsEntry.PublishedOnDate ().ToShortDateString ()}</p>") + HttpUtility.HtmlEncode($"<p><a href=\"{newsEntry.GetUrl (tabId, moduleId)}\" target=\"_blank\">{readMoreText}...</a></p>")); }
public static string GetPermalink(this INewsEntry newsEntry, PermalinkMode permalinkMode, ModuleController moduleController, PortalAliasInfo portalAlias, int moduleId, int tabId) { return((permalinkMode == PermalinkMode.Friendly) ? GetPermalinkFriendly(newsEntry, moduleController, moduleId, tabId) : GetPermalinkRaw(newsEntry, moduleController, portalAlias, moduleId, tabId)); }
public static string GetRawImageUrl(this INewsEntry newsEntry) { var image = newsEntry.GetImage(); if (image != null) { return(Globals.AddHTTP(PortalSettings.Current.PortalAlias.HTTPAlias) + FileManager.Instance.GetUrl(image)); } return(string.Empty); }
public static string GetUrl(this INewsEntry newsEntry, int tabId, int moduleId) { if (!string.IsNullOrWhiteSpace(newsEntry.Url)) { return(Globals.LinkClick(newsEntry.Url, tabId, moduleId)); } return(newsEntry.GetPermalink(PermalinkMode.Friendly, NewsDataProvider.Instance.ModuleController, PortalSettings.Current.PortalAlias, moduleId, tabId)); }
void ReplacePageTitleAndMeta(INewsEntry newsEntry) { var page = (DotNetNuke.Framework.CDefault)Page; page.Title = FormatHelper.JoinNotNullOrEmpty(" - ", page.Title, newsEntry.Title); page.Description = HtmlUtils.StripTags(HttpUtility.HtmlDecode(newsEntry.Description), false); if (newsEntry.ContentItem.Terms.Count > 0) { page.KeyWords = FormatHelper.JoinNotNullOrEmpty(",", newsEntry.ContentItem.Terms.Select(t => t.Name)); } }
public static string GetImageUrl(this INewsEntry newsEntry, int width) { var image = newsEntry.GetImage(); if (image != null) { return(Globals.AddHTTP(PortalSettings.Current.PortalAlias.HTTPAlias) + "/imagehandler.ashx?fileticket=" + UrlUtils.EncryptParameter(image.FileId.ToString()) + "&width=" + width + "&ext=." + image.Extension); } return(string.Empty); }
public static string GetPermalinkRaw(this INewsEntry newsEntry, ModuleController moduleController, PortalAliasInfo portalAlias, int moduleId, int tabId) { var agentModule = GetAgentModuleOnce(moduleController, newsEntry); if (agentModule != null) { return(Globals.AddHTTP(portalAlias.HTTPAlias + "/default.aspx?tabid=" + agentModule.TabID)); } return(Globals.AddHTTP(portalAlias.HTTPAlias + "/default.aspx?tabid=" + tabId + "&mid=" + moduleId + "&ctl=entry&entryid=" + newsEntry.EntryId)); }
ContentItem AddContentItem(INewsEntry newsEntry, int tabId, int moduleId) { // TODO: Add value to ContentKey var contentItem = new ContentItem { ContentTitle = newsEntry.Title, Content = newsEntry.Title, ContentTypeId = NewsDataProvider.Instance.NewsContentType.ContentTypeId, Indexed = false, ModuleID = newsEntry.AgentModuleId ?? moduleId, TabID = tabId }; contentItem.ContentItemId = NewsDataProvider.Instance.ContentController.AddContentItem(contentItem); return(contentItem); }
protected MenuNode CreateMenuNode(INewsEntry newsEntry, MenuNode parentNode, ModuleInfo streamModule) { var node = new MenuNode(); node.Enabled = true; node.Parent = parentNode; node.Text = newsEntry.Title; node.Title = newsEntry.Title; node.Description = HtmlUtils.StripTags(HttpUtility.HtmlDecode(newsEntry.Description), false); node.Url = newsEntry.GetUrl(streamModule.TabID, streamModule.ModuleID); if (newsEntry.AgentModule != null) { node.TabId = newsEntry.AgentModule.TabID; } return(node); }
public static string GetImageUrl(this INewsEntry newsEntry, int width) { var image = newsEntry.GetImage(); if (image != null) { return(Globals.AddHTTP(PortalSettings.Current.PortalAlias.HTTPAlias) + "/dnnimagehandler.ashx" + "?mode=securefile" + "&fileid=" + image.FileId + "&filter=resize" + "&w=" + width // this helps external services to understand mimetype + "&ext=." + image.Extension); } return(string.Empty); }
/// <summary> /// Handles Load event for a control /// </summary> /// <param name="e">Event args.</param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); try { if (!IsPostBack) { // get news entry INewsEntry newsEntry = null; if (EntryId != null) { newsEntry = NewsRepository.Instance.GetNewsEntry(EntryId.Value, PortalId).WithText(); } if (newsEntry != null) { ReplacePageTitleAndMeta(newsEntry); var newsEntries = new List <StreamNewsEntryViewModel> (); newsEntries.Add(new StreamNewsEntryViewModel(newsEntry, ViewModelContext, NewsConfig.Instance.StreamModule)); formNewsEntry.DataSource = newsEntries; formNewsEntry.DataBind(); } else { if (!IsEditable) { // throw 404 exception, which would result in showing 404 page throw new HttpException((int)HttpStatusCode.NotFound, string.Empty); } // display warning for editors instead this.Message("NewsEntryNotFound.Text", MessageType.Warning, true); } } } catch (HttpException ex) { Exceptions.ProcessHttpException(ex); } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
public static string GetPermalinkFriendly(this INewsEntry newsEntry, ModuleController moduleController, int moduleId, int tabId) { var agentModule = GetAgentModuleOnce(moduleController, newsEntry); if (agentModule != null) { return(Globals.NavigateURL(agentModule.TabID)); } return(Globals.NavigateURL( tabId, "entry", "mid", moduleId.ToString(), "entryid", newsEntry.EntryId.ToString())); }
public string Discuss(INewsEntry newsEntry, int portalId, int userId) { try { if (IsAvailable) { var connector = ReflectionHelper.New(connectorType); var postMethod = ReflectionHelper.TryGetMethod(connectorType, "SubmitExternalPost", BindingFlags.Instance | BindingFlags.Public, 13); var forumParams = ForumDiscussParams.Parse(Params); var result = postMethod.Invoke(connector, new object [] { forumParams.TabId, forumParams.ModuleId, portalId, userId, newsEntry.Title, FormatMessage(newsEntry, forumParams.TabId, forumParams.ModuleId), forumParams.ForumId, 0, // ParentPostID null, // string of attachments "R7.News", // provider -1, // ParentThreadID newsEntry.ContentItem.Terms, false // IsPinned }); var postId = (int)submitResultType.GetField("PostId").GetValue(result); // var postMessage = (DnnForumPostMessage) submitResultType.GetField ("Result").GetValue (result); return(postId.ToString()); } } catch (Exception ex) { var log = new LogInfo(); log.Exception = new ExceptionInfo(ex); log.LogPortalID = portalId; log.LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString(); EventLogController.Instance.AddLog(log); } return(null); }
public static IList <NewsEntryAction> GetActions(this INewsEntry newsEntry, int moduleId) { var actions = new List <NewsEntryAction> (); var discussionStarted = !string.IsNullOrEmpty(newsEntry.DiscussProviderKey); if (!discussionStarted) { var discussProvider = NewsConfig.Instance.GetDiscussProviders().FirstOrDefault(); if (discussProvider != null) { actions.Add(new NewsEntryAction { EntryId = newsEntry.EntryId, Action = NewsEntryActions.StartDiscussion, ModuleId = moduleId, Params = new string [] { discussProvider.ProviderKey }, Enabled = HttpContext.Current.Request.IsAuthenticated }); } } else { var discussProvider = NewsConfig.Instance.GetDiscussProviders() .FirstOrDefault(dp => dp.ProviderKey == newsEntry.DiscussProviderKey); if (discussProvider != null) { actions.Add(new NewsEntryAction { EntryId = newsEntry.EntryId, Action = NewsEntryActions.JoinDiscussion, ModuleId = moduleId, Params = new string [] { discussProvider.ProviderKey, discussProvider.GetReplyCount(newsEntry.DiscussEntryId).ToString() }, Enabled = true }); } } return(actions); }
public void UpdateTabFromNewsEntry(TabInfo activeTab, INewsEntry newsEntry) { activeTab.TabName = HtmlUtils.Shorten(newsEntry.Title, 200, "..."); activeTab.Title = activeTab.TabName; activeTab.Description = HtmlUtils.Shorten( HtmlUtils.StripTags( HttpUtility.HtmlDecode(newsEntry.Description), true).Trim(), 500, "..."); activeTab.StartDate = newsEntry.StartDate.GetValueOrDefault(); activeTab.EndDate = (newsEntry.EndDate != null) ? newsEntry.EndDate.Value : DateTime.MaxValue; var tabCtrl = new TabController(); tabCtrl.UpdateTab(activeTab); var termCtrl = new TermController(); termCtrl.RemoveTermsFromContent(activeTab); foreach (var term in newsEntry.ContentItem.Terms) { termCtrl.AddTermToContent(term, activeTab); } }
public string Discuss(INewsEntry newsEntry, int portalId, int userId) { try { if (IsAvailable) { var connector = ReflectionHelper.New(connectorType); var postMethod = ReflectionHelper.TryGetMethod(connectorType, "Topic_QuickCreate", BindingFlags.Instance | BindingFlags.Public); var forumParams = ForumDiscussParams.Parse(Params); var result = postMethod.Invoke(connector, new object [] { portalId, forumParams.ModuleId, forumParams.ForumId, newsEntry.Title, FormatMessage(newsEntry, forumParams.TabId, forumParams.ModuleId), userId, UserController.Instance.GetUserById(portalId, userId).DisplayName, true, // IsApproved "0.0.0.0" }); var postId = (int)result; return(postId.ToString()); } } catch (Exception ex) { var log = new LogInfo(); log.Exception = new ExceptionInfo(ex); log.LogPortalID = portalId; log.LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString(); EventLogController.Instance.AddLog(log); } return(null); }
public static INewsEntry WithContentItem(this INewsEntry newsEntry) { newsEntry.ContentItem = NewsDataProvider.Instance.ContentController.GetContentItem(newsEntry.ContentItemId); return(newsEntry); }
protected void RedirectToDiscussion(INewsEntry newsEntry, IDiscussProvider discussProvider) { Response.Redirect(discussProvider.GetDiscussUrl(newsEntry.DiscussEntryId), false); }
public StreamNewsEntryViewModel(INewsEntry newsEntry, ViewModelContext <StreamSettings> context) : base(newsEntry, context) { }
public AgentNewsEntryViewModel(INewsEntry newsEntry, ViewModelContext <AgentSettings> context, AgentModuleConfig config) : base(newsEntry, context) { Config = config; }
public StreamNewsEntryViewModel(INewsEntry newsEntry, ViewModelContext <StreamSettings> context, StreamModuleConfig config) : base(newsEntry, context) { Config = config; }
public AgentNewsEntryViewModel(INewsEntry newsEntry, ViewModelContext <AgentSettings> context) : base(newsEntry, context) { }
public static DateTime PublishedOnDate(this INewsEntry newsEntry) { return(ModelHelper.PublishedOnDate(newsEntry.StartDate, newsEntry.ContentItem.CreatedOnDate)); }
public static bool IsVisible(this INewsEntry newsEntry, int minThematicWeight, int maxThematicWeight, int minStructuralWeight, int maxStructuralWeight) { return(ModelHelper.IsVisible(newsEntry.ThematicWeight, newsEntry.StructuralWeight, minThematicWeight, maxThematicWeight, minStructuralWeight, maxStructuralWeight)); }
private static ModuleInfo GetAgentModuleOnce(ModuleController moduleController, INewsEntry newsEntry) { if (newsEntry.AgentModule == null && newsEntry.AgentModuleId != null) { return(GetAgentModule(moduleController, newsEntry.AgentModuleId.Value)); } return(newsEntry.AgentModule); }