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

at recaptime-dev/main 128 lines 3.3 kB view raw
1<?php 2 3final class PhabricatorCalendarExportSearchEngine 4 extends PhabricatorApplicationSearchEngine { 5 6 public function getResultTypeDescription() { 7 return pht('Calendar Exports'); 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 $viewer = $this->requireViewer(); 20 21 return id(new PhabricatorCalendarExportQuery()) 22 ->withAuthorPHIDs(array($viewer->getPHID())); 23 } 24 25 protected function buildCustomSearchFields() { 26 return array(); 27 } 28 29 protected function buildQueryFromParameters(array $map) { 30 $query = $this->newQuery(); 31 32 return $query; 33 } 34 35 protected function getURI($path) { 36 return '/calendar/export/'.$path; 37 } 38 39 protected function getBuiltinQueryNames() { 40 $names = array( 41 'all' => pht('All Exports'), 42 ); 43 44 return $names; 45 } 46 47 public function buildSavedQueryFromBuiltin($query_key) { 48 $query = $this->newSavedQuery(); 49 $query->setQueryKey($query_key); 50 51 switch ($query_key) { 52 case 'all': 53 return $query; 54 } 55 56 return parent::buildSavedQueryFromBuiltin($query_key); 57 } 58 59 /** 60 * @param array<PhabricatorCalendarExport> $exports 61 * @param PhabricatorSavedQuery $query 62 * @param array<PhabricatorObjectHandle> $handles 63 */ 64 protected function renderResultList( 65 array $exports, 66 PhabricatorSavedQuery $query, 67 array $handles) { 68 69 assert_instances_of($exports, PhabricatorCalendarExport::class); 70 $viewer = $this->requireViewer(); 71 72 $list = new PHUIObjectItemListView(); 73 foreach ($exports as $export) { 74 $item = id(new PHUIObjectItemView()) 75 ->setViewer($viewer) 76 ->setObjectName(pht('Export %d', $export->getID())) 77 ->setHeader($export->getName()) 78 ->setHref($export->getURI()); 79 80 if ($export->getIsDisabled()) { 81 $item->setDisabled(true); 82 } 83 84 $mode = $export->getPolicyMode(); 85 $policy_icon = PhabricatorCalendarExport::getPolicyModeIcon($mode); 86 $policy_name = PhabricatorCalendarExport::getPolicyModeName($mode); 87 $policy_color = PhabricatorCalendarExport::getPolicyModeColor($mode); 88 89 $item->addIcon( 90 "{$policy_icon} {$policy_color}", 91 $policy_name); 92 93 $list->addItem($item); 94 } 95 96 $result = new PhabricatorApplicationSearchResultView(); 97 $result->setObjectList($list); 98 $result->setNoDataString(pht('No exports found.')); 99 100 return $result; 101 } 102 103 protected function getNewUserBody() { 104 $doc_name = 'Calendar User Guide: Exporting Events'; 105 $doc_href = PhabricatorEnv::getDoclink($doc_name); 106 107 $create_button = id(new PHUIButtonView()) 108 ->setTag('a') 109 ->setIcon('fa-book white') 110 ->setText($doc_name) 111 ->setHref($doc_href) 112 ->setColor(PHUIButtonView::GREEN); 113 114 $icon = $this->getApplication()->getIcon(); 115 $app_name = $this->getApplication()->getName(); 116 $view = id(new PHUIBigInfoView()) 117 ->setIcon('fa-download') 118 ->setTitle(pht('No Exports Configured')) 119 ->setDescription( 120 pht( 121 'You have not set up any events for export from Calendar yet. '. 122 'See the documentation for instructions on how to get started.')) 123 ->addAction($create_button); 124 125 return $view; 126 } 127 128}