@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<?php
2
3final class PhabricatorPasteEditEngine
4 extends PhabricatorEditEngine {
5
6 const ENGINECONST = 'paste.paste';
7
8 public function getEngineName() {
9 return pht('Pastes');
10 }
11
12 public function getSummaryHeader() {
13 return pht('Configure Paste Forms');
14 }
15
16 public function getSummaryText() {
17 return pht('Configure creation and editing forms in Paste.');
18 }
19
20 public function getEngineApplicationClass() {
21 return PhabricatorPasteApplication::class;
22 }
23
24 protected function newEditableObject() {
25 return PhabricatorPaste::initializeNewPaste($this->getViewer());
26 }
27
28 protected function newObjectQuery() {
29 return id(new PhabricatorPasteQuery())
30 ->needRawContent(true);
31 }
32
33 protected function getObjectCreateTitleText($object) {
34 return pht('Create New Paste');
35 }
36
37 protected function getObjectEditTitleText($object) {
38 return pht('Edit Paste: %s', $object->getTitle());
39 }
40
41 protected function getObjectEditShortText($object) {
42 return $object->getMonogram();
43 }
44
45 protected function getObjectCreateShortText() {
46 return pht('Create Paste');
47 }
48
49 protected function getObjectName() {
50 return pht('Paste');
51 }
52
53 protected function getCommentViewHeaderText($object) {
54 return pht('Eat Paste');
55 }
56
57 protected function getCommentViewButtonText($object) {
58 return pht('Nom Nom Nom Nom Nom');
59 }
60
61 protected function getObjectViewURI($object) {
62 return '/P'.$object->getID();
63 }
64
65 protected function buildCustomEditFields($object) {
66 return array(
67 id(new PhabricatorTextEditField())
68 ->setKey('title')
69 ->setLabel(pht('Title'))
70 ->setTransactionType(PhabricatorPasteTitleTransaction::TRANSACTIONTYPE)
71 ->setDescription(pht('The title of the paste.'))
72 ->setConduitDescription(pht('Retitle the paste.'))
73 ->setConduitTypeDescription(pht('New paste title.'))
74 ->setValue($object->getTitle()),
75 id(new PhabricatorDatasourceEditField())
76 ->setKey('language')
77 ->setLabel(pht('Language'))
78 ->setTransactionType(
79 PhabricatorPasteLanguageTransaction::TRANSACTIONTYPE)
80 ->setAliases(array('lang'))
81 ->setIsCopyable(true)
82 ->setDatasource(new PasteLanguageSelectDatasource())
83 ->setDescription(
84 pht(
85 'Language used for syntax highlighting. By default, inferred '.
86 'from the title.'))
87 ->setConduitDescription(
88 pht('Change language used for syntax highlighting.'))
89 ->setConduitTypeDescription(pht('New highlighting language.'))
90 ->setSingleValue($object->getLanguage()),
91 id(new PhabricatorTextAreaEditField())
92 ->setKey('text')
93 ->setLabel(pht('Text'))
94 ->setTransactionType(
95 PhabricatorPasteContentTransaction::TRANSACTIONTYPE)
96 ->setMonospaced(true)
97 ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)
98 ->setDescription(pht('The main body text of the paste.'))
99 ->setConduitDescription(pht('Change the paste content.'))
100 ->setConduitTypeDescription(pht('New body content.'))
101 ->setValue($object->getRawContent()),
102 id(new PhabricatorSelectEditField())
103 ->setKey('status')
104 ->setLabel(pht('Status'))
105 ->setTransactionType(
106 PhabricatorPasteStatusTransaction::TRANSACTIONTYPE)
107 ->setIsFormField(false)
108 ->setOptions(PhabricatorPaste::getStatusNameMap())
109 ->setDescription(pht('Active or archived status.'))
110 ->setConduitDescription(pht('Active or archive the paste.'))
111 ->setConduitTypeDescription(pht('New paste status constant.'))
112 ->setValue($object->getStatus()),
113 );
114 }
115
116}