Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / files / document / PhabricatorSourceDocumentEngine.php
blob5d7c0cdb75c484ba42276e50f037c2234ec7034e
1 <?php
3 final class PhabricatorSourceDocumentEngine
4 extends PhabricatorTextDocumentEngine {
6 const ENGINEKEY = 'source';
8 public function getViewAsLabel(PhabricatorDocumentRef $ref) {
9 return pht('View as Source');
12 public function canConfigureHighlighting(PhabricatorDocumentRef $ref) {
13 return true;
16 public function canBlame(PhabricatorDocumentRef $ref) {
17 return true;
20 protected function getDocumentIconIcon(PhabricatorDocumentRef $ref) {
21 return 'fa-code';
24 protected function getContentScore(PhabricatorDocumentRef $ref) {
25 return 1500;
28 protected function newDocumentContent(PhabricatorDocumentRef $ref) {
29 $content = $this->loadTextData($ref);
31 $messages = array();
33 $highlighting = $this->getHighlightingConfiguration();
34 if ($highlighting !== null) {
35 $content = PhabricatorSyntaxHighlighter::highlightWithLanguage(
36 $highlighting,
37 $content);
38 } else {
39 $highlight_limit = DifferentialChangesetParser::HIGHLIGHT_BYTE_LIMIT;
40 if (strlen($content) > $highlight_limit) {
41 $messages[] = $this->newMessage(
42 pht(
43 'This file is larger than %s, so syntax highlighting was skipped.',
44 phutil_format_bytes($highlight_limit)));
45 } else {
46 $content = PhabricatorSyntaxHighlighter::highlightWithFilename(
47 $ref->getName(),
48 $content);
52 $options = array();
53 if ($ref->getBlameURI() && $this->getBlameEnabled()) {
54 $content = phutil_split_lines($content);
55 $blame = range(1, count($content));
56 $blame = array_fuse($blame);
57 $options['blame'] = $blame;
60 if ($ref->getCoverage()) {
61 $options['coverage'] = $ref->getCoverage();
64 return array(
65 $messages,
66 $this->newTextDocumentContent($ref, $content, $options),