2012-08-15 19:45:06 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorObjectItemView extends AphrontView {
|
|
|
|
|
|
|
|
private $header;
|
|
|
|
private $href;
|
2012-10-01 05:08:22 +02:00
|
|
|
private $attributes = array();
|
2012-08-15 19:45:06 +02:00
|
|
|
private $details = array();
|
|
|
|
private $dates = array();
|
2012-12-13 19:59:29 +01:00
|
|
|
private $icons = array();
|
|
|
|
private $barColor;
|
|
|
|
private $object;
|
|
|
|
|
|
|
|
public function setObject($object) {
|
|
|
|
$this->object = $object;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getObject() {
|
|
|
|
return $this->object;
|
|
|
|
}
|
2012-08-15 19:45:06 +02:00
|
|
|
|
|
|
|
public function setHref($href) {
|
|
|
|
$this->href = $href;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getHref() {
|
|
|
|
return $this->href;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setHeader($header) {
|
|
|
|
$this->header = $header;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getHeader() {
|
|
|
|
return $this->header;
|
|
|
|
}
|
|
|
|
|
2012-12-13 19:59:29 +01:00
|
|
|
public function addIcon($icon, $label = null) {
|
|
|
|
$this->icons[] = array(
|
|
|
|
'icon' => $icon,
|
|
|
|
'label' => $label,
|
2012-08-15 19:45:06 +02:00
|
|
|
);
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-12-13 19:59:29 +01:00
|
|
|
public function setBarColor($bar_color) {
|
|
|
|
$this->barColor = $bar_color;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getBarColor() {
|
|
|
|
return $this->barColor;
|
|
|
|
}
|
|
|
|
|
2012-08-15 19:45:06 +02:00
|
|
|
public function addAttribute($attribute) {
|
|
|
|
$this->attributes[] = $attribute;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function render() {
|
|
|
|
$header = phutil_render_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $this->href,
|
|
|
|
'class' => 'phabricator-object-item-name',
|
|
|
|
),
|
|
|
|
phutil_escape_html($this->header));
|
|
|
|
|
2012-12-13 19:59:29 +01:00
|
|
|
$icons = null;
|
|
|
|
if ($this->icons) {
|
|
|
|
$icon_list = array();
|
|
|
|
foreach ($this->icons as $spec) {
|
|
|
|
$icon = $spec['icon'];
|
|
|
|
|
|
|
|
$icon = phutil_render_tag(
|
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-object-item-icon-image '.
|
|
|
|
'sprite-icon action-'.$icon,
|
|
|
|
),
|
|
|
|
'');
|
|
|
|
|
|
|
|
$label = phutil_render_tag(
|
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-object-item-icon-label',
|
|
|
|
),
|
|
|
|
phutil_escape_html($spec['label']));
|
|
|
|
|
|
|
|
$icon_list[] = phutil_render_tag(
|
|
|
|
'li',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-object-item-icon',
|
|
|
|
),
|
|
|
|
$label.$icon);
|
2012-08-15 19:45:06 +02:00
|
|
|
}
|
2012-12-13 19:59:29 +01:00
|
|
|
|
|
|
|
$icons = phutil_render_tag(
|
|
|
|
'ul',
|
2012-08-15 19:45:06 +02:00
|
|
|
array(
|
2012-12-13 19:59:29 +01:00
|
|
|
'class' => 'phabricator-object-item-icons',
|
2012-08-15 19:45:06 +02:00
|
|
|
),
|
2012-12-13 19:59:29 +01:00
|
|
|
implode('', $icon_list));
|
2012-08-15 19:45:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$attrs = null;
|
|
|
|
if ($this->attributes) {
|
|
|
|
$attrs = array();
|
2012-12-13 19:59:29 +01:00
|
|
|
$spacer = phutil_render_tag(
|
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-object-item-attribute-spacer',
|
|
|
|
),
|
|
|
|
'·');
|
|
|
|
$first = true;
|
2012-08-15 19:45:06 +02:00
|
|
|
foreach ($this->attributes as $attribute) {
|
2012-12-13 19:59:29 +01:00
|
|
|
$attrs[] = phutil_render_tag(
|
|
|
|
'li',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-object-item-attribute',
|
|
|
|
),
|
|
|
|
($first ? null : $spacer).$attribute);
|
|
|
|
$first = false;
|
2012-08-15 19:45:06 +02:00
|
|
|
}
|
|
|
|
$attrs = phutil_render_tag(
|
|
|
|
'ul',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-object-item-attributes',
|
|
|
|
),
|
|
|
|
implode('', $attrs));
|
|
|
|
}
|
|
|
|
|
2012-12-13 19:59:29 +01:00
|
|
|
$classes = array();
|
|
|
|
$classes[] = 'phabricator-object-item';
|
|
|
|
if ($this->barColor) {
|
|
|
|
$classes[] = 'phabricator-object-item-bar-color-'.$this->barColor;
|
|
|
|
}
|
|
|
|
|
2012-08-15 19:45:06 +02:00
|
|
|
return phutil_render_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
2012-12-13 19:59:29 +01:00
|
|
|
'class' => implode(' ', $classes),
|
2012-08-15 19:45:06 +02:00
|
|
|
),
|
2012-12-16 21:02:34 +01:00
|
|
|
$icons.$header.$attrs.$this->renderChildren());
|
2012-08-15 19:45:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|