@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
at upstream/main 269 lines 7.8 kB view raw
1<?php 2 3final class ConpherenceLayoutView extends AphrontTagView { 4 5 private $thread; 6 private $baseURI; 7 private $threadView; 8 private $role; 9 private $header; 10 private $search; 11 private $messages; 12 private $replyForm; 13 private $theme = ConpherenceRoomSettings::COLOR_LIGHT; 14 private $latestTransactionID; 15 16 public function setMessages($messages) { 17 $this->messages = $messages; 18 return $this; 19 } 20 21 public function setReplyForm($reply_form) { 22 $this->replyForm = $reply_form; 23 return $this; 24 } 25 26 public function setHeader($header) { 27 $this->header = $header; 28 return $this; 29 } 30 31 public function setSearch($search) { 32 $this->search = $search; 33 return $this; 34 } 35 36 public function setRole($role) { 37 $this->role = $role; 38 return $this; 39 } 40 41 public function getThreadView() { 42 return $this->threadView; 43 } 44 45 public function setBaseURI($base_uri) { 46 $this->baseURI = $base_uri; 47 return $this; 48 } 49 50 public function setThread(ConpherenceThread $thread) { 51 $this->thread = $thread; 52 return $this; 53 } 54 55 public function setThreadView(ConpherenceThreadListView $thead_view) { 56 $this->threadView = $thead_view; 57 return $this; 58 } 59 60 public function setTheme($theme) { 61 $this->theme = $theme; 62 return $this; 63 } 64 65 public function setLatestTransactionID($id) { 66 $this->latestTransactionID = $id; 67 return $this; 68 } 69 70 protected function getTagAttributes() { 71 $classes = array(); 72 $classes[] = 'conpherence-layout'; 73 $classes[] = 'hide-widgets'; 74 $classes[] = 'conpherence-role-'.$this->role; 75 $classes[] = ConpherenceRoomSettings::getThemeClass($this->theme); 76 77 return array( 78 'id' => 'conpherence-main-layout', 79 'sigil' => 'conpherence-layout', 80 'class' => implode(' ', $classes), 81 ); 82 } 83 84 protected function getTagContent() { 85 require_celerity_resource('conpherence-menu-css'); 86 require_celerity_resource('conpherence-message-pane-css'); 87 require_celerity_resource('conpherence-participant-pane-css'); 88 89 $selected_id = null; 90 $selected_thread_id = null; 91 $selected_thread_phid = null; 92 $can_edit_selected = null; 93 $nux = null; 94 if ($this->thread) { 95 $selected_id = $this->thread->getPHID().'-nav-item'; 96 $selected_thread_id = $this->thread->getID(); 97 $selected_thread_phid = $this->thread->getPHID(); 98 $can_edit_selected = PhabricatorPolicyFilter::hasCapability( 99 $this->getUser(), 100 $this->thread, 101 PhabricatorPolicyCapability::CAN_EDIT); 102 } else { 103 $nux = $this->buildNUXView(); 104 } 105 $this->initBehavior('conpherence-menu', 106 array( 107 'baseURI' => $this->baseURI, 108 'layoutID' => 'conpherence-main-layout', 109 'selectedID' => $selected_id, 110 'selectedThreadID' => $selected_thread_id, 111 'selectedThreadPHID' => $selected_thread_phid, 112 'canEditSelectedThread' => $can_edit_selected, 113 'latestTransactionID' => $this->latestTransactionID, 114 'role' => $this->role, 115 'theme' => ConpherenceRoomSettings::getThemeClass($this->theme), 116 'hasThreadList' => (bool)$this->threadView, 117 'hasThread' => (bool)$this->messages, 118 'hasWidgets' => false, 119 )); 120 121 $this->initBehavior('conpherence-participant-pane'); 122 123 return 124 array( 125 javelin_tag( 126 'div', 127 array( 128 'id' => 'conpherence-menu-pane', 129 'class' => 'conpherence-menu-pane phabricator-side-menu', 130 'sigil' => 'conpherence-menu-pane', 131 ), 132 $this->threadView), 133 javelin_tag( 134 'div', 135 array( 136 'class' => 'conpherence-content-pane', 137 ), 138 array( 139 phutil_tag( 140 'div', 141 array( 142 'class' => 'conpherence-loading-mask', 143 ), 144 ''), 145 javelin_tag( 146 'div', 147 array( 148 'class' => 'conpherence-header-pane', 149 'id' => 'conpherence-header-pane', 150 'sigil' => 'conpherence-header-pane', 151 ), 152 nonempty($this->header, '')), 153 javelin_tag( 154 'div', 155 array( 156 'class' => 'conpherence-no-threads', 157 'sigil' => 'conpherence-no-threads', 158 'style' => 'display: none;', 159 ), 160 $nux), 161 javelin_tag( 162 'div', 163 array( 164 'class' => 'conpherence-participant-pane', 165 'id' => 'conpherence-participant-pane', 166 'sigil' => 'conpherence-participant-pane', 167 ), 168 array( 169 phutil_tag( 170 'div', 171 array( 172 'class' => 'widgets-loading-mask', 173 ), 174 ''), 175 javelin_tag( 176 'div', 177 array( 178 'sigil' => 'conpherence-widgets-holder', 179 ), 180 ''), 181 )), 182 javelin_tag( 183 'div', 184 array( 185 'class' => 'conpherence-message-pane', 186 'id' => 'conpherence-message-pane', 187 'sigil' => 'conpherence-message-pane', 188 ), 189 array( 190 javelin_tag( 191 'div', 192 array( 193 'class' => 'conpherence-messages', 194 'id' => 'conpherence-messages', 195 'sigil' => 'conpherence-messages', 196 ), 197 nonempty($this->messages, '')), 198 javelin_tag( 199 'div', 200 array( 201 'class' => 'conpherence-search-main', 202 'id' => 'conpherence-search-main', 203 'sigil' => 'conpherence-search-main', 204 ), 205 nonempty($this->search, '')), 206 phutil_tag( 207 'div', 208 array( 209 'class' => 'messages-loading-mask', 210 ), 211 ''), 212 javelin_tag( 213 'div', 214 array( 215 'id' => 'conpherence-form', 216 'sigil' => 'conpherence-form', 217 ), 218 nonempty($this->replyForm, '')), 219 )), 220 )), 221 ); 222 } 223 224 private function buildNUXView() { 225 $viewer = $this->getViewer(); 226 227 $engine = id(new ConpherenceThreadSearchEngine()) 228 ->setViewer($viewer); 229 $saved = $engine->buildSavedQueryFromBuiltin('all'); 230 $query = $engine->buildQueryFromSavedQuery($saved); 231 $pager = $engine->newPagerForSavedQuery($saved) 232 ->setPageSize(10); 233 $results = $engine->executeQuery($query, $pager); 234 $view = $engine->renderResults($results, $saved); 235 236 $create_button = id(new PHUIButtonView()) 237 ->setTag('a') 238 ->setText(pht('New Room')) 239 ->setHref('/conpherence/new/') 240 ->setWorkflow(true) 241 ->setColor(PHUIButtonView::GREEN); 242 243 if ($results) { 244 $create_button->setIcon('fa-comments'); 245 246 $header = id(new PHUIHeaderView()) 247 ->setHeader(pht('Joinable Rooms')) 248 ->addActionLink($create_button); 249 250 $box = id(new PHUIObjectBoxView()) 251 ->setHeader($header) 252 ->setObjectList($view->getContent()); 253 254 return $box; 255 } else { 256 257 $view = id(new PHUIBigInfoView()) 258 ->setIcon('fa-comments') 259 ->setTitle(pht('Welcome to Conpherence')) 260 ->setDescription( 261 pht('Conpherence lets you create public or private rooms to '. 262 'communicate with others.')) 263 ->addAction($create_button); 264 265 return $view; 266 } 267 } 268 269}