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 @@ -3983,11 +3983,7 @@ 0 => 'PhabricatorAuditDAO', 1 => 'PhabricatorInlineCommentInterface', ), - 'PhabricatorAuditListController' => - array( - 0 => 'PhabricatorAuditController', - 1 => 'PhabricatorApplicationSearchResultsControllerInterface', - ), + 'PhabricatorAuditListController' => 'PhabricatorAuditController', 'PhabricatorAuditListView' => 'AphrontView', 'PhabricatorAuditMailReceiver' => 'PhabricatorObjectMailReceiver', 'PhabricatorAuditManagementDeleteWorkflow' => 'PhabricatorAuditManagementWorkflow', @@ -4097,11 +4093,7 @@ 'PhabricatorCalendarEventDeleteController' => 'PhabricatorCalendarController', 'PhabricatorCalendarEventEditController' => 'PhabricatorCalendarController', 'PhabricatorCalendarEventInvalidEpochException' => 'Exception', - 'PhabricatorCalendarEventListController' => - array( - 0 => 'PhabricatorCalendarController', - 1 => 'PhabricatorApplicationSearchResultsControllerInterface', - ), + 'PhabricatorCalendarEventListController' => 'PhabricatorCalendarController', 'PhabricatorCalendarEventQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorCalendarEventSearchEngine' => 'PhabricatorApplicationSearchEngine', 'PhabricatorCalendarEventViewController' => 'PhabricatorCalendarController', diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventListController.php b/src/applications/calendar/controller/PhabricatorCalendarEventListController.php --- a/src/applications/calendar/controller/PhabricatorCalendarEventListController.php +++ b/src/applications/calendar/controller/PhabricatorCalendarEventListController.php @@ -1,8 +1,7 @@ getRequest()->getUser(); - - $list = new PHUIObjectItemListView(); - foreach ($events as $event) { - if ($event->getUserPHID() == $viewer->getPHID()) { - $href = $this->getApplicationURI('/event/edit/'.$event->getID().'/'); - } else { - $from = $event->getDateFrom(); - $month = phabricator_format_local_time($from, $viewer, 'm'); - $year = phabricator_format_local_time($from, $viewer, 'Y'); - $uri = new PhutilURI($this->getApplicationURI()); - $uri->setQueryParams( - array( - 'month' => $month, - 'year' => $year, - )); - $href = (string) $uri; - } - $from = phabricator_datetime($event->getDateFrom(), $viewer); - $to = phabricator_datetime($event->getDateTo(), $viewer); - - $color = ($event->getStatus() == PhabricatorCalendarEvent::STATUS_AWAY) - ? 'red' - : 'yellow'; - - $item = id(new PHUIObjectItemView()) - ->setHeader($event->getTerseSummary($viewer)) - ->setHref($href) - ->setBarColor($color) - ->addAttribute(pht('From %s to %s', $from, $to)) - ->addAttribute( - phutil_utf8_shorten($event->getDescription(), 64)); - - $list->addItem($item); - } - - return $list; - } - } diff --git a/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php b/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php --- a/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php +++ b/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php @@ -3,6 +3,10 @@ final class PhabricatorCalendarEventSearchEngine extends PhabricatorApplicationSearchEngine { + public function getApplicationClassName() { + return 'PhabricatorApplicationCalendar'; + } + public function buildSavedQueryFromRequest(AphrontRequest $request) { $saved = new PhabricatorSavedQuery(); @@ -160,4 +164,49 @@ return parent::buildSavedQueryFromBuiltin($query_key); } + protected function renderResultList( + array $events, + PhabricatorSavedQuery $query, + array $handles) { + assert_instances_of($events, 'PhabricatorCalendarEvent'); + + $viewer = $this->requireViewer(); + + $list = new PHUIObjectItemListView(); + foreach ($events as $event) { + if ($event->getUserPHID() == $viewer->getPHID()) { + $href = $this->getApplicationURI('/event/edit/'.$event->getID().'/'); + } else { + $from = $event->getDateFrom(); + $month = phabricator_format_local_time($from, $viewer, 'm'); + $year = phabricator_format_local_time($from, $viewer, 'Y'); + $uri = new PhutilURI($this->getApplicationURI()); + $uri->setQueryParams( + array( + 'month' => $month, + 'year' => $year, + )); + $href = (string) $uri; + } + $from = phabricator_datetime($event->getDateFrom(), $viewer); + $to = phabricator_datetime($event->getDateTo(), $viewer); + + $color = ($event->getStatus() == PhabricatorCalendarEvent::STATUS_AWAY) + ? 'red' + : 'yellow'; + + $item = id(new PHUIObjectItemView()) + ->setHeader($event->getTerseSummary($viewer)) + ->setHref($href) + ->setBarColor($color) + ->addAttribute(pht('From %s to %s', $from, $to)) + ->addAttribute( + phutil_utf8_shorten($event->getDescription(), 64)); + + $list->addItem($item); + } + + return $list; + } + } diff --git a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php --- a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php +++ b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php @@ -5,6 +5,7 @@ * creating and storing saved queries. * * @task construct Constructing Engines + * @task app Applications * @task builtin Builtin Queries * @task uri Query URIs * @task dates Date Filters @@ -16,6 +17,7 @@ */ abstract class PhabricatorApplicationSearchEngine { + private $application; private $viewer; private $errors = array(); private $customFields = false; @@ -177,6 +179,39 @@ } +/* -( Applications )------------------------------------------------------- */ + + + protected function getApplicationURI($path = '') { + return $this->getApplication()->getApplicationURI($path); + } + + protected function getApplication() { + if (!$this->application) { + $class = $this->getApplicationClassName(); + + $this->application = id(new PhabricatorApplicationQuery()) + ->setViewer($this->requireViewer()) + ->withClasses(array($class)) + ->withInstalled(true) + ->executeOne(); + + if (!$this->application) { + throw new Exception( + pht( + 'Application "%s" is not installed!', + $class)); + } + } + + return $this->application; + } + + protected function getApplicationClassName() { + throw new Exception(pht('Not implemented for this SearchEngine yet!')); + } + + /* -( Constructing Engines )----------------------------------------------- */