/** * @param $commentsOnPage * @param $feedbackType */ private static function _comments($commentsOnPage, $feedbackType) { ?> <?php foreach ($commentsOnPage as $commentOnPage) { ?> <li class="media" id="li_<?php echo $commentOnPage->id; ?> "> <?php echo CommentOnPageHelper::comment($commentOnPage, $feedbackType); ?> <ul id="ul_<?php echo $commentOnPage->id; ?> "> <?php echo CommentOnPageHelper::_comments($commentOnPage->childCommentsOnPage, $feedbackType); ?> </ul> </li> <?php } ?> <?php }
/** * POST: /main/create-comment */ public function createCommentPost() { $pageId = $_REQUEST['PageId']; $commentId = $_REQUEST['CommentId']; $body = $_REQUEST['Body']; $pageDAO = new PageDAO(); $page = $pageDAO->getPage($pageId); if ($page->feedbackType != PageEntity::$FEEDBACK_COMMENTS_AUTH || Authentication::isAuthenticated()) { $captcha = true; if ($page->feedbackType == PageEntity::$FEEDBACK_COMMENTS_CAPTCHA && !Authentication::isAuthenticated()) { $captcha = Captcha::getCaptcha($commentId) == $_REQUEST['Captcha']; } if ($captcha) { $commentId = $commentId == 0 ? null : $commentId; $browsingId = Browsing::getBrowsingId(); $userId = Authentication::isAuthenticated() ? Authentication::getUserEntity()->id : null; $commentOnPageDAO = new CommentOnPageDAO(); $newCommentId = $commentOnPageDAO->createCommentOnPage($pageId, $commentId, $browsingId, $userId, $body); $newComment = $commentOnPageDAO->getCommentOnPage($newCommentId); echo CommentOnPageHelper::comment($newComment, $page->feedbackType); } else { echo 'captcha'; } } }