@@ -22,5 +22,5 @@ |
||
22 | 22 | const FRONT_PAGE_POSTS = 3; |
23 | 23 | const POSTS_PER_PAGE = 4; |
24 | 24 | |
25 | - const EXCERPT_WORD_COUNT =50; |
|
25 | + const EXCERPT_WORD_COUNT = 50; |
|
26 | 26 | } |
27 | 27 | \ No newline at end of file |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | * @throws \Twig_Error_Runtime |
43 | 43 | * @throws \Twig_Error_Syntax |
44 | 44 | */ |
45 | - public function posts(string $categorySlug, string $page="page-1") |
|
45 | + public function posts(string $categorySlug, string $page = "page-1") |
|
46 | 46 | { |
47 | 47 | |
48 | 48 | |
49 | 49 | $categoryId = $this->slugModel->getIdFromSlug($categorySlug, "categories", "categories_slug", "idcategories"); |
50 | - $totalPosts = $this->postModel->totalNumberPostsInCategory($categoryId) ; |
|
50 | + $totalPosts = $this->postModel->totalNumberPostsInCategory($categoryId); |
|
51 | 51 | |
52 | 52 | $pagination = $this->pagination->getPagination($page, $totalPosts); |
53 | 53 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | |
57 | 57 | $this->data['navigation'] = $this->categoryModel->getMenu(); |
58 | - $this->data['posts'] = $this->postModel->getPostsInCategory($categoryId,$pagination["offset"]); |
|
58 | + $this->data['posts'] = $this->postModel->getPostsInCategory($categoryId, $pagination["offset"]); |
|
59 | 59 | $this->data['pagination'] = $pagination; |
60 | 60 | $this->data['categorySlug'] = $categorySlug; |
61 | 61 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | |
64 | 64 | } |
65 | 65 | |
66 | - public function allPosts(string $page="page-1") |
|
66 | + public function allPosts(string $page = "page-1") |
|
67 | 67 | { |
68 | 68 | $totalPosts = $this->postModel->totalNumberPosts(); |
69 | 69 |
@@ -25,9 +25,9 @@ |
||
25 | 25 | } |
26 | 26 | |
27 | 27 | return array( |
28 | - "pageNo" => $pageNo, |
|
29 | - "offset" => $offset, |
|
30 | - "totalPages" => $totalPages |
|
28 | + "pageNo" => $pageNo, |
|
29 | + "offset" => $offset, |
|
30 | + "totalPages" => $totalPages |
|
31 | 31 | ); |
32 | 32 | |
33 | 33 | } |
@@ -5,21 +5,21 @@ |
||
5 | 5 | use Core\Modules\Module; |
6 | 6 | use Core\Traits\StringFunctions; |
7 | 7 | |
8 | -class Pagination extends Module{ |
|
8 | +class Pagination extends Module { |
|
9 | 9 | |
10 | 10 | use StringFunctions; |
11 | 11 | |
12 | 12 | public function getPagination(string $page, int $totalPosts):array |
13 | 13 | { |
14 | - if(!$this->startsWith($page, "page-")) |
|
14 | + if (!$this->startsWith($page, "page-")) |
|
15 | 15 | { |
16 | 16 | throw new \Exception("Pagination Error", "404"); |
17 | 17 | } |
18 | 18 | $pageNo = $this->removeFromBeginning($page, "page-"); |
19 | - $offset = ($pageNo-1) * Constant::POSTS_PER_PAGE; |
|
19 | + $offset = ($pageNo - 1) * Constant::POSTS_PER_PAGE; |
|
20 | 20 | $totalPages = ceil($totalPosts / Constant::POSTS_PER_PAGE); |
21 | 21 | |
22 | - if($pageNo > $totalPages) |
|
22 | + if ($pageNo > $totalPages) |
|
23 | 23 | { |
24 | 24 | throw new \Error("Pagination Number not found", "404"); |
25 | 25 | } |