Changeset View
Changeset View
Standalone View
Standalone View
src/view/widget/hovercard/PhabricatorHovercardView.php
<?php | <?php | ||||
/** | /** | ||||
* The default one-for-all hovercard. We may derive from this one to create | * The default one-for-all hovercard. We may derive from this one to create | ||||
* more specialized ones. | * more specialized ones. | ||||
*/ | */ | ||||
final class PhabricatorHovercardView extends AphrontView { | final class PhabricatorHovercardView extends AphrontView { | ||||
/** | /** | ||||
* @var PhabricatorObjectHandle | * @var PhabricatorObjectHandle | ||||
*/ | */ | ||||
private $handle; | private $handle; | ||||
private $object; | |||||
private $title = array(); | private $title = array(); | ||||
private $detail; | private $detail; | ||||
private $tags = array(); | private $tags = array(); | ||||
private $fields = array(); | private $fields = array(); | ||||
private $actions = array(); | private $actions = array(); | ||||
private $color = 'lightblue'; | private $color = 'lightblue'; | ||||
public function setObjectHandle(PhabricatorObjectHandle $handle) { | public function setObjectHandle(PhabricatorObjectHandle $handle) { | ||||
$this->handle = $handle; | $this->handle = $handle; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setObject($object) { | |||||
$this->object = $object; | |||||
return $this; | |||||
} | |||||
public function getObject() { | |||||
return $this->object; | |||||
} | |||||
public function setTitle($title) { | public function setTitle($title) { | ||||
$this->title = $title; | $this->title = $title; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setDetail($detail) { | public function setDetail($detail) { | ||||
$this->detail = $detail; | $this->detail = $detail; | ||||
return $this; | return $this; | ||||
Show All 26 Lines | public function setColor($color) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function render() { | public function render() { | ||||
if (!$this->handle) { | if (!$this->handle) { | ||||
throw new PhutilInvalidStateException('setObjectHandle'); | throw new PhutilInvalidStateException('setObjectHandle'); | ||||
} | } | ||||
$viewer = $this->getUser(); | |||||
$handle = $this->handle; | $handle = $this->handle; | ||||
require_celerity_resource('phabricator-hovercard-view-css'); | require_celerity_resource('phabricator-hovercard-view-css'); | ||||
$title = pht('%s: %s', | $title = array( | ||||
id(new PHUISpacesNamespaceContextView()) | |||||
->setUser($viewer) | |||||
->setObject($this->getObject()), | |||||
pht( | |||||
'%s: %s', | |||||
$handle->getTypeName(), | $handle->getTypeName(), | ||||
$this->title ? $this->title : $handle->getName()); | $this->title ? $this->title : $handle->getName()), | ||||
); | |||||
$header = new PHUIActionHeaderView(); | $header = new PHUIActionHeaderView(); | ||||
$header->setHeaderColor($this->color); | $header->setHeaderColor($this->color); | ||||
$header->setHeaderTitle($title); | $header->setHeaderTitle($title); | ||||
if ($this->tags) { | if ($this->tags) { | ||||
foreach ($this->tags as $tag) { | foreach ($this->tags as $tag) { | ||||
$header->setTag($tag); | $header->setTag($tag); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 89 Lines • Show Last 20 Lines |