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

Move rendering to SearchEngine for Calendar

Summary:
Ref T4986. This one needs `getApplicationURI()` so make it a little beefier to deal with that.

(It would be vaguely nice to somehow share the handle and application stuff between Controllers and Engine classes like this, but I don't immediately see a clean way to do it without traits. Not a big deal, in any case.)

Test Plan:
- Viewed Calendar.
- Made a Calendar panel.
- Viewed feed.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4986

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

+87 -56
+2 -10
src/__phutil_library_map__.php
··· 3983 3983 0 => 'PhabricatorAuditDAO', 3984 3984 1 => 'PhabricatorInlineCommentInterface', 3985 3985 ), 3986 - 'PhabricatorAuditListController' => 3987 - array( 3988 - 0 => 'PhabricatorAuditController', 3989 - 1 => 'PhabricatorApplicationSearchResultsControllerInterface', 3990 - ), 3986 + 'PhabricatorAuditListController' => 'PhabricatorAuditController', 3991 3987 'PhabricatorAuditListView' => 'AphrontView', 3992 3988 'PhabricatorAuditMailReceiver' => 'PhabricatorObjectMailReceiver', 3993 3989 'PhabricatorAuditManagementDeleteWorkflow' => 'PhabricatorAuditManagementWorkflow', ··· 4097 4093 'PhabricatorCalendarEventDeleteController' => 'PhabricatorCalendarController', 4098 4094 'PhabricatorCalendarEventEditController' => 'PhabricatorCalendarController', 4099 4095 'PhabricatorCalendarEventInvalidEpochException' => 'Exception', 4100 - 'PhabricatorCalendarEventListController' => 4101 - array( 4102 - 0 => 'PhabricatorCalendarController', 4103 - 1 => 'PhabricatorApplicationSearchResultsControllerInterface', 4104 - ), 4096 + 'PhabricatorCalendarEventListController' => 'PhabricatorCalendarController', 4105 4097 'PhabricatorCalendarEventQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 4106 4098 'PhabricatorCalendarEventSearchEngine' => 'PhabricatorApplicationSearchEngine', 4107 4099 'PhabricatorCalendarEventViewController' => 'PhabricatorCalendarController',
+1 -46
src/applications/calendar/controller/PhabricatorCalendarEventListController.php
··· 1 1 <?php 2 2 3 3 final class PhabricatorCalendarEventListController 4 - extends PhabricatorCalendarController 5 - implements PhabricatorApplicationSearchResultsControllerInterface { 4 + extends PhabricatorCalendarController { 6 5 7 6 private $queryKey; 8 7 ··· 32 31 $nav->selectFilter(null); 33 32 34 33 return $nav; 35 - } 36 - 37 - public function renderResultsList( 38 - array $events, 39 - PhabricatorSavedQuery $query) { 40 - assert_instances_of($events, 'PhabricatorCalendarEvent'); 41 - 42 - $viewer = $this->getRequest()->getUser(); 43 - 44 - $list = new PHUIObjectItemListView(); 45 - foreach ($events as $event) { 46 - if ($event->getUserPHID() == $viewer->getPHID()) { 47 - $href = $this->getApplicationURI('/event/edit/'.$event->getID().'/'); 48 - } else { 49 - $from = $event->getDateFrom(); 50 - $month = phabricator_format_local_time($from, $viewer, 'm'); 51 - $year = phabricator_format_local_time($from, $viewer, 'Y'); 52 - $uri = new PhutilURI($this->getApplicationURI()); 53 - $uri->setQueryParams( 54 - array( 55 - 'month' => $month, 56 - 'year' => $year, 57 - )); 58 - $href = (string) $uri; 59 - } 60 - $from = phabricator_datetime($event->getDateFrom(), $viewer); 61 - $to = phabricator_datetime($event->getDateTo(), $viewer); 62 - 63 - $color = ($event->getStatus() == PhabricatorCalendarEvent::STATUS_AWAY) 64 - ? 'red' 65 - : 'yellow'; 66 - 67 - $item = id(new PHUIObjectItemView()) 68 - ->setHeader($event->getTerseSummary($viewer)) 69 - ->setHref($href) 70 - ->setBarColor($color) 71 - ->addAttribute(pht('From %s to %s', $from, $to)) 72 - ->addAttribute( 73 - phutil_utf8_shorten($event->getDescription(), 64)); 74 - 75 - $list->addItem($item); 76 - } 77 - 78 - return $list; 79 34 } 80 35 81 36 }
+49
src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php
··· 3 3 final class PhabricatorCalendarEventSearchEngine 4 4 extends PhabricatorApplicationSearchEngine { 5 5 6 + public function getApplicationClassName() { 7 + return 'PhabricatorApplicationCalendar'; 8 + } 9 + 6 10 public function buildSavedQueryFromRequest(AphrontRequest $request) { 7 11 $saved = new PhabricatorSavedQuery(); 8 12 ··· 158 162 } 159 163 160 164 return parent::buildSavedQueryFromBuiltin($query_key); 165 + } 166 + 167 + protected function renderResultList( 168 + array $events, 169 + PhabricatorSavedQuery $query, 170 + array $handles) { 171 + assert_instances_of($events, 'PhabricatorCalendarEvent'); 172 + 173 + $viewer = $this->requireViewer(); 174 + 175 + $list = new PHUIObjectItemListView(); 176 + foreach ($events as $event) { 177 + if ($event->getUserPHID() == $viewer->getPHID()) { 178 + $href = $this->getApplicationURI('/event/edit/'.$event->getID().'/'); 179 + } else { 180 + $from = $event->getDateFrom(); 181 + $month = phabricator_format_local_time($from, $viewer, 'm'); 182 + $year = phabricator_format_local_time($from, $viewer, 'Y'); 183 + $uri = new PhutilURI($this->getApplicationURI()); 184 + $uri->setQueryParams( 185 + array( 186 + 'month' => $month, 187 + 'year' => $year, 188 + )); 189 + $href = (string) $uri; 190 + } 191 + $from = phabricator_datetime($event->getDateFrom(), $viewer); 192 + $to = phabricator_datetime($event->getDateTo(), $viewer); 193 + 194 + $color = ($event->getStatus() == PhabricatorCalendarEvent::STATUS_AWAY) 195 + ? 'red' 196 + : 'yellow'; 197 + 198 + $item = id(new PHUIObjectItemView()) 199 + ->setHeader($event->getTerseSummary($viewer)) 200 + ->setHref($href) 201 + ->setBarColor($color) 202 + ->addAttribute(pht('From %s to %s', $from, $to)) 203 + ->addAttribute( 204 + phutil_utf8_shorten($event->getDescription(), 64)); 205 + 206 + $list->addItem($item); 207 + } 208 + 209 + return $list; 161 210 } 162 211 163 212 }
+35
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
··· 5 5 * creating and storing saved queries. 6 6 * 7 7 * @task construct Constructing Engines 8 + * @task app Applications 8 9 * @task builtin Builtin Queries 9 10 * @task uri Query URIs 10 11 * @task dates Date Filters ··· 16 17 */ 17 18 abstract class PhabricatorApplicationSearchEngine { 18 19 20 + private $application; 19 21 private $viewer; 20 22 private $errors = array(); 21 23 private $customFields = false; ··· 174 176 } 175 177 } 176 178 return $named_queries; 179 + } 180 + 181 + 182 + /* -( Applications )------------------------------------------------------- */ 183 + 184 + 185 + protected function getApplicationURI($path = '') { 186 + return $this->getApplication()->getApplicationURI($path); 187 + } 188 + 189 + protected function getApplication() { 190 + if (!$this->application) { 191 + $class = $this->getApplicationClassName(); 192 + 193 + $this->application = id(new PhabricatorApplicationQuery()) 194 + ->setViewer($this->requireViewer()) 195 + ->withClasses(array($class)) 196 + ->withInstalled(true) 197 + ->executeOne(); 198 + 199 + if (!$this->application) { 200 + throw new Exception( 201 + pht( 202 + 'Application "%s" is not installed!', 203 + $class)); 204 + } 205 + } 206 + 207 + return $this->application; 208 + } 209 + 210 + protected function getApplicationClassName() { 211 + throw new Exception(pht('Not implemented for this SearchEngine yet!')); 177 212 } 178 213 179 214