3 final class PhamePostEditEngine
4 extends PhabricatorEditEngine
{
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) {
27 public function getEngineApplicationClass() {
28 return 'PhabricatorPhameApplication';
31 protected function newEditableObject() {
32 $viewer = $this->getViewer();
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() {
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();
79 id(new PhabricatorHandlesEditField())
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)
94 id(new PhabricatorTextEditField())
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())
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())
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())
129 id(new PHUIRemarkupPreviewPanel())
130 ->setHeader(pht('Blog Post'))
131 ->setPreviewType(PHUIRemarkupPreviewPanel
::DOCUMENT
)),