@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
1<?php
2
3abstract class AphrontStandaloneHTMLResponse
4 extends AphrontHTMLResponse {
5
6 abstract protected function getResources();
7 abstract protected function getResponseTitle();
8 abstract protected function getResponseBodyClass();
9 abstract protected function getResponseBody();
10 abstract protected function buildPlainTextResponseString();
11
12 final public function buildResponseString() {
13 // Check to make sure we aren't requesting this via Ajax or Conduit.
14 if (isset($_REQUEST['__ajax__']) || isset($_REQUEST['__conduit__'])) {
15 return (string)hsprintf('%s', $this->buildPlainTextResponseString());
16 }
17
18 $title = $this->getResponseTitle();
19 $resources = $this->buildResources();
20 $body_class = $this->getResponseBodyClass();
21 $body = $this->getResponseBody();
22
23 return (string)hsprintf(
24<<<EOTEMPLATE
25<!DOCTYPE html>
26<html>
27 <head>
28 <meta charset="UTF-8" />
29 <title>%s</title>
30 %s
31 </head>
32 %s
33</html>
34EOTEMPLATE
35 ,
36 $title,
37 $resources,
38 phutil_tag(
39 'body',
40 array(
41 'class' => $body_class,
42 ),
43 $body));
44 }
45
46 private function buildResources() {
47 $paths = $this->getResources();
48
49 $webroot = dirname(phutil_get_library_root('phabricator')).'/webroot/';
50
51 $resources = array();
52 foreach ($paths as $path) {
53 $resources[] = phutil_tag(
54 'style',
55 array('type' => 'text/css'),
56 phutil_safe_html(Filesystem::readFile($webroot.'/rsrc/'.$path)));
57 }
58
59 return phutil_implode_html("\n", $resources);
60 }
61
62
63}