3 final class PhabricatorCountdownViewController
4 extends PhabricatorCountdownController
{
6 public function shouldAllowPublic() {
10 public function handleRequest(AphrontRequest
$request) {
11 $viewer = $request->getViewer();
12 $id = $request->getURIData('id');
14 $countdown = id(new PhabricatorCountdownQuery())
19 return new Aphront404Response();
22 $countdown_view = id(new PhabricatorCountdownView())
24 ->setCountdown($countdown);
26 $id = $countdown->getID();
27 $title = $countdown->getTitle();
30 ->buildApplicationCrumbs()
31 ->addTextCrumb($countdown->getMonogram())
34 $epoch = $countdown->getEpoch();
35 if ($epoch >= PhabricatorTime
::getNow()) {
38 $status = pht('Running');
40 $icon = 'fa-check-square-o';
42 $status = pht('Launched');
45 $header = id(new PHUIHeaderView())
48 ->setPolicyObject($countdown)
49 ->setStatus($icon, $color, $status)
50 ->setHeaderIcon('fa-rocket');
52 $curtain = $this->buildCurtain($countdown);
53 $subheader = $this->buildSubheaderView($countdown);
55 $timeline = $this->buildTransactionTimeline(
57 new PhabricatorCountdownTransactionQuery());
59 $comment_view = id(new PhabricatorCountdownEditEngine())
61 ->buildEditEngineCommentView($countdown);
69 $view = id(new PHUITwoColumnView())
71 ->setSubheader($subheader)
72 ->setCurtain($curtain)
73 ->setMainColumn($content);
75 return $this->newPage()
80 $countdown->getPHID(),
85 private function buildCurtain(PhabricatorCountdown
$countdown) {
86 $viewer = $this->getViewer();
88 $id = $countdown->getID();
90 $can_edit = PhabricatorPolicyFilter
::hasCapability(
93 PhabricatorPolicyCapability
::CAN_EDIT
);
95 $curtain = $this->newCurtainView($countdown);
98 id(new PhabricatorActionView())
99 ->setIcon('fa-pencil')
100 ->setName(pht('Edit Countdown'))
101 ->setHref($this->getApplicationURI("edit/{$id}/"))
102 ->setDisabled(!$can_edit)
103 ->setWorkflow(!$can_edit));
108 private function buildSubheaderView(
109 PhabricatorCountdown
$countdown) {
110 $viewer = $this->getViewer();
112 $author = $viewer->renderHandle($countdown->getAuthorPHID())->render();
113 $date = phabricator_datetime($countdown->getDateCreated(), $viewer);
114 $author = phutil_tag('strong', array(), $author);
116 $person = id(new PhabricatorPeopleQuery())
118 ->withPHIDs(array($countdown->getAuthorPHID()))
119 ->needProfileImage(true)
122 $image_uri = $person->getProfileImageURI();
123 $image_href = '/p/'.$person->getUsername();
125 $content = pht('Authored by %s on %s.', $author, $date);
127 return id(new PHUIHeadThingView())
128 ->setImage($image_uri)
129 ->setImageHref($image_href)
130 ->setContent($content);