Changeset View
Changeset View
Standalone View
Standalone View
src/applications/search/view/PhabricatorSearchResultView.php
Show All 15 Lines | public function setQuery(PhabricatorSavedQuery $query) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setObject($object) { | public function setObject($object) { | ||||
$this->object = $object; | $this->object = $object; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getObject() { | |||||
return $this->object; | |||||
} | |||||
public function render() { | public function render() { | ||||
$viewer = $this->getUser(); | |||||
$handle = $this->handle; | $handle = $this->handle; | ||||
if (!$handle->isComplete()) { | if (!$handle->isComplete()) { | ||||
return; | return; | ||||
} | } | ||||
require_celerity_resource('phabricator-search-results-css'); | require_celerity_resource('phabricator-search-results-css'); | ||||
$type_name = nonempty($handle->getTypeName(), pht('Document')); | $type_name = nonempty($handle->getTypeName(), pht('Document')); | ||||
$raw_title = $handle->getFullName(); | $raw_title = $handle->getFullName(); | ||||
$title = $this->emboldenQuery($raw_title); | $title = $this->emboldenQuery($raw_title); | ||||
$item = id(new PHUIObjectItemView()) | $item = id(new PHUIObjectItemView()) | ||||
->setHeader($title) | ->setHeader($title) | ||||
->setTitleText($raw_title) | ->setTitleText($raw_title) | ||||
->setHref($handle->getURI()) | ->setHref($handle->getURI()) | ||||
->setImageURI($handle->getImageURI()) | ->setImageURI($handle->getImageURI()) | ||||
->addAttribute($type_name); | ->addAttribute($type_name); | ||||
if ($handle->getStatus() == PhabricatorObjectHandle::STATUS_CLOSED) { | if ($handle->getStatus() == PhabricatorObjectHandle::STATUS_CLOSED) { | ||||
$item->setDisabled(true); | $item->setDisabled(true); | ||||
$item->addAttribute(pht('Closed')); | $item->addAttribute(pht('Closed')); | ||||
} | } | ||||
$object = $this->getObject(); | |||||
if ($object instanceof PhabricatorSearchSnippetInterface) { | |||||
$snippet = $object->renderSearchResultSnippet($viewer); | |||||
$snippet = phutil_tag( | |||||
'div', | |||||
array( | |||||
'class' => 'phui-search-snippet', | |||||
), | |||||
$snippet); | |||||
$item->appendChild($snippet); | |||||
} | |||||
return $item; | return $item; | ||||
} | } | ||||
/** | /** | ||||
* Find the words which are part of the query string, and bold them in a | * Find the words which are part of the query string, and bold them in a | ||||
* result string. This makes it easier for users to see why a result | * result string. This makes it easier for users to see why a result | ||||
* matched their query. | * matched their query. | ||||
▲ Show 20 Lines • Show All 87 Lines • Show Last 20 Lines |