@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | Loader::load('collector', 'waterfall/LogCollector'); |
4 | 4 | Loader::load('controller', 'blog/DefaultPageController'); |
5 | 5 | |
6 | -final class PostController extends DefaultPageController |
|
7 | -{ |
|
6 | +final class PostController extends DefaultPageController |
|
7 | +{ |
|
8 | 8 | |
9 | 9 | private static $PAGE_DESCRIPTION_LIMIT = 250; |
10 | 10 | |
@@ -19,16 +19,17 @@ discard block |
||
19 | 19 | private $tags; |
20 | 20 | private $comment_errors = array(); |
21 | 21 | |
22 | - public function __construct() |
|
23 | - { |
|
22 | + public function __construct() |
|
23 | + { |
|
24 | 24 | parent::__construct(); |
25 | 25 | |
26 | 26 | global $container; |
27 | 27 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
28 | 28 | $this->post = $repository->findPostByPath(URLDecode::getPiece(2)); |
29 | 29 | |
30 | - if($this->post == null) |
|
31 | - $this->eject(); |
|
30 | + if($this->post == null) { |
|
31 | + $this->eject(); |
|
32 | + } |
|
32 | 33 | |
33 | 34 | $this->handle_comment_submit( |
34 | 35 | self::$BLOG_SITE_ID, |
@@ -41,8 +42,8 @@ discard block |
||
41 | 42 | $this->tags = $repository->getTagsForPost($this->post['id']); |
42 | 43 | } |
43 | 44 | |
44 | - protected function set_head_data() |
|
45 | - { |
|
45 | + protected function set_head_data() |
|
46 | + { |
|
46 | 47 | parent::set_head_data(); |
47 | 48 | |
48 | 49 | $this->set_title(sprintf(self::$TITLE, $this->post['title'])); |
@@ -64,10 +65,12 @@ discard block |
||
64 | 65 | } |
65 | 66 | } |
66 | 67 | |
67 | - protected function get_introduction() {} |
|
68 | + protected function get_introduction() |
|
69 | + { |
|
70 | +} |
|
68 | 71 | |
69 | - protected function set_body_data() |
|
70 | - { |
|
72 | + protected function set_body_data() |
|
73 | + { |
|
71 | 74 | parent::set_body_data(); |
72 | 75 | |
73 | 76 | $this->set_body('title', $this->post['title']); |
@@ -82,8 +85,8 @@ discard block |
||
82 | 85 | )); |
83 | 86 | } |
84 | 87 | |
85 | - protected function get_post_description() |
|
86 | - { |
|
88 | + protected function get_post_description() |
|
89 | + { |
|
87 | 90 | $description = $this->post['body']; |
88 | 91 | $description = strip_tags($description); |
89 | 92 | $description = Content::instance('SmartTrim', $description)->activate(self::$PAGE_DESCRIPTION_LIMIT); |
@@ -91,8 +94,8 @@ discard block |
||
91 | 94 | return $description; |
92 | 95 | } |
93 | 96 | |
94 | - protected function get_post_keywords() |
|
95 | - { |
|
97 | + protected function get_post_keywords() |
|
98 | + { |
|
96 | 99 | $keyword_array = array(); |
97 | 100 | $keywords = $this->tags; |
98 | 101 | |
@@ -107,11 +110,12 @@ discard block |
||
107 | 110 | return $keyword_array; |
108 | 111 | } |
109 | 112 | |
110 | - private function get_series_posts() |
|
111 | - { |
|
113 | + private function get_series_posts() |
|
114 | + { |
|
112 | 115 | $series_posts = $this->fetch_series_posts(); |
113 | - if(count($series_posts) < 1) |
|
114 | - return array(); |
|
116 | + if(count($series_posts) < 1) { |
|
117 | + return array(); |
|
118 | + } |
|
115 | 119 | |
116 | 120 | $previous_post = new stdclass(); |
117 | 121 | $next_post = new stdclass(); |
@@ -150,9 +154,9 @@ discard block |
||
150 | 154 | |
151 | 155 | $post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/"; |
152 | 156 | |
153 | - if(!$found_current_post) |
|
154 | - $previous_post = $post; |
|
155 | - else |
|
157 | + if(!$found_current_post) { |
|
158 | + $previous_post = $post; |
|
159 | + } else |
|
156 | 160 | { |
157 | 161 | $next_post = $post; |
158 | 162 | break; |
@@ -167,8 +171,8 @@ discard block |
||
167 | 171 | } |
168 | 172 | |
169 | 173 | private $series_posts; |
170 | - private function fetch_series_posts() |
|
171 | - { |
|
174 | + private function fetch_series_posts() |
|
175 | + { |
|
172 | 176 | if(!isset($this->series_posts)) { |
173 | 177 | global $container; |
174 | 178 | $repository = new Jacobemerick\Web\Domain\Blog\Series\MysqlSeriesRepository($container['db_connection_locator']); |
@@ -177,8 +181,8 @@ discard block |
||
177 | 181 | return $this->series_posts; |
178 | 182 | } |
179 | 183 | |
180 | - private function get_related_posts() |
|
181 | - { |
|
184 | + private function get_related_posts() |
|
185 | + { |
|
182 | 186 | $tag_array = array(); |
183 | 187 | foreach($this->tags as $tag) |
184 | 188 | { |
@@ -213,8 +217,8 @@ discard block |
||
213 | 217 | return $post_array; |
214 | 218 | } |
215 | 219 | |
216 | - protected function get_comment_array($path) |
|
217 | - { |
|
220 | + protected function get_comment_array($path) |
|
221 | + { |
|
218 | 222 | global $config; |
219 | 223 | $configuration = new Jacobemerick\CommentService\Configuration(); |
220 | 224 | $configuration->setUsername($config->comments->user); |
@@ -5,8 +5,8 @@ discard block |
||
5 | 5 | Loader::load('controller', '/PageController'); |
6 | 6 | Loader::load('utility', 'Content'); |
7 | 7 | |
8 | -abstract class DefaultPageController extends PageController |
|
9 | -{ |
|
8 | +abstract class DefaultPageController extends PageController |
|
9 | +{ |
|
10 | 10 | |
11 | 11 | private static $RECENT_COMMENT_COUNT = 10; |
12 | 12 | private static $MINIMUM_TAG_COUNT = 10; |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | |
17 | 17 | private static $INTRODUCTION_IMAGE_PATTERN = '<img src="/photo/%s/%s-size-%s.jpg" height="%d" width="%d" alt="%s" />'; |
18 | 18 | |
19 | - protected function set_head_data() |
|
20 | - { |
|
19 | + protected function set_head_data() |
|
20 | + { |
|
21 | 21 | $this->set_head('rss_link', [ |
22 | 22 | 'title' => 'Jacob Emerick Blog Feed', |
23 | 23 | 'url' => '/rss.xml' |
@@ -31,18 +31,19 @@ discard block |
||
31 | 31 | $this->add_css('blog'); |
32 | 32 | } |
33 | 33 | |
34 | - protected function get_introduction() |
|
35 | - { |
|
34 | + protected function get_introduction() |
|
35 | + { |
|
36 | 36 | return; |
37 | 37 | } |
38 | 38 | |
39 | - protected function get_introduction_image($id) |
|
40 | - { |
|
39 | + protected function get_introduction_image($id) |
|
40 | + { |
|
41 | 41 | Loader::load('collector', 'image/PhotoCollector'); |
42 | 42 | $photo_result = PhotoCollector::getRow($id); |
43 | 43 | |
44 | - if($photo_result == null) |
|
45 | - return; |
|
44 | + if($photo_result == null) { |
|
45 | + return; |
|
46 | + } |
|
46 | 47 | |
47 | 48 | $name = $photo_result->name; |
48 | 49 | $category = $photo_result->category; |
@@ -54,8 +55,8 @@ discard block |
||
54 | 55 | return sprintf(self::$INTRODUCTION_IMAGE_PATTERN, $category, $name, $size, $height, $width, $description); |
55 | 56 | } |
56 | 57 | |
57 | - protected function set_body_data() |
|
58 | - { |
|
58 | + protected function set_body_data() |
|
59 | + { |
|
59 | 60 | $this->set_body('introduction', $this->get_introduction()); |
60 | 61 | $this->set_body('right_side', $this->get_right_side()); |
61 | 62 | $this->set_body('activity_array', $this->get_recent_activity()); |
@@ -63,8 +64,8 @@ discard block |
||
63 | 64 | $this->set_body_view('Page'); |
64 | 65 | } |
65 | 66 | |
66 | - final protected function format_post($post, $trim = false) |
|
67 | - { |
|
67 | + final protected function format_post($post, $trim = false) |
|
68 | + { |
|
68 | 69 | $post_object = new stdclass(); |
69 | 70 | |
70 | 71 | $post_object->title = $post['title']; |
@@ -80,8 +81,8 @@ discard block |
||
80 | 81 | return $post_object; |
81 | 82 | } |
82 | 83 | |
83 | - final private function get_comments_for_post($post) |
|
84 | - { |
|
84 | + final private function get_comments_for_post($post) |
|
85 | + { |
|
85 | 86 | $count = CommentCollector::getCommentCountForURL(self::$BLOG_SITE_ID, $post['path']); |
86 | 87 | $count_from_service = $this->get_comments_for_post_from_service($post); |
87 | 88 | |
@@ -93,8 +94,8 @@ discard block |
||
93 | 94 | return $count; |
94 | 95 | } |
95 | 96 | |
96 | - final private function get_comments_for_post_from_service($post) |
|
97 | - { |
|
97 | + final private function get_comments_for_post_from_service($post) |
|
98 | + { |
|
98 | 99 | global $config; |
99 | 100 | $configuration = new Jacobemerick\CommentService\Configuration(); |
100 | 101 | $configuration->setUsername($config->comments->user); |
@@ -127,8 +128,8 @@ discard block |
||
127 | 128 | return count($comment_response); |
128 | 129 | } |
129 | 130 | |
130 | - final private function get_tags_for_post($post) |
|
131 | - { |
|
131 | + final private function get_tags_for_post($post) |
|
132 | + { |
|
132 | 133 | global $container; |
133 | 134 | $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
134 | 135 | $tag_result = $repository->getTagsForPost($post['id']); |
@@ -144,12 +145,13 @@ discard block |
||
144 | 145 | return $tag_array; |
145 | 146 | } |
146 | 147 | |
147 | - final private function get_body_for_post($post, $trim) |
|
148 | - { |
|
148 | + final private function get_body_for_post($post, $trim) |
|
149 | + { |
|
149 | 150 | $body = $post['body']; |
150 | 151 | |
151 | - if($trim) |
|
152 | - $body = Content::instance('SmartTrim', $body)->activate(self::$LENGTH_OF_TRIMMED_POST); |
|
152 | + if($trim) { |
|
153 | + $body = Content::instance('SmartTrim', $body)->activate(self::$LENGTH_OF_TRIMMED_POST); |
|
154 | + } |
|
153 | 155 | |
154 | 156 | $body = Content::instance('FixPhoto', $body)->activate(false, 'standard'); |
155 | 157 | $body = Content::instance('MarkupCode', $body)->activate(); |
@@ -157,16 +159,16 @@ discard block |
||
157 | 159 | return $body; |
158 | 160 | } |
159 | 161 | |
160 | - final protected function get_right_side() |
|
161 | - { |
|
162 | + final protected function get_right_side() |
|
163 | + { |
|
162 | 164 | $side_array = array(); |
163 | 165 | $side_array['tags'] = $this->get_tag_cloud(); |
164 | 166 | $side_array['comments'] = $this->get_comments(); |
165 | 167 | return $side_array; |
166 | 168 | } |
167 | 169 | |
168 | - final private function get_tag_cloud() |
|
169 | - { |
|
170 | + final private function get_tag_cloud() |
|
171 | + { |
|
170 | 172 | global $container; |
171 | 173 | $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
172 | 174 | $tag_result = $repository->getTagCloud(); |
@@ -176,8 +178,9 @@ discard block |
||
176 | 178 | $cloud_array = array(); |
177 | 179 | foreach($tag_result as $tag) |
178 | 180 | { |
179 | - if($tag['count'] < self::$MINIMUM_TAG_COUNT) |
|
180 | - continue; |
|
181 | + if($tag['count'] < self::$MINIMUM_TAG_COUNT) { |
|
182 | + continue; |
|
183 | + } |
|
181 | 184 | |
182 | 185 | $tag_object = new stdclass(); |
183 | 186 | $tag_object->name = $tag['tag']; |
@@ -189,20 +192,21 @@ discard block |
||
189 | 192 | return $cloud_array; |
190 | 193 | } |
191 | 194 | |
192 | - final private function get_maximum_tag_count($tag_result) |
|
193 | - { |
|
195 | + final private function get_maximum_tag_count($tag_result) |
|
196 | + { |
|
194 | 197 | $maximum = 1; |
195 | 198 | |
196 | 199 | foreach($tag_result as $tag) |
197 | 200 | { |
198 | - if($tag['count'] > $maximum) |
|
199 | - $maximum = $tag['count']; |
|
201 | + if($tag['count'] > $maximum) { |
|
202 | + $maximum = $tag['count']; |
|
203 | + } |
|
200 | 204 | } |
201 | 205 | return $maximum; |
202 | 206 | } |
203 | 207 | |
204 | - final private function get_comments() |
|
205 | - { |
|
208 | + final private function get_comments() |
|
209 | + { |
|
206 | 210 | $comment_array = CommentCollector::getRecentBlogComments(self::$RECENT_COMMENT_COUNT); |
207 | 211 | |
208 | 212 | $array = array(); |
@@ -228,8 +232,8 @@ discard block |
||
228 | 232 | return $array; |
229 | 233 | } |
230 | 234 | |
231 | - final private function get_comments_from_service() |
|
232 | - { |
|
235 | + final private function get_comments_from_service() |
|
236 | + { |
|
233 | 237 | global $config; |
234 | 238 | $configuration = new Jacobemerick\CommentService\Configuration(); |
235 | 239 | $configuration->setUsername($config->comments->user); |
@@ -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']); |
@@ -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 |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('controller', 'blog/DefaultListController'); |
4 | 4 | |
5 | -final class TagController extends DefaultListController |
|
6 | -{ |
|
5 | +final class TagController extends DefaultListController |
|
6 | +{ |
|
7 | 7 | |
8 | 8 | private static $TITLE_MAIN = "%s Tag | Jacob Emerick's Blog"; |
9 | 9 | private static $DESCRIPTION_MAIN = "Posts tagged with %s on Jacob Emerick's Blog, a website about Upper Peninsula hiking and web development best practices."; |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | |
22 | 22 | private $tag; |
23 | 23 | |
24 | - public function __construct() |
|
25 | - { |
|
24 | + public function __construct() |
|
25 | + { |
|
26 | 26 | $tag = URLDecode::getPiece(2); |
27 | 27 | $tag = str_replace('-', ' ', $tag); |
28 | 28 | |
@@ -30,24 +30,24 @@ discard block |
||
30 | 30 | $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
31 | 31 | $tag_result = $repository->findTagByTitle($tag); |
32 | 32 | |
33 | - if($tag_result === false) |
|
34 | - $this->eject(); |
|
33 | + if($tag_result === false) { |
|
34 | + $this->eject(); |
|
35 | + } |
|
35 | 36 | |
36 | 37 | $this->tag = $tag_result; |
37 | 38 | |
38 | 39 | parent::__construct(); |
39 | 40 | } |
40 | 41 | |
41 | - protected function set_head_data() |
|
42 | - { |
|
42 | + protected function set_head_data() |
|
43 | + { |
|
43 | 44 | parent::set_head_data(); |
44 | 45 | |
45 | 46 | if($this->page == 1) |
46 | 47 | { |
47 | 48 | $this->set_title(sprintf(self::$TITLE_MAIN, ucwords($this->tag['tag']))); |
48 | 49 | $this->set_description(sprintf(self::$DESCRIPTION_MAIN, ucwords($this->tag['tag']))); |
49 | - } |
|
50 | - else |
|
50 | + } else |
|
51 | 51 | { |
52 | 52 | $this->set_title(sprintf(self::$TITLE_PAGINATED, ucwords($this->tag['tag']), $this->page, $this->total_pages)); |
53 | 53 | $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages, ucwords($this->tag['tag']))); |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | $this->set_keywords($keyword_array); |
59 | 59 | } |
60 | 60 | |
61 | - protected function get_introduction() |
|
62 | - { |
|
61 | + protected function get_introduction() |
|
62 | + { |
|
63 | 63 | $tag = ucwords($this->tag['tag']); |
64 | 64 | |
65 | 65 | if($this->page == 1) |
@@ -86,48 +86,52 @@ discard block |
||
86 | 86 | 'title' => "{$tag} posts, page {$this->page} of {$this->total_pages}."); |
87 | 87 | } |
88 | 88 | |
89 | - protected function get_page_number() |
|
90 | - { |
|
89 | + protected function get_page_number() |
|
90 | + { |
|
91 | 91 | $page = URLDecode::getPiece(3); |
92 | - if(isset($page) && is_numeric($page)) |
|
93 | - return $page; |
|
92 | + if(isset($page) && is_numeric($page)) { |
|
93 | + return $page; |
|
94 | + } |
|
94 | 95 | return 1; |
95 | 96 | } |
96 | 97 | |
97 | - protected function get_list_results() |
|
98 | - { |
|
98 | + protected function get_list_results() |
|
99 | + { |
|
99 | 100 | global $container; |
100 | 101 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
101 | 102 | return $repository->getActivePostsByTag($this->tag['id'], self::$POSTS_PER_PAGE, $this->offset); |
102 | 103 | } |
103 | 104 | |
104 | - protected function get_list_description() |
|
105 | - { |
|
105 | + protected function get_list_description() |
|
106 | + { |
|
106 | 107 | $start = $this->offset + 1; |
107 | 108 | $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
108 | 109 | |
109 | 110 | return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count(), $this->tag['tag']); |
110 | 111 | } |
111 | 112 | |
112 | - protected function get_list_next_link() |
|
113 | - { |
|
114 | - if($this->page == 1) |
|
115 | - return; |
|
116 | - if($this->page == 2) |
|
117 | - return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/")->activate(); |
|
113 | + protected function get_list_next_link() |
|
114 | + { |
|
115 | + if($this->page == 1) { |
|
116 | + return; |
|
117 | + } |
|
118 | + if($this->page == 2) { |
|
119 | + return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/")->activate(); |
|
120 | + } |
|
118 | 121 | return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/" . ($this->page - 1) . '/')->activate(); |
119 | 122 | } |
120 | 123 | |
121 | - protected function get_list_prev_link() |
|
122 | - { |
|
123 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
124 | - return; |
|
124 | + protected function get_list_prev_link() |
|
125 | + { |
|
126 | + if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) { |
|
127 | + return; |
|
128 | + } |
|
125 | 129 | return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/" . ($this->page + 1) . '/')->activate(); |
126 | 130 | } |
127 | 131 | |
128 | 132 | private $total_post_count; |
129 | - protected function get_total_post_count() |
|
130 | - { |
|
133 | + protected function get_total_post_count() |
|
134 | + { |
|
131 | 135 | if(!isset($this->total_post_count)) { |
132 | 136 | global $container; |
133 | 137 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('controller', 'blog/DefaultPageController'); |
4 | 4 | |
5 | -final class AboutController extends DefaultPageController |
|
6 | -{ |
|
5 | +final class AboutController extends DefaultPageController |
|
6 | +{ |
|
7 | 7 | |
8 | 8 | private static $TITLE = 'About the Blog | Jacob Emerick'; |
9 | 9 | private static $DESCRIPTION = "A little bit about the awesomeness on Jacob Emerick's Blog, diving into the topics covered, technology used, and methodology of writing new posts."; |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | 'blog', |
16 | 16 | 'Jacob Emerick'); |
17 | 17 | |
18 | - protected function set_head_data() |
|
19 | - { |
|
18 | + protected function set_head_data() |
|
19 | + { |
|
20 | 20 | $this->set_title(self::$TITLE); |
21 | 21 | $this->set_description(self::$DESCRIPTION); |
22 | 22 | $this->set_keywords(self::$KEYWORD_ARRAY); |
@@ -24,15 +24,15 @@ discard block |
||
24 | 24 | parent::set_head_data(); |
25 | 25 | } |
26 | 26 | |
27 | - protected function set_body_data() |
|
28 | - { |
|
27 | + protected function set_body_data() |
|
28 | + { |
|
29 | 29 | $this->set_body('view', 'About'); |
30 | 30 | |
31 | 31 | parent::set_body_data(); |
32 | 32 | } |
33 | 33 | |
34 | - protected function get_introduction() |
|
35 | - { |
|
34 | + protected function get_introduction() |
|
35 | + { |
|
36 | 36 | global $container; |
37 | 37 | $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
38 | 38 | $introduction_result = $repository->findByType('about'); |
@@ -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}"; |
@@ -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,11 +2,11 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('controller', 'portfolio/DefaultPageController'); |
4 | 4 | |
5 | -class ProjectsController extends DefaultPageController |
|
6 | -{ |
|
5 | +class ProjectsController extends DefaultPageController |
|
6 | +{ |
|
7 | 7 | |
8 | - protected function set_head_data() |
|
9 | - { |
|
8 | + protected function set_head_data() |
|
9 | + { |
|
10 | 10 | $this->set_title("Projects Page | Jacob Emerick's Portfolio"); |
11 | 11 | $this->set_description("Collection of key open-source projects that Jacob has developed and maintained over the years."); |
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', 'Projects'); |
25 | 25 | $this->set_body('body_data', []); |
26 | 26 |