Represents an abstract comment
Beispiel #1
0
        public void pingback(string sourceUri, string targetUri)
        {
            try
            {
                string entryId   = HttpContext.Current.Request.QueryString["entryId"].ToString();
                var    currentID = ID.Parse(entryId);

                var comment = new Model.Comment()
                {
                    AuthorName = "Automatic pingback",
                    Text       = string.Format("Pingkback from {0}", sourceUri)
                };

                comment.Fields.Add(Constants.Fields.Website, sourceUri);

                var commentId = ManagerFactory.CommentManagerInstance.AddCommentToEntry(currentID, comment);

                ContentHelper.PublishItemAndRequiredAncestors(commentId);
            }
            catch (Exception)
            {
                throw new XmlRpcFaultException(1, "Invalid sourceUri parameter.");
            }

            // return "Your ping request has been received successfully.";
        }
Beispiel #2
0
 private Comment NormalizeWebsiteAddress(Comment comment)
 {
     if (comment.Fields.ContainsKey(Constants.Fields.Website))
     {
         var website = comment.Fields[Constants.Fields.Website];
         comment.Fields[Constants.Fields.Website] = FixWebsiteAddress(website);
     }
     return comment;
 }
Beispiel #3
0
        protected void buttonSaveComment_Click(object sender, EventArgs e)
        {
            if (MessagePanel != null)
            {
                MessagePanel.Visible = false;
            }
            if (Page.IsValid)
            {
                Comment comment = new Comment
                {
                    AuthorName = GetFormValue(txtCommentName),
                    AuthorEmail = GetFormValue(txtCommentEmail),
                    Text = GetFormValue(txtCommentText)
                };
                comment.Fields.Add(Constants.Fields.Website, GetFormValue(txtCommentWebsite));
                comment.Fields.Add(Constants.Fields.IpAddress, Context.Request.UserHostAddress);

                var submissionResult = SubmitCommentCore.Submit(comment);
                if (submissionResult.IsNull)
                {
                    SetErrorMessage(Translator.Text("COMMENT_SUBMIT_ERROR"));
                }
                else
                {
                    SetSuccessMessage(Translator.Text("COMMENT_SUBMIT_SUCCESS"));
                    ResetCommentFields();
                }

                //check if added comment is available. if so, send it along with the event
                //won't happen unless publishing and indexing is really fast, but worth a try
                CommentItem newComment = ManagerFactory.CommentManagerInstance.GetEntryComments(Sitecore.Context.Item).SingleOrDefault(item => item.ID == submissionResult);
                Sitecore.Events.Event.RaiseEvent(Constants.Events.UI.COMMENT_ADDED, new object[] { newComment });

                //display javascript to scroll right to the comments list
                CommentScroll.Visible = true;
            }
        }
Beispiel #4
0
        public void pingback(string sourceUri, string targetUri)
        {
            try
            {
                string entryId = HttpContext.Current.Request.QueryString["entryId"].ToString();
                var currentID = ID.Parse(entryId);

                var comment = new Model.Comment()
                {
                    AuthorName = "Automatic pingback",
                    Text = string.Format("Pingkback from {0}", sourceUri)
                };

                comment.Fields.Add(Constants.Fields.Website, sourceUri);

                var commentId = ManagerFactory.CommentManagerInstance.AddCommentToEntry(currentID, comment);

                ContentHelper.PublishItemAndRequiredAncestors(commentId);
            }
            catch (Exception)
            {
                throw new XmlRpcFaultException(1, "Invalid sourceUri parameter.");
            }

            // return "Your ping request has been received successfully.";
        }
Beispiel #5
0
 public ID Submit(Comment comment)
 {
     comment = NormalizeWebsiteAddress(comment);
     return ManagerFactory.CommentManagerInstance.SubmitComment(Context.Item.ID, comment, Context.Language);
 }