Remove all "FileHasObject" edge reads and writes
[phabricator.git] / src / applications / calendar / query / PhabricatorCalendarExportSearchEngine.php
blob032cab0c02f3aa3c6cab526cd6f88c9eef4139fa
1 <?php
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() {
15 return false;
18 public function newQuery() {
19 $viewer = $this->requireViewer();
21 return id(new PhabricatorCalendarExportQuery())
22 ->withAuthorPHIDs(array($viewer->getPHID()));
25 protected function buildCustomSearchFields() {
26 return array();
29 protected function buildQueryFromParameters(array $map) {
30 $query = $this->newQuery();
32 return $query;
35 protected function getURI($path) {
36 return '/calendar/export/'.$path;
39 protected function getBuiltinQueryNames() {
40 $names = array(
41 'all' => pht('All Exports'),
44 return $names;
47 public function buildSavedQueryFromBuiltin($query_key) {
48 $query = $this->newSavedQuery();
49 $query->setQueryKey($query_key);
51 switch ($query_key) {
52 case 'all':
53 return $query;
56 return parent::buildSavedQueryFromBuiltin($query_key);
59 protected function renderResultList(
60 array $exports,
61 PhabricatorSavedQuery $query,
62 array $handles) {
64 assert_instances_of($exports, 'PhabricatorCalendarExport');
65 $viewer = $this->requireViewer();
67 $list = new PHUIObjectItemListView();
68 foreach ($exports as $export) {
69 $item = id(new PHUIObjectItemView())
70 ->setViewer($viewer)
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);
84 $item->addIcon(
85 "{$policy_icon} {$policy_color}",
86 $policy_name);
88 $list->addItem($item);
91 $result = new PhabricatorApplicationSearchResultView();
92 $result->setObjectList($list);
93 $result->setNoDataString(pht('No exports found.'));
95 return $result;
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())
103 ->setTag('a')
104 ->setIcon('fa-book white')
105 ->setText($doc_name)
106 ->setHref($doc_href)
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'))
114 ->setDescription(
115 pht(
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);
120 return $view;