Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phame/controller/blog/PhameBlogManageController.php
<?php | <?php | ||||
final class PhameBlogManageController extends PhameBlogController { | final class PhameBlogManageController extends PhameBlogController { | ||||
public function shouldAllowPublic() { | public function shouldAllowPublic() { | ||||
return true; | return true; | ||||
} | } | ||||
public function handleRequest(AphrontRequest $request) { | public function handleRequest(AphrontRequest $request) { | ||||
$viewer = $request->getViewer(); | $viewer = $request->getViewer(); | ||||
$id = $request->getURIData('id'); | $id = $request->getURIData('id'); | ||||
$blog = id(new PhameBlogQuery()) | $blog = id(new PhameBlogQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withIDs(array($id)) | ->withIDs(array($id)) | ||||
->needProfileImage(true) | ->needProfileImage(true) | ||||
->needHeaderImage(true) | |||||
->executeOne(); | ->executeOne(); | ||||
if (!$blog) { | if (!$blog) { | ||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
} | } | ||||
if ($blog->isArchived()) { | if ($blog->isArchived()) { | ||||
$header_icon = 'fa-ban'; | $header_icon = 'fa-ban'; | ||||
$header_name = pht('Archived'); | $header_name = pht('Archived'); | ||||
Show All 10 Lines | $header = id(new PHUIHeaderView()) | ||||
->setHeader($blog->getName()) | ->setHeader($blog->getName()) | ||||
->setUser($viewer) | ->setUser($viewer) | ||||
->setPolicyObject($blog) | ->setPolicyObject($blog) | ||||
->setImage($picture) | ->setImage($picture) | ||||
->setStatus($header_icon, $header_color, $header_name); | ->setStatus($header_icon, $header_color, $header_name); | ||||
$curtain = $this->buildCurtain($blog); | $curtain = $this->buildCurtain($blog); | ||||
$properties = $this->buildPropertyView($blog); | $properties = $this->buildPropertyView($blog); | ||||
$file = $this->buildFileView($blog); | |||||
$crumbs = $this->buildApplicationCrumbs(); | $crumbs = $this->buildApplicationCrumbs(); | ||||
$crumbs->addTextCrumb( | $crumbs->addTextCrumb( | ||||
pht('Blogs'), | pht('Blogs'), | ||||
$this->getApplicationURI('blog/')); | $this->getApplicationURI('blog/')); | ||||
$crumbs->addTextCrumb( | $crumbs->addTextCrumb( | ||||
$blog->getName()); | $blog->getName()); | ||||
$crumbs->setBorder(true); | $crumbs->setBorder(true); | ||||
$object_box = id(new PHUIObjectBoxView()) | $object_box = id(new PHUIObjectBoxView()) | ||||
->setHeader($header) | ->setHeader($header) | ||||
->addPropertyList($properties); | ->addPropertyList($properties); | ||||
$timeline = $this->buildTransactionTimeline( | $timeline = $this->buildTransactionTimeline( | ||||
$blog, | $blog, | ||||
new PhameBlogTransactionQuery()); | new PhameBlogTransactionQuery()); | ||||
$timeline->setShouldTerminate(true); | $timeline->setShouldTerminate(true); | ||||
$view = id(new PHUITwoColumnView()) | $view = id(new PHUITwoColumnView()) | ||||
->setHeader($header) | ->setHeader($header) | ||||
->setCurtain($curtain) | ->setCurtain($curtain) | ||||
->addPropertySection(pht('Details'), $properties) | ->addPropertySection(pht('Details'), $properties) | ||||
->addPropertySection(pht('Header'), $file) | |||||
->setMainColumn( | ->setMainColumn( | ||||
array( | array( | ||||
$timeline, | $timeline, | ||||
)); | )); | ||||
return $this->newPage() | return $this->newPage() | ||||
->setTitle($blog->getName()) | ->setTitle($blog->getName()) | ||||
->setCrumbs($crumbs) | ->setCrumbs($crumbs) | ||||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | $curtain->addAction( | ||||
->setIcon('fa-pencil') | ->setIcon('fa-pencil') | ||||
->setHref($this->getApplicationURI('blog/edit/'.$blog->getID().'/')) | ->setHref($this->getApplicationURI('blog/edit/'.$blog->getID().'/')) | ||||
->setName(pht('Edit Blog')) | ->setName(pht('Edit Blog')) | ||||
->setDisabled(!$can_edit) | ->setDisabled(!$can_edit) | ||||
->setWorkflow(!$can_edit)); | ->setWorkflow(!$can_edit)); | ||||
$curtain->addAction( | $curtain->addAction( | ||||
id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
->setIcon('fa-camera') | |||||
->setHref($this->getApplicationURI('blog/header/'.$blog->getID().'/')) | |||||
->setName(pht('Edit Blog Header')) | |||||
->setDisabled(!$can_edit) | |||||
->setWorkflow(!$can_edit)); | |||||
$curtain->addAction( | |||||
id(new PhabricatorActionView()) | |||||
->setIcon('fa-picture-o') | ->setIcon('fa-picture-o') | ||||
->setHref($this->getApplicationURI('blog/picture/'.$blog->getID().'/')) | ->setHref($this->getApplicationURI('blog/picture/'.$blog->getID().'/')) | ||||
->setName(pht('Edit Blog Picture')) | ->setName(pht('Edit Blog Picture')) | ||||
->setDisabled(!$can_edit) | ->setDisabled(!$can_edit) | ||||
->setWorkflow(!$can_edit)); | ->setWorkflow(!$can_edit)); | ||||
if ($blog->isArchived()) { | if ($blog->isArchived()) { | ||||
$curtain->addAction( | $curtain->addAction( | ||||
Show All 13 Lines | if ($blog->isArchived()) { | ||||
$this->getApplicationURI('blog/archive/'.$blog->getID().'/')) | $this->getApplicationURI('blog/archive/'.$blog->getID().'/')) | ||||
->setDisabled(!$can_edit) | ->setDisabled(!$can_edit) | ||||
->setWorkflow(true)); | ->setWorkflow(true)); | ||||
} | } | ||||
return $curtain; | return $curtain; | ||||
} | } | ||||
private function buildFileView( | |||||
PhameBlog $blog) { | |||||
$viewer = $this->getViewer(); | |||||
$view = id(new PHUIPropertyListView()) | |||||
->setUser($viewer); | |||||
if ($blog->getHeaderImagePHID()) { | |||||
$view->addImageContent( | |||||
phutil_tag( | |||||
'img', | |||||
array( | |||||
'src' => $blog->getHeaderImageURI(), | |||||
'class' => 'phabricator-image-macro-hero', | |||||
))); | |||||
return $view; | |||||
} | |||||
return null; | |||||
} | |||||
} | } |