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
|
|
|
|
2013-04-14 17:02:29 +02:00
|
|
|
$nav->addLabel(pht('Create'));
|
|
|
|
$nav->addFilter('post/new', pht('New Post'));
|
|
|
|
$nav->addFilter('blog/new', pht('New Blog'));
|
2012-10-15 23:50:12 +02:00
|
|
|
|
2013-04-14 17:02:29 +02:00
|
|
|
$nav->addLabel(pht('Posts'));
|
|
|
|
$nav->addFilter('post/draft', pht('My Drafts'));
|
|
|
|
$nav->addFilter('post', pht('My Posts'));
|
|
|
|
$nav->addFilter('post/all', pht('All Posts'));
|
2012-04-12 22:09:04 +02:00
|
|
|
|
2013-04-14 17:02:29 +02:00
|
|
|
$nav->addLabel(pht('Blogs'));
|
|
|
|
$nav->addFilter('blog/user', pht('Joinable Blogs'));
|
|
|
|
$nav->addFilter('blog/all', pht('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-20 23:48:23 +01:00
|
|
|
->setUser($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;
|
|
|
|
}
|
2013-04-14 17:02:29 +02:00
|
|
|
|
|
|
|
public function buildApplicationMenu() {
|
|
|
|
return $this->renderSideNavFilterView()->getMenu();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function buildApplicationCrumbs() {
|
|
|
|
$crumbs = parent::buildApplicationCrumbs();
|
|
|
|
$crumbs->addAction(
|
|
|
|
id(new PhabricatorMenuItemView())
|
|
|
|
->setName(pht('New Blog'))
|
|
|
|
->setHref($this->getApplicationURI('/blog/new'))
|
|
|
|
->setIcon('create'));
|
|
|
|
$crumbs->addAction(
|
|
|
|
id(new PhabricatorMenuItemView())
|
|
|
|
->setName(pht('New Post'))
|
|
|
|
->setHref($this->getApplicationURI('/post/new'))
|
|
|
|
->setIcon('new'));
|
|
|
|
return $crumbs;
|
|
|
|
}
|
2012-04-12 22:09:04 +02:00
|
|
|
}
|