Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/phame/controller/post/PhamePostFramedController.php b/src/applications/phame/controller/post/PhamePostFramedController.php
index 635c120928..46f723aa81 100644
--- a/src/applications/phame/controller/post/PhamePostFramedController.php
+++ b/src/applications/phame/controller/post/PhamePostFramedController.php
@@ -1,45 +1,39 @@
<?php
final class PhamePostFramedController extends PhameController {
- private $id;
-
- public function willProcessRequest(array $data) {
- $this->id = $data['id'];
- }
-
- public function processRequest() {
- $request = $this->getRequest();
- $user = $request->getUser();
+ public function handleRequest(AphrontRequest $request) {
+ $user = $request->getViewer();
+ $id = $request->getURIData('id');
$post = id(new PhamePostQuery())
->setViewer($user)
- ->withIDs(array($this->id))
+ ->withIDs(array($id))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$post) {
return new Aphront404Response();
}
$blog = $post->getBlog();
$phame_request = $request->setPath('/post/'.$post->getPhameTitle());
$skin = $post->getBlog()->getSkinRenderer($phame_request);
$uri = clone $request->getRequestURI();
$uri->setPath('/phame/live/'.$blog->getID().'/');
$skin
->setPreview(true)
->setBlog($post->getBlog())
->setBaseURI((string)$uri);
$response = $skin->processRequest();
$response->setFrameable(true);
return $response;
}
}
diff --git a/src/applications/phame/controller/post/PhamePostListController.php b/src/applications/phame/controller/post/PhamePostListController.php
index 90ba2a1ae7..6a02129bd8 100644
--- a/src/applications/phame/controller/post/PhamePostListController.php
+++ b/src/applications/phame/controller/post/PhamePostListController.php
@@ -1,88 +1,80 @@
<?php
final class PhamePostListController extends PhameController {
- private $bloggername;
- private $filter;
-
- public function willProcessRequest(array $data) {
- $this->filter = idx($data, 'filter', 'blogger');
- $this->bloggername = idx($data, 'bloggername');
- }
-
- public function processRequest() {
- $request = $this->getRequest();
- $user = $request->getUser();
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $filter = $request->getURIData('filter');
+ $bloggername = $request->getURIData('bloggername');
$query = id(new PhamePostQuery())
- ->setViewer($user);
+ ->setViewer($viewer);
$nav = $this->renderSideNavFilterView();
$nodata = null;
- switch ($this->filter) {
+ switch ($filter) {
case 'draft':
- $query->withBloggerPHIDs(array($user->getPHID()));
+ $query->withBloggerPHIDs(array($viewer->getPHID()));
$query->withVisibility(PhamePost::VISIBILITY_DRAFT);
$nodata = pht('You have no unpublished drafts.');
$title = pht('Unpublished Drafts');
$nav->selectFilter('post/draft');
break;
+ case 'all':
+ $nodata = pht('There are no visible posts.');
+ $title = pht('Posts');
+ $nav->selectFilter('post/all');
+ break;
+ default:
case 'blogger':
- if ($this->bloggername) {
+ if ($bloggername) {
$blogger = id(new PhabricatorUser())->loadOneWhere(
'username = %s',
- $this->bloggername);
+ $bloggername);
if (!$blogger) {
return new Aphront404Response();
}
} else {
- $blogger = $user;
+ $blogger = $viewer;
}
$query->withBloggerPHIDs(array($blogger->getPHID()));
- if ($blogger->getPHID() == $user->getPHID()) {
+ if ($blogger->getPHID() == $viewer->getPHID()) {
$nav->selectFilter('post');
$nodata = pht('You have not written any posts.');
} else {
$nodata = pht('%s has not written any posts.', $blogger);
}
$title = pht('Posts by %s', $blogger);
break;
- case 'all':
- $nodata = pht('There are no visible posts.');
- $title = pht('Posts');
- $nav->selectFilter('post/all');
- break;
- default:
- throw new Exception(pht("Unknown filter '%s'!", $this->filter));
}
$pager = id(new AphrontCursorPagerView())
->readFromRequest($request);
$posts = $query->executeWithCursorPager($pager);
require_celerity_resource('phame-css');
- $post_list = $this->renderPostList($posts, $user, $nodata);
+ $post_list = $this->renderPostList($posts, $viewer, $nodata);
$post_list = id(new PHUIObjectBoxView())
->setHeaderText($title)
->appendChild($post_list);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($title, $this->getApplicationURI());
$nav->appendChild(
array(
$crumbs,
$post_list,
));
return $this->buildApplicationPage(
$nav,
array(
'title' => $title,
));
}
}
diff --git a/src/applications/phame/controller/post/PhamePostNotLiveController.php b/src/applications/phame/controller/post/PhamePostNotLiveController.php
index 8cfddb8436..3f69860003 100644
--- a/src/applications/phame/controller/post/PhamePostNotLiveController.php
+++ b/src/applications/phame/controller/post/PhamePostNotLiveController.php
@@ -1,58 +1,52 @@
<?php
final class PhamePostNotLiveController extends PhameController {
- private $id;
-
- public function willProcessRequest(array $data) {
- $this->id = $data['id'];
- }
-
- public function processRequest() {
- $request = $this->getRequest();
+ public function handleRequest(AphrontRequest $request) {
$user = $request->getUser();
+ $id = $request->getURIData('id');
$post = id(new PhamePostQuery())
->setViewer($user)
- ->withIDs(array($this->id))
+ ->withIDs(array($id))
->executeOne();
if (!$post) {
return new Aphront404Response();
}
$reasons = array();
if (!$post->getBlog()) {
$reasons[] = phutil_tag('p', array(), pht(
'You can not view the live version of this post because it '.
'is not associated with a blog. Move the post to a blog in order to '.
'view it live.'));
}
if ($post->isDraft()) {
$reasons[] = phutil_tag('p', array(), pht(
'You can not view the live version of this post because it '.
'is still a draft. Use "Preview/Publish" to publish the post.'));
}
if ($reasons) {
$cancel_uri = $this->getApplicationURI('/post/view/'.$post->getID().'/');
$dialog = id(new AphrontDialogView())
->setUser($user)
->setTitle(pht('Post Not Live'))
->addCancelButton($cancel_uri);
foreach ($reasons as $reason) {
$dialog->appendChild($reason);
}
return id(new AphrontDialogResponse())->setDialog($dialog);
}
// No reason this can't go live, maybe an old link. Kick them live and see
// what happens.
$live_uri = $post->getViewURI();
return id(new AphrontRedirectResponse())->setURI($live_uri);
}
}
diff --git a/src/applications/phame/controller/post/PhamePostPublishController.php b/src/applications/phame/controller/post/PhamePostPublishController.php
index fcc7b29dc8..1b3cac79a4 100644
--- a/src/applications/phame/controller/post/PhamePostPublishController.php
+++ b/src/applications/phame/controller/post/PhamePostPublishController.php
@@ -1,87 +1,81 @@
<?php
final class PhamePostPublishController extends PhameController {
- private $id;
-
- public function willProcessRequest(array $data) {
- $this->id = $data['id'];
- }
-
- public function processRequest() {
- $request = $this->getRequest();
+ public function handleRequest(AphrontRequest $request) {
$user = $request->getUser();
+ $id = $request->getURIData('id');
$post = id(new PhamePostQuery())
->setViewer($user)
- ->withIDs(array($this->id))
+ ->withIDs(array($id))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$post) {
return new Aphront404Response();
}
$view_uri = $this->getApplicationURI('/post/view/'.$post->getID().'/');
if ($request->isFormPost()) {
$post->setVisibility(PhamePost::VISIBILITY_PUBLISHED);
$post->setDatePublished(time());
$post->save();
return id(new AphrontRedirectResponse())->setURI($view_uri);
}
$form = id(new AphrontFormView())
->setUser($user)
->appendChild(
id(new AphrontFormSubmitControl())
->setValue(pht('Publish Post'))
->addCancelButton($view_uri));
$frame = $this->renderPreviewFrame($post);
$form_box = id(new PHUIObjectBoxView())
->setHeaderText(pht('Preview Post'))
->setForm($form);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Preview'), $view_uri);
$nav = $this->renderSideNavFilterView(null);
$nav->appendChild(
array(
$crumbs,
$form_box,
$frame,
));
return $this->buildApplicationPage(
$nav,
array(
'title' => pht('Preview Post'),
));
}
private function renderPreviewFrame(PhamePost $post) {
// TODO: Clean up this CSS.
return phutil_tag(
'div',
array(
'style' => 'text-align: center; padding: 1em;',
),
phutil_tag(
'iframe',
array(
'style' => 'width: 100%; height: 600px; '.
'border: 1px solid #303030;',
'src' => $this->getApplicationURI('/post/framed/'.$post->getID().'/'),
),
''));
}
}
diff --git a/src/applications/phame/controller/post/PhamePostUnpublishController.php b/src/applications/phame/controller/post/PhamePostUnpublishController.php
index 52c29da120..e2634e710e 100644
--- a/src/applications/phame/controller/post/PhamePostUnpublishController.php
+++ b/src/applications/phame/controller/post/PhamePostUnpublishController.php
@@ -1,52 +1,46 @@
<?php
final class PhamePostUnpublishController extends PhameController {
- private $id;
-
- public function willProcessRequest(array $data) {
- $this->id = $data['id'];
- }
-
- public function processRequest() {
- $request = $this->getRequest();
+ public function handleRequest(AphrontRequest $request) {
$user = $request->getUser();
+ $id = $request->getURIData('id');
$post = id(new PhamePostQuery())
->setViewer($user)
- ->withIDs(array($this->id))
+ ->withIDs(array($id))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$post) {
return new Aphront404Response();
}
if ($request->isFormPost()) {
$post->setVisibility(PhamePost::VISIBILITY_DRAFT);
$post->setDatePublished(0);
$post->save();
return id(new AphrontRedirectResponse())
->setURI($this->getApplicationURI('/post/view/'.$post->getID().'/'));
}
$cancel_uri = $this->getApplicationURI('/post/view/'.$post->getID().'/');
$dialog = id(new AphrontDialogView())
->setUser($user)
->setTitle(pht('Unpublish Post?'))
->appendChild(
pht(
'The post "%s" will no longer be visible to other users until you '.
'republish it.',
$post->getTitle()))
->addSubmitButton(pht('Unpublish'))
->addCancelButton($cancel_uri);
return id(new AphrontDialogResponse())->setDialog($dialog);
}
}

File Metadata

Mime Type
text/x-diff
Expires
Tue, Jun 10, 5:16 PM (1 d, 13 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
140595
Default Alt Text
(11 KB)

Event Timeline