Remove product literal strings in "pht()", part 6
[phabricator.git] / src / applications / legalpad / editor / LegalpadDocumentEditEngine.php
blobfb3f54275a16321311da2086edb08b99227d9c97
1 <?php
3 final class LegalpadDocumentEditEngine
4 extends PhabricatorEditEngine {
6 const ENGINECONST = 'legalpad.document';
8 public function getEngineName() {
9 return pht('Legalpad');
12 public function getEngineApplicationClass() {
13 return 'PhabricatorLegalpadApplication';
16 public function getSummaryHeader() {
17 return pht('Configure Legalpad Forms');
20 public function getSummaryText() {
21 return pht('Configure creation and editing documents in Legalpad.');
24 public function isEngineConfigurable() {
25 return false;
28 protected function newEditableObject() {
29 $viewer = $this->getViewer();
31 $document = LegalpadDocument::initializeNewDocument($viewer);
32 $body = id(new LegalpadDocumentBody())
33 ->setCreatorPHID($viewer->getPHID());
34 $document->attachDocumentBody($body);
35 $document->setDocumentBodyPHID(PhabricatorPHIDConstants::PHID_VOID);
37 return $document;
40 protected function newObjectQuery() {
41 return id(new LegalpadDocumentQuery())
42 ->needDocumentBodies(true);
45 protected function getObjectCreateTitleText($object) {
46 return pht('Create New Document');
49 protected function getObjectEditTitleText($object) {
50 $body = $object->getDocumentBody();
51 $title = $body->getTitle();
52 return pht('Edit Document: %s', $title);
55 protected function getObjectEditShortText($object) {
56 $body = $object->getDocumentBody();
57 return $body->getTitle();
60 protected function getObjectCreateShortText() {
61 return pht('Create Document');
64 protected function getObjectName() {
65 return pht('Document');
68 protected function getObjectCreateCancelURI($object) {
69 return $this->getApplication()->getApplicationURI('/');
72 protected function getEditorURI() {
73 return $this->getApplication()->getApplicationURI('edit/');
76 protected function getObjectViewURI($object) {
77 $id = $object->getID();
78 return $this->getApplication()->getApplicationURI('view/'.$id.'/');
82 protected function getCreateNewObjectPolicy() {
83 return $this->getApplication()->getPolicy(
84 LegalpadCreateDocumentsCapability::CAPABILITY);
87 protected function buildCustomEditFields($object) {
88 $viewer = $this->getViewer();
90 $body = $object->getDocumentBody();
91 $document_body = $body->getText();
93 $is_create = $this->getIsCreate();
94 $is_admin = $viewer->getIsAdmin();
96 $fields = array();
97 $fields[] =
98 id(new PhabricatorTextEditField())
99 ->setKey('title')
100 ->setLabel(pht('Title'))
101 ->setDescription(pht('Document Title.'))
102 ->setConduitTypeDescription(pht('New document title.'))
103 ->setValue($object->getTitle())
104 ->setIsRequired(true)
105 ->setTransactionType(
106 LegalpadDocumentTitleTransaction::TRANSACTIONTYPE);
108 if ($is_create) {
109 $fields[] =
110 id(new PhabricatorSelectEditField())
111 ->setKey('signatureType')
112 ->setLabel(pht('Who Should Sign?'))
113 ->setDescription(pht('Type of signature required'))
114 ->setConduitTypeDescription(pht('New document signature type.'))
115 ->setValue($object->getSignatureType())
116 ->setOptions(LegalpadDocument::getSignatureTypeMap())
117 ->setTransactionType(
118 LegalpadDocumentSignatureTypeTransaction::TRANSACTIONTYPE);
119 $show_require = true;
120 } else {
121 $fields[] = id(new PhabricatorStaticEditField())
122 ->setLabel(pht('Who Should Sign?'))
123 ->setValue($object->getSignatureTypeName());
124 $individual = LegalpadDocument::SIGNATURE_TYPE_INDIVIDUAL;
125 $show_require = $object->getSignatureType() == $individual;
128 if ($show_require && $is_admin) {
129 $fields[] =
130 id(new PhabricatorBoolEditField())
131 ->setKey('requireSignature')
132 ->setOptions(
133 pht('No Signature Required'),
134 pht('Signature Required to Log In'))
135 ->setAsCheckbox(true)
136 ->setTransactionType(
137 LegalpadDocumentRequireSignatureTransaction::TRANSACTIONTYPE)
138 ->setDescription(pht('Marks this document as required signing.'))
139 ->setConduitDescription(
140 pht('Marks this document as required signing.'))
141 ->setValue($object->getRequireSignature());
144 $fields[] =
145 id(new PhabricatorRemarkupEditField())
146 ->setKey('preamble')
147 ->setLabel(pht('Preamble'))
148 ->setDescription(pht('The preamble of the document.'))
149 ->setConduitTypeDescription(pht('New document preamble.'))
150 ->setValue($object->getPreamble())
151 ->setTransactionType(
152 LegalpadDocumentPreambleTransaction::TRANSACTIONTYPE);
154 $fields[] =
155 id(new PhabricatorRemarkupEditField())
156 ->setKey('text')
157 ->setLabel(pht('Document Body'))
158 ->setDescription(pht('The body of text of the document.'))
159 ->setConduitTypeDescription(pht('New document body.'))
160 ->setValue($document_body)
161 ->setIsRequired(true)
162 ->setTransactionType(
163 LegalpadDocumentTextTransaction::TRANSACTIONTYPE);
165 return $fields;