Generate file attachment transactions for explicit Remarkup attachments on common...
[phabricator.git] / src / view / phui / PHUITwoColumnView.php
blobcf4abe3a4069e89795b0f40a2c5ae677e1958b5e
1 <?php
3 final class PHUITwoColumnView extends AphrontTagView {
5 private $mainColumn;
6 private $sideColumn = null;
7 private $navigation;
8 private $display;
9 private $fixed;
10 private $header;
11 private $subheader;
12 private $footer;
13 private $tabs;
14 private $propertySection = array();
15 private $curtain;
17 const DISPLAY_LEFT = 'phui-side-column-left';
18 const DISPLAY_RIGHT = 'phui-side-column-right';
20 public function setMainColumn($main) {
21 $this->mainColumn = $main;
22 return $this;
25 public function setSideColumn($side) {
26 $this->sideColumn = $side;
27 return $this;
30 public function setNavigation($nav) {
31 $this->navigation = $nav;
32 $this->display = self::DISPLAY_LEFT;
33 return $this;
36 public function setHeader(PHUIHeaderView $header) {
37 $this->header = $header;
38 return $this;
41 public function setSubheader($subheader) {
42 $this->subheader = $subheader;
43 return $this;
46 public function setTabs(PHUIListView $tabs) {
47 $tabs->setType(PHUIListView::TABBAR_LIST);
48 $this->tabs = $tabs;
49 return $this;
52 public function setFooter($footer) {
53 $this->footer = $footer;
54 return $this;
57 public function addPropertySection($title, $section) {
58 $this->propertySection[] = array(
59 'header' => $title,
60 'content' => $section,
62 return $this;
65 public function setCurtain(PHUICurtainView $curtain) {
66 $this->curtain = $curtain;
67 return $this;
70 public function getCurtain() {
71 return $this->curtain;
74 public function setFixed($fixed) {
75 $this->fixed = $fixed;
76 return $this;
79 public function setDisplay($display) {
80 $this->display = $display;
81 return $this;
84 private function getDisplay() {
85 if ($this->display) {
86 return $this->display;
87 } else {
88 return self::DISPLAY_RIGHT;
92 protected function getTagAttributes() {
93 $classes = array();
94 $classes[] = 'phui-two-column-view';
95 $classes[] = $this->getDisplay();
97 if ($this->fixed) {
98 $classes[] = 'phui-two-column-fixed';
101 if ($this->tabs) {
102 $classes[] = 'with-tabs';
105 if ($this->subheader) {
106 $classes[] = 'with-subheader';
109 if (!$this->header) {
110 $classes[] = 'without-header';
113 return array(
114 'class' => implode(' ', $classes),
118 protected function getTagContent() {
119 require_celerity_resource('phui-two-column-view-css');
121 $main = $this->buildMainColumn();
122 $side = $this->buildSideColumn();
123 $footer = $this->buildFooter();
125 $order = array($side, $main);
127 $inner = phutil_tag_div('phui-two-column-row grouped', $order);
128 $table = phutil_tag_div('phui-two-column-content', $inner);
130 $header = null;
131 if ($this->header) {
132 $curtain = $this->getCurtain();
133 if ($curtain) {
134 $action_list = $curtain->getActionList();
135 $this->header->setActionListID($action_list->getID());
138 $header = phutil_tag_div(
139 'phui-two-column-header', $this->header);
142 $tabs = null;
143 if ($this->tabs) {
144 $tabs = phutil_tag_div(
145 'phui-two-column-tabs', $this->tabs);
148 $subheader = null;
149 if ($this->subheader) {
150 $subheader = phutil_tag_div(
151 'phui-two-column-subheader', $this->subheader);
154 return phutil_tag(
155 'div',
156 array(
157 'class' => 'phui-two-column-container',
159 array(
160 $header,
161 $tabs,
162 $subheader,
163 $table,
164 $footer,
168 private function buildMainColumn() {
170 $view = array();
171 $sections = $this->propertySection;
173 if ($sections) {
174 foreach ($sections as $section) {
175 $section_header = $section['header'];
177 $section_content = $section['content'];
178 if ($section_content === null) {
179 continue;
182 if ($section_header instanceof PHUIHeaderView) {
183 $header = $section_header;
184 } else {
185 $header = id(new PHUIHeaderView())
186 ->setHeader($section_header);
189 $view[] = id(new PHUIObjectBoxView())
190 ->setHeader($header)
191 ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
192 ->appendChild($section_content);
196 return phutil_tag(
197 'div',
198 array(
199 'class' => 'phui-main-column',
201 array(
202 $view,
203 $this->mainColumn,
207 private function buildSideColumn() {
209 $classes = array();
210 $classes[] = 'phui-side-column';
211 $navigation = null;
212 if ($this->navigation) {
213 $classes[] = 'side-has-nav';
214 $navigation = id(new PHUIObjectBoxView())
215 ->appendChild($this->navigation);
218 $curtain = $this->getCurtain();
220 return phutil_tag(
221 'div',
222 array(
223 'class' => implode(' ', $classes),
225 array(
226 $navigation,
227 $curtain,
228 $this->sideColumn,
232 private function buildFooter() {
234 $footer = $this->footer;
236 return phutil_tag(
237 'div',
238 array(
239 'class' => 'phui-two-column-content phui-two-column-footer',
241 array(
242 $footer,