2013-04-18 20:34:02 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PHUIBoxView extends AphrontTagView {
|
|
|
|
|
|
|
|
private $margin = array();
|
|
|
|
private $padding = array();
|
2013-08-26 20:53:11 +02:00
|
|
|
private $border = false;
|
2016-01-20 21:18:01 +01:00
|
|
|
private $color;
|
|
|
|
|
|
|
|
const BLUE = 'phui-box-blue';
|
|
|
|
const GREY = 'phui-box-grey';
|
2013-04-18 20:34:02 +02:00
|
|
|
|
|
|
|
public function addMargin($margin) {
|
|
|
|
$this->margin[] = $margin;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addPadding($padding) {
|
|
|
|
$this->padding[] = $padding;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-08-26 20:53:11 +02:00
|
|
|
public function setBorder($border) {
|
|
|
|
$this->border = $border;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2016-01-20 21:18:01 +01:00
|
|
|
public function setColor($color) {
|
|
|
|
$this->color = $color;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-09-06 19:42:44 +02:00
|
|
|
protected function getTagAttributes() {
|
2014-02-20 08:05:42 +01:00
|
|
|
require_celerity_resource('phui-box-css');
|
2013-04-18 20:34:02 +02:00
|
|
|
$outer_classes = array();
|
|
|
|
$outer_classes[] = 'phui-box';
|
2016-01-20 21:18:01 +01:00
|
|
|
|
2013-08-26 20:53:11 +02:00
|
|
|
if ($this->border) {
|
|
|
|
$outer_classes[] = 'phui-box-border';
|
|
|
|
}
|
2016-01-20 21:18:01 +01:00
|
|
|
|
2013-04-18 20:34:02 +02:00
|
|
|
foreach ($this->margin as $margin) {
|
|
|
|
$outer_classes[] = $margin;
|
|
|
|
}
|
2016-01-20 21:18:01 +01:00
|
|
|
|
2014-02-20 08:05:42 +01:00
|
|
|
foreach ($this->padding as $padding) {
|
|
|
|
$outer_classes[] = $padding;
|
|
|
|
}
|
2016-01-20 21:18:01 +01:00
|
|
|
|
|
|
|
if ($this->color) {
|
|
|
|
$outer_classes[] = $this->color;
|
|
|
|
}
|
|
|
|
|
2013-09-06 19:42:44 +02:00
|
|
|
return array('class' => $outer_classes);
|
|
|
|
}
|
|
|
|
|
2015-01-13 20:54:39 +01:00
|
|
|
protected function getTagName() {
|
2013-09-06 19:42:44 +02:00
|
|
|
return 'div';
|
|
|
|
}
|
|
|
|
|
2015-01-13 20:54:39 +01:00
|
|
|
protected function getTagContent() {
|
2014-02-20 08:05:42 +01:00
|
|
|
return $this->renderChildren();
|
2013-04-18 20:34:02 +02:00
|
|
|
}
|
|
|
|
}
|