3 final class PhameBlogManageController
extends PhameBlogController
{
5 public function shouldAllowPublic() {
9 public function handleRequest(AphrontRequest
$request) {
10 $viewer = $request->getViewer();
11 $id = $request->getURIData('id');
13 $blog = id(new PhameBlogQuery())
16 ->needProfileImage(true)
17 ->needHeaderImage(true)
20 return new Aphront404Response();
23 if ($blog->isArchived()) {
24 $header_icon = 'fa-ban';
25 $header_name = pht('Archived');
26 $header_color = 'dark';
28 $header_icon = 'fa-check';
29 $header_name = pht('Active');
30 $header_color = 'bluegrey';
33 $picture = $blog->getProfileImageURI();
35 $view = id(new PHUIButtonView())
37 ->setText(pht('View Live'))
38 ->setIcon('fa-external-link')
39 ->setHref($blog->getLiveURI())
40 ->setDisabled($blog->isArchived());
42 $header = id(new PHUIHeaderView())
43 ->setHeader($blog->getName())
45 ->setPolicyObject($blog)
47 ->setStatus($header_icon, $header_color, $header_name)
48 ->addActionLink($view);
50 $can_edit = PhabricatorPolicyFilter
::hasCapability(
53 PhabricatorPolicyCapability
::CAN_EDIT
);
56 $header->setImageEditURL(
57 $this->getApplicationURI('blog/picture/'.$blog->getID().'/'));
60 $curtain = $this->buildCurtain($blog);
61 $properties = $this->buildPropertyView($blog);
62 $file = $this->buildFileView($blog);
64 $crumbs = $this->buildApplicationCrumbs();
65 $crumbs->addTextCrumb(
67 $this->getApplicationURI('blog/'));
68 $crumbs->addTextCrumb(
70 $this->getApplicationURI('blog/view/'.$id));
71 $crumbs->addTextCrumb(pht('Manage Blog'));
72 $crumbs->setBorder(true);
74 $object_box = id(new PHUIObjectBoxView())
76 ->addPropertyList($properties);
78 $timeline = $this->buildTransactionTimeline(
80 new PhameBlogTransactionQuery());
81 $timeline->setShouldTerminate(true);
83 $view = id(new PHUITwoColumnView())
85 ->setCurtain($curtain)
86 ->addPropertySection(pht('Details'), $properties)
87 ->addPropertySection(pht('Header'), $file)
93 return $this->newPage()
94 ->setTitle($blog->getName())
102 private function buildPropertyView(PhameBlog
$blog) {
103 $viewer = $this->getViewer();
105 require_celerity_resource('aphront-tooltip-css');
106 Javelin
::initBehavior('phabricator-tooltips');
108 $properties = id(new PHUIPropertyListView())
111 $full_domain = $blog->getDomainFullURI();
113 $full_domain = phutil_tag('em', array(), pht('No external domain'));
115 $properties->addProperty(pht('Full Domain'), $full_domain);
117 $parent_site = $blog->getParentSite();
119 $parent_site = phutil_tag('em', array(), pht('No parent site'));
122 $properties->addProperty(pht('Parent Site'), $parent_site);
124 $parent_domain = $blog->getParentDomain();
125 if (!$parent_domain) {
126 $parent_domain = phutil_tag('em', array(), pht('No parent domain'));
129 $properties->addProperty(pht('Parent Domain'), $parent_domain);
131 $feed_uri = PhabricatorEnv
::getProductionURI(
132 $this->getApplicationURI('blog/feed/'.$blog->getID().'/'));
133 $properties->addProperty(
138 'sigil' => 'has-tooltip',
140 'tip' => pht('Atom URI does not support custom domains.'),
146 $description = $blog->getDescription();
147 if (strlen($description)) {
148 $description = new PHUIRemarkupView($viewer, $description);
149 $properties->addSectionHeader(
151 PHUIPropertyListView
::ICON_SUMMARY
);
152 $properties->addTextContent($description);
158 private function buildCurtain(PhameBlog
$blog) {
159 $viewer = $this->getViewer();
161 $curtain = $this->newCurtainView($blog);
163 $actions = id(new PhabricatorActionListView())
167 $can_edit = PhabricatorPolicyFilter
::hasCapability(
170 PhabricatorPolicyCapability
::CAN_EDIT
);
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));
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));
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));
196 if ($blog->isArchived()) {
198 id(new PhabricatorActionView())
199 ->setName(pht('Activate Blog'))
200 ->setIcon('fa-check')
202 $this->getApplicationURI('blog/archive/'.$blog->getID().'/'))
203 ->setDisabled(!$can_edit)
204 ->setWorkflow(true));
207 id(new PhabricatorActionView())
208 ->setName(pht('Archive Blog'))
211 $this->getApplicationURI('blog/archive/'.$blog->getID().'/'))
212 ->setDisabled(!$can_edit)
213 ->setWorkflow(true));
219 private function buildFileView(
221 $viewer = $this->getViewer();
223 $view = id(new PHUIPropertyListView())
226 if ($blog->getHeaderImagePHID()) {
227 $view->addImageContent(
231 'src' => $blog->getHeaderImageURI(),
232 'class' => 'phabricator-image-macro-hero',