/**
  * 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())));
 }
 /**
  * Comments interface for the front end. Includes the CommentAddForm and the composition
  * of the comments display. 
  * 
  * To customize the html see templates/CommentInterface.ss or extend this function with
  * your own extension.
  *
  * @todo Cleanup the passing of all this configuration based functionality
  *
  * @see docs/en/Extending
  */
 public function CommentsForm()
 {
     $interface = new SSViewer('CommentsInterface');
     // detect whether we comments are enabled. By default if $CommentsForm is included
     // on a {@link DataObject} then it is enabled, however {@link SiteTree} objects can
     // trigger comments on / off via ProvideComments
     $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->owner);
     $controller->setBaseClass($this->ownerBaseClass);
     $controller->setOwnerController(Controller::curr());
     $form = $enabled ? $controller->CommentsForm() : 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->ownerBaseClass, 'comments_holder_id'), 'PostingRequiresPermission' => Commenting::get_config_value($this->ownerBaseClass, 'required_permission'), 'CanPost' => Commenting::can_member_post($this->ownerBaseClass), 'RssLink' => "CommentingController/rss", 'RssLinkPage' => "CommentingController/rss/" . $this->ownerBaseClass . '/' . $this->owner->ID, 'CommentsEnabled' => $enabled, 'AddCommentForm' => $form, 'Comments' => $this->Comments())));
 }