Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15517113
D13671.id33045.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D13671.id33045.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -3034,6 +3034,7 @@
'PhamePostPreviewController' => 'applications/phame/controller/post/PhamePostPreviewController.php',
'PhamePostPublishController' => 'applications/phame/controller/post/PhamePostPublishController.php',
'PhamePostQuery' => 'applications/phame/query/PhamePostQuery.php',
+ 'PhamePostSearchEngine' => 'applications/phame/query/PhamePostSearchEngine.php',
'PhamePostTransaction' => 'applications/phame/storage/PhamePostTransaction.php',
'PhamePostTransactionQuery' => 'applications/phame/query/PhamePostTransactionQuery.php',
'PhamePostUnpublishController' => 'applications/phame/controller/post/PhamePostUnpublishController.php',
@@ -7001,6 +7002,7 @@
'PhamePostPreviewController' => 'PhameController',
'PhamePostPublishController' => 'PhameController',
'PhamePostQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
+ 'PhamePostSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PhamePostTransaction' => 'PhabricatorApplicationTransaction',
'PhamePostTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'PhamePostUnpublishController' => 'PhameController',
diff --git a/src/applications/phame/query/PhamePostQuery.php b/src/applications/phame/query/PhamePostQuery.php
--- a/src/applications/phame/query/PhamePostQuery.php
+++ b/src/applications/phame/query/PhamePostQuery.php
@@ -81,61 +81,59 @@
return $posts;
}
- protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
- $where = array();
+ protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
+ $where = parent::buildWhereClauseParts($conn);
if ($this->ids) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'p.id IN (%Ld)',
$this->ids);
}
if ($this->phids) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'p.phid IN (%Ls)',
$this->phids);
}
if ($this->bloggerPHIDs) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'p.bloggerPHID IN (%Ls)',
$this->bloggerPHIDs);
}
if ($this->phameTitles) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'p.phameTitle IN (%Ls)',
$this->phameTitles);
}
if ($this->visibility !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'p.visibility = %d',
$this->visibility);
}
if ($this->publishedAfter !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'p.datePublished > %d',
$this->publishedAfter);
}
if ($this->blogPHIDs) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'p.blogPHID in (%Ls)',
$this->blogPHIDs);
}
- $where[] = $this->buildPagingClause($conn_r);
-
- return $this->formatWhereClause($where);
+ return $where;
}
public function getQueryApplicationClass() {
diff --git a/src/applications/phame/query/PhamePostSearchEngine.php b/src/applications/phame/query/PhamePostSearchEngine.php
new file mode 100644
--- /dev/null
+++ b/src/applications/phame/query/PhamePostSearchEngine.php
@@ -0,0 +1,111 @@
+<?php
+
+final class PhamePostSearchEngine
+ extends PhabricatorApplicationSearchEngine {
+
+ public function getResultTypeDescription() {
+ return pht('Phame Posts');
+ }
+
+ public function getApplicationClassName() {
+ return 'PhabricatorPhameApplication';
+ }
+
+ public function newQuery() {
+ return new PhamePostQuery();
+ }
+
+ protected function buildQueryFromParameters(array $map) {
+ $query = $this->newQuery();
+
+ if ($map['visibility']) {
+ $query->withVisibility($map['visibility']);
+ }
+
+ return $query;
+ }
+
+ protected function buildCustomSearchFields() {
+ return array(
+ id(new PhabricatorSearchSelectField())
+ ->setKey('visibility')
+ ->setOptions(array(
+ '' => pht('All'),
+ PhamePost::VISIBILITY_PUBLISHED => pht('Live'),
+ PhamePost::VISIBILITY_DRAFT => pht('Draft'),
+ )),
+ );
+ }
+
+ protected function getURI($path) {
+ return '/phame/post/'.$path;
+ }
+
+ protected function getBuiltinQueryNames() {
+ $names = array(
+ 'all' => pht('All'),
+ 'live' => pht('Live'),
+ 'draft' => pht('Draft'),
+ );
+ return $names;
+ }
+
+ public function buildSavedQueryFromBuiltin($query_key) {
+ $query = $this->newSavedQuery();
+ $query->setQueryKey($query_key);
+
+ switch ($query_key) {
+ case 'all':
+ return $query;
+ case 'live':
+ return $query->setParameter(
+ 'visibility', PhamePost::VISIBILITY_PUBLISHED);
+ // TODO: Doesn't seem able to query because of the 0 value
+ case 'draft':
+ return $query->setParameter(
+ 'visibility', PhamePost::VISIBILITY_DRAFT);
+ }
+
+ return parent::buildSavedQueryFromBuiltin($query_key);
+ }
+ protected function renderResultList(
+ array $posts,
+ PhabricatorSavedQuery $query,
+ array $handles) {
+
+ assert_instances_of($posts, 'PhamePost');
+ $viewer = $this->requireViewer();
+
+ $list = new PHUIObjectItemListView();
+ $list->setUser($viewer);
+
+ foreach ($posts as $post) {
+ $id = $post->getID();
+ $blog = $viewer->renderHandle($post->getBlogPHID())->render();
+ $item = id(new PHUIObjectItemView())
+ ->setUser($viewer)
+ ->setObject($post)
+ ->setHeader($post->getTitle())
+ ->setStatusIcon('fa-star')
+ ->setHref($this->getApplicationURI("/post/view/{$id}/"))
+ ->addAttribute(
+ pht('Blog: %s', $blog));
+ if ($post->isDraft()) {
+ $item->setStatusIcon('fa-star-o grey');
+ $item->setDisabled(true);
+ $item->addIcon('none', pht('Draft Post'));
+ } else {
+ $date = $post->getDatePublished();
+ $item->setEpoch($date);
+ }
+ $list->addItem($item);
+ }
+
+ $result = new PhabricatorApplicationSearchResultView();
+ $result->setObjectList($list);
+ $result->setNoDataString(pht('No blogs found.'));
+
+ return $result;
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 20, 12:39 AM (2 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7731639
Default Alt Text
D13671.id33045.diff (6 KB)
Attached To
Mode
D13671: PhamePostSearchEngine
Attached
Detach File
Event Timeline
Log In to Comment