2013-04-05 16:40:27 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorActionHeaderView extends AphrontView {
|
|
|
|
|
|
|
|
const ICON_GREY = 'grey';
|
|
|
|
const ICON_WHITE = 'white';
|
|
|
|
|
|
|
|
const HEADER_GREY = 'grey';
|
2013-04-10 00:50:48 +02:00
|
|
|
const HEADER_DARK_GREY = 'dark-grey';
|
2013-04-05 16:40:27 +02:00
|
|
|
const HEADER_BLUE = 'blue';
|
|
|
|
const HEADER_GREEN = 'green';
|
|
|
|
const HEADER_RED = 'red';
|
|
|
|
const HEADER_YELLOW = 'yellow';
|
2013-08-26 20:53:11 +02:00
|
|
|
const HEADER_LIGHTBLUE ='lightblue';
|
2013-04-05 16:40:27 +02:00
|
|
|
|
|
|
|
private $headerTitle;
|
|
|
|
private $headerHref;
|
|
|
|
private $headerIcon;
|
2013-05-24 19:50:18 +02:00
|
|
|
private $headerSigils = array();
|
2013-04-05 16:40:27 +02:00
|
|
|
private $actions = array();
|
|
|
|
private $iconColor = PhabricatorActionHeaderView::ICON_GREY;
|
|
|
|
private $headerColor;
|
2013-05-24 19:50:18 +02:00
|
|
|
private $dropdown;
|
|
|
|
|
|
|
|
public function setDropdown($dropdown) {
|
|
|
|
$this->dropdown = $dropdown;
|
|
|
|
return $this;
|
|
|
|
}
|
2013-04-05 16:40:27 +02:00
|
|
|
|
2013-04-20 02:44:20 +02:00
|
|
|
public function addAction(PHUIIconView $action) {
|
2013-04-05 16:40:27 +02:00
|
|
|
$this->actions[] = $action;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setTag(PhabricatorTagView $tag) {
|
|
|
|
$this->actions[] = $tag;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setHeaderTitle($header) {
|
|
|
|
$this->headerTitle = $header;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setHeaderHref($href) {
|
|
|
|
$this->headerHref = $href;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-05-24 19:50:18 +02:00
|
|
|
public function addHeaderSigil($sigil) {
|
|
|
|
$this->headerSigils[] = $sigil;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-04-05 16:40:27 +02:00
|
|
|
public function setHeaderIcon($minicon) {
|
|
|
|
$this->headerIcon = $minicon;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setIconColor($color) {
|
|
|
|
$this->iconColor = $color;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setHeaderColor($color) {
|
|
|
|
$this->headerColor = $color;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function render() {
|
|
|
|
|
|
|
|
require_celerity_resource('phabricator-action-header-view-css');
|
|
|
|
|
|
|
|
$classes = array();
|
|
|
|
$classes[] = 'phabricator-action-header';
|
|
|
|
|
|
|
|
if ($this->headerColor) {
|
|
|
|
$classes[] = 'sprite-gradient';
|
|
|
|
$classes[] = 'gradient-'.$this->headerColor.'-header';
|
|
|
|
}
|
|
|
|
|
2013-05-24 19:50:18 +02:00
|
|
|
if ($this->dropdown) {
|
|
|
|
$classes[] = 'dropdown';
|
|
|
|
}
|
|
|
|
|
2013-04-05 16:40:27 +02:00
|
|
|
$action_list = array();
|
|
|
|
foreach ($this->actions as $action) {
|
|
|
|
$action_list[] = phutil_tag(
|
|
|
|
'li',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-action-header-icon-item'
|
|
|
|
),
|
|
|
|
$action);
|
|
|
|
}
|
|
|
|
|
|
|
|
$header_icon = '';
|
|
|
|
if ($this->headerIcon) {
|
|
|
|
require_celerity_resource('sprite-minicons-css');
|
|
|
|
$header_icon = phutil_tag(
|
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'class' => 'sprite-minicons minicons-'.$this->headerIcon
|
|
|
|
),
|
|
|
|
'');
|
|
|
|
}
|
|
|
|
|
|
|
|
$header_title = $this->headerTitle;
|
|
|
|
if ($this->headerHref) {
|
2013-05-24 19:50:18 +02:00
|
|
|
$header_title = javelin_tag(
|
2013-04-05 16:40:27 +02:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-action-header-link',
|
2013-05-24 19:50:18 +02:00
|
|
|
'href' => $this->headerHref,
|
|
|
|
'sigil' => implode(' ', $this->headerSigils)
|
2013-04-05 16:40:27 +02:00
|
|
|
),
|
|
|
|
$this->headerTitle);
|
|
|
|
}
|
|
|
|
|
|
|
|
$header = phutil_tag(
|
|
|
|
'h3',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-action-header-title'
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
$header_icon,
|
|
|
|
$header_title));
|
|
|
|
|
|
|
|
$icons = '';
|
|
|
|
if (!empty($action_list)) {
|
|
|
|
$classes[] = 'phabricator-action-header-icon-'.$this->iconColor;
|
|
|
|
$icons = phutil_tag(
|
|
|
|
'ul',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-action-header-icon-list'
|
|
|
|
),
|
|
|
|
$action_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
return phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => implode(' ', $classes)
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
$header,
|
|
|
|
$icons
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|