2012-10-16 19:33:47 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is a bare HTML page view which has access to Phabricator page
|
|
|
|
* infrastructure like Celerity, but no content or builtin static resources.
|
|
|
|
* You basically get a valid HMTL5 document and an empty body tag.
|
|
|
|
*
|
|
|
|
* @concrete-extensible
|
|
|
|
*/
|
|
|
|
class PhabricatorBarePageView extends AphrontPageView {
|
|
|
|
|
|
|
|
private $request;
|
|
|
|
private $controller;
|
|
|
|
private $frameable;
|
|
|
|
private $deviceReady;
|
|
|
|
|
|
|
|
private $bodyContent;
|
|
|
|
|
|
|
|
public function setController(AphrontController $controller) {
|
|
|
|
$this->controller = $controller;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getController() {
|
|
|
|
return $this->controller;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setRequest(AphrontRequest $request) {
|
|
|
|
$this->request = $request;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getRequest() {
|
|
|
|
return $this->request;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setFrameable($frameable) {
|
|
|
|
$this->frameable = $frameable;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFrameable() {
|
|
|
|
return $this->frameable;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setDeviceReady($device_ready) {
|
|
|
|
$this->deviceReady = $device_ready;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDeviceReady() {
|
|
|
|
return $this->deviceReady;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function willRenderPage() {
|
|
|
|
// We render this now to resolve static resources so they can appear in the
|
|
|
|
// document head.
|
2013-02-11 23:55:35 +01:00
|
|
|
$this->bodyContent = implode('', $this->renderChildren());
|
2012-10-16 19:33:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function getHead() {
|
|
|
|
$framebust = null;
|
|
|
|
if (!$this->getFrameable()) {
|
|
|
|
$framebust = '(top != self) && top.location.replace(self.location.href);';
|
|
|
|
}
|
|
|
|
|
|
|
|
$viewport_tag = null;
|
2013-01-01 23:09:10 +01:00
|
|
|
if ($this->getDeviceReady()) {
|
2013-01-18 03:39:02 +01:00
|
|
|
$viewport_tag = phutil_tag(
|
2012-10-16 19:33:47 +02:00
|
|
|
'meta',
|
|
|
|
array(
|
|
|
|
'name' => 'viewport',
|
|
|
|
'content' => 'width=device-width, '.
|
|
|
|
'initial-scale=1, '.
|
|
|
|
'maximum-scale=1',
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
$response = CelerityAPI::getStaticResourceResponse();
|
|
|
|
|
|
|
|
$head = array(
|
|
|
|
$viewport_tag,
|
|
|
|
|
|
|
|
'<script type="text/javascript">'.
|
|
|
|
$framebust.
|
2013-02-01 18:34:06 +01:00
|
|
|
'window.__DEV__='.
|
2013-02-01 19:38:08 +01:00
|
|
|
(PhabricatorEnv::getEnvConfig('phabricator.developer-mode')
|
|
|
|
? '1'
|
|
|
|
: '0').
|
2013-02-01 18:34:06 +01:00
|
|
|
';'.
|
2012-10-16 19:33:47 +02:00
|
|
|
'</script>',
|
|
|
|
|
|
|
|
$response->renderResourcesOfType('css'),
|
|
|
|
);
|
|
|
|
|
|
|
|
return implode("\n", $head);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getBody() {
|
|
|
|
return $this->bodyContent;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getTail() {
|
|
|
|
$response = CelerityAPI::getStaticResourceResponse();
|
|
|
|
return $response->renderResourcesOfType('js');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|