@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 109 lines 3.2 kB view raw
1<?php 2 3final class PonderQuestionEditEngine 4 extends PhabricatorEditEngine { 5 6 const ENGINECONST = 'ponder.question'; 7 8 public function getEngineName() { 9 return pht('Ponder Question'); 10 } 11 12 public function getEngineApplicationClass() { 13 return PhabricatorPonderApplication::class; 14 } 15 16 public function getSummaryHeader() { 17 return pht('Configure Ponder Question Forms'); 18 } 19 20 public function getSummaryText() { 21 return pht('Configure creation and editing forms in Ponder Questions.'); 22 } 23 24 public function isEngineConfigurable() { 25 return false; 26 } 27 28 protected function newEditableObject() { 29 return PonderQuestion::initializeNewQuestion($this->getViewer()); 30 } 31 32 protected function newObjectQuery() { 33 return new PonderQuestionQuery(); 34 } 35 36 protected function getObjectCreateTitleText($object) { 37 return pht('Create New Question'); 38 } 39 40 protected function getObjectEditTitleText($object) { 41 return pht('Edit Question: %s', $object->getTitle()); 42 } 43 44 protected function getObjectEditShortText($object) { 45 return $object->getTitle(); 46 } 47 48 protected function getObjectCreateShortText() { 49 return pht('New Question'); 50 } 51 52 protected function getObjectName() { 53 return pht('Question'); 54 } 55 56 protected function getObjectCreateCancelURI($object) { 57 return $this->getApplication()->getApplicationURI('/'); 58 } 59 60 protected function getEditorURI() { 61 return $this->getApplication()->getApplicationURI('question/edit/'); 62 } 63 64 protected function getObjectViewURI($object) { 65 return $object->getViewURI(); 66 } 67 68 protected function buildCustomEditFields($object) { 69 70 return array( 71 id(new PhabricatorTextEditField()) 72 ->setKey('title') 73 ->setLabel(pht('Question')) 74 ->setDescription(pht('Question title.')) 75 ->setConduitTypeDescription(pht('New question title.')) 76 ->setTransactionType( 77 PonderQuestionTitleTransaction::TRANSACTIONTYPE) 78 ->setValue($object->getTitle()) 79 ->setIsRequired(true), 80 id(new PhabricatorRemarkupEditField()) 81 ->setKey('content') 82 ->setLabel(pht('Details')) 83 ->setDescription(pht('Long details of the question.')) 84 ->setConduitTypeDescription(pht('New question details.')) 85 ->setValue($object->getContent()) 86 ->setTransactionType( 87 PonderQuestionContentTransaction::TRANSACTIONTYPE), 88 id(new PhabricatorRemarkupEditField()) 89 ->setKey('answerWiki') 90 ->setLabel(pht('Answer Summary')) 91 ->setDescription(pht('Answer summary of the question.')) 92 ->setConduitTypeDescription(pht('New question answer summary.')) 93 ->setValue($object->getAnswerWiki()) 94 ->setTransactionType( 95 PonderQuestionAnswerWikiTransaction::TRANSACTIONTYPE), 96 id(new PhabricatorSelectEditField()) 97 ->setKey('status') 98 ->setLabel(pht('Status')) 99 ->setDescription(pht('Status of the question.')) 100 ->setConduitTypeDescription(pht('New question status.')) 101 ->setValue($object->getStatus()) 102 ->setTransactionType( 103 PonderQuestionStatusTransaction::TRANSACTIONTYPE) 104 ->setOptions(PonderQuestionStatus::getQuestionStatusMap()), 105 106 ); 107 } 108 109}