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())
|
2012-12-13 19:59:29 +01:00
|
|
|
->setViewer($user)
|
2012-10-15 23:50:12 +02:00
|
|
|
->setNoDataString($nodata);
|
|
|
|
|
|
|
|
foreach ($posts as $post) {
|
2012-12-13 19:59:29 +01:00
|
|
|
$blogger = $this->getHandle($post->getBloggerPHID())->renderLink();
|
|
|
|
|
|
|
|
$blog = null;
|
|
|
|
if ($post->getBlog()) {
|
|
|
|
$blog = $this->getHandle($post->getBlog()->getPHID())->renderLink();
|
|
|
|
}
|
|
|
|
|
|
|
|
$published = null;
|
|
|
|
if ($post->getDatePublished()) {
|
|
|
|
$published = phabricator_date($post->getDatePublished(), $user);
|
|
|
|
}
|
|
|
|
|
|
|
|
$draft = $post->isDraft();
|
|
|
|
|
2012-10-15 23:50:12 +02:00
|
|
|
$item = id(new PhabricatorObjectItemView())
|
2012-12-13 19:59:29 +01:00
|
|
|
->setObject($post)
|
2012-10-15 23:50:12 +02:00
|
|
|
->setHeader($post->getTitle())
|
2012-12-13 19:59:29 +01:00
|
|
|
->setHref($this->getApplicationURI('post/view/'.$post->getID().'/'));
|
|
|
|
|
|
|
|
if ($blog) {
|
|
|
|
$item->addAttribute($blog);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($draft) {
|
|
|
|
$desc = pht('Draft by %s', $blogger);
|
2012-10-15 23:50:37 +02:00
|
|
|
} else {
|
2012-12-13 19:59:29 +01:00
|
|
|
$desc = pht('Published on %s by %s', $published, $blogger);
|
2012-10-15 23:50:37 +02:00
|
|
|
}
|
2012-12-13 19:59:29 +01:00
|
|
|
$item->addAttribute($desc);
|
2012-10-15 23:50:12 +02:00
|
|
|
|
|
|
|
$list->addItem($item);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $list;
|
|
|
|
}
|
2012-04-12 22:09:04 +02:00
|
|
|
}
|