Differential D21242 Diff 50589 src/applications/differential/mail/DifferentialInlineCommentMailView.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/mail/DifferentialInlineCommentMailView.php
| Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | foreach ($groups as $changeset_id => $group) { | ||||
| $is_last_group = ($changeset_id == $last_group_key); | $is_last_group = ($changeset_id == $last_group_key); | ||||
| $last_inline_key = last_key($group); | $last_inline_key = last_key($group); | ||||
| foreach ($group as $inline_key => $inline) { | foreach ($group as $inline_key => $inline) { | ||||
| $comment = $inline->getComment(); | $comment = $inline->getComment(); | ||||
| $parent_phid = $comment->getReplyToCommentPHID(); | $parent_phid = $comment->getReplyToCommentPHID(); | ||||
| $inline_object = $comment->newInlineCommentObject(); | |||||
| $document_engine_key = $inline_object->getDocumentEngineKey(); | |||||
| $is_last_inline = ($inline_key == $last_inline_key); | $is_last_inline = ($inline_key == $last_inline_key); | ||||
| $context_text = null; | $context_text = null; | ||||
| $context_html = null; | $context_html = null; | ||||
| if ($parent_phid) { | if ($parent_phid) { | ||||
| $parent = idx($parents, $parent_phid); | $parent = idx($parents, $parent_phid); | ||||
| if ($parent) { | if ($parent) { | ||||
| $context_text = $this->renderInline($parent, false, true); | $context_text = $this->renderInline($parent, false, true); | ||||
| $context_html = $this->renderInline($parent, true, true); | $context_html = $this->renderInline($parent, true, true); | ||||
| } | } | ||||
| } else if ($document_engine_key !== null) { | |||||
| // See T13513. If an inline was left on a rendered document, don't | |||||
| // include the patch context. Document engines currently can not | |||||
| // render to mail targets, and using the line numbers as raw source | |||||
| // lines produces misleading context. | |||||
| $patch_text = null; | |||||
| $context_text = $this->renderPatch($comment, $patch_text, false); | |||||
| $patch_html = null; | |||||
| $context_html = $this->renderPatch($comment, $patch_html, true); | |||||
| } else { | } else { | ||||
| $patch_text = $this->getPatch($hunk_parser, $comment, false); | $patch_text = $this->getPatch($hunk_parser, $comment, false); | ||||
| $context_text = $this->renderPatch($comment, $patch_text, false); | $context_text = $this->renderPatch($comment, $patch_text, false); | ||||
| $patch_html = $this->getPatch($hunk_parser, $comment, true); | $patch_html = $this->getPatch($hunk_parser, $comment, true); | ||||
| $context_html = $this->renderPatch($comment, $patch_html, true); | $context_html = $this->renderPatch($comment, $patch_html, true); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 288 Lines • ▼ Show 20 Lines | final class DifferentialInlineCommentMailView | ||||
| } | } | ||||
| private function renderPatch( | private function renderPatch( | ||||
| DifferentialTransactionComment $comment, | DifferentialTransactionComment $comment, | ||||
| $patch, | $patch, | ||||
| $is_html) { | $is_html) { | ||||
| if ($is_html) { | if ($is_html) { | ||||
| if ($patch !== null) { | |||||
| $patch = $this->renderCodeBlock($patch); | $patch = $this->renderCodeBlock($patch); | ||||
| } | } | ||||
| } | |||||
| $header = $this->renderHeader($comment, $is_html, false); | $header = $this->renderHeader($comment, $is_html, false); | ||||
| if ($patch === null) { | |||||
| $patch = array( | |||||
| $header, | |||||
| ); | |||||
| } else { | |||||
| $patch = array( | $patch = array( | ||||
| $header, | $header, | ||||
| "\n", | "\n", | ||||
| $patch, | $patch, | ||||
| ); | ); | ||||
| } | |||||
| if (!$is_html) { | if (!$is_html) { | ||||
| $patch = implode('', $patch); | $patch = implode('', $patch); | ||||
| $patch = $this->quoteText($patch); | $patch = $this->quoteText($patch); | ||||
| } else { | } else { | ||||
| $patch = $this->quoteHTML($patch); | $patch = $this->quoteHTML($patch); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 103 Lines • Show Last 20 Lines | |||||