/** * Generate a reply form for this comment * * @return Form */ public function ReplyForm() { // Ensure replies are enabled if (!$this->getRepliesEnabled()) { return null; } // Check parent is available $parent = $this->getParent(); if (!$parent || !$parent->exists()) { return null; } // Build reply controller $controller = CommentingController::create(); $controller->setOwnerRecord($parent); $controller->setBaseClass($parent->ClassName); $controller->setOwnerController(Controller::curr()); return $controller->ReplyForm($this); }
/** * 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() { // Check if enabled $enabled = $this->getCommentsEnabled(); if ($enabled && $this->owner->getCommentsOption('include_js')) { Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js'); Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js'); Requirements::javascript(THIRDPARTY_DIR . '/jquery-validate/lib/jquery.form.js'); Requirements::javascript(COMMENTS_THIRDPARTY . '/jquery-validate/jquery.validate.min.js'); Requirements::javascript('comments/javascript/CommentsInterface.js'); } $controller = CommentingController::create(); $controller->setOwnerRecord($this->owner); $controller->setBaseClass($this->ownerBaseClass); $controller->setOwnerController(Controller::curr()); $moderatedSubmitted = Session::get('CommentsModerated'); Session::clear('CommentsModerated'); $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 $this->owner->customise(array('AddCommentForm' => $form, 'ModeratedSubmitted' => $moderatedSubmitted))->renderWith('CommentsInterface'); }