[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

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

   1  <?php
   2  
   3  final class AphrontPanelView extends AphrontView {
   4  
   5    const WIDTH_FULL = 'full';
   6    const WIDTH_FORM = 'form';
   7    const WIDTH_WIDE = 'wide';
   8  
   9    private $buttons = array();
  10    private $header;
  11    private $caption;
  12    private $width;
  13    private $classes = array();
  14    private $id;
  15  
  16    public function setCreateButton($create_button, $href) {
  17      $this->addButton(
  18        phutil_tag(
  19          'a',
  20          array(
  21            'href' => $href,
  22            'class' => 'button green',
  23          ),
  24          $create_button));
  25  
  26      return $this;
  27    }
  28  
  29    public function addClass($class) {
  30      $this->classes[] = $class;
  31      return $this;
  32    }
  33  
  34    public function addButton($button) {
  35      $this->buttons[] = $button;
  36      return $this;
  37    }
  38  
  39    public function setHeader($header) {
  40      $this->header = $header;
  41      return $this;
  42    }
  43  
  44    public function setWidth($width) {
  45      $this->width = $width;
  46      return $this;
  47    }
  48  
  49    public function setID($id) {
  50      $this->id = $id;
  51      return $this;
  52    }
  53  
  54    public function setCaption($caption) {
  55      $this->caption = $caption;
  56      return $this;
  57    }
  58  
  59    public function setNoBackground() {
  60      $this->classes[] = 'aphront-panel-plain';
  61      return $this;
  62    }
  63  
  64    public function render() {
  65      if ($this->header !== null) {
  66        $header = phutil_tag('h1', array(), $this->header);
  67      } else {
  68        $header = null;
  69      }
  70  
  71      if ($this->caption !== null) {
  72        $caption = phutil_tag_div('aphront-panel-view-caption', $this->caption);
  73      } else {
  74        $caption = null;
  75      }
  76  
  77      $buttons = null;
  78      if ($this->buttons) {
  79        $buttons = phutil_tag_div(
  80          'aphront-panel-view-buttons',
  81          phutil_implode_html(' ', $this->buttons));
  82      }
  83      $header_elements = phutil_tag_div(
  84        'aphront-panel-header',
  85        array($buttons, $header, $caption));
  86  
  87      $table = phutil_implode_html('', $this->renderChildren());
  88  
  89      require_celerity_resource('aphront-panel-view-css');
  90  
  91      $classes = $this->classes;
  92      $classes[] = 'aphront-panel-view';
  93      if ($this->width) {
  94        $classes[] = 'aphront-panel-width-'.$this->width;
  95      }
  96  
  97      return phutil_tag(
  98        'div',
  99        array(
 100          'class' => implode(' ', $classes),
 101          'id'    => $this->id,
 102        ),
 103        array($header_elements, $table));
 104    }
 105  
 106  }


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