2015-08-10 23:55:43 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PHUITwoColumnView extends AphrontTagView {
|
|
|
|
|
|
|
|
private $mainColumn;
|
|
|
|
private $sideColumn;
|
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;
|
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-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';
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
$side = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phui-side-column',
|
|
|
|
),
|
|
|
|
$this->sideColumn);
|
|
|
|
|
2015-12-12 02:23:09 +01:00
|
|
|
if ($this->getDisplay() == self::DISPLAY_LEFT) {
|
|
|
|
$order = array($side, $main);
|
|
|
|
} else {
|
|
|
|
$order = array($main, $side);
|
|
|
|
}
|
|
|
|
|
2016-02-17 22:05:24 +01:00
|
|
|
$inner = phutil_tag_div('phui-two-column-row', $order);
|
|
|
|
$table = phutil_tag_div('phui-two-column-content', $inner);
|
|
|
|
|
|
|
|
$header = null;
|
|
|
|
if ($this->header) {
|
|
|
|
$header = phutil_tag_div('phui-two-column-header', $this->header);
|
|
|
|
}
|
|
|
|
|
2016-02-23 16:23:58 +01:00
|
|
|
return phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phui-two-column-container',
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
$header,
|
|
|
|
$table,
|
|
|
|
));
|
2015-08-10 23:55:43 +02:00
|
|
|
}
|
|
|
|
}
|