@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<?php
2
3final class PhabricatorCalendarImportSearchEngine
4 extends PhabricatorApplicationSearchEngine {
5
6 public function getResultTypeDescription() {
7 return pht('Calendar Imports');
8 }
9
10 public function getApplicationClassName() {
11 return PhabricatorCalendarApplication::class;
12 }
13
14 public function canUseInPanelContext() {
15 return false;
16 }
17
18 public function newQuery() {
19 return new PhabricatorCalendarImportQuery();
20 }
21
22 protected function buildCustomSearchFields() {
23 return array();
24 }
25
26 protected function buildQueryFromParameters(array $map) {
27 $query = $this->newQuery();
28
29 return $query;
30 }
31
32 protected function getURI($path) {
33 return '/calendar/import/'.$path;
34 }
35
36 protected function getBuiltinQueryNames() {
37 $names = array(
38 'all' => pht('All Imports'),
39 );
40
41 return $names;
42 }
43
44 public function buildSavedQueryFromBuiltin($query_key) {
45 $query = $this->newSavedQuery();
46 $query->setQueryKey($query_key);
47
48 switch ($query_key) {
49 case 'all':
50 return $query;
51 }
52
53 return parent::buildSavedQueryFromBuiltin($query_key);
54 }
55
56 /**
57 * @param array<PhabricatorCalendarImport> $imports
58 * @param PhabricatorSavedQuery $query
59 * @param array<PhabricatorObjectHandle> $handles
60 */
61 protected function renderResultList(
62 array $imports,
63 PhabricatorSavedQuery $query,
64 array $handles) {
65
66 assert_instances_of($imports, PhabricatorCalendarImport::class);
67 $viewer = $this->requireViewer();
68
69 $list = new PHUIObjectItemListView();
70 foreach ($imports as $import) {
71 $item = id(new PHUIObjectItemView())
72 ->setViewer($viewer)
73 ->setObjectName(pht('Import %d', $import->getID()))
74 ->setHeader($import->getDisplayName())
75 ->setHref($import->getURI());
76
77 if ($import->getIsDisabled()) {
78 $item->setDisabled(true);
79 }
80
81 $list->addItem($item);
82 }
83
84 $result = new PhabricatorApplicationSearchResultView();
85 $result->setObjectList($list);
86 $result->setNoDataString(pht('No imports found.'));
87
88 return $result;
89 }
90}