diff --git a/src/applications/phame/controller/blog/PhameBlogArchiveController.php b/src/applications/phame/controller/blog/PhameBlogArchiveController.php index dd69f3154a..4c8d4a4a63 100644 --- a/src/applications/phame/controller/blog/PhameBlogArchiveController.php +++ b/src/applications/phame/controller/blog/PhameBlogArchiveController.php @@ -1,68 +1,68 @@ <?php final class PhameBlogArchiveController extends PhameBlogController { public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $blog = id(new PhameBlogQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) ->executeOne(); if (!$blog) { return new Aphront404Response(); } - $view_uri = $this->getApplicationURI('blog/view/'.$blog->getID().'/'); + $view_uri = $this->getApplicationURI('blog/manage/'.$blog->getID().'/'); if ($request->isFormPost()) { if ($blog->isArchived()) { $new_status = PhameBlog::STATUS_ACTIVE; } else { $new_status = PhameBlog::STATUS_ARCHIVED; } $xactions = array(); $xactions[] = id(new PhameBlogTransaction()) ->setTransactionType(PhameBlogTransaction::TYPE_STATUS) ->setNewValue($new_status); id(new PhameBlogEditor()) ->setActor($viewer) ->setContentSourceFromRequest($request) ->setContinueOnNoEffect(true) ->setContinueOnMissingFields(true) ->applyTransactions($blog, $xactions); return id(new AphrontRedirectResponse())->setURI($view_uri); } if ($blog->isArchived()) { $title = pht('Activate Blog'); $body = pht('This blog will become active again.'); $button = pht('Activate Blog'); } else { $title = pht('Archive Blog'); $body = pht('This blog will be marked as archived.'); $button = pht('Archive Blog'); } $dialog = id(new AphrontDialogView()) ->setUser($viewer) ->setTitle($title) ->appendChild($body) ->addCancelButton($view_uri) ->addSubmitButton($button); return id(new AphrontDialogResponse())->setDialog($dialog); } } diff --git a/src/applications/phame/controller/blog/PhameBlogManageController.php b/src/applications/phame/controller/blog/PhameBlogManageController.php index 42aec0223c..c2c1d28f46 100644 --- a/src/applications/phame/controller/blog/PhameBlogManageController.php +++ b/src/applications/phame/controller/blog/PhameBlogManageController.php @@ -1,205 +1,190 @@ <?php final class PhameBlogManageController extends PhameBlogController { public function shouldAllowPublic() { return true; } public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $blog = id(new PhameBlogQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->needProfileImage(true) ->executeOne(); if (!$blog) { return new Aphront404Response(); } if ($blog->isArchived()) { $header_icon = 'fa-ban'; $header_name = pht('Archived'); $header_color = 'dark'; } else { $header_icon = 'fa-check'; $header_name = pht('Active'); $header_color = 'bluegrey'; } $picture = $blog->getProfileImageURI(); $header = id(new PHUIHeaderView()) ->setHeader($blog->getName()) ->setUser($viewer) ->setPolicyObject($blog) ->setImage($picture) ->setStatus($header_icon, $header_color, $header_name); $actions = $this->renderActions($blog, $viewer); $properties = $this->renderProperties($blog, $viewer, $actions); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb( pht('Blogs'), $this->getApplicationURI('blog/')); $crumbs->addTextCrumb( $blog->getName()); $object_box = id(new PHUIObjectBoxView()) ->setHeader($header) ->addPropertyList($properties); $timeline = $this->buildTransactionTimeline( $blog, new PhameBlogTransactionQuery()); $timeline->setShouldTerminate(true); return $this->newPage() ->setTitle($blog->getName()) ->setCrumbs($crumbs) ->appendChild( array( $object_box, $timeline, )); } private function renderProperties( PhameBlog $blog, PhabricatorUser $viewer, PhabricatorActionListView $actions) { require_celerity_resource('aphront-tooltip-css'); Javelin::initBehavior('phabricator-tooltips'); $properties = id(new PHUIPropertyListView()) ->setUser($viewer) ->setObject($blog) ->setActionList($actions); $skin = $blog->getSkin(); if (!$skin) { - $skin = pht('(No external skin)'); + $skin = phutil_tag('em', array(), pht('No external skin')); } $domain = $blog->getDomain(); if (!$domain) { - $domain = pht('(No external domain)'); + $domain = phutil_tag('em', array(), pht('No external domain')); } $properties->addProperty(pht('Skin'), $skin); $properties->addProperty(pht('Domain'), $domain); $feed_uri = PhabricatorEnv::getProductionURI( $this->getApplicationURI('blog/feed/'.$blog->getID().'/')); $properties->addProperty( pht('Atom URI'), javelin_tag('a', array( 'href' => $feed_uri, 'sigil' => 'has-tooltip', 'meta' => array( 'tip' => pht('Atom URI does not support custom domains.'), 'size' => 320, ), ), $feed_uri)); $descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions( $viewer, $blog); $properties->addProperty( pht('Editable By'), $descriptions[PhabricatorPolicyCapability::CAN_EDIT]); $engine = id(new PhabricatorMarkupEngine()) ->setViewer($viewer) ->addObject($blog, PhameBlog::MARKUP_FIELD_DESCRIPTION) ->process(); $properties->invokeWillRenderEvent(); if (strlen($blog->getDescription())) { $description = PhabricatorMarkupEngine::renderOneObject( id(new PhabricatorMarkupOneOff())->setContent($blog->getDescription()), 'default', $viewer); $properties->addSectionHeader( pht('Description'), PHUIPropertyListView::ICON_SUMMARY); $properties->addTextContent($description); } return $properties; } private function renderActions(PhameBlog $blog, PhabricatorUser $viewer) { $actions = id(new PhabricatorActionListView()) ->setObject($blog) ->setObjectURI($this->getRequest()->getRequestURI()) ->setUser($viewer); $can_edit = PhabricatorPolicyFilter::hasCapability( $viewer, $blog, PhabricatorPolicyCapability::CAN_EDIT); - $actions->addAction( - id(new PhabricatorActionView()) - ->setIcon('fa-plus') - ->setHref($this->getApplicationURI('post/edit/?blog='.$blog->getID())) - ->setName(pht('Write Post')) - ->setDisabled(!$can_edit) - ->setWorkflow(!$can_edit)); - - $actions->addAction( - id(new PhabricatorActionView()) - ->setUser($viewer) - ->setIcon('fa-globe') - ->setHref($blog->getLiveURI()) - ->setName(pht('View Live'))); - $actions->addAction( id(new PhabricatorActionView()) ->setIcon('fa-pencil') ->setHref($this->getApplicationURI('blog/edit/'.$blog->getID().'/')) ->setName(pht('Edit Blog')) ->setDisabled(!$can_edit) ->setWorkflow(!$can_edit)); $actions->addAction( id(new PhabricatorActionView()) ->setIcon('fa-picture-o') ->setHref($this->getApplicationURI('blog/picture/'.$blog->getID().'/')) ->setName(pht('Edit Blog Picture')) ->setDisabled(!$can_edit) ->setWorkflow(!$can_edit)); if ($blog->isArchived()) { $actions->addAction( id(new PhabricatorActionView()) ->setName(pht('Activate Blog')) ->setIcon('fa-check') ->setHref( $this->getApplicationURI('blog/archive/'.$blog->getID().'/')) ->setDisabled(!$can_edit) ->setWorkflow(true)); } else { $actions->addAction( id(new PhabricatorActionView()) ->setName(pht('Archive Blog')) ->setIcon('fa-ban') ->setHref( $this->getApplicationURI('blog/archive/'.$blog->getID().'/')) ->setDisabled(!$can_edit) ->setWorkflow(true)); } return $actions; } } diff --git a/src/applications/phame/storage/PhameBlogTransaction.php b/src/applications/phame/storage/PhameBlogTransaction.php index 791dc930c4..ac996a8a3b 100644 --- a/src/applications/phame/storage/PhameBlogTransaction.php +++ b/src/applications/phame/storage/PhameBlogTransaction.php @@ -1,226 +1,234 @@ <?php final class PhameBlogTransaction extends PhabricatorApplicationTransaction { const TYPE_NAME = 'phame.blog.name'; const TYPE_DESCRIPTION = 'phame.blog.description'; const TYPE_DOMAIN = 'phame.blog.domain'; const TYPE_SKIN = 'phame.blog.skin'; const TYPE_STATUS = 'phame.blog.status'; const MAILTAG_DETAILS = 'phame-blog-details'; const MAILTAG_SUBSCRIBERS = 'phame-blog-subscribers'; const MAILTAG_OTHER = 'phame-blog-other'; public function getApplicationName() { return 'phame'; } public function getApplicationTransactionType() { return PhabricatorPhameBlogPHIDType::TYPECONST; } public function shouldHide() { $old = $this->getOldValue(); switch ($this->getTransactionType()) { case self::TYPE_DESCRIPTION: return ($old === null); } return parent::shouldHide(); } public function getIcon() { $old = $this->getOldValue(); + $new = $this->getNewValue(); switch ($this->getTransactionType()) { case self::TYPE_NAME: if ($old === null) { return 'fa-plus'; } else { return 'fa-pencil'; } break; case self::TYPE_DESCRIPTION: case self::TYPE_DOMAIN: case self::TYPE_SKIN: return 'fa-pencil'; + case self::TYPE_STATUS: + if ($new == PhameBlog::STATUS_ARCHIVED) { + return 'fa-ban'; + } else { + return 'fa-check'; + } break; } return parent::getIcon(); } + public function getColor() { + + $old = $this->getOldValue(); + $new = $this->getNewValue(); + + switch ($this->getTransactionType()) { + case self::TYPE_STATUS: + if ($new == PhameBlog::STATUS_ARCHIVED) { + return 'red'; + } else { + return 'green'; + } + } + return parent::getColor(); + } + public function getMailTags() { $tags = parent::getMailTags(); switch ($this->getTransactionType()) { case PhabricatorTransactions::TYPE_SUBSCRIBERS: $tags[] = self::MAILTAG_SUBSCRIBERS; break; case self::TYPE_NAME: case self::TYPE_DESCRIPTION: case self::TYPE_DOMAIN: case self::TYPE_SKIN: $tags[] = self::MAILTAG_DETAILS; break; default: $tags[] = self::MAILTAG_OTHER; break; } return $tags; } public function getTitle() { $author_phid = $this->getAuthorPHID(); $object_phid = $this->getObjectPHID(); $old = $this->getOldValue(); $new = $this->getNewValue(); $type = $this->getTransactionType(); switch ($type) { case self::TYPE_NAME: if ($old === null) { return pht( '%s created this blog.', $this->renderHandleLink($author_phid)); } else { return pht( '%s updated the blog\'s name to "%s".', $this->renderHandleLink($author_phid), $new); } break; case self::TYPE_DESCRIPTION: return pht( '%s updated the blog\'s description.', $this->renderHandleLink($author_phid)); break; case self::TYPE_DOMAIN: return pht( '%s updated the blog\'s domain to "%s".', $this->renderHandleLink($author_phid), $new); break; case self::TYPE_SKIN: return pht( '%s updated the blog\'s skin to "%s".', $this->renderHandleLink($author_phid), $new); break; case self::TYPE_STATUS: switch ($new) { case PhameBlog::STATUS_ACTIVE: return pht( '%s published this blog.', $this->renderHandleLink($author_phid)); case PhameBlog::STATUS_ARCHIVED: return pht( '%s archived this blog.', $this->renderHandleLink($author_phid)); } } return parent::getTitle(); } public function getTitleForFeed() { $author_phid = $this->getAuthorPHID(); $object_phid = $this->getObjectPHID(); $old = $this->getOldValue(); $new = $this->getNewValue(); $type = $this->getTransactionType(); switch ($type) { case self::TYPE_NAME: if ($old === null) { return pht( '%s created %s.', $this->renderHandleLink($author_phid), $this->renderHandleLink($object_phid)); } else { return pht( '%s updated the name for %s.', $this->renderHandleLink($author_phid), $this->renderHandleLink($object_phid)); } break; case self::TYPE_DESCRIPTION: return pht( '%s updated the description for %s.', $this->renderHandleLink($author_phid), $this->renderHandleLink($object_phid)); break; case self::TYPE_DOMAIN: return pht( '%s updated the domain for %s.', $this->renderHandleLink($author_phid), $this->renderHandleLink($object_phid)); break; case self::TYPE_SKIN: return pht( '%s updated the skin for %s.', $this->renderHandleLink($author_phid), $this->renderHandleLink($object_phid)); break; case self::TYPE_STATUS: switch ($new) { case PhameBlog::STATUS_ACTIVE: return pht( '%s published the blog %s.', $this->renderHandleLink($author_phid), $this->renderHandleLink($object_phid)); case PhameBlog::STATUS_ARCHIVED: return pht( '%s archived the blog %s.', $this->renderHandleLink($author_phid), $this->renderHandleLink($object_phid)); } break; } return parent::getTitleForFeed(); } - public function getColor() { - $old = $this->getOldValue(); - - switch ($this->getTransactionType()) { - case self::TYPE_NAME: - if ($old === null) { - return PhabricatorTransactions::COLOR_GREEN; - } - break; - } - - return parent::getColor(); - } - - public function hasChangeDetails() { switch ($this->getTransactionType()) { case self::TYPE_DESCRIPTION: return ($this->getOldValue() !== null); } return parent::hasChangeDetails(); } public function renderChangeDetails(PhabricatorUser $viewer) { switch ($this->getTransactionType()) { case self::TYPE_DESCRIPTION: $old = $this->getOldValue(); $new = $this->getNewValue(); return $this->renderTextCorpusChangeDetails( $viewer, $old, $new); } return parent::renderChangeDetails($viewer); } }