3 final class PhabricatorCalendarExportSearchEngine
4 extends PhabricatorApplicationSearchEngine
{
6 public function getResultTypeDescription() {
7 return pht('Calendar Exports');
10 public function getApplicationClassName() {
11 return 'PhabricatorCalendarApplication';
14 public function canUseInPanelContext() {
18 public function newQuery() {
19 $viewer = $this->requireViewer();
21 return id(new PhabricatorCalendarExportQuery())
22 ->withAuthorPHIDs(array($viewer->getPHID()));
25 protected function buildCustomSearchFields() {
29 protected function buildQueryFromParameters(array $map) {
30 $query = $this->newQuery();
35 protected function getURI($path) {
36 return '/calendar/export/'.$path;
39 protected function getBuiltinQueryNames() {
41 'all' => pht('All Exports'),
47 public function buildSavedQueryFromBuiltin($query_key) {
48 $query = $this->newSavedQuery();
49 $query->setQueryKey($query_key);
56 return parent
::buildSavedQueryFromBuiltin($query_key);
59 protected function renderResultList(
61 PhabricatorSavedQuery
$query,
64 assert_instances_of($exports, 'PhabricatorCalendarExport');
65 $viewer = $this->requireViewer();
67 $list = new PHUIObjectItemListView();
68 foreach ($exports as $export) {
69 $item = id(new PHUIObjectItemView())
71 ->setObjectName(pht('Export %d', $export->getID()))
72 ->setHeader($export->getName())
73 ->setHref($export->getURI());
75 if ($export->getIsDisabled()) {
76 $item->setDisabled(true);
79 $mode = $export->getPolicyMode();
80 $policy_icon = PhabricatorCalendarExport
::getPolicyModeIcon($mode);
81 $policy_name = PhabricatorCalendarExport
::getPolicyModeName($mode);
82 $policy_color = PhabricatorCalendarExport
::getPolicyModeColor($mode);
85 "{$policy_icon} {$policy_color}",
88 $list->addItem($item);
91 $result = new PhabricatorApplicationSearchResultView();
92 $result->setObjectList($list);
93 $result->setNoDataString(pht('No exports found.'));
98 protected function getNewUserBody() {
99 $doc_name = 'Calendar User Guide: Exporting Events';
100 $doc_href = PhabricatorEnv
::getDoclink($doc_name);
102 $create_button = id(new PHUIButtonView())
104 ->setIcon('fa-book white')
107 ->setColor(PHUIButtonView
::GREEN
);
109 $icon = $this->getApplication()->getIcon();
110 $app_name = $this->getApplication()->getName();
111 $view = id(new PHUIBigInfoView())
112 ->setIcon('fa-download')
113 ->setTitle(pht('No Exports Configured'))
116 'You have not set up any events for export from Calendar yet. '.
117 'See the documentation for instructions on how to get started.'))
118 ->addAction($create_button);