[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorInlineSummaryView extends AphrontView { 4 5 private $groups = array(); 6 7 public function addCommentGroup($name, array $items) { 8 if (!isset($this->groups[$name])) { 9 $this->groups[$name] = $items; 10 } else { 11 $this->groups[$name] = array_merge($this->groups[$name], $items); 12 } 13 return $this; 14 } 15 16 public function render() { 17 require_celerity_resource('inline-comment-summary-css'); 18 return hsprintf('%s%s', $this->renderHeader(), $this->renderTable()); 19 } 20 21 private function renderHeader() { 22 $icon = id(new PHUIIconView()) 23 ->setIconFont('fa-comment bluegrey msr'); 24 25 $header = phutil_tag_div( 26 'phabricator-inline-summary', 27 array( 28 $icon, 29 pht('Inline Comments'), 30 )); 31 return $header; 32 } 33 34 private function renderTable() { 35 $rows = array(); 36 foreach ($this->groups as $group => $items) { 37 38 $has_where = false; 39 foreach ($items as $item) { 40 if (!empty($item['where'])) { 41 $has_where = true; 42 break; 43 } 44 } 45 46 $rows[] = phutil_tag( 47 'tr', 48 array(), 49 phutil_tag('th', array('colspan' => 3), $group)); 50 51 foreach ($items as $item) { 52 $line = $item['line']; 53 $length = $item['length']; 54 if ($length) { 55 $lines = $line."\xE2\x80\x93".($line + $length); 56 } else { 57 $lines = $line; 58 } 59 60 if (isset($item['href'])) { 61 $href = $item['href']; 62 $target = '_blank'; 63 $tail = " \xE2\x86\x97"; 64 } else { 65 $href = '#inline-'.$item['id']; 66 $target = null; 67 $tail = null; 68 } 69 70 if ($href) { 71 $icon = id(new PHUIIconView()) 72 ->setIconFont('fa-share white msr'); 73 74 $lines = phutil_tag( 75 'a', 76 array( 77 'href' => $href, 78 'target' => $target, 79 'class' => 'num', 80 ), 81 array( 82 $icon, 83 $lines, 84 $tail, 85 )); 86 } 87 88 $where = idx($item, 'where'); 89 90 $colspan = ($has_where ? null : 2); 91 $rows[] = phutil_tag( 92 'tr', 93 array(), 94 array( 95 phutil_tag('td', array('class' => 'inline-line-number'), $lines), 96 ($has_where 97 ? phutil_tag('td', array('class' => 'inline-which-diff'), $where) 98 : null), 99 phutil_tag( 100 'td', 101 array( 102 'class' => 'inline-summary-content', 103 'colspan' => $colspan, 104 ), 105 phutil_tag_div('phabricator-remarkup', $item['content'])), 106 )); 107 } 108 } 109 110 return phutil_tag( 111 'table', 112 array( 113 'class' => 'phabricator-inline-summary-table', 114 ), 115 phutil_implode_html("\n", $rows)); 116 } 117 118 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |