3 final class PhabricatorBadgesViewController
4 extends PhabricatorBadgesProfileController
{
6 public function shouldAllowPublic() {
10 public function handleRequest(AphrontRequest
$request) {
11 $viewer = $request->getViewer();
12 $id = $request->getURIData('id');
14 $badge = id(new PhabricatorBadgesQuery())
19 return new Aphront404Response();
22 $this->setBadge($badge);
24 $crumbs = $this->buildApplicationCrumbs();
25 $title = $badge->getName();
27 $header = $this->buildHeaderView();
28 $curtain = $this->buildCurtain($badge);
29 $details = $this->buildDetailsView($badge);
31 $timeline = $this->buildTransactionTimeline(
33 new PhabricatorBadgesTransactionQuery());
35 $comment_view = id(new PhabricatorBadgesEditEngine())
37 ->buildEditEngineCommentView($badge);
39 $view = id(new PHUITwoColumnView())
41 ->setCurtain($curtain)
42 ->setMainColumn(array(
46 ->addPropertySection(pht('Description'), $details);
48 $navigation = $this->buildSideNavView('view');
50 return $this->newPage()
53 ->setPageObjectPHIDs(array($badge->getPHID()))
54 ->setNavigation($navigation)
58 private function buildDetailsView(
59 PhabricatorBadgesBadge
$badge) {
60 $viewer = $this->getViewer();
62 $view = id(new PHUIPropertyListView())
65 $description = $badge->getDescription();
66 if (strlen($description)) {
67 $view->addTextContent(
68 new PHUIRemarkupView($viewer, $description));
71 $badge = id(new PHUIBadgeView())
72 ->setIcon($badge->getIcon())
73 ->setHeader($badge->getName())
74 ->setSubhead($badge->getFlavor())
75 ->setQuality($badge->getQuality());
77 $view->addTextContent($badge);
82 private function buildCurtain(PhabricatorBadgesBadge
$badge) {
83 $viewer = $this->getViewer();
85 $can_edit = PhabricatorPolicyFilter
::hasCapability(
88 PhabricatorPolicyCapability
::CAN_EDIT
);
90 $id = $badge->getID();
91 $edit_uri = $this->getApplicationURI("/edit/{$id}/");
92 $archive_uri = $this->getApplicationURI("/archive/{$id}/");
94 $curtain = $this->newCurtainView($badge);
97 id(new PhabricatorActionView())
98 ->setName(pht('Edit Badge'))
99 ->setIcon('fa-pencil')
100 ->setDisabled(!$can_edit)
101 ->setHref($edit_uri));
103 if ($badge->isArchived()) {
105 id(new PhabricatorActionView())
106 ->setName(pht('Activate Badge'))
107 ->setIcon('fa-check')
108 ->setDisabled(!$can_edit)
109 ->setWorkflow($can_edit)
110 ->setHref($archive_uri));
113 id(new PhabricatorActionView())
114 ->setName(pht('Archive Badge'))
116 ->setDisabled(!$can_edit)
117 ->setWorkflow($can_edit)
118 ->setHref($archive_uri));