[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

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

   1  <?php
   2  
   3  final class PHUIObjectItemListView extends AphrontTagView {
   4  
   5    private $header;
   6    private $items;
   7    private $pager;
   8    private $stackable;
   9    private $noDataString;
  10    private $flush;
  11    private $plain;
  12    private $allowEmptyList;
  13    private $states;
  14  
  15  
  16    public function setAllowEmptyList($allow_empty_list) {
  17      $this->allowEmptyList = $allow_empty_list;
  18      return $this;
  19    }
  20  
  21    public function getAllowEmptyList() {
  22      return $this->allowEmptyList;
  23    }
  24  
  25    public function setFlush($flush) {
  26      $this->flush = $flush;
  27      return $this;
  28    }
  29  
  30    public function setPlain($plain) {
  31      $this->plain = $plain;
  32      return $this;
  33    }
  34  
  35    public function setHeader($header) {
  36      $this->header = $header;
  37      return $this;
  38    }
  39  
  40    public function setPager($pager) {
  41      $this->pager = $pager;
  42      return $this;
  43    }
  44  
  45    public function setNoDataString($no_data_string) {
  46      $this->noDataString = $no_data_string;
  47      return $this;
  48    }
  49  
  50    public function addItem(PHUIObjectItemView $item) {
  51      $this->items[] = $item;
  52      return $this;
  53    }
  54  
  55    public function setStackable($stackable) {
  56      $this->stackable = $stackable;
  57      return $this;
  58    }
  59  
  60    public function setStates($states) {
  61      $this->states = $states;
  62      return $this;
  63    }
  64  
  65    protected function getTagName() {
  66      return 'ul';
  67    }
  68  
  69    protected function getTagAttributes() {
  70      $classes = array();
  71  
  72      $classes[] = 'phui-object-item-list-view';
  73      if ($this->stackable) {
  74        $classes[] = 'phui-object-list-stackable';
  75      }
  76      if ($this->states) {
  77        $classes[] = 'phui-object-list-states';
  78        $classes[] = 'phui-object-list-stackable';
  79      }
  80      if ($this->flush) {
  81        $classes[] = 'phui-object-list-flush';
  82      }
  83      if ($this->plain) {
  84        $classes[] = 'phui-object-list-plain';
  85      }
  86  
  87      return array(
  88        'class' => $classes,
  89      );
  90    }
  91  
  92    protected function getTagContent() {
  93      require_celerity_resource('phui-object-item-list-view-css');
  94  
  95      $header = null;
  96      if (strlen($this->header)) {
  97        $header = phutil_tag(
  98          'h1',
  99          array(
 100            'class' => 'phui-object-item-list-header',
 101          ),
 102          $this->header);
 103      }
 104  
 105      if ($this->items) {
 106        $items = $this->items;
 107      } else if ($this->allowEmptyList) {
 108        $items = null;
 109      } else {
 110        $string = nonempty($this->noDataString, pht('No data.'));
 111        $string = id(new AphrontErrorView())
 112          ->setSeverity(AphrontErrorView::SEVERITY_NODATA)
 113          ->appendChild($string);
 114        $items = phutil_tag(
 115          'li',
 116          array(
 117            'class' => 'phui-object-item-empty',
 118          ),
 119          $string);
 120  
 121      }
 122  
 123      $pager = null;
 124      if ($this->pager) {
 125        $pager = $this->pager;
 126      }
 127  
 128      return array(
 129        $header,
 130        $items,
 131        $pager,
 132        $this->renderChildren(),
 133      );
 134    }
 135  
 136  }


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