3 final class PhabricatorNavigationRemarkupRule
extends PhutilRemarkupRule
{
5 public function getPriority() {
9 public function apply($text) {
10 return preg_replace_callback(
11 '@{nav\b((?:[^}\\\\]+|\\\\.)*)}@m',
12 array($this, 'markupNavigation'),
16 public function markupNavigation(array $matches) {
17 if (!$this->isFlatText($matches[0])) {
21 $elements = ltrim($matches[1], ", \n");
22 $elements = explode('>', $elements);
32 $parser = new PhutilSimpleOptions();
33 foreach ($elements as $element) {
34 if (strpos($element, '=') === false) {
36 'name' => trim($element),
39 $sequence[] = $parser->parse($element) +
$defaults;
43 if ($this->getEngine()->isTextMode()) {
44 return implode(' > ', ipull($sequence, 'name'));
49 $icon_names = array_fuse(PHUIIconView
::getIcons());
53 foreach ($sequence as $item) {
54 $item_name = $item['name'];
55 $item_color = PHUITagView
::COLOR_GREY
;
56 if ($item['type'] == 'instructions') {
57 $item_name = phutil_tag('em', array(), $item_name);
58 $item_color = PHUITagView
::COLOR_INDIGO
;
61 $tag = id(new PHUITagView())
62 ->setType(PHUITagView
::TYPE_SHADE
)
63 ->setColor($item_color)
64 ->setName($item_name);
67 $icon_name = 'fa-'.$item['icon'];
68 if (isset($icon_names[$icon_name])) {
69 $tag->setIcon($icon_name);
73 if ($item['href'] !== null) {
74 if (PhabricatorEnv
::isValidRemoteURIForLink($item['href'])) {
75 $tag->setHref($item['href']);
76 $tag->setExternal(true);
83 if ($this->getEngine()->isHTMLMailMode()) {
85 'style' => 'color: #92969D;',
90 'class' => 'remarkup-nav-sequence-arrow',
93 'class' => 'remarkup-nav-sequence',
102 $out = phutil_implode_html($joiner, $out);
109 return $this->getEngine()->storeText($out);