Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14038832
D16199.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D16199.id.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
@@ -3794,6 +3794,7 @@
'PhameBlogArchiveController' => 'applications/phame/controller/blog/PhameBlogArchiveController.php',
'PhameBlogController' => 'applications/phame/controller/blog/PhameBlogController.php',
'PhameBlogCreateCapability' => 'applications/phame/capability/PhameBlogCreateCapability.php',
+ 'PhameBlogDatasource' => 'applications/phame/typeahead/PhameBlogDatasource.php',
'PhameBlogEditConduitAPIMethod' => 'applications/phame/conduit/PhameBlogEditConduitAPIMethod.php',
'PhameBlogEditController' => 'applications/phame/controller/blog/PhameBlogEditController.php',
'PhameBlogEditEngine' => 'applications/phame/editor/PhameBlogEditEngine.php',
@@ -8698,6 +8699,7 @@
'PhameBlogArchiveController' => 'PhameBlogController',
'PhameBlogController' => 'PhameController',
'PhameBlogCreateCapability' => 'PhabricatorPolicyCapability',
+ 'PhameBlogDatasource' => 'PhabricatorTypeaheadDatasource',
'PhameBlogEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod',
'PhameBlogEditController' => 'PhameBlogController',
'PhameBlogEditEngine' => 'PhabricatorEditEngine',
diff --git a/src/applications/phame/controller/blog/PhameBlogViewController.php b/src/applications/phame/controller/blog/PhameBlogViewController.php
--- a/src/applications/phame/controller/blog/PhameBlogViewController.php
+++ b/src/applications/phame/controller/blog/PhameBlogViewController.php
@@ -142,6 +142,14 @@
$actions->addAction(
id(new PhabricatorActionView())
->setUser($viewer)
+ ->setIcon('fa-search')
+ ->setHref(
+ $this->getApplicationURI('post/?blog='.$blog->getPHID()))
+ ->setName(pht('Search Posts')));
+
+ $actions->addAction(
+ id(new PhabricatorActionView())
+ ->setUser($viewer)
->setIcon('fa-globe')
->setHref($blog->getLiveURI())
->setName(pht('View Live')));
diff --git a/src/applications/phame/query/PhamePostSearchEngine.php b/src/applications/phame/query/PhamePostSearchEngine.php
--- a/src/applications/phame/query/PhamePostSearchEngine.php
+++ b/src/applications/phame/query/PhamePostSearchEngine.php
@@ -18,25 +18,36 @@
protected function buildQueryFromParameters(array $map) {
$query = $this->newQuery();
- if (strlen($map['visibility'])) {
- $query->withVisibility(array($map['visibility']));
+ if ($map['visibility']) {
+ $query->withVisibility($map['visibility']);
}
+ if ($map['blogPHIDs']) {
+ $query->withBlogPHIDs($map['blogPHIDs']);
+ }
+
return $query;
}
protected function buildCustomSearchFields() {
return array(
- id(new PhabricatorSearchSelectField())
+ id(new PhabricatorSearchCheckboxesField())
->setKey('visibility')
->setLabel(pht('Visibility'))
->setOptions(
array(
- '' => pht('All'),
PhameConstants::VISIBILITY_PUBLISHED => pht('Published'),
PhameConstants::VISIBILITY_DRAFT => pht('Draft'),
PhameConstants::VISIBILITY_ARCHIVED => pht('Archived'),
)),
+ id(new PhabricatorSearchDatasourceField())
+ ->setLabel(pht('Blogs'))
+ ->setKey('blogPHIDs')
+ ->setAliases(array('blog', 'blogs', 'blogPHIDs'))
+ ->setDescription(
+ pht('Search for posts within certain blogs.'))
+ ->setDatasource(new PhameBlogDatasource()),
+
);
}
@@ -63,13 +74,13 @@
return $query;
case 'live':
return $query->setParameter(
- 'visibility', PhameConstants::VISIBILITY_PUBLISHED);
+ 'visibility', array(PhameConstants::VISIBILITY_PUBLISHED));
case 'draft':
return $query->setParameter(
- 'visibility', PhameConstants::VISIBILITY_DRAFT);
+ 'visibility', array(PhameConstants::VISIBILITY_DRAFT));
case 'archived':
return $query->setParameter(
- 'visibility', PhameConstants::VISIBILITY_ARCHIVED);
+ 'visibility', array(PhameConstants::VISIBILITY_ARCHIVED));
}
return parent::buildSavedQueryFromBuiltin($query_key);
diff --git a/src/applications/phame/typeahead/PhameBlogDatasource.php b/src/applications/phame/typeahead/PhameBlogDatasource.php
new file mode 100644
--- /dev/null
+++ b/src/applications/phame/typeahead/PhameBlogDatasource.php
@@ -0,0 +1,53 @@
+<?php
+
+final class PhameBlogDatasource
+ extends PhabricatorTypeaheadDatasource {
+
+ public function getBrowseTitle() {
+ return pht('Browse Blogs');
+ }
+
+ public function getPlaceholderText() {
+ return pht('Type a blog name...');
+ }
+
+ public function getDatasourceApplicationClass() {
+ return 'PhabricatorPhameApplication';
+ }
+
+ public function loadResults() {
+ $viewer = $this->getViewer();
+
+ $blogs = id(new PhameBlogQuery())
+ ->setViewer($viewer)
+ ->needProfileImage(true)
+ ->requireCapabilities(
+ array(
+ PhabricatorPolicyCapability::CAN_VIEW,
+ PhabricatorPolicyCapability::CAN_EDIT,
+ ))
+ ->execute();
+
+ $results = array();
+ foreach ($blogs as $blog) {
+ $closed = null;
+
+ $status = $blog->getStatus();
+ if ($status === PhabricatorBadgesBadge::STATUS_ARCHIVED) {
+ $closed = pht('Archived');
+ }
+
+ $results[] = id(new PhabricatorTypeaheadResult())
+ ->setName($blog->getName())
+ ->setClosed($closed)
+ ->addAttribute(pht('Phame Blog'))
+ ->setImageURI($blog->getProfileImageURI())
+ ->setPHID($blog->getPHID());
+ }
+
+ $results = $this->filterResultsAgainstTokens($results);
+
+ return $results;
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 12, 2:17 AM (6 d, 21 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6733918
Default Alt Text
D16199.id.diff (5 KB)
Attached To
Mode
D16199: Improve PhamePost search options
Attached
Detach File
Event Timeline
Log In to Comment