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;
|
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;
|
|
|
|
}
|
|
|
|
|
2013-09-06 19:42:44 +02:00
|
|
|
protected function getTagAttributes() {
|
2013-04-18 20:34:02 +02:00
|
|
|
$outer_classes = array();
|
|
|
|
$outer_classes[] = 'phui-box';
|
2013-08-26 20:53:11 +02:00
|
|
|
if ($this->border) {
|
|
|
|
$outer_classes[] = 'phui-box-border';
|
|
|
|
}
|
2013-04-18 20:34:02 +02:00
|
|
|
foreach ($this->margin as $margin) {
|
|
|
|
$outer_classes[] = $margin;
|
|
|
|
}
|
|
|
|
|
2013-09-06 19:42:44 +02:00
|
|
|
return array('class' => $outer_classes);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTagName() {
|
|
|
|
return 'div';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTagContent() {
|
|
|
|
require_celerity_resource('phui-box-css');
|
|
|
|
|
2013-04-18 20:34:02 +02:00
|
|
|
$inner_classes = array();
|
|
|
|
$inner_classes[] = 'phui-box-inner';
|
|
|
|
foreach ($this->padding as $padding) {
|
|
|
|
$inner_classes[] = $padding;
|
|
|
|
}
|
|
|
|
|
2013-09-06 19:42:44 +02:00
|
|
|
return phutil_tag(
|
2013-04-18 20:34:02 +02:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => implode(' ', $inner_classes)
|
|
|
|
),
|
|
|
|
$this->renderChildren());
|
|
|
|
}
|
|
|
|
}
|