1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-29 18:22:41 +01:00

Modernize Phame post lists

Summary:
Use device UI for all post lists.

Left menu is a bit wonky but I'll clean that up shortly.

Test Plan: Will add screenshots.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1373

Differential Revision: https://secure.phabricator.com/D3696
This commit is contained in:
epriestley 2012-10-15 14:50:37 -07:00
parent b072e937b5
commit c37202dd48
11 changed files with 143 additions and 434 deletions

View file

@ -1147,7 +1147,6 @@ phutil_register_library_map(array(
'PhabricatorXHProfSample' => 'applications/xhprof/storage/PhabricatorXHProfSample.php', 'PhabricatorXHProfSample' => 'applications/xhprof/storage/PhabricatorXHProfSample.php',
'PhabricatorXHProfSampleListController' => 'applications/xhprof/controller/PhabricatorXHProfSampleListController.php', 'PhabricatorXHProfSampleListController' => 'applications/xhprof/controller/PhabricatorXHProfSampleListController.php',
'PhabricatorXHProfSampleListView' => 'applications/xhprof/view/PhabricatorXHProfSampleListView.php', 'PhabricatorXHProfSampleListView' => 'applications/xhprof/view/PhabricatorXHProfSampleListView.php',
'PhameAllPostListController' => 'applications/phame/controller/post/list/PhameAllPostListController.php',
'PhameBlog' => 'applications/phame/storage/PhameBlog.php', 'PhameBlog' => 'applications/phame/storage/PhameBlog.php',
'PhameBlogDeleteController' => 'applications/phame/controller/blog/PhameBlogDeleteController.php', 'PhameBlogDeleteController' => 'applications/phame/controller/blog/PhameBlogDeleteController.php',
'PhameBlogDetailView' => 'applications/phame/view/PhameBlogDetailView.php', 'PhameBlogDetailView' => 'applications/phame/view/PhameBlogDetailView.php',
@ -1157,20 +1156,17 @@ phutil_register_library_map(array(
'PhameBlogQuery' => 'applications/phame/query/PhameBlogQuery.php', 'PhameBlogQuery' => 'applications/phame/query/PhameBlogQuery.php',
'PhameBlogSkin' => 'applications/phame/view/skins/PhameBlogSkin.php', 'PhameBlogSkin' => 'applications/phame/view/skins/PhameBlogSkin.php',
'PhameBlogViewController' => 'applications/phame/controller/blog/PhameBlogViewController.php', 'PhameBlogViewController' => 'applications/phame/controller/blog/PhameBlogViewController.php',
'PhameBloggerPostListController' => 'applications/phame/controller/post/list/PhameBloggerPostListController.php',
'PhameController' => 'applications/phame/controller/PhameController.php', 'PhameController' => 'applications/phame/controller/PhameController.php',
'PhameDAO' => 'applications/phame/storage/PhameDAO.php', 'PhameDAO' => 'applications/phame/storage/PhameDAO.php',
'PhameDraftListController' => 'applications/phame/controller/post/list/PhameDraftListController.php',
'PhamePost' => 'applications/phame/storage/PhamePost.php', 'PhamePost' => 'applications/phame/storage/PhamePost.php',
'PhamePostDeleteController' => 'applications/phame/controller/post/PhamePostDeleteController.php', 'PhamePostDeleteController' => 'applications/phame/controller/post/PhamePostDeleteController.php',
'PhamePostDetailView' => 'applications/phame/view/PhamePostDetailView.php', 'PhamePostDetailView' => 'applications/phame/view/PhamePostDetailView.php',
'PhamePostEditController' => 'applications/phame/controller/post/PhamePostEditController.php', 'PhamePostEditController' => 'applications/phame/controller/post/PhamePostEditController.php',
'PhamePostListBaseController' => 'applications/phame/controller/post/list/PhamePostListBaseController.php', 'PhamePostListController' => 'applications/phame/controller/post/PhamePostListController.php',
'PhamePostListView' => 'applications/phame/view/PhamePostListView.php', 'PhamePostListView' => 'applications/phame/view/PhamePostListView.php',
'PhamePostPreviewController' => 'applications/phame/controller/post/PhamePostPreviewController.php', 'PhamePostPreviewController' => 'applications/phame/controller/post/PhamePostPreviewController.php',
'PhamePostQuery' => 'applications/phame/query/PhamePostQuery.php', 'PhamePostQuery' => 'applications/phame/query/PhamePostQuery.php',
'PhamePostViewController' => 'applications/phame/controller/post/PhamePostViewController.php', 'PhamePostViewController' => 'applications/phame/controller/post/PhamePostViewController.php',
'PhameUserPostListController' => 'applications/phame/controller/post/list/PhameUserPostListController.php',
'PhortuneMonthYearExpiryControl' => 'applications/phortune/control/PhortuneMonthYearExpiryControl.php', 'PhortuneMonthYearExpiryControl' => 'applications/phortune/control/PhortuneMonthYearExpiryControl.php',
'PhortuneStripeBaseController' => 'applications/phortune/stripe/controller/PhortuneStripeBaseController.php', 'PhortuneStripeBaseController' => 'applications/phortune/stripe/controller/PhortuneStripeBaseController.php',
'PhortuneStripePaymentFormView' => 'applications/phortune/stripe/view/PhortuneStripePaymentFormView.php', 'PhortuneStripePaymentFormView' => 'applications/phortune/stripe/view/PhortuneStripePaymentFormView.php',
@ -2272,7 +2268,6 @@ phutil_register_library_map(array(
'PhabricatorXHProfSample' => 'PhabricatorXHProfDAO', 'PhabricatorXHProfSample' => 'PhabricatorXHProfDAO',
'PhabricatorXHProfSampleListController' => 'PhabricatorXHProfController', 'PhabricatorXHProfSampleListController' => 'PhabricatorXHProfController',
'PhabricatorXHProfSampleListView' => 'AphrontView', 'PhabricatorXHProfSampleListView' => 'AphrontView',
'PhameAllPostListController' => 'PhamePostListBaseController',
'PhameBlog' => 'PhameBlog' =>
array( array(
0 => 'PhameDAO', 0 => 'PhameDAO',
@ -2286,10 +2281,8 @@ phutil_register_library_map(array(
'PhameBlogQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhameBlogQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhameBlogSkin' => 'AphrontView', 'PhameBlogSkin' => 'AphrontView',
'PhameBlogViewController' => 'PhameController', 'PhameBlogViewController' => 'PhameController',
'PhameBloggerPostListController' => 'PhamePostListBaseController',
'PhameController' => 'PhabricatorController', 'PhameController' => 'PhabricatorController',
'PhameDAO' => 'PhabricatorLiskDAO', 'PhameDAO' => 'PhabricatorLiskDAO',
'PhameDraftListController' => 'PhamePostListBaseController',
'PhamePost' => 'PhamePost' =>
array( array(
0 => 'PhameDAO', 0 => 'PhameDAO',
@ -2298,12 +2291,11 @@ phutil_register_library_map(array(
'PhamePostDeleteController' => 'PhameController', 'PhamePostDeleteController' => 'PhameController',
'PhamePostDetailView' => 'AphrontView', 'PhamePostDetailView' => 'AphrontView',
'PhamePostEditController' => 'PhameController', 'PhamePostEditController' => 'PhameController',
'PhamePostListBaseController' => 'PhameController', 'PhamePostListController' => 'PhameController',
'PhamePostListView' => 'AphrontView', 'PhamePostListView' => 'AphrontView',
'PhamePostPreviewController' => 'PhameController', 'PhamePostPreviewController' => 'PhameController',
'PhamePostQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhamePostQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhamePostViewController' => 'PhameController', 'PhamePostViewController' => 'PhameController',
'PhameUserPostListController' => 'PhamePostListBaseController',
'PhortuneMonthYearExpiryControl' => 'AphrontFormControl', 'PhortuneMonthYearExpiryControl' => 'AphrontFormControl',
'PhortuneStripeBaseController' => 'PhabricatorController', 'PhortuneStripeBaseController' => 'PhabricatorController',
'PhortuneStripePaymentFormView' => 'AphrontView', 'PhortuneStripePaymentFormView' => 'AphrontView',

View file

@ -45,21 +45,18 @@ final class PhabricatorApplicationPhame extends PhabricatorApplication {
public function getRoutes() { public function getRoutes() {
return array( return array(
'/phame/' => array( '/phame/' => array(
'' => 'PhameAllPostListController', '' => 'PhamePostListController',
'post/' => array( 'post/' => array(
'' => 'PhameUserPostListController', '(?:(?P<filter>draft|all)/)?' => 'PhamePostListController',
'blogger/(?P<bloggername>[\w\.-_]+)/' => 'PhamePostListController',
'delete/(?P<phid>[^/]+)/' => 'PhamePostDeleteController', 'delete/(?P<phid>[^/]+)/' => 'PhamePostDeleteController',
'edit/(?P<phid>[^/]+)/' => 'PhamePostEditController', 'edit/(?P<phid>[^/]+)/' => 'PhamePostEditController',
'new/' => 'PhamePostEditController', 'new/' => 'PhamePostEditController',
'preview/' => 'PhamePostPreviewController', 'preview/' => 'PhamePostPreviewController',
'view/(?P<phid>[^/]+)/' => 'PhamePostViewController', 'view/(?P<phid>[^/]+)/' => 'PhamePostViewController',
), ),
'draft/' => array(
'' => 'PhameDraftListController',
'new/' => 'PhamePostEditController',
),
'blog/(?:(?P<filter>user|all)/)?' => 'PhameBlogListController',
'blog/' => array( 'blog/' => array(
'(?:(?P<filter>user|all)/)?' => 'PhameBlogListController',
'delete/(?P<id>[^/]+)/' => 'PhameBlogDeleteController', 'delete/(?P<id>[^/]+)/' => 'PhameBlogDeleteController',
'edit/(?P<id>[^/]+)/' => 'PhameBlogEditController', 'edit/(?P<id>[^/]+)/' => 'PhameBlogEditController',
'view/(?P<id>[^/]+)/' => 'PhameBlogViewController', 'view/(?P<id>[^/]+)/' => 'PhameBlogViewController',
@ -67,8 +64,6 @@ final class PhabricatorApplicationPhame extends PhabricatorApplication {
'new/' => 'PhameBlogEditController', 'new/' => 'PhameBlogEditController',
), ),
'posts/' => array( 'posts/' => array(
'' => 'PhameUserPostListController',
'(?P<bloggername>\w+)/' => 'PhameBloggerPostListController',
'(?P<bloggername>\w+)/(?P<phametitle>.+/)' '(?P<bloggername>\w+)/(?P<phametitle>.+/)'
=> 'PhamePostViewController', => 'PhamePostViewController',
), ),

View file

@ -81,18 +81,15 @@ abstract class PhameController extends PhabricatorController {
$nav->addSpacer(); $nav->addSpacer();
$nav->addLabel('Posts'); $nav->addLabel('Posts');
$nav->addFilter('draft', $nav->addFilter('post/draft',
'My Drafts'); 'My Drafts');
foreach ($this->getSideNavExtraDraftFilters() as $draft_filter) { foreach ($this->getSideNavExtraDraftFilters() as $draft_filter) {
$nav->addFilter($draft_filter['key'], $nav->addFilter($draft_filter['key'],
$draft_filter['name'], $draft_filter['name'],
idx($draft_filter, 'uri')); idx($draft_filter, 'uri'));
} }
$nav->addFilter('post', $nav->addFilter('post/', 'My Posts');
'My Posts'); $nav->addFilter('post/all', 'All Posts');
$nav->addFilter('post/all',
'All Posts',
$base_uri);
foreach ($this->getSideNavExtraPostFilters() as $post_filter) { foreach ($this->getSideNavExtraPostFilters() as $post_filter) {
$nav->addFilter($post_filter['key'], $nav->addFilter($post_filter['key'],
$post_filter['name'], $post_filter['name'],
@ -167,7 +164,24 @@ abstract class PhameController extends PhabricatorController {
foreach ($posts as $post) { foreach ($posts as $post) {
$item = id(new PhabricatorObjectItemView()) $item = id(new PhabricatorObjectItemView())
->setHeader($post->getTitle()) ->setHeader($post->getTitle())
->setHref($this->getApplicationURI('post/view/'.$post->getPHID())); ->setHref($this->getApplicationURI('post/view/'.$post->getPHID()))
->addDetail(
pht('Blogger'),
$this->getHandle($post->getBloggerPHID())->renderLink())
->addDetail(
pht('Blog'),
$post->getBlog()
? $this->getHandle($post->getBlog()->getPHID())->renderLink()
: '-');
if ($post->isDraft()) {
$item->addAttribute(pht('Draft'));
} else {
$date_published = phabricator_datetime(
$post->getDatePublished(),
$user);
$item->addAttribute(pht('Published on %s', $date_published));
}
$list->addItem($item); $list->addItem($item);
} }

View file

@ -65,6 +65,11 @@ final class PhameBlogViewController extends PhameController {
$header = id(new PhabricatorHeaderView()) $header = id(new PhabricatorHeaderView())
->setHeader($blog->getName()); ->setHeader($blog->getName());
$handle_phids = array_merge(
mpull($posts, 'getBloggerPHID'),
mpull($posts, 'getBlogPHID'));
$this->loadHandles($handle_phids);
$actions = $this->renderActions($blog, $user); $actions = $this->renderActions($blog, $user);
$properties = $this->renderProperties($blog, $user); $properties = $this->renderProperties($blog, $user);
$post_list = $this->renderPostList( $post_list = $this->renderPostList(

View file

@ -0,0 +1,105 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @group phame
*/
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();
$query = id(new PhamePostQuery())
->setViewer($user);
switch ($this->filter) {
case 'draft':
$query->withBloggerPHIDs(array($user->getPHID()));
$query->withVisibility(PhamePost::VISIBILITY_DRAFT);
$nodata = pht('You have no unpublished drafts.');
$title = pht('Unpublished Drafts');
break;
case 'blogger':
if ($this->bloggername) {
$blogger = id(new PhabricatorUser())->loadOneWhere(
'username = %s',
$this->bloggername);
if (!$blogger) {
return new Aphront404Response();
}
} else {
$blogger = $user;
}
$query->withBloggerPHIDs(array($blogger->getPHID()));
if ($blogger->getPHID() == $user->getPHID()) {
$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');
break;
default:
throw new Exception("Unknown filter '{$this->filter}'!");
}
$pager = id(new AphrontCursorPagerView())
->readFromRequest($request);
$posts = $query->executeWithCursorPager($pager);
$handle_phids = array_merge(
mpull($posts, 'getBloggerPHID'),
mpull($posts, 'getBlogPHID'));
$this->loadHandles($handle_phids);
$header = id(new PhabricatorHeaderView())
->setHeader($title);
$post_list = $this->renderPostList($posts, $user, $nodata);
$nav = $this->renderSideNavFilterView(null);
$nav->appendChild(
array(
$header,
$post_list,
));
return $this->buildApplicationPage(
$nav,
array(
'title' => $title,
'device' => true,
));
}
}

View file

@ -1,93 +0,0 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @group phame
*/
final class PhameAllPostListController
extends PhamePostListBaseController {
public function shouldRequireLogin() {
return true;
}
protected function getSideNavFilter() {
return 'post/all';
}
protected function getNoticeView() {
$user = $this->getRequest()->getUser();
$new_link = phutil_render_tag(
'a',
array(
'href' => '/phame/post/new/',
'class' => 'button green',
),
'write a blog post'
);
$remarkup_link = phutil_render_tag(
'a',
array(
'href' =>
PhabricatorEnv::getDoclink('article/Remarkup_Reference.html'),
),
'remarkup'
);
$guide_link = phutil_render_tag(
'a',
array(
'href' => PhabricatorEnv::getDoclink('article/Phame_User_Guide.html'),
),
'Phame user guide'
);
$notices = array(
'Seek phame and '.$new_link,
'Use '.$remarkup_link.' for maximal elegance, grace, and style. ',
'If you need more help try the '.$guide_link.'.',
);
$notice_view = $this->buildNoticeView();
foreach ($notices as $notice) {
$notice_view->appendChild('<p>'.$notice.'</p>');
}
return $notice_view;
}
public function processRequest() {
$user = $this->getRequest()->getUser();
$query = id(new PhamePostQuery())
->setViewer($user);
$this->setPhamePostQuery($query);
$this->setActions(array());
$page_title = 'All Posts';
$this->setPageTitle($page_title);
$this->setShowSideNav(true);
return $this->buildPostListPageResponse();
}
}

View file

@ -1,75 +0,0 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @group phame
*/
final class PhameBloggerPostListController
extends PhamePostListBaseController {
private $bloggerName;
private function setBloggerName($blogger_name) {
$this->bloggerName = $blogger_name;
return $this;
}
private function getBloggerName() {
return $this->bloggerName;
}
public function shouldRequireLogin() {
// TODO -- get policy logic going
// return PhabricatorEnv::getEnvConfig('policy.allow-public');
return true;
}
public function willProcessRequest(array $data) {
$this->setBloggerName(idx($data, 'bloggername'));
}
public function processRequest() {
$user = $this->getRequest()->getUser();
$blogger = id(new PhabricatorUser())->loadOneWhere(
'username = %s',
$this->getBloggerName());
if (!$blogger) {
return new Aphront404Response();
}
$blogger_phid = $blogger->getPHID();
if ($blogger_phid == $user->getPHID()) {
$actions = array('view', 'edit');
} else {
$actions = array('view');
}
$this->setActions($actions);
$query = id(new PhamePostQuery())
->setViewer($user)
->withBloggerPHIDs(array($blogger_phid));
$this->setPhamePostQuery($query);
$page_title = 'Posts by '.$this->getBloggerName();
$this->setPageTitle($page_title);
$this->setShowSideNav(false);
return $this->buildPostListPageResponse();
}
}

View file

@ -1,70 +0,0 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @group phame
*/
final class PhameDraftListController
extends PhamePostListBaseController {
public function shouldRequireLogin() {
return true;
}
protected function getSideNavFilter() {
return 'draft';
}
protected function isDraft() {
return true;
}
protected function getNoticeView() {
$request = $this->getRequest();
if ($request->getExists('deleted')) {
$notice_view = $this->buildNoticeView()
->appendChild('Deleted draft successfully.');
} else {
$notice_view = null;
}
return $notice_view;
}
public function processRequest() {
$user = $this->getRequest()->getUser();
$phid = $user->getPHID();
$query = id(new PhamePostQuery())
->setViewer($user)
->withBloggerPHIDs(array($phid))
->withVisibility(PhamePost::VISIBILITY_DRAFT);
$this->setPhamePostQuery($query);
$actions = array('view', 'edit');
$this->setActions($actions);
$this->setPageTitle('My Drafts');
$this->setShowSideNav(true);
return $this->buildPostListPageResponse();
}
}

View file

@ -1,99 +0,0 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @group phame
*/
abstract class PhamePostListBaseController
extends PhameController {
private $phamePostQuery;
private $actions;
private $pageTitle;
protected function setPageTitle($page_title) {
$this->pageTitle = $page_title;
return $this;
}
private function getPageTitle() {
return $this->pageTitle;
}
protected function setActions($actions) {
$this->actions = $actions;
return $this;
}
private function getActions() {
return $this->actions;
}
protected function setPhamePostQuery(PhamePostQuery $query) {
$this->phamePostQuery = $query;
return $this;
}
private function getPhamePostQuery() {
return $this->phamePostQuery;
}
protected function isDraft() {
return false;
}
protected function getNoticeView() {
return null;
}
private function loadBloggersFromPosts(array $posts) {
assert_instances_of($posts, 'PhamePost');
if (empty($posts)) {
return array();
}
$blogger_phids = mpull($posts, 'getBloggerPHID', 'getBloggerPHID');
return
$this->loadViewerHandles($blogger_phids);
}
protected function buildPostListPageResponse() {
$request = $this->getRequest();
$pager = $this->getPager();
$query = $this->getPhamePostQuery();
$posts = $query->executeWithOffsetPager($pager);
$bloggers = $this->loadBloggersFromPosts($posts);
$panel = id(new PhamePostListView())
->setUser($this->getRequest()->getUser())
->setBloggers($bloggers)
->setPosts($posts)
->setActions($this->getActions())
->setRequestURI($request->getRequestURI())
->setDraftList($this->isDraft());
return $this->buildStandardPageResponse(
array(
$this->getNoticeView(),
$panel,
$pager
),
array(
'title' => $this->getPageTitle(),
));
}
}

View file

@ -1,65 +0,0 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @group phame
*/
final class PhameUserPostListController
extends PhamePostListBaseController {
public function shouldRequireLogin() {
return true;
}
protected function getSideNavFilter() {
return 'post';
}
protected function getNoticeView() {
$request = $this->getRequest();
if ($request->getExists('deleted')) {
$notice_view = $this->buildNoticeView()
->appendChild('Deleted post successfully.');
} else {
$notice_view = null;
}
return $notice_view;
}
public function processRequest() {
$user = $this->getRequest()->getUser();
$phid = $user->getPHID();
$query = id(new PhamePostQuery())
->setViewer($user)
->withBloggerPHIDs(array($phid));
$this->setPhamePostQuery($query);
$actions = array('view', 'edit');
$this->setActions($actions);
$this->setPageTitle('My Posts');
$this->setShowSideNav(true);
return $this->buildPostListPageResponse();
}
}

View file

@ -77,7 +77,7 @@ final class PhamePostQuery extends PhabricatorCursorPagedPolicyAwareQuery {
->setViewer($this->getViewer()) ->setViewer($this->getViewer())
->withPHIDs($blog_phids) ->withPHIDs($blog_phids)
->execute(); ->execute();
$blogs = mpull($blogs, 'getPHID'); $blogs = mpull($blogs, null, 'getPHID');
foreach ($posts as $post) { foreach ($posts as $post) {
if (isset($blogs[$post->getBlogPHID()])) { if (isset($blogs[$post->getBlogPHID()])) {
$post->setBlog($blogs[$post->getBlogPHID()]); $post->setBlog($blogs[$post->getBlogPHID()]);