assign_by_ref('formfeedback', $formfeedback); if (!empty($_REQUEST['delete_comment_id'])) { $deleteComment = new LibertyComment($_REQUEST['delete_comment_id']); if (!empty ($deleteComment->mInfo['content_id'])) { $deleteComment->deleteComment(); } } if (!empty($_REQUEST['post_comment_id'])) { $post_comment_id = $_REQUEST['post_comment_id']; $editComment = new LibertyComment($post_comment_id); if ($editComment->mInfo['content_id']) { if (!$editComment->userCanEdit()) { $formfeedback['error'] = "You do not have permission to edit this comment."; $editComment = NULL; $post_comment_id = NULL; } else { $postComment['data'] = $editComment->mInfo['data']; $postComment['title'] = $editComment->mInfo['title']; } } else { $formfeedback['error'] = "Comment does not exist."; $editComment = NULL; $post_comment_id = NULL; } } else { $post_comment_id = NULL; $editComment = NULL; } $smarty->assign('post_comment_id', $post_comment_id); // Store comment posts if (!empty($_REQUEST['post_comment_submit'])) { $storeComment = new LibertyComment(!empty($editComment->mCommentId) ? $editComment->mCommentId : NULL); $storeRow = array(); $storeRow['title'] = $_REQUEST['comment_title']; $storeRow['edit'] = $_REQUEST['comment_data']; $storeRow['parent_id'] = (!empty($storeComment->mInfo['parent_id']) ? $storeComment->mInfo['parent_id'] : (empty($_REQUEST['post_comment_reply_id']) ? $commentsParentId : $_REQUEST['post_comment_reply_id'])); $storeRow['content_id'] = (!empty($storeComment->mContentId) ? $storeComment->mContentId : NULL); $storeComment->storeComment($storeRow); } // $post_comment_request is a flag indicating whether or not to display the comment input form if (empty($_REQUEST['post_comment_request'])) { $post_comment_request = NULL; } elseif ($_REQUEST['post_comment_request']) { $post_comment_request = TRUE; } $smarty->assign_by_ref('post_comment_request', $post_comment_request); // $post_comment_preview is a flag indicating that the user wants to preview their comment prior to saving it if( !empty( $_REQUEST['post_comment_preview'] ) ) { $postComment['title'] = $_REQUEST['comment_title']; $postComment['data'] = $_REQUEST['comment_data']; $postComment['parsed_data'] = LibertyComment::parseData( $_REQUEST['comment_data'], 'tikiwiki' ); $smarty->assign('post_comment_preview', TRUE); } // $post_comment_reply_id is the content_id which a post is replying to if (!empty($_REQUEST['post_comment_reply_id'])) { $post_comment_reply_id = $_REQUEST['post_comment_reply_id']; $tmpComment = new LibertyComment(NULL, $post_comment_reply_id); //$postComment['data'] = $commentsLib->quoteComment($tmpComment->mInfo['data']); // This is super-ugly, better to just not quote at all, the indented comment indicates what comment it is replying to $postComment['title'] = tra('Re:')." ".$tmpComment->mInfo['title']; $smarty->assign('post_comment_reply_id', $post_comment_reply_id); } $commentOffset = !empty( $_REQUEST['comment_page'] ) ? ($_REQUEST['comment_page'] - 1) * $maxComments : 0; $gComment = new LibertyComment( NULL, $gContent->mContentId ); // $commentsParentId is the content_id which the comment tree is attached to if (empty($commentsParentId)) { $comments = NULL; $numComments = 0; } else { $comments = $gComment->getComments($commentsParentId, $maxComments, $commentOffset ); $numComments = $gComment->getNumComments($commentsParentId); } $smarty->assign('comments', $comments); $numCommentPages = ceil( $numComments / $maxComments ); $currentPage = !empty( $_REQUEST['comment_page'] ) ? $_REQUEST['comment_page'] : 1; $commentsPgnHash = array( 'numPages' => $numCommentPages, 'pgnName' => 'comment_page', 'page' => $currentPage, 'url' => $comments_return_url, ); $smarty->assign( 'commentsPgnHash', $commentsPgnHash ); $smarty->assign('postComment', $postComment); $smarty->assign('currentTimestamp', time()); $smarty->assign('comments_return_url', $comments_return_url); ?>