Path: blob/master/src/infrastructure/diff/view/PhabricatorInlineSummaryView.php
12242 views
<?php12final class PhabricatorInlineSummaryView extends AphrontView {34private $groups = array();56public function addCommentGroup($name, array $items) {7if (!isset($this->groups[$name])) {8$this->groups[$name] = $items;9} else {10$this->groups[$name] = array_merge($this->groups[$name], $items);11}12return $this;13}1415public function render() {16require_celerity_resource('inline-comment-summary-css');17return hsprintf('%s', $this->renderTable());18}1920private function renderTable() {21$rows = array();22foreach ($this->groups as $group => $items) {2324$has_where = false;25foreach ($items as $item) {26if (!empty($item['where'])) {27$has_where = true;28break;29}30}3132$icon = id(new PHUIIconView())33->setIcon('fa-file-code-o darkbluetext mmr');34$header = phutil_tag(35'th',36array(37'colspan' => 3,38'class' => 'inline-comment-summary-table-header',39),40array(41$icon,42$group,43));44$rows[] = phutil_tag('tr', array(), $header);4546foreach ($items as $item) {47$line = $item['line'];48$length = $item['length'];49if ($length) {50$lines = $line."\xE2\x80\x93".($line + $length);51} else {52$lines = $line;53}5455if (isset($item['href'])) {56$href = $item['href'];57$target = '_blank';58$tail = " \xE2\x86\x97";59} else {60$href = '#inline-'.$item['id'];61$target = null;62$tail = null;63}6465if ($href) {66$icon = id(new PHUIIconView())67->setIcon('fa-share darkbluetext mmr');6869$lines = phutil_tag(70'a',71array(72'href' => $href,73'target' => $target,74'class' => 'num',75),76array(77$icon,78$lines,79$tail,80));81}8283$where = idx($item, 'where');8485$colspan = ($has_where ? null : 2);86$rows[] = phutil_tag(87'tr',88array(),89array(90phutil_tag('td',91array('class' => 'inline-line-number inline-table-dolumn'),92$lines),93($has_where94? phutil_tag('td',95array('class' => 'inline-which-diff inline-table-dolumn'),96$where)97: null),98phutil_tag(99'td',100array(101'class' => 'inline-summary-content inline-table-dolumn',102'colspan' => $colspan,103),104phutil_tag_div('phabricator-remarkup', $item['content'])),105));106}107}108109return phutil_tag(110'table',111array(112'class' => 'phabricator-inline-summary-table',113),114phutil_implode_html("\n", $rows));115}116117}118119120