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;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2015-12-12 02:23:09 +01:00
|
|
|
public function setDisplay($display) {
|
|
|
|
$this->display = $display;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDisplay() {
|
|
|
|
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[] = 'grouped';
|
|
|
|
$classes[] = $this->getDisplay();
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
return phutil_tag_div('phui-two-column-row', $order);
|
2015-08-10 23:55:43 +02:00
|
|
|
}
|
|
|
|
}
|