コード例 #1
0
ファイル: FeedComment.cs プロジェクト: vipwan/CommunityServer
 public FeedComment(long feedId, Feed feed)
 {
     FeedId = feedId;
     Creator = SecurityContext.CurrentAccount.ID.ToString();
     Date = TenantUtil.DateTimeNow();
     Inactive = false;
     Feed = feed;
 }
コード例 #2
0
 public EventWrapperFull(ASC.Web.Community.News.Code.Feed feed)
     : base(feed)
 {
     if (feed is FeedPoll)
     {
         //Add poll info
         var poll = feed as FeedPoll;
         Poll = new PollWrapper(poll);
     }
     Text = feed.Text;
 }
コード例 #3
0
        private void InitCommentsView(IFeedStorage storage, FeedNS.Feed feed)
        {
            IList <CommentInfo> comments = BuildCommentsList(storage.GetFeedComments(feed.Id));

            //AppendChildsComments(ref comments, storage.GetFeedComments(feed.Id));

            ConfigureComments(commentList, feed);
            commentList.Items = comments;
            commentList.CommentsCountTitle = GetCommentsCount(comments).ToString(CultureInfo.CurrentCulture);
            commentList.TotalCount         = GetCommentsCount(comments);
        }
コード例 #4
0
ファイル: EventApi.cs プロジェクト: ridhouan/teamlab.v6.5
 public EventWrapperFull CreateEvent(string content, string title, FeedType type)
 {
     var feed = new ASC.Web.Community.News.Code.Feed
                    {
                        Caption = title,
                        Text = content,
                        Creator = SecurityContext.CurrentAccount.ID.ToString(),
                        Date = DateTime.UtcNow
                    };
     FeedStorage.SaveFeed(feed, false, type);
     return new EventWrapperFull(feed);
 }
コード例 #5
0
        public EventWrapperFull CreateEvent(string content, string title, FeedType type)
        {
            var feed = new ASC.Web.Community.News.Code.Feed
            {
                Caption = title,
                Text    = content,
                Creator = SecurityContext.CurrentAccount.ID.ToString(),
                Date    = DateTime.UtcNow
            };

            FeedStorage.SaveFeed(feed, false, type);
            return(new EventWrapperFull(feed));
        }
コード例 #6
0
        private static void ConfigureComments(CommentsList commentList, FeedNS.Feed feed)
        {
            CommonControlsConfigurer.CommentsConfigure(commentList);
            commentList.Simple        = false;
            commentList.BehaviorID    = "_commentsObj";
            commentList.FckDomainName = "news_comments";

            commentList.JavaScriptAddCommentFunctionName        = "Default.AddComment";
            commentList.JavaScriptPreviewCommentFunctionName    = "Default.GetPreview";
            commentList.JavaScriptRemoveCommentFunctionName     = "Default.RemoveComment";
            commentList.JavaScriptUpdateCommentFunctionName     = "Default.UpdateComment";
            commentList.JavaScriptLoadBBcodeCommentFunctionName = "Default.LoadCommentText";

            commentList.ObjectID = feed != null?feed.Id.ToString(CultureInfo.CurrentCulture) : "";
        }
コード例 #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Utility.RegisterTypeForAjax(GetType());

            if (!CommunitySecurity.CheckPermissions(NewsConst.Action_Add))
            {
                Response.Redirect(FeedUrls.MainPageUrl, true);
            }

            var storage = FeedStorageFactory.Create();

            FeedNS.Feed feed = null;
            if (!string.IsNullOrEmpty(Request["docID"]))
            {
                long docID;
                if (long.TryParse(Request["docID"], out docID))
                {
                    feed      = storage.GetFeed(docID);
                    PageTitle = NewsResource.NewsEditBreadCrumbsNews;
                    Title     = HeaderStringHelper.GetPageTitle(PageTitle);
                    _text     = (feed != null ? feed.Text : "").HtmlEncode();
                }
            }
            else
            {
                _text     = "";
                PageTitle = NewsResource.NewsAddBreadCrumbsNews;
                Title     = HeaderStringHelper.GetPageTitle(NewsResource.NewsAddBreadCrumbsNews);
            }

            if (!IsPostBack)
            {
                BindNewsTypes();

                if (feed != null)
                {
                    if (!CommunitySecurity.CheckPermissions(feed, NewsConst.Action_Edit))
                    {
                        Response.Redirect(FeedUrls.MainPageUrl, true);
                    }
                    feedName.Text          = feed.Caption;
                    _text                  = feed.Text;
                    FeedId                 = feed.Id;
                    feedType.SelectedIndex = (int)Math.Log((int)feed.FeedType, 2);
                }
                else
                {
                    if (!string.IsNullOrEmpty(Request["type"]))
                    {
                        var requestFeedType = (FeedType)Enum.Parse(typeof(FeedType), Request["type"], true);
                        var feedTypeInfo    = FeedTypeInfo.FromFeedType(requestFeedType);
                        var item            = feedType.Items.FindByText(feedTypeInfo.TypeName);

                        feedType.SelectedValue = item.Value;
                        feedType.SelectedIndex = (int)Math.Log((int)requestFeedType, 2);
                    }
                }
            }
            else
            {
                var control = FindControl(Request.Params["__EVENTTARGET"]);
                if (lbCancel.Equals(control))
                {
                    CancelFeed(sender, e);
                }
                else
                {
                    SaveFeed();
                }
            }

            RenderScripts();
        }
