2012-12-07 22:35:17 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorCrumbsView extends AphrontView {
|
|
|
|
|
|
|
|
private $crumbs = array();
|
|
|
|
private $actions = array();
|
|
|
|
|
|
|
|
protected function canAppendChild() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addCrumb(PhabricatorCrumbView $crumb) {
|
|
|
|
$this->crumbs[] = $crumb;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function addAction(PhabricatorMenuItemView $action) {
|
|
|
|
$this->actions[] = $action;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function render() {
|
|
|
|
require_celerity_resource('phabricator-crumbs-view-css');
|
|
|
|
|
|
|
|
$action_view = null;
|
|
|
|
if ($this->actions) {
|
|
|
|
$actions = array();
|
|
|
|
foreach ($this->actions as $action) {
|
|
|
|
$icon = null;
|
|
|
|
if ($action->getIcon()) {
|
2013-01-18 03:57:09 +01:00
|
|
|
$icon = phutil_tag(
|
2012-12-07 22:35:17 +01:00
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'class' => 'sprite-icon action-'.$action->getIcon(),
|
|
|
|
),
|
|
|
|
'');
|
|
|
|
}
|
2013-01-25 21:57:17 +01:00
|
|
|
$actions[] = javelin_tag(
|
2012-12-07 22:35:17 +01:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $action->getHref(),
|
|
|
|
'class' => 'phabricator-crumbs-action',
|
2013-01-11 20:58:31 +01:00
|
|
|
'sigil' => $action->getWorkflow() ? 'workflow' : null,
|
2012-12-07 22:35:17 +01:00
|
|
|
),
|
2013-01-25 21:57:17 +01:00
|
|
|
array(
|
|
|
|
$icon,
|
|
|
|
$action->getName(),
|
|
|
|
));
|
2012-12-07 22:35:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$action_view = phutil_render_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-crumbs-actions',
|
|
|
|
),
|
|
|
|
self::renderSingleView($actions));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->crumbs) {
|
|
|
|
last($this->crumbs)->setIsLastCrumb(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
return phutil_render_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
2012-12-07 22:35:49 +01:00
|
|
|
'class' => 'phabricator-crumbs-view '.
|
|
|
|
'sprite-gradient gradient-breadcrumbs',
|
2012-12-07 22:35:17 +01:00
|
|
|
),
|
|
|
|
$action_view.
|
|
|
|
self::renderSingleView($this->crumbs));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|