[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/view/phui/ -> PHUIActionHeaderView.php (source)

   1  <?php
   2  
   3  final class PHUIActionHeaderView extends AphrontView {
   4  
   5    const HEADER_GREY = 'grey';
   6    const HEADER_DARK_GREY = 'dark-grey';
   7    const HEADER_LIGHTGREEN = 'lightgreen';
   8    const HEADER_LIGHTRED = 'lightred';
   9    const HEADER_LIGHTVIOLET = 'lightviolet';
  10    const HEADER_LIGHTBLUE ='lightblue';
  11    const HEADER_WHITE = 'white';
  12  
  13    private $headerTitle;
  14    private $headerSubtitle;
  15    private $headerHref;
  16    private $headerIcon;
  17    private $headerSigils = array();
  18    private $actions = array();
  19    private $headerColor;
  20    private $tag = null;
  21    private $dropdown;
  22  
  23    public function setDropdown($dropdown) {
  24      $this->dropdown = $dropdown;
  25      return $this;
  26    }
  27  
  28    public function addAction(PHUIIconView $action) {
  29      $this->actions[] = $action;
  30      return $this;
  31    }
  32  
  33    public function setTag(PHUITagView $tag) {
  34      $this->tag = $tag;
  35      return $this;
  36    }
  37  
  38    public function setHeaderTitle($header) {
  39      $this->headerTitle = $header;
  40      return $this;
  41    }
  42  
  43    public function setHeaderSubtitle($subtitle) {
  44      $this->headerSubtitle = $subtitle;
  45      return $this;
  46    }
  47  
  48    public function setHeaderHref($href) {
  49      $this->headerHref = $href;
  50      return $this;
  51    }
  52  
  53    public function addHeaderSigil($sigil) {
  54      $this->headerSigils[] = $sigil;
  55      return $this;
  56    }
  57  
  58    public function setHeaderIcon(PHUIIconView $icon) {
  59      $this->headerIcon = $icon;
  60      return $this;
  61    }
  62  
  63    public function setHeaderColor($color) {
  64      $this->headerColor = $color;
  65      return $this;
  66    }
  67  
  68    private function getIconColor() {
  69      switch ($this->headerColor) {
  70        case self::HEADER_GREY:
  71          return 'lightgreytext';
  72        case self::HEADER_DARK_GREY:
  73          return 'lightgreytext';
  74        case self::HEADER_LIGHTGREEN:
  75          return 'bluegrey';
  76        case self::HEADER_LIGHTRED:
  77          return 'bluegrey';
  78        case self::HEADER_LIGHTVIOLET:
  79          return 'bluegrey';
  80        case self::HEADER_LIGHTBLUE:
  81          return 'bluegrey';
  82      }
  83    }
  84  
  85    public function render() {
  86  
  87      require_celerity_resource('phui-action-header-view-css');
  88  
  89      $classes = array();
  90      $classes[] = 'phui-action-header';
  91  
  92      if ($this->headerColor) {
  93        $classes[] = 'sprite-gradient';
  94        $classes[] = 'gradient-'.$this->headerColor.'-header';
  95      }
  96  
  97      if ($this->dropdown) {
  98        $classes[] = 'dropdown';
  99      }
 100  
 101      $action_list = array();
 102      if (nonempty($this->actions)) {
 103        foreach ($this->actions as $action) {
 104          $action->addClass($this->getIconColor());
 105          $action_list[] = phutil_tag(
 106            'li',
 107              array(
 108              'class' => 'phui-action-header-icon-item',
 109            ),
 110            $action);
 111        }
 112      }
 113  
 114      if ($this->tag) {
 115        $action_list[] = phutil_tag(
 116          'li',
 117            array(
 118            'class' => 'phui-action-header-icon-item',
 119          ),
 120          $this->tag);
 121      }
 122  
 123      $header_icon = null;
 124      if ($this->headerIcon) {
 125        $header_icon = $this->headerIcon;
 126      }
 127  
 128      $header_title = $this->headerTitle;
 129      if ($this->headerHref) {
 130        $header_title = javelin_tag(
 131          'a',
 132            array(
 133              'class' => 'phui-action-header-link',
 134              'href' => $this->headerHref,
 135              'sigil' => implode(' ', $this->headerSigils),
 136            ),
 137            $this->headerTitle);
 138      }
 139  
 140      $header_subtitle = null;
 141      if ($this->headerSubtitle) {
 142        $header_subtitle = phutil_tag(
 143          'span',
 144            array(
 145              'class' => 'phui-action-header-subtitle',
 146            ),
 147            $this->headerSubtitle);
 148      }
 149  
 150      $header = phutil_tag(
 151        'h3',
 152          array(
 153            'class' => 'phui-action-header-title',
 154          ),
 155        array(
 156          $header_icon,
 157          $header_title,
 158          $header_subtitle,
 159        ));
 160  
 161      $icons = '';
 162      if (nonempty($action_list)) {
 163        $icons = phutil_tag(
 164          'ul',
 165            array(
 166              'class' => 'phui-action-header-icon-list',
 167            ),
 168            $action_list);
 169      }
 170  
 171      return phutil_tag(
 172        'div',
 173          array(
 174            'class' => implode(' ', $classes),
 175          ),
 176          array(
 177            $header,
 178            $icons,
 179          ));
 180    }
 181  }


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