@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
3abstract class ConpherenceController extends PhabricatorController {
4
5 private $conpherence;
6
7 public function setConpherence(ConpherenceThread $conpherence) {
8 $this->conpherence = $conpherence;
9 return $this;
10 }
11 public function getConpherence() {
12 return $this->conpherence;
13 }
14
15 public function buildApplicationMenu() {
16 $nav = new PHUIListView();
17 $conpherence = $this->conpherence;
18
19 // Local Links
20 if ($conpherence) {
21 $nav->addMenuItem(
22 id(new PHUIListItemView())
23 ->setName(pht('Joined Rooms'))
24 ->setType(PHUIListItemView::TYPE_LINK)
25 ->setHref($this->getApplicationURI()));
26
27 $nav->addMenuItem(
28 id(new PHUIListItemView())
29 ->setName(pht('Edit Room'))
30 ->setType(PHUIListItemView::TYPE_LINK)
31 ->setHref(
32 $this->getApplicationURI('update/'.$conpherence->getID()).'/')
33 ->setWorkflow(true));
34
35 $nav->addMenuItem(
36 id(new PHUIListItemView())
37 ->setName(pht('Add Participants'))
38 ->setType(PHUIListItemView::TYPE_LINK)
39 ->setHref('#')
40 ->addSigil('conpherence-widget-adder')
41 ->setMetadata(array('widget' => 'widgets-people')));
42 }
43
44 // Global Links
45 $nav->newLabel(pht('Conpherence'));
46 $nav->newLink(
47 pht('New Room'),
48 $this->getApplicationURI('new/'));
49 $nav->newLink(
50 pht('Search Rooms'),
51 $this->getApplicationURI('search/'));
52
53 return $nav;
54 }
55
56 protected function buildHeaderPaneContent(
57 ConpherenceThread $conpherence) {
58 $viewer = $this->getViewer();
59 $header = null;
60 $id = $conpherence->getID();
61
62 if ($id) {
63 $data = $conpherence->getDisplayData($this->getViewer());
64
65 $header = id(new PHUIHeaderView())
66 ->setViewer($viewer)
67 ->setHeader($data['title'])
68 ->setPolicyObject($conpherence)
69 ->setImage($data['image']);
70
71 if (strlen($data['topic'])) {
72 $topic = id(new PHUITagView())
73 ->setName($data['topic'])
74 ->setColor(PHUITagView::COLOR_VIOLET)
75 ->setType(PHUITagView::TYPE_SHADE)
76 ->addClass('conpherence-header-topic');
77 $header->addTag($topic);
78 }
79
80 $can_edit = PhabricatorPolicyFilter::hasCapability(
81 $viewer,
82 $conpherence,
83 PhabricatorPolicyCapability::CAN_EDIT);
84
85 if ($can_edit) {
86 $header->setImageURL(
87 $this->getApplicationURI("picture/{$id}/"));
88 }
89
90 $participating = $conpherence->getParticipantIfExists($viewer->getPHID());
91
92 $header->addActionItem(
93 id(new PHUIIconCircleView())
94 ->setHref(
95 $this->getApplicationURI('edit/'.$conpherence->getID()).'/')
96 ->setIcon('fa-pencil')
97 ->addClass('hide-on-device')
98 ->setColor('violet')
99 ->setWorkflow(true));
100
101 $header->addActionItem(
102 id(new PHUIIconCircleView())
103 ->setHref($this->getApplicationURI("preferences/{$id}/"))
104 ->setIcon('fa-gear')
105 ->addClass('hide-on-device')
106 ->setColor('pink')
107 ->setWorkflow(true));
108
109 $widget_key = PhabricatorConpherenceWidgetVisibleSetting::SETTINGKEY;
110 $widget_view = (bool)$viewer->getUserSetting($widget_key, false);
111
112 Javelin::initBehavior(
113 'toggle-widget',
114 array(
115 'show' => (int)$widget_view,
116 'settingsURI' => '/settings/adjust/?key='.$widget_key,
117 ));
118
119 $header->addActionItem(
120 id(new PHUIIconCircleView())
121 ->addSigil('conpherence-widget-toggle')
122 ->setIcon('fa-group')
123 ->setHref('#')
124 ->addClass('conpherence-participant-toggle'));
125
126 Javelin::initBehavior('conpherence-search');
127
128 $header->addActionItem(
129 id(new PHUIIconCircleView())
130 ->addSigil('conpherence-search-toggle')
131 ->setIcon('fa-search')
132 ->setHref('#')
133 ->setColor('green')
134 ->addClass('conpherence-search-toggle'));
135
136 if (!$participating) {
137 $action = ConpherenceUpdateActions::JOIN_ROOM;
138 $uri = $this->getApplicationURI("update/{$id}/");
139 $button = phutil_tag(
140 'button',
141 array(
142 'type' => 'SUBMIT',
143 'class' => 'button button-green mlr',
144 ),
145 pht('Join Room'));
146
147 $hidden = phutil_tag(
148 'input',
149 array(
150 'type' => 'hidden',
151 'name' => 'action',
152 'value' => ConpherenceUpdateActions::JOIN_ROOM,
153 ));
154
155 $form = phabricator_form(
156 $viewer,
157 array(
158 'method' => 'POST',
159 'action' => (string)$uri,
160 ),
161 array(
162 $hidden,
163 $button,
164 ));
165 $header->addActionItem($form);
166 }
167 }
168
169 return $header;
170 }
171
172 public function buildSearchForm() {
173 $viewer = $this->getViewer();
174 $conpherence = $this->conpherence;
175 $name = $conpherence->getTitle();
176
177 $bar = javelin_tag(
178 'input',
179 array(
180 'type' => 'text',
181 'id' => 'conpherence-search-input',
182 'name' => 'fulltext',
183 'class' => 'conpherence-search-input',
184 'sigil' => 'conpherence-search-input',
185 'placeholder' => pht('Search %s...', $name),
186 ));
187
188 $id = $conpherence->getID();
189 $form = phabricator_form(
190 $viewer,
191 array(
192 'method' => 'POST',
193 'action' => '/conpherence/threadsearch/'.$id.'/',
194 'sigil' => 'conpherence-search-form',
195 'class' => 'conpherence-search-form',
196 'id' => 'conpherence-search-form',
197 ),
198 array(
199 $bar,
200 ));
201
202 $form_view = phutil_tag(
203 'div',
204 array(
205 'class' => 'conpherence-search-form-view',
206 ),
207 $form);
208
209 $results = phutil_tag(
210 'div',
211 array(
212 'id' => 'conpherence-search-results',
213 'class' => 'conpherence-search-results',
214 ));
215
216 $view = phutil_tag(
217 'div',
218 array(
219 'class' => 'conpherence-search-window',
220 ),
221 array(
222 $form_view,
223 $results,
224 ));
225
226 return $view;
227 }
228
229}