From cd6eb836f6ca73c7aa17ddfd65beb062c82836fe Mon Sep 17 00:00:00 2001 From: Hua Wang Date: Wed, 31 Aug 2011 23:18:38 -0700 Subject: [PATCH] Enable comments for image Summary: Added line number 1 for each image and added code to display the comments for each image. Test Plan: Adding an image in my local directory and create a revision for it. Click line number 1, and the comment window prompts. Adding and save the comment. The comment shows in the differential comment list and in the inline comment. Submit the comment. Create more comments for the image and the "Previous" and "Next" buttons all work well. Reviewers: epriestley, jungejason CC: Differential Revision: 901 --- .../changeset/DifferentialChangesetParser.php | 50 +++++++++++++++++-- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/src/applications/differential/parser/changeset/DifferentialChangesetParser.php b/src/applications/differential/parser/changeset/DifferentialChangesetParser.php index fe0878b8c9..b8ace11c4d 100644 --- a/src/applications/differential/parser/changeset/DifferentialChangesetParser.php +++ b/src/applications/differential/parser/changeset/DifferentialChangesetParser.php @@ -899,22 +899,66 @@ class DifferentialChangesetParser { } } + $this->comments = msort($this->comments, 'getID'); + $old_comments = array(); + $new_comments = array(); + foreach ($this->comments as $comment) { + if ($this->isCommentOnRightSideWhenDisplayed($comment)) { + $new_comments[] = $comment; + } else { + $old_comments[] = $comment; + } + } + + $html_old = array(); + $html_new = array(); + foreach ($old_comments as $comment) { + $xhp = $this->renderInlineComment($comment); + $html_old[] = + ''. + $xhp. + ''; + } + foreach ($new_comments as $comment) { + $xhp = $this->renderInlineComment($comment); + $html_new[] = + ''. + $xhp. + ''; + } + + $changset_id = $this->changeset->getID(); + if (!$old) { + $th_old = ''; + } + else { + $th_old = '1'; + } + if (!$cur) { + $th_new = ''; + } + else { + $th_new = '1'; + } + $output = $this->renderChangesetTable( $this->changeset, ''. - ''. + $th_old. ''. '
'. $old. '
'. ''. - ''. + $th_new. ''. '
'. $cur. '
'. ''. - ''); + ''. + implode('', $html_old). + implode('', $html_new)); return $output; case DifferentialChangeType::FILE_DIRECTORY: