@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
at recaptime-dev/main 159 lines 4.5 kB view raw
1<?php 2 3final class PhabricatorFilesApplication extends PhabricatorApplication { 4 5 public function getBaseURI() { 6 return '/file/'; 7 } 8 9 public function getName() { 10 return pht('Files'); 11 } 12 13 public function getShortDescription() { 14 return pht('Store and Share Files'); 15 } 16 17 public function getIcon() { 18 return 'fa-file'; 19 } 20 21 public function getTitleGlyph() { 22 return "\xE2\x87\xAA"; 23 } 24 25 public function getFlavorText() { 26 return pht('Blob store for Pokemon pictures.'); 27 } 28 29 public function getApplicationGroup() { 30 return self::GROUP_UTILITIES; 31 } 32 33 public function canUninstall() { 34 return false; 35 } 36 37 public function getRemarkupRules() { 38 return array( 39 new PhabricatorEmbedFileRemarkupRule(), 40 new PhabricatorImageRemarkupRule(), 41 ); 42 } 43 44 public function supportsEmailIntegration() { 45 return true; 46 } 47 48 public function getAppEmailBlurb() { 49 return pht( 50 'Send emails with file attachments to these addresses to upload '. 51 'files. %s', 52 phutil_tag( 53 'a', 54 array( 55 'href' => $this->getInboundEmailSupportLink(), 56 ), 57 pht('Learn More'))); 58 } 59 60 protected function getCustomCapabilities() { 61 return array( 62 FilesDefaultViewCapability::CAPABILITY => array( 63 'caption' => pht('Default view policy for newly created files.'), 64 'template' => PhabricatorFileFilePHIDType::TYPECONST, 65 'capability' => PhabricatorPolicyCapability::CAN_VIEW, 66 ), 67 ); 68 } 69 70 public function getMonograms() { 71 return array('F'); 72 } 73 74 public function getRoutes() { 75 return array( 76 '/F(?P<id>[1-9]\d*)(?:\$(?P<lines>\d+(?:-\d+)?))?' 77 => 'PhabricatorFileViewController', 78 '/file/' => array( 79 '(query/(?P<queryKey>[^/]+)/)?' => 'PhabricatorFileListController', 80 'view/(?P<id>[1-9]\d*)/'. 81 '(?:(?P<engineKey>[^/]+)/)?'. 82 '(?:\$(?P<lines>\d+(?:-\d+)?))?' 83 => 'PhabricatorFileViewController', 84 'info/(?P<phid>[^/]+)/' => 'PhabricatorFileViewController', 85 'upload/' => 'PhabricatorFileUploadController', 86 'dropupload/' => 'PhabricatorFileDropUploadController', 87 'compose/' => 'PhabricatorFileComposeController', 88 'thread/(?P<phid>[^/]+)/' => 'PhabricatorFileLightboxController', 89 'delete/(?P<id>[1-9]\d*)/' => 'PhabricatorFileDeleteController', 90 $this->getEditRoutePattern('edit/') 91 => 'PhabricatorFileEditController', 92 'imageproxy/' => 'PhabricatorFileImageProxyController', 93 'transforms/(?P<id>[1-9]\d*)/' => 94 'PhabricatorFileTransformListController', 95 'uploaddialog/(?P<single>single/)?' 96 => 'PhabricatorFileUploadDialogController', 97 'iconset/(?P<key>[^/]+)/' => array( 98 'select/' => 'PhabricatorFileIconSetSelectController', 99 ), 100 'document/(?P<engineKey>[^/]+)/(?P<phid>[^/]+)/' 101 => 'PhabricatorFileDocumentController', 102 'ui/' => array( 103 'detach/(?P<objectPHID>[^/]+)/(?P<filePHID>[^/]+)/' 104 => 'PhabricatorFileDetachController', 105 'curtain/' => array( 106 'list/(?P<phid>[^/]+)/' 107 => 'PhabricatorFileUICurtainListController', 108 'attach/(?P<objectPHID>[^/]+)/(?P<filePHID>[^/]+)/' 109 => 'PhabricatorFileUICurtainAttachController', 110 ), 111 ), 112 ) + $this->getResourceSubroutes(), 113 ); 114 } 115 116 public function getResourceRoutes() { 117 return array( 118 '/file/' => $this->getResourceSubroutes(), 119 ); 120 } 121 122 private function getResourceSubroutes() { 123 return array( 124 '(?P<kind>data|download)/'. 125 '(?:@(?P<instance>[^/]+)/)?'. 126 '(?P<key>[^/]+)/'. 127 '(?P<phid>[^/]+)/'. 128 '(?:(?P<token>[^/]+)/)?'. 129 '.*' 130 => 'PhabricatorFileDataController', 131 'xform/'. 132 '(?:@(?P<instance>[^/]+)/)?'. 133 '(?P<transform>[^/]+)/'. 134 '(?P<phid>[^/]+)/'. 135 '(?P<key>[^/]+)/' 136 => 'PhabricatorFileTransformController', 137 ); 138 } 139 140 public function getMailCommandObjects() { 141 return array( 142 'file' => array( 143 'name' => pht('Email Commands: Files'), 144 'header' => pht('Interacting with Files'), 145 'object' => new PhabricatorFile(), 146 'summary' => pht( 147 'This page documents the commands you can use to interact with '. 148 'files.'), 149 ), 150 ); 151 } 152 153 public function getQuicksandURIPatternBlacklist() { 154 return array( 155 '/file/(data|download)/.*', 156 ); 157 } 158 159}