2013-07-23 06:16:19 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorCountdownView extends AphrontTagView {
|
|
|
|
|
|
|
|
private $countdown;
|
|
|
|
private $headless;
|
|
|
|
|
|
|
|
|
|
|
|
public function setHeadless($headless) {
|
|
|
|
$this->headless = $headless;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setCountdown(PhabricatorCountdown $countdown) {
|
|
|
|
$this->countdown = $countdown;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-14 06:54:39 +11:00
|
|
|
protected function getTagContent() {
|
2013-07-23 06:16:19 -07:00
|
|
|
$countdown = $this->countdown;
|
|
|
|
|
|
|
|
require_celerity_resource('phabricator-countdown-css');
|
|
|
|
|
|
|
|
$header = null;
|
|
|
|
if (!$this->headless) {
|
|
|
|
$header = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-timer-header',
|
|
|
|
),
|
|
|
|
array(
|
2014-06-09 11:36:49 -07:00
|
|
|
'C'.$countdown->getID(),
|
2013-07-23 06:16:19 -07:00
|
|
|
' ',
|
|
|
|
phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '/countdown/'.$countdown->getID(),
|
|
|
|
),
|
|
|
|
$countdown->getTitle()),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-11-11 09:23:23 -08:00
|
|
|
$ths = array(
|
|
|
|
phutil_tag('th', array(), pht('Days')),
|
|
|
|
phutil_tag('th', array(), pht('Hours')),
|
|
|
|
phutil_tag('th', array(), pht('Minutes')),
|
|
|
|
phutil_tag('th', array(), pht('Seconds')),
|
|
|
|
);
|
|
|
|
|
|
|
|
$dashes = array(
|
2013-07-23 06:16:19 -07:00
|
|
|
javelin_tag('td', array('sigil' => 'phabricator-timer-days'), '-'),
|
|
|
|
javelin_tag('td', array('sigil' => 'phabricator-timer-hours'), '-'),
|
|
|
|
javelin_tag('td', array('sigil' => 'phabricator-timer-minutes'), '-'),
|
2013-11-11 09:23:23 -08:00
|
|
|
javelin_tag('td', array('sigil' => 'phabricator-timer-seconds'), '-'),
|
|
|
|
);
|
|
|
|
|
|
|
|
$container = celerity_generate_unique_node_id();
|
|
|
|
$content = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array('class' => 'phabricator-timer', 'id' => $container),
|
|
|
|
array(
|
|
|
|
$header,
|
|
|
|
phutil_tag('table', array('class' => 'phabricator-timer-table'), array(
|
|
|
|
phutil_tag('tr', array(), $ths),
|
|
|
|
phutil_tag('tr', array(), $dashes),
|
|
|
|
)),
|
|
|
|
));
|
2013-07-23 06:16:19 -07:00
|
|
|
|
|
|
|
Javelin::initBehavior('countdown-timer', array(
|
|
|
|
'timestamp' => $countdown->getEpoch(),
|
|
|
|
'container' => $container,
|
|
|
|
));
|
|
|
|
|
|
|
|
return $content;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|