/**
  * Return an RSS feed of comments for a given set of comments or all 
  * comments on the website.
  *
  * To maintain backwards compatibility with 2.4 this supports mapping
  * of PageComment/rss?pageid= as well as the new RSS format for comments
  * of CommentingController/rss/{classname}/{id}
  *
  * @return RSS
  */
 public function rss()
 {
     $link = $this->Link('rss');
     $class = $this->urlParams['ID'];
     $id = $this->urlParams['OtherID'];
     if (isset($_GET['pageid'])) {
         $id = Convert::raw2sql($_GET['pageid']);
         $comments = Comment::get()->where(sprintf("BaseClass = 'SiteTree' AND ParentID = '%s' AND Moderated = 1 AND IsSpam = 0", $id));
         $link = $this->Link('rss', 'SiteTree', $id);
     } else {
         if ($class && $id) {
             if (Commenting::has_commenting($class)) {
                 $comments = Comment::get()->where(sprintf("BaseClass = '%s' AND ParentID = '%s' AND Moderated = 1 AND IsSpam = 0", Convert::raw2sql($class), Convert::raw2sql($id)));
                 $link = $this->Link('rss', Convert::raw2xml($class), (int) $id);
             } else {
                 return $this->httpError(404);
             }
         } else {
             if ($class) {
                 if (Commenting::has_commenting($class)) {
                     $comments = Comment::get()->where(sprintf("BaseClass = '%s' AND Moderated = 1 AND IsSpam = 0", Convert::raw2sql($class)));
                 } else {
                     return $this->httpError(404);
                 }
             } else {
                 $comments = Comment::get();
             }
         }
     }
     $title = _t('CommentingController.RSSTITLE', "Comments RSS Feed");
     $feed = new RSSFeed($comments, $link, $title, $link, 'Title', 'Comment', 'AuthorName');
     $feed->outputToBrowser();
 }
 /**
  * Overwrite the default comments form so we can tweak a bit
  *
  * @see docs/en/Extending
  */
 public function CommentsForm()
 {
     if (Commenting::has_commenting($this->ownerBaseClass) && Commenting::get_config_value($this->ownerBaseClass, 'include_js')) {
         Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
         Requirements::javascript(THIRDPARTY_DIR . '/jquery-validate/lib/jquery.form.js');
         Requirements::javascript(THIRDPARTY_DIR . '/jquery-validate/jquery.validate.pack.js');
         Requirements::javascript('comments/javascript/CommentsInterface.js');
     }
     $interface = new SSViewer('DiscussionsCommentsInterface');
     $enabled = !$this->attachedToSiteTree() || $this->owner->ProvideComments ? true : false;
     // do not include the comments on pages which don't have id's such as security pages
     if ($this->owner->ID < 0) {
         return false;
     }
     $controller = new CommentingController();
     $controller->setOwnerRecord($this);
     $controller->setBaseClass($this->ClassName);
     $controller->setOwnerController(Controller::curr());
     $moderatedSubmitted = Session::get('CommentsModerated');
     Session::clear('CommentsModerated');
     // Tweak the comments form a bit, so it is more user friendly
     if ($enabled) {
         $form = $controller->CommentsForm();
         $form->Fields()->removeByName("Comment");
         $comment_field = TextareaField::create("Comment", "")->setCustomValidationMessage(_t('CommentInterface.COMMENT_MESSAGE_REQUIRED', 'Please enter your comment'))->setAttribute('data-message-required', _t('CommentInterface.COMMENT_MESSAGE_REQUIRED', 'Please enter your comment'));
         if ($form->Fields()->dataFieldByName("NameView")) {
             $form->Fields()->insertBefore($comment_field, "NameView");
         } else {
             $form->Fields()->insertBefore($comment_field, "Name");
         }
     } else {
         $form = false;
     }
     // a little bit all over the show but to ensure a slightly easier upgrade for users
     // return back the same variables as previously done in comments
     return $interface->process(new ArrayData(array('CommentHolderID' => Commenting::get_config_value($this->ClassName, 'comments_holder_id'), 'PostingRequiresPermission' => Commenting::get_config_value($this->ClassName, 'required_permission'), 'CanPost' => Commenting::can_member_post($this->ClassName), 'RssLink' => "CommentingController/rss", 'RssLinkPage' => "CommentingController/rss/" . $this->ClassName . '/' . $this->ID, 'CommentsEnabled' => $enabled, 'Parent' => $this, 'AddCommentForm' => $form, 'ModeratedSubmitted' => $moderatedSubmitted, 'Comments' => $this->getComments())));
 }