diff --git a/src/applications/phame/controller/PhameController.php b/src/applications/phame/controller/PhameController.php index 1e485e07fe..2ce962e16b 100644 --- a/src/applications/phame/controller/PhameController.php +++ b/src/applications/phame/controller/PhameController.php @@ -20,138 +20,36 @@ * @group phame */ abstract class PhameController extends PhabricatorController { - private $showSideNav; - private $showChrome = true; - private $deviceReady = false; - protected function setShowSideNav($value) { - $this->showSideNav = (bool) $value; - return $this; - } - private function showSideNav() { - return $this->showSideNav; - } + protected function renderSideNavFilterView() { - protected function setShowChrome($show_chrome) { - $this->showChrome = $show_chrome; - return $this; - } - private function getShowChrome() { - return $this->showChrome; - } + $base_uri = new PhutilURI($this->getApplicationURI()); - public function setDeviceReady($device_ready) { - $this->deviceReady = $device_ready; - return $this; - } - public function getDeviceReady() { - return $this->deviceReady; - } - - public function buildStandardPageResponse($view, array $data) { - - $page = $this->buildStandardPageView(); - - $page->setApplicationName('Phame'); - $page->setBaseURI('/phame/'); - $page->setTitle(idx($data, 'title')); - $page->setGlyph("\xe2\x9c\xa9"); - $page->setShowChrome($this->getShowChrome()); - $page->setDeviceReady($this->getDeviceReady()); - - if ($this->showSideNav()) { - $nav = $this->renderSideNavFilterView($this->getSideNavFilter()); - $nav->appendChild($view); - $page->appendChild($nav); - } else { - $page->appendChild($view); - } - - $response = new AphrontWebpageResponse(); - return $response->setContent($page->render()); - } - - protected function renderSideNavFilterView($filter) { - $base_uri = new PhutilURI('/phame/'); $nav = new AphrontSideNavFilterView(); $nav->setBaseURI($base_uri); + $nav->addLabel('Create'); - $nav->addFilter('post/new', 'New Post'); - $nav->addFilter('blog/new', 'New Blog'); + $nav->addFilter('post/new', 'New Post'); + $nav->addFilter('blog/new', 'New Blog'); $nav->addSpacer(); + $nav->addLabel('Posts'); - $nav->addFilter('post/draft', - 'My Drafts'); - foreach ($this->getSideNavExtraDraftFilters() as $draft_filter) { - $nav->addFilter($draft_filter['key'], - $draft_filter['name'], - idx($draft_filter, 'uri')); - } - $nav->addFilter('post/', 'My Posts'); - $nav->addFilter('post/all', 'All Posts'); - foreach ($this->getSideNavExtraPostFilters() as $post_filter) { - $nav->addFilter($post_filter['key'], - $post_filter['name'], - idx($post_filter, 'uri')); - } + $nav->addFilter('post/draft', 'My Drafts'); + $nav->addFilter('post', 'My Posts'); + $nav->addFilter('post/all', 'All Posts'); $nav->addSpacer(); - $nav->addLabel('Blogs'); - foreach ($this->getSideNavBlogFilters() as $blog_filter) { - $nav->addFilter($blog_filter['key'], - $blog_filter['name'], - idx($blog_filter, 'uri')); - } - $nav->selectFilter($filter); + $nav->addLabel('Blogs'); + $nav->addFilter('blog/user', 'Joinable Blogs'); + $nav->addFilter('blog/all', 'All Blogs'); + + $nav->selectFilter(null); return $nav; } - protected function getSideNavExtraDraftFilters() { - return array(); - } - - protected function getSideNavExtraPostFilters() { - return array(); - } - - protected function getSideNavBlogFilters() { - return array( - array( - 'key' => 'blog/user', - 'name' => 'My Blogs', - ), - array( - 'key' => 'blog/all', - 'name' => 'All Blogs', - ), - ); - } - - protected function getSideNavFilter() { - return 'post'; - } - - protected function getPager() { - $request = $this->getRequest(); - $pager = new AphrontPagerView(); - $page_size = 50; - $pager->setURI($request->getRequestURI(), 'offset'); - $pager->setPageSize($page_size); - $pager->setOffset($request->getInt('offset')); - - return $pager; - } - - protected function buildNoticeView() { - $notice_view = id(new AphrontErrorView()) - ->setSeverity(AphrontErrorView::SEVERITY_NOTICE) - ->setTitle('Meta thoughts and feelings'); - return $notice_view; - } - protected function renderPostList( array $posts, PhabricatorUser $user, diff --git a/src/applications/phame/controller/blog/PhameBlogEditController.php b/src/applications/phame/controller/blog/PhameBlogEditController.php index c3af88a262..35cddc9b52 100644 --- a/src/applications/phame/controller/blog/PhameBlogEditController.php +++ b/src/applications/phame/controller/blog/PhameBlogEditController.php @@ -187,9 +187,14 @@ final class PhameBlogEditController $error_view = null; } - $nav = $this->renderSideNavFilterView(null); + $header = id(new PhabricatorHeaderView()) + ->setHeader($page_title); + + $nav = $this->renderSideNavFilterView(); + $nav->selectFilter($this->id ? null : 'blog/new'); $nav->appendChild( array( + $header, $error_view, $form, )); diff --git a/src/applications/phame/controller/blog/PhameBlogListController.php b/src/applications/phame/controller/blog/PhameBlogListController.php index fb8665c1fa..d066f69666 100644 --- a/src/applications/phame/controller/blog/PhameBlogListController.php +++ b/src/applications/phame/controller/blog/PhameBlogListController.php @@ -39,12 +39,12 @@ final class PhameBlogListController extends PhameController { switch ($filter) { case 'blog/all': - $title = 'All Blogs'; - $nodata = 'No blogs have been created.'; + $title = pht('All Blogs'); + $nodata = pht('No blogs have been created.'); break; case 'blog/user': - $title = 'My Blogs'; - $nodata = 'There are no blogs you can contribute to.'; + $title = pht('Joinable Blogs'); + $nodata = pht('There are no blogs you can contribute to.'); $query->requireCapabilities( array( PhabricatorPolicyCapability::CAN_JOIN, @@ -93,7 +93,7 @@ final class PhameBlogListController extends PhameController { ->setHeader($blog->getName()) ->setHref($this->getApplicationURI('blog/view/'.$blog->getID().'/')) ->addDetail( - 'Custom Domain', + pht('Custom Domain'), phutil_escape_html($blog->getDomain())); $view->addItem($item); diff --git a/src/applications/phame/controller/post/PhamePostListController.php b/src/applications/phame/controller/post/PhamePostListController.php index 3f926c9e98..ed437ebb5d 100644 --- a/src/applications/phame/controller/post/PhamePostListController.php +++ b/src/applications/phame/controller/post/PhamePostListController.php @@ -36,12 +36,15 @@ final class PhamePostListController extends PhameController { $query = id(new PhamePostQuery()) ->setViewer($user); + $nav = $this->renderSideNavFilterView(); + switch ($this->filter) { case 'draft': $query->withBloggerPHIDs(array($user->getPHID())); $query->withVisibility(PhamePost::VISIBILITY_DRAFT); $nodata = pht('You have no unpublished drafts.'); $title = pht('Unpublished Drafts'); + $nav->selectFilter('post/draft'); break; case 'blogger': if ($this->bloggername) { @@ -57,6 +60,7 @@ final class PhamePostListController extends PhameController { $query->withBloggerPHIDs(array($blogger->getPHID())); if ($blogger->getPHID() == $user->getPHID()) { + $nav->selectFilter('post'); $nodata = pht('You have not written any posts.'); } else { $nodata = pht('%s has not written any posts.', $blogger); @@ -66,6 +70,7 @@ final class PhamePostListController extends PhameController { case 'all': $nodata = pht('There are no visible posts.'); $title = pht('Posts'); + $nav->selectFilter('post/all'); break; default: throw new Exception("Unknown filter '{$this->filter}'!"); @@ -86,7 +91,6 @@ final class PhamePostListController extends PhameController { ->setHeader($title); $post_list = $this->renderPostList($posts, $user, $nodata); - $nav = $this->renderSideNavFilterView(null); $nav->appendChild( array( $header, diff --git a/src/applications/phame/controller/post/PhamePostNewController.php b/src/applications/phame/controller/post/PhamePostNewController.php index f181cc4654..6393c2d9b0 100644 --- a/src/applications/phame/controller/post/PhamePostNewController.php +++ b/src/applications/phame/controller/post/PhamePostNewController.php @@ -33,13 +33,20 @@ final class PhamePostNewController extends PhameController { )) ->execute(); - $nav = $this->renderSideNavFilterView(null); + $nav = $this->renderSideNavFilterView(); + $nav->selectFilter('post/new'); $nav->appendChild( id(new PhabricatorHeaderView())->setHeader( pht('Create Post'))); if (!$blogs) { + $notification = id(new AphrontErrorView()) + ->setSeverity(AphrontErrorView::SEVERITY_NODATA) + ->appendChild( + pht('You do not have permission to join any blogs. Create a blog '. + 'first, then you can post to it.')); + $nav->appendChild($notification); } else { $options = mpull($blogs, 'getName', 'getID');