Path: blob/master/src/applications/files/document/PhabricatorPDFDocumentEngine.php
12241 views
<?php12final class PhabricatorPDFDocumentEngine3extends PhabricatorDocumentEngine {45const ENGINEKEY = 'pdf';67public function getViewAsLabel(PhabricatorDocumentRef $ref) {8return pht('View as PDF');9}1011protected function getDocumentIconIcon(PhabricatorDocumentRef $ref) {12return 'fa-file-pdf-o';13}1415protected function canRenderDocumentType(PhabricatorDocumentRef $ref) {16// Since we just render a link to the document anyway, we don't need to17// check anything fancy in config to see if the MIME type is actually18// viewable.1920return $ref->hasAnyMimeType(21array(22'application/pdf',23));24}2526protected function newDocumentContent(PhabricatorDocumentRef $ref) {27$viewer = $this->getViewer();2829$file = $ref->getFile();30if ($file) {31$source_uri = $file->getViewURI();32} else {33throw new PhutilMethodNotImplementedException();34}3536$name = $ref->getName();37$length = $ref->getByteLength();3839$link = id(new PhabricatorFileLinkView())40->setViewer($viewer)41->setFileName($name)42->setFileViewURI($source_uri)43->setFileViewable(true)44->setFileSize(phutil_format_bytes($length));4546$container = phutil_tag(47'div',48array(49'class' => 'document-engine-pdf',50),51$link);5253return $container;54}5556}575859