コード例 #8
0
        private Tuple<Feed, object> ToFeed(Tuple<Event, IEnumerable<EventComment>> e)
        {
            var evt = e.Item1;
            var item = e.Item1.FeedType.ToString().ToLowerInvariant();

            var itemUrl = "/products/community/modules/news/?docid=" + evt.Id;
            var commentApiUrl = "/api/2.0/community/event/" + evt.Id + "/comment.json";

            var comments = e.Item2.Where(c => c.Id != 0).OrderBy(c => c.Date).ToList();
            var feedDate = comments.Any() ? comments.First().Date : evt.Date;
            var feedAutohor = comments.Any() ? comments.Last().Creator : evt.Creator;

            var feed = new Feed(new Guid(evt.Creator), feedDate, true)
                {
                    Item = item,
                    ItemId = evt.Id.ToString(CultureInfo.InvariantCulture),
                    ItemUrl = CommonLinkUtility.ToAbsolute(itemUrl),
                    LastModifiedBy = new Guid(feedAutohor),
                    Product = Product,
                    Module = Name,
                    Action = comments.Any() ? FeedAction.Commented : FeedAction.Created,
                    Title = evt.Caption,
                    Description = HtmlSanitizer.Sanitize(evt.Text),
                    HasPreview = false,
                    CanComment = true,
                    CommentApiUrl = CommonLinkUtility.ToAbsolute(commentApiUrl),
                    Comments = comments.Select(ToFeedComment),
                    GroupId = string.Format("{0}_{1}", item, evt.Id)
                };
            feed.Keywords = string.Format("{0} {1} {2}",
                                          evt.Caption,
                                          Helper.GetText(evt.Text),
                                          string.Join(" ", feed.Comments.Select(x => x.Description)));

            return new Tuple<Feed, object>(feed, evt);
        }
コード例 #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!CommunitySecurity.CheckPermissions(NewsConst.Action_Add))
            {
                Response.Redirect(FeedUrls.MainPageUrl, true);
            }

            var storage = FeedStorageFactory.Create();

            FeedNS.Feed feed  = null;
            long        docID = 0;

            if (!string.IsNullOrEmpty(Request["docID"]) && long.TryParse(Request["docID"], out docID))
            {
                feed = storage.GetFeed(docID);
            }
            if (!IsPostBack)
            {
                _errorMessage.Text = "";
                if (feed != null)
                {
                    if (!CommunitySecurity.CheckPermissions(feed, NewsConst.Action_Edit))
                    {
                        Response.Redirect(FeedUrls.MainPageUrl, true);
                    }

                    FeedId = docID;
                    var pollFeed = feed as FeedPoll;
                    if (pollFeed != null)
                    {
                        _pollMaster.QuestionFieldID = "feedName";
                        var question = pollFeed;
                        _pollMaster.Singleton = (question.PollType == FeedPollType.SimpleAnswer);
                        _pollMaster.Name      = feed.Caption;
                        _pollMaster.ID        = question.Id.ToString(CultureInfo.CurrentCulture);

                        foreach (var variant in question.Variants)
                        {
                            _pollMaster.AnswerVariants.Add(new PollFormMaster.AnswerViarint
                            {
                                ID   = variant.ID.ToString(CultureInfo.CurrentCulture),
                                Name = variant.Name
                            });
                        }
                    }
                }
                else
                {
                    _pollMaster.QuestionFieldID = "feedName";
                }
            }
            else
            {
                SaveFeed();
            }

            if (feed != null)
            {
                (Master as NewsMaster).CurrentPageCaption = NewsResource.NewsEditBreadCrumbsPoll;
                Title = HeaderStringHelper.GetPageTitle(NewsResource.NewsEditBreadCrumbsPoll);
                lbCancel.NavigateUrl = VirtualPathUtility.ToAbsolute("~/Products/Community/Modules/News/") + "?docid=" + docID + Info.UserIdAttribute;
            }
            else
            {
                (Master as NewsMaster).CurrentPageCaption = NewsResource.NewsAddBreadCrumbsPoll;
                Title = HeaderStringHelper.GetPageTitle(NewsResource.NewsAddBreadCrumbsPoll);
                lbCancel.NavigateUrl = VirtualPathUtility.ToAbsolute("~/Products/Community/Modules/News/") + (string.IsNullOrEmpty(Info.UserIdAttribute) ? string.Empty : "?" + Info.UserIdAttribute.Substring(1));
            }
        }
