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;
|
|
|
|
private $actionList;
|
|
|
|
private $propertyList;
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setActionList(PhabricatorActionListView $list) {
|
|
|
|
$this->actionList = $list;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setPropertyList(PHUIPropertyListView $list) {
|
|
|
|
$this->propertyList = $list;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
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');
|
|
|
|
|
|
|
|
$main = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phui-main-column',
|
|
|
|
),
|
|
|
|
$this->mainColumn);
|
|
|
|
|
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-02-26 23:34:51 +01:00
|
|
|
if ($this->actionList) {
|
|
|
|
$this->header->setActionList($this->actionList);
|
|
|
|
}
|
|
|
|
$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
|
|
|
|
|
|
|
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');
|
|
|
|
}
|
|
|
|
|
|
|
|
return phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phui-side-column',
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
$properties,
|
|
|
|
$this->sideColumn,
|
|
|
|
));
|
|
|
|
}
|
2015-08-10 23:55:43 +02:00
|
|
|
}
|