Path: blob/master/src/view/page/PhabricatorBarePageView.php
12241 views
<?php12/**3* This is a bare HTML page view which has access to Phabricator page4* infrastructure like Celerity, but no content or builtin static resources.5* You basically get a valid HMTL5 document and an empty body tag.6*7* @concrete-extensible8*/9class PhabricatorBarePageView extends AphrontPageView {1011private $request;12private $controller;13private $frameable;14private $deviceReady;1516private $bodyContent;1718public function setController(AphrontController $controller) {19$this->controller = $controller;20return $this;21}2223public function getController() {24return $this->controller;25}2627public function setRequest(AphrontRequest $request) {28$this->request = $request;29return $this;30}3132public function getRequest() {33return $this->request;34}3536public function setFrameable($frameable) {37$this->frameable = $frameable;38return $this;39}4041public function getFrameable() {42return $this->frameable;43}4445public function setDeviceReady($device_ready) {46$this->deviceReady = $device_ready;47return $this;48}4950public function getDeviceReady() {51return $this->deviceReady;52}5354protected function willRenderPage() {55// We render this now to resolve static resources so they can appear in the56// document head.57$this->bodyContent = phutil_implode_html('', $this->renderChildren());58}5960protected function getHead() {61$viewport_tag = null;62if ($this->getDeviceReady()) {63$viewport_tag = phutil_tag(64'meta',65array(66'name' => 'viewport',67'content' => 'width=device-width, '.68'initial-scale=1, '.69'user-scalable=no',70));71}7273$referrer_tag = phutil_tag(74'meta',75array(76'name' => 'referrer',77'content' => 'no-referrer',78));798081$mask_icon = phutil_tag(82'link',83array(84'rel' => 'mask-icon',85'color' => '#3D4B67',86'href' => celerity_get_resource_uri(87'/rsrc/favicons/mask-icon.svg'),88));8990$favicon_links = $this->newFavicons();9192$response = CelerityAPI::getStaticResourceResponse();9394if ($this->getRequest()) {95$viewer = $this->getRequest()->getViewer();96if ($viewer) {97$postprocessor_key = $viewer->getUserSetting(98PhabricatorAccessibilitySetting::SETTINGKEY);99if (strlen($postprocessor_key)) {100$response->setPostProcessorKey($postprocessor_key);101}102}103}104105return hsprintf(106'%s%s%s%s%s',107$viewport_tag,108$mask_icon,109$favicon_links,110$referrer_tag,111$response->renderResourcesOfType('css'));112}113114protected function getBody() {115return $this->bodyContent;116}117118protected function getTail() {119$response = CelerityAPI::getStaticResourceResponse();120return $response->renderResourcesOfType('js');121}122123private function newFavicons() {124$favicon_refs = array(125array(126'rel' => 'apple-touch-icon',127'sizes' => '76x76',128'width' => 76,129'height' => 76,130),131array(132'rel' => 'apple-touch-icon',133'sizes' => '120x120',134'width' => 120,135'height' => 120,136),137array(138'rel' => 'apple-touch-icon',139'sizes' => '152x152',140'width' => 152,141'height' => 152,142),143array(144'rel' => 'icon',145'id' => 'favicon',146'width' => 64,147'height' => 64,148),149);150151$fetch_refs = array();152foreach ($favicon_refs as $key => $spec) {153$ref = id(new PhabricatorFaviconRef())154->setWidth($spec['width'])155->setHeight($spec['height']);156157$favicon_refs[$key]['ref'] = $ref;158$fetch_refs[] = $ref;159}160161id(new PhabricatorFaviconRefQuery())162->withRefs($fetch_refs)163->execute();164165$favicon_links = array();166foreach ($favicon_refs as $spec) {167$favicon_links[] = phutil_tag(168'link',169array(170'rel' => $spec['rel'],171'sizes' => idx($spec, 'sizes'),172'id' => idx($spec, 'id'),173'href' => $spec['ref']->getURI(),174));175}176177return $favicon_links;178}179180}181182183