コード例 #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Utility.RegisterTypeForAjax(GetType());

            if (!CommunitySecurity.CheckPermissions(NewsConst.Action_Add))
            {
                Response.Redirect(FeedUrls.MainPageUrl, true);
            }

            _mobileVer = Core.Mobile.MobileDetector.IsRequestMatchesMobile(Context);

            //fix for IE 10
            var browser = HttpContext.Current.Request.Browser.Browser;

            var userAgent  = Context.Request.Headers["User-Agent"];
            var regExp     = new Regex("MSIE 10.0", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);
            var regExpIe11 = new Regex("(?=.*Trident.*rv:11.0).+", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);

            if (browser == "IE" && regExp.Match(userAgent).Success || regExpIe11.Match(userAgent).Success)
            {
                _mobileVer = true;
            }

            var storage = FeedStorageFactory.Create();

            FeedNS.Feed feed = null;
            if (!string.IsNullOrEmpty(Request["docID"]))
            {
                long docID;
                if (long.TryParse(Request["docID"], out docID))
                {
                    feed = storage.GetFeed(docID);
                    (Master as NewsMaster).CurrentPageCaption = NewsResource.NewsEditBreadCrumbsNews;
                    Title = HeaderStringHelper.GetPageTitle(NewsResource.NewsEditBreadCrumbsNews);
                    _text = (feed != null ? feed.Text : "").HtmlEncode();
                }
            }
            else
            {
                (Master as NewsMaster).CurrentPageCaption = NewsResource.NewsAddBreadCrumbsNews;
                Title = HeaderStringHelper.GetPageTitle(NewsResource.NewsAddBreadCrumbsNews);
            }

            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.BaseCSSFileAbsoluteWebPath;
                HTML_FCKEditor.Visible       = !_mobileVer;
                BindNewsTypes();

                if (feed != null)
                {
                    if (!CommunitySecurity.CheckPermissions(feed, NewsConst.Action_Edit))
                    {
                        Response.Redirect(FeedUrls.MainPageUrl, true);
                    }
                    feedName.Text        = feed.Caption;
                    HTML_FCKEditor.Value = feed.Text;
                    FeedId = feed.Id;
                    feedType.SelectedIndex = (int)Math.Log((int)feed.FeedType, 2);
                }
                else
                {
                    if (!string.IsNullOrEmpty(Request["type"]))
                    {
                        var requestFeedType = (FeedType)Enum.Parse(typeof(FeedType), Request["type"], true);
                        var feedTypeInfo    = FeedTypeInfo.FromFeedType(requestFeedType);
                        var item            = feedType.Items.FindByText(feedTypeInfo.TypeName);

                        feedType.SelectedValue = item.Value;
                        feedType.SelectedIndex = (int)Math.Log((int)requestFeedType, 2);
                    }
                }
            }
            else
            {
                var control = FindControl(Request.Params["__EVENTTARGET"]);
                if (lbCancel.Equals(control))
                {
                    CancelFeed(sender, e);
                }
                else
                {
                    SaveFeed();
                }
            }

            lbCancel.Attributes["name"] = HTML_FCKEditor.ClientID;
            RenderScripts();
        }