Give Phame blogs mutable interact policies
[phabricator.git] / src / applications / phame / view / PhameDraftListView.php
blob294eeb11bc5fe1d2c04046913f70d92802069e55
1 <?php
3 final class PhameDraftListView extends AphrontTagView {
5 private $posts;
6 private $blogs;
8 public function setPosts($posts) {
9 assert_instances_of($posts, 'PhamePost');
10 $this->posts = $posts;
11 return $this;
14 public function setBlogs($blogs) {
15 assert_instances_of($blogs, 'PhameBlog');
16 $this->blogs = $blogs;
17 return $this;
20 protected function getTagAttributes() {
21 $classes = array();
22 $classes[] = 'phame-blog-list';
23 return array('class' => implode(' ', $classes));
26 protected function getTagContent() {
27 require_celerity_resource('phame-css');
29 $list = array();
30 foreach ($this->posts as $post) {
31 $blog = $post->getBlog();
32 $image_uri = $blog->getProfileImageURI();
33 $image = phutil_tag(
34 'a',
35 array(
36 'class' => 'phame-blog-list-image',
37 'style' => 'background-image: url('.$image_uri.');',
38 'href' => $blog->getViewURI(),
39 ));
41 $title = phutil_tag(
42 'a',
43 array(
44 'class' => 'phame-blog-list-title',
45 'href' => $post->getViewURI(),
47 $post->getTitle());
49 $icon = id(new PHUIIconView())
50 ->setIcon('fa-pencil-square-o')
51 ->addClass('phame-blog-list-icon');
53 $edit = phutil_tag(
54 'a',
55 array(
56 'href' => '/phame/post/edit/'.$post->getID().'/',
57 'class' => 'phame-blog-list-new-post',
59 $icon);
61 $list[] = phutil_tag(
62 'div',
63 array(
64 'class' => 'phame-blog-list-item',
66 array(
67 $image,
68 $title,
69 $edit,
70 ));
73 if (empty($list)) {
74 $list = pht('You have no draft posts.');
77 $header = phutil_tag(
78 'h4',
79 array(
80 'class' => 'phame-blog-list-header',
82 phutil_tag(
83 'a',
84 array(
85 'href' => '/phame/post/query/draft/',
87 pht('Drafts')));
89 return id(new PHUIBoxView())
90 ->appendChild($header)
91 ->appendChild($list)
92 ->addClass('pl')
93 ->setColor(PHUIBoxView::BLUE);