From 015ead6e7b85aa660994862e8ab3a62f23a7902d Mon Sep 17 00:00:00 2001 From: Chad Little Date: Tue, 15 Nov 2016 11:48:31 -0800 Subject: [PATCH] Add subtitle to PhamePost Summary: No view engine yet (adding header image next), but adds subtitle to display like PhameBlog Test Plan: Add a subtitle, remove a subtitle. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D16871 --- .../20161115.phamepost.01.subtitle.sql | 2 ++ .../phame/editor/PhamePostEditEngine.php | 8 +++++++ .../phame/editor/PhamePostEditor.php | 7 +++++++ src/applications/phame/storage/PhamePost.php | 2 ++ .../phame/storage/PhamePostTransaction.php | 21 +++++++++++++++++++ 5 files changed, 40 insertions(+) create mode 100644 resources/sql/autopatches/20161115.phamepost.01.subtitle.sql diff --git a/resources/sql/autopatches/20161115.phamepost.01.subtitle.sql b/resources/sql/autopatches/20161115.phamepost.01.subtitle.sql new file mode 100644 index 0000000000..c3047bba82 --- /dev/null +++ b/resources/sql/autopatches/20161115.phamepost.01.subtitle.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_phame.phame_post + ADD subtitle VARCHAR(64) NOT NULL COLLATE {$COLLATE_TEXT}; diff --git a/src/applications/phame/editor/PhamePostEditEngine.php b/src/applications/phame/editor/PhamePostEditEngine.php index 382ef3f8ff..e80c1f6d0d 100644 --- a/src/applications/phame/editor/PhamePostEditEngine.php +++ b/src/applications/phame/editor/PhamePostEditEngine.php @@ -99,6 +99,14 @@ final class PhamePostEditEngine ->setConduitTypeDescription(pht('New post title.')) ->setTransactionType(PhamePostTransaction::TYPE_TITLE) ->setValue($object->getTitle()), + id(new PhabricatorTextEditField()) + ->setKey('subtitle') + ->setLabel(pht('Subtitle')) + ->setDescription(pht('Post subtitle.')) + ->setConduitDescription(pht('Change the post subtitle.')) + ->setConduitTypeDescription(pht('New post subtitle.')) + ->setTransactionType(PhamePostTransaction::TYPE_SUBTITLE) + ->setValue($object->getSubtitle()), id(new PhabricatorSelectEditField()) ->setKey('visibility') ->setLabel(pht('Visibility')) diff --git a/src/applications/phame/editor/PhamePostEditor.php b/src/applications/phame/editor/PhamePostEditor.php index 363f39fb46..156059cae6 100644 --- a/src/applications/phame/editor/PhamePostEditor.php +++ b/src/applications/phame/editor/PhamePostEditor.php @@ -16,6 +16,7 @@ final class PhamePostEditor $types[] = PhamePostTransaction::TYPE_BLOG; $types[] = PhamePostTransaction::TYPE_TITLE; + $types[] = PhamePostTransaction::TYPE_SUBTITLE; $types[] = PhamePostTransaction::TYPE_BODY; $types[] = PhamePostTransaction::TYPE_VISIBILITY; $types[] = PhabricatorTransactions::TYPE_COMMENT; @@ -32,6 +33,8 @@ final class PhamePostEditor return $object->getBlogPHID(); case PhamePostTransaction::TYPE_TITLE: return $object->getTitle(); + case PhamePostTransaction::TYPE_SUBTITLE: + return $object->getSubtitle(); case PhamePostTransaction::TYPE_BODY: return $object->getBody(); case PhamePostTransaction::TYPE_VISIBILITY: @@ -45,6 +48,7 @@ final class PhamePostEditor switch ($xaction->getTransactionType()) { case PhamePostTransaction::TYPE_TITLE: + case PhamePostTransaction::TYPE_SUBTITLE: case PhamePostTransaction::TYPE_BODY: case PhamePostTransaction::TYPE_VISIBILITY: case PhamePostTransaction::TYPE_BLOG: @@ -59,6 +63,8 @@ final class PhamePostEditor switch ($xaction->getTransactionType()) { case PhamePostTransaction::TYPE_TITLE: return $object->setTitle($xaction->getNewValue()); + case PhamePostTransaction::TYPE_SUBTITLE: + return $object->setSubtitle($xaction->getNewValue()); case PhamePostTransaction::TYPE_BODY: return $object->setBody($xaction->getNewValue()); case PhamePostTransaction::TYPE_BLOG: @@ -84,6 +90,7 @@ final class PhamePostEditor switch ($xaction->getTransactionType()) { case PhamePostTransaction::TYPE_TITLE: + case PhamePostTransaction::TYPE_SUBTITLE: case PhamePostTransaction::TYPE_BODY: case PhamePostTransaction::TYPE_VISIBILITY: case PhamePostTransaction::TYPE_BLOG: diff --git a/src/applications/phame/storage/PhamePost.php b/src/applications/phame/storage/PhamePost.php index 351bcb5dc0..7eb05e8866 100644 --- a/src/applications/phame/storage/PhamePost.php +++ b/src/applications/phame/storage/PhamePost.php @@ -18,6 +18,7 @@ final class PhamePost extends PhameDAO protected $bloggerPHID; protected $title; + protected $subtitle; protected $phameTitle; protected $body; protected $visibility; @@ -122,6 +123,7 @@ final class PhamePost extends PhameDAO ), self::CONFIG_COLUMN_SCHEMA => array( 'title' => 'text255', + 'subtitle' => 'text64', 'phameTitle' => 'sort64?', 'visibility' => 'uint32', 'mailKey' => 'bytes20', diff --git a/src/applications/phame/storage/PhamePostTransaction.php b/src/applications/phame/storage/PhamePostTransaction.php index a1efb584b0..5142e0d594 100644 --- a/src/applications/phame/storage/PhamePostTransaction.php +++ b/src/applications/phame/storage/PhamePostTransaction.php @@ -4,6 +4,7 @@ final class PhamePostTransaction extends PhabricatorApplicationTransaction { const TYPE_TITLE = 'phame.post.title'; + const TYPE_SUBTITLE = 'phame.post.subtitle'; const TYPE_BODY = 'phame.post.body'; const TYPE_VISIBILITY = 'phame.post.visibility'; const TYPE_BLOG = 'phame.post.blog'; @@ -94,6 +95,7 @@ final class PhamePostTransaction $tags[] = self::MAILTAG_SUBSCRIBERS; break; case self::TYPE_TITLE: + case self::TYPE_SUBTITLE: case self::TYPE_BODY: $tags[] = self::MAILTAG_CONTENT; break; @@ -136,6 +138,19 @@ final class PhamePostTransaction $new); } break; + case self::TYPE_SUBTITLE: + if ($old === null) { + return pht( + '%s set the post\'s subtitle to "%s".', + $this->renderHandleLink($author_phid), + $new); + } else { + return pht( + '%s updated the post\'s subtitle to "%s".', + $this->renderHandleLink($author_phid), + $new); + } + break; case self::TYPE_BODY: return pht( '%s updated the blog post.', @@ -195,6 +210,12 @@ final class PhamePostTransaction $this->renderHandleLink($object_phid)); } break; + case self::TYPE_SUBTITLE: + return pht( + '%s updated the subtitle for %s.', + $this->renderHandleLink($author_phid), + $this->renderHandleLink($object_phid)); + break; case self::TYPE_BODY: return pht( '%s updated the blog post %s.',