Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/document/PhabricatorSourceDocumentEngine.php
<?php | <?php | ||||
final class PhabricatorSourceDocumentEngine | final class PhabricatorSourceDocumentEngine | ||||
extends PhabricatorTextDocumentEngine { | extends PhabricatorTextDocumentEngine { | ||||
const ENGINEKEY = 'source'; | const ENGINEKEY = 'source'; | ||||
public function getViewAsLabel(PhabricatorDocumentRef $ref) { | public function getViewAsLabel(PhabricatorDocumentRef $ref) { | ||||
return pht('View as Source'); | return pht('View as Source'); | ||||
} | } | ||||
public function canConfigureHighlighting(PhabricatorDocumentRef $ref) { | |||||
return true; | |||||
} | |||||
protected function getDocumentIconIcon(PhabricatorDocumentRef $ref) { | protected function getDocumentIconIcon(PhabricatorDocumentRef $ref) { | ||||
return 'fa-code'; | return 'fa-code'; | ||||
} | } | ||||
protected function getContentScore(PhabricatorDocumentRef $ref) { | protected function getContentScore(PhabricatorDocumentRef $ref) { | ||||
return 1500; | return 1500; | ||||
} | } | ||||
protected function newDocumentContent(PhabricatorDocumentRef $ref) { | protected function newDocumentContent(PhabricatorDocumentRef $ref) { | ||||
$content = $this->loadTextData($ref); | $content = $this->loadTextData($ref); | ||||
$highlighting = $this->getHighlightingConfiguration(); | |||||
if ($highlighting !== null) { | |||||
$content = PhabricatorSyntaxHighlighter::highlightWithLanguage( | |||||
$highlighting, | |||||
$content); | |||||
} else { | |||||
$content = PhabricatorSyntaxHighlighter::highlightWithFilename( | $content = PhabricatorSyntaxHighlighter::highlightWithFilename( | ||||
$ref->getName(), | $ref->getName(), | ||||
$content); | $content); | ||||
} | |||||
return $this->newTextDocumentContent($content); | return $this->newTextDocumentContent($content); | ||||
} | } | ||||
} | } |