@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Improve PhamePost search options

Summary: Ref T9360. This adds ability to search posts by blog(s) and by type better.

Test Plan:
Create some posts, search for them.

{F1705961}

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T9360

Differential Revision: https://secure.phabricator.com/D16199

+81 -7
+2
src/__phutil_library_map__.php
··· 3794 3794 'PhameBlogArchiveController' => 'applications/phame/controller/blog/PhameBlogArchiveController.php', 3795 3795 'PhameBlogController' => 'applications/phame/controller/blog/PhameBlogController.php', 3796 3796 'PhameBlogCreateCapability' => 'applications/phame/capability/PhameBlogCreateCapability.php', 3797 + 'PhameBlogDatasource' => 'applications/phame/typeahead/PhameBlogDatasource.php', 3797 3798 'PhameBlogEditConduitAPIMethod' => 'applications/phame/conduit/PhameBlogEditConduitAPIMethod.php', 3798 3799 'PhameBlogEditController' => 'applications/phame/controller/blog/PhameBlogEditController.php', 3799 3800 'PhameBlogEditEngine' => 'applications/phame/editor/PhameBlogEditEngine.php', ··· 8698 8699 'PhameBlogArchiveController' => 'PhameBlogController', 8699 8700 'PhameBlogController' => 'PhameController', 8700 8701 'PhameBlogCreateCapability' => 'PhabricatorPolicyCapability', 8702 + 'PhameBlogDatasource' => 'PhabricatorTypeaheadDatasource', 8701 8703 'PhameBlogEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod', 8702 8704 'PhameBlogEditController' => 'PhameBlogController', 8703 8705 'PhameBlogEditEngine' => 'PhabricatorEditEngine',
+8
src/applications/phame/controller/blog/PhameBlogViewController.php
··· 142 142 $actions->addAction( 143 143 id(new PhabricatorActionView()) 144 144 ->setUser($viewer) 145 + ->setIcon('fa-search') 146 + ->setHref( 147 + $this->getApplicationURI('post/?blog='.$blog->getPHID())) 148 + ->setName(pht('Search Posts'))); 149 + 150 + $actions->addAction( 151 + id(new PhabricatorActionView()) 152 + ->setUser($viewer) 145 153 ->setIcon('fa-globe') 146 154 ->setHref($blog->getLiveURI()) 147 155 ->setName(pht('View Live')));
+18 -7
src/applications/phame/query/PhamePostSearchEngine.php
··· 18 18 protected function buildQueryFromParameters(array $map) { 19 19 $query = $this->newQuery(); 20 20 21 - if (strlen($map['visibility'])) { 22 - $query->withVisibility(array($map['visibility'])); 21 + if ($map['visibility']) { 22 + $query->withVisibility($map['visibility']); 23 + } 24 + if ($map['blogPHIDs']) { 25 + $query->withBlogPHIDs($map['blogPHIDs']); 23 26 } 24 27 28 + 25 29 return $query; 26 30 } 27 31 28 32 protected function buildCustomSearchFields() { 29 33 return array( 30 - id(new PhabricatorSearchSelectField()) 34 + id(new PhabricatorSearchCheckboxesField()) 31 35 ->setKey('visibility') 32 36 ->setLabel(pht('Visibility')) 33 37 ->setOptions( 34 38 array( 35 - '' => pht('All'), 36 39 PhameConstants::VISIBILITY_PUBLISHED => pht('Published'), 37 40 PhameConstants::VISIBILITY_DRAFT => pht('Draft'), 38 41 PhameConstants::VISIBILITY_ARCHIVED => pht('Archived'), 39 42 )), 43 + id(new PhabricatorSearchDatasourceField()) 44 + ->setLabel(pht('Blogs')) 45 + ->setKey('blogPHIDs') 46 + ->setAliases(array('blog', 'blogs', 'blogPHIDs')) 47 + ->setDescription( 48 + pht('Search for posts within certain blogs.')) 49 + ->setDatasource(new PhameBlogDatasource()), 50 + 40 51 ); 41 52 } 42 53 ··· 63 74 return $query; 64 75 case 'live': 65 76 return $query->setParameter( 66 - 'visibility', PhameConstants::VISIBILITY_PUBLISHED); 77 + 'visibility', array(PhameConstants::VISIBILITY_PUBLISHED)); 67 78 case 'draft': 68 79 return $query->setParameter( 69 - 'visibility', PhameConstants::VISIBILITY_DRAFT); 80 + 'visibility', array(PhameConstants::VISIBILITY_DRAFT)); 70 81 case 'archived': 71 82 return $query->setParameter( 72 - 'visibility', PhameConstants::VISIBILITY_ARCHIVED); 83 + 'visibility', array(PhameConstants::VISIBILITY_ARCHIVED)); 73 84 } 74 85 75 86 return parent::buildSavedQueryFromBuiltin($query_key);
+53
src/applications/phame/typeahead/PhameBlogDatasource.php
··· 1 + <?php 2 + 3 + final class PhameBlogDatasource 4 + extends PhabricatorTypeaheadDatasource { 5 + 6 + public function getBrowseTitle() { 7 + return pht('Browse Blogs'); 8 + } 9 + 10 + public function getPlaceholderText() { 11 + return pht('Type a blog name...'); 12 + } 13 + 14 + public function getDatasourceApplicationClass() { 15 + return 'PhabricatorPhameApplication'; 16 + } 17 + 18 + public function loadResults() { 19 + $viewer = $this->getViewer(); 20 + 21 + $blogs = id(new PhameBlogQuery()) 22 + ->setViewer($viewer) 23 + ->needProfileImage(true) 24 + ->requireCapabilities( 25 + array( 26 + PhabricatorPolicyCapability::CAN_VIEW, 27 + PhabricatorPolicyCapability::CAN_EDIT, 28 + )) 29 + ->execute(); 30 + 31 + $results = array(); 32 + foreach ($blogs as $blog) { 33 + $closed = null; 34 + 35 + $status = $blog->getStatus(); 36 + if ($status === PhabricatorBadgesBadge::STATUS_ARCHIVED) { 37 + $closed = pht('Archived'); 38 + } 39 + 40 + $results[] = id(new PhabricatorTypeaheadResult()) 41 + ->setName($blog->getName()) 42 + ->setClosed($closed) 43 + ->addAttribute(pht('Phame Blog')) 44 + ->setImageURI($blog->getProfileImageURI()) 45 + ->setPHID($blog->getPHID()); 46 + } 47 + 48 + $results = $this->filterResultsAgainstTokens($results); 49 + 50 + return $results; 51 + } 52 + 53 + }