@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
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add Drafts to PhameHome

Summary: Adds a list of your drafts. Fixes T9927y

Test Plan:
Load up home, see my drafts. Fake 0 drafts, see fallback message.

{F1023139}

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D14756

+122 -5
+2
src/__phutil_library_map__.php
··· 3341 3341 'PhameCreatePostConduitAPIMethod' => 'applications/phame/conduit/PhameCreatePostConduitAPIMethod.php', 3342 3342 'PhameDAO' => 'applications/phame/storage/PhameDAO.php', 3343 3343 'PhameDescriptionView' => 'applications/phame/view/PhameDescriptionView.php', 3344 + 'PhameDraftListView' => 'applications/phame/view/PhameDraftListView.php', 3344 3345 'PhameHomeController' => 'applications/phame/controller/PhameHomeController.php', 3345 3346 'PhameLiveController' => 'applications/phame/controller/PhameLiveController.php', 3346 3347 'PhamePost' => 'applications/phame/storage/PhamePost.php', ··· 7691 7692 'PhameCreatePostConduitAPIMethod' => 'PhameConduitAPIMethod', 7692 7693 'PhameDAO' => 'PhabricatorLiskDAO', 7693 7694 'PhameDescriptionView' => 'AphrontTagView', 7695 + 'PhameDraftListView' => 'AphrontTagView', 7694 7696 'PhameHomeController' => 'PhamePostController', 7695 7697 'PhameLiveController' => 'PhameController', 7696 7698 'PhamePost' => array(
+21 -2
src/applications/phame/controller/PhameHomeController.php
··· 57 57 ->setHeader($header) 58 58 ->appendChild($post_list); 59 59 60 - $sidebar = id(new PhameBlogListView()) 60 + $blog_list = id(new PhameBlogListView()) 61 61 ->setBlogs($blogs) 62 62 ->setViewer($viewer); 63 63 64 + $draft_list = null; 65 + if ($viewer->isLoggedIn()) { 66 + $drafts = id(new PhamePostQuery()) 67 + ->setViewer($viewer) 68 + ->withBloggerPHIDs(array($viewer->getPHID())) 69 + ->withBlogPHIDs(mpull($blogs, 'getPHID')) 70 + ->withVisibility(PhameConstants::VISIBILITY_DRAFT) 71 + ->setLimit(5) 72 + ->execute(); 73 + 74 + $draft_list = id(new PhameDraftListView()) 75 + ->setPosts($drafts) 76 + ->setBlogs($blogs) 77 + ->setViewer($viewer); 78 + } 79 + 64 80 $phame_view = id(new PHUITwoColumnView()) 65 81 ->setMainColumn(array( 66 82 $page, 67 83 )) 68 - ->setSideColumn($sidebar) 84 + ->setSideColumn(array( 85 + $blog_list, 86 + $draft_list, 87 + )) 69 88 ->setDisplay(PHUITwoColumnView::DISPLAY_LEFT) 70 89 ->addClass('phame-home-view'); 71 90
+1
src/applications/phame/query/PhamePostQuery.php
··· 68 68 $blog_phids = mpull($posts, 'getBlogPHID'); 69 69 $blogs = id(new PhameBlogQuery()) 70 70 ->setViewer($this->getViewer()) 71 + ->needProfileImage(true) 71 72 ->withPHIDs($blog_phids) 72 73 ->execute(); 73 74 $blogs = mpull($blogs, null, 'getPHID');
-3
src/applications/phame/view/PhameBlogListView.php
··· 24 24 25 25 protected function getTagContent() { 26 26 require_celerity_resource('phame-css'); 27 - Javelin::initBehavior('phabricator-tooltips'); 28 27 29 28 $list = array(); 30 29 foreach ($this->blogs as $blog) { ··· 54 53 array( 55 54 'href' => '/phame/post/edit/?blog='.$blog->getID(), 56 55 'class' => 'phame-blog-list-new-post', 57 - 'sigil' => 'has-tooltip', 58 - 'meta' => array('tip' => pht('New Post')), 59 56 ), 60 57 $icon); 61 58
+98
src/applications/phame/view/PhameDraftListView.php
··· 1 + <?php 2 + 3 + final class PhameDraftListView extends AphrontTagView { 4 + 5 + private $posts; 6 + private $blogs; 7 + private $viewer; 8 + 9 + public function setPosts($posts) { 10 + assert_instances_of($posts, 'PhamePost'); 11 + $this->posts = $posts; 12 + return $this; 13 + } 14 + 15 + public function setBlogs($blogs) { 16 + assert_instances_of($blogs, 'PhameBlog'); 17 + $this->blogs = $blogs; 18 + return $this; 19 + } 20 + 21 + public function setViewer($viewer) { 22 + $this->viewer = $viewer; 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 + ->setIconFont('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 array($header, $list); 96 + } 97 + 98 + }