From be6a19f95ef5d6d7403e2b74485670cd5c5ddc0e Mon Sep 17 00:00:00 2001 From: Adam Lewis Date: Thu, 29 May 2008 08:23:25 -0400 Subject: [PATCH] Support for showing a threaded comment reply inline using ajax. Falls back to default if javascript is disabled. --- comment_body.php | 9 + include/comment.php | 64 +- include/header.php | 1 + prototype-1.6.0.2.js | 4221 ++++++++++++++++++++++++++++++++++++++++++ scripts.js | 27 + 5 files changed, 4316 insertions(+), 6 deletions(-) create mode 100644 comment_body.php create mode 100644 prototype-1.6.0.2.js diff --git a/comment_body.php b/comment_body.php new file mode 100644 index 0000000..a4e0cbe --- /dev/null +++ b/comment_body.php @@ -0,0 +1,9 @@ + diff --git a/include/comment.php b/include/comment.php index 2550889..c47c158 100644 --- a/include/comment.php +++ b/include/comment.php @@ -223,6 +223,20 @@ class Comment { $this->sDateCreated = date("l F jS Y, H:i"); } + /** + * Displays the body of one comment. + */ + function view_comment_body($iCommentId) + { + $hResult = Comment::grab_comment($iCommentId); + + if ($hResult) + { + $oRow = query_fetch_object($hResult); + Comment::view_app_comment($oRow); + } + } + /** * display a single comment (in $oRow) */ @@ -276,6 +290,27 @@ class Comment { echo html_frame_end(); } + /** + * grab single comment for commentId + */ + function grab_comment($iCommentId) + { + $iCommentId = query_escape_string($iCommentId); + + if($iCommentId) + { + $sQuery = "SELECT from_unixtime(unix_timestamp(appComments.time), \"%W %M %D %Y, %k:%i\") as time, ". + "appComments.commentId, appComments.parentId, appComments.versionId, appComments.userId, appComments.subject, appComments.body, appVersion.appId ". + "FROM appComments, appVersion WHERE appComments.commentId = '$iCommentId'"; + + $hResult = query_appdb($sQuery); + + return $hResult; + } + + return null; + } + /** * grab comments for appId / versionId * if parentId is not -1 only comments for that thread are returned @@ -343,6 +378,25 @@ class Comment { Comment::do_display_comments_nested($hResult); } + /** + * Generates the link to show the comment. + */ + function comment_link($oRow) + { + $sLink = "commentview.php?iAppId={$oRow->appId}&iVersionId=". + "{$oRow->versionId}&iThreadId={$oRow->parentId}"; + + $sOnClick = "showComment('{$oRow->commentId}');"; + + /** + * The return false line in the onClick is used to handle javascript + * being disabled so we can fail gracefully to the old style. + */ + return "
  • $oRow->subject". + ' by '.forum_lookup_user($oRow->userId)." on + {$oRow->time}
    commentId}\">
  • \n"; + } + /** * display threaded comments * handle is a db result set @@ -351,7 +405,7 @@ class Comment { { if (!$is_main) echo "