Remove product literal strings in "pht()", part 6
[phabricator.git] / src / applications / differential / engine / DifferentialFileTreeEngine.php
blobfeb1c64ebf3d54f3335654cd0bd9b863bf77e3de
1 <?php
3 final class DifferentialFileTreeEngine
4 extends Phobject {
6 private $viewer;
7 private $changesets;
8 private $disabled;
9 private $ownedChangesets;
11 public function setViewer($viewer) {
12 $this->viewer = $viewer;
13 return $this;
16 public function getViewer() {
17 return $this->viewer;
20 public function getIsVisible() {
21 return (bool)$this->getSetting($this->getVisibleSettingKey());
24 public function setDisabled($disabled) {
25 $this->disabled = $disabled;
26 return $this;
29 public function getDisabled() {
30 return $this->disabled;
33 public function setChangesets(array $changesets) {
34 $this->changesets = $changesets;
35 return $this;
38 public function getChangesets() {
39 return $this->changesets;
42 public function newView($content) {
43 if ($this->getDisabled()) {
44 return $content;
47 require_celerity_resource('diff-tree-view-css');
49 $width = $this->getWidth();
50 $is_visible = $this->getIsVisible();
52 $formation_view = new PHUIFormationView();
54 $flank_view = $formation_view->newFlankColumn()
55 ->setHeaderText(pht('Paths'))
56 ->setIsResizable(true)
57 ->setIsFixed(true)
58 ->setIsVisible($is_visible)
59 ->setIsDesktopOnly(true)
60 ->setWidth($width)
61 ->setMinimumWidth($this->getMinimumWidth())
62 ->setMaximumWidth($this->getMaximumWidth());
64 $viewer = $this->getViewer();
65 if ($viewer->isLoggedIn()) {
66 $flank_view
67 ->setExpanderTooltip(pht('Show Paths Panel'))
68 ->setVisibleSettingKey($this->getVisibleSettingKey())
69 ->setWidthSettingKey($this->getWidthSettingKey());
72 $head_view = id(new PHUIListView())
73 ->addMenuItem(
74 id(new PHUIListItemView())
75 ->setIcon('fa-list')
76 ->setName(pht('Table of Contents'))
77 ->setKeyCommand('t')
78 ->setHref('#'));
79 $flank_view->setHead($head_view);
81 $tail_view = id(new PHUIListView());
83 if ($viewer->isLoggedIn()) {
84 $tail_view->addMenuItem(
85 id(new PHUIListItemView())
86 ->setIcon('fa-comment-o')
87 ->setName(pht('Add Comment'))
88 ->setKeyCommand('x')
89 ->setHref('#'));
92 $tail_view
93 ->addMenuItem(
94 id(new PHUIListItemView())
95 ->setIcon('fa-chevron-left')
96 ->setName(pht('Hide Panel'))
97 ->setKeyCommand('f')
98 ->setHref('#'))
99 ->addMenuItem(
100 id(new PHUIListItemView())
101 ->setIcon('fa-keyboard-o')
102 ->setName(pht('Keyboard Reference'))
103 ->setKeyCommand('?')
104 ->setHref('#'));
105 $flank_view->setTail($tail_view);
107 $main_column = $formation_view->newContentColumn()
108 ->appendChild($content);
110 return $formation_view;
113 private function getVisibleSettingKey() {
114 return PhabricatorFiletreeVisibleSetting::SETTINGKEY;
117 private function getWidthSettingKey() {
118 return PhabricatorFiletreeWidthSetting::SETTINGKEY;
121 private function getWidth() {
122 $width = (int)$this->getSetting($this->getWidthSettingKey());
124 if (!$width) {
125 $width = $this->getDefaultWidth();
128 $min = $this->getMinimumWidth();
129 if ($width < $min) {
130 $width = $min;
133 $max = $this->getMaximumWidth();
134 if ($width > $max) {
135 $width = $max;
138 return $width;
141 private function getDefaultWidth() {
142 return 240;
145 private function getMinimumWidth() {
146 return 150;
149 private function getMaximumWidth() {
150 return 512;
153 private function getSetting($key) {
154 $viewer = $this->getViewer();
155 return $viewer->getUserSetting($key);