Path: blob/master/src/view/phui/PHUIObjectItemListView.php
12249 views
<?php12final class PHUIObjectItemListView extends AphrontTagView {34private $header;5private $items;6private $pager;7private $noDataString;8private $flush;9private $simple;10private $big;11private $drag;12private $allowEmptyList;13private $itemClass = 'phui-oi-standard';14private $tail = array();1516public function setAllowEmptyList($allow_empty_list) {17$this->allowEmptyList = $allow_empty_list;18return $this;19}2021public function getAllowEmptyList() {22return $this->allowEmptyList;23}2425public function setFlush($flush) {26$this->flush = $flush;27return $this;28}2930public function setHeader($header) {31$this->header = $header;32return $this;33}3435public function setPager($pager) {36$this->pager = $pager;37return $this;38}3940public function setSimple($simple) {41$this->simple = $simple;42return $this;43}4445public function setBig($big) {46$this->big = $big;47return $this;48}4950public function setDrag($drag) {51$this->drag = $drag;52$this->setItemClass('phui-oi-drag');53return $this;54}5556public function setNoDataString($no_data_string) {57$this->noDataString = $no_data_string;58return $this;59}6061public function addItem(PHUIObjectItemView $item) {62$this->items[] = $item;63return $this;64}6566public function setItemClass($item_class) {67$this->itemClass = $item_class;68return $this;69}7071protected function getTagName() {72return 'ul';73}7475public function newTailButton() {76$button = id(new PHUIButtonView())77->setTag('a')78->setColor(PHUIButtonView::GREY)79->setIcon('fa-chevron-down')80->setText(pht('View All Results'));8182$this->tail[] = $button;8384return $button;85}8687protected function getTagAttributes() {88$classes = array();89$classes[] = 'phui-oi-list-view';9091if ($this->flush) {92$classes[] = 'phui-oi-list-flush';93require_celerity_resource('phui-oi-flush-ui-css');94}9596if ($this->simple) {97$classes[] = 'phui-oi-list-simple';98require_celerity_resource('phui-oi-simple-ui-css');99}100101if ($this->big) {102$classes[] = 'phui-oi-list-big';103require_celerity_resource('phui-oi-big-ui-css');104}105106if ($this->drag) {107$classes[] = 'phui-oi-list-drag';108require_celerity_resource('phui-oi-drag-ui-css');109}110111return array(112'class' => $classes,113);114}115116protected function getTagContent() {117$viewer = $this->getUser();118require_celerity_resource('phui-oi-list-view-css');119require_celerity_resource('phui-oi-color-css');120121$header = null;122if ($this->header !== null && strlen($this->header)) {123$header = phutil_tag(124'h1',125array(126'class' => 'phui-oi-list-header',127),128$this->header);129}130131if ($this->items) {132if ($viewer) {133foreach ($this->items as $item) {134$item->setUser($viewer);135}136}137138foreach ($this->items as $item) {139$item->addClass($this->itemClass);140}141142$items = $this->items;143} else if ($this->getAllowEmptyList()) {144$items = null;145} else {146$string = nonempty($this->noDataString, pht('No data.'));147$string = id(new PHUIInfoView())148->setSeverity(PHUIInfoView::SEVERITY_NODATA)149->appendChild($string);150$items = phutil_tag(151'li',152array(153'class' => 'phui-oi-empty',154),155$string);156157}158159$pager = null;160if ($this->pager) {161$pager = $this->pager;162}163164$tail = array();165foreach ($this->tail as $tail_item) {166$tail[] = phutil_tag(167'li',168array(169'class' => 'phui-oi-tail',170),171$tail_item);172}173174return array(175$header,176$items,177$tail,178$pager,179$this->renderChildren(),180);181}182183}184185186