mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-13 10:22:42 +01:00
1c9a6be979
Summary: Add a basic breadcrumbs element, and implement it in Paste. This needs some polish but is most of the way there. Test Plan: {F26443} {F26444} {F26445} (This element is not visible on devices.) Reviewers: chad Reviewed By: chad CC: aran, btrahan Maniphest Tasks: T1960 Differential Revision: https://secure.phabricator.com/D4087
71 lines
1.4 KiB
PHP
71 lines
1.4 KiB
PHP
<?php
|
|
|
|
final class PhabricatorMenuView extends AphrontView {
|
|
|
|
private $items = array();
|
|
private $map = array();
|
|
private $classes = array();
|
|
|
|
public function addClass($class) {
|
|
$this->classes[] = $class;
|
|
return $this;
|
|
}
|
|
|
|
public function newLabel($name) {
|
|
$item = id(new PhabricatorMenuItemView())
|
|
->setType(PhabricatorMenuItemView::TYPE_LABEL)
|
|
->setName($name);
|
|
|
|
$this->addMenuItem($item);
|
|
|
|
return $item;
|
|
}
|
|
|
|
public function newLink($name, $href) {
|
|
$item = id(new PhabricatorMenuItemView())
|
|
->setType(PhabricatorMenuItemView::TYPE_LINK)
|
|
->setName($name)
|
|
->setHref($href);
|
|
|
|
$this->addMenuItem($item);
|
|
|
|
return $item;
|
|
}
|
|
|
|
public function addMenuItem(PhabricatorMenuItemView $item) {
|
|
$key = $item->getKey();
|
|
if ($key !== null) {
|
|
if (isset($this->map[$key])) {
|
|
throw new Exception(
|
|
"Menu contains duplicate items with key '{$key}'!");
|
|
}
|
|
$this->map[$key] = $item;
|
|
}
|
|
|
|
$this->items[] = $item;
|
|
$this->appendChild($item);
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getItem($key) {
|
|
return idx($this->map, (string)$key);
|
|
}
|
|
|
|
public function getItems() {
|
|
return $this->items;
|
|
}
|
|
|
|
public function render() {
|
|
$classes = $this->classes;
|
|
$classes[] = 'phabricator-menu-view';
|
|
|
|
return phutil_render_tag(
|
|
'div',
|
|
array(
|
|
'class' => implode(' ', $classes),
|
|
),
|
|
$this->renderChildren());
|
|
}
|
|
|
|
}
|