public override SearchResultItem[] Search(string text) { return(FeedStorageFactory.Create() .SearchFeeds(text) .ConvertAll <SearchResultItem>(f => new SearchResultItem() { Name = f.Caption, Description = HtmlUtility.GetText(f.Text, 120), URL = FeedUrls.GetFeedUrl(f.Id), Date = f.Date }) .ToArray()); }
private static string RenderWidget() { var widgetSettings = SettingsManager.Instance.LoadSettingsFor <FeedWidgetSettings>(SecurityContext.CurrentAccount.ID); var widget = new StringBuilder(); widget.Append("<div id=\"Feed_DataContent\">"); var feeds = FeedStorageFactory.Create().GetFeeds(FeedType.AllNews, Guid.Empty, widgetSettings.NewsCount, 0); if (feeds.Count > 0) { foreach (var feed in feeds) { widget.Append(@"<div style=""padding-bottom: 10px;"">"); widget.Append("<table cellspacing='0' cellpadding='0' border='0'><tr valign='top'><td width='25'>"); widget.AppendFormat(@"<span class=""textMediumDescribe"">{0}<br/>{1}</span>", feed.Date.ToShortDayMonth(), feed.Date.ToShortTimeString()); widget.Append("</td>"); widget.Append("<td>"); widget.Append("<div style=\"padding-left: 10px;\">"); widget.AppendFormat(@"<a href=""{0}"">{1}</a>", FeedUrls.GetFeedUrl(feed.Id), feed.Caption.HtmlEncode()); widget.Append("</div>"); widget.Append("</td>"); widget.Append("</tr>"); widget.Append("</table>"); widget.Append(@"</div>"); } widget.Append(@"<div style=""margin-top: 10px;"">"); widget.AppendFormat(@"<a href=""{1}"">{0}</a>", Resources.NewsResource.SeeAllNews, FeedUrls.MainPageUrl); widget.Append(@"</div>"); } else { widget.Append("<div class=\"empty-widget\" style=\"padding:40px; text-align: center;\">" + String.Format(Resources.NewsResource.NoFeedWidgetMessage, string.Format("<div style=\"padding-top:3px;\"><a class=\"promoAction\" href=\"{0}\">", VirtualPathUtility.ToAbsolute("~/products/community/modules/news/editnews.aspx")), "</a></div>") + "</div>"); } widget.Append("</div>"); return(widget.ToString()); }
protected void SaveFeed() { if (string.IsNullOrEmpty(feedName.Text)) { ((NewsMaster)Master).SetInfoMessage(NewsResource.RequaredFieldValidatorCaption, InfoType.Alert); return; } var storage = FeedStorageFactory.Create(); var isEdit = (FeedId != 0); var feed = isEdit ? storage.GetFeed(FeedId) : new FeedNews(); feed.Caption = feedName.Text; feed.Text = (Request["news_text"] ?? ""); feed.FeedType = (FeedType)int.Parse(feedType.SelectedValue, CultureInfo.CurrentCulture); storage.SaveFeed(feed, isEdit, FeedType.News); CommonControlsConfigurer.FCKEditingComplete("news", feed.Id.ToString(), feed.Text, isEdit); Response.Redirect(FeedUrls.GetFeedUrl(feed.Id, Info.UserId)); }
protected override void RenderContents(System.Web.UI.HtmlTextWriter writer) { writer.Write("<div id=\"Poll_DataContent\">"); writer.Write(@"<div>"); if (poll != null) { writer.Write("<div style='padding-bottom:15px;'><a class=\"linkHeaderLightMedium\" href=\"" + FeedUrls.GetFeedUrl(poll.Id) + "\">" + pollForm.Name + "</a></div>"); pollForm.RenderControl(writer); writer.Write("<div style=\"margin-top: 10px;\">"); writer.Write("<a href=\"" + FeedUrls.GetFeedListUrl(FeedType.Poll) + "\">" + Resources.NewsResource.SeeAllPolls + "</a>"); writer.Write("</div>"); } else { writer.Write("<div class=\"empty-widget\" style=\"padding:40px; text-align: center;\">" + String.Format(Resources.NewsResource.NoPollWidgetMessage, string.Format("<div style=\"padding-top:3px;\"><a class=\"promoAction\" href=\"{0}\">", VirtualPathUtility.ToAbsolute("~/products/community/modules/news/editpoll.aspx")), "</a></div>") + "</div>"); } writer.Write("</div>"); writer.Write("</div>"); }
protected void Page_Load(object sender, EventArgs e) { if (SetupInfo.WorkMode == WorkMode.Promo) { Response.Redirect(FeedUrls.MainPageUrl, true); } Utility.RegisterTypeForAjax(this.GetType()); if (!CommunitySecurity.CheckPermissions(NewsConst.Action_Add)) { Response.Redirect(FeedUrls.MainPageUrl, true); } _mobileVer = Core.Mobile.MobileDetector.IsRequestMatchesMobile(this.Context); Breadcrumb.Add(new BreadCrumb { NavigationUrl = FeedUrls.MainPageUrl, Caption = NewsResource.NewsBreadCrumbs }); if (Info.HasUser) { Breadcrumb.Add(new BreadCrumb { Caption = Info.User.DisplayUserName(false), NavigationUrl = FeedUrls.GetFeedListUrl(Info.UserId) }); } var storage = FeedStorageFactory.Create(); Feed feed = null; if (!string.IsNullOrEmpty(Request["docID"])) { long docID; if (long.TryParse(Request["docID"], out docID)) { feed = storage.GetFeed(docID); Breadcrumb.Add(new BreadCrumb { Caption = feed.Caption ?? string.Empty, NavigationUrl = FeedUrls.GetFeedUrl(docID, Info.UserId) }); Breadcrumb.Add(new BreadCrumb { Caption = NewsResource.NewsEditBreadCrumbsNews, NavigationUrl = FeedUrls.EditNewsUrl + "?docID=" + docID + Info.UserIdAttribute }); _text = (feed != null ? feed.Text : "").HtmlEncode(); } } else { Breadcrumb.Add(new BreadCrumb { Caption = NewsResource.NewsAddBreadCrumbsNews, NavigationUrl = FeedUrls.EditNewsUrl + (string.IsNullOrEmpty(Info.UserIdAttribute) ? string.Empty : "?" + Info.UserIdAttribute.Substring(1)) }); } if (_mobileVer && IsPostBack) { _text = Request["mobiletext"] ?? ""; } if (!IsPostBack) { //feedNameRequiredFieldValidator.ErrorMessage = NewsResource.RequaredFieldValidatorCaption; HTML_FCKEditor.BasePath = VirtualPathUtility.ToAbsolute(CommonControlsConfigurer.FCKEditorBasePath); HTML_FCKEditor.ToolbarSet = "NewsToolbar"; HTML_FCKEditor.EditorAreaCSS = WebSkin.GetUserSkin().BaseCSSFileAbsoluteWebPath; HTML_FCKEditor.Visible = !_mobileVer; BindNewsTypes(); if (feed != null) { if (!CommunitySecurity.CheckPermissions(feed, NewsConst.Action_Edit)) { Response.Redirect(FeedUrls.MainPageName, true); } feedName.Text = feed.Caption; HTML_FCKEditor.Value = feed.Text; FeedId = feed.Id; feedType.SelectedIndex = (int)Math.Log((int)feed.FeedType, 2); } } else { var control = FindControl(Request.Params["__EVENTTARGET"]); if (lbCancel.Equals(control)) { CancelFeed(sender, e); } else { SaveFeed(); } } this.Title = HeaderStringHelper.GetPageTitle(NewsResource.AddonName, Breadcrumb); lbCancel.Attributes["name"] = HTML_FCKEditor.ClientID; }
protected void Page_Load(object sender, EventArgs e) { Utility.RegisterTypeForAjax(typeof(Default), Page); commentList.Visible = CommunitySecurity.CheckPermissions(NewsConst.Action_Comment); pgNavigator.EntryCount = 1; pgNavigator.EntryCountOnPage = 1; Breadcrumb.Add(new BreadCrumb { Caption = NewsResource.NewsBreadCrumbs, NavigationUrl = FeedUrls.MainPageUrl }); if (Info.HasUser) { Breadcrumb.Add(new BreadCrumb { Caption = Info.User.DisplayUserName(false), NavigationUrl = FeedUrls.GetFeedListUrl(Info.UserId) }); } if (!IsPostBack) { var storage = FeedStorageFactory.Create(); if (!string.IsNullOrEmpty(Request["docID"])) { long docID; if (long.TryParse(Request["docID"], out docID)) { //Show panel ContentView.Visible = false; FeedView.Visible = true; var feed = storage.GetFeed(docID); if (feed != null) { if (!feed.Readed) { storage.ReadFeed(feed.Id, SecurityContext.CurrentAccount.ID.ToString()); } FeedViewCtrl.Feed = feed; hdnField.Value = feed.Id.ToString(CultureInfo.CurrentCulture); Title += string.Format(CultureInfo.CurrentCulture, "-{0}", feed.Caption); InitCommentsView(storage, feed); FeedView.DataBind(); Breadcrumb.Add(new BreadCrumb { Caption = feed.Caption, NavigationUrl = FeedUrls.GetFeedUrl(docID, Info.UserId) }); } else { ContentView.Visible = true; FeedView.Visible = false; FeedRepeater.Visible = true; } } } else { PageNumber = string.IsNullOrEmpty(Request["page"]) ? 1 : Convert.ToInt32(Request["page"]); LoadData(); } } this.Title = HeaderStringHelper.GetPageTitle(Resources.NewsResource.AddonName, Breadcrumb); }