Changeset View
Changeset View
Standalone View
Standalone View
src/view/phui/PHUICurtainObjectRefListView.php
<?php | <?php | ||||
final class PHUICurtainObjectRefListView | final class PHUICurtainObjectRefListView | ||||
extends AphrontTagView { | extends AphrontTagView { | ||||
private $refs = array(); | private $refs = array(); | ||||
private $emptyMessage; | private $emptyMessage; | ||||
private $tail = array(); | |||||
protected function getTagAttributes() { | protected function getTagAttributes() { | ||||
return array( | return array( | ||||
'class' => 'phui-curtain-object-ref-list-view', | 'class' => 'phui-curtain-object-ref-list-view', | ||||
); | ); | ||||
} | } | ||||
public function setEmptyMessage($empty_message) { | public function setEmptyMessage($empty_message) { | ||||
$this->emptyMessage = $empty_message; | $this->emptyMessage = $empty_message; | ||||
return $this; | return $this; | ||||
} | } | ||||
protected function getTagContent() { | protected function getTagContent() { | ||||
$refs = $this->refs; | $refs = $this->refs; | ||||
if (!$refs) { | if (!$refs && ($this->emptyMessage !== null)) { | ||||
if ($this->emptyMessage) { | $view = phutil_tag( | ||||
return phutil_tag( | |||||
'div', | 'div', | ||||
array( | array( | ||||
'class' => 'phui-curtain-object-ref-list-view-empty', | 'class' => 'phui-curtain-object-ref-list-view-empty', | ||||
), | ), | ||||
$this->emptyMessage); | $this->emptyMessage); | ||||
} else { | |||||
$view = $refs; | |||||
} | } | ||||
$tail = null; | |||||
if ($this->tail) { | |||||
$tail = phutil_tag( | |||||
'div', | |||||
array( | |||||
'class' => 'phui-curtain-object-ref-list-view-tail', | |||||
), | |||||
$this->tail); | |||||
} | } | ||||
return $refs; | return array( | ||||
$view, | |||||
$tail, | |||||
); | |||||
} | } | ||||
public function newObjectRefView() { | public function newObjectRefView() { | ||||
$ref_view = id(new PHUICurtainObjectRefView()) | $ref_view = id(new PHUICurtainObjectRefView()) | ||||
->setViewer($this->getViewer()); | ->setViewer($this->getViewer()); | ||||
$this->refs[] = $ref_view; | $this->refs[] = $ref_view; | ||||
return $ref_view; | return $ref_view; | ||||
} | } | ||||
public function newTailLink() { | |||||
$link = new PHUILinkView(); | |||||
$this->tail[] = $link; | |||||
return $link; | |||||
} | |||||
} | } |