Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phame/controller/PhameHomeController.php
| <?php | <?php | ||||
| final class PhameHomeController extends PhamePostController { | final class PhameHomeController extends PhamePostController { | ||||
| public function shouldAllowPublic() { | public function shouldAllowPublic() { | ||||
| return true; | return true; | ||||
| } | } | ||||
| public function handleRequest(AphrontRequest $request) { | public function handleRequest(AphrontRequest $request) { | ||||
| $viewer = $request->getViewer(); | $viewer = $request->getViewer(); | ||||
| $blogs = id(new PhameBlogQuery()) | $blogs = id(new PhameBlogQuery()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->withStatuses(array(PhameBlog::STATUS_ACTIVE)) | ->withStatuses(array(PhameBlog::STATUS_ACTIVE)) | ||||
| ->needProfileImage(true) | |||||
| ->execute(); | ->execute(); | ||||
| $blog_phids = mpull($blogs, 'getPHID'); | $blog_phids = mpull($blogs, 'getPHID'); | ||||
| $pager = id(new AphrontCursorPagerView()) | $pager = id(new AphrontCursorPagerView()) | ||||
| ->readFromRequest($request); | ->readFromRequest($request); | ||||
| $posts = id(new PhamePostQuery()) | $posts = id(new PhamePostQuery()) | ||||
| Show All 28 Lines | public function handleRequest(AphrontRequest $request) { | ||||
| $crumbs->addTextCrumb( | $crumbs->addTextCrumb( | ||||
| pht('Recent Posts'), | pht('Recent Posts'), | ||||
| $this->getApplicationURI('post/')); | $this->getApplicationURI('post/')); | ||||
| $page = id(new PHUIDocumentViewPro()) | $page = id(new PHUIDocumentViewPro()) | ||||
| ->setHeader($header) | ->setHeader($header) | ||||
| ->appendChild($post_list); | ->appendChild($post_list); | ||||
| $sidebar = id(new PhameBlogListView()) | |||||
| ->setBlogs($blogs) | |||||
| ->setViewer($viewer); | |||||
| $phame_view = id(new PHUITwoColumnView()) | |||||
| ->setMainColumn(array( | |||||
| $page, | |||||
| )) | |||||
| ->setSideColumn($sidebar) | |||||
| ->setDisplay(PHUITwoColumnView::DISPLAY_LEFT) | |||||
| ->addClass('phame-home-view'); | |||||
| return $this->newPage() | return $this->newPage() | ||||
| ->setTitle($title) | ->setTitle($title) | ||||
| ->setCrumbs($crumbs) | ->setCrumbs($crumbs) | ||||
| ->appendChild( | ->appendChild( | ||||
| array( | array( | ||||
| $page, | $phame_view, | ||||
| )); | )); | ||||
| } | } | ||||
| private function renderActions($viewer) { | private function renderActions($viewer) { | ||||
| $actions = id(new PhabricatorActionListView()) | $actions = id(new PhabricatorActionListView()) | ||||
| ->setUser($viewer); | ->setUser($viewer); | ||||
| $actions->addAction( | $actions->addAction( | ||||
| id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
| ->setIcon('fa-pencil') | ->setIcon('fa-pencil') | ||||
| ->setHref($this->getApplicationURI('post/query/draft/')) | ->setHref($this->getApplicationURI('post/query/draft/')) | ||||
| ->setName(pht('My Drafts'))); | ->setName(pht('My Drafts'))); | ||||
| $actions->addAction( | $actions->addAction( | ||||
| id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
| ->setIcon('fa-pencil-square-o') | ->setIcon('fa-pencil-square-o') | ||||
| ->setHref($this->getApplicationURI('post/')) | ->setHref($this->getApplicationURI('post/')) | ||||
| ->setName(pht('All Posts'))); | ->setName(pht('All Posts'))); | ||||
| $actions->addAction( | |||||
| id(new PhabricatorActionView()) | |||||
| ->setIcon('fa-star') | |||||
| ->setHref($this->getApplicationURI('blog/')) | |||||
| ->setName(pht('Active Blogs'))); | |||||
| return $actions; | return $actions; | ||||
| } | } | ||||
| private function renderBlogs($viewer, $blogs) {} | |||||
| protected function buildApplicationCrumbs() { | protected function buildApplicationCrumbs() { | ||||
| $crumbs = parent::buildApplicationCrumbs(); | $crumbs = parent::buildApplicationCrumbs(); | ||||
| $can_create = $this->hasApplicationCapability( | $can_create = $this->hasApplicationCapability( | ||||
| PhameBlogCreateCapability::CAPABILITY); | PhameBlogCreateCapability::CAPABILITY); | ||||
| $crumbs->addAction( | $crumbs->addAction( | ||||
| id(new PHUIListItemView()) | id(new PHUIListItemView()) | ||||
| ->setName(pht('New Post')) | |||||
| ->setHref($this->getApplicationURI('/post/new/')) | |||||
| ->setIcon('fa-plus-square') | |||||
| ->setWorkflow(true)); | |||||
| $crumbs->addAction( | |||||
| id(new PHUIListItemView()) | |||||
| ->setName(pht('New Blog')) | ->setName(pht('New Blog')) | ||||
| ->setHref($this->getApplicationURI('/blog/new/')) | ->setHref($this->getApplicationURI('/blog/new/')) | ||||
| ->setIcon('fa-plus-square') | ->setIcon('fa-plus-square') | ||||
| ->setDisabled(!$can_create) | ->setDisabled(!$can_create) | ||||
| ->setWorkflow(!$can_create)); | ->setWorkflow(!$can_create)); | ||||
| return $crumbs; | return $crumbs; | ||||
| } | } | ||||
| } | } | ||||