@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 239 lines 6.7 kB view raw
1<?php 2 3final class PhameBlogManageController extends PhameBlogController { 4 5 public function shouldAllowPublic() { 6 return true; 7 } 8 9 public function handleRequest(AphrontRequest $request) { 10 $viewer = $request->getViewer(); 11 $id = $request->getURIData('id'); 12 13 $blog = id(new PhameBlogQuery()) 14 ->setViewer($viewer) 15 ->withIDs(array($id)) 16 ->needProfileImage(true) 17 ->needHeaderImage(true) 18 ->executeOne(); 19 if (!$blog) { 20 return new Aphront404Response(); 21 } 22 23 if ($blog->isArchived()) { 24 $header_icon = 'fa-ban'; 25 $header_name = pht('Archived'); 26 $header_color = 'dark'; 27 } else { 28 $header_icon = 'fa-check'; 29 $header_name = pht('Active'); 30 $header_color = 'bluegrey'; 31 } 32 33 $picture = $blog->getProfileImageURI(); 34 35 $view = id(new PHUIButtonView()) 36 ->setTag('a') 37 ->setText(pht('View Live')) 38 ->setIcon('fa-external-link') 39 ->setHref($blog->getLiveURI()) 40 ->setDisabled($blog->isArchived()); 41 42 $header = id(new PHUIHeaderView()) 43 ->setHeader($blog->getName()) 44 ->setUser($viewer) 45 ->setPolicyObject($blog) 46 ->setImage($picture) 47 ->setStatus($header_icon, $header_color, $header_name) 48 ->addActionLink($view); 49 50 $can_edit = PhabricatorPolicyFilter::hasCapability( 51 $viewer, 52 $blog, 53 PhabricatorPolicyCapability::CAN_EDIT); 54 55 if ($can_edit) { 56 $header->setImageEditURL( 57 $this->getApplicationURI('blog/picture/'.$blog->getID().'/')); 58 } 59 60 $curtain = $this->buildCurtain($blog); 61 $properties = $this->buildPropertyView($blog); 62 $file = $this->buildFileView($blog); 63 64 $crumbs = $this->buildApplicationCrumbs(); 65 $crumbs->addTextCrumb( 66 pht('Blogs'), 67 $this->getApplicationURI('blog/')); 68 $crumbs->addTextCrumb( 69 $blog->getName(), 70 $this->getApplicationURI('blog/view/'.$id)); 71 $crumbs->addTextCrumb(pht('Manage Blog')); 72 $crumbs->setBorder(true); 73 74 $object_box = id(new PHUIObjectBoxView()) 75 ->setHeader($header) 76 ->addPropertyList($properties); 77 78 $timeline = $this->buildTransactionTimeline( 79 $blog, 80 new PhameBlogTransactionQuery()); 81 $timeline->setShouldTerminate(true); 82 83 $view = id(new PHUITwoColumnView()) 84 ->setHeader($header) 85 ->setCurtain($curtain) 86 ->addPropertySection(pht('Details'), $properties) 87 ->addPropertySection(pht('Header'), $file) 88 ->setMainColumn( 89 array( 90 $timeline, 91 )); 92 93 return $this->newPage() 94 ->setTitle($blog->getName()) 95 ->setCrumbs($crumbs) 96 ->appendChild( 97 array( 98 $view, 99 )); 100 } 101 102 private function buildPropertyView(PhameBlog $blog) { 103 $viewer = $this->getViewer(); 104 105 require_celerity_resource('aphront-tooltip-css'); 106 Javelin::initBehavior('phabricator-tooltips'); 107 108 $properties = id(new PHUIPropertyListView()) 109 ->setUser($viewer); 110 111 $full_domain = $blog->getDomainFullURI(); 112 if (!$full_domain) { 113 $full_domain = phutil_tag('em', array(), pht('No external domain')); 114 } 115 $properties->addProperty(pht('Full Domain'), $full_domain); 116 117 $parent_site = $blog->getParentSite(); 118 if (!$parent_site) { 119 $parent_site = phutil_tag('em', array(), pht('No parent site')); 120 } 121 122 $properties->addProperty(pht('Parent Site'), $parent_site); 123 124 $parent_domain = $blog->getParentDomain(); 125 if (!$parent_domain) { 126 $parent_domain = phutil_tag('em', array(), pht('No parent domain')); 127 } 128 129 $properties->addProperty(pht('Parent Domain'), $parent_domain); 130 131 $feed_uri = PhabricatorEnv::getProductionURI( 132 $this->getApplicationURI('blog/feed/'.$blog->getID().'/')); 133 $properties->addProperty( 134 pht('Atom URI'), 135 javelin_tag('a', 136 array( 137 'href' => $feed_uri, 138 'sigil' => 'has-tooltip', 139 'meta' => array( 140 'tip' => pht('Atom URI does not support custom domains.'), 141 'size' => 320, 142 ), 143 ), 144 $feed_uri)); 145 146 $description = $blog->getDescription(); 147 if (strlen($description)) { 148 $description = new PHUIRemarkupView($viewer, $description); 149 $properties->addSectionHeader( 150 pht('Description'), 151 PHUIPropertyListView::ICON_SUMMARY); 152 $properties->addTextContent($description); 153 } 154 155 return $properties; 156 } 157 158 private function buildCurtain(PhameBlog $blog) { 159 $viewer = $this->getViewer(); 160 161 $curtain = $this->newCurtainView($blog); 162 163 $actions = id(new PhabricatorActionListView()) 164 ->setObject($blog) 165 ->setUser($viewer); 166 167 $can_edit = PhabricatorPolicyFilter::hasCapability( 168 $viewer, 169 $blog, 170 PhabricatorPolicyCapability::CAN_EDIT); 171 172 $curtain->addAction( 173 id(new PhabricatorActionView()) 174 ->setIcon('fa-pencil') 175 ->setHref($this->getApplicationURI('blog/edit/'.$blog->getID().'/')) 176 ->setName(pht('Edit Blog')) 177 ->setDisabled(!$can_edit) 178 ->setWorkflow(!$can_edit)); 179 180 $curtain->addAction( 181 id(new PhabricatorActionView()) 182 ->setIcon('fa-camera') 183 ->setHref($this->getApplicationURI('blog/header/'.$blog->getID().'/')) 184 ->setName(pht('Edit Blog Header')) 185 ->setDisabled(!$can_edit) 186 ->setWorkflow(!$can_edit)); 187 188 $curtain->addAction( 189 id(new PhabricatorActionView()) 190 ->setIcon('fa-picture-o') 191 ->setHref($this->getApplicationURI('blog/picture/'.$blog->getID().'/')) 192 ->setName(pht('Edit Blog Picture')) 193 ->setDisabled(!$can_edit) 194 ->setWorkflow(!$can_edit)); 195 196 if ($blog->isArchived()) { 197 $curtain->addAction( 198 id(new PhabricatorActionView()) 199 ->setName(pht('Activate Blog')) 200 ->setIcon('fa-check') 201 ->setHref( 202 $this->getApplicationURI('blog/archive/'.$blog->getID().'/')) 203 ->setDisabled(!$can_edit) 204 ->setWorkflow(true)); 205 } else { 206 $curtain->addAction( 207 id(new PhabricatorActionView()) 208 ->setName(pht('Archive Blog')) 209 ->setIcon('fa-ban') 210 ->setHref( 211 $this->getApplicationURI('blog/archive/'.$blog->getID().'/')) 212 ->setDisabled(!$can_edit) 213 ->setWorkflow(true)); 214 } 215 216 return $curtain; 217 } 218 219 private function buildFileView( 220 PhameBlog $blog) { 221 $viewer = $this->getViewer(); 222 223 $view = id(new PHUIPropertyListView()) 224 ->setUser($viewer); 225 226 if ($blog->getHeaderImagePHID()) { 227 $view->addImageContent( 228 phutil_tag( 229 'img', 230 array( 231 'src' => $blog->getHeaderImageURI(), 232 'class' => 'phabricator-image-macro-hero', 233 ))); 234 return $view; 235 } 236 return null; 237 } 238 239}