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
|
|
|
}
|
|
|
|
|
2013-01-31 18:07:31 +01:00
|
|
|
$action_view = phutil_tag(
|
2012-12-07 22:35:17 +01:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-crumbs-actions',
|
|
|
|
),
|
2013-02-13 23:50:15 +01:00
|
|
|
$this->renderSingleView($actions));
|
2012-12-07 22:35:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->crumbs) {
|
|
|
|
last($this->crumbs)->setIsLastCrumb(true);
|
|
|
|
}
|
|
|
|
|
2013-01-31 18:07:31 +01:00
|
|
|
return phutil_tag(
|
2012-12-07 22:35:17 +01:00
|
|
|
'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
|
|
|
),
|
2013-02-13 23:50:15 +01:00
|
|
|
$this->renderSingleView(
|
2013-01-31 18:07:31 +01:00
|
|
|
array(
|
|
|
|
$action_view,
|
|
|
|
$this->crumbs,
|
|
|
|
)));
|
2012-12-07 22:35:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|