Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / phame / editor / PhamePostEditEngine.php
blob04738beb8001b8f4c1ded1d59c4b05c7a1ae25fe
1 <?php
3 final class PhamePostEditEngine
4 extends PhabricatorEditEngine {
6 private $blog;
8 const ENGINECONST = 'phame.post';
10 public function getEngineName() {
11 return pht('Blog Posts');
14 public function getSummaryHeader() {
15 return pht('Configure Blog Post Forms');
18 public function getSummaryText() {
19 return pht('Configure creation and editing blog posts in Phame.');
22 public function setBlog(PhameBlog $blog) {
23 $this->blog = $blog;
24 return $this;
27 public function getEngineApplicationClass() {
28 return 'PhabricatorPhameApplication';
31 protected function newEditableObject() {
32 $viewer = $this->getViewer();
34 if ($this->blog) {
35 $blog = $this->blog;
36 } else {
37 $blog = PhameBlog::initializeNewBlog($viewer);
40 return PhamePost::initializePost($viewer, $blog);
43 protected function newObjectQuery() {
44 return new PhamePostQuery();
47 protected function getObjectCreateTitleText($object) {
48 return pht('Create New Post');
51 protected function getObjectEditTitleText($object) {
52 return pht('Edit %s', $object->getTitle());
55 protected function getObjectEditShortText($object) {
56 return $object->getTitle();
59 protected function getObjectCreateShortText() {
60 return pht('Create Post');
63 protected function getObjectName() {
64 return pht('Post');
67 protected function getObjectViewURI($object) {
68 return $object->getViewURI();
71 protected function getEditorURI() {
72 return $this->getApplication()->getApplicationURI('post/edit/');
75 protected function buildCustomEditFields($object) {
76 $blog_phid = $object->getBlog()->getPHID();
78 return array(
79 id(new PhabricatorHandlesEditField())
80 ->setKey('blog')
81 ->setLabel(pht('Blog'))
82 ->setDescription(pht('Blog to publish this post to.'))
83 ->setConduitDescription(
84 pht('Choose a blog to create a post on (or move a post to).'))
85 ->setConduitTypeDescription(pht('PHID of the blog.'))
86 ->setAliases(array('blogPHID'))
87 ->setTransactionType(PhamePostBlogTransaction::TRANSACTIONTYPE)
88 ->setHandleParameterType(new AphrontPHIDListHTTPParameterType())
89 ->setSingleValue($blog_phid)
90 ->setIsReorderable(false)
91 ->setIsDefaultable(false)
92 ->setIsLockable(false)
93 ->setIsLocked(true),
94 id(new PhabricatorTextEditField())
95 ->setKey('title')
96 ->setLabel(pht('Title'))
97 ->setDescription(pht('Post title.'))
98 ->setConduitDescription(pht('Retitle the post.'))
99 ->setConduitTypeDescription(pht('New post title.'))
100 ->setTransactionType(PhamePostTitleTransaction::TRANSACTIONTYPE)
101 ->setIsRequired(true)
102 ->setValue($object->getTitle()),
103 id(new PhabricatorTextEditField())
104 ->setKey('subtitle')
105 ->setLabel(pht('Subtitle'))
106 ->setDescription(pht('Post subtitle.'))
107 ->setConduitDescription(pht('Change the post subtitle.'))
108 ->setConduitTypeDescription(pht('New post subtitle.'))
109 ->setTransactionType(PhamePostSubtitleTransaction::TRANSACTIONTYPE)
110 ->setValue($object->getSubtitle()),
111 id(new PhabricatorSelectEditField())
112 ->setKey('visibility')
113 ->setLabel(pht('Visibility'))
114 ->setDescription(pht('Post visibility.'))
115 ->setConduitDescription(pht('Change post visibility.'))
116 ->setConduitTypeDescription(pht('New post visibility constant.'))
117 ->setTransactionType(PhamePostVisibilityTransaction::TRANSACTIONTYPE)
118 ->setValue($object->getVisibility())
119 ->setOptions(PhameConstants::getPhamePostStatusMap()),
120 id(new PhabricatorRemarkupEditField())
121 ->setKey('body')
122 ->setLabel(pht('Body'))
123 ->setDescription(pht('Post body.'))
124 ->setConduitDescription(pht('Change post body.'))
125 ->setConduitTypeDescription(pht('New post body.'))
126 ->setTransactionType(PhamePostBodyTransaction::TRANSACTIONTYPE)
127 ->setValue($object->getBody())
128 ->setPreviewPanel(
129 id(new PHUIRemarkupPreviewPanel())
130 ->setHeader(pht('Blog Post'))
131 ->setPreviewType(PHUIRemarkupPreviewPanel::DOCUMENT)),