1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-30 18:52:42 +01:00
phorge-phorge/src/view/layout/PhabricatorCrumbsView.php
Chad Little f1bf27959f PHUIList, PHUIDocument updates
Summary:
This diff covers a bit of ground.

- PHUIDocumentExample has been added
- PHUIDocument has been extended with new features
- PhabricatorMenuView is now PHUIListView
- PhabricatorMenuItemView is now PHUIItemListView

Overall - I think I've gotten all the edges covered here. There is some derpi-ness that we can talk about, comments in the code. Responsive design is missing from the new features on PHUIDocument, will follow up later.

Test Plan: Tested mobile and desktop menus, old phriction layout, new document views, new lists, and object lists.

Reviewers: epriestley, btrahan

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D6130
2013-06-05 08:41:43 -07:00

132 lines
3.3 KiB
PHP

<?php
final class PhabricatorCrumbsView extends AphrontView {
private $crumbs = array();
private $actions = array();
private $actionListID = null;
protected function canAppendChild() {
return false;
}
public function addCrumb(PhabricatorCrumbView $crumb) {
$this->crumbs[] = $crumb;
return $this;
}
public function addAction(PHUIListItemView $action) {
$this->actions[] = $action;
return $this;
}
public function setActionList(PhabricatorActionListView $list) {
$this->actionListID = celerity_generate_unique_node_id();
$list->setId($this->actionListID);
return $this;
}
public function render() {
require_celerity_resource('phabricator-crumbs-view-css');
$action_view = null;
if (($this->actions) || ($this->actionListID)) {
$actions = array();
foreach ($this->actions as $action) {
$icon = null;
if ($action->getIcon()) {
$icon = phutil_tag(
'span',
array(
'class' => 'sprite-icons icons-'.$action->getIcon(),
),
'');
}
$name = phutil_tag(
'span',
array(
'class' => 'phabricator-crumbs-action-name'
),
$action->getName());
$action_sigils = $action->getSigils();
if ($action->getWorkflow()) {
$action_sigils[] = 'workflow';
}
$action_classes = $action->getClasses();
$action_classes[] = 'phabricator-crumbs-action';
$actions[] = javelin_tag(
'a',
array(
'href' => $action->getHref(),
'class' => implode(' ', $action_classes),
'sigil' => implode(' ', $action_sigils),
'style' => $action->getStyle()
),
array(
$icon,
$name,
));
}
if ($this->actionListID) {
$icon_id = celerity_generate_unique_node_id();
$icon = phutil_tag(
'span',
array(
'class' => 'sprite-icons action-action-menu'
),
'');
$name = phutil_tag(
'span',
array(
'class' => 'phabricator-crumbs-action-name'
),
pht('Actions'));
$actions[] = javelin_tag(
'a',
array(
'href' => '#',
'class' =>
'phabricator-crumbs-action phabricator-crumbs-action-menu',
'sigil' => 'jx-toggle-class',
'id' => $icon_id,
'meta' => array(
'map' => array(
$this->actionListID => 'phabricator-action-list-toggle',
$icon_id => 'phabricator-crumbs-action-menu-open'
),
),
),
array(
$icon,
$name,
));
}
$action_view = phutil_tag(
'div',
array(
'class' => 'phabricator-crumbs-actions',
),
$actions);
}
if ($this->crumbs) {
last($this->crumbs)->setIsLastCrumb(true);
}
return phutil_tag(
'div',
array(
'class' => 'phabricator-crumbs-view '.
'sprite-gradient gradient-breadcrumbs',
),
array(
$action_view,
$this->crumbs,
));
}
}