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

at recaptime-dev/main 132 lines 3.5 kB view raw
1<?php 2 3final class PhameHomeController extends PhamePostController { 4 5 public function shouldAllowPublic() { 6 return true; 7 } 8 9 protected function buildApplicationCrumbs() { 10 $crumbs = parent::buildApplicationCrumbs(); 11 12 id(new PhameBlogEditEngine()) 13 ->setViewer($this->getViewer()) 14 ->addActionToCrumbs($crumbs); 15 16 return $crumbs; 17 } 18 19 public function handleRequest(AphrontRequest $request) { 20 $viewer = $request->getViewer(); 21 22 $blogs = id(new PhameBlogQuery()) 23 ->setViewer($viewer) 24 ->withStatuses(array(PhameBlog::STATUS_ACTIVE)) 25 ->needProfileImage(true) 26 ->execute(); 27 28 $post_list = null; 29 if ($blogs) { 30 $blog_phids = mpull($blogs, 'getPHID'); 31 32 $pager = id(new AphrontCursorPagerView()) 33 ->readFromRequest($request); 34 35 $posts = id(new PhamePostQuery()) 36 ->setViewer($viewer) 37 ->withBlogPHIDs($blog_phids) 38 ->withVisibility(array(PhameConstants::VISIBILITY_PUBLISHED)) 39 ->setOrder('datePublished') 40 ->executeWithCursorPager($pager); 41 42 if ($posts) { 43 $post_list = id(new PhamePostListView()) 44 ->setPosts($posts) 45 ->setViewer($viewer) 46 ->showBlog(true); 47 } else { 48 $post_list = id(new PHUIBigInfoView()) 49 ->setIcon('fa-star') 50 ->setTitle('No Visible Posts') 51 ->setDescription( 52 pht('There aren\'t any visible blog posts.')); 53 } 54 } else { 55 $create_button = id(new PHUIButtonView()) 56 ->setTag('a') 57 ->setText(pht('Create a Blog')) 58 ->setHref('/phame/blog/edit/') 59 ->setColor(PHUIButtonView::GREEN); 60 61 $post_list = id(new PHUIBigInfoView()) 62 ->setIcon('fa-star') 63 ->setTitle('Welcome to Phame') 64 ->setDescription( 65 pht('There aren\'t any visible blog posts.')) 66 ->addAction($create_button); 67 } 68 69 $view_all = id(new PHUIButtonView()) 70 ->setTag('a') 71 ->setText(pht('View All')) 72 ->setHref($this->getApplicationURI('post/')) 73 ->setIcon('fa-list-ul'); 74 75 $title = pht('Recent Posts'); 76 77 $header = id(new PHUIHeaderView()) 78 ->setHeader($title) 79 ->addActionLink($view_all); 80 81 $crumbs = $this->buildApplicationCrumbs(); 82 $crumbs->setBorder(true); 83 $crumbs->addTextCrumb( 84 pht('Recent Posts'), 85 $this->getApplicationURI('post/')); 86 87 $page = id(new PHUIDocumentView()) 88 ->setHeader($header) 89 ->appendChild($post_list); 90 91 $blog_list = id(new PhameBlogListView()) 92 ->setBlogs($blogs) 93 ->setViewer($viewer); 94 95 $draft_list = null; 96 if ($viewer->isLoggedIn() && $blogs) { 97 $drafts = id(new PhamePostQuery()) 98 ->setViewer($viewer) 99 ->withBloggerPHIDs(array($viewer->getPHID())) 100 ->withBlogPHIDs(mpull($blogs, 'getPHID')) 101 ->withVisibility(array(PhameConstants::VISIBILITY_DRAFT)) 102 ->setLimit(5) 103 ->execute(); 104 105 $draft_list = id(new PhameDraftListView()) 106 ->setPosts($drafts) 107 ->setBlogs($blogs) 108 ->setViewer($viewer); 109 } 110 111 $phame_view = id(new PHUITwoColumnView()) 112 ->setMainColumn(array( 113 $page, 114 )) 115 ->setSideColumn(array( 116 $blog_list, 117 $draft_list, 118 )) 119 ->addClass('phame-home-container'); 120 121 $phame_home = phutil_tag_div('phame-home-view', $phame_view); 122 123 return $this->newPage() 124 ->setTitle($title) 125 ->setCrumbs($crumbs) 126 ->appendChild( 127 array( 128 $phame_home, 129 )); 130 } 131 132}