[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class DifferentialChangesetFileTreeSideNavBuilder { 4 5 private $title; 6 private $baseURI; 7 private $anchorName; 8 private $collapsed = false; 9 10 public function setAnchorName($anchor_name) { 11 $this->anchorName = $anchor_name; 12 return $this; 13 } 14 public function getAnchorName() { 15 return $this->anchorName; 16 } 17 18 public function setBaseURI(PhutilURI $base_uri) { 19 $this->baseURI = $base_uri; 20 return $this; 21 } 22 public function getBaseURI() { 23 return $this->baseURI; 24 } 25 26 public function setTitle($title) { 27 $this->title = $title; 28 return $this; 29 } 30 public function getTitle() { 31 return $this->title; 32 } 33 34 public function setCollapsed($collapsed) { 35 $this->collapsed = $collapsed; 36 return $this; 37 } 38 39 public function build(array $changesets) { 40 assert_instances_of($changesets, 'DifferentialChangeset'); 41 42 $nav = new AphrontSideNavFilterView(); 43 $nav->setBaseURI($this->getBaseURI()); 44 $nav->setFlexible(true); 45 $nav->setCollapsed($this->collapsed); 46 47 $anchor = $this->getAnchorName(); 48 49 $tree = new PhutilFileTree(); 50 foreach ($changesets as $changeset) { 51 try { 52 $tree->addPath($changeset->getFilename(), $changeset); 53 } catch (Exception $ex) { 54 // TODO: See T1702. When viewing the versus diff of diffs, we may 55 // have files with the same filename. For example, if you have a setup 56 // like this in SVN: 57 // 58 // a/ 59 // README 60 // b/ 61 // README 62 // 63 // ...and you run "arc diff" once from a/, and again from b/, you'll 64 // get two diffs with path README. However, in the versus diff view we 65 // will compute their absolute repository paths and detect that they 66 // aren't really the same file. This is correct, but causes us to 67 // throw when inserting them. 68 // 69 // We should probably compute the smallest unique path for each file 70 // and show these as "a/README" and "b/README" when diffed against 71 // one another. However, we get this wrong in a lot of places (the 72 // other TOC shows two "README" files, and we generate the same anchor 73 // hash for both) so I'm just stopping the bleeding until we can get 74 // a proper fix in place. 75 } 76 } 77 78 require_celerity_resource('phabricator-filetree-view-css'); 79 80 $filetree = array(); 81 82 $path = $tree; 83 while (($path = $path->getNextNode())) { 84 $data = $path->getData(); 85 86 $name = $path->getName(); 87 $style = 'padding-left: '.(2 + (3 * $path->getDepth())).'px'; 88 89 $href = null; 90 if ($data) { 91 $href = '#'.$data->getAnchorName(); 92 $title = $name; 93 $icon = id(new PHUIIconView()) 94 ->setIconFont('fa-file-text-o bluetext'); 95 } else { 96 $name .= '/'; 97 $title = $path->getFullPath().'/'; 98 $icon = id(new PHUIIconView()) 99 ->setIconFont('fa-folder-open blue'); 100 } 101 102 $name_element = phutil_tag( 103 'span', 104 array( 105 'class' => 'phabricator-filetree-name', 106 ), 107 $name); 108 109 $filetree[] = javelin_tag( 110 $href ? 'a' : 'span', 111 array( 112 'href' => $href, 113 'style' => $style, 114 'title' => $title, 115 'class' => 'phabricator-filetree-item', 116 ), 117 array($icon, $name_element)); 118 } 119 $tree->destroy(); 120 121 $filetree = phutil_tag( 122 'div', 123 array( 124 'class' => 'phabricator-filetree', 125 ), 126 $filetree); 127 128 Javelin::initBehavior('phabricator-file-tree', array()); 129 130 $nav->addLabel(pht('Changed Files')); 131 $nav->addCustomBlock($filetree); 132 $nav->setActive(true); 133 $nav->selectFilter(null); 134 return $nav; 135 } 136 137 }
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 |