Path: blob/master/src/applications/files/document/PhabricatorSourceDocumentEngine.php
12241 views
<?php12final class PhabricatorSourceDocumentEngine3extends PhabricatorTextDocumentEngine {45const ENGINEKEY = 'source';67public function getViewAsLabel(PhabricatorDocumentRef $ref) {8return pht('View as Source');9}1011public function canConfigureHighlighting(PhabricatorDocumentRef $ref) {12return true;13}1415public function canBlame(PhabricatorDocumentRef $ref) {16return true;17}1819protected function getDocumentIconIcon(PhabricatorDocumentRef $ref) {20return 'fa-code';21}2223protected function getContentScore(PhabricatorDocumentRef $ref) {24return 1500;25}2627protected function newDocumentContent(PhabricatorDocumentRef $ref) {28$content = $this->loadTextData($ref);2930$messages = array();3132$highlighting = $this->getHighlightingConfiguration();33if ($highlighting !== null) {34$content = PhabricatorSyntaxHighlighter::highlightWithLanguage(35$highlighting,36$content);37} else {38$highlight_limit = DifferentialChangesetParser::HIGHLIGHT_BYTE_LIMIT;39if (strlen($content) > $highlight_limit) {40$messages[] = $this->newMessage(41pht(42'This file is larger than %s, so syntax highlighting was skipped.',43phutil_format_bytes($highlight_limit)));44} else {45$content = PhabricatorSyntaxHighlighter::highlightWithFilename(46$ref->getName(),47$content);48}49}5051$options = array();52if ($ref->getBlameURI() && $this->getBlameEnabled()) {53$content = phutil_split_lines($content);54$blame = range(1, count($content));55$blame = array_fuse($blame);56$options['blame'] = $blame;57}5859if ($ref->getCoverage()) {60$options['coverage'] = $ref->getCoverage();61}6263return array(64$messages,65$this->newTextDocumentContent($ref, $content, $options),66);67}6869}707172