3 final class PhameBlogSearchEngine
4 extends PhabricatorApplicationSearchEngine
{
6 public function getResultTypeDescription() {
7 return pht('Phame Blogs');
10 public function getApplicationClassName() {
11 return 'PhabricatorPhameApplication';
14 public function newQuery() {
15 return id(new PhameBlogQuery())
16 ->needProfileImage(true);
19 protected function buildQueryFromParameters(array $map) {
20 $query = $this->newQuery();
21 if ($map['statuses']) {
22 $query->withStatuses(array($map['statuses']));
27 protected function buildCustomSearchFields() {
29 id(new PhabricatorSearchSelectField())
31 ->setLabel(pht('Status'))
34 PhameBlog
::STATUS_ACTIVE
=> pht('Active'),
35 PhameBlog
::STATUS_ARCHIVED
=> pht('Archived'),
40 protected function getURI($path) {
41 return '/phame/blog/'.$path;
44 protected function getBuiltinQueryNames() {
46 'active' => pht('Active Blogs'),
47 'archived' => pht('Archived Blogs'),
48 'all' => pht('All Blogs'),
53 public function buildSavedQueryFromBuiltin($query_key) {
54 $query = $this->newSavedQuery();
55 $query->setQueryKey($query_key);
61 return $query->setParameter(
62 'statuses', PhameBlog
::STATUS_ACTIVE
);
64 return $query->setParameter(
65 'statuses', PhameBlog
::STATUS_ARCHIVED
);
68 return parent
::buildSavedQueryFromBuiltin($query_key);
70 protected function renderResultList(
72 PhabricatorSavedQuery
$query,
75 assert_instances_of($blogs, 'PhameBlog');
76 $viewer = $this->requireViewer();
78 $list = new PHUIObjectItemListView();
79 $list->setUser($viewer);
81 foreach ($blogs as $blog) {
83 if ($blog->getDomain()) {
84 $domain = $blog->getDomain();
86 $domain = pht('Local Blog');
88 $item = id(new PHUIObjectItemView())
91 ->setHeader($blog->getName())
92 ->setImageURI($blog->getProfileImageURI())
93 ->setDisabled($blog->isArchived())
94 ->setHref($this->getApplicationURI("/blog/view/{$id}/"))
95 ->addAttribute($domain);
96 if (!$blog->isArchived()) {
97 $button = id(new PHUIButtonView())
100 ->setHref($this->getApplicationURI('/post/edit/?blog='.$id))
101 ->setButtonType(PHUIButtonView
::BUTTONTYPE_SIMPLE
);
102 $item->setSideColumn($button);
105 $list->addItem($item);
108 $result = new PhabricatorApplicationSearchResultView();
109 $result->setObjectList($list);
110 $result->setNoDataString(pht('No blogs found.'));