From d6f02fb724c5f4508e43cbf16f0df7a677a1ee3e Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Mon, 3 Mar 2014 21:56:10 +0100 Subject: [PATCH] Added "upvoted" tab --- src/Controllers/PostController.php | 10 +++++++++- src/Views/post-list-wrapper.phtml | 25 +++++++++++++++++++++---- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/Controllers/PostController.php b/src/Controllers/PostController.php index fbe750a5..aae13462 100644 --- a/src/Controllers/PostController.php +++ b/src/Controllers/PostController.php @@ -151,7 +151,15 @@ class PostController $this->listAction('favmin:1', $page); } - + /** + * @route /upvoted + * @route /upvoted/{page} + * @validate page \d* + */ + public function upvotedAction($page = 1) + { + $this->listAction('scoremin:1', $page); + } /** * @route /random diff --git a/src/Views/post-list-wrapper.phtml b/src/Views/post-list-wrapper.phtml index e95d1ac7..05012c5d 100644 --- a/src/Views/post-list-wrapper.phtml +++ b/src/Views/post-list-wrapper.phtml @@ -2,24 +2,41 @@ CustomAssetViewDecorator::setSubTitle('posts'); $tabs = []; +$activeTab = 0; if (PrivilegesHelper::confirm(Privilege::ListPosts)) $tabs []= ['All posts', \Chibi\UrlHelper::route('post', 'list')]; if (PrivilegesHelper::confirm(Privilege::ListPosts)) +{ $tabs []= ['Random', \Chibi\UrlHelper::route('post', 'random')]; + if ($this->context->route->simpleActionName == 'random') + $activeTab = count($tabs) - 1; +} + if (PrivilegesHelper::confirm(Privilege::ListPosts)) +{ $tabs []= ['Favorites', \Chibi\UrlHelper::route('post', 'favorites')]; + if ($this->context->route->simpleActionName == 'favorites') + $activeTab = count($tabs) - 1; +} + +if (PrivilegesHelper::confirm(Privilege::ListPosts)) +{ + $tabs []= ['Upvoted', \Chibi\UrlHelper::route('post', 'upvoted')]; + if ($this->context->route->simpleActionName == 'upvoted') + $activeTab = count($tabs) - 1; +} if (PrivilegesHelper::confirm(Privilege::MassTag)) +{ $tabs []= ['Mass tag', \Chibi\UrlHelper::route('post', 'list', [ 'source' => 'mass-tag', 'query' => isset($this->context->transport->searchQuery) ? htmlspecialchars($this->context->transport->searchQuery) : '', 'page' => isset($this->context->transport->paginator) ? $this->context->transport->paginator->page : 1])]; + if ($this->context->source == 'mass-tag') + $activeTab = count($tabs) - 1; +} -$activeTab = 0; -if ($this->context->route->simpleActionName == 'random') $activeTab = 1; -if ($this->context->route->simpleActionName == 'favorites') $activeTab = 2; -if ($this->context->source == 'mass-tag') $activeTab = 3; ?>