Path: blob/master/src/applications/conpherence/view/ConpherenceLayoutView.php
12256 views
<?php12final class ConpherenceLayoutView extends AphrontTagView {34private $thread;5private $baseURI;6private $threadView;7private $role;8private $header;9private $search;10private $messages;11private $replyForm;12private $theme = ConpherenceRoomSettings::COLOR_LIGHT;13private $latestTransactionID;1415public function setMessages($messages) {16$this->messages = $messages;17return $this;18}1920public function setReplyForm($reply_form) {21$this->replyForm = $reply_form;22return $this;23}2425public function setHeader($header) {26$this->header = $header;27return $this;28}2930public function setSearch($search) {31$this->search = $search;32return $this;33}3435public function setRole($role) {36$this->role = $role;37return $this;38}3940public function getThreadView() {41return $this->threadView;42}4344public function setBaseURI($base_uri) {45$this->baseURI = $base_uri;46return $this;47}4849public function setThread(ConpherenceThread $thread) {50$this->thread = $thread;51return $this;52}5354public function setThreadView(ConpherenceThreadListView $thead_view) {55$this->threadView = $thead_view;56return $this;57}5859public function setTheme($theme) {60$this->theme = $theme;61return $this;62}6364public function setLatestTransactionID($id) {65$this->latestTransactionID = $id;66return $this;67}6869protected function getTagAttributes() {70$classes = array();71$classes[] = 'conpherence-layout';72$classes[] = 'hide-widgets';73$classes[] = 'conpherence-role-'.$this->role;74$classes[] = ConpherenceRoomSettings::getThemeClass($this->theme);7576return array(77'id' => 'conpherence-main-layout',78'sigil' => 'conpherence-layout',79'class' => implode(' ', $classes),80);81}8283protected function getTagContent() {84require_celerity_resource('conpherence-menu-css');85require_celerity_resource('conpherence-message-pane-css');86require_celerity_resource('conpherence-participant-pane-css');8788$selected_id = null;89$selected_thread_id = null;90$selected_thread_phid = null;91$can_edit_selected = null;92$nux = null;93if ($this->thread) {94$selected_id = $this->thread->getPHID().'-nav-item';95$selected_thread_id = $this->thread->getID();96$selected_thread_phid = $this->thread->getPHID();97$can_edit_selected = PhabricatorPolicyFilter::hasCapability(98$this->getUser(),99$this->thread,100PhabricatorPolicyCapability::CAN_EDIT);101} else {102$nux = $this->buildNUXView();103}104$this->initBehavior('conpherence-menu',105array(106'baseURI' => $this->baseURI,107'layoutID' => 'conpherence-main-layout',108'selectedID' => $selected_id,109'selectedThreadID' => $selected_thread_id,110'selectedThreadPHID' => $selected_thread_phid,111'canEditSelectedThread' => $can_edit_selected,112'latestTransactionID' => $this->latestTransactionID,113'role' => $this->role,114'theme' => ConpherenceRoomSettings::getThemeClass($this->theme),115'hasThreadList' => (bool)$this->threadView,116'hasThread' => (bool)$this->messages,117'hasWidgets' => false,118));119120$this->initBehavior('conpherence-participant-pane');121122return123array(124javelin_tag(125'div',126array(127'id' => 'conpherence-menu-pane',128'class' => 'conpherence-menu-pane phabricator-side-menu',129'sigil' => 'conpherence-menu-pane',130),131$this->threadView),132javelin_tag(133'div',134array(135'class' => 'conpherence-content-pane',136),137array(138phutil_tag(139'div',140array(141'class' => 'conpherence-loading-mask',142),143''),144javelin_tag(145'div',146array(147'class' => 'conpherence-header-pane',148'id' => 'conpherence-header-pane',149'sigil' => 'conpherence-header-pane',150),151nonempty($this->header, '')),152javelin_tag(153'div',154array(155'class' => 'conpherence-no-threads',156'sigil' => 'conpherence-no-threads',157'style' => 'display: none;',158),159$nux),160javelin_tag(161'div',162array(163'class' => 'conpherence-participant-pane',164'id' => 'conpherence-participant-pane',165'sigil' => 'conpherence-participant-pane',166),167array(168phutil_tag(169'div',170array(171'class' => 'widgets-loading-mask',172),173''),174javelin_tag(175'div',176array(177'sigil' => 'conpherence-widgets-holder',178),179''),180)),181javelin_tag(182'div',183array(184'class' => 'conpherence-message-pane',185'id' => 'conpherence-message-pane',186'sigil' => 'conpherence-message-pane',187),188array(189javelin_tag(190'div',191array(192'class' => 'conpherence-messages',193'id' => 'conpherence-messages',194'sigil' => 'conpherence-messages',195),196nonempty($this->messages, '')),197javelin_tag(198'div',199array(200'class' => 'conpherence-search-main',201'id' => 'conpherence-search-main',202'sigil' => 'conpherence-search-main',203),204nonempty($this->search, '')),205phutil_tag(206'div',207array(208'class' => 'messages-loading-mask',209),210''),211javelin_tag(212'div',213array(214'id' => 'conpherence-form',215'sigil' => 'conpherence-form',216),217nonempty($this->replyForm, '')),218)),219)),220);221}222223private function buildNUXView() {224$viewer = $this->getViewer();225226$engine = id(new ConpherenceThreadSearchEngine())227->setViewer($viewer);228$saved = $engine->buildSavedQueryFromBuiltin('all');229$query = $engine->buildQueryFromSavedQuery($saved);230$pager = $engine->newPagerForSavedQuery($saved)231->setPageSize(10);232$results = $engine->executeQuery($query, $pager);233$view = $engine->renderResults($results, $saved);234235$create_button = id(new PHUIButtonView())236->setTag('a')237->setText(pht('New Room'))238->setHref('/conpherence/new/')239->setWorkflow(true)240->setColor(PHUIButtonView::GREEN);241242if ($results) {243$create_button->setIcon('fa-comments');244245$header = id(new PHUIHeaderView())246->setHeader(pht('Joinable Rooms'))247->addActionLink($create_button);248249$box = id(new PHUIObjectBoxView())250->setHeader($header)251->setObjectList($view->getContent());252253return $box;254} else {255256$view = id(new PHUIBigInfoView())257->setIcon('fa-comments')258->setTitle(pht('Welcome to Conpherence'))259->setDescription(260pht('Conpherence lets you create public or private rooms to '.261'communicate with others.'))262->addAction($create_button);263264return $view;265}266}267268}269270271