@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhameDraftListView extends AphrontTagView {
4
5 private $posts;
6 private $blogs;
7
8 /**
9 * @param array<PhamePost> $posts
10 */
11 public function setPosts($posts) {
12 assert_instances_of($posts, PhamePost::class);
13 $this->posts = $posts;
14 return $this;
15 }
16
17 /**
18 * @param array<PhameBlog> $blogs
19 */
20 public function setBlogs($blogs) {
21 assert_instances_of($blogs, PhameBlog::class);
22 $this->blogs = $blogs;
23 return $this;
24 }
25
26 protected function getTagAttributes() {
27 $classes = array();
28 $classes[] = 'phame-blog-list';
29 return array('class' => implode(' ', $classes));
30 }
31
32 protected function getTagContent() {
33 require_celerity_resource('phame-css');
34
35 $list = array();
36 foreach ($this->posts as $post) {
37 $blog = $post->getBlog();
38 $image_uri = $blog->getProfileImageURI();
39 $image = phutil_tag(
40 'a',
41 array(
42 'class' => 'phame-blog-list-image',
43 'style' => 'background-image: url('.$image_uri.');',
44 'href' => $blog->getViewURI(),
45 ));
46
47 $title = phutil_tag(
48 'a',
49 array(
50 'class' => 'phame-blog-list-title',
51 'href' => $post->getViewURI(),
52 ),
53 $post->getTitle());
54
55 $icon = id(new PHUIIconView())
56 ->setIcon('fa-pencil-square-o')
57 ->addClass('phame-blog-list-icon');
58
59 $edit = phutil_tag(
60 'a',
61 array(
62 'href' => '/phame/post/edit/'.$post->getID().'/',
63 'class' => 'phame-blog-list-new-post',
64 ),
65 $icon);
66
67 $list[] = phutil_tag(
68 'div',
69 array(
70 'class' => 'phame-blog-list-item',
71 ),
72 array(
73 $image,
74 $title,
75 $edit,
76 ));
77 }
78
79 if (empty($list)) {
80 $list = pht('You have no draft posts.');
81 }
82
83 $header = phutil_tag(
84 'h4',
85 array(
86 'class' => 'phame-blog-list-header',
87 ),
88 phutil_tag(
89 'a',
90 array(
91 'href' => '/phame/post/query/draft/',
92 ),
93 pht('Drafts')));
94
95 return id(new PHUIBoxView())
96 ->appendChild($header)
97 ->appendChild($list)
98 ->addClass('pl')
99 ->setColor(PHUIBoxView::BLUE);
100 }
101
102}