@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
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Roughly modularize document rendering in Files

Summary:
Ref T13105. This change begins modularizing document rendering. I'm starting in Files since it's the use case with the smallest amount of complexity.

Currently, we hard-coding the inline rendering for images, audio, and video. Instead, use the modular engine pattern to make rendering flexible and extensible.

There aren't any options for switching modes yet and none of the renderers do anything fancy. This API is also probably very unstable.

Test Plan: Viewwed images, audio, video, and other files. Saw reasonable renderings, with "nothing can render this" for any other file type.

Maniphest Tasks: T13105

Differential Revision: https://secure.phabricator.com/D19237

+485 -87
+3 -3
resources/celerity/map.php
··· 9 9 'names' => array( 10 10 'conpherence.pkg.css' => 'e68cf1fa', 11 11 'conpherence.pkg.js' => '15191c65', 12 - 'core.pkg.css' => 'c218ed53', 12 + 'core.pkg.css' => '6a8ba174', 13 13 'core.pkg.js' => '8581cd02', 14 14 'differential.pkg.css' => '113e692c', 15 15 'differential.pkg.js' => 'f6d809c0', ··· 168 168 'rsrc/css/phui/phui-object-box.css' => '9cff003c', 169 169 'rsrc/css/phui/phui-pager.css' => 'edcbc226', 170 170 'rsrc/css/phui/phui-pinboard-view.css' => '2495140e', 171 - 'rsrc/css/phui/phui-property-list-view.css' => '2dc7993f', 171 + 'rsrc/css/phui/phui-property-list-view.css' => '79fc3a02', 172 172 'rsrc/css/phui/phui-remarkup-preview.css' => '54a34863', 173 173 'rsrc/css/phui/phui-segment-bar-view.css' => 'b1d1b892', 174 174 'rsrc/css/phui/phui-spacing.css' => '042804d6', ··· 848 848 'phui-oi-simple-ui-css' => 'a8beebea', 849 849 'phui-pager-css' => 'edcbc226', 850 850 'phui-pinboard-view-css' => '2495140e', 851 - 'phui-property-list-view-css' => '2dc7993f', 851 + 'phui-property-list-view-css' => '79fc3a02', 852 852 'phui-remarkup-preview-css' => '54a34863', 853 853 'phui-segment-bar-view-css' => 'b1d1b892', 854 854 'phui-spacing-css' => '042804d6',
+12
src/__phutil_library_map__.php
··· 2066 2066 'PhabricatorAsanaConfigOptions' => 'applications/doorkeeper/option/PhabricatorAsanaConfigOptions.php', 2067 2067 'PhabricatorAsanaSubtaskHasObjectEdgeType' => 'applications/doorkeeper/edge/PhabricatorAsanaSubtaskHasObjectEdgeType.php', 2068 2068 'PhabricatorAsanaTaskHasObjectEdgeType' => 'applications/doorkeeper/edge/PhabricatorAsanaTaskHasObjectEdgeType.php', 2069 + 'PhabricatorAudioDocumentEngine' => 'applications/files/document/PhabricatorAudioDocumentEngine.php', 2069 2070 'PhabricatorAuditActionConstants' => 'applications/audit/constants/PhabricatorAuditActionConstants.php', 2070 2071 'PhabricatorAuditApplication' => 'applications/audit/application/PhabricatorAuditApplication.php', 2071 2072 'PhabricatorAuditCommentEditor' => 'applications/audit/editor/PhabricatorAuditCommentEditor.php', ··· 2808 2809 'PhabricatorDividerEditField' => 'applications/transactions/editfield/PhabricatorDividerEditField.php', 2809 2810 'PhabricatorDividerProfileMenuItem' => 'applications/search/menuitem/PhabricatorDividerProfileMenuItem.php', 2810 2811 'PhabricatorDivinerApplication' => 'applications/diviner/application/PhabricatorDivinerApplication.php', 2812 + 'PhabricatorDocumentEngine' => 'applications/files/document/PhabricatorDocumentEngine.php', 2813 + 'PhabricatorDocumentRef' => 'applications/files/document/PhabricatorDocumentRef.php', 2811 2814 'PhabricatorDoorkeeperApplication' => 'applications/doorkeeper/application/PhabricatorDoorkeeperApplication.php', 2812 2815 'PhabricatorDraft' => 'applications/draft/storage/PhabricatorDraft.php', 2813 2816 'PhabricatorDraftDAO' => 'applications/draft/storage/PhabricatorDraftDAO.php', ··· 3155 3158 'PhabricatorIconSet' => 'applications/files/iconset/PhabricatorIconSet.php', 3156 3159 'PhabricatorIconSetEditField' => 'applications/transactions/editfield/PhabricatorIconSetEditField.php', 3157 3160 'PhabricatorIconSetIcon' => 'applications/files/iconset/PhabricatorIconSetIcon.php', 3161 + 'PhabricatorImageDocumentEngine' => 'applications/files/document/PhabricatorImageDocumentEngine.php', 3158 3162 'PhabricatorImageMacroRemarkupRule' => 'applications/macro/markup/PhabricatorImageMacroRemarkupRule.php', 3159 3163 'PhabricatorImageRemarkupRule' => 'applications/files/markup/PhabricatorImageRemarkupRule.php', 3160 3164 'PhabricatorImageTransformer' => 'applications/files/PhabricatorImageTransformer.php', ··· 4481 4485 'PhabricatorVCSResponse' => 'applications/repository/response/PhabricatorVCSResponse.php', 4482 4486 'PhabricatorVersionedDraft' => 'applications/draft/storage/PhabricatorVersionedDraft.php', 4483 4487 'PhabricatorVeryWowEnglishTranslation' => 'infrastructure/internationalization/translation/PhabricatorVeryWowEnglishTranslation.php', 4488 + 'PhabricatorVideoDocumentEngine' => 'applications/files/document/PhabricatorVideoDocumentEngine.php', 4484 4489 'PhabricatorViewerDatasource' => 'applications/people/typeahead/PhabricatorViewerDatasource.php', 4490 + 'PhabricatorVoidDocumentEngine' => 'applications/files/document/PhabricatorVoidDocumentEngine.php', 4485 4491 'PhabricatorWatcherHasObjectEdgeType' => 'applications/transactions/edges/PhabricatorWatcherHasObjectEdgeType.php', 4486 4492 'PhabricatorWebContentSource' => 'infrastructure/contentsource/PhabricatorWebContentSource.php', 4487 4493 'PhabricatorWebServerSetupCheck' => 'applications/config/check/PhabricatorWebServerSetupCheck.php', ··· 7497 7503 'PhabricatorAsanaConfigOptions' => 'PhabricatorApplicationConfigOptions', 7498 7504 'PhabricatorAsanaSubtaskHasObjectEdgeType' => 'PhabricatorEdgeType', 7499 7505 'PhabricatorAsanaTaskHasObjectEdgeType' => 'PhabricatorEdgeType', 7506 + 'PhabricatorAudioDocumentEngine' => 'PhabricatorDocumentEngine', 7500 7507 'PhabricatorAuditActionConstants' => 'Phobject', 7501 7508 'PhabricatorAuditApplication' => 'PhabricatorApplication', 7502 7509 'PhabricatorAuditCommentEditor' => 'PhabricatorEditor', ··· 8362 8369 'PhabricatorDividerEditField' => 'PhabricatorEditField', 8363 8370 'PhabricatorDividerProfileMenuItem' => 'PhabricatorProfileMenuItem', 8364 8371 'PhabricatorDivinerApplication' => 'PhabricatorApplication', 8372 + 'PhabricatorDocumentEngine' => 'Phobject', 8373 + 'PhabricatorDocumentRef' => 'Phobject', 8365 8374 'PhabricatorDoorkeeperApplication' => 'PhabricatorApplication', 8366 8375 'PhabricatorDraft' => 'PhabricatorDraftDAO', 8367 8376 'PhabricatorDraftDAO' => 'PhabricatorLiskDAO', ··· 8756 8765 'PhabricatorIconSet' => 'Phobject', 8757 8766 'PhabricatorIconSetEditField' => 'PhabricatorEditField', 8758 8767 'PhabricatorIconSetIcon' => 'Phobject', 8768 + 'PhabricatorImageDocumentEngine' => 'PhabricatorDocumentEngine', 8759 8769 'PhabricatorImageMacroRemarkupRule' => 'PhutilRemarkupRule', 8760 8770 'PhabricatorImageRemarkupRule' => 'PhutilRemarkupRule', 8761 8771 'PhabricatorImageTransformer' => 'Phobject', ··· 10330 10340 'PhabricatorVCSResponse' => 'AphrontResponse', 10331 10341 'PhabricatorVersionedDraft' => 'PhabricatorDraftDAO', 10332 10342 'PhabricatorVeryWowEnglishTranslation' => 'PhutilTranslation', 10343 + 'PhabricatorVideoDocumentEngine' => 'PhabricatorDocumentEngine', 10333 10344 'PhabricatorViewerDatasource' => 'PhabricatorTypeaheadDatasource', 10345 + 'PhabricatorVoidDocumentEngine' => 'PhabricatorDocumentEngine', 10334 10346 'PhabricatorWatcherHasObjectEdgeType' => 'PhabricatorEdgeType', 10335 10347 'PhabricatorWebContentSource' => 'PhabricatorContentSource', 10336 10348 'PhabricatorWebServerSetupCheck' => 'PhabricatorSetupCheck',
+59 -63
src/applications/files/controller/PhabricatorFileInfoController.php
··· 23 23 } 24 24 return id(new AphrontRedirectResponse())->setURI($file->getInfoURI()); 25 25 } 26 + 26 27 $file = id(new PhabricatorFileQuery()) 27 28 ->setViewer($viewer) 28 29 ->withIDs(array($id)) ··· 62 63 $timeline = $this->buildTransactionView($file); 63 64 $crumbs = $this->buildApplicationCrumbs(); 64 65 $crumbs->addTextCrumb( 65 - 'F'.$file->getID(), 66 - $this->getApplicationURI("/info/{$phid}/")); 66 + $file->getMonogram(), 67 + $file->getInfoURI()); 67 68 $crumbs->setBorder(true); 68 69 69 70 $object_box = id(new PHUIObjectBoxView()) 70 - ->setHeaderText(pht('File')) 71 + ->setHeaderText(pht('File Metadata')) 71 72 ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY); 72 73 73 74 $this->buildPropertyViews($object_box, $file); 74 75 $title = $file->getName(); 76 + 77 + $file_content = $this->newFileContent($file); 75 78 76 79 $view = id(new PHUITwoColumnView()) 77 80 ->setHeader($header) 78 81 ->setCurtain($curtain) 79 - ->setMainColumn(array( 80 - $object_box, 81 - $timeline, 82 - )); 82 + ->setMainColumn( 83 + array( 84 + $object_box, 85 + $file_content, 86 + $timeline, 87 + )); 83 88 84 89 return $this->newPage() 85 90 ->setTitle($title) 86 91 ->setCrumbs($crumbs) 87 92 ->setPageObjectPHIDs(array($file->getPHID())) 88 93 ->appendChild($view); 89 - 90 94 } 91 95 92 96 private function buildTransactionView(PhabricatorFile $file) { ··· 325 329 $viewer->renderHandleList($phids)); 326 330 } 327 331 328 - if ($file->isViewableImage()) { 329 - $image = phutil_tag( 330 - 'img', 331 - array( 332 - 'src' => $file->getViewURI(), 333 - 'class' => 'phui-property-list-image', 334 - )); 335 - 336 - $linked_image = phutil_tag( 337 - 'a', 338 - array( 339 - 'href' => $file->getViewURI(), 340 - ), 341 - $image); 342 - 343 - $media = id(new PHUIPropertyListView()) 344 - ->addImageContent($linked_image); 345 - 346 - $box->addPropertyList($media); 347 - } else if ($file->isVideo()) { 348 - $video = phutil_tag( 349 - 'video', 350 - array( 351 - 'controls' => 'controls', 352 - 'class' => 'phui-property-list-video', 353 - ), 354 - phutil_tag( 355 - 'source', 356 - array( 357 - 'src' => $file->getViewURI(), 358 - 'type' => $file->getMimeType(), 359 - ))); 360 - $media = id(new PHUIPropertyListView()) 361 - ->addImageContent($video); 362 - 363 - $box->addPropertyList($media); 364 - } else if ($file->isAudio()) { 365 - $audio = phutil_tag( 366 - 'audio', 367 - array( 368 - 'controls' => 'controls', 369 - 'class' => 'phui-property-list-audio', 370 - ), 371 - phutil_tag( 372 - 'source', 373 - array( 374 - 'src' => $file->getViewURI(), 375 - 'type' => $file->getMimeType(), 376 - ))); 377 - $media = id(new PHUIPropertyListView()) 378 - ->addImageContent($audio); 379 - 380 - $box->addPropertyList($media); 381 - } 382 - 383 332 $engine = $this->loadStorageEngine($file); 384 333 if ($engine) { 385 334 if ($engine->isChunkEngine()) { ··· 453 402 return $engine; 454 403 } 455 404 405 + private function newFileContent(PhabricatorFile $file) { 406 + $viewer = $this->getViewer(); 407 + $engines = PhabricatorDocumentEngine::getAllEngines(); 408 + 409 + $ref = id(new PhabricatorDocumentRef()) 410 + ->setFile($file); 411 + 412 + foreach ($engines as $key => $engine) { 413 + $engine = id(clone $engine) 414 + ->setViewer($viewer); 415 + 416 + if (!$engine->canRenderDocument($ref)) { 417 + unset($engines[$key]); 418 + continue; 419 + } 420 + 421 + $engines[$key] = $engine; 422 + } 423 + 424 + if (!$engines) { 425 + throw new Exception(pht('No engine can render this document.')); 426 + } 427 + 428 + $vectors = array(); 429 + foreach ($engines as $key => $usable_engine) { 430 + $vectors[$key] = $usable_engine->newSortVector($ref); 431 + } 432 + $vectors = msortv($vectors, 'getSelf'); 433 + 434 + $engine = $engines[head_key($vectors)]; 435 + 436 + $content = $engine->newDocument($ref); 437 + if (!$content) { 438 + return null; 439 + } 440 + 441 + $icon = $engine->newDocumentIcon($ref); 442 + 443 + $header = id(new PHUIHeaderView()) 444 + ->setHeaderIcon($icon) 445 + ->setHeader($ref->getName()); 446 + 447 + return id(new PHUIObjectBoxView()) 448 + ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 449 + ->setHeader($header) 450 + ->appendChild($content); 451 + } 456 452 457 453 }
+61
src/applications/files/document/PhabricatorAudioDocumentEngine.php
··· 1 + <?php 2 + 3 + final class PhabricatorAudioDocumentEngine 4 + extends PhabricatorDocumentEngine { 5 + 6 + const ENGINEKEY = 'audio'; 7 + 8 + protected function getDocumentIconIcon(PhabricatorDocumentRef $ref) { 9 + return 'fa-file-sound-o'; 10 + } 11 + 12 + protected function canRenderDocumentType(PhabricatorDocumentRef $ref) { 13 + $file = $ref->getFile(); 14 + if ($file) { 15 + return $file->isAudio(); 16 + } 17 + 18 + $viewable_types = PhabricatorEnv::getEnvConfig('files.viewable-mime-types'); 19 + $viewable_types = array_keys($viewable_types); 20 + 21 + $audio_types = PhabricatorEnv::getEnvConfig('files.audio-mime-types'); 22 + $audio_types = array_keys($audio_types); 23 + 24 + return 25 + $ref->hasAnyMimeType($viewable_types) && 26 + $ref->hasAnyMimeType($audio_types); 27 + } 28 + 29 + protected function newDocumentContent(PhabricatorDocumentRef $ref) { 30 + $file = $ref->getFile(); 31 + if ($file) { 32 + $source_uri = $file->getViewURI(); 33 + } else { 34 + throw new PhutilMethodNotImplementedException(); 35 + } 36 + 37 + $mime_type = $ref->getMimeType(); 38 + 39 + $audio = phutil_tag( 40 + 'audio', 41 + array( 42 + 'controls' => 'controls', 43 + ), 44 + phutil_tag( 45 + 'source', 46 + array( 47 + 'src' => $source_uri, 48 + 'type' => $mime_type, 49 + ))); 50 + 51 + $container = phutil_tag( 52 + 'div', 53 + array( 54 + 'class' => 'document-engine-audio', 55 + ), 56 + $audio); 57 + 58 + return $container; 59 + } 60 + 61 + }
+62
src/applications/files/document/PhabricatorDocumentEngine.php
··· 1 + <?php 2 + 3 + abstract class PhabricatorDocumentEngine 4 + extends Phobject { 5 + 6 + private $viewer; 7 + 8 + final public function setViewer(PhabricatorUser $viewer) { 9 + $this->viewer = $viewer; 10 + return $this; 11 + } 12 + 13 + final public function getViewer() { 14 + return $this->viewer; 15 + } 16 + 17 + final public function canRenderDocument(PhabricatorDocumentRef $ref) { 18 + return $this->canRenderDocumentType($ref); 19 + } 20 + 21 + abstract protected function canRenderDocumentType( 22 + PhabricatorDocumentRef $ref); 23 + 24 + final public function newDocument(PhabricatorDocumentRef $ref) { 25 + return $this->newDocumentContent($ref); 26 + } 27 + 28 + final public function newDocumentIcon(PhabricatorDocumentRef $ref) { 29 + return id(new PHUIIconView()) 30 + ->setIcon($this->getDocumentIconIcon($ref)); 31 + } 32 + 33 + abstract protected function newDocumentContent( 34 + PhabricatorDocumentRef $ref); 35 + 36 + protected function getDocumentIconIcon(PhabricatorDocumentRef $ref) { 37 + return 'fa-file-o'; 38 + } 39 + 40 + final public function getDocumentEngineKey() { 41 + return $this->getPhobjectClassConstant('ENGINEKEY'); 42 + } 43 + 44 + final public static function getAllEngines() { 45 + return id(new PhutilClassMapQuery()) 46 + ->setAncestorClass(__CLASS__) 47 + ->setUniqueMethod('getDocumentEngineKey') 48 + ->execute(); 49 + } 50 + 51 + final public function newSortVector(PhabricatorDocumentRef $ref) { 52 + $content_score = $this->getContentScore($ref); 53 + 54 + return id(new PhutilSortVector()) 55 + ->addInt(-$content_score); 56 + } 57 + 58 + protected function getContentScore() { 59 + return 2000; 60 + } 61 + 62 + }
+93
src/applications/files/document/PhabricatorDocumentRef.php
··· 1 + <?php 2 + 3 + final class PhabricatorDocumentRef 4 + extends Phobject { 5 + 6 + private $name; 7 + private $mimeType; 8 + private $file; 9 + private $byteLength; 10 + 11 + public function setFile(PhabricatorFile $file) { 12 + $this->file = $file; 13 + return $this; 14 + } 15 + 16 + public function getFile() { 17 + return $this->file; 18 + } 19 + 20 + public function setMimeType($mime_type) { 21 + $this->mimeType = $mime_type; 22 + return $this; 23 + } 24 + 25 + public function getMimeType() { 26 + if ($this->mimeType !== null) { 27 + return $this->mimeType; 28 + } 29 + 30 + if ($this->file) { 31 + return $this->file->getMimeType(); 32 + } 33 + 34 + return null; 35 + } 36 + 37 + public function setName($name) { 38 + $this->name = $name; 39 + return $this; 40 + } 41 + 42 + public function getName() { 43 + if ($this->name !== null) { 44 + return $this->name; 45 + } 46 + 47 + if ($this->file) { 48 + return $this->file->getName(); 49 + } 50 + 51 + return null; 52 + } 53 + 54 + public function setByteLength($length) { 55 + $this->byteLength = $length; 56 + return $this; 57 + } 58 + 59 + public function getLength() { 60 + if ($this->byteLength !== null) { 61 + return $this->byteLength; 62 + } 63 + 64 + if ($this->file) { 65 + return (int)$this->file->getByteSize(); 66 + } 67 + 68 + return null; 69 + } 70 + 71 + public function hasAnyMimeType(array $candidate_types) { 72 + $mime_full = $this->getMimeType(); 73 + $mime_parts = explode(';', $mime_full); 74 + 75 + $mime_type = head($mime_parts); 76 + $mime_type = $this->normalizeMimeType($mime_type); 77 + 78 + foreach ($candidate_types as $candidate_type) { 79 + if ($this->normalizeMimeType($candidate_type) === $mime_type) { 80 + return true; 81 + } 82 + } 83 + 84 + return false; 85 + } 86 + 87 + private function normalizeMimeType($mime_type) { 88 + $mime_type = trim($mime_type); 89 + $mime_type = phutil_utf8_strtolower($mime_type); 90 + return $mime_type; 91 + } 92 + 93 + }
+63
src/applications/files/document/PhabricatorImageDocumentEngine.php
··· 1 + <?php 2 + 3 + final class PhabricatorImageDocumentEngine 4 + extends PhabricatorDocumentEngine { 5 + 6 + const ENGINEKEY = 'image'; 7 + 8 + protected function getDocumentIconIcon(PhabricatorDocumentRef $ref) { 9 + return 'fa-file-image-o'; 10 + } 11 + 12 + protected function canRenderDocumentType(PhabricatorDocumentRef $ref) { 13 + $file = $ref->getFile(); 14 + if ($file) { 15 + return $file->isViewableImage(); 16 + } 17 + 18 + $viewable_types = PhabricatorEnv::getEnvConfig('files.viewable-mime-types'); 19 + $viewable_types = array_keys($viewable_types); 20 + 21 + $image_types = PhabricatorEnv::getEnvConfig('files.image-mime-types'); 22 + $image_types = array_keys($image_types); 23 + 24 + return 25 + $ref->hasAnyMimeType($viewable_types) && 26 + $ref->hasAnyMimeType($image_types); 27 + } 28 + 29 + protected function newDocumentContent(PhabricatorDocumentRef $ref) { 30 + $file = $ref->getFile(); 31 + if ($file) { 32 + $source_uri = $file->getViewURI(); 33 + } else { 34 + // We could use a "data:" URI here. It's not yet clear if or when we'll 35 + // have a ref but no backing file. 36 + throw new PhutilMethodNotImplementedException(); 37 + } 38 + 39 + $image = phutil_tag( 40 + 'img', 41 + array( 42 + 'src' => $source_uri, 43 + )); 44 + 45 + $linked_image = phutil_tag( 46 + 'a', 47 + array( 48 + 'href' => $source_uri, 49 + 'rel' => 'noreferrer', 50 + ), 51 + $image); 52 + 53 + $container = phutil_tag( 54 + 'div', 55 + array( 56 + 'class' => 'document-engine-image', 57 + ), 58 + $linked_image); 59 + 60 + return $container; 61 + } 62 + 63 + }
+61
src/applications/files/document/PhabricatorVideoDocumentEngine.php
··· 1 + <?php 2 + 3 + final class PhabricatorVideoDocumentEngine 4 + extends PhabricatorDocumentEngine { 5 + 6 + const ENGINEKEY = 'video'; 7 + 8 + protected function getDocumentIconIcon(PhabricatorDocumentRef $ref) { 9 + return 'fa-film'; 10 + } 11 + 12 + protected function canRenderDocumentType(PhabricatorDocumentRef $ref) { 13 + $file = $ref->getFile(); 14 + if ($file) { 15 + return $file->isVideo(); 16 + } 17 + 18 + $viewable_types = PhabricatorEnv::getEnvConfig('files.viewable-mime-types'); 19 + $viewable_types = array_keys($viewable_types); 20 + 21 + $video_types = PhabricatorEnv::getEnvConfig('files.video-mime-types'); 22 + $video_types = array_keys($video_types); 23 + 24 + return 25 + $ref->hasAnyMimeType($viewable_types) && 26 + $ref->hasAnyMimeType($video_types); 27 + } 28 + 29 + protected function newDocumentContent(PhabricatorDocumentRef $ref) { 30 + $file = $ref->getFile(); 31 + if ($file) { 32 + $source_uri = $file->getViewURI(); 33 + } else { 34 + throw new PhutilMethodNotImplementedException(); 35 + } 36 + 37 + $mime_type = $ref->getMimeType(); 38 + 39 + $video = phutil_tag( 40 + 'video', 41 + array( 42 + 'controls' => 'controls', 43 + ), 44 + phutil_tag( 45 + 'source', 46 + array( 47 + 'src' => $source_uri, 48 + 'type' => $mime_type, 49 + ))); 50 + 51 + $container = phutil_tag( 52 + 'div', 53 + array( 54 + 'class' => 'document-engine-video', 55 + ), 56 + $video); 57 + 58 + return $container; 59 + } 60 + 61 + }
+34
src/applications/files/document/PhabricatorVoidDocumentEngine.php
··· 1 + <?php 2 + 3 + final class PhabricatorVoidDocumentEngine 4 + extends PhabricatorDocumentEngine { 5 + 6 + const ENGINEKEY = 'void'; 7 + 8 + protected function getDocumentIconIcon(PhabricatorDocumentRef $ref) { 9 + return 'fa-file'; 10 + } 11 + 12 + protected function getContentScore() { 13 + return 1000; 14 + } 15 + 16 + protected function canRenderDocumentType(PhabricatorDocumentRef $ref) { 17 + return true; 18 + } 19 + 20 + protected function newDocumentContent(PhabricatorDocumentRef $ref) { 21 + $message = pht( 22 + 'No document engine can render the contents of this file.'); 23 + 24 + $container = phutil_tag( 25 + 'div', 26 + array( 27 + 'class' => 'document-engine-message', 28 + ), 29 + $message); 30 + 31 + return $container; 32 + } 33 + 34 + }
+8 -3
src/view/phui/PHUIHeaderView.php
··· 307 307 308 308 $icon = null; 309 309 if ($this->headerIcon) { 310 - $icon = id(new PHUIIconView()) 311 - ->setIcon($this->headerIcon) 312 - ->addClass('phui-header-icon'); 310 + if ($this->headerIcon instanceof PHUIIconView) { 311 + $icon = id(clone $this->headerIcon) 312 + ->addClass('phui-header-icon'); 313 + } else { 314 + $icon = id(new PHUIIconView()) 315 + ->setIcon($this->headerIcon) 316 + ->addClass('phui-header-icon'); 317 + } 313 318 } 314 319 315 320 $header_content = $this->header;
+29 -18
webroot/rsrc/css/phui/phui-property-list-view.css
··· 149 149 } 150 150 151 151 152 - .phui-property-list-image { 153 - margin: auto; 154 - max-width: 95%; 155 - } 156 - 157 - .phui-property-list-audio { 158 - display: block; 159 - margin: 16px auto; 160 - width: 50%; 161 - min-width: 240px; 162 - } 163 - 164 - .phui-property-list-video { 165 - display: block; 166 - margin: 0 auto; 167 - max-width: 95%; 168 - } 169 - 170 152 /* When tags appear in property lists, give them a little more vertical 171 153 spacing. */ 172 154 .phui-property-list-value .phui-tag-view { ··· 220 202 border-right: 1px solid {$lightblueborder}; 221 203 border-bottom: 1px solid {$blueborder}; 222 204 } 205 + 206 + 207 + .document-engine-image img { 208 + margin: 20px auto; 209 + background: url('/rsrc/image/checker_light.png'); 210 + } 211 + 212 + .device-desktop .document-engine-image img:hover { 213 + background: url('/rsrc/image/checker_dark.png'); 214 + } 215 + 216 + .document-engine-video video { 217 + margin: 20px auto; 218 + display: block; 219 + max-width: 95%; 220 + } 221 + 222 + .document-engine-audio audio { 223 + display: block; 224 + margin: 16px auto; 225 + width: 50%; 226 + min-width: 240px; 227 + } 228 + 229 + .document-engine-message { 230 + margin: 20px auto; 231 + text-align: center; 232 + color: {$greytext}; 233 + }