Changeset View
Changeset View
Standalone View
Standalone View
src/view/phui/PHUICurtainObjectRefView.php
<?php | <?php | ||||
final class PHUICurtainObjectRefView | final class PHUICurtainObjectRefView | ||||
extends AphrontTagView { | extends AphrontTagView { | ||||
private $handle; | private $handle; | ||||
private $epoch; | private $epoch; | ||||
private $highlighted; | |||||
public function setHandle(PhabricatorObjectHandle $handle) { | public function setHandle(PhabricatorObjectHandle $handle) { | ||||
$this->handle = $handle; | $this->handle = $handle; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setEpoch($epoch) { | public function setEpoch($epoch) { | ||||
$this->epoch = $epoch; | $this->epoch = $epoch; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setHighlighted($highlighted) { | |||||
$this->highlighted = $highlighted; | |||||
return $this; | |||||
} | |||||
protected function getTagAttributes() { | protected function getTagAttributes() { | ||||
$classes = array(); | |||||
$classes[] = 'phui-curtain-object-ref-view'; | |||||
if ($this->highlighted) { | |||||
$classes[] = 'phui-curtain-object-ref-view-highlighted'; | |||||
} | |||||
$classes = implode(' ', $classes); | |||||
return array( | return array( | ||||
'class' => 'phui-curtain-object-ref-view', | 'class' => $classes, | ||||
); | ); | ||||
} | } | ||||
protected function getTagContent() { | protected function getTagContent() { | ||||
require_celerity_resource('phui-curtain-object-ref-view-css'); | require_celerity_resource('phui-curtain-object-ref-view-css'); | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$handle = $this->handle; | $handle = $this->handle; | ||||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | private function newTitle() { | ||||
return $title_view; | return $title_view; | ||||
} | } | ||||
private function newImage() { | private function newImage() { | ||||
$image_uri = $this->getImageURI(); | $image_uri = $this->getImageURI(); | ||||
$target_uri = $this->getTargetURI(); | $target_uri = $this->getTargetURI(); | ||||
$icon_view = null; | |||||
if ($image_uri == null) { | |||||
$icon_view = $this->newIconView(); | |||||
} | |||||
if ($image_uri !== null) { | if ($image_uri !== null) { | ||||
$image_view = javelin_tag( | $image_view = javelin_tag( | ||||
'a', | 'a', | ||||
array( | array( | ||||
'style' => sprintf('background-image: url(%s)', $image_uri), | 'style' => sprintf('background-image: url(%s)', $image_uri), | ||||
'href' => $target_uri, | 'href' => $target_uri, | ||||
'aural' => false, | 'aural' => false, | ||||
)); | )); | ||||
} else if ($icon_view !== null) { | |||||
$image_view = javelin_tag( | |||||
'a', | |||||
array( | |||||
'href' => $target_uri, | |||||
'class' => 'phui-curtain-object-ref-view-icon-image', | |||||
'aural' => false, | |||||
), | |||||
$icon_view); | |||||
} else { | } else { | ||||
$image_view = null; | $image_view = null; | ||||
} | } | ||||
return $image_view; | return $image_view; | ||||
} | } | ||||
private function getTargetURI() { | private function getTargetURI() { | ||||
Show All 13 Lines | private function getImageURI() { | ||||
if ($handle) { | if ($handle) { | ||||
$image_uri = $handle->getImageURI(); | $image_uri = $handle->getImageURI(); | ||||
} | } | ||||
return $image_uri; | return $image_uri; | ||||
} | } | ||||
private function newIconView() { | |||||
$handle = $this->handle; | |||||
if ($handle) { | |||||
$icon_view = id(new PHUIIconView()) | |||||
->setIcon($handle->getIcon()); | |||||
} | |||||
return $icon_view; | |||||
} | |||||
} | } |