Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phame/controller/post/PhamePostViewController.php
| Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | if ($post->isDraft()) { | ||||
| id(new PHUIInfoView()) | id(new PHUIInfoView()) | ||||
| ->setSeverity(PHUIInfoView::SEVERITY_NOTICE) | ->setSeverity(PHUIInfoView::SEVERITY_NOTICE) | ||||
| ->setTitle(pht('Draft Post')) | ->setTitle(pht('Draft Post')) | ||||
| ->appendChild( | ->appendChild( | ||||
| pht('Only you can see this draft until you publish it. '. | pht('Only you can see this draft until you publish it. '. | ||||
| 'Use "Publish" to publish this post.'))); | 'Use "Publish" to publish this post.'))); | ||||
| } | } | ||||
| if ($post->isArchived()) { | |||||
| $document->appendChild( | |||||
| id(new PHUIInfoView()) | |||||
| ->setSeverity(PHUIInfoView::SEVERITY_ERROR) | |||||
| ->setTitle(pht('Archived Post')) | |||||
| ->appendChild( | |||||
| pht('Only you can see this archived post until you publish it. '. | |||||
| 'Use "Publish" to publish this post.'))); | |||||
| } | |||||
| if (!$post->getBlog()) { | if (!$post->getBlog()) { | ||||
| $document->appendChild( | $document->appendChild( | ||||
| id(new PHUIInfoView()) | id(new PHUIInfoView()) | ||||
| ->setSeverity(PHUIInfoView::SEVERITY_WARNING) | ->setSeverity(PHUIInfoView::SEVERITY_WARNING) | ||||
| ->setTitle(pht('Not On A Blog')) | ->setTitle(pht('Not On A Blog')) | ||||
| ->appendChild( | ->appendChild( | ||||
| pht('This post is not associated with a blog (the blog may have '. | pht('This post is not associated with a blog (the blog may have '. | ||||
| 'been deleted). Use "Move Post" to move it to a new blog.'))); | 'been deleted). Use "Move Post" to move it to a new blog.'))); | ||||
| Show All 28 Lines | $author = phutil_tag( | ||||
| array( | array( | ||||
| 'href' => $author_uri, | 'href' => $author_uri, | ||||
| ), | ), | ||||
| $blogger->getUsername()); | $blogger->getUsername()); | ||||
| $date = phabricator_datetime($post->getDatePublished(), $viewer); | $date = phabricator_datetime($post->getDatePublished(), $viewer); | ||||
| if ($post->isDraft()) { | if ($post->isDraft()) { | ||||
| $subtitle = pht('Unpublished draft by %s.', $author); | $subtitle = pht('Unpublished draft by %s.', $author); | ||||
| } else if ($post->isArchived()) { | |||||
| $subtitle = pht('Archived post by %s.', $author); | |||||
| } else { | } else { | ||||
| $subtitle = pht('Written by %s on %s.', $author, $date); | $subtitle = pht('Written by %s on %s.', $author, $date); | ||||
| } | } | ||||
| $user_icon = $blogger_profile->getIcon(); | $user_icon = $blogger_profile->getIcon(); | ||||
| $user_icon = PhabricatorPeopleIconSet::getIconIcon($user_icon); | $user_icon = PhabricatorPeopleIconSet::getIconIcon($user_icon); | ||||
| $user_icon = id(new PHUIIconView())->setIcon($user_icon); | $user_icon = id(new PHUIIconView())->setIcon($user_icon); | ||||
| ▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | private function renderActions(PhamePost $post) { | ||||
| if ($post->isDraft()) { | if ($post->isDraft()) { | ||||
| $actions->addAction( | $actions->addAction( | ||||
| id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
| ->setIcon('fa-eye') | ->setIcon('fa-eye') | ||||
| ->setHref($this->getApplicationURI('post/publish/'.$id.'/')) | ->setHref($this->getApplicationURI('post/publish/'.$id.'/')) | ||||
| ->setName(pht('Publish')) | ->setName(pht('Publish')) | ||||
| ->setDisabled(!$can_edit) | ->setDisabled(!$can_edit) | ||||
| ->setWorkflow(true)); | ->setWorkflow(true)); | ||||
| $actions->addAction( | |||||
| id(new PhabricatorActionView()) | |||||
| ->setIcon('fa-ban') | |||||
| ->setHref($this->getApplicationURI('post/archive/'.$id.'/')) | |||||
| ->setName(pht('Archive')) | |||||
| ->setDisabled(!$can_edit) | |||||
| ->setWorkflow(true)); | |||||
| } else if ($post->isArchived()) { | |||||
| $actions->addAction( | |||||
| id(new PhabricatorActionView()) | |||||
| ->setIcon('fa-eye') | |||||
| ->setHref($this->getApplicationURI('post/publish/'.$id.'/')) | |||||
| ->setName(pht('Publish')) | |||||
| ->setDisabled(!$can_edit) | |||||
| ->setWorkflow(true)); | |||||
| } else { | } else { | ||||
| $actions->addAction( | $actions->addAction( | ||||
| id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
| ->setIcon('fa-eye-slash') | ->setIcon('fa-eye-slash') | ||||
| ->setHref($this->getApplicationURI('post/unpublish/'.$id.'/')) | ->setHref($this->getApplicationURI('post/unpublish/'.$id.'/')) | ||||
| ->setName(pht('Unpublish')) | ->setName(pht('Unpublish')) | ||||
| ->setDisabled(!$can_edit) | ->setDisabled(!$can_edit) | ||||
| ->setWorkflow(true)); | ->setWorkflow(true)); | ||||
| $actions->addAction( | |||||
| id(new PhabricatorActionView()) | |||||
| ->setIcon('fa-ban') | |||||
| ->setHref($this->getApplicationURI('post/archive/'.$id.'/')) | |||||
| ->setName(pht('Archive')) | |||||
| ->setDisabled(!$can_edit) | |||||
| ->setWorkflow(true)); | |||||
| } | } | ||||
| if ($post->isDraft()) { | if ($post->isDraft()) { | ||||
| $live_name = pht('Preview'); | $live_name = pht('Preview'); | ||||
| } else { | } else { | ||||
| $live_name = pht('View Live'); | $live_name = pht('View Live'); | ||||
| } | } | ||||
| if (!$post->isArchived()) { | |||||
| $actions->addAction( | $actions->addAction( | ||||
| id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
| ->setUser($viewer) | ->setUser($viewer) | ||||
| ->setIcon('fa-globe') | ->setIcon('fa-globe') | ||||
| ->setHref($post->getLiveURI()) | ->setHref($post->getLiveURI()) | ||||
| ->setName($live_name)); | ->setName($live_name)); | ||||
| } | |||||
| return $actions; | return $actions; | ||||
| } | } | ||||
| private function buildCommentForm(PhamePost $post) { | private function buildCommentForm(PhamePost $post) { | ||||
| $viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
| $draft = PhabricatorDraft::newFromUserAndKey( | $draft = PhabricatorDraft::newFromUserAndKey( | ||||
| Show All 10 Lines | private function buildCommentForm(PhamePost $post) { | ||||
| return phutil_tag_div('phui-document-view-pro-box', $box); | return phutil_tag_div('phui-document-view-pro-box', $box); | ||||
| } | } | ||||
| private function loadAdjacentPosts(PhamePost $post) { | private function loadAdjacentPosts(PhamePost $post) { | ||||
| $viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
| $query = id(new PhamePostQuery()) | $query = id(new PhamePostQuery()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->withVisibility(PhameConstants::VISIBILITY_PUBLISHED) | ->withVisibility(array(PhameConstants::VISIBILITY_PUBLISHED)) | ||||
| ->withBlogPHIDs(array($post->getBlog()->getPHID())) | ->withBlogPHIDs(array($post->getBlog()->getPHID())) | ||||
| ->setLimit(1); | ->setLimit(1); | ||||
| $prev = id(clone $query) | $prev = id(clone $query) | ||||
| ->setAfterID($post->getID()) | ->setAfterID($post->getID()) | ||||
| ->execute(); | ->execute(); | ||||
| $next = id(clone $query) | $next = id(clone $query) | ||||
| ->setBeforeID($post->getID()) | ->setBeforeID($post->getID()) | ||||
| ->execute(); | ->execute(); | ||||
| return array(head($prev), head($next)); | return array(head($prev), head($next)); | ||||
| } | } | ||||
| } | } | ||||