@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 176 lines 4.9 kB view raw
1<?php 2 3final class PhabricatorCalendarExportViewController 4 extends PhabricatorCalendarController { 5 6 public function handleRequest(AphrontRequest $request) { 7 $viewer = $request->getViewer(); 8 9 $export = id(new PhabricatorCalendarExportQuery()) 10 ->setViewer($viewer) 11 ->withIDs(array($request->getURIData('id'))) 12 ->executeOne(); 13 if (!$export) { 14 return new Aphront404Response(); 15 } 16 17 $crumbs = $this->buildApplicationCrumbs(); 18 $crumbs->addTextCrumb( 19 pht('Exports'), 20 '/calendar/export/'); 21 $crumbs->addTextCrumb(pht('Export %d', $export->getID())); 22 $crumbs->setBorder(true); 23 24 $timeline = $this->buildTransactionTimeline( 25 $export, 26 new PhabricatorCalendarExportTransactionQuery()); 27 $timeline->setShouldTerminate(true); 28 29 $header = $this->buildHeaderView($export); 30 $curtain = $this->buildCurtain($export); 31 $details = $this->buildPropertySection($export); 32 33 $view = id(new PHUITwoColumnView()) 34 ->setHeader($header) 35 ->setMainColumn( 36 array( 37 $timeline, 38 )) 39 ->setCurtain($curtain) 40 ->addPropertySection(pht('Details'), $details); 41 42 $page_title = pht('Export %d %s', $export->getID(), $export->getName()); 43 44 return $this->newPage() 45 ->setTitle($page_title) 46 ->setCrumbs($crumbs) 47 ->setPageObjectPHIDs(array($export->getPHID())) 48 ->appendChild($view); 49 } 50 51 private function buildHeaderView( 52 PhabricatorCalendarExport $export) { 53 $viewer = $this->getViewer(); 54 $id = $export->getID(); 55 56 if ($export->getIsDisabled()) { 57 $icon = 'fa-ban'; 58 $color = 'red'; 59 $status = pht('Disabled'); 60 } else { 61 $icon = 'fa-check'; 62 $color = 'bluegrey'; 63 $status = pht('Active'); 64 } 65 66 $header = id(new PHUIHeaderView()) 67 ->setUser($viewer) 68 ->setHeader($export->getName()) 69 ->setStatus($icon, $color, $status) 70 ->setPolicyObject($export); 71 72 return $header; 73 } 74 75 private function buildCurtain(PhabricatorCalendarExport $export) { 76 $viewer = $this->getRequest()->getUser(); 77 $id = $export->getID(); 78 79 $curtain = $this->newCurtainView($export); 80 81 $can_edit = PhabricatorPolicyFilter::hasCapability( 82 $viewer, 83 $export, 84 PhabricatorPolicyCapability::CAN_EDIT); 85 86 $ics_uri = $export->getICSURI(); 87 88 $edit_uri = "export/edit/{$id}/"; 89 $edit_uri = $this->getApplicationURI($edit_uri); 90 91 $curtain->addAction( 92 id(new PhabricatorActionView()) 93 ->setName(pht('Edit Export')) 94 ->setIcon('fa-pencil') 95 ->setDisabled(!$can_edit) 96 ->setWorkflow(!$can_edit) 97 ->setHref($edit_uri)); 98 99 $curtain->addAction( 100 id(new PhabricatorActionView()) 101 ->setName(pht('Export as .ics')) 102 ->setIcon('fa-download') 103 ->setHref($ics_uri)); 104 105 $disable_uri = "export/disable/{$id}/"; 106 $disable_uri = $this->getApplicationURI($disable_uri); 107 if ($export->getIsDisabled()) { 108 $disable_name = pht('Enable Export'); 109 $disable_icon = 'fa-check'; 110 } else { 111 $disable_name = pht('Disable Export'); 112 $disable_icon = 'fa-ban'; 113 } 114 115 $curtain->addAction( 116 id(new PhabricatorActionView()) 117 ->setName($disable_name) 118 ->setIcon($disable_icon) 119 ->setDisabled(!$can_edit) 120 ->setWorkflow(true) 121 ->setHref($disable_uri)); 122 123 return $curtain; 124 } 125 126 private function buildPropertySection( 127 PhabricatorCalendarExport $export) { 128 $viewer = $this->getViewer(); 129 130 $properties = id(new PHUIPropertyListView()) 131 ->setUser($viewer); 132 133 $mode = $export->getPolicyMode(); 134 135 $policy_icon = PhabricatorCalendarExport::getPolicyModeIcon($mode); 136 $policy_name = PhabricatorCalendarExport::getPolicyModeName($mode); 137 $policy_desc = PhabricatorCalendarExport::getPolicyModeDescription($mode); 138 $policy_color = PhabricatorCalendarExport::getPolicyModeColor($mode); 139 140 $policy_view = id(new PHUIStatusListView()) 141 ->addItem( 142 id(new PHUIStatusItemView()) 143 ->setIcon($policy_icon, $policy_color) 144 ->setTarget($policy_name) 145 ->setNote($policy_desc)); 146 147 $properties->addProperty(pht('Mode'), $policy_view); 148 149 $query_key = $export->getQueryKey(); 150 $query_link = phutil_tag( 151 'a', 152 array( 153 'href' => $this->getApplicationURI("/query/{$query_key}/"), 154 ), 155 $query_key); 156 $properties->addProperty(pht('Query'), $query_link); 157 158 $ics_uri = $export->getICSURI(); 159 $ics_uri = PhabricatorEnv::getURI($ics_uri); 160 161 if ($export->getIsDisabled()) { 162 $ics_href = phutil_tag('em', array(), $ics_uri); 163 } else { 164 $ics_href = phutil_tag( 165 'a', 166 array( 167 'href' => $ics_uri, 168 ), 169 $ics_uri); 170 } 171 172 $properties->addProperty(pht('ICS URI'), $ics_href); 173 174 return $properties; 175 } 176}