inlineComment = $comment; return $this; } public function setOnRight($on_right) { $this->onRight = $on_right; return $this; } public function setBuildScaffolding($scaffold) { $this->buildScaffolding = $scaffold; return $this; } public function setHandles(array $handles) { $this->handles = $handles; return $this; } public function setMarkupEngine(PhutilMarkupEngine $engine) { $this->markupEngine = $engine; return $this; } public function setEditable($editable) { $this->editable = $editable; return $this; } public function setPreview($preview) { $this->preview = $preview; } public function render() { $inline = $this->inlineComment; $start = $inline->getLineNumber(); $length = $inline->getLineLength(); if ($length) { $end = $start + $length; $line = 'Lines '.number_format($start).'-'.number_format($end); } else { $line = 'Line '.number_format($start); } $metadata = array( 'id' => $inline->getID(), 'number' => $inline->getLineNumber(), 'length' => $inline->getLineLength(), 'on_right' => $this->onRight, 'original' => $inline->getContent(), ); $sigil = 'differential-inline-comment'; $content = $inline->getContent(); $handles = $this->handles; $links = array(); $is_draft = false; if (!$inline->getCommentID()) { $links[] = 'Not Submitted Yet'; $is_draft = true; } if (!$this->preview) { $links[] = javelin_render_tag( 'a', array( 'href' => '#', 'mustcapture' => true, 'sigil' => 'differential-inline-prev', ), 'Previous'); $links[] = javelin_render_tag( 'a', array( 'href' => '#', 'mustcapture' => true, 'sigil' => 'differential-inline-next', ), 'Next'); $links[] = javelin_render_tag( 'a', array( 'href' => '#', 'mustcapture' => true, 'sigil' => 'differential-inline-reply', ), 'Reply'); } if ($this->editable && !$this->preview) { $links[] = javelin_render_tag( 'a', array( 'href' => '#', 'mustcapture' => true, 'sigil' => 'differential-inline-edit', ), 'Edit'); $links[] = javelin_render_tag( 'a', array( 'href' => '#', 'mustcapture' => true, 'sigil' => 'differential-inline-delete', ), 'Delete'); } if ($links) { $links = ''. implode(' · ', $links). ''; } else { $links = null; } $cache = $inline->getCache(); if (strlen($cache)) { $content = $cache; } else { $content = $this->markupEngine->markupText($content); if ($inline->getID()) { $inline->setCache($content); $inline->save(); } } $anchor = phutil_render_tag( 'a', array( 'name' => 'inline-'.$inline->getID(), ), ''); $classes = array( 'differential-inline-comment', ); if ($is_draft) { $classes[] = 'differential-inline-comment-unsaved-draft'; } $classes = implode(' ', $classes); $markup = javelin_render_tag( 'div', array( 'class' => $classes, 'sigil' => $sigil, 'meta' => $metadata, ), '
'. $anchor. $links. ''.$line.''. phutil_escape_html($handles[$inline->getAuthorPHID()]->getName()). '
'. '
'. $content. '
'); return $this->scaffoldMarkup($markup); } private function scaffoldMarkup($markup) { if (!$this->buildScaffolding) { return $markup; } $left_markup = !$this->onRight ? $markup : ''; $right_markup = $this->onRight ? $markup : ''; return ''. ''. ''. ''. ''. ''. ''. '
'.$left_markup.''.$right_markup.'
'; } }