[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/view/layout/ -> PhabricatorCrumbsView.php (source)

   1  <?php
   2  
   3  final class PhabricatorCrumbsView extends AphrontView {
   4  
   5    private $crumbs = array();
   6    private $actions = array();
   7    private $actionListID = null;
   8  
   9    protected function canAppendChild() {
  10      return false;
  11    }
  12  
  13  
  14    /**
  15     * Convenience method for adding a simple crumb with just text, or text and
  16     * a link.
  17     *
  18     * @param string  Text of the crumb.
  19     * @param string? Optional href for the crumb.
  20     * @return this
  21     */
  22    public function addTextCrumb($text, $href = null) {
  23      return $this->addCrumb(
  24        id(new PhabricatorCrumbView())
  25          ->setName($text)
  26          ->setHref($href));
  27    }
  28  
  29    public function addCrumb(PhabricatorCrumbView $crumb) {
  30      $this->crumbs[] = $crumb;
  31      return $this;
  32    }
  33  
  34    public function addAction(PHUIListItemView $action) {
  35      $this->actions[] = $action;
  36      return $this;
  37    }
  38  
  39    public function setActionList(PhabricatorActionListView $list) {
  40      $this->actionListID = celerity_generate_unique_node_id();
  41      $list->setId($this->actionListID);
  42      return $this;
  43    }
  44  
  45    public function render() {
  46      require_celerity_resource('phabricator-crumbs-view-css');
  47  
  48      $action_view = null;
  49      if (($this->actions) || ($this->actionListID)) {
  50        $actions = array();
  51        foreach ($this->actions as $action) {
  52          $icon = null;
  53          if ($action->getIcon()) {
  54            $icon_name = $action->getIcon();
  55            if ($action->getDisabled()) {
  56              $icon_name .= ' lightgreytext';
  57            }
  58  
  59            $icon = id(new PHUIIconView())
  60              ->setIconFont($icon_name);
  61  
  62          }
  63          $name = phutil_tag(
  64            'span',
  65              array(
  66                'class' => 'phabricator-crumbs-action-name',
  67              ),
  68            $action->getName());
  69  
  70          $action_sigils = $action->getSigils();
  71          if ($action->getWorkflow()) {
  72            $action_sigils[] = 'workflow';
  73          }
  74          $action_classes = $action->getClasses();
  75          $action_classes[] = 'phabricator-crumbs-action';
  76  
  77          if ($action->getDisabled()) {
  78            $action_classes[] = 'phabricator-crumbs-action-disabled';
  79          }
  80  
  81          $actions[] = javelin_tag(
  82            'a',
  83            array(
  84              'href' => $action->getHref(),
  85              'class' => implode(' ', $action_classes),
  86              'sigil' => implode(' ', $action_sigils),
  87              'style' => $action->getStyle(),
  88            ),
  89            array(
  90              $icon,
  91              $name,
  92            ));
  93        }
  94  
  95        if ($this->actionListID) {
  96          $icon_id = celerity_generate_unique_node_id();
  97          $icon = id(new PHUIIconView())
  98            ->setIconFont('fa-bars');
  99          $name = phutil_tag(
 100            'span',
 101              array(
 102                'class' => 'phabricator-crumbs-action-name',
 103              ),
 104            pht('Actions'));
 105  
 106          $actions[] = javelin_tag(
 107            'a',
 108              array(
 109                'href'  => '#',
 110                'class' =>
 111                  'phabricator-crumbs-action phabricator-crumbs-action-menu',
 112                'sigil' => 'jx-toggle-class',
 113                'id'    => $icon_id,
 114                'meta'  => array(
 115                  'map' => array(
 116                    $this->actionListID => 'phabricator-action-list-toggle',
 117                    $icon_id => 'phabricator-crumbs-action-menu-open',
 118                  ),
 119                ),
 120              ),
 121              array(
 122                $icon,
 123                $name,
 124              ));
 125        }
 126  
 127        $action_view = phutil_tag(
 128          'div',
 129          array(
 130            'class' => 'phabricator-crumbs-actions',
 131          ),
 132          $actions);
 133      }
 134  
 135      if ($this->crumbs) {
 136        last($this->crumbs)->setIsLastCrumb(true);
 137      }
 138  
 139      return phutil_tag(
 140        'div',
 141        array(
 142          'class' => 'phabricator-crumbs-view '.
 143                     'sprite-gradient gradient-breadcrumbs',
 144        ),
 145        array(
 146          $action_view,
 147          $this->crumbs,
 148        ));
 149    }
 150  
 151  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1