@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 PHUIFormTimerControl extends AphrontFormControl {
4
5 private $icon;
6 private $updateURI;
7
8 public function setIcon(PHUIIconView $icon) {
9 $this->icon = $icon;
10 return $this;
11 }
12
13 public function getIcon() {
14 return $this->icon;
15 }
16
17 public function setUpdateURI($update_uri) {
18 $this->updateURI = $update_uri;
19 return $this;
20 }
21
22 public function getUpdateURI() {
23 return $this->updateURI;
24 }
25
26 protected function getCustomControlClass() {
27 return 'phui-form-timer';
28 }
29
30 protected function renderInput() {
31 return $this->newTimerView();
32 }
33
34 public function newTimerView() {
35 $icon_cell = phutil_tag(
36 'td',
37 array(
38 'class' => 'phui-form-timer-icon',
39 ),
40 $this->getIcon());
41
42 $content_cell = phutil_tag(
43 'td',
44 array(
45 'class' => 'phui-form-timer-content',
46 ),
47 $this->renderChildren());
48
49 $row = phutil_tag('tr', array(), array($icon_cell, $content_cell));
50
51 $node_id = null;
52
53 $update_uri = $this->getUpdateURI();
54 if ($update_uri) {
55 $node_id = celerity_generate_unique_node_id();
56
57 Javelin::initBehavior(
58 'phui-timer-control',
59 array(
60 'nodeID' => $node_id,
61 'uri' => $update_uri,
62 ));
63 }
64
65 return phutil_tag('table', array('id' => $node_id), $row);
66 }
67
68}