@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 PhabricatorPhurlURLEditEngine
4 extends PhabricatorEditEngine {
5
6 const ENGINECONST = 'phurl.url';
7
8 public function getEngineName() {
9 return pht('Phurl');
10 }
11
12 public function getEngineApplicationClass() {
13 return PhabricatorPhurlApplication::class;
14 }
15
16 public function getSummaryHeader() {
17 return pht('Configure Phurl Forms');
18 }
19
20 public function getSummaryText() {
21 return pht('Configure creation and editing forms in Phurl.');
22 }
23
24 public function isEngineConfigurable() {
25 return false;
26 }
27
28 protected function newEditableObject() {
29 return PhabricatorPhurlURL::initializeNewPhurlURL($this->getViewer());
30 }
31
32 protected function newObjectQuery() {
33 return new PhabricatorPhurlURLQuery();
34 }
35
36 protected function getObjectCreateTitleText($object) {
37 return pht('Create New URL');
38 }
39
40 protected function getObjectEditTitleText($object) {
41 return pht('Edit URL: %s', $object->getName());
42 }
43
44 protected function getObjectEditShortText($object) {
45 return $object->getName();
46 }
47
48 protected function getObjectCreateShortText() {
49 return pht('Create URL');
50 }
51
52 protected function getObjectName() {
53 return pht('URL');
54 }
55
56 protected function getObjectCreateCancelURI($object) {
57 return $this->getApplication()->getApplicationURI('/');
58 }
59
60 protected function getEditorURI() {
61 return $this->getApplication()->getApplicationURI('url/edit/');
62 }
63
64 protected function getObjectViewURI($object) {
65 return $object->getURI();
66 }
67
68 protected function getCreateNewObjectPolicy() {
69 return $this->getApplication()->getPolicy(
70 PhabricatorPhurlURLCreateCapability::CAPABILITY);
71 }
72
73 protected function buildCustomEditFields($object) {
74
75 return array(
76 id(new PhabricatorTextEditField())
77 ->setKey('name')
78 ->setLabel(pht('Name'))
79 ->setDescription(pht('URL name.'))
80 ->setIsRequired(true)
81 ->setConduitTypeDescription(pht('New URL name.'))
82 ->setTransactionType(
83 PhabricatorPhurlURLNameTransaction::TRANSACTIONTYPE)
84 ->setValue($object->getName()),
85 id(new PhabricatorTextEditField())
86 ->setKey('url')
87 ->setLabel(pht('URL'))
88 ->setDescription(pht('The URL to shorten.'))
89 ->setConduitTypeDescription(pht('New URL.'))
90 ->setValue($object->getLongURL())
91 ->setIsRequired(true)
92 ->setTransactionType(
93 PhabricatorPhurlURLLongURLTransaction::TRANSACTIONTYPE),
94 id(new PhabricatorTextEditField())
95 ->setKey('alias')
96 ->setLabel(pht('Alias'))
97 ->setIsRequired(true)
98 ->setTransactionType(
99 PhabricatorPhurlURLAliasTransaction::TRANSACTIONTYPE)
100 ->setDescription(pht('The alias to give the URL.'))
101 ->setConduitTypeDescription(pht('New alias.'))
102 ->setValue($object->getAlias()),
103 id(new PhabricatorRemarkupEditField())
104 ->setKey('description')
105 ->setLabel(pht('Description'))
106 ->setDescription(pht('URL long description.'))
107 ->setConduitTypeDescription(pht('New URL description.'))
108 ->setTransactionType(
109 PhabricatorPhurlURLDescriptionTransaction::TRANSACTIONTYPE)
110 ->setValue($object->getDescription()),
111 );
112 }
113
114}