@@ -32,12 +32,12 @@ discard block |
||
32 | 32 | { |
33 | 33 | parent::set_head_data(); |
34 | 34 | |
35 | - if($this->page == 1) |
|
35 | + if ($this->page == 1) |
|
36 | 36 | $this->set_title(self::$TITLE_MAIN); |
37 | 37 | else |
38 | 38 | $this->set_title(sprintf(self::$TITLE_PAGINATED, $this->page, $this->total_pages)); |
39 | 39 | |
40 | - if($this->page == 1) |
|
40 | + if ($this->page == 1) |
|
41 | 41 | $this->set_description(self::$DESCRIPTION_MAIN); |
42 | 42 | else |
43 | 43 | $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages)); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | protected function get_introduction() |
49 | 49 | { |
50 | - if($this->page == 1) |
|
50 | + if ($this->page == 1) |
|
51 | 51 | { |
52 | 52 | global $container; |
53 | 53 | $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | protected function get_page_number() |
69 | 69 | { |
70 | 70 | $page = URLDecode::getPiece(1); |
71 | - if(isset($page) && is_numeric($page)) |
|
71 | + if (isset($page) && is_numeric($page)) |
|
72 | 72 | return $page; |
73 | 73 | return 1; |
74 | 74 | } |
@@ -90,24 +90,24 @@ discard block |
||
90 | 90 | |
91 | 91 | protected function get_list_next_link() |
92 | 92 | { |
93 | - if($this->page == 1) |
|
93 | + if ($this->page == 1) |
|
94 | 94 | return; |
95 | - if($this->page == 2) |
|
95 | + if ($this->page == 2) |
|
96 | 96 | return '/'; |
97 | - return '/' . ($this->page - 1) . '/'; |
|
97 | + return '/'.($this->page - 1).'/'; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | protected function get_list_prev_link() |
101 | 101 | { |
102 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
102 | + if (($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
103 | 103 | return; |
104 | - return '/' . ($this->page + 1) . '/'; |
|
104 | + return '/'.($this->page + 1).'/'; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | private $total_post_count; |
108 | 108 | protected function get_total_post_count() |
109 | 109 | { |
110 | - if(!isset($this->total_post_count)) { |
|
110 | + if (!isset($this->total_post_count)) { |
|
111 | 111 | global $container; |
112 | 112 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
113 | 113 | $this->total_post_count = $repository->getActivePostsCount(); |
@@ -5,115 +5,115 @@ |
||
5 | 5 | final class HomeController extends DefaultListController |
6 | 6 | { |
7 | 7 | |
8 | - private static $TITLE_MAIN = "Jacob Emerick's Blog | Posts on Hiking, Web Development, and more"; |
|
9 | - private static $TITLE_PAGINATED = "Page %d of %d in Jacob Emerick's Blog"; |
|
10 | - |
|
11 | - private static $DESCRIPTION_MAIN = "Jacob Emerick's Blog - a collection of posts about hiking the Upper Peninsula, learning to be a web developer, and other experiences of a young man."; |
|
12 | - private static $DESCRIPTION_PAGINATED = "Page %d of %d of posts about hiking in the Upper Peninsula, learning to be a web developer, and more on Jacob Emerick's Blog."; |
|
13 | - |
|
14 | - private static $KEYWORD_ARRAY = array( |
|
15 | - 'blog', |
|
16 | - 'Jacob Emerick', |
|
17 | - 'hiking', |
|
18 | - 'Huron Mountains', |
|
19 | - 'Peshekee Highlands', |
|
20 | - 'Keweenaw', |
|
21 | - 'Michigan', |
|
22 | - 'Upper Peninsula', |
|
23 | - 'leadership', |
|
24 | - 'web development', |
|
25 | - 'php programming', |
|
26 | - 'data handling', |
|
27 | - 'optimization'); |
|
28 | - |
|
29 | - private static $LIST_DESCRIPTION = 'Viewing %d - %d of %d total posts.'; |
|
30 | - |
|
31 | - protected function set_head_data() |
|
32 | - { |
|
33 | - parent::set_head_data(); |
|
8 | + private static $TITLE_MAIN = "Jacob Emerick's Blog | Posts on Hiking, Web Development, and more"; |
|
9 | + private static $TITLE_PAGINATED = "Page %d of %d in Jacob Emerick's Blog"; |
|
10 | + |
|
11 | + private static $DESCRIPTION_MAIN = "Jacob Emerick's Blog - a collection of posts about hiking the Upper Peninsula, learning to be a web developer, and other experiences of a young man."; |
|
12 | + private static $DESCRIPTION_PAGINATED = "Page %d of %d of posts about hiking in the Upper Peninsula, learning to be a web developer, and more on Jacob Emerick's Blog."; |
|
13 | + |
|
14 | + private static $KEYWORD_ARRAY = array( |
|
15 | + 'blog', |
|
16 | + 'Jacob Emerick', |
|
17 | + 'hiking', |
|
18 | + 'Huron Mountains', |
|
19 | + 'Peshekee Highlands', |
|
20 | + 'Keweenaw', |
|
21 | + 'Michigan', |
|
22 | + 'Upper Peninsula', |
|
23 | + 'leadership', |
|
24 | + 'web development', |
|
25 | + 'php programming', |
|
26 | + 'data handling', |
|
27 | + 'optimization'); |
|
28 | + |
|
29 | + private static $LIST_DESCRIPTION = 'Viewing %d - %d of %d total posts.'; |
|
30 | + |
|
31 | + protected function set_head_data() |
|
32 | + { |
|
33 | + parent::set_head_data(); |
|
34 | 34 | |
35 | - if($this->page == 1) |
|
36 | - $this->set_title(self::$TITLE_MAIN); |
|
37 | - else |
|
38 | - $this->set_title(sprintf(self::$TITLE_PAGINATED, $this->page, $this->total_pages)); |
|
35 | + if($this->page == 1) |
|
36 | + $this->set_title(self::$TITLE_MAIN); |
|
37 | + else |
|
38 | + $this->set_title(sprintf(self::$TITLE_PAGINATED, $this->page, $this->total_pages)); |
|
39 | 39 | |
40 | - if($this->page == 1) |
|
41 | - $this->set_description(self::$DESCRIPTION_MAIN); |
|
42 | - else |
|
43 | - $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages)); |
|
40 | + if($this->page == 1) |
|
41 | + $this->set_description(self::$DESCRIPTION_MAIN); |
|
42 | + else |
|
43 | + $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages)); |
|
44 | 44 | |
45 | - $this->set_keywords(self::$KEYWORD_ARRAY); |
|
46 | - } |
|
45 | + $this->set_keywords(self::$KEYWORD_ARRAY); |
|
46 | + } |
|
47 | 47 | |
48 | - protected function get_introduction() |
|
49 | - { |
|
50 | - if($this->page == 1) |
|
51 | - { |
|
48 | + protected function get_introduction() |
|
49 | + { |
|
50 | + if($this->page == 1) |
|
51 | + { |
|
52 | 52 | global $container; |
53 | 53 | $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
54 | 54 | $introduction_result = $repository->findByType('home'); |
55 | 55 | |
56 | - $introduction = array(); |
|
57 | - $introduction['title'] = $introduction_result['title']; |
|
58 | - $introduction['content'] = $introduction_result['content']; |
|
59 | - $introduction['image'] = $this->get_introduction_image($introduction_result['image']); |
|
56 | + $introduction = array(); |
|
57 | + $introduction['title'] = $introduction_result['title']; |
|
58 | + $introduction['content'] = $introduction_result['content']; |
|
59 | + $introduction['image'] = $this->get_introduction_image($introduction_result['image']); |
|
60 | 60 | |
61 | - return $introduction; |
|
62 | - } |
|
61 | + return $introduction; |
|
62 | + } |
|
63 | 63 | |
64 | - return array( |
|
65 | - 'title' => "All of Jacob Emerick's posts, page {$this->page} of {$this->total_pages}."); |
|
66 | - } |
|
67 | - |
|
68 | - protected function get_page_number() |
|
69 | - { |
|
70 | - $page = URLDecode::getPiece(1); |
|
71 | - if(isset($page) && is_numeric($page)) |
|
72 | - return $page; |
|
73 | - return 1; |
|
74 | - } |
|
75 | - |
|
76 | - protected function get_list_results() |
|
77 | - { |
|
64 | + return array( |
|
65 | + 'title' => "All of Jacob Emerick's posts, page {$this->page} of {$this->total_pages}."); |
|
66 | + } |
|
67 | + |
|
68 | + protected function get_page_number() |
|
69 | + { |
|
70 | + $page = URLDecode::getPiece(1); |
|
71 | + if(isset($page) && is_numeric($page)) |
|
72 | + return $page; |
|
73 | + return 1; |
|
74 | + } |
|
75 | + |
|
76 | + protected function get_list_results() |
|
77 | + { |
|
78 | 78 | global $container; |
79 | 79 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
80 | 80 | return $repository->getActivePosts(self::$POSTS_PER_PAGE, $this->offset); |
81 | - } |
|
81 | + } |
|
82 | 82 | |
83 | - protected function get_list_description() |
|
84 | - { |
|
85 | - $start = $this->offset + 1; |
|
86 | - $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
|
83 | + protected function get_list_description() |
|
84 | + { |
|
85 | + $start = $this->offset + 1; |
|
86 | + $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
|
87 | 87 | |
88 | - return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count()); |
|
89 | - } |
|
90 | - |
|
91 | - protected function get_list_next_link() |
|
92 | - { |
|
93 | - if($this->page == 1) |
|
94 | - return; |
|
95 | - if($this->page == 2) |
|
96 | - return '/'; |
|
97 | - return '/' . ($this->page - 1) . '/'; |
|
98 | - } |
|
99 | - |
|
100 | - protected function get_list_prev_link() |
|
101 | - { |
|
102 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
103 | - return; |
|
104 | - return '/' . ($this->page + 1) . '/'; |
|
105 | - } |
|
106 | - |
|
107 | - private $total_post_count; |
|
108 | - protected function get_total_post_count() |
|
109 | - { |
|
110 | - if(!isset($this->total_post_count)) { |
|
111 | - global $container; |
|
112 | - $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
113 | - $this->total_post_count = $repository->getActivePostsCount(); |
|
114 | - } |
|
115 | - |
|
116 | - return $this->total_post_count; |
|
117 | - } |
|
88 | + return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count()); |
|
89 | + } |
|
90 | + |
|
91 | + protected function get_list_next_link() |
|
92 | + { |
|
93 | + if($this->page == 1) |
|
94 | + return; |
|
95 | + if($this->page == 2) |
|
96 | + return '/'; |
|
97 | + return '/' . ($this->page - 1) . '/'; |
|
98 | + } |
|
99 | + |
|
100 | + protected function get_list_prev_link() |
|
101 | + { |
|
102 | + if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
103 | + return; |
|
104 | + return '/' . ($this->page + 1) . '/'; |
|
105 | + } |
|
106 | + |
|
107 | + private $total_post_count; |
|
108 | + protected function get_total_post_count() |
|
109 | + { |
|
110 | + if(!isset($this->total_post_count)) { |
|
111 | + global $container; |
|
112 | + $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
113 | + $this->total_post_count = $repository->getActivePostsCount(); |
|
114 | + } |
|
115 | + |
|
116 | + return $this->total_post_count; |
|
117 | + } |
|
118 | 118 | |
119 | 119 | } |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('controller', 'blog/DefaultListController'); |
4 | 4 | |
5 | -final class HomeController extends DefaultListController |
|
6 | -{ |
|
5 | +final class HomeController extends DefaultListController |
|
6 | +{ |
|
7 | 7 | |
8 | 8 | private static $TITLE_MAIN = "Jacob Emerick's Blog | Posts on Hiking, Web Development, and more"; |
9 | 9 | private static $TITLE_PAGINATED = "Page %d of %d in Jacob Emerick's Blog"; |
@@ -28,25 +28,27 @@ discard block |
||
28 | 28 | |
29 | 29 | private static $LIST_DESCRIPTION = 'Viewing %d - %d of %d total posts.'; |
30 | 30 | |
31 | - protected function set_head_data() |
|
32 | - { |
|
31 | + protected function set_head_data() |
|
32 | + { |
|
33 | 33 | parent::set_head_data(); |
34 | 34 | |
35 | - if($this->page == 1) |
|
36 | - $this->set_title(self::$TITLE_MAIN); |
|
37 | - else |
|
38 | - $this->set_title(sprintf(self::$TITLE_PAGINATED, $this->page, $this->total_pages)); |
|
35 | + if($this->page == 1) { |
|
36 | + $this->set_title(self::$TITLE_MAIN); |
|
37 | + } else { |
|
38 | + $this->set_title(sprintf(self::$TITLE_PAGINATED, $this->page, $this->total_pages)); |
|
39 | + } |
|
39 | 40 | |
40 | - if($this->page == 1) |
|
41 | - $this->set_description(self::$DESCRIPTION_MAIN); |
|
42 | - else |
|
43 | - $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages)); |
|
41 | + if($this->page == 1) { |
|
42 | + $this->set_description(self::$DESCRIPTION_MAIN); |
|
43 | + } else { |
|
44 | + $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages)); |
|
45 | + } |
|
44 | 46 | |
45 | 47 | $this->set_keywords(self::$KEYWORD_ARRAY); |
46 | 48 | } |
47 | 49 | |
48 | - protected function get_introduction() |
|
49 | - { |
|
50 | + protected function get_introduction() |
|
51 | + { |
|
50 | 52 | if($this->page == 1) |
51 | 53 | { |
52 | 54 | global $container; |
@@ -65,48 +67,52 @@ discard block |
||
65 | 67 | 'title' => "All of Jacob Emerick's posts, page {$this->page} of {$this->total_pages}."); |
66 | 68 | } |
67 | 69 | |
68 | - protected function get_page_number() |
|
69 | - { |
|
70 | + protected function get_page_number() |
|
71 | + { |
|
70 | 72 | $page = URLDecode::getPiece(1); |
71 | - if(isset($page) && is_numeric($page)) |
|
72 | - return $page; |
|
73 | + if(isset($page) && is_numeric($page)) { |
|
74 | + return $page; |
|
75 | + } |
|
73 | 76 | return 1; |
74 | 77 | } |
75 | 78 | |
76 | - protected function get_list_results() |
|
77 | - { |
|
79 | + protected function get_list_results() |
|
80 | + { |
|
78 | 81 | global $container; |
79 | 82 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
80 | 83 | return $repository->getActivePosts(self::$POSTS_PER_PAGE, $this->offset); |
81 | 84 | } |
82 | 85 | |
83 | - protected function get_list_description() |
|
84 | - { |
|
86 | + protected function get_list_description() |
|
87 | + { |
|
85 | 88 | $start = $this->offset + 1; |
86 | 89 | $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
87 | 90 | |
88 | 91 | return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count()); |
89 | 92 | } |
90 | 93 | |
91 | - protected function get_list_next_link() |
|
92 | - { |
|
93 | - if($this->page == 1) |
|
94 | - return; |
|
95 | - if($this->page == 2) |
|
96 | - return '/'; |
|
94 | + protected function get_list_next_link() |
|
95 | + { |
|
96 | + if($this->page == 1) { |
|
97 | + return; |
|
98 | + } |
|
99 | + if($this->page == 2) { |
|
100 | + return '/'; |
|
101 | + } |
|
97 | 102 | return '/' . ($this->page - 1) . '/'; |
98 | 103 | } |
99 | 104 | |
100 | - protected function get_list_prev_link() |
|
101 | - { |
|
102 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
103 | - return; |
|
105 | + protected function get_list_prev_link() |
|
106 | + { |
|
107 | + if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) { |
|
108 | + return; |
|
109 | + } |
|
104 | 110 | return '/' . ($this->page + 1) . '/'; |
105 | 111 | } |
106 | 112 | |
107 | 113 | private $total_post_count; |
108 | - protected function get_total_post_count() |
|
109 | - { |
|
114 | + protected function get_total_post_count() |
|
115 | + { |
|
110 | 116 | if(!isset($this->total_post_count)) { |
111 | 117 | global $container; |
112 | 118 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | { |
45 | 45 | parent::set_head_data(); |
46 | 46 | |
47 | - if($this->page == 1) |
|
47 | + if ($this->page == 1) |
|
48 | 48 | { |
49 | 49 | $this->set_title(sprintf(self::$TITLE_MAIN, ucwords($this->query))); |
50 | 50 | $this->set_description(sprintf(self::$DESCRIPTION_MAIN, ucwords($this->query))); |
@@ -62,10 +62,10 @@ discard block |
||
62 | 62 | |
63 | 63 | protected function get_introduction() |
64 | 64 | { |
65 | - if($this->total_pages > 1) |
|
65 | + if ($this->total_pages > 1) |
|
66 | 66 | return array( |
67 | 67 | 'title' => "Posts from search '{$this->query}', page {$this->page} of {$this->total_pages}."); |
68 | - else if($this->total_pages == 1) |
|
68 | + else if ($this->total_pages == 1) |
|
69 | 69 | return array( |
70 | 70 | 'title' => "Posts from search '{$this->query}'."); |
71 | 71 | else |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | protected function get_page_number() |
77 | 77 | { |
78 | 78 | $page = URLDecode::getPiece(3); |
79 | - if(isset($page) && is_numeric($page)) |
|
79 | + if (isset($page) && is_numeric($page)) |
|
80 | 80 | return $page; |
81 | 81 | return 1; |
82 | 82 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | private $search_result; |
85 | 85 | private function get_search_result() |
86 | 86 | { |
87 | - if(!isset($this->search_result)) |
|
87 | + if (!isset($this->search_result)) |
|
88 | 88 | { |
89 | 89 | global $container; |
90 | 90 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
@@ -114,24 +114,24 @@ discard block |
||
114 | 114 | |
115 | 115 | protected function get_list_next_link() |
116 | 116 | { |
117 | - if($this->page == 1) |
|
117 | + if ($this->page == 1) |
|
118 | 118 | return; |
119 | - if($this->page == 2) |
|
119 | + if ($this->page == 2) |
|
120 | 120 | return Content::instance('URLSafe', "/search/{$this->query}/")->activate(); |
121 | - return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page - 1) . '/')->activate(); |
|
121 | + return Content::instance('URLSafe', "/search/{$this->query}/".($this->page - 1).'/')->activate(); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | protected function get_list_prev_link() |
125 | 125 | { |
126 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
126 | + if (($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
127 | 127 | return; |
128 | - return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page + 1) . '/')->activate(); |
|
128 | + return Content::instance('URLSafe', "/search/{$this->query}/".($this->page + 1).'/')->activate(); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | private $total_post_count; |
132 | 132 | protected function get_total_post_count() |
133 | 133 | { |
134 | - if(!isset($this->total_post_count)) |
|
134 | + if (!isset($this->total_post_count)) |
|
135 | 135 | $this->total_post_count = count($this->get_search_result()); |
136 | 136 | return $this->total_post_count; |
137 | 137 | } |
@@ -6,134 +6,134 @@ |
||
6 | 6 | final class SearchController extends DefaultListController |
7 | 7 | { |
8 | 8 | |
9 | - private static $TITLE_MAIN = "%s Search | Jacob Emerick's Blog"; |
|
10 | - private static $DESCRIPTION_MAIN = "Posts containing the phrase %s on Jacob Emerick's Blog."; |
|
11 | - |
|
12 | - private static $TITLE_PAGINATED = "%s Search - Page %d of %d | Jacob Emerick's Blog"; |
|
13 | - private static $DESCRIPTION_PAGINATED = "Page %d of %d with posts containing the phrase %s on Jacob Emerick's Blog."; |
|
14 | - |
|
15 | - private static $KEYWORD_ARRAY = array( |
|
16 | - 'hiking', |
|
17 | - 'web development', |
|
18 | - 'blog', |
|
19 | - 'Jacob Emerick'); |
|
20 | - |
|
21 | - private static $LIST_DESCRIPTION = 'Viewing %d - %d of %d posts containing the phrase %s.'; |
|
22 | - private static $SEARCH_WEIGHTS = array( |
|
23 | - array( |
|
24 | - 'field' => 'title', |
|
25 | - 'weight' => 8), |
|
26 | - array( |
|
27 | - 'field' => 'body', |
|
28 | - 'weight' => 4)); |
|
29 | - |
|
30 | - private $query; |
|
31 | - |
|
32 | - public function __construct() |
|
33 | - { |
|
34 | - $query = URLDecode::getPiece(2); |
|
35 | - $query = urldecode($query); |
|
9 | + private static $TITLE_MAIN = "%s Search | Jacob Emerick's Blog"; |
|
10 | + private static $DESCRIPTION_MAIN = "Posts containing the phrase %s on Jacob Emerick's Blog."; |
|
11 | + |
|
12 | + private static $TITLE_PAGINATED = "%s Search - Page %d of %d | Jacob Emerick's Blog"; |
|
13 | + private static $DESCRIPTION_PAGINATED = "Page %d of %d with posts containing the phrase %s on Jacob Emerick's Blog."; |
|
14 | + |
|
15 | + private static $KEYWORD_ARRAY = array( |
|
16 | + 'hiking', |
|
17 | + 'web development', |
|
18 | + 'blog', |
|
19 | + 'Jacob Emerick'); |
|
20 | + |
|
21 | + private static $LIST_DESCRIPTION = 'Viewing %d - %d of %d posts containing the phrase %s.'; |
|
22 | + private static $SEARCH_WEIGHTS = array( |
|
23 | + array( |
|
24 | + 'field' => 'title', |
|
25 | + 'weight' => 8), |
|
26 | + array( |
|
27 | + 'field' => 'body', |
|
28 | + 'weight' => 4)); |
|
29 | + |
|
30 | + private $query; |
|
31 | + |
|
32 | + public function __construct() |
|
33 | + { |
|
34 | + $query = URLDecode::getPiece(2); |
|
35 | + $query = urldecode($query); |
|
36 | 36 | $query = str_replace('-', ' ', $query); |
37 | 37 | |
38 | - $this->query = $query; |
|
38 | + $this->query = $query; |
|
39 | 39 | |
40 | - parent::__construct(); |
|
41 | - } |
|
40 | + parent::__construct(); |
|
41 | + } |
|
42 | 42 | |
43 | - protected function set_head_data() |
|
44 | - { |
|
45 | - parent::set_head_data(); |
|
43 | + protected function set_head_data() |
|
44 | + { |
|
45 | + parent::set_head_data(); |
|
46 | 46 | |
47 | - if($this->page == 1) |
|
48 | - { |
|
49 | - $this->set_title(sprintf(self::$TITLE_MAIN, ucwords($this->query))); |
|
50 | - $this->set_description(sprintf(self::$DESCRIPTION_MAIN, ucwords($this->query))); |
|
51 | - } |
|
52 | - else |
|
53 | - { |
|
54 | - $this->set_title(sprintf(self::$TITLE_PAGINATED, ucwords($this->query), $this->page, $this->total_pages)); |
|
55 | - $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages, ucwords($this->query))); |
|
56 | - } |
|
47 | + if($this->page == 1) |
|
48 | + { |
|
49 | + $this->set_title(sprintf(self::$TITLE_MAIN, ucwords($this->query))); |
|
50 | + $this->set_description(sprintf(self::$DESCRIPTION_MAIN, ucwords($this->query))); |
|
51 | + } |
|
52 | + else |
|
53 | + { |
|
54 | + $this->set_title(sprintf(self::$TITLE_PAGINATED, ucwords($this->query), $this->page, $this->total_pages)); |
|
55 | + $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages, ucwords($this->query))); |
|
56 | + } |
|
57 | 57 | |
58 | - $keyword_array = self::$KEYWORD_ARRAY; |
|
59 | - array_unshift($keyword_array, $this->query); |
|
60 | - $this->set_keywords($keyword_array); |
|
61 | - } |
|
62 | - |
|
63 | - protected function get_introduction() |
|
64 | - { |
|
65 | - if($this->total_pages > 1) |
|
66 | - return array( |
|
67 | - 'title' => "Posts from search '{$this->query}', page {$this->page} of {$this->total_pages}."); |
|
68 | - else if($this->total_pages == 1) |
|
69 | - return array( |
|
70 | - 'title' => "Posts from search '{$this->query}'."); |
|
71 | - else |
|
72 | - return array( |
|
73 | - 'title' => "Sorry, '{$this->query}' didn't return any posts."); |
|
74 | - } |
|
75 | - |
|
76 | - protected function get_page_number() |
|
77 | - { |
|
78 | - $page = URLDecode::getPiece(3); |
|
79 | - if(isset($page) && is_numeric($page)) |
|
80 | - return $page; |
|
81 | - return 1; |
|
82 | - } |
|
83 | - |
|
84 | - private $search_result; |
|
85 | - private function get_search_result() |
|
86 | - { |
|
87 | - if(!isset($this->search_result)) |
|
88 | - { |
|
58 | + $keyword_array = self::$KEYWORD_ARRAY; |
|
59 | + array_unshift($keyword_array, $this->query); |
|
60 | + $this->set_keywords($keyword_array); |
|
61 | + } |
|
62 | + |
|
63 | + protected function get_introduction() |
|
64 | + { |
|
65 | + if($this->total_pages > 1) |
|
66 | + return array( |
|
67 | + 'title' => "Posts from search '{$this->query}', page {$this->page} of {$this->total_pages}."); |
|
68 | + else if($this->total_pages == 1) |
|
69 | + return array( |
|
70 | + 'title' => "Posts from search '{$this->query}'."); |
|
71 | + else |
|
72 | + return array( |
|
73 | + 'title' => "Sorry, '{$this->query}' didn't return any posts."); |
|
74 | + } |
|
75 | + |
|
76 | + protected function get_page_number() |
|
77 | + { |
|
78 | + $page = URLDecode::getPiece(3); |
|
79 | + if(isset($page) && is_numeric($page)) |
|
80 | + return $page; |
|
81 | + return 1; |
|
82 | + } |
|
83 | + |
|
84 | + private $search_result; |
|
85 | + private function get_search_result() |
|
86 | + { |
|
87 | + if(!isset($this->search_result)) |
|
88 | + { |
|
89 | 89 | global $container; |
90 | 90 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
91 | 91 | $posts = $repository->getActivePosts(); |
92 | 92 | |
93 | - $this->search_result = Search::instance() |
|
94 | - ->setQuery($this->query) |
|
95 | - ->setResult($posts) |
|
96 | - ->setWeight(self::$SEARCH_WEIGHTS) |
|
97 | - ->perform(); |
|
98 | - } |
|
99 | - return $this->search_result; |
|
100 | - } |
|
101 | - |
|
102 | - protected function get_list_results() |
|
103 | - { |
|
104 | - return array_slice($this->get_search_result(), $this->offset, self::$POSTS_PER_PAGE); |
|
105 | - } |
|
106 | - |
|
107 | - protected function get_list_description() |
|
108 | - { |
|
109 | - $start = $this->offset + 1; |
|
110 | - $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
|
93 | + $this->search_result = Search::instance() |
|
94 | + ->setQuery($this->query) |
|
95 | + ->setResult($posts) |
|
96 | + ->setWeight(self::$SEARCH_WEIGHTS) |
|
97 | + ->perform(); |
|
98 | + } |
|
99 | + return $this->search_result; |
|
100 | + } |
|
101 | + |
|
102 | + protected function get_list_results() |
|
103 | + { |
|
104 | + return array_slice($this->get_search_result(), $this->offset, self::$POSTS_PER_PAGE); |
|
105 | + } |
|
106 | + |
|
107 | + protected function get_list_description() |
|
108 | + { |
|
109 | + $start = $this->offset + 1; |
|
110 | + $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
|
111 | 111 | |
112 | - return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count(), $this->query); |
|
113 | - } |
|
114 | - |
|
115 | - protected function get_list_next_link() |
|
116 | - { |
|
117 | - if($this->page == 1) |
|
118 | - return; |
|
119 | - if($this->page == 2) |
|
120 | - return Content::instance('URLSafe', "/search/{$this->query}/")->activate(); |
|
121 | - return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page - 1) . '/')->activate(); |
|
122 | - } |
|
123 | - |
|
124 | - protected function get_list_prev_link() |
|
125 | - { |
|
126 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
127 | - return; |
|
128 | - return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page + 1) . '/')->activate(); |
|
129 | - } |
|
130 | - |
|
131 | - private $total_post_count; |
|
132 | - protected function get_total_post_count() |
|
133 | - { |
|
134 | - if(!isset($this->total_post_count)) |
|
135 | - $this->total_post_count = count($this->get_search_result()); |
|
136 | - return $this->total_post_count; |
|
137 | - } |
|
112 | + return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count(), $this->query); |
|
113 | + } |
|
114 | + |
|
115 | + protected function get_list_next_link() |
|
116 | + { |
|
117 | + if($this->page == 1) |
|
118 | + return; |
|
119 | + if($this->page == 2) |
|
120 | + return Content::instance('URLSafe', "/search/{$this->query}/")->activate(); |
|
121 | + return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page - 1) . '/')->activate(); |
|
122 | + } |
|
123 | + |
|
124 | + protected function get_list_prev_link() |
|
125 | + { |
|
126 | + if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
127 | + return; |
|
128 | + return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page + 1) . '/')->activate(); |
|
129 | + } |
|
130 | + |
|
131 | + private $total_post_count; |
|
132 | + protected function get_total_post_count() |
|
133 | + { |
|
134 | + if(!isset($this->total_post_count)) |
|
135 | + $this->total_post_count = count($this->get_search_result()); |
|
136 | + return $this->total_post_count; |
|
137 | + } |
|
138 | 138 | |
139 | 139 | } |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | Loader::load('controller', 'blog/DefaultListController'); |
4 | 4 | Loader::load('utility', 'Search'); |
5 | 5 | |
6 | -final class SearchController extends DefaultListController |
|
7 | -{ |
|
6 | +final class SearchController extends DefaultListController |
|
7 | +{ |
|
8 | 8 | |
9 | 9 | private static $TITLE_MAIN = "%s Search | Jacob Emerick's Blog"; |
10 | 10 | private static $DESCRIPTION_MAIN = "Posts containing the phrase %s on Jacob Emerick's Blog."; |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | |
30 | 30 | private $query; |
31 | 31 | |
32 | - public function __construct() |
|
33 | - { |
|
32 | + public function __construct() |
|
33 | + { |
|
34 | 34 | $query = URLDecode::getPiece(2); |
35 | 35 | $query = urldecode($query); |
36 | 36 | $query = str_replace('-', ' ', $query); |
@@ -40,16 +40,15 @@ discard block |
||
40 | 40 | parent::__construct(); |
41 | 41 | } |
42 | 42 | |
43 | - protected function set_head_data() |
|
44 | - { |
|
43 | + protected function set_head_data() |
|
44 | + { |
|
45 | 45 | parent::set_head_data(); |
46 | 46 | |
47 | 47 | if($this->page == 1) |
48 | 48 | { |
49 | 49 | $this->set_title(sprintf(self::$TITLE_MAIN, ucwords($this->query))); |
50 | 50 | $this->set_description(sprintf(self::$DESCRIPTION_MAIN, ucwords($this->query))); |
51 | - } |
|
52 | - else |
|
51 | + } else |
|
53 | 52 | { |
54 | 53 | $this->set_title(sprintf(self::$TITLE_PAGINATED, ucwords($this->query), $this->page, $this->total_pages)); |
55 | 54 | $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages, ucwords($this->query))); |
@@ -60,30 +59,32 @@ discard block |
||
60 | 59 | $this->set_keywords($keyword_array); |
61 | 60 | } |
62 | 61 | |
63 | - protected function get_introduction() |
|
64 | - { |
|
65 | - if($this->total_pages > 1) |
|
66 | - return array( |
|
67 | - 'title' => "Posts from search '{$this->query}', page {$this->page} of {$this->total_pages}."); |
|
68 | - else if($this->total_pages == 1) |
|
69 | - return array( |
|
70 | - 'title' => "Posts from search '{$this->query}'."); |
|
71 | - else |
|
72 | - return array( |
|
73 | - 'title' => "Sorry, '{$this->query}' didn't return any posts."); |
|
62 | + protected function get_introduction() |
|
63 | + { |
|
64 | + if($this->total_pages > 1) { |
|
65 | + return array( |
|
66 | + 'title' => "Posts from search '{$this->query}', page {$this->page} of {$this->total_pages}."); |
|
67 | + } else if($this->total_pages == 1) { |
|
68 | + return array( |
|
69 | + 'title' => "Posts from search '{$this->query}'."); |
|
70 | + } else { |
|
71 | + return array( |
|
72 | + 'title' => "Sorry, '{$this->query}' didn't return any posts."); |
|
73 | + } |
|
74 | 74 | } |
75 | 75 | |
76 | - protected function get_page_number() |
|
77 | - { |
|
76 | + protected function get_page_number() |
|
77 | + { |
|
78 | 78 | $page = URLDecode::getPiece(3); |
79 | - if(isset($page) && is_numeric($page)) |
|
80 | - return $page; |
|
79 | + if(isset($page) && is_numeric($page)) { |
|
80 | + return $page; |
|
81 | + } |
|
81 | 82 | return 1; |
82 | 83 | } |
83 | 84 | |
84 | 85 | private $search_result; |
85 | - private function get_search_result() |
|
86 | - { |
|
86 | + private function get_search_result() |
|
87 | + { |
|
87 | 88 | if(!isset($this->search_result)) |
88 | 89 | { |
89 | 90 | global $container; |
@@ -99,40 +100,44 @@ discard block |
||
99 | 100 | return $this->search_result; |
100 | 101 | } |
101 | 102 | |
102 | - protected function get_list_results() |
|
103 | - { |
|
103 | + protected function get_list_results() |
|
104 | + { |
|
104 | 105 | return array_slice($this->get_search_result(), $this->offset, self::$POSTS_PER_PAGE); |
105 | 106 | } |
106 | 107 | |
107 | - protected function get_list_description() |
|
108 | - { |
|
108 | + protected function get_list_description() |
|
109 | + { |
|
109 | 110 | $start = $this->offset + 1; |
110 | 111 | $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
111 | 112 | |
112 | 113 | return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count(), $this->query); |
113 | 114 | } |
114 | 115 | |
115 | - protected function get_list_next_link() |
|
116 | - { |
|
117 | - if($this->page == 1) |
|
118 | - return; |
|
119 | - if($this->page == 2) |
|
120 | - return Content::instance('URLSafe', "/search/{$this->query}/")->activate(); |
|
116 | + protected function get_list_next_link() |
|
117 | + { |
|
118 | + if($this->page == 1) { |
|
119 | + return; |
|
120 | + } |
|
121 | + if($this->page == 2) { |
|
122 | + return Content::instance('URLSafe', "/search/{$this->query}/")->activate(); |
|
123 | + } |
|
121 | 124 | return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page - 1) . '/')->activate(); |
122 | 125 | } |
123 | 126 | |
124 | - protected function get_list_prev_link() |
|
125 | - { |
|
126 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
127 | - return; |
|
127 | + protected function get_list_prev_link() |
|
128 | + { |
|
129 | + if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) { |
|
130 | + return; |
|
131 | + } |
|
128 | 132 | return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page + 1) . '/')->activate(); |
129 | 133 | } |
130 | 134 | |
131 | 135 | private $total_post_count; |
132 | - protected function get_total_post_count() |
|
133 | - { |
|
134 | - if(!isset($this->total_post_count)) |
|
135 | - $this->total_post_count = count($this->get_search_result()); |
|
136 | + protected function get_total_post_count() |
|
137 | + { |
|
138 | + if(!isset($this->total_post_count)) { |
|
139 | + $this->total_post_count = count($this->get_search_result()); |
|
140 | + } |
|
136 | 141 | return $this->total_post_count; |
137 | 142 | } |
138 | 143 |
@@ -25,7 +25,7 @@ |
||
25 | 25 | { |
26 | 26 | $this->set_body('body_view', 'Resume'); |
27 | 27 | |
28 | - $resumePath = Loader::getRootURL('portfolio') . "/jsonresume/{$this->resume}"; |
|
28 | + $resumePath = Loader::getRootURL('portfolio')."/jsonresume/{$this->resume}"; |
|
29 | 29 | $resume = file_get_contents($resumePath); |
30 | 30 | $resume = json_decode($resume, true); |
31 | 31 | $this->set_body('body_data', $resume); |
@@ -2,13 +2,13 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('controller', 'portfolio/DefaultPageController'); |
4 | 4 | |
5 | -class ResumeController extends DefaultPageController |
|
6 | -{ |
|
5 | +class ResumeController extends DefaultPageController |
|
6 | +{ |
|
7 | 7 | |
8 | 8 | protected $resume = 'resume-20160318.json'; |
9 | 9 | |
10 | - protected function set_head_data() |
|
11 | - { |
|
10 | + protected function set_head_data() |
|
11 | + { |
|
12 | 12 | $this->set_title("Resume | Jacob Emerick's Portfolio"); |
13 | 13 | $this->set_description("Resume for Jacob Emerick, a software engineer extraordinaire"); |
14 | 14 | $this->set_keywords([ |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | ]); |
22 | 22 | } |
23 | 23 | |
24 | - protected function set_body_data() |
|
25 | - { |
|
24 | + protected function set_body_data() |
|
25 | + { |
|
26 | 26 | $this->set_body('body_view', 'Resume'); |
27 | 27 | |
28 | 28 | $resumePath = Loader::getRootURL('portfolio') . "/jsonresume/{$this->resume}"; |
@@ -89,7 +89,7 @@ |
||
89 | 89 | |
90 | 90 | return [ |
91 | 91 | 'success' => |
92 | - "Thank you for your message, {$_POST['name']}! " . |
|
92 | + "Thank you for your message, {$_POST['name']}! ". |
|
93 | 93 | "I'll get back to you as soon as possible." |
94 | 94 | ]; |
95 | 95 | } |
@@ -2,11 +2,11 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('controller', 'portfolio/DefaultPageController'); |
4 | 4 | |
5 | -class ContactController extends DefaultPageController |
|
6 | -{ |
|
5 | +class ContactController extends DefaultPageController |
|
6 | +{ |
|
7 | 7 | |
8 | - protected function set_head_data() |
|
9 | - { |
|
8 | + protected function set_head_data() |
|
9 | + { |
|
10 | 10 | $this->set_title("Contact Page | Jacob Emerick's Portfolio"); |
11 | 11 | $this->set_description("Contact page for Jacob Emerick's Portfolio"); |
12 | 12 | $this->set_keywords([ |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | ]); |
20 | 20 | } |
21 | 21 | |
22 | - protected function set_body_data() |
|
23 | - { |
|
22 | + protected function set_body_data() |
|
23 | + { |
|
24 | 24 | $this->set_body('body_view', 'Contact'); |
25 | 25 | |
26 | 26 | $body_data = []; |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | parent::set_body_data(); |
34 | 34 | } |
35 | 35 | |
36 | - private function process_form_data() |
|
37 | - { |
|
36 | + private function process_form_data() |
|
37 | + { |
|
38 | 38 | $errors = []; |
39 | 39 | |
40 | 40 | if ( |
@@ -33,15 +33,15 @@ discard block |
||
33 | 33 | ], |
34 | 34 | [ |
35 | 35 | 'name' => 'Projects', |
36 | - 'link' => Loader::getRootURL() . 'projects/', |
|
36 | + 'link' => Loader::getRootURL().'projects/', |
|
37 | 37 | ], |
38 | 38 | [ |
39 | 39 | 'name' => 'Résumé', |
40 | - 'link' => Loader::getRootURL() . 'resume/', |
|
40 | + 'link' => Loader::getRootURL().'resume/', |
|
41 | 41 | ], |
42 | 42 | [ |
43 | 43 | 'name' => 'Contact', |
44 | - 'link' => Loader::getRootURL() . 'contact/', |
|
44 | + 'link' => Loader::getRootURL().'contact/', |
|
45 | 45 | ], |
46 | 46 | ]; |
47 | 47 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $active_page = ucfirst(URLDecode::getPiece(1)); |
52 | 52 | } |
53 | 53 | |
54 | - return array_map(function ($row) use ($active_page) { |
|
54 | + return array_map(function($row) use ($active_page) { |
|
55 | 55 | $row = (object) $row; |
56 | 56 | $row->active = ($row->name == $active_page); |
57 | 57 | return $row; |
@@ -2,19 +2,19 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('controller', '/PageController'); |
4 | 4 | |
5 | -abstract class DefaultPageController extends PageController |
|
6 | -{ |
|
5 | +abstract class DefaultPageController extends PageController |
|
6 | +{ |
|
7 | 7 | |
8 | - public function __construct() |
|
9 | - { |
|
8 | + public function __construct() |
|
9 | + { |
|
10 | 10 | parent::__construct(); |
11 | 11 | |
12 | 12 | $this->add_css('reset'); |
13 | 13 | $this->add_css('portfolio', 4); |
14 | 14 | } |
15 | 15 | |
16 | - protected function set_body_data() |
|
17 | - { |
|
16 | + protected function set_body_data() |
|
17 | + { |
|
18 | 18 | $this->set_body('header_data', [ |
19 | 19 | 'menu' => $this->get_menu(), |
20 | 20 | 'home_link' => Loader::getRootURL(), |
@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | $this->set_body_view('Page'); |
25 | 25 | } |
26 | 26 | |
27 | - protected function get_menu() |
|
28 | - { |
|
27 | + protected function get_menu() |
|
28 | + { |
|
29 | 29 | $menu = [ |
30 | 30 | [ |
31 | 31 | 'name' => 'About', |
@@ -2,8 +2,8 @@ |
||
2 | 2 | |
3 | 3 | namespace Jacobemerick\Web\Domain\Comment\Comment; |
4 | 4 | |
5 | -interface CommentRepositoryInterface |
|
6 | -{ |
|
5 | +interface CommentRepositoryInterface |
|
6 | +{ |
|
7 | 7 | public function createComment(array $comment); |
8 | 8 | public function getComment($commentId); |
9 | 9 | public function getComments($domain = null, $path = null, $page = null, $perPage = null, $order = null); |
@@ -2,8 +2,8 @@ |
||
2 | 2 | |
3 | 3 | namespace Jacobemerick\Web\Domain\Comment\Commenter; |
4 | 4 | |
5 | -interface CommenterRepositoryInterface |
|
6 | -{ |
|
5 | +interface CommenterRepositoryInterface |
|
6 | +{ |
|
7 | 7 | public function createCommenter(array $commenter); |
8 | 8 | public function getCommenter($commenterId); |
9 | 9 | public function getCommenters($page = null, $perPage = null); |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | namespace Jacobemerick\Web\Domain\Waterfall\County; |
4 | 4 | |
5 | -interface CountyRepositoryInterface |
|
6 | -{ |
|
5 | +interface CountyRepositoryInterface |
|
6 | +{ |
|
7 | 7 | public function getCountyList(); |
8 | 8 | } |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | namespace Jacobemerick\Web\Domain\Waterfall\Period; |
4 | 4 | |
5 | -interface PeriodRepositoryInterface |
|
6 | -{ |
|
5 | +interface PeriodRepositoryInterface |
|
6 | +{ |
|
7 | 7 | public function getPeriodList(); |
8 | 8 | } |