2015-08-10 23:55:43 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PHUITwoColumnView extends AphrontTagView {
|
|
|
|
|
|
|
|
private $mainColumn;
|
2016-02-26 23:34:51 +01:00
|
|
|
private $sideColumn = null;
|
2015-12-12 02:23:09 +01:00
|
|
|
private $display;
|
2016-02-23 16:23:58 +01:00
|
|
|
private $fluid;
|
2016-02-17 22:05:24 +01:00
|
|
|
private $header;
|
2016-02-26 23:34:51 +01:00
|
|
|
private $subheader;
|
2016-03-01 21:14:28 +01:00
|
|
|
private $propertySection = array();
|
2016-02-26 23:34:51 +01:00
|
|
|
private $actionList;
|
|
|
|
private $propertyList;
|
2016-03-05 23:45:56 +01:00
|
|
|
private $curtain;
|
2015-12-12 02:23:09 +01:00
|
|
|
|
|
|
|
const DISPLAY_LEFT = 'phui-side-column-left';
|
|
|
|
const DISPLAY_RIGHT = 'phui-side-column-right';
|
2015-08-10 23:55:43 +02:00
|
|
|
|
|
|
|
public function setMainColumn($main) {
|
|
|
|
$this->mainColumn = $main;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setSideColumn($side) {
|
|
|
|
$this->sideColumn = $side;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2016-02-17 22:05:24 +01:00
|
|
|
public function setHeader(PHUIHeaderView $header) {
|
|
|
|
$this->header = $header;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2016-02-26 23:34:51 +01:00
|
|
|
public function setSubheader($subheader) {
|
|
|
|
$this->subheader = $subheader;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2016-03-01 21:14:28 +01:00
|
|
|
public function addPropertySection($title, $section) {
|
|
|
|
$this->propertySection[] = array($title, $section);
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2016-02-26 23:34:51 +01:00
|
|
|
public function setActionList(PhabricatorActionListView $list) {
|
|
|
|
$this->actionList = $list;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setPropertyList(PHUIPropertyListView $list) {
|
|
|
|
$this->propertyList = $list;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2016-03-05 23:45:56 +01:00
|
|
|
public function setCurtain(PHUICurtainView $curtain) {
|
|
|
|
$this->curtain = $curtain;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCurtain() {
|
|
|
|
return $this->curtain;
|
|
|
|
}
|
|
|
|
|
2016-02-23 16:23:58 +01:00
|
|
|
public function setFluid($fluid) {
|
|
|
|
$this->fluid = $fluid;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2015-12-12 02:23:09 +01:00
|
|
|
public function setDisplay($display) {
|
|
|
|
$this->display = $display;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2016-02-23 16:23:58 +01:00
|
|
|
private function getDisplay() {
|
2015-12-12 02:23:09 +01:00
|
|
|
if ($this->display) {
|
|
|
|
return $this->display;
|
|
|
|
} else {
|
|
|
|
return self::DISPLAY_RIGHT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-10 23:55:43 +02:00
|
|
|
protected function getTagAttributes() {
|
2015-12-12 02:23:09 +01:00
|
|
|
$classes = array();
|
|
|
|
$classes[] = 'phui-two-column-view';
|
|
|
|
$classes[] = $this->getDisplay();
|
|
|
|
|
2016-02-23 16:23:58 +01:00
|
|
|
if ($this->fluid) {
|
|
|
|
$classes[] = 'phui-two-column-fluid';
|
|
|
|
}
|
|
|
|
|
2016-02-26 23:34:51 +01:00
|
|
|
if ($this->subheader) {
|
|
|
|
$classes[] = 'with-subheader';
|
|
|
|
}
|
|
|
|
|
2015-08-10 23:55:43 +02:00
|
|
|
return array(
|
2015-12-12 02:23:09 +01:00
|
|
|
'class' => implode(' ', $classes),
|
2015-08-10 23:55:43 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getTagContent() {
|
|
|
|
require_celerity_resource('phui-two-column-view-css');
|
|
|
|
|
2016-03-01 21:14:28 +01:00
|
|
|
$main = $this->buildMainColumn();
|
2016-02-26 23:34:51 +01:00
|
|
|
$side = $this->buildSideColumn();
|
|
|
|
$order = array($side, $main);
|
2015-08-10 23:55:43 +02:00
|
|
|
|
2016-02-26 23:34:51 +01:00
|
|
|
$inner = phutil_tag_div('phui-two-column-row grouped', $order);
|
2016-02-17 22:05:24 +01:00
|
|
|
$table = phutil_tag_div('phui-two-column-content', $inner);
|
|
|
|
|
|
|
|
$header = null;
|
|
|
|
if ($this->header) {
|
2016-03-05 23:45:56 +01:00
|
|
|
$curtain = $this->getCurtain();
|
|
|
|
if ($curtain) {
|
|
|
|
$action_list = $curtain->getActionList();
|
|
|
|
} else {
|
|
|
|
$action_list = $this->actionList;
|
2016-02-26 23:34:51 +01:00
|
|
|
}
|
2016-03-05 23:45:56 +01:00
|
|
|
|
|
|
|
if ($action_list) {
|
|
|
|
$this->header->setActionList($action_list);
|
|
|
|
}
|
|
|
|
|
2016-02-26 23:34:51 +01:00
|
|
|
$header = phutil_tag_div(
|
|
|
|
'phui-two-column-header', $this->header);
|
|
|
|
}
|
|
|
|
|
|
|
|
$subheader = null;
|
|
|
|
if ($this->subheader) {
|
|
|
|
$subheader = phutil_tag_div(
|
|
|
|
'phui-two-column-subheader', $this->subheader);
|
2016-02-17 22:05:24 +01:00
|
|
|
}
|
|
|
|
|
2016-02-23 16:23:58 +01:00
|
|
|
return phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phui-two-column-container',
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
$header,
|
2016-02-26 23:34:51 +01:00
|
|
|
$subheader,
|
2016-02-23 16:23:58 +01:00
|
|
|
$table,
|
|
|
|
));
|
2015-08-10 23:55:43 +02:00
|
|
|
}
|
2016-02-26 23:34:51 +01:00
|
|
|
|
2016-03-01 21:14:28 +01:00
|
|
|
private function buildMainColumn() {
|
|
|
|
|
|
|
|
$view = array();
|
|
|
|
$sections = $this->propertySection;
|
|
|
|
|
|
|
|
if ($sections) {
|
|
|
|
foreach ($sections as $content) {
|
2016-03-03 01:23:11 +01:00
|
|
|
if ($content[1]) {
|
|
|
|
$view[] = id(new PHUIObjectBoxView())
|
|
|
|
->setHeaderText($content[0])
|
|
|
|
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
|
|
|
->appendChild($content[1]);
|
|
|
|
}
|
2016-03-01 21:14:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phui-main-column',
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
$view,
|
|
|
|
$this->mainColumn,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2016-02-26 23:34:51 +01:00
|
|
|
private function buildSideColumn() {
|
|
|
|
$property_list = $this->propertyList;
|
|
|
|
$action_list = $this->actionList;
|
|
|
|
|
|
|
|
$properties = null;
|
|
|
|
if ($property_list || $action_list) {
|
|
|
|
if ($property_list) {
|
|
|
|
$property_list->setStacked(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
$properties = id(new PHUIObjectBoxView())
|
|
|
|
->appendChild($action_list)
|
|
|
|
->appendChild($property_list)
|
|
|
|
->addClass('phui-two-column-properties');
|
|
|
|
}
|
|
|
|
|
2016-03-05 23:45:56 +01:00
|
|
|
$curtain = $this->getCurtain();
|
|
|
|
|
2016-02-26 23:34:51 +01:00
|
|
|
return phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phui-side-column',
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
$properties,
|
2016-03-05 23:45:56 +01:00
|
|
|
$curtain,
|
2016-02-26 23:34:51 +01:00
|
|
|
$this->sideColumn,
|
|
|
|
));
|
|
|
|
}
|
2015-08-10 23:55:43 +02:00
|
|
|
}
|