@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
at upstream/main 74 lines 1.3 kB view raw
1<?php 2 3abstract class PhabricatorXHPASTViewPanelController 4 extends PhabricatorXHPASTViewController { 5 6 private $id; 7 private $storageTree; 8 9 public function shouldAllowPublic() { 10 return true; 11 } 12 13 public function willProcessRequest(array $data) { 14 $this->id = $data['id']; 15 $this->storageTree = id(new PhabricatorXHPASTParseTree()) 16 ->load($this->id); 17 18 if (!$this->storageTree) { 19 throw new Exception(pht('No such AST!')); 20 } 21 } 22 23 protected function getStorageTree() { 24 return $this->storageTree; 25 } 26 27 protected function buildXHPASTViewPanelResponse($content) { 28 $content = hsprintf( 29 '<!DOCTYPE html>'. 30 '<html>'. 31 '<head>'. 32 '<style type="text/css"> 33body { 34 white-space: pre; 35 font: 10px "Monaco"; 36 cursor: pointer; 37} 38 39.token { 40 padding: 2px 4px; 41 margin: 2px 2px; 42 border: 1px solid #bbbbbb; 43 line-height: 24px; 44} 45 46ul { 47 margin: 0 0 0 1em; 48 padding: 0; 49 list-style: none; 50 line-height: 1em; 51} 52 53li { 54 margin: 0; 55 padding: 0; 56} 57 58li span { 59 background: #dddddd; 60 padding: 3px 6px; 61} 62 63 </style>'. 64 '</head>'. 65 '<body>%s</body>'. 66 '</html>', 67 $content); 68 69 return id(new AphrontWebpageResponse()) 70 ->setFrameable(true) 71 ->setContent($content); 72 } 73 74}