@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 89 lines 2.5 kB view raw
1<?php 2 3final class PhabricatorFileEditEngine 4 extends PhabricatorEditEngine { 5 6 const ENGINECONST = 'files.file'; 7 8 public function getEngineName() { 9 return pht('Files'); 10 } 11 12 protected function supportsEditEngineConfiguration() { 13 return false; 14 } 15 16 protected function getCreateNewObjectPolicy() { 17 // TODO: For now, this EditEngine can only edit objects, since there is 18 // a lot of complexity in dealing with file data during file creation. 19 return PhabricatorPolicies::POLICY_NOONE; 20 } 21 22 public function getSummaryHeader() { 23 return pht('Configure Files Forms'); 24 } 25 26 public function getSummaryText() { 27 return pht('Configure creation and editing forms in Files.'); 28 } 29 30 public function getEngineApplicationClass() { 31 return PhabricatorFilesApplication::class; 32 } 33 34 protected function newEditableObject() { 35 return PhabricatorFile::initializeNewFile(); 36 } 37 38 protected function newObjectQuery() { 39 $query = new PhabricatorFileQuery(); 40 $query->withIsDeleted(false); 41 return $query; 42 } 43 44 protected function getObjectCreateTitleText($object) { 45 return pht('Create New File'); 46 } 47 48 protected function getObjectEditTitleText($object) { 49 return pht('Edit File: %s', $object->getName()); 50 } 51 52 protected function getObjectEditShortText($object) { 53 return $object->getMonogram(); 54 } 55 56 protected function getObjectCreateShortText() { 57 return pht('Create File'); 58 } 59 60 protected function getObjectName() { 61 return pht('File'); 62 } 63 64 protected function getObjectViewURI($object) { 65 return $object->getURI(); 66 } 67 68 protected function buildCustomEditFields($object) { 69 return array( 70 id(new PhabricatorTextEditField()) 71 ->setKey('name') 72 ->setLabel(pht('Name')) 73 ->setTransactionType(PhabricatorFileNameTransaction::TRANSACTIONTYPE) 74 ->setDescription(pht('The name of the file.')) 75 ->setConduitDescription(pht('Rename the file.')) 76 ->setConduitTypeDescription(pht('New file name.')) 77 ->setValue($object->getName()), 78 id(new PhabricatorTextEditField()) 79 ->setKey('alt') 80 ->setLabel(pht('Alt Text')) 81 ->setTransactionType(PhabricatorFileAltTextTransaction::TRANSACTIONTYPE) 82 ->setDescription(pht('Human-readable file description.')) 83 ->setConduitDescription(pht('Set the file alt text.')) 84 ->setConduitTypeDescription(pht('New alt text.')) 85 ->setValue($object->getCustomAltText()), 86 ); 87 } 88 89}