@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.

Allow atoms to be queried by book

Summary: Ref T4558. Allows querying for atoms from specified books. Depends on D13091.

Test Plan: Poked around at `/diviner/query/`.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T4558

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

+109 -1
+2
src/__phutil_library_map__.php
··· 649 649 'DivinerAtomizeWorkflow' => 'applications/diviner/workflow/DivinerAtomizeWorkflow.php', 650 650 'DivinerAtomizer' => 'applications/diviner/atomizer/DivinerAtomizer.php', 651 651 'DivinerBookController' => 'applications/diviner/controller/DivinerBookController.php', 652 + 'DivinerBookDatasource' => 'applications/diviner/typeahead/DivinerBookDatasource.php', 652 653 'DivinerBookEditController' => 'applications/diviner/controller/DivinerBookEditController.php', 653 654 'DivinerBookItemView' => 'applications/diviner/view/DivinerBookItemView.php', 654 655 'DivinerBookPHIDType' => 'applications/diviner/phid/DivinerBookPHIDType.php', ··· 4016 4017 'DivinerAtomizeWorkflow' => 'DivinerWorkflow', 4017 4018 'DivinerAtomizer' => 'Phobject', 4018 4019 'DivinerBookController' => 'DivinerController', 4020 + 'DivinerBookDatasource' => 'PhabricatorTypeaheadDatasource', 4019 4021 'DivinerBookEditController' => 'DivinerController', 4020 4022 'DivinerBookItemView' => 'AphrontTagView', 4021 4023 'DivinerBookPHIDType' => 'PhabricatorPHIDType',
+15
src/applications/diviner/query/DivinerAtomSearchEngine.php
··· 14 14 $saved = new PhabricatorSavedQuery(); 15 15 16 16 $saved->setParameter( 17 + 'bookPHIDs', 18 + $this->readPHIDsFromRequest($request, 'bookPHIDs')); 19 + $saved->setParameter( 17 20 'repositoryPHIDs', 18 21 $this->readPHIDsFromRequest($request, 'repositoryPHIDs')); 19 22 $saved->setParameter('name', $request->getStr('name')); ··· 26 29 27 30 public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { 28 31 $query = id(new DivinerAtomQuery()); 32 + 33 + $books = $saved->getParameter('bookPHIDs'); 34 + if ($books) { 35 + $query->withBookPHIDs($books); 36 + } 29 37 30 38 $repository_phids = $saved->getParameter('repositoryPHIDs'); 31 39 if ($repository_phids) { ··· 73 81 isset($types[$type])); 74 82 } 75 83 $form->appendChild($type_control); 84 + 85 + $form->appendControl( 86 + id(new AphrontFormTokenizerControl()) 87 + ->setDatasource(new DivinerBookDatasource()) 88 + ->setName('bookPHIDs') 89 + ->setLabel(pht('Books')) 90 + ->setValue($saved->getParameter('bookPHIDs'))); 76 91 77 92 $form->appendControl( 78 93 id(new AphrontFormTokenizerControl())
+55 -1
src/applications/diviner/query/DivinerBookQuery.php
··· 5 5 private $ids; 6 6 private $phids; 7 7 private $names; 8 + private $nameLike; 9 + private $namePrefix; 8 10 private $repositoryPHIDs; 9 11 10 12 private $needProjectPHIDs; ··· 20 22 return $this; 21 23 } 22 24 25 + public function withNameLike($name) { 26 + $this->nameLike = $name; 27 + return $this; 28 + } 29 + 23 30 public function withNames(array $names) { 24 31 $this->names = $names; 32 + return $this; 33 + } 34 + 35 + public function withNamePrefix($prefix) { 36 + $this->namePrefix = $prefix; 25 37 return $this; 26 38 } 27 39 ··· 121 133 $this->phids); 122 134 } 123 135 124 - if ($this->names) { 136 + if (strlen($this->nameLike)) { 137 + $where[] = qsprintf( 138 + $conn_r, 139 + 'name LIKE %~', 140 + $this->nameLike); 141 + } 142 + 143 + if ($this->names !== null) { 125 144 $where[] = qsprintf( 126 145 $conn_r, 127 146 'name IN (%Ls)', 128 147 $this->names); 129 148 } 130 149 150 + if (strlen($this->namePrefix)) { 151 + $where[] = qsprintf( 152 + $conn_r, 153 + 'name LIKE %>', 154 + $this->namePrefix); 155 + } 156 + 131 157 if ($this->repositoryPHIDs !== null) { 132 158 $where[] = qsprintf( 133 159 $conn_r, ··· 142 168 143 169 public function getQueryApplicationClass() { 144 170 return 'PhabricatorDivinerApplication'; 171 + } 172 + 173 + public function getOrderableColumns() { 174 + return parent::getOrderableColumns() + array( 175 + 'name' => array( 176 + 'column' => 'name', 177 + 'type' => 'string', 178 + 'reverse' => true, 179 + 'unique' => true, 180 + ), 181 + ); 182 + } 183 + 184 + protected function getPagingValueMap($cursor, array $keys) { 185 + $book = $this->loadCursorObject($cursor); 186 + 187 + return array( 188 + 'name' => $book->getName(), 189 + ); 190 + } 191 + 192 + public function getBuiltinOrders() { 193 + return array( 194 + 'name' => array( 195 + 'vector' => array('name'), 196 + 'name' => pht('Name'), 197 + ), 198 + ) + parent::getBuiltinOrders(); 145 199 } 146 200 147 201 }
+37
src/applications/diviner/typeahead/DivinerBookDatasource.php
··· 1 + <?php 2 + 3 + final class DivinerBookDatasource extends PhabricatorTypeaheadDatasource { 4 + 5 + public function getBrowseTitle() { 6 + return pht('Browse Books'); 7 + } 8 + 9 + public function getPlaceholderText() { 10 + return pht('Type a book name...'); 11 + } 12 + 13 + public function getDatasourceApplicationClass() { 14 + return 'PhabricatorDivinerApplication'; 15 + } 16 + 17 + public function loadResults() { 18 + $raw_query = $this->getRawQuery(); 19 + 20 + $query = id(new DivinerBookQuery()) 21 + ->setOrder('name') 22 + ->withNamePrefix($raw_query); 23 + $books = $this->executeQuery($query); 24 + 25 + $results = array(); 26 + foreach ($books as $book) { 27 + $results[] = id(new PhabricatorTypeaheadResult()) 28 + ->setName($book->getTitle()) 29 + ->setURI('/book/'.$book->getName().'/') 30 + ->setPHID($book->getPHID()) 31 + ->setPriorityString($book->getName()); 32 + } 33 + 34 + return $results; 35 + } 36 + 37 + }