@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 PonderFooterView extends AphrontTagView {
4
5 private $contentID;
6 private $count;
7 private $actions = array();
8
9 public function setContentID($content_id) {
10 $this->contentID = $content_id;
11 return $this;
12 }
13
14 public function setCount($count) {
15 $this->count = $count;
16 return $this;
17 }
18
19 public function addAction($action) {
20 $this->actions[] = $action;
21 return $this;
22 }
23
24 protected function getTagAttributes() {
25 return array(
26 'class' => 'ponder-footer-view',
27 );
28 }
29
30 protected function getTagContent() {
31 require_celerity_resource('ponder-view-css');
32 Javelin::initBehavior('phabricator-reveal-content');
33
34 $hide_action_id = celerity_generate_unique_node_id();
35 $show_action_id = celerity_generate_unique_node_id();
36 $content_id = $this->contentID;
37
38 if ($this->count == 0) {
39 $text = pht('Add a Comment');
40 } else {
41 $text = pht('Show %s Comment(s)', new PhutilNumber($this->count));
42 }
43
44 $actions = array();
45 $hide_action = javelin_tag(
46 'a',
47 array(
48 'sigil' => 'reveal-content',
49 'class' => 'ponder-footer-action',
50 'id' => $hide_action_id,
51 'href' => '#',
52 'meta' => array(
53 'showIDs' => array($content_id, $show_action_id),
54 'hideIDs' => array($hide_action_id),
55 ),
56 ),
57 array($text));
58
59 $show_action = javelin_tag(
60 'a',
61 array(
62 'sigil' => 'reveal-content',
63 'style' => 'display: none;',
64 'class' => 'ponder-footer-action',
65 'id' => $show_action_id,
66 'href' => '#',
67 'meta' => array(
68 'showIDs' => array($hide_action_id),
69 'hideIDs' => array($content_id, $show_action_id),
70 ),
71 ),
72 array(pht('Hide Comments')));
73
74 $actions[] = $hide_action;
75 $actions[] = $show_action;
76
77 return array($actions, $this->actions);
78 }
79
80}