@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<?php
2
3final class PhabricatorCountdownView extends AphrontView {
4
5 private $countdown;
6
7 public function setCountdown(PhabricatorCountdown $countdown) {
8 $this->countdown = $countdown;
9 return $this;
10 }
11
12 public function render() {
13 $countdown = $this->countdown;
14 require_celerity_resource('phabricator-countdown-css');
15
16 $header_text = array(
17 $countdown->getMonogram(),
18 ' ',
19 phutil_tag(
20 'a',
21 array(
22 'href' => $countdown->getURI(),
23 ),
24 $countdown->getTitle()),
25 );
26
27 $header = id(new PHUIHeaderView())
28 ->setHeader($header_text);
29
30 $ths = array(
31 phutil_tag('th', array(), pht('Days')),
32 phutil_tag('th', array(), pht('Hours')),
33 phutil_tag('th', array(), pht('Minutes')),
34 phutil_tag('th', array(), pht('Seconds')),
35 );
36
37 $dashes = array(
38 javelin_tag('td', array('sigil' => 'phabricator-timer-days'), '-'),
39 javelin_tag('td', array('sigil' => 'phabricator-timer-hours'), '-'),
40 javelin_tag('td', array('sigil' => 'phabricator-timer-minutes'), '-'),
41 javelin_tag('td', array('sigil' => 'phabricator-timer-seconds'), '-'),
42 );
43
44 $epoch = $countdown->getEpoch();
45 $launch_date = phabricator_datetime($epoch, $this->getUser());
46 $foot = phutil_tag(
47 'td',
48 array(
49 'colspan' => '4',
50 'class' => 'phabricator-timer-foot',
51 ),
52 $launch_date);
53
54 $description = $countdown->getDescription();
55 if (strlen($description)) {
56 $description = new PHUIRemarkupView($this->getUser(), $description);
57 $description = phutil_tag(
58 'div',
59 array(
60 'class' => 'countdown-description phabricator-remarkup',
61 ),
62 $description);
63 }
64
65 $container = celerity_generate_unique_node_id();
66 $content = phutil_tag(
67 'div',
68 array('class' => 'phabricator-timer', 'id' => $container),
69 array(
70 $description,
71 phutil_tag('table', array('class' => 'phabricator-timer-table'), array(
72 phutil_tag('tr', array(), $ths),
73 phutil_tag('tr', array(), $dashes),
74 phutil_tag('tr', array(), $foot),
75 )),
76 ));
77
78 Javelin::initBehavior('countdown-timer', array(
79 'timestamp' => $countdown->getEpoch(),
80 'container' => $container,
81 ));
82
83 return id(new PHUIObjectBoxView())
84 ->setHeader($header)
85 ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
86 ->addClass('phabricator-timer-view')
87 ->appendChild($content);
88 }
89
90}