Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / conpherence / controller / ConpherenceController.php
blobf47e7bf1add70b02b972aae47db144c92ccd0a4c
1 <?php
3 abstract class ConpherenceController extends PhabricatorController {
5 private $conpherence;
7 public function setConpherence(ConpherenceThread $conpherence) {
8 $this->conpherence = $conpherence;
9 return $this;
11 public function getConpherence() {
12 return $this->conpherence;
15 public function buildApplicationMenu() {
16 $nav = new PHUIListView();
17 $conpherence = $this->conpherence;
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()));
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));
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')));
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/'));
53 return $nav;
56 protected function buildHeaderPaneContent(
57 ConpherenceThread $conpherence) {
58 $viewer = $this->getViewer();
59 $header = null;
60 $id = $conpherence->getID();
62 if ($id) {
63 $data = $conpherence->getDisplayData($this->getViewer());
65 $header = id(new PHUIHeaderView())
66 ->setViewer($viewer)
67 ->setHeader($data['title'])
68 ->setPolicyObject($conpherence)
69 ->setImage($data['image']);
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);
80 $can_edit = PhabricatorPolicyFilter::hasCapability(
81 $viewer,
82 $conpherence,
83 PhabricatorPolicyCapability::CAN_EDIT);
85 if ($can_edit) {
86 $header->setImageURL(
87 $this->getApplicationURI("picture/{$id}/"));
90 $participating = $conpherence->getParticipantIfExists($viewer->getPHID());
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));
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));
109 $widget_key = PhabricatorConpherenceWidgetVisibleSetting::SETTINGKEY;
110 $widget_view = (bool)$viewer->getUserSetting($widget_key, false);
112 Javelin::initBehavior(
113 'toggle-widget',
114 array(
115 'show' => (int)$widget_view,
116 'settingsURI' => '/settings/adjust/?key='.$widget_key,
119 $header->addActionItem(
120 id(new PHUIIconCircleView())
121 ->addSigil('conpherence-widget-toggle')
122 ->setIcon('fa-group')
123 ->setHref('#')
124 ->addClass('conpherence-participant-toggle'));
126 Javelin::initBehavior('conpherence-search');
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'));
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',
145 pht('Join Room'));
147 $hidden = phutil_tag(
148 'input',
149 array(
150 'type' => 'hidden',
151 'name' => 'action',
152 'value' => ConpherenceUpdateActions::JOIN_ROOM,
155 $form = phabricator_form(
156 $viewer,
157 array(
158 'method' => 'POST',
159 'action' => (string)$uri,
161 array(
162 $hidden,
163 $button,
165 $header->addActionItem($form);
169 return $header;
172 public function buildSearchForm() {
173 $viewer = $this->getViewer();
174 $conpherence = $this->conpherence;
175 $name = $conpherence->getTitle();
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),
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',
198 array(
199 $bar,
202 $form_view = phutil_tag(
203 'div',
204 array(
205 'class' => 'conpherence-search-form-view',
207 $form);
209 $results = phutil_tag(
210 'div',
211 array(
212 'id' => 'conpherence-search-results',
213 'class' => 'conpherence-search-results',
216 $view = phutil_tag(
217 'div',
218 array(
219 'class' => 'conpherence-search-window',
221 array(
222 $form_view,
223 $results,
226 return $view;