2012-04-12 22:09:04 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group phame
|
|
|
|
*/
|
|
|
|
abstract class PhameController extends PhabricatorController {
|
|
|
|
|
2012-10-16 02:55:57 +02:00
|
|
|
protected function renderSideNavFilterView() {
|
2012-10-13 01:01:33 +02:00
|
|
|
|
2012-10-16 02:55:57 +02:00
|
|
|
$base_uri = new PhutilURI($this->getApplicationURI());
|
2012-04-12 22:09:04 +02:00
|
|
|
|
|
|
|
$nav = new AphrontSideNavFilterView();
|
2012-07-06 00:43:14 +02:00
|
|
|
$nav->setBaseURI($base_uri);
|
2012-10-16 02:55:57 +02:00
|
|
|
|
2012-10-15 23:50:12 +02:00
|
|
|
$nav->addLabel('Create');
|
2012-10-16 02:55:57 +02:00
|
|
|
$nav->addFilter('post/new', 'New Post');
|
|
|
|
$nav->addFilter('blog/new', 'New Blog');
|
2012-10-15 23:50:12 +02:00
|
|
|
|
|
|
|
$nav->addSpacer();
|
2012-10-16 02:55:57 +02:00
|
|
|
|
2012-10-15 23:50:12 +02:00
|
|
|
$nav->addLabel('Posts');
|
2012-10-16 02:55:57 +02:00
|
|
|
$nav->addFilter('post/draft', 'My Drafts');
|
|
|
|
$nav->addFilter('post', 'My Posts');
|
|
|
|
$nav->addFilter('post/all', 'All Posts');
|
2012-04-12 22:09:04 +02:00
|
|
|
|
2012-07-19 18:03:10 +02:00
|
|
|
$nav->addSpacer();
|
2012-10-16 02:55:57 +02:00
|
|
|
|
2012-07-19 18:03:10 +02:00
|
|
|
$nav->addLabel('Blogs');
|
2012-10-16 02:55:57 +02:00
|
|
|
$nav->addFilter('blog/user', 'Joinable Blogs');
|
|
|
|
$nav->addFilter('blog/all', 'All Blogs');
|
2012-07-19 18:03:10 +02:00
|
|
|
|
2012-10-16 02:55:57 +02:00
|
|
|
$nav->selectFilter(null);
|
2012-04-12 22:09:04 +02:00
|
|
|
|
|
|
|
return $nav;
|
|
|
|
}
|
|
|
|
|
2012-10-15 23:50:12 +02:00
|
|
|
protected function renderPostList(
|
|
|
|
array $posts,
|
|
|
|
PhabricatorUser $user,
|
|
|
|
$nodata) {
|
|
|
|
assert_instances_of($posts, 'PhamePost');
|
|
|
|
|
|
|
|
$list = id(new PhabricatorObjectItemListView())
|
|
|
|
->setNoDataString($nodata);
|
|
|
|
|
|
|
|
foreach ($posts as $post) {
|
|
|
|
$item = id(new PhabricatorObjectItemView())
|
|
|
|
->setHeader($post->getTitle())
|
2012-10-15 23:50:45 +02:00
|
|
|
->setHref($this->getApplicationURI('post/view/'.$post->getID().'/'))
|
2012-10-15 23:50:37 +02:00
|
|
|
->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));
|
|
|
|
}
|
2012-10-15 23:50:12 +02:00
|
|
|
|
|
|
|
$list->addItem($item);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $list;
|
|
|
|
}
|
2012-04-12 22:09:04 +02:00
|
|
|
}
|