Changeset View
Changeset View
Standalone View
Standalone View
src/view/page/PhabricatorStandardPageView.php
| Show First 20 Lines • Show All 365 Lines • ▼ Show 20 Lines | $tail = array( | ||||
| parent::getTail(), | parent::getTail(), | ||||
| ); | ); | ||||
| $response = CelerityAPI::getStaticResourceResponse(); | $response = CelerityAPI::getStaticResourceResponse(); | ||||
| if (PhabricatorEnv::getEnvConfig('notification.enabled')) { | if (PhabricatorEnv::getEnvConfig('notification.enabled')) { | ||||
| if ($user && $user->isLoggedIn()) { | if ($user && $user->isLoggedIn()) { | ||||
| $aphlict_object_id = celerity_generate_unique_node_id(); | |||||
| $aphlict_container_id = celerity_generate_unique_node_id(); | |||||
| $client_uri = PhabricatorEnv::getEnvConfig('notification.client-uri'); | $client_uri = PhabricatorEnv::getEnvConfig('notification.client-uri'); | ||||
| $client_uri = new PhutilURI($client_uri); | $client_uri = new PhutilURI($client_uri); | ||||
| if ($client_uri->getDomain() == 'localhost') { | if ($client_uri->getDomain() == 'localhost') { | ||||
| $this_host = $this->getRequest()->getHost(); | $this_host = $this->getRequest()->getHost(); | ||||
| $this_host = new PhutilURI('http://'.$this_host.'/'); | $this_host = new PhutilURI('http://'.$this_host.'/'); | ||||
| $client_uri->setDomain($this_host->getDomain()); | $client_uri->setDomain($this_host->getDomain()); | ||||
| } | } | ||||
| $map = CelerityResourceMap::getNamedInstance('phabricator'); | |||||
| $swf_uri = $response->getURI($map, 'rsrc/swf/aphlict.swf', true); | |||||
| $enable_debug = PhabricatorEnv::getEnvConfig('notification.debug'); | |||||
| $subscriptions = $this->pageObjects; | $subscriptions = $this->pageObjects; | ||||
| if ($user) { | if ($user) { | ||||
| $subscriptions[] = $user->getPHID(); | $subscriptions[] = $user->getPHID(); | ||||
| } | } | ||||
| if ($request->isHTTPS()) { | |||||
| $client_uri->setProtocol('wss'); | |||||
| } else { | |||||
| $client_uri->setProtocol('ws'); | |||||
| } | |||||
| Javelin::initBehavior( | Javelin::initBehavior( | ||||
| 'aphlict-listen', | 'aphlict-listen', | ||||
| array( | array( | ||||
| 'id' => $aphlict_object_id, | 'websocketURI' => (string)$client_uri, | ||||
| 'containerID' => $aphlict_container_id, | |||||
| 'server' => $client_uri->getDomain(), | |||||
| 'port' => $client_uri->getPort(), | |||||
| 'debug' => $enable_debug, | |||||
| 'swfURI' => $swf_uri, | |||||
| 'pageObjects' => array_fill_keys($this->pageObjects, true), | 'pageObjects' => array_fill_keys($this->pageObjects, true), | ||||
| 'subscriptions' => $subscriptions, | 'subscriptions' => $subscriptions, | ||||
| )); | )); | ||||
| $tail[] = phutil_tag( | |||||
| 'div', | |||||
| array( | |||||
| 'id' => $aphlict_container_id, | |||||
| 'style' => | |||||
| 'position: absolute; width: 0; height: 0; overflow: hidden;', | |||||
| ), | |||||
| ''); | |||||
| } | } | ||||
| } | } | ||||
| $tail[] = $response->renderHTMLFooter(); | $tail[] = $response->renderHTMLFooter(); | ||||
| return $tail; | return $tail; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 93 Lines • Show Last 20 Lines | |||||